diff options
Diffstat (limited to 'utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h')
-rw-r--r-- | utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h new file mode 100644 index 0000000000..e06265af82 --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h | |||
@@ -0,0 +1,78 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #ifndef COLORSELECTIONBUTTON_H_ | ||
26 | #define COLORSELECTIONBUTTON_H_ | ||
27 | |||
28 | #include <Qt/qitemdelegate.h> | ||
29 | |||
30 | |||
31 | /** | ||
32 | * This class is used to create the editor widgets for datatypes encapsulated in QVariant variables | ||
33 | */ | ||
34 | class QVariantDelegate : public QItemDelegate { | ||
35 | Q_OBJECT | ||
36 | |||
37 | public: | ||
38 | /** | ||
39 | * Constructor | ||
40 | * @param parent optional parent object | ||
41 | */ | ||
42 | QVariantDelegate(QObject* parent = 0); | ||
43 | /// Destructor | ||
44 | virtual ~QVariantDelegate(); | ||
45 | |||
46 | /** | ||
47 | * Creates an editor widget as child of a given widget for a specific QModelIndex | ||
48 | * | ||
49 | * @param parent the parent widget for the editor | ||
50 | * @param option some style options that the editor should use | ||
51 | * @param index the index of the item the editor will be created for | ||
52 | * @return QWidget the editor widget | ||
53 | */ | ||
54 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
55 | |||
56 | /** | ||
57 | * Tries to set the editor data based on the value stored at a specific QModelIndex | ||
58 | * @param editor the editor widget | ||
59 | * @param index the model index of the value that should be used in the editor | ||
60 | */ | ||
61 | virtual void setEditorData(QWidget *editor, const QModelIndex &index) const; | ||
62 | |||
63 | /** | ||
64 | * Sets the data of a specific QModelIndex to tha value of the editor widget | ||
65 | * @param editor the editor widget that contains the new value | ||
66 | * @param model the model that contains the index | ||
67 | * @param index the index within the model whose data value should be set to the data value of the editor | ||
68 | */ | ||
69 | virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; | ||
70 | |||
71 | /// QItemDelegate implementation | ||
72 | virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
73 | |||
74 | protected: | ||
75 | void parseEditorHints(QWidget* editor, const QString& editorHints) const; | ||
76 | |||
77 | }; | ||
78 | #endif | ||