logic: Reworked CDB project setup

* added separate step for project name, project location and cdb path
* added description that project stays up-to-date under cdb path picker.
* added include and framework paths to advanced settings
* disregard source extensions for cdb projects

bug id = 70
This commit is contained in:
Eberhard Graether
2016-06-13 16:43:37 +02:00
parent aae388d8ee
commit b07d03692d
20 changed files with 329 additions and 204 deletions
@@ -5,15 +5,15 @@
QtProjectWizzardContentData::QtProjectWizzardContentData(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
, m_showLanguage(true)
, m_projectName(nullptr)
, m_projectFileLocation(nullptr)
, m_language(nullptr)
, m_cppStandard(nullptr)
, m_cStandard(nullptr)
, m_buildFilePicker(nullptr)
{
}
void QtProjectWizzardContentData::hideLanguage()
{
m_showLanguage = false;
}
void QtProjectWizzardContentData::populateWindow(QGridLayout* layout)
{
int row = 0;
@@ -31,118 +31,71 @@ void QtProjectWizzardContentData::populateWindow(QGridLayout* layout)
void QtProjectWizzardContentData::populateForm(QGridLayout* layout, int& row)
{
QLabel* nameLabel = createFormLabel("Name");
m_projectName = new QLineEdit();
m_projectName->setObjectName("name");
m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0);
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_projectName, row, QtProjectWizzardWindow::BACK_COL);
row++;
QLabel* locationLabel = createFormLabel("Location");
m_projectFileLocation = new QtLocationPicker(this);
m_projectFileLocation->setPickDirectory(true);
layout->addWidget(locationLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_projectFileLocation, row, QtProjectWizzardWindow::BACK_COL);
row++;
QLabel* languageLabel = new QLabel("Language");
languageLabel->setObjectName("label");
m_language = new QComboBox();
m_language->insertItem(0, "C++");
m_language->insertItem(1, "C");
connect(m_language, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
QLabel* standardLabel = createFormLabel("Standard");
m_cppStandard = new QComboBox();
m_cppStandard->insertItem(0, "1z");
m_cppStandard->insertItem(1, "14");
m_cppStandard->insertItem(2, "1y");
m_cppStandard->insertItem(3, "11");
m_cppStandard->insertItem(4, "0x");
m_cppStandard->insertItem(5, "03");
m_cppStandard->insertItem(6, "98");
m_cStandard = new QComboBox();
m_cStandard->insertItem(0, "1x");
m_cStandard->insertItem(1, "11");
m_cStandard->insertItem(2, "9x");
m_cStandard->insertItem(3, "99");
m_cStandard->insertItem(4, "90");
m_cStandard->insertItem(5, "89");
if (m_showLanguage)
{
layout->addWidget(languageLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_language, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
layout->addWidget(standardLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_cppStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
layout->addWidget(m_cStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
}
else
{
languageLabel->hide();
m_language->hide();
standardLabel->hide();
m_cppStandard->hide();
m_cStandard->hide();
}
row++;
addNameAndLocation(layout, row);
addLanguageAndStandard(layout, row);
}
void QtProjectWizzardContentData::load()
{
m_projectName->setText(QString::fromStdString(m_settings->getProjectName()));
m_projectFileLocation->setText(QString::fromStdString(m_settings->getProjectFileLocation().str()));
if (m_settings->getLanguage().length() > 0)
if (m_projectName)
{
m_language->setCurrentText(QString::fromStdString(m_settings->getLanguage()));
m_projectName->setText(QString::fromStdString(m_settings->getProjectName()));
m_projectFileLocation->setText(QString::fromStdString(m_settings->getProjectFileLocation().str()));
}
if (m_settings->getStandard().length() > 0)
if (m_language)
{
if (m_language->currentIndex() == 0) // c++
if (m_settings->getLanguage().length() > 0)
{
m_cppStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
}
else if (m_language->currentIndex() == 1) // c
{
m_cStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
m_language->setCurrentText(QString::fromStdString(m_settings->getLanguage()));
}
handleSelectionChanged(m_language->currentIndex());
if (m_settings->getStandard().length() > 0)
{
if (m_language->currentIndex() == 0) // c++
{
m_cppStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
}
else if (m_language->currentIndex() == 1) // c
{
m_cStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
}
handleSelectionChanged(m_language->currentIndex());
}
}
}
void QtProjectWizzardContentData::save()
{
m_settings->setProjectName(m_projectName->text().toStdString());
m_settings->setProjectFileLocation(m_projectFileLocation->getText().toStdString());
m_settings->setLanguage(m_language->currentText().toStdString());
if (m_cppStandard->isVisible())
if (m_projectName)
{
m_settings->setStandard(m_cppStandard->currentText().toStdString());
m_settings->setProjectName(m_projectName->text().toStdString());
m_settings->setProjectFileLocation(m_projectFileLocation->getText().toStdString());
}
else if (m_cStandard->isVisible())
if (m_language)
{
m_settings->setStandard(m_cStandard->currentText().toStdString());
m_settings->setLanguage(m_language->currentText().toStdString());
if (m_cppStandard->isVisible())
{
m_settings->setStandard(m_cppStandard->currentText().toStdString());
}
else if (m_cStandard->isVisible())
{
m_settings->setStandard(m_cStandard->currentText().toStdString());
}
}
}
bool QtProjectWizzardContentData::check()
{
if (!m_projectName)
{
return true;
}
if (m_projectName->text().isEmpty())
{
QMessageBox msgBox;
@@ -175,9 +128,99 @@ QSize QtProjectWizzardContentData::preferredWindowSize() const
return QSize(580, 340);
}
void QtProjectWizzardContentData::addNameAndLocation(QGridLayout* layout, int& row)
{
QLabel* nameLabel = createFormLabel("Name");
m_projectName = new QLineEdit();
m_projectName->setObjectName("name");
m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0);
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_projectName, row, QtProjectWizzardWindow::BACK_COL);
row++;
QLabel* locationLabel = createFormLabel("Location");
m_projectFileLocation = new QtLocationPicker(this);
m_projectFileLocation->setPickDirectory(true);
layout->addWidget(locationLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_projectFileLocation, row, QtProjectWizzardWindow::BACK_COL);
row++;
}
void QtProjectWizzardContentData::addLanguageAndStandard(QGridLayout* layout, int& row)
{
QLabel* languageLabel = new QLabel("Language");
languageLabel->setObjectName("label");
m_language = new QComboBox();
m_language->insertItem(0, "C++");
m_language->insertItem(1, "C");
connect(m_language, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
layout->addWidget(languageLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_language, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
QLabel* standardLabel = createFormLabel("Standard");
m_cppStandard = new QComboBox();
m_cppStandard->insertItem(0, "1z");
m_cppStandard->insertItem(1, "14");
m_cppStandard->insertItem(2, "1y");
m_cppStandard->insertItem(3, "11");
m_cppStandard->insertItem(4, "0x");
m_cppStandard->insertItem(5, "03");
m_cppStandard->insertItem(6, "98");
m_cStandard = new QComboBox();
m_cStandard->insertItem(0, "1x");
m_cStandard->insertItem(1, "11");
m_cStandard->insertItem(2, "9x");
m_cStandard->insertItem(3, "99");
m_cStandard->insertItem(4, "90");
m_cStandard->insertItem(5, "89");
layout->addWidget(standardLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_cppStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
layout->addWidget(m_cStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
}
void QtProjectWizzardContentData::addBuildFilePicker(
QGridLayout* layout, int& row, const QString& name, const QString& filter)
{
QLabel* label = createFormLabel(name);
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL);
m_buildFilePicker = new QtLocationPicker(this);
m_buildFilePicker->setFileFilter(filter);
// QPushButton* button = new QPushButton("", this);
// button->setObjectName("refreshButton");
// button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
// button->setToolTip("refresh paths");
// connect(button, SIGNAL(clicked()), this, SLOT(refreshClicked()));
// m_buildFilePicker->layout()->addWidget(button);
layout->addWidget(m_buildFilePicker, row, QtProjectWizzardWindow::BACK_COL);
row++;
QLabel* description = new QLabel(
"The project will stay up-to-date with changes in the compilation database on refresh.", this);
description->setObjectName("description");
description->setWordWrap(true);
layout->addWidget(description, row, QtProjectWizzardWindow::BACK_COL);
row++;
}
void QtProjectWizzardContentData::handleSelectionChanged(int index)
{
if (!m_showLanguage)
if (!m_language)
{
return;
}
@@ -193,3 +236,64 @@ void QtProjectWizzardContentData::handleSelectionChanged(int index)
m_cStandard->hide();
}
}
QtProjectWizzardContentDataCDB::QtProjectWizzardContentDataCDB(
ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContentData(settings, window)
{
}
void QtProjectWizzardContentDataCDB::populateForm(QGridLayout* layout, int& row)
{
QString name = "Compilation Database";
QString filter = "JSON Compilation Database (*.json)";
addNameAndLocation(layout, row);
layout->setRowMinimumHeight(row++, 20);
addBuildFilePicker(layout, row, name, filter);
}
void QtProjectWizzardContentDataCDB::load()
{
QtProjectWizzardContentData::load();
m_buildFilePicker->setText(QString::fromStdString(m_settings->getCompilationDatabasePath().str()));
}
void QtProjectWizzardContentDataCDB::save()
{
QtProjectWizzardContentData::save();
FilePath path = m_buildFilePicker->getText().toStdString();
if (!path.exists() || path.extension() != ".json")
{
return;
}
m_settings->setCompilationDatabasePath(path);
}
bool QtProjectWizzardContentDataCDB::check()
{
if (!QtProjectWizzardContentData::check())
{
return false;
}
FilePath path = m_buildFilePicker->getText().toStdString();
if (!path.exists() || path.extension() != ".json")
{
QMessageBox msgBox;
msgBox.setText("Please enter a valid compilation database file (*.json).");
msgBox.exec();
return false;
}
return true;
}
void QtProjectWizzardContentDataCDB::refreshClicked()
{
}