diff options
author | Alex Neundorf <neundorf@kde.org> | 2011-11-19 21:21:41 (GMT) |
---|---|---|
committer | Alex Neundorf <neundorf@kde.org> | 2011-11-19 21:21:41 (GMT) |
commit | b0d01c306bd8dc6c636e65d38dc0d9e483568a67 (patch) | |
tree | 97bdc61a64fdbcfaa2057a4541f7c9324de15d1e /Source/QtDialog/CMakeSetupDialog.cxx | |
parent | 08c59af4dec0628964d9534ac165d75914bf580c (diff) | |
download | CMake-b0d01c306bd8dc6c636e65d38dc0d9e483568a67.zip CMake-b0d01c306bd8dc6c636e65d38dc0d9e483568a67.tar.gz CMake-b0d01c306bd8dc6c636e65d38dc0d9e483568a67.tar.bz2 |
cmake-gui: add completion for the names when adding cache entries
Up to 100 completion strings for the names of added variables
are saved in the settings, so it will remember the variables
you are usually adding.
It also ensures that CMAKE_INSTALL_PREFIX is always there, since
this is maybe the one which is set most often.
Alex
Diffstat (limited to 'Source/QtDialog/CMakeSetupDialog.cxx')
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.cxx | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index c8c4bfa..1c058d3 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -68,6 +68,9 @@ CMakeSetupDialog::CMakeSetupDialog() int w = settings.value("Width", 700).toInt(); this->resize(w, h); + this->AddVariableCompletions = settings.value("AddVariableCompletionEntries", + QStringList("CMAKE_INSTALL_PREFIX")).toStringList(); + QWidget* cont = new QWidget(this); this->setupUi(cont); this->Splitter->setStretchFactor(0, 3); @@ -1008,7 +1011,7 @@ void CMakeSetupDialog::addCacheEntry() dialog.resize(400, 200); dialog.setWindowTitle(tr("Add Cache Entry")); QVBoxLayout* l = new QVBoxLayout(&dialog); - AddCacheEntry* w = new AddCacheEntry(&dialog); + AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableCompletions); QDialogButtonBox* btns = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); @@ -1021,6 +1024,26 @@ void CMakeSetupDialog::addCacheEntry() { QCMakeCacheModel* m = this->CacheValues->cacheModel(); m->insertProperty(w->type(), w->name(), w->description(), w->value(), false); + + // only add variable names to the completion which are new + if (!this->AddVariableCompletions.contains(w->name())) + { + this->AddVariableCompletions << w->name(); + // limit to at most 100 completion items + if (this->AddVariableCompletions.size() > 100) + { + this->AddVariableCompletions.removeFirst(); + } + // make sure CMAKE_INSTALL_PREFIX is always there + if (!this->AddVariableCompletions.contains("CMAKE_INSTALL_PREFIX")) + { + this->AddVariableCompletions << QString("CMAKE_INSTALL_PREFIX"); + } + QSettings settings; + settings.beginGroup("Settings/StartPath"); + settings.setValue("AddVariableCompletionEntries", + this->AddVariableCompletions); + } } } |