diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-03-05 21:12:31 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-03-05 21:12:31 +0000 |
commit | e1244a0dff7815ad325ae433bc890275916b4fe8 (patch) | |
tree | 9c69167fa5877951028b6addecccc20dc13ae0b5 /utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp | |
parent | 6538326ef2a46c11fa87e50cb7906e21cb6c42a4 (diff) | |
download | rockbox-e1244a0dff7815ad325ae433bc890275916b4fe8.tar.gz rockbox-e1244a0dff7815ad325ae433bc890275916b4fe8.zip |
Remove outdated and unmaintained wpseditor.
The wpseditor is superseded by the Theme Editor these days.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29528 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp')
-rw-r--r-- | utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp deleted file mode 100644 index ebda9b2c31..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
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 | #include "QVariantDelegate.h" | ||
26 | |||
27 | #include "Property.h" | ||
28 | |||
29 | #include <Qt/qabstractitemview.h> | ||
30 | |||
31 | |||
32 | QVariantDelegate::QVariantDelegate(QObject* parent) : QItemDelegate(parent) {} | ||
33 | |||
34 | |||
35 | QVariantDelegate::~QVariantDelegate() {} | ||
36 | |||
37 | QWidget *QVariantDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem& option , const QModelIndex & index ) const { | ||
38 | QWidget* editor = 0; | ||
39 | Property* p = static_cast<Property*>(index.internalPointer()); | ||
40 | switch (p->value().type()) { | ||
41 | case QVariant::Color: | ||
42 | case QVariant::Int: | ||
43 | case QMetaType::Float: | ||
44 | case QVariant::Double: | ||
45 | case QVariant::UserType: | ||
46 | editor = p->createEditor(parent, option); | ||
47 | if (editor) break; // if no editor could be created take default case | ||
48 | default: | ||
49 | editor = QItemDelegate::createEditor(parent, option, index); | ||
50 | } | ||
51 | parseEditorHints(editor, p->editorHints()); | ||
52 | return editor; | ||
53 | } | ||
54 | |||
55 | void QVariantDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { | ||
56 | QVariant data = index.model()->data(index, Qt::EditRole); | ||
57 | switch (data.type()) { | ||
58 | case QVariant::Color: | ||
59 | case QMetaType::Double: | ||
60 | case QMetaType::Float: | ||
61 | case QVariant::UserType: | ||
62 | if (static_cast<Property*>(index.internalPointer())->setEditorData(editor, data)) // if editor couldn't be recognized use default | ||
63 | break; | ||
64 | default: | ||
65 | QItemDelegate::setEditorData(editor, index); | ||
66 | break; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | void QVariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { | ||
71 | QVariant data = index.model()->data(index, Qt::EditRole); | ||
72 | switch (data.type()) { | ||
73 | case QVariant::Color: | ||
74 | case QMetaType::Double: | ||
75 | case QMetaType::Float: | ||
76 | case QVariant::UserType: { | ||
77 | QVariant data = static_cast<Property*>(index.internalPointer())->editorData(editor); | ||
78 | if (data.isValid()) { | ||
79 | model->setData(index, data , Qt::EditRole); | ||
80 | break; | ||
81 | } | ||
82 | } | ||
83 | default: | ||
84 | QItemDelegate::setModelData(editor, model, index); | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | void QVariantDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index ) const { | ||
90 | return QItemDelegate::updateEditorGeometry(editor, option, index); | ||
91 | } | ||
92 | |||
93 | void QVariantDelegate::parseEditorHints(QWidget* editor, const QString& editorHints) const { | ||
94 | if (editor && !editorHints.isEmpty()) { | ||
95 | // Parse for property values | ||
96 | QRegExp rx("(.*)(=\\s*)(.*)(;{1})"); | ||
97 | rx.setMinimal(true); | ||
98 | int pos = 0; | ||
99 | while ((pos = rx.indexIn(editorHints, pos)) != -1) { | ||
100 | qDebug("Setting %s to %s", qPrintable(rx.cap(1)), qPrintable(rx.cap(3))); | ||
101 | editor->setProperty(qPrintable(rx.cap(1).trimmed()), rx.cap(3).trimmed()); | ||
102 | pos += rx.matchedLength(); | ||
103 | } | ||
104 | } | ||
105 | } | ||