forked from qt-creator/qt-creator
CppEditor: Inline clangbasechecks.ui
Change-Id: I630f794377936139eade42f56a8bd46175e84143 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -11,7 +11,6 @@ add_qtc_plugin(CppEditor
|
|||||||
builtineditordocumentparser.cpp builtineditordocumentparser.h
|
builtineditordocumentparser.cpp builtineditordocumentparser.h
|
||||||
builtineditordocumentprocessor.cpp builtineditordocumentprocessor.h
|
builtineditordocumentprocessor.cpp builtineditordocumentprocessor.h
|
||||||
builtinindexingsupport.cpp builtinindexingsupport.h
|
builtinindexingsupport.cpp builtinindexingsupport.h
|
||||||
clangbasechecks.ui
|
|
||||||
clangdiagnosticconfig.cpp clangdiagnosticconfig.h
|
clangdiagnosticconfig.cpp clangdiagnosticconfig.h
|
||||||
clangdiagnosticconfigsmodel.cpp clangdiagnosticconfigsmodel.h
|
clangdiagnosticconfigsmodel.cpp clangdiagnosticconfigsmodel.h
|
||||||
clangdiagnosticconfigsselectionwidget.cpp clangdiagnosticconfigsselectionwidget.h
|
clangdiagnosticconfigsselectionwidget.cpp clangdiagnosticconfigsselectionwidget.h
|
||||||
|
@@ -1,48 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>CppEditor::ClangBaseChecks</class>
|
|
||||||
<widget class="QWidget" name="CppEditor::ClangBaseChecks">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>665</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>For appropriate options, consult the GCC or Clang manual pages or the <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html">GCC online documentation</a>.</string>
|
|
||||||
</property>
|
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="useFlagsFromBuildSystemCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use diagnostic flags from build system</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="CppEditor::WrappableLineEdit" name="diagnosticOptionsTextEdit"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>CppEditor::WrappableLineEdit</class>
|
|
||||||
<extends>QLineEdit</extends>
|
|
||||||
<header location="global">cppeditor/wrappablelineedit.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
@@ -5,19 +5,25 @@
|
|||||||
|
|
||||||
#include "clangdiagnosticconfigsmodel.h"
|
#include "clangdiagnosticconfigsmodel.h"
|
||||||
#include "ui_clangdiagnosticconfigswidget.h"
|
#include "ui_clangdiagnosticconfigswidget.h"
|
||||||
#include "ui_clangbasechecks.h"
|
#include "wrappablelineedit.h"
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/executeondestruction.h>
|
#include <utils/executeondestruction.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
class ConfigNode : public Utils::TreeItem
|
class ConfigNode : public TreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfigNode(const ClangDiagnosticConfig &config)
|
ConfigNode(const ClangDiagnosticConfig &config)
|
||||||
@@ -34,11 +40,11 @@ public:
|
|||||||
ClangDiagnosticConfig config;
|
ClangDiagnosticConfig config;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupNode : public Utils::StaticTreeItem
|
class GroupNode : public StaticTreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GroupNode(const QString &text)
|
GroupNode(const QString &text)
|
||||||
: Utils::StaticTreeItem(text)
|
: StaticTreeItem(text)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Qt::ItemFlags flags(int) const final { return {}; }
|
Qt::ItemFlags flags(int) const final { return {}; }
|
||||||
@@ -49,11 +55,11 @@ public:
|
|||||||
return QApplication::palette().color(QPalette::ColorGroup::Normal,
|
return QApplication::palette().color(QPalette::ColorGroup::Normal,
|
||||||
QPalette::ColorRole::Text);
|
QPalette::ColorRole::Text);
|
||||||
}
|
}
|
||||||
return Utils::StaticTreeItem::data(column, role);
|
return StaticTreeItem::data(column, role);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigsModel : public Utils::TreeModel<Utils::TreeItem, GroupNode, ConfigNode>
|
class ConfigsModel : public TreeModel<TreeItem, GroupNode, ConfigNode>
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -66,7 +72,7 @@ public:
|
|||||||
rootItem()->appendChild(m_customRoot);
|
rootItem()->appendChild(m_customRoot);
|
||||||
|
|
||||||
for (const ClangDiagnosticConfig &config : configs) {
|
for (const ClangDiagnosticConfig &config : configs) {
|
||||||
Utils::TreeItem *parent = config.isReadOnly() ? m_builtinRoot : m_customRoot;
|
TreeItem *parent = config.isReadOnly() ? m_builtinRoot : m_customRoot;
|
||||||
parent->appendChild(new ConfigNode(config));
|
parent->appendChild(new ConfigNode(config));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,13 +94,13 @@ public:
|
|||||||
m_customRoot->appendChild(new ConfigNode(config));
|
m_customRoot->appendChild(new ConfigNode(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeConfig(const Utils::Id &id)
|
void removeConfig(const Id &id)
|
||||||
{
|
{
|
||||||
ConfigNode *node = itemForConfigId(id);
|
ConfigNode *node = itemForConfigId(id);
|
||||||
node->parent()->removeChildAt(node->indexInParent());
|
node->parent()->removeChildAt(node->indexInParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigNode *itemForConfigId(const Utils::Id &id) const
|
ConfigNode *itemForConfigId(const Id &id) const
|
||||||
{
|
{
|
||||||
return findItemAtLevel<2>([id](const ConfigNode *node) {
|
return findItemAtLevel<2>([id](const ConfigNode *node) {
|
||||||
return node->config.id() == id;
|
return node->config.id() == id;
|
||||||
@@ -102,12 +108,41 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::TreeItem *m_builtinRoot = nullptr;
|
TreeItem *m_builtinRoot = nullptr;
|
||||||
Utils::TreeItem *m_customRoot = nullptr;
|
TreeItem *m_customRoot = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ClangBaseChecksWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(CppEditor::ClangBaseChecks)
|
||||||
|
|
||||||
|
public:
|
||||||
|
ClangBaseChecksWidget()
|
||||||
|
{
|
||||||
|
auto label = new QLabel(tr("For appropriate options, consult the GCC or Clang manual "
|
||||||
|
"pages or the <a href=\"https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html\">"
|
||||||
|
"GCC online documentation</a>."));
|
||||||
|
label->setOpenExternalLinks(true);
|
||||||
|
|
||||||
|
useFlagsFromBuildSystemCheckBox = new QCheckBox(tr("Use diagnostic flags from build system"));
|
||||||
|
|
||||||
|
diagnosticOptionsTextEdit = new WrappableLineEdit;
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
label,
|
||||||
|
useFlagsFromBuildSystemCheckBox,
|
||||||
|
diagnosticOptionsTextEdit
|
||||||
|
}.attachTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QCheckBox *useFlagsFromBuildSystemCheckBox;
|
||||||
|
WrappableLineEdit *diagnosticOptionsTextEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(const ClangDiagnosticConfigs &configs,
|
ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(const ClangDiagnosticConfigs &configs,
|
||||||
const Utils::Id &configToSelect,
|
const Id &configToSelect,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_ui(new Ui::ClangDiagnosticConfigsWidget)
|
, m_ui(new Ui::ClangDiagnosticConfigsWidget)
|
||||||
@@ -126,11 +161,9 @@ ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(const ClangDiagnostic
|
|||||||
this,
|
this,
|
||||||
&ClangDiagnosticConfigsWidget::sync);
|
&ClangDiagnosticConfigsWidget::sync);
|
||||||
|
|
||||||
m_clangBaseChecks = std::make_unique<CppEditor::Ui::ClangBaseChecks>();
|
m_clangBaseChecks = new ClangBaseChecksWidget;
|
||||||
m_clangBaseChecksWidget = new QWidget();
|
|
||||||
m_clangBaseChecks->setupUi(m_clangBaseChecksWidget);
|
|
||||||
|
|
||||||
m_ui->tabWidget->addTab(m_clangBaseChecksWidget, tr("Clang Warnings"));
|
m_ui->tabWidget->addTab(m_clangBaseChecks, tr("Clang Warnings"));
|
||||||
m_ui->tabWidget->setCurrentIndex(0);
|
m_ui->tabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
connect(m_ui->copyButton, &QPushButton::clicked,
|
connect(m_ui->copyButton, &QPushButton::clicked,
|
||||||
@@ -188,13 +221,13 @@ void ClangDiagnosticConfigsWidget::onRenameButtonClicked()
|
|||||||
|
|
||||||
const ClangDiagnosticConfig ClangDiagnosticConfigsWidget::currentConfig() const
|
const ClangDiagnosticConfig ClangDiagnosticConfigsWidget::currentConfig() const
|
||||||
{
|
{
|
||||||
Utils::TreeItem *item = m_configsModel->itemForIndex(m_ui->configsView->currentIndex());
|
TreeItem *item = m_configsModel->itemForIndex(m_ui->configsView->currentIndex());
|
||||||
return static_cast<ConfigNode *>(item)->config;
|
return static_cast<ConfigNode *>(item)->config;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangDiagnosticConfigsWidget::onRemoveButtonClicked()
|
void ClangDiagnosticConfigsWidget::onRemoveButtonClicked()
|
||||||
{
|
{
|
||||||
const Utils::Id configToRemove = currentConfig().id();
|
const Id configToRemove = currentConfig().id();
|
||||||
if (m_configsModel->customConfigsCount() == 1)
|
if (m_configsModel->customConfigsCount() == 1)
|
||||||
m_ui->configsView->setCurrentIndex(m_configsModel->fallbackConfigIndex());
|
m_ui->configsView->setCurrentIndex(m_configsModel->fallbackConfigIndex());
|
||||||
m_configsModel->removeConfig(configToRemove);
|
m_configsModel->removeConfig(configToRemove);
|
||||||
@@ -270,7 +303,7 @@ void ClangDiagnosticConfigsWidget::sync()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
disconnectClangOnlyOptionsChanged();
|
disconnectClangOnlyOptionsChanged();
|
||||||
Utils::ExecuteOnDestruction e([this] { connectClangOnlyOptionsChanged(); });
|
ExecuteOnDestruction e([this] { connectClangOnlyOptionsChanged(); });
|
||||||
|
|
||||||
// Update main button row
|
// Update main button row
|
||||||
const ClangDiagnosticConfig &config = currentConfig();
|
const ClangDiagnosticConfig &config = currentConfig();
|
||||||
@@ -285,10 +318,10 @@ void ClangDiagnosticConfigsWidget::sync()
|
|||||||
? m_notAcceptedOptions.value(config.id())
|
? m_notAcceptedOptions.value(config.id())
|
||||||
: config.clangOptions().join(QLatin1Char(' '));
|
: config.clangOptions().join(QLatin1Char(' '));
|
||||||
setDiagnosticOptions(options);
|
setDiagnosticOptions(options);
|
||||||
m_clangBaseChecksWidget->setEnabled(!config.isReadOnly());
|
m_clangBaseChecks->setEnabled(!config.isReadOnly());
|
||||||
|
|
||||||
if (config.isReadOnly()) {
|
if (config.isReadOnly()) {
|
||||||
m_ui->infoLabel->setType(Utils::InfoLabel::Information);
|
m_ui->infoLabel->setType(InfoLabel::Information);
|
||||||
m_ui->infoLabel->setText(tr("Copy this configuration to customize it."));
|
m_ui->infoLabel->setText(tr("Copy this configuration to customize it."));
|
||||||
m_ui->infoLabel->setFilled(false);
|
m_ui->infoLabel->setFilled(false);
|
||||||
}
|
}
|
||||||
@@ -314,11 +347,11 @@ void ClangDiagnosticConfigsWidget::setDiagnosticOptions(const QString &options)
|
|||||||
void ClangDiagnosticConfigsWidget::updateValidityWidgets(const QString &errorMessage)
|
void ClangDiagnosticConfigsWidget::updateValidityWidgets(const QString &errorMessage)
|
||||||
{
|
{
|
||||||
if (errorMessage.isEmpty()) {
|
if (errorMessage.isEmpty()) {
|
||||||
m_ui->infoLabel->setType(Utils::InfoLabel::Information);
|
m_ui->infoLabel->setType(InfoLabel::Information);
|
||||||
m_ui->infoLabel->setText(tr("Configuration passes sanity checks."));
|
m_ui->infoLabel->setText(tr("Configuration passes sanity checks."));
|
||||||
m_ui->infoLabel->setFilled(false);
|
m_ui->infoLabel->setFilled(false);
|
||||||
} else {
|
} else {
|
||||||
m_ui->infoLabel->setType(Utils::InfoLabel::Error);
|
m_ui->infoLabel->setType(InfoLabel::Error);
|
||||||
m_ui->infoLabel->setText(tr("%1").arg(errorMessage));
|
m_ui->infoLabel->setText(tr("%1").arg(errorMessage));
|
||||||
m_ui->infoLabel->setFilled(true);
|
m_ui->infoLabel->setFilled(true);
|
||||||
}
|
}
|
||||||
|
@@ -17,12 +17,11 @@ class QTabWidget;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
class ClangDiagnosticConfig;
|
|
||||||
|
|
||||||
namespace Ui {
|
class ClangDiagnosticConfig;
|
||||||
class ClangDiagnosticConfigsWidget;
|
class ClangBaseChecksWidget;
|
||||||
class ClangBaseChecks;
|
|
||||||
}
|
namespace Ui { class ClangDiagnosticConfigsWidget; }
|
||||||
|
|
||||||
class ConfigsModel;
|
class ConfigsModel;
|
||||||
|
|
||||||
@@ -64,8 +63,7 @@ private:
|
|||||||
ConfigsModel *m_configsModel = nullptr;
|
ConfigsModel *m_configsModel = nullptr;
|
||||||
QHash<Utils::Id, QString> m_notAcceptedOptions;
|
QHash<Utils::Id, QString> m_notAcceptedOptions;
|
||||||
|
|
||||||
std::unique_ptr<Ui::ClangBaseChecks> m_clangBaseChecks;
|
ClangBaseChecksWidget *m_clangBaseChecks = nullptr;
|
||||||
QWidget *m_clangBaseChecksWidget = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // CppEditor namespace
|
} // CppEditor namespace
|
||||||
|
@@ -41,7 +41,6 @@ QtcPlugin {
|
|||||||
"builtineditordocumentprocessor.h",
|
"builtineditordocumentprocessor.h",
|
||||||
"builtinindexingsupport.cpp",
|
"builtinindexingsupport.cpp",
|
||||||
"builtinindexingsupport.h",
|
"builtinindexingsupport.h",
|
||||||
"clangbasechecks.ui", // FIXME: Is this used at all?
|
|
||||||
"clangdiagnosticconfig.cpp",
|
"clangdiagnosticconfig.cpp",
|
||||||
"clangdiagnosticconfig.h",
|
"clangdiagnosticconfig.h",
|
||||||
"clangdiagnosticconfigsmodel.cpp",
|
"clangdiagnosticconfigsmodel.cpp",
|
||||||
|
Reference in New Issue
Block a user