forked from qt-creator/qt-creator
Todo: Inline todoprojectsettingswidget.ui
Change-Id: I942d1687a6a34a269ce4abd9233975febb4516e8 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -20,5 +20,5 @@ add_qtc_plugin(Todo
|
||||
todooutputtreeviewdelegate.cpp todooutputtreeviewdelegate.h
|
||||
todoplugin.cpp todoplugin.h
|
||||
todoplugin.qrc
|
||||
todoprojectsettingswidget.cpp todoprojectsettingswidget.h todoprojectsettingswidget.ui
|
||||
todoprojectsettingswidget.cpp todoprojectsettingswidget.h
|
||||
)
|
||||
|
||||
@@ -26,7 +26,6 @@ QtcPlugin {
|
||||
"optionsdialog.h",
|
||||
"todoprojectsettingswidget.cpp",
|
||||
"todoprojectsettingswidget.h",
|
||||
"todoprojectsettingswidget.ui",
|
||||
"qmljstodoitemsscanner.cpp",
|
||||
"qmljstodoitemsscanner.h",
|
||||
"settings.cpp",
|
||||
|
||||
@@ -24,49 +24,72 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "todoprojectsettingswidget.h"
|
||||
#include "ui_todoprojectsettingswidget.h"
|
||||
|
||||
#include "constants.h"
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace Todo {
|
||||
namespace Internal {
|
||||
|
||||
static QString excludePlaceholder()
|
||||
{
|
||||
return Todo::Internal::TodoProjectSettingsWidget::tr("<Enter regular expression to exclude>");
|
||||
}
|
||||
|
||||
namespace Todo {
|
||||
namespace Internal {
|
||||
|
||||
TodoProjectSettingsWidget::TodoProjectSettingsWidget(ProjectExplorer::Project *project) :
|
||||
ui(new Ui::TodoProjectSettingsWidget),
|
||||
m_project(project)
|
||||
TodoProjectSettingsWidget::TodoProjectSettingsWidget(ProjectExplorer::Project *project)
|
||||
: m_project(project)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_excludedPatternsList = new QListWidget;
|
||||
m_excludedPatternsList->setSortingEnabled(true);
|
||||
m_excludedPatternsList->setToolTip(tr("Regular expressions for file paths to be excluded from scanning."));
|
||||
|
||||
m_removeExcludedPatternButton = new QPushButton(tr("Remove"));
|
||||
|
||||
auto addExcludedPatternButton = new QPushButton(tr("Add"));
|
||||
|
||||
using namespace Utils::Layouting;
|
||||
|
||||
Column {
|
||||
Group {
|
||||
Title(tr("Excluded Files")),
|
||||
Row {
|
||||
m_excludedPatternsList,
|
||||
Column {
|
||||
addExcludedPatternButton,
|
||||
m_removeExcludedPatternButton,
|
||||
Stretch()
|
||||
}
|
||||
}
|
||||
}
|
||||
}.attachTo(this);
|
||||
|
||||
setExcludedPatternsButtonsEnabled();
|
||||
connect(ui->addExcludedPatternButton, &QPushButton::clicked,
|
||||
connect(addExcludedPatternButton, &QPushButton::clicked,
|
||||
this, &TodoProjectSettingsWidget::addExcludedPatternButtonClicked);
|
||||
connect(ui->removeExcludedPatternButton, &QPushButton::clicked,
|
||||
connect(m_removeExcludedPatternButton, &QPushButton::clicked,
|
||||
this, &TodoProjectSettingsWidget::removeExcludedPatternButtonClicked);
|
||||
connect(ui->excludedPatternsList, &QListWidget::itemChanged,
|
||||
connect(m_excludedPatternsList, &QListWidget::itemChanged,
|
||||
this, &TodoProjectSettingsWidget::excludedPatternChanged, Qt::QueuedConnection);
|
||||
connect(ui->excludedPatternsList, &QListWidget::itemSelectionChanged,
|
||||
connect(m_excludedPatternsList, &QListWidget::itemSelectionChanged,
|
||||
this, &TodoProjectSettingsWidget::setExcludedPatternsButtonsEnabled);
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
TodoProjectSettingsWidget::~TodoProjectSettingsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
TodoProjectSettingsWidget::~TodoProjectSettingsWidget() = default;
|
||||
|
||||
QListWidgetItem *TodoProjectSettingsWidget::addToExcludedPatternsList(const QString &pattern)
|
||||
{
|
||||
auto item = new QListWidgetItem(pattern);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
prepareItem(item);
|
||||
ui->excludedPatternsList->addItem(item);
|
||||
m_excludedPatternsList->addItem(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -74,7 +97,7 @@ void TodoProjectSettingsWidget::loadSettings()
|
||||
{
|
||||
QVariant s = m_project->namedSettings(Constants::SETTINGS_NAME_KEY);
|
||||
QVariantMap settings = s.toMap();
|
||||
ui->excludedPatternsList->clear();
|
||||
m_excludedPatternsList->clear();
|
||||
for (const QVariant &pattern : settings[Constants::EXCLUDES_LIST_KEY].toList())
|
||||
addToExcludedPatternsList(pattern.toString());
|
||||
}
|
||||
@@ -84,8 +107,8 @@ void TodoProjectSettingsWidget::saveSettings()
|
||||
QVariantMap settings;
|
||||
QVariantList excludes;
|
||||
|
||||
for (int i = 0; i < ui->excludedPatternsList->count(); ++i)
|
||||
excludes << ui->excludedPatternsList->item(i)->text();
|
||||
for (int i = 0; i < m_excludedPatternsList->count(); ++i)
|
||||
excludes << m_excludedPatternsList->item(i)->text();
|
||||
|
||||
settings[Constants::EXCLUDES_LIST_KEY] = excludes;
|
||||
|
||||
@@ -96,40 +119,40 @@ void TodoProjectSettingsWidget::saveSettings()
|
||||
void TodoProjectSettingsWidget::prepareItem(QListWidgetItem *item) const
|
||||
{
|
||||
if (QRegularExpression(item->text()).isValid())
|
||||
item->setForeground(QBrush(ui->excludedPatternsList->palette().color(QPalette::Active, QPalette::Text)));
|
||||
item->setForeground(QBrush(m_excludedPatternsList->palette().color(QPalette::Active, QPalette::Text)));
|
||||
else
|
||||
item->setForeground(QBrush(Qt::red));
|
||||
}
|
||||
|
||||
void TodoProjectSettingsWidget::addExcludedPatternButtonClicked()
|
||||
{
|
||||
if (!ui->excludedPatternsList->findItems(excludePlaceholder(), Qt::MatchFixedString).isEmpty())
|
||||
if (!m_excludedPatternsList->findItems(excludePlaceholder(), Qt::MatchFixedString).isEmpty())
|
||||
return;
|
||||
ui->excludedPatternsList->editItem(addToExcludedPatternsList(excludePlaceholder()));
|
||||
m_excludedPatternsList->editItem(addToExcludedPatternsList(excludePlaceholder()));
|
||||
}
|
||||
|
||||
void TodoProjectSettingsWidget::removeExcludedPatternButtonClicked()
|
||||
{
|
||||
delete ui->excludedPatternsList->takeItem(ui->excludedPatternsList->currentRow());
|
||||
delete m_excludedPatternsList->takeItem(m_excludedPatternsList->currentRow());
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void TodoProjectSettingsWidget::setExcludedPatternsButtonsEnabled()
|
||||
{
|
||||
const bool isSomethingSelected = !ui->excludedPatternsList->selectedItems().isEmpty();
|
||||
ui->removeExcludedPatternButton->setEnabled(isSomethingSelected);
|
||||
const bool isSomethingSelected = !m_excludedPatternsList->selectedItems().isEmpty();
|
||||
m_removeExcludedPatternButton->setEnabled(isSomethingSelected);
|
||||
}
|
||||
|
||||
void TodoProjectSettingsWidget::excludedPatternChanged(QListWidgetItem *item)
|
||||
{
|
||||
if (item->text().isEmpty() || item->text() == excludePlaceholder()) {
|
||||
ui->excludedPatternsList->removeItemWidget(item);
|
||||
m_excludedPatternsList->removeItemWidget(item);
|
||||
delete item;
|
||||
} else {
|
||||
prepareItem(item);
|
||||
}
|
||||
saveSettings();
|
||||
ui->excludedPatternsList->setCurrentItem(nullptr);
|
||||
m_excludedPatternsList->setCurrentItem(nullptr);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -30,20 +30,16 @@
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Project;
|
||||
}
|
||||
namespace ProjectExplorer { class Project; }
|
||||
|
||||
namespace Todo {
|
||||
namespace Internal {
|
||||
|
||||
namespace Ui {
|
||||
class TodoProjectSettingsWidget;
|
||||
}
|
||||
|
||||
class TodoProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -65,10 +61,10 @@ private:
|
||||
void saveSettings();
|
||||
void prepareItem(QListWidgetItem *item) const;
|
||||
|
||||
Ui::TodoProjectSettingsWidget *ui;
|
||||
ProjectExplorer::Project *m_project;
|
||||
QListWidget *m_excludedPatternsList;
|
||||
QPushButton *m_removeExcludedPatternButton;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Todo
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Todo::Internal::TodoProjectSettingsWidget</class>
|
||||
<widget class="QWidget" name="Todo::Internal::TodoProjectSettingsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>814</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="excludedPatternsBox">
|
||||
<property name="title">
|
||||
<string>Excluded Files</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QListWidget" name="excludedPatternsList">
|
||||
<property name="toolTip">
|
||||
<string>Regular expressions for file paths to be excluded from scanning.</string>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addExcludedPatternButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeExcludedPatternButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user