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).
This commit is contained in:
Clinton Stimpson 2007-11-05 19:26:18 -05:00
parent c0108d1e07
commit a7746624e8
5 changed files with 253 additions and 134 deletions

View File

@ -25,6 +25,7 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QCloseEvent> #include <QCloseEvent>
#include <QCoreApplication> #include <QCoreApplication>
#include <QSettings>
#include "QCMake.h" #include "QCMake.h"
#include "QCMakeCacheView.h" #include "QCMakeCacheView.h"
@ -62,7 +63,12 @@ void QCMakeThread::run()
CMakeSetupDialog::CMakeSetupDialog() CMakeSetupDialog::CMakeSetupDialog()
{ {
// create the GUI // 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); QWidget* cont = new QWidget(this);
this->setupUi(cont); this->setupUi(cont);
this->Splitter->setStretchFactor(0, 2); this->Splitter->setStretchFactor(0, 2);
@ -77,6 +83,8 @@ CMakeSetupDialog::CMakeSetupDialog()
this->statusBar()->addPermanentWidget(this->InterruptButton); this->statusBar()->addPermanentWidget(this->InterruptButton);
this->statusBar()->addPermanentWidget(this->ProgressBar); this->statusBar()->addPermanentWidget(this->ProgressBar);
// start the cmake worker thread // start the cmake worker thread
this->CMakeThread = new QCMakeThread(this); this->CMakeThread = new QCMakeThread(this);
QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()), QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()),
@ -142,10 +150,44 @@ void CMakeSetupDialog::initialize()
QObject::connect(this->HelpButton, SIGNAL(clicked(bool)), QObject::connect(this->HelpButton, SIGNAL(clicked(bool)),
this, SLOT(doHelp())); 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() CMakeSetupDialog::~CMakeSetupDialog()
{ {
QSettings settings;
settings.beginGroup("Settings/StartPath");
settings.setValue("Height", this->height());
settings.setValue("Width", this->width());
// wait for thread to stop // wait for thread to stop
this->CMakeThread->quit(); this->CMakeThread->quit();
this->CMakeThread->wait(); this->CMakeThread->wait();
@ -171,11 +213,14 @@ void CMakeSetupDialog::doConfigure()
dir.mkpath("."); dir.mkpath(".");
} }
/*
// prompt for generator if one doesn't exist // prompt for generator if one doesn't exist
if(this->CMakeThread->cmakeInstance()->generator().isEmpty()) if(this->CMakeThread->cmakeInstance()->generator().isEmpty())
{ {
this->promptForGenerator(); this->promptForGenerator();
} }
*/
this->CMakeThread->cmakeInstance()->setGenerator(this->Generators->currentText());
this->InterruptButton->setEnabled(true); this->InterruptButton->setEnabled(true);
this->setEnabledState(false); this->setEnabledState(false);
@ -360,6 +405,7 @@ void CMakeSetupDialog::setEnabledState(bool enabled)
this->CancelButton->setEnabled(enabled); this->CancelButton->setEnabled(enabled);
} }
/*
void CMakeSetupDialog::promptForGenerator() void CMakeSetupDialog::promptForGenerator()
{ {
QStringList gens = this->CMakeThread->cmakeInstance()->availableGenerators(); QStringList gens = this->CMakeThread->cmakeInstance()->availableGenerators();
@ -382,4 +428,5 @@ void CMakeSetupDialog::promptForGenerator()
dialog.exec(); dialog.exec();
this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText()); this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText());
} }
*/

View File

@ -52,7 +52,7 @@ protected slots:
void setBinaryDirectory(const QString& dir); void setBinaryDirectory(const QString& dir);
void showProgress(const QString& msg, float percent); void showProgress(const QString& msg, float percent);
void setEnabledState(bool); void setEnabledState(bool);
void promptForGenerator(); //void promptForGenerator();
protected: protected:
void closeEvent(QCloseEvent*); void closeEvent(QCloseEvent*);

