From a7746624e8e8ac29ea3db21d30746b0e70c7cb1c Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Mon, 5 Nov 2007 19:26:18 -0500 Subject: ENH: Replace prompt for generator with combobox in UI. ENH: Make "Show Advanced" toggle work. ENH: Add regex search capabilities. ENH: Read existing registry entries from MFC CMakeSetup.exe (will save later). --- Source/QtDialog/CMakeSetupDialog.cxx | 49 +++++- Source/QtDialog/CMakeSetupDialog.h | 2 +- Source/QtDialog/CMakeSetupDialog.ui | 295 ++++++++++++++++++++--------------- Source/QtDialog/QCMakeCacheView.cxx | 32 +++- Source/QtDialog/QCMakeCacheView.h | 9 ++ 5 files changed, 253 insertions(+), 134 deletions(-) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 3a39c81..36adc33 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include "QCMake.h" #include "QCMakeCacheView.h" @@ -62,7 +63,12 @@ void QCMakeThread::run() CMakeSetupDialog::CMakeSetupDialog() { // create the GUI - this->resize(700, 500); + QSettings settings; + settings.beginGroup("Settings/StartPath"); + int h = settings.value("Height", 500).toInt(); + int w = settings.value("Width", 700).toInt(); + this->resize(w, h); + QWidget* cont = new QWidget(this); this->setupUi(cont); this->Splitter->setStretchFactor(0, 2); @@ -76,6 +82,8 @@ CMakeSetupDialog::CMakeSetupDialog() this->style()->standardPixmap(QStyle::SP_DialogCancelButton)); this->statusBar()->addPermanentWidget(this->InterruptButton); this->statusBar()->addPermanentWidget(this->ProgressBar); + + // start the cmake worker thread this->CMakeThread = new QCMakeThread(this); @@ -142,10 +150,44 @@ void CMakeSetupDialog::initialize() QObject::connect(this->HelpButton, SIGNAL(clicked(bool)), this, SLOT(doHelp())); + + QObject::connect(this->Advanced, SIGNAL(clicked(bool)), + this->CacheValues, SLOT(setShowAdvanced(bool))); + QObject::connect(this->Search, SIGNAL(textChanged(QString)), + this->CacheValues, SLOT(setSearchFilter(QString))); + + QStringList gens = this->CMakeThread->cmakeInstance()->availableGenerators(); + this->Generators->addItems(gens); + + // get the saved binary directories + QSettings settings; + settings.beginGroup("Settings/StartPath"); + QStringList buildPaths; + for(int i=0; i<10; i++) + { + QString p = settings.value(QString("WhereBuild%1").arg(i)).toString(); + if(!p.isEmpty()) + { + buildPaths.append(p); + } + } + this->BinaryDirectory->addItems(buildPaths); + + QString lastGen = settings.value("LastGenerator").toString(); + int idx = this->Generators->findText(lastGen); + if(idx != -1) + { + this->Generators->setCurrentIndex(idx); + } } CMakeSetupDialog::~CMakeSetupDialog() { + QSettings settings; + settings.beginGroup("Settings/StartPath"); + settings.setValue("Height", this->height()); + settings.setValue("Width", this->width()); + // wait for thread to stop this->CMakeThread->quit(); this->CMakeThread->wait(); @@ -171,11 +213,14 @@ void CMakeSetupDialog::doConfigure() dir.mkpath("."); } + /* // prompt for generator if one doesn't exist if(this->CMakeThread->cmakeInstance()->generator().isEmpty()) { this->promptForGenerator(); } + */ + this->CMakeThread->cmakeInstance()->setGenerator(this->Generators->currentText()); this->InterruptButton->setEnabled(true); this->setEnabledState(false); @@ -360,6 +405,7 @@ void CMakeSetupDialog::setEnabledState(bool enabled) this->CancelButton->setEnabled(enabled); } +/* void CMakeSetupDialog::promptForGenerator() { QStringList gens = this->CMakeThread->cmakeInstance()->availableGenerators(); @@ -382,4 +428,5 @@ void CMakeSetupDialog::promptForGenerator() dialog.exec(); this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText()); } +*/ diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index d1efcce..e67315a 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -52,7 +52,7 @@ protected slots: void setBinaryDirectory(const QString& dir); void showProgress(const QString& msg, float percent); void setEnabledState(bool); - void promptForGenerator(); + //void promptForGenerator(); protected: void closeEvent(QCloseEvent*); diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui index 93fcf48..e06c1ae 100644 --- a/Source/QtDialog/CMakeSetupDialog.ui +++ b/Source/QtDialog/CMakeSetupDialog.ui @@ -5,145 +5,184 @@ 0 0 - 673 - 460 + 693 + 582 - - - QFrame::NoFrame - - - QFrame::Raised + + + + + Where is the source code: + + + + + + + + + + Browse... + + + + + + + Where to build the binaries: + + + + + + + + 0 + 0 + + + + true + + + + + + + Browse... + + + + + + + + + + + + 0 + 0 + + + + Search: + + + + + + + + 0 + 0 + + + + + + + + Show Advanced + + + + + + + Build For: + + + + + + + + + + Qt::Horizontal + + + + 141 + 23 + + + + + + + + + + Qt::Vertical - - - 0 + + + true - - 0 + + QAbstractItemView::SelectRows - - 0 + + + + QTextEdit::NoWrap - - 0 + + true - - - - - - Where is the source code: - - - - - - - - - - Browse... - - - - - - - Where to build the binaries: - - - - - - - true - - - - - - - Browse... - - - - - - - - - Qt::Vertical - - - - true - - - QAbstractItemView::SelectRows - - - - - QTextEdit::NoWrap - - - true - - - - - - - - - - Configure - - - - - - - Ok - - - - - - - Cancel - - - - - - - Help - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - + + + + + + + Configure + + + + + + + Generate + + + + + + + Cancel + + + + + + + Help + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 9b732e8..07b70af 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -26,12 +26,20 @@ #include #include +static QRegExp AdvancedRegExp[2] = { QRegExp("(false)"), QRegExp("(true|false)") }; + QCMakeCacheView::QCMakeCacheView(QWidget* p) : QTableView(p), Init(false) { - // hook up our model - QCMakeCacheModel* m = new QCMakeCacheModel(this); - this->setModel(m); + // hook up our model and search/filter proxies + this->CacheModel = new QCMakeCacheModel(this); + this->AdvancedFilter = new QSortFilterProxyModel(this); + this->AdvancedFilter->setSourceModel(this->CacheModel); + this->AdvancedFilter->setFilterRole(QCMakeCacheModel::AdvancedRole); + this->AdvancedFilter->setFilterRegExp(AdvancedRegExp[0]); + this->SearchFilter = new QSortFilterProxyModel(this); + this->SearchFilter->setSourceModel(this->AdvancedFilter); + this->setModel(this->SearchFilter); // our delegate for creating our editors QCMakeCacheModelDelegate* delegate = new QCMakeCacheModelDelegate(this); @@ -61,7 +69,7 @@ void QCMakeCacheView::showEvent(QShowEvent* e) QCMakeCacheModel* QCMakeCacheView::cacheModel() const { - return qobject_cast(this->model()); + return this->CacheModel; } QModelIndex QCMakeCacheView::moveCursor(CursorAction act, @@ -97,6 +105,22 @@ QModelIndex QCMakeCacheView::moveCursor(CursorAction act, } return QTableView::moveCursor(act, mod); } + +void QCMakeCacheView::setShowAdvanced(bool s) +{ + this->AdvancedFilter->setFilterRegExp( + s ? AdvancedRegExp[1] : AdvancedRegExp[0]); +} + +bool QCMakeCacheView::showAdvanced() const +{ + return this->AdvancedFilter->filterRegExp() == AdvancedRegExp[1]; +} + +void QCMakeCacheView::setSearchFilter(const QString& s) +{ + this->SearchFilter->setFilterRegExp(s); +} QCMakeCacheModel::QCMakeCacheModel(QObject* p) : QAbstractTableModel(p), NewCount(0), IsDirty(false) diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 91d1053..039c834 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -24,6 +24,7 @@ #include #include #include +#include class QCMakeCacheModel; @@ -36,11 +37,19 @@ public: QCMakeCacheView(QWidget* p); QCMakeCacheModel* cacheModel() const; + bool showAdvanced() const; + +public slots: + void setShowAdvanced(bool); + void setSearchFilter(const QString&); protected: QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers); void showEvent(QShowEvent* e); bool Init; + QCMakeCacheModel* CacheModel; + QSortFilterProxyModel* AdvancedFilter; + QSortFilterProxyModel* SearchFilter; }; /// Qt model class for cache properties -- cgit v0.12