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:
Alexander Drozdov
2016-10-10 09:49:46 +10:00
parent 9e67dfbe17
commit 76b76f2723
11 changed files with 158 additions and 10 deletions

View File

@@ -34,6 +34,11 @@ class ConfigModel : public QAbstractTableModel
Q_OBJECT
public:
enum Roles {
ItemTypeRole = Qt::UserRole,
ItemValuesRole
};
class DataItem {
public:
enum Type { BOOLEAN, FILE, DIRECTORY, STRING, UNKNOWN};
@@ -43,6 +48,7 @@ public:
bool isAdvanced = false;
QString value;
QString description;
QStringList values;
};
explicit ConfigModel(QObject *parent = nullptr);
@@ -58,7 +64,8 @@ public:
void appendConfiguration(const QString &key,
const QString &value = QString(),
const DataItem::Type type = DataItem::UNKNOWN,
const QString &description = QString());
const QString &description = QString(),
const QStringList &values = QStringList());
void setConfiguration(const QList<DataItem> &config);
void flush();
void resetAllChanges();