]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/InsetParamsWidget.h
More GuiInfo usability work
[lyx.git] / src / frontends / qt4 / InsetParamsWidget.h
1 // -*- C++ -*-
2 /**
3  * \file InsetParamsWidget.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_PARAMS_WIDGET_H
13 #define INSET_PARAMS_WIDGET_H
14
15 #include "insets/InsetCode.h"
16 #include "insets/Inset.h"
17
18 #include "qt_helpers.h"
19
20 #include "FuncCode.h"
21
22 #include "support/strfwd.h"
23
24 #include <QWidget>
25
26 class QLineEdit;
27
28 namespace lyx {
29
30 class Inset;
31
32 namespace frontend {
33
34 /// CheckedWidget
35 // FIXME: Get rid of CheckedLineEdit in ButtonController and rename this one
36 // to it.
37 class CheckedWidget
38 {
39 public:
40         CheckedWidget(QLineEdit * input, QWidget * label = 0);
41         ///
42         bool check() const;
43
44 private:
45         // non-owned
46         QLineEdit * input_;
47         QWidget * label_;
48 };
49
50
51 typedef QList<CheckedWidget> CheckedWidgets;
52
53 class InsetParamsWidget : public QWidget
54 {
55         Q_OBJECT
56
57 Q_SIGNALS:
58         void changed();
59 public:
60         InsetParamsWidget(QWidget * parent);
61         /// This is a base class; destructor must exist and be virtual.
62         virtual ~InsetParamsWidget() {}
63         ///
64         virtual QString dialogTitle() const { return toqstr(insetName(insetCode())); }
65         ///
66         virtual InsetCode insetCode() const = 0;
67         ///
68         virtual FuncCode creationCode() const = 0;
69         ///
70         virtual void paramsToDialog(Inset const *) = 0;
71         ///
72         virtual docstring dialogToParams() const = 0;
73         ///
74         virtual bool initialiseParams(std::string const & /*data*/)
75                 { return false; }
76
77         /// \return true if all CheckedWidgets are in a valid state.
78         virtual bool checkWidgets(bool readonly = false) const;
79
80 protected:
81         /// Add a widget to the list of all widgets whose validity should
82         /// be checked explicitly when the buttons are refreshed.
83         void addCheckedWidget(QLineEdit * input, QWidget * label = 0);
84 private:
85         ///
86         CheckedWidgets checked_widgets_;
87 };
88
89 } // namespace frontend
90 } // namespace lyx
91
92 #endif // INSET_PARAMS_WIDGET_H