diff options
| author | Brad King <brad.king@kitware.com> | 2014-01-16 14:24:11 (GMT) |
|---|---|---|
| committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-01-16 14:24:11 (GMT) |
| commit | 2d5d690ea6a783dd781980bbf507b459c726718b (patch) | |
| tree | c632c5413070e2e7cffda9946aa16cd7e60fc597 /Source/QtDialog/AddCacheEntry.cxx | |
| parent | 4e4951c9fcd312a1a3d799afbbc926c56a4accf2 (diff) | |
| parent | cfec180d66a7210606c5274e6ba3bb86a1e197a7 (diff) | |
| download | CMake-2d5d690ea6a783dd781980bbf507b459c726718b.zip CMake-2d5d690ea6a783dd781980bbf507b459c726718b.tar.gz CMake-2d5d690ea6a783dd781980bbf507b459c726718b.tar.bz2 | |
Merge topic 'var-type-autofill'
cfec180d cmake-gui: Remember variable type in Add Entry
Diffstat (limited to 'Source/QtDialog/AddCacheEntry.cxx')
| -rw-r--r-- | Source/QtDialog/AddCacheEntry.cxx | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index e7fedc5..3881045 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -15,14 +15,16 @@ #include <QCompleter> static const int NumTypes = 4; +static const int DefaultTypeIndex = 0; static const QByteArray TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; static const QCMakeProperty::PropertyType Types[NumTypes] = { QCMakeProperty::BOOL, QCMakeProperty::PATH, QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; -AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) - : QWidget(p) +AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames, + const QStringList& varTypes) + : QWidget(p), VarNames(varNames), VarTypes(varTypes) { this->setupUi(this); for(int i=0; i<NumTypes; i++) @@ -43,7 +45,10 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) this->setTabOrder(path, filepath); this->setTabOrder(filepath, string); this->setTabOrder(string, this->Description); - this->Name->setCompleter(new QCompleter(completions, this)); + QCompleter *completer = new QCompleter(this->VarNames, this); + this->Name->setCompleter(completer); + connect(completer, SIGNAL(activated(const QString&)), + this, SLOT(onCompletionActivated(const QString&))); } QString AddCacheEntry::name() const @@ -77,7 +82,32 @@ QCMakeProperty::PropertyType AddCacheEntry::type() const { return Types[idx]; } - return QCMakeProperty::BOOL; + return Types[DefaultTypeIndex]; } +QString AddCacheEntry::typeString() const +{ + int idx = this->Type->currentIndex(); + if(idx >= 0 && idx < NumTypes) + { + return TypeStrings[idx]; + } + return TypeStrings[DefaultTypeIndex]; +} +void AddCacheEntry::onCompletionActivated(const QString &text) +{ + int idx = this->VarNames.indexOf(text); + if (idx != -1) + { + QString vartype = this->VarTypes[idx]; + for (int i = 0; i < NumTypes; i++) + { + if (TypeStrings[i] == vartype) + { + this->Type->setCurrentIndex(i); + break; + } + } + } +} |
