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.
This commit is contained in:
Clinton Stimpson 2008-02-14 18:18:10 -05:00
parent 1c0595c73f
commit df3169273a
5 changed files with 37 additions and 36 deletions

View File

@ -23,7 +23,6 @@
#include "CMakeSetupDialog.h"
#include "cmDocumentation.h"
#include "cmSystemTools.h"
#include "cmake.h"
#include "cmVersion.h"
#include <cmsys/CommandLineArguments.hxx>
@ -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;

View File

@ -32,6 +32,7 @@
#include <QDragEnterEvent>
#include <QMimeData>
#include <QUrl>
#include <QShortcut>
#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();
}

View File

@ -71,6 +71,7 @@ protected slots:
void removeSelectedCacheEntries();
void selectionChanged();
void addCacheEntry();
void startSearch();
protected:

View File

@ -31,22 +31,27 @@ QCMake::QCMake(QObject* p)
qRegisterMetaType<QCMakeCacheProperty>();
qRegisterMetaType<QCMakeCachePropertyList>();
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();

View File

@ -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);
}