summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2009-03-12 15:19:27 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2009-03-12 15:19:27 (GMT)
commitc54f47635c7f4eda101cc092605481efb9e5275d (patch)
tree2157d540e011660f7d3db31ffb4b7929f3fc61c2 /Source
parentdd7b48c9c386ffd7fa184284403988df85a38279 (diff)
downloadCMake-c54f47635c7f4eda101cc092605481efb9e5275d.zip
CMake-c54f47635c7f4eda101cc092605481efb9e5275d.tar.gz
CMake-c54f47635c7f4eda101cc092605481efb9e5275d.tar.bz2
ENH: Add support for showing combo box for choosing from a list of strings that a cache property can have.
Diffstat (limited to 'Source')
-rw-r--r--Source/QtDialog/QCMake.cxx4
-rw-r--r--Source/QtDialog/QCMake.h1
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx20
-rw-r--r--Source/QtDialog/QCMakeCacheView.h3
-rw-r--r--Source/QtDialog/QCMakeWidgets.h21
5 files changed, 46 insertions, 3 deletions
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index dd1608e..f007160 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -286,6 +286,10 @@ QCMakePropertyList QCMake::properties() const
else if(i.GetType() == cmCacheManager::STRING)
{
prop.Type = QCMakeProperty::STRING;
+ if (i.PropertyExists("STRINGS"))
+ {
+ prop.Strings = QString(i.GetProperty("STRINGS")).split(";");
+ }
}
ret.append(prop);
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 909c1ac..05cd7eb 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -38,6 +38,7 @@ struct QCMakeProperty
enum PropertyType { BOOL, PATH, FILEPATH, STRING };
QString Key;
QVariant Value;
+ QStringList Strings;
QString Help;
PropertyType Type;
bool Advanced;
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index 5191f92..585843d 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -365,6 +365,11 @@ void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
}
this->setData(idx2, prop.Help, QCMakeCacheModel::HelpRole);
+ if (!prop.Strings.isEmpty())
+ {
+ this->setData(idx1, prop.Strings, QCMakeCacheModel::StringsRole);
+ }
+
if(isNew)
{
this->setData(idx1, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
@@ -381,6 +386,7 @@ void QCMakeCacheModel::getPropertyData(const QModelIndex& idx1,
prop.Help = this->data(idx1, HelpRole).toString();
prop.Type = static_cast<QCMakeProperty::PropertyType>(this->data(idx1, TypeRole).toInt());
prop.Advanced = this->data(idx1, AdvancedRole).toBool();
+ prop.Strings = this->data(idx1, QCMakeCacheModel::StringsRole).toStringList();
if(prop.Type == QCMakeProperty::BOOL)
{
int check = this->data(idx2, Qt::CheckStateRole).toInt();
@@ -572,10 +578,20 @@ QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p,
SLOT(setFileDialogFlag(bool)));
return editor;
}
+ else if(type == QCMakeProperty::STRING &&
+ var.data(QCMakeCacheModel::StringsRole).isValid())
+ {
+ QCMakeComboBox* editor =
+ new QCMakeComboBox(p, var.data(QCMakeCacheModel::StringsRole).toStringList());
+ editor->setFrame(false);
+ return editor;
+ }
- return new QLineEdit(p);
+ QLineEdit* editor = new QLineEdit(p);
+ editor->setFrame(false);
+ return editor;
}
-
+
bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, QAbstractItemModel* model,
const QStyleOptionViewItem& option, const QModelIndex& index)
{
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index e046d09..77422ec 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -70,7 +70,8 @@ public:
// properties, and the advanced flag
enum { HelpRole = Qt::ToolTipRole,
TypeRole = Qt::UserRole,
- AdvancedRole };
+ AdvancedRole,
+ StringsRole};
enum ViewType { FlatView, GroupView };
diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h
index 231f728..64691b5 100644
--- a/Source/QtDialog/QCMakeWidgets.h
+++ b/Source/QtDialog/QCMakeWidgets.h
@@ -19,6 +19,7 @@
#define QCMakeWidgets_h
#include <QLineEdit>
+#include <QComboBox>
#include <QCompleter>
class QToolButton;
@@ -67,5 +68,25 @@ public:
virtual QString pathFromIndex(const QModelIndex& idx) const;
};
+// editor for strings
+class QCMakeComboBox : public QComboBox
+{
+ Q_OBJECT
+ Q_PROPERTY(QString value READ currentText WRITE setValue USER true);
+public:
+ QCMakeComboBox(QWidget* p, QStringList strings) : QComboBox(p)
+ {
+ this->addItems(strings);
+ }
+ void setValue(const QString& v)
+ {
+ int i = this->findText(v);
+ if(i != -1)
+ {
+ this->setCurrentIndex(i);
+ }
+ }
+};
+
#endif