diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2007-11-09 20:18:49 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2007-11-09 20:18:49 (GMT) |
commit | 57e46c74d427e7d0ad19fa8671110908cf325cd9 (patch) | |
tree | 7cf188fae4d424ac0c384c3a65795eafd374dfc3 /Source | |
parent | e5bb99e01077a8ac084bbd6dbf8e2f81390b5cd9 (diff) | |
download | CMake-57e46c74d427e7d0ad19fa8671110908cf325cd9.zip CMake-57e46c74d427e7d0ad19fa8671110908cf325cd9.tar.gz CMake-57e46c74d427e7d0ad19fa8671110908cf325cd9.tar.bz2 |
BUG: Don't prompt for unsaved changes if no changes were made.
ENH: Error messages go to output window instead of message boxes.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.cxx | 53 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.h | 5 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 6 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.h | 4 | ||||
-rw-r--r-- | Source/QtDialog/QCMakeCacheView.cxx | 16 | ||||
-rw-r--r-- | Source/QtDialog/QCMakeCacheView.h | 5 |
6 files changed, 37 insertions, 52 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 1ed4943..62f3c37 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -66,7 +66,7 @@ void QCMakeThread::run() } CMakeSetupDialog::CMakeSetupDialog() - : ExitAfterGenerate(true) + : ExitAfterGenerate(true), CacheModified(false) { // create the GUI QSettings settings; @@ -170,9 +170,8 @@ void CMakeSetupDialog::initialize() this, SLOT(showProgress(QString,float))); QObject::connect(this->CMakeThread->cmakeInstance(), - SIGNAL(error(QString, QString, bool*)), - this, SLOT(error(QString,QString,bool*)), - Qt::BlockingQueuedConnection); + SIGNAL(errorMessage(QString)), + this, SLOT(error(QString))); QObject::connect(this->InterruptButton, SIGNAL(clicked(bool)), this, SLOT(doInterrupt())); @@ -191,15 +190,14 @@ void CMakeSetupDialog::initialize() this, SLOT(updateGeneratorLabel(QString))); this->updateGeneratorLabel(QString()); - QObject::connect(this->CacheValues->cacheModel(), - SIGNAL(dataChanged(QModelIndex, QModelIndex)), - this, SLOT(cacheModelDirty())); - QObject::connect(this->CacheValues->cacheModel(), SIGNAL(modelReset()), - this, SLOT(cacheModelDirty())); - QObject::connect(this->DeleteCacheButton, SIGNAL(clicked(bool)), this, SLOT(doDeleteCache())); + QObject::connect(this->CacheValues->cacheModel(), + SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(setCacheModified())); + + // get the saved binary directories QStringList buildPaths = this->loadBuildPaths(); this->BinaryDirectory->blockSignals(true); @@ -284,7 +282,7 @@ void CMakeSetupDialog::finishConfigure(int err) tr("Error in configuration process, project files may be invalid"), QMessageBox::Ok); } - else if(!this->CacheValues->cacheModel()->modifiedValues()) + else if(0 == this->CacheValues->cacheModel()->newCount()) { this->setGenerateEnabled(true); } @@ -329,7 +327,7 @@ void CMakeSetupDialog::closeEvent(QCloseEvent* e) } // prompt for close if there are unsaved changes - if(this->CacheValues->cacheModel()->modifiedValues()) + if(this->CacheModified) { QString message = tr("You have changed options but not rebuilt, " "are you sure you want to exit?"); @@ -426,6 +424,7 @@ void CMakeSetupDialog::onSourceDirectoryChanged(const QString& dir) void CMakeSetupDialog::onBinaryDirectoryChanged(const QString& dir) { + this->CacheModified = false; this->CacheValues->cacheModel()->clear(); this->Output->clear(); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), @@ -442,18 +441,9 @@ void CMakeSetupDialog::showProgress(const QString& /*msg*/, float percent) this->ProgressBar->setValue(qRound(percent * 100)); } -void CMakeSetupDialog::error(const QString& title, const QString& message, - bool* cancel) -{ - QMessageBox::StandardButton btn; - QString msg = message + "\n\n" + - tr("(Press cancel to suppress any further messages.)"); - btn = QMessageBox::critical(this, title, msg, - QMessageBox::Ok | QMessageBox::Cancel); - if(btn == QMessageBox::Cancel) - { - *cancel = false; - } +void CMakeSetupDialog::error(const QString& message) +{ + this->Output->append(QString("<b><font color=red>%1</font></b>").arg(message)); } void CMakeSetupDialog::setEnabledState(bool enabled) @@ -562,14 +552,6 @@ void CMakeSetupDialog::setExitAfterGenerate(bool b) */ } -void CMakeSetupDialog::cacheModelDirty() -{ - if(this->CacheValues->cacheModel()->modifiedValues()) - { - this->setGenerateEnabled(false); - } -} - void CMakeSetupDialog::setGenerateEnabled(bool b) { this->GenerateButton->setEnabled(b); @@ -682,4 +664,11 @@ void CMakeSetupDialog::saveBuildPaths(const QStringList& paths) settings.setValue(QString("WhereBuild%1").arg(i), paths[i]); } } + +void CMakeSetupDialog::setCacheModified() +{ + this->CacheModified = true; + this->setGenerateEnabled(false); +} + diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index bd8b9c2..8f3c1b3 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -49,7 +49,7 @@ protected slots: void doInterrupt(); void finishConfigure(int error); void finishGenerate(int error); - void error(const QString& title, const QString& message, bool* cancel); + void error(const QString& message); void doSourceBrowse(); void doBinaryBrowse(); @@ -61,13 +61,13 @@ protected slots: void promptForGenerator(); void updateGeneratorLabel(const QString& gen); void setExitAfterGenerate(bool); - void cacheModelDirty(); void setGenerateEnabled(bool); void addBinaryPath(const QString&); QStringList loadBuildPaths(); void saveBuildPaths(const QStringList&); void onBinaryDirectoryChanged(const QString& dir); void onSourceDirectoryChanged(const QString& dir); + void setCacheModified(); protected: void closeEvent(QCloseEvent*); @@ -76,6 +76,7 @@ protected: QCMakeThread* CMakeThread; bool ExitAfterGenerate; + bool CacheModified; QAction* ReloadCacheAction; QAction* DeleteCacheAction; QAction* ExitAction; diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 9d25170..48a9c57 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -255,11 +255,11 @@ void QCMake::progressCallback(const char* msg, float percent, void* cd) } } -void QCMake::errorCallback(const char* msg, const char* title, - bool& stop, void* cd) +void QCMake::errorCallback(const char* msg, const char* /*title*/, + bool& /*stop*/, void* cd) { QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->error(title, msg, &stop); + emit self->errorMessage(msg); } QString QCMake::binaryDirectory() const diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index 0aeb8bc9..ad3f3f5 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -105,8 +105,6 @@ signals: void propertiesChanged(const QCMakeCachePropertyList& vars); /// signal when the generator changes void generatorChanged(const QString& gen); - /// signal when there is an error message - void error(const QString& title, const QString& message, bool*); /// signal when the source directory changes (binary directory already /// containing a CMakeCache.txt file) void sourceDirChanged(const QString& dir); @@ -118,6 +116,8 @@ signals: void generateDone(int error); /// signal when there is an output message void outputMessage(const QString& msg); + /// signal when there is an error message + void errorMessage(const QString& msg); protected: cmake* CMakeInstance; diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 729b9d8..4bb160e 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -207,7 +207,7 @@ void QCMakeCacheView::setSearchFilter(const QString& s) QCMakeCacheModel::QCMakeCacheModel(QObject* p) : QAbstractTableModel(p), - NewCount(0), ModifiedValues(false), EditEnabled(true) + NewCount(0), EditEnabled(true) { } @@ -215,11 +215,6 @@ QCMakeCacheModel::~QCMakeCacheModel() { } -bool QCMakeCacheModel::modifiedValues() const -{ - return this->ModifiedValues; -} - static uint qHash(const QCMakeCacheProperty& p) { return qHash(p.Key); @@ -247,7 +242,6 @@ void QCMakeCacheModel::setProperties(const QCMakeCachePropertyList& props) qSort(tmp); this->Properties += tmp; - this->ModifiedValues = NewCount != 0; this->reset(); } @@ -266,6 +260,11 @@ bool QCMakeCacheModel::editEnabled() const return this->EditEnabled; } +int QCMakeCacheModel::newCount() const +{ + return this->NewCount; +} + int QCMakeCacheModel::columnCount (const QModelIndex& /*p*/ ) const { return 2; @@ -361,19 +360,16 @@ bool QCMakeCacheModel::setData (const QModelIndex& idx, const QVariant& value, i if(idx.column() == 0 && (role == Qt::DisplayRole || role == Qt::EditRole)) { this->Properties[idx.row()].Key = value.toString(); - this->ModifiedValues = true; emit this->dataChanged(idx, idx); } else if(idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole)) { this->Properties[idx.row()].Value = value.toString(); - this->ModifiedValues = true; emit this->dataChanged(idx, idx); } else if(idx.column() == 1 && (role == Qt::CheckStateRole)) { this->Properties[idx.row()].Value = value.toInt() == Qt::Checked; - this->ModifiedValues = true; emit this->dataChanged(idx, idx); } return false; diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 8e92b42..15c06d4 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -81,18 +81,17 @@ public: bool setData ( const QModelIndex& index, const QVariant& value, int role ); QModelIndex buddy ( const QModelIndex& index ) const; - // flag if a cache property has been modified - bool modifiedValues() const; // get the properties QCMakeCachePropertyList properties() const; // editing enabled bool editEnabled() const; + int newCount() const; + protected: QCMakeCachePropertyList Properties; int NewCount; - bool ModifiedValues; bool EditEnabled; }; |