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 <QStatusBar>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QCloseEvent>
|
||||||
|
|
||||||
#include "QCMake.h"
|
#include "QCMake.h"
|
||||||
#include "QCMakeCacheView.h"
|
#include "QCMakeCacheView.h"
|
||||||
@ -50,6 +51,8 @@ CMakeSetupDialog::CMakeSetupDialog()
|
|||||||
this->resize(700, 500);
|
this->resize(700, 500);
|
||||||
QWidget* cont = new QWidget(this);
|
QWidget* cont = new QWidget(this);
|
||||||
this->setupUi(cont);
|
this->setupUi(cont);
|
||||||
|
this->Splitter->setStretchFactor(0, 2);
|
||||||
|
this->Splitter->setStretchFactor(1, 1);
|
||||||
this->setCentralWidget(cont);
|
this->setCentralWidget(cont);
|
||||||
this->ProgressBar = new QProgressBar();
|
this->ProgressBar = new QProgressBar();
|
||||||
this->ProgressBar->setRange(0,100);
|
this->ProgressBar->setRange(0,100);
|
||||||
@ -87,7 +90,7 @@ void CMakeSetupDialog::initialize()
|
|||||||
this, SLOT(doOk()));
|
this, SLOT(doOk()));
|
||||||
|
|
||||||
QObject::connect(this->CancelButton, SIGNAL(clicked(bool)),
|
QObject::connect(this->CancelButton, SIGNAL(clicked(bool)),
|
||||||
this, SLOT(doCancel()));
|
this, SLOT(close()));
|
||||||
|
|
||||||
QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
|
QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
|
||||||
this, SLOT(doSourceBrowse()));
|
this, SLOT(doSourceBrowse()));
|
||||||
@ -96,6 +99,8 @@ void CMakeSetupDialog::initialize()
|
|||||||
|
|
||||||
QObject::connect(this->BinaryDirectory, SIGNAL(editTextChanged(QString)),
|
QObject::connect(this->BinaryDirectory, SIGNAL(editTextChanged(QString)),
|
||||||
this->CMakeThread->CMakeInstance, SLOT(setBinaryDirectory(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)),
|
QObject::connect(this->CMakeThread->CMakeInstance, SIGNAL(sourceDirChanged(QString)),
|
||||||
this, SLOT(updateSourceDirectory(QString)));
|
this, SLOT(updateSourceDirectory(QString)));
|
||||||
@ -127,6 +132,21 @@ CMakeSetupDialog::~CMakeSetupDialog()
|
|||||||
|
|
||||||
void CMakeSetupDialog::doConfigure()
|
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->InterruptButton->setEnabled(true);
|
||||||
this->setEnabledState(false);
|
this->setEnabledState(false);
|
||||||
this->Output->clear();
|
this->Output->clear();
|
||||||
@ -179,7 +199,7 @@ void CMakeSetupDialog::doOk()
|
|||||||
"generate", Qt::QueuedConnection);
|
"generate", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeSetupDialog::doCancel()
|
void CMakeSetupDialog::closeEvent(QCloseEvent* e)
|
||||||
{
|
{
|
||||||
if(this->CacheValues->cacheModel()->isDirty())
|
if(this->CacheValues->cacheModel()->isDirty())
|
||||||
{
|
{
|
||||||
@ -187,14 +207,12 @@ void CMakeSetupDialog::doCancel()
|
|||||||
"are you sure you want to exit?");
|
"are you sure you want to exit?");
|
||||||
QString title = tr("Confirm Exit");
|
QString title = tr("Confirm Exit");
|
||||||
QMessageBox::StandardButton btn =
|
QMessageBox::StandardButton btn =
|
||||||
QMessageBox::critical(this, title, message, QMessageBox::Ok | QMessageBox::Cancel);
|
QMessageBox::critical(this, title, message, QMessageBox::Yes | QMessageBox::No);
|
||||||
if(btn == QMessageBox::Cancel)
|
if(btn == QMessageBox::No)
|
||||||
{
|
{
|
||||||
return;
|
e->ignore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QApplication::quit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeSetupDialog::doHelp()
|
void CMakeSetupDialog::doHelp()
|
||||||
@ -242,13 +260,16 @@ void CMakeSetupDialog::doSourceBrowse()
|
|||||||
tr("Enter Path to Source"), this->SourceDirectory->text());
|
tr("Enter Path to Source"), this->SourceDirectory->text());
|
||||||
if(!dir.isEmpty())
|
if(!dir.isEmpty())
|
||||||
{
|
{
|
||||||
this->updateSourceDirectory(dir);
|
this->SourceDirectory->setText(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeSetupDialog::updateSourceDirectory(const QString& dir)
|
void CMakeSetupDialog::updateSourceDirectory(const QString& dir)
|
||||||
{
|
{
|
||||||
this->SourceDirectory->setText(dir);
|
if(this->SourceDirectory->text() != dir)
|
||||||
|
{
|
||||||
|
this->SourceDirectory->setText(dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeSetupDialog::doBinaryBrowse()
|
void CMakeSetupDialog::doBinaryBrowse()
|
||||||
@ -265,6 +286,7 @@ void CMakeSetupDialog::setBinaryDirectory(const QString& dir)
|
|||||||
{
|
{
|
||||||
if(dir != this->BinaryDirectory->currentText())
|
if(dir != this->BinaryDirectory->currentText())
|
||||||
{
|
{
|
||||||
|
this->CacheValues->cacheModel()->setProperties(QCMakeCachePropertyList());
|
||||||
this->Output->clear();
|
this->Output->clear();
|
||||||
this->BinaryDirectory->setEditText(dir);
|
this->BinaryDirectory->setEditText(dir);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ protected slots:
|
|||||||
void initialize();
|
void initialize();
|
||||||
void doConfigure();
|
void doConfigure();
|
||||||
void doOk();
|
void doOk();
|
||||||
void doCancel();
|
|
||||||
void doHelp();
|
void doHelp();
|
||||||
void doInterrupt();
|
void doInterrupt();
|
||||||
void finishConfigure(int error);
|
void finishConfigure(int error);
|
||||||
@ -51,6 +50,7 @@ protected slots:
|
|||||||
void setEnabledState(bool);
|
void setEnabledState(bool);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void closeEvent(QCloseEvent*);
|
||||||
|
|
||||||
QCMakeThread* CMakeThread;
|
QCMakeThread* CMakeThread;
|
||||||
QProgressBar* ProgressBar;
|
QProgressBar* ProgressBar;
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="splitter" >
|
<widget class="QSplitter" name="Splitter" >
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -61,21 +61,27 @@ void QCMake::loadCache(const QString& dir)
|
|||||||
|
|
||||||
void QCMake::setSourceDirectory(const QString& dir)
|
void QCMake::setSourceDirectory(const QString& dir)
|
||||||
{
|
{
|
||||||
this->SourceDirectory = dir;
|
if(this->SourceDirectory != dir)
|
||||||
emit this->sourceDirChanged(dir);
|
{
|
||||||
|
this->SourceDirectory = dir;
|
||||||
|
emit this->sourceDirChanged(dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCMake::setBinaryDirectory(const QString& dir)
|
void QCMake::setBinaryDirectory(const QString& dir)
|
||||||
{
|
{
|
||||||
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
|
if(this->BinaryDirectory != dir)
|
||||||
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());
|
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;
|
QString Help;
|
||||||
PropertyType Type;
|
PropertyType Type;
|
||||||
bool Advanced;
|
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
|
// make types usable with QVariant
|
||||||
|
@ -88,7 +88,7 @@ QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
|
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;
|
return this->IsDirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint qHash(const QCMakeCacheProperty& p)
|
||||||
|
{
|
||||||
|
return qHash(p.Key);
|
||||||
|
}
|
||||||
|
|
||||||
void QCMakeCacheModel::setProperties(const QCMakeCachePropertyList& props)
|
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->reset();
|
||||||
this->IsDirty = false;
|
this->IsDirty = false;
|
||||||
}
|
}
|
||||||
@ -155,6 +174,10 @@ QVariant QCMakeCacheModel::data (const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
return this->Properties[index.row()].Advanced;
|
return this->Properties[index.row()].Advanced;
|
||||||
}
|
}
|
||||||
|
else if(role == Qt::BackgroundRole && index.row()+1 <= this->NewCount)
|
||||||
|
{
|
||||||
|
return QBrush(QColor(255,100,100));
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QCMakeCachePropertyList Properties;
|
QCMakeCachePropertyList Properties;
|
||||||
|
int NewCount;
|
||||||
bool IsDirty;
|
bool IsDirty;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user