summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/CMakeSetupDialog.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2009-07-17 18:38:36 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2009-07-17 18:38:36 (GMT)
commit17acf0a310a8f10543c2be9fe902095a5a3c3c1d (patch)
tree4052fa5cd94ae8131c53db5c4e5ac358c581237d /Source/QtDialog/CMakeSetupDialog.cxx
parent3250cb3d3b5b4ed60e620ff78cad7fa8fb24113f (diff)
downloadCMake-17acf0a310a8f10543c2be9fe902095a5a3c3c1d.zip
CMake-17acf0a310a8f10543c2be9fe902095a5a3c3c1d.tar.gz
CMake-17acf0a310a8f10543c2be9fe902095a5a3c3c1d.tar.bz2
ENH: Add a "Show my changes" to the Tools menu.
Changes by the user are recorded and when requested, it shows -D arguments for commandline or contents for a cache file.
Diffstat (limited to 'Source/QtDialog/CMakeSetupDialog.cxx')
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx69
1 files changed, 69 insertions, 0 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index ce7c786..cafff1d 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -108,6 +108,9 @@ CMakeSetupDialog::CMakeSetupDialog()
this->GenerateAction = ToolsMenu->addAction(tr("&Generate"));
QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)),
this, SLOT(doGenerate()));
+ QAction* showChangesAction = ToolsMenu->addAction(tr("&Show My Changes"));
+ QObject::connect(showChangesAction, SIGNAL(triggered(bool)),
+ this, SLOT(showUserChanges()));
#if defined(Q_WS_MAC)
this->InstallForCommandLineAction
= ToolsMenu->addAction(tr("&Install For Command Line Use"));
@@ -512,6 +515,7 @@ void CMakeSetupDialog::onBinaryDirectoryChanged(const QString& dir)
{
this->CacheModified = false;
this->CacheValues->cacheModel()->clear();
+ qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())->clearChanges();
this->Output->clear();
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
"setBinaryDirectory", Qt::QueuedConnection, Q_ARG(QString, dir));
@@ -962,3 +966,68 @@ void CMakeSetupDialog::setViewType(int v)
}
+void CMakeSetupDialog::showUserChanges()
+{
+ QSet<QCMakeProperty> changes =
+ qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())->changes();
+
+ QDialog dialog(this);
+ dialog.setWindowTitle(tr("My Changes"));
+ dialog.resize(600, 400);
+ QVBoxLayout* l = new QVBoxLayout(&dialog);
+ QTextEdit* textedit = new QTextEdit(&dialog);
+ textedit->setReadOnly(true);
+ l->addWidget(textedit);
+ QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
+ Qt::Horizontal, &dialog);
+ QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
+ l->addWidget(btns);
+
+ QString command;
+ QString cache;
+
+ foreach(QCMakeProperty prop, changes)
+ {
+ QString type;
+ switch(prop.Type)
+ {
+ case QCMakeProperty::BOOL:
+ type = "BOOL";
+ break;
+ case QCMakeProperty::PATH:
+ type = "PATH";
+ break;
+ case QCMakeProperty::FILEPATH:
+ type = "FILEPATH";
+ break;
+ case QCMakeProperty::STRING:
+ type = "STRING";
+ break;
+ }
+ QString value;
+ if(prop.Type == QCMakeProperty::BOOL)
+ {
+ value = prop.Value.toBool() ? "1" : "0";
+ }
+ else
+ {
+ value = prop.Value.toString();
+ }
+
+ QString line("%1:%2=");
+ line = line.arg(prop.Key);
+ line = line.arg(type);
+
+ command += QString("-D%1\"%2\" ").arg(line).arg(value);
+ cache += QString("%1%2\n").arg(line).arg(value);
+ }
+
+ textedit->append(tr("Commandline options:"));
+ textedit->append(command);
+ textedit->append("\n");
+ textedit->append(tr("Cache file:"));
+ textedit->append(cache);
+
+ dialog.exec();
+}
+