forked from qt-creator/qt-creator
CMakeProjectManager: Support drop down selector for options
CMake provides "hack" for cmake-gui, that allows set options variants and select then from drop down list. Allows Qt Creator re-use this solution. See: - https://blog.kitware.com/constraining-values-with-comboboxes-in-cmake-cmake-gui/ - http://blog.bethcodes.com/cmake-tips-tricks-drop-down-list Drop down values can be added to option via: SET_PROPERTY(CACHE OptionName PROPERTY STRINGS Option1 Option2 Option3) This solution should not restrict to provide any other value, it provides only suggestion for user to select one of prdefined values. Change-Id: I8fc52155775f1e04979db8206bb42363df9359e8 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -88,6 +88,15 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
const InternalDataItem &item = m_configuration[index.row()];
|
||||
|
||||
if (index.column() < 2) {
|
||||
switch (role) {
|
||||
case ItemTypeRole:
|
||||
return item.type;
|
||||
case ItemValuesRole:
|
||||
return item.values;
|
||||
}
|
||||
}
|
||||
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
switch (role) {
|
||||
@@ -97,8 +106,6 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
|
||||
return item.key;
|
||||
case Qt::ToolTipRole:
|
||||
return item.description;
|
||||
case Qt::UserRole:
|
||||
return item.type;
|
||||
case Qt::FontRole: {
|
||||
QFont font;
|
||||
font.setItalic(item.isCMakeChanged);
|
||||
@@ -126,8 +133,6 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
return item.description;
|
||||
case Qt::UserRole:
|
||||
return item.type;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@@ -209,13 +214,15 @@ QVariant ConfigModel::headerData(int section, Qt::Orientation orientation, int r
|
||||
void ConfigModel::appendConfiguration(const QString &key,
|
||||
const QString &value,
|
||||
const ConfigModel::DataItem::Type type,
|
||||
const QString &description)
|
||||
const QString &description,
|
||||
const QStringList &values)
|
||||
{
|
||||
DataItem item;
|
||||
item.key = key;
|
||||
item.type = type;
|
||||
item.value = value;
|
||||
item.description = description;
|
||||
item.values = values;
|
||||
|
||||
InternalDataItem internalItem(item);
|
||||
internalItem.isUserNew = true;
|
||||
|
||||
Reference in New Issue
Block a user