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);
@ -76,6 +82,8 @@ CMakeSetupDialog::CMakeSetupDialog()
this->style()->standardPixmap(QStyle::SP_DialogCancelButton)); this->style()->standardPixmap(QStyle::SP_DialogCancelButton));
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);
@ -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,145 +5,184 @@
<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" > <layout class="QGridLayout" >
<property name="frameShape" > <item row="0" column="0" >
<enum>QFrame::NoFrame</enum> <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> </property>
<property name="frameShadow" > <widget class="QCMakeCacheView" name="CacheValues" >
<enum>QFrame::Raised</enum> <property name="alternatingRowColors" >
</property> <bool>true</bool>
<layout class="QVBoxLayout" >
<property name="leftMargin" >
<number>0</number>
</property> </property>
<property name="topMargin" > <property name="selectionBehavior" >
<number>0</number> <enum>QAbstractItemView::SelectRows</enum>
</property> </property>
<property name="rightMargin" > </widget>
<number>0</number> <widget class="QTextEdit" name="Output" >
<property name="lineWrapMode" >
<enum>QTextEdit::NoWrap</enum>
</property> </property>
<property name="bottomMargin" > <property name="readOnly" >
<number>0</number> <bool>true</bool>
</property> </property>
<item> </widget>
<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>
<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> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

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,
@ -97,6 +105,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