diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 1ed4943b7..62f3c3776 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) +void CMakeSetupDialog::error(const QString& message) { - 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; - } + this->Output->append(QString("%1").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 bd8b9c288..8f3c1b3f1 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 9d2517053..48a9c57f4 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(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 0aeb8bc92..ad3f3f516 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 729b9d861..4bb160e21 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 8e92b42df..15c06d4fc 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; };