From df3169273a3333efe8ecb45da51e4c53b5d27fe9 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Thu, 14 Feb 2008 18:18:10 -0500 Subject: ENH: Add shortcut to start search/filter. A bit of cleanup. Disable tab navigation in cache variable list. Enable home/end keys. BUG: Ensure currently edited values are saved before doing configure. --- Source/QtDialog/CMakeSetup.cxx | 2 -- Source/QtDialog/CMakeSetupDialog.cxx | 14 ++++++++++++++ Source/QtDialog/CMakeSetupDialog.h | 1 + Source/QtDialog/QCMake.cxx | 24 ++++++++++++++---------- Source/QtDialog/QCMakeCacheView.cxx | 32 ++++++++------------------------ 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 8be36f9..b43f728 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -23,7 +23,6 @@ #include "CMakeSetupDialog.h" #include "cmDocumentation.h" -#include "cmSystemTools.h" #include "cmake.h" #include "cmVersion.h" #include @@ -73,7 +72,6 @@ int main(int argc, char** argv) #if defined(Q_OS_MAC) cmExecDir.cd("../../../"); #endif - cmSystemTools::FindExecutableDirectory(cmExecDir.filePath("cmake").toAscii().data()); // pick up translation files if they exists in the data directory QDir translationsDir = cmExecDir; diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 090a137..5a280c9 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include "QCMake.h" #include "QCMakeCacheView.h" @@ -96,6 +97,7 @@ CMakeSetupDialog::CMakeSetupDialog() this->GenerateAction = ToolsMenu->addAction(tr("&Generate")); QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), this, SLOT(doGenerate())); + QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help")); QAction* a = HelpMenu->addAction(tr("About")); @@ -105,6 +107,10 @@ CMakeSetupDialog::CMakeSetupDialog() QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doHelp())); + QShortcut* filterShortcut = new QShortcut(QKeySequence::Find, this); + QObject::connect(filterShortcut, SIGNAL(activated()), + this, SLOT(startSearch())); + this->setAcceptDrops(true); // get the saved binary directories @@ -266,6 +272,7 @@ void CMakeSetupDialog::doConfigure() this->enterState(Configuring); this->Output->clear(); + this->CacheValues->selectionModel()->clear(); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "setProperties", Qt::QueuedConnection, Q_ARG(QCMakeCachePropertyList, @@ -829,3 +836,10 @@ void CMakeSetupDialog::addCacheEntry() } } +void CMakeSetupDialog::startSearch() +{ + this->Search->setFocus(Qt::OtherFocusReason); + this->Search->selectAll(); +} + + diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 652660a..b2dbce6 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -71,6 +71,7 @@ protected slots: void removeSelectedCacheEntries(); void selectionChanged(); void addCacheEntry(); + void startSearch(); protected: diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 01c23da..020bdb8 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -31,22 +31,27 @@ QCMake::QCMake(QObject* p) qRegisterMetaType(); qRegisterMetaType(); - QDir appDir(QCoreApplication::applicationDirPath()); -#if defined(Q_OS_WIN) - this->CMakeExecutable = appDir.filePath("cmake.exe"); -#elif defined(Q_OS_MAC) - appDir.cd("../../../"); // path to cmake in build directory (need to fix for deployment) - this->CMakeExecutable = appDir.filePath("cmake"); -#else - this->CMakeExecutable = appDir.filePath("cmake"); + QDir execDir(QCoreApplication::applicationDirPath()); + + QString cmakeGUICommand = QString("cmake-gui")+cmSystemTools::GetExecutableExtension(); + cmakeGUICommand = execDir.filePath(cmakeGUICommand); + +#if defined(Q_OS_MAC) + execDir.cd("../../../"); // path to cmake in build directory (need to fix for deployment) #endif - // TODO: check for existence? + + QString cmakeCommand = QString("cmake")+cmSystemTools::GetExecutableExtension(); + cmakeCommand = execDir.filePath(cmakeCommand); + cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); cmSystemTools::SetErrorCallback(QCMake::errorCallback, this); + cmSystemTools::FindExecutableDirectory(cmakeCommand.toAscii().data()); this->CMakeInstance = new cmake; + this->CMakeInstance->SetCMakeCommand(cmakeCommand.toAscii().data()); + //this->CMakeInstance->SetCMakeEditCommand(cmakeGUICommand.toAscii().data()); this->CMakeInstance->SetCMakeEditCommand("cmake-gui"); this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this); @@ -131,7 +136,6 @@ void QCMake::configure() this->CMakeInstance->SetStartOutputDirectory(this->BinaryDirectory.toAscii().data()); this->CMakeInstance->SetGlobalGenerator( this->CMakeInstance->CreateGlobalGenerator(this->Generator.toAscii().data())); - this->CMakeInstance->SetCMakeCommand(this->CMakeExecutable.toAscii().data()); this->CMakeInstance->LoadCache(); this->CMakeInstance->PreLoadCMakeFiles(); diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index ba9ece3..776e10b 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -75,6 +75,9 @@ QCMakeCacheView::QCMakeCacheView(QWidget* p) QAbstractItemView::EditKeyPressed | QAbstractItemView::AnyKeyPressed); + // tab, backtab doesn't step through items + this->setTabKeyNavigation(false); + // set up headers and sizes int h = 0; QFontMetrics met(this->font()); @@ -105,33 +108,14 @@ QCMakeCacheModel* QCMakeCacheView::cacheModel() const QModelIndex QCMakeCacheView::moveCursor(CursorAction act, Qt::KeyboardModifiers mod) { - // tab through values only (not names) - QModelIndex current = this->currentIndex(); - if(act == MoveNext) + // want home/end to go to begin/end of rows, not columns + if(act == MoveHome) { - if(!current.isValid()) - { - return this->model()->index(0, 1); - } - else if(current.column() == 0) - { - return this->model()->index(current.row(), 1); - } - else - { - return this->model()->index(current.row()+1, 1); - } + return this->model()->index(0, 1); } - else if(act == MovePrevious) + else if(act == MoveEnd) { - if(!current.isValid()) - { - return this->model()->index(0, 1); - } - else - { - return this->model()->index(current.row()-1, 1); - } + return this->model()->index(this->model()->rowCount()-1, 1); } return QTableView::moveCursor(act, mod); } -- cgit v0.12