forked from qt-creator/qt-creator
CppEditor: inline clangdiagnosticconfigswidget.ui
Change-Id: Ic0800378b31eac71c743cda13e7306c0c1131129 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -14,7 +14,7 @@ add_qtc_plugin(CppEditor
|
|||||||
clangdiagnosticconfig.cpp clangdiagnosticconfig.h
|
clangdiagnosticconfig.cpp clangdiagnosticconfig.h
|
||||||
clangdiagnosticconfigsmodel.cpp clangdiagnosticconfigsmodel.h
|
clangdiagnosticconfigsmodel.cpp clangdiagnosticconfigsmodel.h
|
||||||
clangdiagnosticconfigsselectionwidget.cpp clangdiagnosticconfigsselectionwidget.h
|
clangdiagnosticconfigsselectionwidget.cpp clangdiagnosticconfigsselectionwidget.h
|
||||||
clangdiagnosticconfigswidget.cpp clangdiagnosticconfigswidget.h clangdiagnosticconfigswidget.ui
|
clangdiagnosticconfigswidget.cpp clangdiagnosticconfigswidget.h
|
||||||
compileroptionsbuilder.cpp compileroptionsbuilder.h
|
compileroptionsbuilder.cpp compileroptionsbuilder.h
|
||||||
cppautocompleter.cpp cppautocompleter.h
|
cppautocompleter.cpp cppautocompleter.h
|
||||||
cppbuiltinmodelmanagersupport.cpp cppbuiltinmodelmanagersupport.h
|
cppbuiltinmodelmanagersupport.cpp cppbuiltinmodelmanagersupport.h
|
||||||
|
@@ -4,20 +4,24 @@
|
|||||||
#include "clangdiagnosticconfigswidget.h"
|
#include "clangdiagnosticconfigswidget.h"
|
||||||
|
|
||||||
#include "clangdiagnosticconfigsmodel.h"
|
#include "clangdiagnosticconfigsmodel.h"
|
||||||
#include "ui_clangdiagnosticconfigswidget.h"
|
|
||||||
#include "wrappablelineedit.h"
|
#include "wrappablelineedit.h"
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/executeondestruction.h>
|
#include <utils/executeondestruction.h>
|
||||||
|
#include <utils/infolabel.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QHeaderView>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -145,40 +149,57 @@ ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(const ClangDiagnostic
|
|||||||
const Id &configToSelect,
|
const Id &configToSelect,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_ui(new Ui::ClangDiagnosticConfigsWidget)
|
|
||||||
, m_configsModel(new ConfigsModel(configs))
|
, m_configsModel(new ConfigsModel(configs))
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
auto copyButton = new QPushButton(tr("Copy..."));
|
||||||
m_ui->configsView->setHeaderHidden(true);
|
m_renameButton = new QPushButton(tr("Rename..."));
|
||||||
m_ui->configsView->setUniformRowHeights(true);
|
m_removeButton = new QPushButton(tr("Remove"));
|
||||||
m_ui->configsView->setRootIsDecorated(false);
|
|
||||||
m_ui->configsView->setModel(m_configsModel);
|
m_infoLabel = new InfoLabel;
|
||||||
m_ui->configsView->setCurrentIndex(m_configsModel->itemForConfigId(configToSelect)->index());
|
|
||||||
m_ui->configsView->setItemsExpandable(false);
|
m_configsView = new QTreeView;
|
||||||
m_ui->configsView->expandAll();
|
m_configsView->setHeaderHidden(true);
|
||||||
connect(m_ui->configsView->selectionModel(),
|
m_configsView->setUniformRowHeights(true);
|
||||||
&QItemSelectionModel::currentChanged,
|
m_configsView->setRootIsDecorated(false);
|
||||||
this,
|
m_configsView->setModel(m_configsModel);
|
||||||
&ClangDiagnosticConfigsWidget::sync);
|
m_configsView->setCurrentIndex(m_configsModel->itemForConfigId(configToSelect)->index());
|
||||||
|
m_configsView->setItemsExpandable(false);
|
||||||
|
m_configsView->expandAll();
|
||||||
|
|
||||||
m_clangBaseChecks = new ClangBaseChecksWidget;
|
m_clangBaseChecks = new ClangBaseChecksWidget;
|
||||||
|
|
||||||
m_ui->tabWidget->addTab(m_clangBaseChecks, tr("Clang Warnings"));
|
m_tabWidget = new QTabWidget;
|
||||||
m_ui->tabWidget->setCurrentIndex(0);
|
m_tabWidget->addTab(m_clangBaseChecks, tr("Clang Warnings"));
|
||||||
|
|
||||||
connect(m_ui->copyButton, &QPushButton::clicked,
|
using namespace Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Row {
|
||||||
|
m_configsView,
|
||||||
|
Column {
|
||||||
|
copyButton,
|
||||||
|
m_renameButton,
|
||||||
|
m_removeButton,
|
||||||
|
st
|
||||||
|
}
|
||||||
|
},
|
||||||
|
m_infoLabel,
|
||||||
|
m_tabWidget
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(copyButton, &QPushButton::clicked,
|
||||||
this, &ClangDiagnosticConfigsWidget::onCopyButtonClicked);
|
this, &ClangDiagnosticConfigsWidget::onCopyButtonClicked);
|
||||||
connect(m_ui->renameButton, &QPushButton::clicked,
|
connect(m_renameButton, &QPushButton::clicked,
|
||||||
this, &ClangDiagnosticConfigsWidget::onRenameButtonClicked);
|
this, &ClangDiagnosticConfigsWidget::onRenameButtonClicked);
|
||||||
connect(m_ui->removeButton, &QPushButton::clicked,
|
connect(m_removeButton, &QPushButton::clicked,
|
||||||
this, &ClangDiagnosticConfigsWidget::onRemoveButtonClicked);
|
this, &ClangDiagnosticConfigsWidget::onRemoveButtonClicked);
|
||||||
|
connect(m_configsView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||||
|
this, &ClangDiagnosticConfigsWidget::sync);
|
||||||
|
|
||||||
connectClangOnlyOptionsChanged();
|
connectClangOnlyOptionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangDiagnosticConfigsWidget::~ClangDiagnosticConfigsWidget()
|
ClangDiagnosticConfigsWidget::~ClangDiagnosticConfigsWidget() = default;
|
||||||
{
|
|
||||||
delete m_ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClangDiagnosticConfigsWidget::onCopyButtonClicked()
|
void ClangDiagnosticConfigsWidget::onCopyButtonClicked()
|
||||||
{
|
{
|
||||||
@@ -195,7 +216,7 @@ void ClangDiagnosticConfigsWidget::onCopyButtonClicked()
|
|||||||
= ClangDiagnosticConfigsModel::createCustomConfig(config, newName);
|
= ClangDiagnosticConfigsModel::createCustomConfig(config, newName);
|
||||||
|
|
||||||
m_configsModel->appendCustomConfig(customConfig);
|
m_configsModel->appendCustomConfig(customConfig);
|
||||||
m_ui->configsView->setCurrentIndex(
|
m_configsView->setCurrentIndex(
|
||||||
m_configsModel->itemForConfigId(customConfig.id())->index());
|
m_configsModel->itemForConfigId(customConfig.id())->index());
|
||||||
sync();
|
sync();
|
||||||
m_clangBaseChecks->diagnosticOptionsTextEdit->setFocus();
|
m_clangBaseChecks->diagnosticOptionsTextEdit->setFocus();
|
||||||
@@ -221,7 +242,7 @@ void ClangDiagnosticConfigsWidget::onRenameButtonClicked()
|
|||||||
|
|
||||||
const ClangDiagnosticConfig ClangDiagnosticConfigsWidget::currentConfig() const
|
const ClangDiagnosticConfig ClangDiagnosticConfigsWidget::currentConfig() const
|
||||||
{
|
{
|
||||||
TreeItem *item = m_configsModel->itemForIndex(m_ui->configsView->currentIndex());
|
TreeItem *item = m_configsModel->itemForIndex(m_configsView->currentIndex());
|
||||||
return static_cast<ConfigNode *>(item)->config;
|
return static_cast<ConfigNode *>(item)->config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +250,7 @@ void ClangDiagnosticConfigsWidget::onRemoveButtonClicked()
|
|||||||
{
|
{
|
||||||
const 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_configsView->setCurrentIndex(m_configsModel->fallbackConfigIndex());
|
||||||
m_configsModel->removeConfig(configToRemove);
|
m_configsModel->removeConfig(configToRemove);
|
||||||
sync();
|
sync();
|
||||||
}
|
}
|
||||||
@@ -299,7 +320,7 @@ void ClangDiagnosticConfigsWidget::onClangOnlyOptionsChanged()
|
|||||||
|
|
||||||
void ClangDiagnosticConfigsWidget::sync()
|
void ClangDiagnosticConfigsWidget::sync()
|
||||||
{
|
{
|
||||||
if (!m_ui->configsView->currentIndex().isValid())
|
if (!m_configsView->currentIndex().isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
disconnectClangOnlyOptionsChanged();
|
disconnectClangOnlyOptionsChanged();
|
||||||
@@ -307,8 +328,8 @@ void ClangDiagnosticConfigsWidget::sync()
|
|||||||
|
|
||||||
// Update main button row
|
// Update main button row
|
||||||
const ClangDiagnosticConfig &config = currentConfig();
|
const ClangDiagnosticConfig &config = currentConfig();
|
||||||
m_ui->removeButton->setEnabled(!config.isReadOnly());
|
m_removeButton->setEnabled(!config.isReadOnly());
|
||||||
m_ui->renameButton->setEnabled(!config.isReadOnly());
|
m_renameButton->setEnabled(!config.isReadOnly());
|
||||||
|
|
||||||
// Update check box
|
// Update check box
|
||||||
m_clangBaseChecks->useFlagsFromBuildSystemCheckBox->setChecked(config.useBuildSystemWarnings());
|
m_clangBaseChecks->useFlagsFromBuildSystemCheckBox->setChecked(config.useBuildSystemWarnings());
|
||||||
@@ -321,9 +342,9 @@ void ClangDiagnosticConfigsWidget::sync()
|
|||||||
m_clangBaseChecks->setEnabled(!config.isReadOnly());
|
m_clangBaseChecks->setEnabled(!config.isReadOnly());
|
||||||
|
|
||||||
if (config.isReadOnly()) {
|
if (config.isReadOnly()) {
|
||||||
m_ui->infoLabel->setType(InfoLabel::Information);
|
m_infoLabel->setType(InfoLabel::Information);
|
||||||
m_ui->infoLabel->setText(tr("Copy this configuration to customize it."));
|
m_infoLabel->setText(tr("Copy this configuration to customize it."));
|
||||||
m_ui->infoLabel->setFilled(false);
|
m_infoLabel->setFilled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
syncExtraWidgets(config);
|
syncExtraWidgets(config);
|
||||||
@@ -347,13 +368,13 @@ 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(InfoLabel::Information);
|
m_infoLabel->setType(InfoLabel::Information);
|
||||||
m_ui->infoLabel->setText(tr("Configuration passes sanity checks."));
|
m_infoLabel->setText(tr("Configuration passes sanity checks."));
|
||||||
m_ui->infoLabel->setFilled(false);
|
m_infoLabel->setFilled(false);
|
||||||
} else {
|
} else {
|
||||||
m_ui->infoLabel->setType(InfoLabel::Error);
|
m_infoLabel->setType(InfoLabel::Error);
|
||||||
m_ui->infoLabel->setText(tr("%1").arg(errorMessage));
|
m_infoLabel->setText(tr("%1").arg(errorMessage));
|
||||||
m_ui->infoLabel->setFilled(true);
|
m_infoLabel->setFilled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,8 +392,7 @@ void ClangDiagnosticConfigsWidget::connectClangOnlyOptionsChanged()
|
|||||||
|
|
||||||
void ClangDiagnosticConfigsWidget::disconnectClangOnlyOptionsChanged()
|
void ClangDiagnosticConfigsWidget::disconnectClangOnlyOptionsChanged()
|
||||||
{
|
{
|
||||||
disconnect(m_clangBaseChecks->useFlagsFromBuildSystemCheckBox,
|
disconnect(m_clangBaseChecks->useFlagsFromBuildSystemCheckBox, &QCheckBox::stateChanged,
|
||||||
&QCheckBox::stateChanged,
|
|
||||||
this,
|
this,
|
||||||
&ClangDiagnosticConfigsWidget::onClangOnlyOptionsChanged);
|
&ClangDiagnosticConfigsWidget::onClangOnlyOptionsChanged);
|
||||||
disconnect(m_clangBaseChecks->diagnosticOptionsTextEdit->document(),
|
disconnect(m_clangBaseChecks->diagnosticOptionsTextEdit->document(),
|
||||||
@@ -388,7 +408,7 @@ ClangDiagnosticConfigs ClangDiagnosticConfigsWidget::configs() const
|
|||||||
|
|
||||||
QTabWidget *ClangDiagnosticConfigsWidget::tabWidget() const
|
QTabWidget *ClangDiagnosticConfigsWidget::tabWidget() const
|
||||||
{
|
{
|
||||||
return m_ui->tabWidget;
|
return m_tabWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // CppEditor namespace
|
} // CppEditor namespace
|
||||||
|
@@ -10,19 +10,18 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QPushButton;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
|
class QTreeView;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Utils { class InfoLabel; }
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
class ClangDiagnosticConfig;
|
class ClangDiagnosticConfig;
|
||||||
class ClangBaseChecksWidget;
|
class ClangBaseChecksWidget;
|
||||||
|
|
||||||
namespace Ui { class ClangDiagnosticConfigsWidget; }
|
|
||||||
|
|
||||||
class ConfigsModel;
|
class ConfigsModel;
|
||||||
|
|
||||||
class CPPEDITOR_EXPORT ClangDiagnosticConfigsWidget : public QWidget
|
class CPPEDITOR_EXPORT ClangDiagnosticConfigsWidget : public QWidget
|
||||||
@@ -59,11 +58,15 @@ private:
|
|||||||
void disconnectClangOnlyOptionsChanged();
|
void disconnectClangOnlyOptionsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ClangDiagnosticConfigsWidget *m_ui;
|
|
||||||
ConfigsModel *m_configsModel = nullptr;
|
ConfigsModel *m_configsModel = nullptr;
|
||||||
QHash<Utils::Id, QString> m_notAcceptedOptions;
|
QHash<Utils::Id, QString> m_notAcceptedOptions;
|
||||||
|
|
||||||
ClangBaseChecksWidget *m_clangBaseChecks = nullptr;
|
ClangBaseChecksWidget *m_clangBaseChecks = nullptr;
|
||||||
|
QTreeView *m_configsView;
|
||||||
|
Utils::InfoLabel *m_infoLabel;
|
||||||
|
QTabWidget *m_tabWidget;
|
||||||
|
QPushButton *m_renameButton;
|
||||||
|
QPushButton *m_removeButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // CppEditor namespace
|
} // CppEditor namespace
|
||||||
|
@@ -1,87 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>CppEditor::ClangDiagnosticConfigsWidget</class>
|
|
||||||
<widget class="QWidget" name="CppEditor::ClangDiagnosticConfigsWidget">
|
|
||||||
<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_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="configsView"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="copyButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Copy...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="renameButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Rename...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="removeButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::InfoLabel" name="infoLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>InfoText</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTabWidget" name="tabWidget"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::InfoLabel</class>
|
|
||||||
<extends>QLabel</extends>
|
|
||||||
<header location="global">utils/infolabel.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
@@ -49,7 +49,6 @@ QtcPlugin {
|
|||||||
"clangdiagnosticconfigsselectionwidget.h",
|
"clangdiagnosticconfigsselectionwidget.h",
|
||||||
"clangdiagnosticconfigswidget.cpp",
|
"clangdiagnosticconfigswidget.cpp",
|
||||||
"clangdiagnosticconfigswidget.h",
|
"clangdiagnosticconfigswidget.h",
|
||||||
"clangdiagnosticconfigswidget.ui",
|
|
||||||
"compileroptionsbuilder.cpp",
|
"compileroptionsbuilder.cpp",
|
||||||
"compileroptionsbuilder.h",
|
"compileroptionsbuilder.h",
|
||||||
"cppautocompleter.cpp",
|
"cppautocompleter.cpp",
|
||||||
|
Reference in New Issue
Block a user