diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2007-11-06 00:26:18 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2007-11-06 00:26:18 (GMT) |
commit | a7746624e8e8ac29ea3db21d30746b0e70c7cb1c (patch) | |
tree | d0df0682c7f98ac6400cdf49875464515c609d43 | |
parent | c0108d1e07903af49c136217026a2fca082fbb1f (diff) | |
download | CMake-a7746624e8e8ac29ea3db21d30746b0e70c7cb1c.zip CMake-a7746624e8e8ac29ea3db21d30746b0e70c7cb1c.tar.gz CMake-a7746624e8e8ac29ea3db21d30746b0e70c7cb1c.tar.bz2 |
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).
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.cxx | 49 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.h | 2 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.ui | 295 | ||||
-rw-r--r-- | Source/QtDialog/QCMakeCacheView.cxx | 32 | ||||
-rw-r--r-- | 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 <QDialogButtonBox> #include <QCloseEvent> #include <QCoreApplication> +#include <QSettings> #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 @@ <rect> <x>0</x> <y>0</y> - <width>673</width> - <height>460</height> + <width>693</width> + <height>582</height> </rect> </property> <layout class="QGridLayout" > <item row="0" column="0" > - <widget class="QFrame" name="frame" > - <property name="frameShape" > - <enum>QFrame::NoFrame</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Where is the source code:</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="SourceDirectory" /> + </item> + <item row="0" column="2" > + <widget class="QPushButton" name="BrowseSourceDirectoryButton" > + <property name="text" > + <string>Browse...</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Where to build the binaries:</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QComboBox" name="BinaryDirectory" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="editable" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QPushButton" name="BrowseBinaryDirectoryButton" > + <property name="text" > + <string>Browse...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0" > + <layout class="QHBoxLayout" > + <item> + <widget class="QLabel" name="label_4" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="Minimum" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Search:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="Search" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="Advanced" > + <property name="text" > + <string>Show Advanced</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_3" > + <property name="text" > + <string>Build For:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="Generators" /> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>141</width> + <height>23</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="2" column="0" > + <widget class="QSplitter" name="Splitter" > + <property name="orientation" > + <enum>Qt::Vertical</enum> </property> - <layout class="QVBoxLayout" > - <property name="leftMargin" > - <number>0</number> + <widget class="QCMakeCacheView" name="CacheValues" > + <property name="alternatingRowColors" > + <bool>true</bool> </property> - <property name="topMargin" > - <number>0</number> + <property name="selectionBehavior" > + <enum>QAbstractItemView::SelectRows</enum> </property> - <property name="rightMargin" > - <number>0</number> + </widget> + <widget class="QTextEdit" name="Output" > + <property name="lineWrapMode" > + <enum>QTextEdit::NoWrap</enum> </property> - <property name="bottomMargin" > - <number>0</number> + <property name="readOnly" > + <bool>true</bool> </property> - <item> - <layout class="QGridLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Where is the source code:</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="SourceDirectory" /> - </item> - <item row="0" column="2" > - <widget class="QPushButton" name="BrowseSourceDirectoryButton" > - <property name="text" > - <string>Browse...</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="label_2" > - <property name="text" > - <string>Where to build the binaries:</string> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QComboBox" name="BinaryDirectory" > - <property name="editable" > - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="2" > - <widget class="QPushButton" name="BrowseBinaryDirectoryButton" > - <property name="text" > - <string>Browse...</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QSplitter" name="Splitter" > - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <widget class="QCMakeCacheView" name="CacheValues" > - <property name="alternatingRowColors" > - <bool>true</bool> - </property> - <property name="selectionBehavior" > - <enum>QAbstractItemView::SelectRows</enum> - </property> - </widget> - <widget class="QTextEdit" name="Output" > - <property name="lineWrapMode" > - <enum>QTextEdit::NoWrap</enum> - </property> - <property name="readOnly" > - <bool>true</bool> - </property> - </widget> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <item> - <widget class="QPushButton" name="ConfigureButton" > - <property name="text" > - <string>Configure</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="GenerateButton" > - <property name="text" > - <string>Ok</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="CancelButton" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="HelpButton" > - <property name="text" > - <string>Help</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> + </widget> </widget> </item> + <item row="3" column="0" > + <layout class="QHBoxLayout" > + <item> + <widget class="QPushButton" name="ConfigureButton" > + <property name="text" > + <string>Configure</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="GenerateButton" > + <property name="text" > + <string>Generate</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="CancelButton" > + <property name="text" > + <string>Cancel</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="HelpButton" > + <property name="text" > + <string>Help</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> </layout> </widget> <customwidgets> 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 <QStyle> #include <QKeyEvent> +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<QCMakeCacheModel*>(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 <QCheckBox> #include <QLineEdit> #include <QItemDelegate> +#include <QSortFilterProxyModel> 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 |