ui: Added status checkbox for disabling Source Groups to project setup

This commit is contained in:
Eberhard Graether
2018-01-16 12:55:38 +01:00
parent 2c52425d99
commit 0a53d2828d
3 changed files with 41 additions and 15 deletions
@@ -324,7 +324,13 @@ void QtProjectWizzard::updateSourceGroupList()
for (const std::shared_ptr<SourceGroupSettings>& group : m_allSourceGroupSettings) for (const std::shared_ptr<SourceGroupSettings>& group : m_allSourceGroupSettings)
{ {
QListWidgetItem *item = new QListWidgetItem(QString::fromStdString(group->getName())); QString name = QString::fromStdString(group->getName());
if (group->getStatus() == SOURCE_GROUP_STATUS_DISABLED)
{
name = "(" + name + ")";
}
QListWidgetItem *item = new QListWidgetItem(name);
m_sourceGroupList->addItem(item); m_sourceGroupList->addItem(item);
} }
} }
@@ -1,5 +1,6 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h" #include "qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h"
#include <QCheckBox>
#include <QLineEdit> #include <QLineEdit>
#include <QMessageBox> #include <QMessageBox>
@@ -12,43 +13,45 @@ QtProjectWizzardContentSourceGroupData::QtProjectWizzardContentSourceGroupData(
: QtProjectWizzardContent(window) : QtProjectWizzardContent(window)
, m_settings(settings) , m_settings(settings)
, m_name(nullptr) , m_name(nullptr)
, m_status(nullptr)
{ {
} }
void QtProjectWizzardContentSourceGroupData::populate(QGridLayout* layout, int& row) void QtProjectWizzardContentSourceGroupData::populate(QGridLayout* layout, int& row)
{ {
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
row++;
}
QLabel* nameLabel = createFormLabel("Source Group Name");
m_name = new QLineEdit(); m_name = new QLineEdit();
m_name->setObjectName("name"); m_name->setObjectName("name");
m_name->setAttribute(Qt::WA_MacShowFocusRect, 0); m_name->setAttribute(Qt::WA_MacShowFocusRect, 0);
connect(m_name, &QLineEdit::textEdited, this, &QtProjectWizzardContentSourceGroupData::editedName); connect(m_name, &QLineEdit::textEdited, this, &QtProjectWizzardContentSourceGroupData::editedName);
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); layout->addWidget(createFormLabel("Source Group Name"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_name, row, QtProjectWizzardWindow::BACK_COL); layout->addWidget(m_name, row, QtProjectWizzardWindow::BACK_COL);
layout->setRowMinimumHeight(row, 30);
row++; row++;
if (!isInForm()) m_status = new QCheckBox("active");
{ connect(m_status, &QCheckBox::toggled, this, &QtProjectWizzardContentSourceGroupData::changedStatus);
layout->setRowMinimumHeight(row, 15); layout->addWidget(createFormLabel("Status"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->setRowStretch(row, 1); layout->addWidget(m_status, row, QtProjectWizzardWindow::BACK_COL);
}
addHelpButton("Status", "<p>Only source files of active Source Groups will be processed during indexing. "
"Inactive Source Groups will be ignored or cleared from the index.</p><p>Use this setting to temporarily "
"remove files from your project (e.g. tests).</p>", layout, row);
row++;
} }
void QtProjectWizzardContentSourceGroupData::load() void QtProjectWizzardContentSourceGroupData::load()
{ {
m_name->setText(QString::fromStdString(m_settings->getName())); m_name->setText(QString::fromStdString(m_settings->getName()));
m_status->setChecked(m_settings->getStatus() == SOURCE_GROUP_STATUS_ENABLED);
} }
void QtProjectWizzardContentSourceGroupData::save() void QtProjectWizzardContentSourceGroupData::save()
{ {
m_settings->setName(m_name->text().toStdString()); m_settings->setName(m_name->text().toStdString());
m_settings->setStatus(m_status->isChecked() ? SOURCE_GROUP_STATUS_ENABLED : SOURCE_GROUP_STATUS_DISABLED);
} }
bool QtProjectWizzardContentSourceGroupData::check() bool QtProjectWizzardContentSourceGroupData::check()
@@ -66,5 +69,17 @@ bool QtProjectWizzardContentSourceGroupData::check()
void QtProjectWizzardContentSourceGroupData::editedName(QString name) void QtProjectWizzardContentSourceGroupData::editedName(QString name)
{ {
if (!m_status->isChecked())
{
name = "(" + name + ")";
}
emit nameUpdated(name); emit nameUpdated(name);
} }
void QtProjectWizzardContentSourceGroupData::changedStatus(bool checked)
{
emit statusUpdated(m_status->isChecked() ? SOURCE_GROUP_STATUS_ENABLED : SOURCE_GROUP_STATUS_DISABLED);
editedName(m_name->text());
}
@@ -2,7 +2,9 @@
#define QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H #define QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h" #include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "settings/SourceGroupStatusType.h"
class QCheckBox;
class QLineEdit; class QLineEdit;
class SourceGroupSettings; class SourceGroupSettings;
@@ -25,14 +27,17 @@ public:
signals: signals:
void nameUpdated(QString); void nameUpdated(QString);
void statusUpdated(SourceGroupStatusType);
private slots: private slots:
void editedName(QString name); void editedName(QString name);
void changedStatus(bool checked);
private: private:
std::shared_ptr<SourceGroupSettings> m_settings; std::shared_ptr<SourceGroupSettings> m_settings;
QLineEdit* m_name; QLineEdit* m_name;
QCheckBox* m_status;
}; };
#endif // QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H #endif // QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H