View File

@ -5,33 +5,12 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>673</width> <width>693</width>
<height>460</height> <height>582</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<item row="0" column="0" > <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>
</property>
<layout class="QVBoxLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QLabel" name="label" > <widget class="QLabel" name="label" >
@ -59,6 +38,12 @@
</item> </item>
<item row="1" column="1" > <item row="1" column="1" >
<widget class="QComboBox" name="BinaryDirectory" > <widget class="QComboBox" name="BinaryDirectory" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable" > <property name="editable" >
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -73,7 +58,64 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0" >
<layout class="QHBoxLayout" >
<item> <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" > <widget class="QSplitter" name="Splitter" >
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -96,7 +138,7 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item> <item row="3" column="0" >
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<item> <item>
<widget class="QPushButton" name="ConfigureButton" > <widget class="QPushButton" name="ConfigureButton" >
@ -108,7 +150,7 @@
<item> <item>
<widget class="QPushButton" name="GenerateButton" > <widget class="QPushButton" name="GenerateButton" >
<property name="text" > <property name="text" >
<string>Ok</string> <string>Generate</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -143,9 +185,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
</layout>
</widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>QCMakeCacheView</class> <class>QCMakeCacheView</class>

View File

@ -26,12 +26,20 @@
#include <QStyle> #include <QStyle>
#include <QKeyEvent> #include <QKeyEvent>
static QRegExp AdvancedRegExp[2] = { QRegExp("(false)"), QRegExp("(true|false)") };
QCMakeCacheView::QCMakeCacheView(QWidget* p) QCMakeCacheView::QCMakeCacheView(QWidget* p)
: QTableView(p), Init(false) : QTableView(p), Init(false)
{ {
// hook up our model // hook up our model and search/filter proxies
QCMakeCacheModel* m = new QCMakeCacheModel(this); this->CacheModel = new QCMakeCacheModel(this);
this->setModel(m); 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 // our delegate for creating our editors
QCMakeCacheModelDelegate* delegate = new QCMakeCacheModelDelegate(this); QCMakeCacheModelDelegate* delegate = new QCMakeCacheModelDelegate(this);
@ -61,7 +69,7 @@ void QCMakeCacheView::showEvent(QShowEvent* e)
QCMakeCacheModel* QCMakeCacheView::cacheModel() const QCMakeCacheModel* QCMakeCacheView::cacheModel() const
{ {
return qobject_cast<QCMakeCacheModel*>(this->model()); return this->CacheModel;
} }
QModelIndex QCMakeCacheView::moveCursor(CursorAction act, QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
@ -98,6 +106,22 @@ QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
return QTableView::moveCursor(act, mod); 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) QCMakeCacheModel::QCMakeCacheModel(QObject* p)
: QAbstractTableModel(p), NewCount(0), IsDirty(false) : QAbstractTableModel(p), NewCount(0), IsDirty(false)
{ {

View File

@ -24,6 +24,7 @@
#include <QCheckBox> #include <QCheckBox>
#include <QLineEdit> #include <QLineEdit>
#include <QItemDelegate> #include <QItemDelegate>
#include <QSortFilterProxyModel>
class QCMakeCacheModel; class QCMakeCacheModel;
@ -36,11 +37,19 @@ public:
QCMakeCacheView(QWidget* p); QCMakeCacheView(QWidget* p);
QCMakeCacheModel* cacheModel() const; QCMakeCacheModel* cacheModel() const;
bool showAdvanced() const;
public slots:
void setShowAdvanced(bool);
void setSearchFilter(const QString&);
protected: protected:
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers); QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
void showEvent(QShowEvent* e); void showEvent(QShowEvent* e);
bool Init; bool Init;
QCMakeCacheModel* CacheModel;
QSortFilterProxyModel* AdvancedFilter;
QSortFilterProxyModel* SearchFilter;
}; };
/// Qt model class for cache properties /// Qt model class for cache properties