summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx42
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h2
-rw-r--r--Source/QtDialog/CMakeSetupDialog.ui2
-rw-r--r--Source/QtDialog/QCMake.cxx26
-rw-r--r--Source/QtDialog/QCMake.h2
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx27
-rw-r--r--Source/QtDialog/QCMakeCacheView.h1
7 files changed, 78 insertions, 24 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 36fdb6f..e718bc5 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -24,6 +24,7 @@
#include <QStatusBar>
#include <QToolButton>
#include <QDialogButtonBox>
+#include <QCloseEvent>
#include "QCMake.h"
#include "QCMakeCacheView.h"
@@ -50,6 +51,8 @@ CMakeSetupDialog::CMakeSetupDialog()
this->resize(700, 500);
QWidget* cont = new QWidget(this);
this->setupUi(cont);
+ this->Splitter->setStretchFactor(0, 2);
+ this->Splitter->setStretchFactor(1, 1);
this->setCentralWidget(cont);
this->ProgressBar = new QProgressBar();
this->ProgressBar->setRange(0,100);
@@ -87,7 +90,7 @@ void CMakeSetupDialog::initialize()
this, SLOT(doOk()));
QObject::connect(this->CancelButton, SIGNAL(clicked(bool)),
- this, SLOT(doCancel()));
+ this, SLOT(close()));
QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
this, SLOT(doSourceBrowse()));
@@ -96,6 +99,8 @@ void CMakeSetupDialog::initialize()
QObject::connect(this->BinaryDirectory, SIGNAL(editTextChanged(QString)),
this->CMakeThread->CMakeInstance, SLOT(setBinaryDirectory(QString)));
+ QObject::connect(this->SourceDirectory, SIGNAL(textChanged(QString)),
+ this->CMakeThread->CMakeInstance, SLOT(setSourceDirectory(QString)));
QObject::connect(this->CMakeThread->CMakeInstance, SIGNAL(sourceDirChanged(QString)),
this, SLOT(updateSourceDirectory(QString)));
@@ -127,6 +132,21 @@ CMakeSetupDialog::~CMakeSetupDialog()
void CMakeSetupDialog::doConfigure()
{
+ QDir dir(this->BinaryDirectory->currentText());
+ if(!dir.exists())
+ {
+ QString message = tr("Build directory does not exist, should I create it?\n\n"
+ "Directory: ");
+ message += this->BinaryDirectory->currentText();
+ QString title = tr("Create Directory");
+ QMessageBox::StandardButton btn =
+ QMessageBox::information(this, title, message, QMessageBox::Yes | QMessageBox::No);
+ if(btn == QMessageBox::No)
+ {
+ return;
+ }
+ dir.mkpath(".");
+ }
this->InterruptButton->setEnabled(true);
this->setEnabledState(false);
this->Output->clear();
@@ -178,8 +198,8 @@ void CMakeSetupDialog::doOk()
QMetaObject::invokeMethod(this->CMakeThread->CMakeInstance,
"generate", Qt::QueuedConnection);
}
-
-void CMakeSetupDialog::doCancel()
+
+void CMakeSetupDialog::closeEvent(QCloseEvent* e)
{
if(this->CacheValues->cacheModel()->isDirty())
{
@@ -187,14 +207,12 @@ void CMakeSetupDialog::doCancel()
"are you sure you want to exit?");
QString title = tr("Confirm Exit");
QMessageBox::StandardButton btn =
- QMessageBox::critical(this, title, message, QMessageBox::Ok | QMessageBox::Cancel);
- if(btn == QMessageBox::Cancel)
+ QMessageBox::critical(this, title, message, QMessageBox::Yes | QMessageBox::No);
+ if(btn == QMessageBox::No)
{
- return;
+ e->ignore();
}
}
-
- QApplication::quit();
}
void CMakeSetupDialog::doHelp()
@@ -242,13 +260,16 @@ void CMakeSetupDialog::doSourceBrowse()
tr("Enter Path to Source"), this->SourceDirectory->text());
if(!dir.isEmpty())
{
- this->updateSourceDirectory(dir);
+ this->SourceDirectory->setText(dir);
}
}
void CMakeSetupDialog::updateSourceDirectory(const QString& dir)
{
- this->SourceDirectory->setText(dir);
+ if(this->SourceDirectory->text() != dir)
+ {
+ this->SourceDirectory->setText(dir);
+ }
}
void CMakeSetupDialog::doBinaryBrowse()
@@ -265,6 +286,7 @@ void CMakeSetupDialog::setBinaryDirectory(const QString& dir)
{
if(dir != this->BinaryDirectory->currentText())
{
+ this->CacheValues->cacheModel()->setProperties(QCMakeCachePropertyList());
this->Output->clear();
this->BinaryDirectory->setEditText(dir);
}
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index 8d85ee9..a8221be 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -36,7 +36,6 @@ protected slots:
void initialize();
void doConfigure();
void doOk();
- void doCancel();
void doHelp();
void doInterrupt();
void finishConfigure(int error);
@@ -51,6 +50,7 @@ protected slots:
void setEnabledState(bool);
protected:
+ void closeEvent(QCloseEvent*);
QCMakeThread* CMakeThread;
QProgressBar* ProgressBar;
diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui
index 3942eb1..93fcf48 100644
--- a/Source/QtDialog/CMakeSetupDialog.ui
+++ b/Source/QtDialog/CMakeSetupDialog.ui
@@ -74,7 +74,7 @@
</layout>
</item>
<item>
- <widget class="QSplitter" name="splitter" >
+ <widget class="QSplitter" name="Splitter" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index a81d6af..495d404 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -61,21 +61,27 @@ void QCMake::loadCache(const QString& dir)
void QCMake::setSourceDirectory(const QString& dir)
{
- this->SourceDirectory = dir;
- emit this->sourceDirChanged(dir);
+ if(this->SourceDirectory != dir)
+ {
+ this->SourceDirectory = dir;
+ emit this->sourceDirChanged(dir);
+ }
}
void QCMake::setBinaryDirectory(const QString& dir)
{
- cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
- this->BinaryDirectory = dir;
- this->CMakeInstance->GetCacheManager()->LoadCache(dir.toLocal8Bit().data());
- QCMakeCachePropertyList props = this->properties();
- emit this->propertiesChanged(props);
- cmCacheManager::CacheIterator itm = cachem->NewIterator();
- if ( itm.Find("CMAKE_HOME_DIRECTORY"))
+ if(this->BinaryDirectory != dir)
{
- setSourceDirectory(itm.GetValue());
+ cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
+ this->BinaryDirectory = dir;
+ this->CMakeInstance->GetCacheManager()->LoadCache(dir.toLocal8Bit().data());
+ QCMakeCachePropertyList props = this->properties();
+ emit this->propertiesChanged(props);
+ cmCacheManager::CacheIterator itm = cachem->NewIterator();
+ if ( itm.Find("CMAKE_HOME_DIRECTORY"))
+ {
+ setSourceDirectory(itm.GetValue());
+ }
}
}
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index b9abf18..bfd2585 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -40,6 +40,8 @@ struct QCMakeCacheProperty
QString Help;
PropertyType Type;
bool Advanced;
+ bool operator==(const QCMakeCacheProperty& other) const { return this->Key == other.Key; }
+ bool operator<(const QCMakeCacheProperty& other) const { return this->Key < other.Key; }
};
// make types usable with QVariant
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index e14b322..4003c2f 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -88,7 +88,7 @@ QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
}
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
- : QAbstractTableModel(p), IsDirty(false)
+ : QAbstractTableModel(p), NewCount(0), IsDirty(false)
{
}
@@ -101,9 +101,28 @@ bool QCMakeCacheModel::isDirty() const
return this->IsDirty;
}
+static uint qHash(const QCMakeCacheProperty& p)
+{
+ return qHash(p.Key);
+}
+
void QCMakeCacheModel::setProperties(const QCMakeCachePropertyList& props)
{
- this->Properties = props;
+ QSet<QCMakeCacheProperty> newProps = props.toSet();
+ QSet<QCMakeCacheProperty> oldProps = this->Properties.toSet();
+
+ oldProps.intersect(newProps);
+ newProps.subtract(oldProps);
+
+ this->NewCount = newProps.count();
+ this->Properties.clear();
+
+ this->Properties = newProps.toList();
+ qSort(this->Properties);
+ QCMakeCachePropertyList tmp = oldProps.toList();
+ qSort(tmp);
+ this->Properties += tmp;
+
this->reset();
this->IsDirty = false;
}
@@ -155,6 +174,10 @@ QVariant QCMakeCacheModel::data (const QModelIndex& index, int role) const
{
return this->Properties[index.row()].Advanced;
}
+ else if(role == Qt::BackgroundRole && index.row()+1 <= this->NewCount)
+ {
+ return QBrush(QColor(255,100,100));
+ }
return QVariant();
}
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index a7e28e7..892d84f 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -73,6 +73,7 @@ public:
protected:
QCMakeCachePropertyList Properties;
+ int NewCount;
bool IsDirty;
};