From 31d4280bf3c1c0b24cd586b17c8d34cdb2f09647 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Wed, 7 Nov 2007 10:09:02 -0500 Subject: BUG: Fix behavior of CMakeSetupDialog::set{Binary|Source}Directory so they work right when called externally. Disable the generate button when one hits configure again. ENH: Some UI tweaks for spacing. Allow viewing cache values while configure/generate (but not edit). --- Source/QtDialog/CMakeSetupDialog.cxx | 36 ++++++++++++++++++++++++++++++------ Source/QtDialog/CMakeSetupDialog.h | 2 ++ Source/QtDialog/CMakeSetupDialog.ui | 16 ++++++++++++++++ Source/QtDialog/QCMakeCacheView.cxx | 15 +++++++++++++-- Source/QtDialog/QCMakeCacheView.h | 5 +++++ 5 files changed, 66 insertions(+), 8 deletions(-) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 5213908..c1484f5 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -162,10 +162,9 @@ void CMakeSetupDialog::initialize() this, SLOT(doBinaryBrowse())); QObject::connect(this->BinaryDirectory, SIGNAL(editTextChanged(QString)), - this, SLOT(setBinaryDirectory(QString))); + this, SLOT(onBinaryDirectoryChanged(QString))); QObject::connect(this->SourceDirectory, SIGNAL(textChanged(QString)), - this->CMakeThread->cmakeInstance(), - SLOT(setSourceDirectory(QString))); + this, SLOT(onSourceDirectoryChanged(QString))); QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(sourceDirChanged(QString)), @@ -207,7 +206,20 @@ void CMakeSetupDialog::initialize() // get the saved binary directories QStringList buildPaths = this->loadBuildPaths(); + this->BinaryDirectory->blockSignals(true); this->BinaryDirectory->addItems(buildPaths); + this->BinaryDirectory->blockSignals(false); + + if(!this->SourceDirectory->text().isEmpty() || + !this->BinaryDirectory->lineEdit()->text().isEmpty()) + { + this->onSourceDirectoryChanged(this->SourceDirectory->text()); + this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text()); + } + else + { + this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text()); + } } CMakeSetupDialog::~CMakeSetupDialog() @@ -251,9 +263,11 @@ void CMakeSetupDialog::doConfigure() // remember path this->addBinaryPath(dir.absolutePath()); - + this->InterruptButton->setEnabled(true); this->setEnabledState(false); + this->setGenerateEnabled(false); + this->Output->clear(); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "setProperties", Qt::QueuedConnection, @@ -406,9 +420,19 @@ void CMakeSetupDialog::doBinaryBrowse() void CMakeSetupDialog::setBinaryDirectory(const QString& dir) { + this->BinaryDirectory->setEditText(dir); +} + +void CMakeSetupDialog::onSourceDirectoryChanged(const QString& dir) +{ + QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), + "setSourceDirectory", Qt::QueuedConnection, Q_ARG(QString, dir)); +} + +void CMakeSetupDialog::onBinaryDirectoryChanged(const QString& dir) +{ this->CacheValues->cacheModel()->clear(); this->Output->clear(); - this->BinaryDirectory->setEditText(dir); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "setBinaryDirectory", Qt::QueuedConnection, Q_ARG(QString, dir)); } @@ -441,7 +465,7 @@ void CMakeSetupDialog::error(const QString& title, const QString& message, void CMakeSetupDialog::setEnabledState(bool enabled) { // disable parts of the GUI during configure/generate - this->CacheValues->setEnabled(enabled); + this->CacheValues->cacheModel()->setEditEnabled(enabled); this->SourceDirectory->setEnabled(enabled); this->BrowseSourceDirectoryButton->setEnabled(enabled); this->BinaryDirectory->setEnabled(enabled); diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 0010e1d..006569f 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -66,6 +66,8 @@ protected slots: void addBinaryPath(const QString&); QStringList loadBuildPaths(); void saveBuildPaths(const QStringList&); + void onBinaryDirectoryChanged(const QString& dir); + void onSourceDirectoryChanged(const QString& dir); protected: void closeEvent(QCloseEvent*); diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui index 1b3b537..aa2433a 100644 --- a/Source/QtDialog/CMakeSetupDialog.ui +++ b/Source/QtDialog/CMakeSetupDialog.ui @@ -68,6 +68,22 @@ + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index eca2b96..1937f24 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -124,7 +124,8 @@ void QCMakeCacheView::setSearchFilter(const QString& s) } QCMakeCacheModel::QCMakeCacheModel(QObject* p) - : QAbstractTableModel(p), NewCount(0), ModifiedValues(false) + : QAbstractTableModel(p), + NewCount(0), ModifiedValues(false), EditEnabled(true) { } @@ -173,6 +174,16 @@ QCMakeCachePropertyList QCMakeCacheModel::properties() const return this->Properties; } +void QCMakeCacheModel::setEditEnabled(bool e) +{ + this->EditEnabled = e; +} + +bool QCMakeCacheModel::editEnabled() const +{ + return this->EditEnabled; +} + int QCMakeCacheModel::columnCount (const QModelIndex& /*p*/ ) const { return 2; @@ -250,7 +261,7 @@ Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const { Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; // all column 1's are editable - if(idx.column() == 1) + if(idx.column() == 1 && this->EditEnabled) { f |= Qt::ItemIsEditable; // booleans are editable in place diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 5ea671f..52b154e 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -65,6 +65,7 @@ public: public slots: void setProperties(const QCMakeCachePropertyList& props); void clear(); + void setEditEnabled(bool); public: // satisfy [pure] virtuals @@ -80,11 +81,15 @@ public: bool modifiedValues() const; // get the properties QCMakeCachePropertyList properties() const; + + // editing enabled + bool editEnabled() const; protected: QCMakeCachePropertyList Properties; int NewCount; bool ModifiedValues; + bool EditEnabled; }; /// Qt delegate class for interaction (or other customization) -- cgit v0.12