ENH: Allow working with empty build directories.
Make output window a bit smaller compared to cache view. Prompt on X'ing window as well as hitting cancel. Color new cache values red, and put them first.
This commit is contained in:
parent
3135561227
commit
8770969464
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
|
||||
protected:
|
||||
QCMakeCachePropertyList Properties;
|
||||
int NewCount;
|
||||
bool IsDirty;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue