diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2009-03-12 15:19:27 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2009-03-12 15:19:27 (GMT) |
commit | c54f47635c7f4eda101cc092605481efb9e5275d (patch) | |
tree | 2157d540e011660f7d3db31ffb4b7929f3fc61c2 /Source/QtDialog/QCMakeCacheView.cxx | |
parent | dd7b48c9c386ffd7fa184284403988df85a38279 (diff) | |
download | CMake-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/QtDialog/QCMakeCacheView.cxx')
-rw-r--r-- | Source/QtDialog/QCMakeCacheView.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
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) { |