forked from qt-creator/qt-creator
CppTools: Split diagnostic settings and selection
Now selection is only consists of combobox and a "Manage" button to diagnostic configurations. Diagnostic configurations are moved to the modal dialog which is shown by clicking the mentioned "Manage" button. Change-Id: I607fb923c97e8730448548708f3aaf32ce1983c8 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangdiagnosticconfigsselectionwidget.h"
|
||||
|
||||
#include "cppcodemodelsettings.h"
|
||||
#include "cpptoolsreuse.h"
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
ClangDiagnosticConfigsSelectionWidget::ClangDiagnosticConfigsSelectionWidget(QWidget *parent)
|
||||
: QComboBox(parent)
|
||||
{
|
||||
refresh(codeModelSettings()->clangDiagnosticConfigId());
|
||||
|
||||
connectToCurrentIndexChanged();
|
||||
}
|
||||
|
||||
Core::Id ClangDiagnosticConfigsSelectionWidget::currentConfigId() const
|
||||
{
|
||||
return Core::Id::fromSetting(currentData());
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsSelectionWidget::connectToCurrentIndexChanged()
|
||||
{
|
||||
m_currentIndexChangedConnection
|
||||
= connect(this,
|
||||
static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
[this]() { emit currentConfigChanged(currentConfigId()); });
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsSelectionWidget::disconnectFromCurrentIndexChanged()
|
||||
{
|
||||
disconnect(m_currentIndexChangedConnection);
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsSelectionWidget::refresh(Core::Id id)
|
||||
{
|
||||
disconnectFromCurrentIndexChanged();
|
||||
|
||||
int configToSelectIndex = -1;
|
||||
clear();
|
||||
m_diagnosticConfigsModel = ClangDiagnosticConfigsModel(
|
||||
codeModelSettings()->clangCustomDiagnosticConfigs());
|
||||
const int size = m_diagnosticConfigsModel.size();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
const ClangDiagnosticConfig &config = m_diagnosticConfigsModel.at(i);
|
||||
const QString displayName
|
||||
= ClangDiagnosticConfigsModel::displayNameWithBuiltinIndication(config);
|
||||
addItem(displayName, config.id().toSetting());
|
||||
|
||||
if (id == config.id())
|
||||
configToSelectIndex = i;
|
||||
}
|
||||
|
||||
if (configToSelectIndex != -1)
|
||||
setCurrentIndex(configToSelectIndex);
|
||||
else
|
||||
emit currentConfigChanged(currentConfigId());
|
||||
|
||||
connectToCurrentIndexChanged();
|
||||
}
|
||||
|
||||
} // CppTools namespace
|
||||
58
src/plugins/cpptools/clangdiagnosticconfigsselectionwidget.h
Normal file
58
src/plugins/cpptools/clangdiagnosticconfigsselectionwidget.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include "clangdiagnosticconfigsmodel.h"
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class CPPTOOLS_EXPORT ClangDiagnosticConfigsSelectionWidget : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ClangDiagnosticConfigsSelectionWidget(QWidget *parent = nullptr);
|
||||
|
||||
Core::Id currentConfigId() const;
|
||||
|
||||
void refresh(Core::Id id);
|
||||
|
||||
signals:
|
||||
void currentConfigChanged(const Core::Id ¤tConfigId);
|
||||
|
||||
private:
|
||||
void connectToCurrentIndexChanged();
|
||||
void disconnectFromCurrentIndexChanged();
|
||||
|
||||
QMetaObject::Connection m_currentIndexChangedConnection;
|
||||
ClangDiagnosticConfigsModel m_diagnosticConfigsModel;
|
||||
};
|
||||
|
||||
} // CppTools namespace
|
||||
@@ -24,32 +24,39 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangdiagnosticconfigswidget.h"
|
||||
|
||||
#include "cppcodemodelsettings.h"
|
||||
#include "cpptoolsreuse.h"
|
||||
#include "ui_clangdiagnosticconfigswidget.h"
|
||||
#include "ui_clangbasechecks.h"
|
||||
#include "ui_clazychecks.h"
|
||||
#include "ui_tidychecks.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QInputDialog>
|
||||
#include <QPushButton>
|
||||
#include <QUuid>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(
|
||||
const ClangDiagnosticConfigsModel &diagnosticConfigsModel,
|
||||
const Core::Id &configToSelect,
|
||||
QWidget *parent)
|
||||
ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ClangDiagnosticConfigsWidget)
|
||||
, m_diagnosticConfigsModel(diagnosticConfigsModel)
|
||||
, m_diagnosticConfigsModel(codeModelSettings()->clangCustomDiagnosticConfigs())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setupTabs();
|
||||
|
||||
m_selectedConfigIndex = m_diagnosticConfigsModel.indexOfConfig(
|
||||
codeModelSettings()->clangDiagnosticConfigId());
|
||||
|
||||
connectConfigChooserCurrentIndex();
|
||||
connect(m_ui->copyButton, &QPushButton::clicked,
|
||||
this, &ClangDiagnosticConfigsWidget::onCopyButtonClicked);
|
||||
@@ -57,7 +64,7 @@ ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(
|
||||
this, &ClangDiagnosticConfigsWidget::onRemoveButtonClicked);
|
||||
connectDiagnosticOptionsChanged();
|
||||
|
||||
syncWidgetsToModel(configToSelect);
|
||||
syncWidgetsToModel();
|
||||
}
|
||||
|
||||
ClangDiagnosticConfigsWidget::~ClangDiagnosticConfigsWidget()
|
||||
@@ -65,11 +72,10 @@ ClangDiagnosticConfigsWidget::~ClangDiagnosticConfigsWidget()
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::onCurrentConfigChanged(int)
|
||||
void ClangDiagnosticConfigsWidget::onCurrentConfigChanged(int index)
|
||||
{
|
||||
m_selectedConfigIndex = index;
|
||||
syncOtherWidgetsToComboBox();
|
||||
|
||||
emit currentConfigChanged(currentConfigId());
|
||||
}
|
||||
|
||||
static ClangDiagnosticConfig createCustomConfig(const ClangDiagnosticConfig &config,
|
||||
@@ -85,7 +91,7 @@ static ClangDiagnosticConfig createCustomConfig(const ClangDiagnosticConfig &con
|
||||
|
||||
void ClangDiagnosticConfigsWidget::onCopyButtonClicked()
|
||||
{
|
||||
const ClangDiagnosticConfig &config = currentConfig();
|
||||
const ClangDiagnosticConfig &config = selectedConfig();
|
||||
|
||||
bool diaglogAccepted = false;
|
||||
const QString newName = QInputDialog::getText(this,
|
||||
@@ -104,9 +110,19 @@ void ClangDiagnosticConfigsWidget::onCopyButtonClicked()
|
||||
}
|
||||
}
|
||||
|
||||
const ClangDiagnosticConfig &ClangDiagnosticConfigsWidget::selectedConfig() const
|
||||
{
|
||||
return m_diagnosticConfigsModel.at(m_selectedConfigIndex);
|
||||
}
|
||||
|
||||
Core::Id ClangDiagnosticConfigsWidget::selectedConfigId() const
|
||||
{
|
||||
return selectedConfig().id();
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::onRemoveButtonClicked()
|
||||
{
|
||||
m_diagnosticConfigsModel.removeConfigWithId(currentConfigId());
|
||||
m_diagnosticConfigsModel.removeConfigWithId(selectedConfigId());
|
||||
emit customConfigsChanged(customConfigs());
|
||||
|
||||
syncConfigChooserToModel();
|
||||
@@ -114,7 +130,7 @@ void ClangDiagnosticConfigsWidget::onRemoveButtonClicked()
|
||||
|
||||
void ClangDiagnosticConfigsWidget::onClangTidyModeChanged(int index)
|
||||
{
|
||||
ClangDiagnosticConfig config = currentConfig();
|
||||
ClangDiagnosticConfig config = selectedConfig();
|
||||
config.setClangTidyMode(static_cast<ClangDiagnosticConfig::TidyMode>(index));
|
||||
updateConfig(config);
|
||||
syncClangTidyWidgets(config);
|
||||
@@ -123,7 +139,7 @@ void ClangDiagnosticConfigsWidget::onClangTidyModeChanged(int index)
|
||||
void ClangDiagnosticConfigsWidget::onClangTidyItemChanged(QListWidgetItem *item)
|
||||
{
|
||||
const QString prefix = item->text();
|
||||
ClangDiagnosticConfig config = currentConfig();
|
||||
ClangDiagnosticConfig config = selectedConfig();
|
||||
QString checks = config.clangTidyChecksPrefixes();
|
||||
item->checkState() == Qt::Checked
|
||||
? checks.append(',' + prefix)
|
||||
@@ -134,7 +150,7 @@ void ClangDiagnosticConfigsWidget::onClangTidyItemChanged(QListWidgetItem *item)
|
||||
|
||||
void ClangDiagnosticConfigsWidget::onClangTidyLineEdited(const QString &text)
|
||||
{
|
||||
ClangDiagnosticConfig config = currentConfig();
|
||||
ClangDiagnosticConfig config = selectedConfig();
|
||||
config.setClangTidyChecksString(text);
|
||||
updateConfig(config);
|
||||
}
|
||||
@@ -156,7 +172,7 @@ void ClangDiagnosticConfigsWidget::onClazyRadioButtonChanged(bool checked)
|
||||
else if (m_clazyChecks->clazyRadioLevel3->isChecked())
|
||||
checks = "level3";
|
||||
|
||||
ClangDiagnosticConfig config = currentConfig();
|
||||
ClangDiagnosticConfig config = selectedConfig();
|
||||
config.setClazyChecks(checks);
|
||||
updateConfig(config);
|
||||
}
|
||||
@@ -209,13 +225,13 @@ void ClangDiagnosticConfigsWidget::onDiagnosticOptionsEdited()
|
||||
updateValidityWidgets(errorMessage);
|
||||
if (!errorMessage.isEmpty()) {
|
||||
// Remember the entered options in case the user will switch back.
|
||||
m_notAcceptedOptions.insert(currentConfigId(), diagnosticOptions);
|
||||
m_notAcceptedOptions.insert(selectedConfigId(), diagnosticOptions);
|
||||
return;
|
||||
}
|
||||
m_notAcceptedOptions.remove(currentConfigId());
|
||||
m_notAcceptedOptions.remove(selectedConfigId());
|
||||
|
||||
// Commit valid changes
|
||||
ClangDiagnosticConfig updatedConfig = currentConfig();
|
||||
ClangDiagnosticConfig updatedConfig = selectedConfig();
|
||||
updatedConfig.setClangOptions(normalizedOptions);
|
||||
updateConfig(updatedConfig);
|
||||
}
|
||||
@@ -230,9 +246,10 @@ void ClangDiagnosticConfigsWidget::syncConfigChooserToModel(const Core::Id &conf
|
||||
{
|
||||
disconnectConfigChooserCurrentIndex();
|
||||
|
||||
const int previousCurrentIndex = m_ui->configChooserComboBox->currentIndex();
|
||||
m_ui->configChooserComboBox->clear();
|
||||
int configToSelectIndex = -1;
|
||||
m_selectedConfigIndex = std::max(std::min(m_selectedConfigIndex,
|
||||
m_diagnosticConfigsModel.size() - 1),
|
||||
0);
|
||||
|
||||
const int size = m_diagnosticConfigsModel.size();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
@@ -242,17 +259,12 @@ void ClangDiagnosticConfigsWidget::syncConfigChooserToModel(const Core::Id &conf
|
||||
m_ui->configChooserComboBox->addItem(displayName, config.id().toSetting());
|
||||
|
||||
if (configToSelect == config.id())
|
||||
configToSelectIndex = i;
|
||||
m_selectedConfigIndex = i;
|
||||
}
|
||||
|
||||
connectConfigChooserCurrentIndex();
|
||||
|
||||
if (configToSelectIndex != -1) {
|
||||
m_ui->configChooserComboBox->setCurrentIndex(configToSelectIndex);
|
||||
} else if (previousCurrentIndex != m_ui->configChooserComboBox->currentIndex()) {
|
||||
syncOtherWidgetsToComboBox();
|
||||
emit currentConfigChanged(currentConfigId());
|
||||
}
|
||||
m_ui->configChooserComboBox->setCurrentIndex(m_selectedConfigIndex);
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::syncOtherWidgetsToComboBox()
|
||||
@@ -260,7 +272,7 @@ void ClangDiagnosticConfigsWidget::syncOtherWidgetsToComboBox()
|
||||
if (isConfigChooserEmpty())
|
||||
return;
|
||||
|
||||
const ClangDiagnosticConfig &config = currentConfig();
|
||||
const ClangDiagnosticConfig &config = selectedConfig();
|
||||
|
||||
// Update main button row
|
||||
m_ui->removeButton->setEnabled(!config.isReadOnly());
|
||||
@@ -363,11 +375,6 @@ bool ClangDiagnosticConfigsWidget::isConfigChooserEmpty() const
|
||||
return m_ui->configChooserComboBox->count() == 0;
|
||||
}
|
||||
|
||||
const ClangDiagnosticConfig &ClangDiagnosticConfigsWidget::currentConfig() const
|
||||
{
|
||||
return m_diagnosticConfigsModel.configWithId(currentConfigId());
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::setDiagnosticOptions(const QString &options)
|
||||
{
|
||||
if (options != m_clangBaseChecks->diagnosticOptionsTextEdit->document()->toPlainText()) {
|
||||
@@ -464,11 +471,6 @@ void ClangDiagnosticConfigsWidget::disconnectDiagnosticOptionsChanged()
|
||||
&ClangDiagnosticConfigsWidget::onDiagnosticOptionsEdited);
|
||||
}
|
||||
|
||||
Core::Id ClangDiagnosticConfigsWidget::currentConfigId() const
|
||||
{
|
||||
return Core::Id::fromSetting(m_ui->configChooserComboBox->currentData());
|
||||
}
|
||||
|
||||
ClangDiagnosticConfigs ClangDiagnosticConfigsWidget::customConfigs() const
|
||||
{
|
||||
const ClangDiagnosticConfigs allConfigs = m_diagnosticConfigsModel.configs();
|
||||
@@ -478,14 +480,6 @@ ClangDiagnosticConfigs ClangDiagnosticConfigsWidget::customConfigs() const
|
||||
});
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::refresh(
|
||||
const ClangDiagnosticConfigsModel &diagnosticConfigsModel,
|
||||
const Core::Id &configToSelect)
|
||||
{
|
||||
m_diagnosticConfigsModel = diagnosticConfigsModel;
|
||||
syncWidgetsToModel(configToSelect);
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::setupTabs()
|
||||
{
|
||||
m_clangBaseChecks.reset(new CppTools::Ui::ClangBaseChecks);
|
||||
@@ -513,4 +507,33 @@ void ClangDiagnosticConfigsWidget::setupTabs()
|
||||
m_ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void connectToClangDiagnosticConfigsDialog(QPushButton *button)
|
||||
{
|
||||
QObject::connect(button, &QPushButton::clicked, []() {
|
||||
ClangDiagnosticConfigsWidget *widget = new ClangDiagnosticConfigsWidget;
|
||||
QDialog dialog;
|
||||
dialog.setWindowTitle(widget->tr("Diagnostic Configurations"));
|
||||
dialog.setLayout(new QVBoxLayout);
|
||||
dialog.layout()->setMargin(0);
|
||||
dialog.layout()->setSpacing(0);
|
||||
dialog.layout()->addWidget(widget);
|
||||
auto *buttonsBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
dialog.layout()->addWidget(buttonsBox);
|
||||
QObject::connect(buttonsBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
||||
QObject::connect(buttonsBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
||||
|
||||
QObject::connect(&dialog, &QDialog::accepted, [widget]() {
|
||||
QSharedPointer<CppCodeModelSettings> settings = codeModelSettings();
|
||||
const ClangDiagnosticConfigs oldDiagnosticConfigs
|
||||
= settings->clangCustomDiagnosticConfigs();
|
||||
const ClangDiagnosticConfigs currentDiagnosticConfigs = widget->customConfigs();
|
||||
if (oldDiagnosticConfigs != currentDiagnosticConfigs) {
|
||||
settings->setClangCustomDiagnosticConfigs(currentDiagnosticConfigs);
|
||||
settings->toSettings(Core::ICore::settings());
|
||||
}
|
||||
});
|
||||
dialog.exec();
|
||||
});
|
||||
}
|
||||
|
||||
} // CppTools namespace
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QListWidgetItem;
|
||||
class QPushButton;
|
||||
class QRadioButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -54,26 +55,18 @@ class CPPTOOLS_EXPORT ClangDiagnosticConfigsWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ClangDiagnosticConfigsWidget(
|
||||
const ClangDiagnosticConfigsModel &diagnosticConfigsModel = ClangDiagnosticConfigsModel(),
|
||||
const Core::Id &configToSelect = Core::Id(),
|
||||
QWidget *parent = nullptr);
|
||||
explicit ClangDiagnosticConfigsWidget(QWidget *parent = nullptr);
|
||||
~ClangDiagnosticConfigsWidget() override;
|
||||
|
||||
Core::Id currentConfigId() const;
|
||||
ClangDiagnosticConfigs customConfigs() const;
|
||||
|
||||
void refresh(const ClangDiagnosticConfigsModel &diagnosticConfigsModel,
|
||||
const Core::Id &configToSelect);
|
||||
|
||||
signals:
|
||||
void currentConfigChanged(const Core::Id ¤tConfigId);
|
||||
void customConfigsChanged(const CppTools::ClangDiagnosticConfigs &customConfigs);
|
||||
|
||||
private:
|
||||
void setupTabs();
|
||||
|
||||
void onCurrentConfigChanged(int);
|
||||
void onCurrentConfigChanged(int index);
|
||||
void onCopyButtonClicked();
|
||||
void onRemoveButtonClicked();
|
||||
void onClangTidyModeChanged(int index);
|
||||
@@ -93,7 +86,8 @@ private:
|
||||
void updateConfig(const CppTools::ClangDiagnosticConfig &config);
|
||||
|
||||
bool isConfigChooserEmpty() const;
|
||||
const ClangDiagnosticConfig ¤tConfig() const;
|
||||
const ClangDiagnosticConfig &selectedConfig() const;
|
||||
Core::Id selectedConfigId() const;
|
||||
|
||||
void setDiagnosticOptions(const QString &options);
|
||||
void updateValidityWidgets(const QString &errorMessage);
|
||||
@@ -121,6 +115,10 @@ private:
|
||||
|
||||
std::unique_ptr<CppTools::Ui::TidyChecks> m_tidyChecks;
|
||||
QWidget *m_tidyChecksWidget = nullptr;
|
||||
|
||||
int m_selectedConfigIndex = 0;
|
||||
};
|
||||
|
||||
CPPTOOLS_EXPORT void connectToClangDiagnosticConfigsDialog(QPushButton *button);
|
||||
|
||||
} // CppTools namespace
|
||||
|
||||
@@ -43,8 +43,6 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(QWidget *parent)
|
||||
, m_ui(new Ui::CppCodeModelSettingsPage)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->clangSettingsGroupBox->setVisible(true);
|
||||
}
|
||||
|
||||
CppCodeModelSettingsWidget::~CppCodeModelSettingsWidget()
|
||||
@@ -77,13 +75,21 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets()
|
||||
|
||||
m_ui->clangCodeModelIsDisabledHint->setVisible(!isClangActive);
|
||||
m_ui->clangCodeModelIsEnabledHint->setVisible(isClangActive);
|
||||
m_ui->clangSettingsGroupBox->setEnabled(isClangActive);
|
||||
for (int i = 0; i < m_ui->clangDiagnosticsLayout->count(); ++i) {
|
||||
QWidget *widget = m_ui->clangDiagnosticsLayout->itemAt(i)->widget();
|
||||
if (widget)
|
||||
widget->setEnabled(isClangActive);
|
||||
}
|
||||
|
||||
ClangDiagnosticConfigsModel diagnosticConfigsModel(m_settings->clangCustomDiagnosticConfigs());
|
||||
m_clangDiagnosticConfigsWidget = new ClangDiagnosticConfigsWidget(
|
||||
diagnosticConfigsModel,
|
||||
m_settings->clangDiagnosticConfigId());
|
||||
m_ui->clangSettingsGroupBox->layout()->addWidget(m_clangDiagnosticConfigsWidget);
|
||||
connectToClangDiagnosticConfigsDialog(m_ui->manageButton);
|
||||
|
||||
connect(m_settings.data(), &CppCodeModelSettings::changed,
|
||||
this, [this]() {
|
||||
m_ui->clangDiagnosticConfigsSelectionWidget->refresh(
|
||||
m_ui->clangDiagnosticConfigsSelectionWidget->currentConfigId());
|
||||
if (applyClangCodeModelWidgetsToSettings())
|
||||
m_settings->toSettings(Core::ICore::settings());
|
||||
});
|
||||
}
|
||||
|
||||
void CppCodeModelSettingsWidget::setupGeneralWidgets()
|
||||
@@ -100,24 +106,14 @@ void CppCodeModelSettingsWidget::setupGeneralWidgets()
|
||||
|
||||
bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const
|
||||
{
|
||||
bool settingsChanged = false;
|
||||
|
||||
const Core::Id oldConfigId = m_settings->clangDiagnosticConfigId();
|
||||
const Core::Id currentConfigId = m_clangDiagnosticConfigsWidget->currentConfigId();
|
||||
const Core::Id currentConfigId = m_ui->clangDiagnosticConfigsSelectionWidget->currentConfigId();
|
||||
if (oldConfigId != currentConfigId) {
|
||||
m_settings->setClangDiagnosticConfigId(currentConfigId);
|
||||
settingsChanged = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
const ClangDiagnosticConfigs oldDiagnosticConfigs = m_settings->clangCustomDiagnosticConfigs();
|
||||
const ClangDiagnosticConfigs currentDiagnosticConfigs
|
||||
= m_clangDiagnosticConfigsWidget->customConfigs();
|
||||
if (oldDiagnosticConfigs != currentDiagnosticConfigs) {
|
||||
m_settings->setClangCustomDiagnosticConfigs(currentDiagnosticConfigs);
|
||||
settingsChanged = true;
|
||||
}
|
||||
|
||||
return settingsChanged;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CppCodeModelSettingsWidget::applyGeneralWidgetsToSettings() const
|
||||
|
||||
@@ -37,8 +37,6 @@ QT_FORWARD_DECLARE_CLASS(QSettings)
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class ClangDiagnosticConfigsWidget;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
namespace Ui { class CppCodeModelSettingsPage; }
|
||||
@@ -49,7 +47,7 @@ class CppCodeModelSettingsWidget: public QWidget
|
||||
|
||||
public:
|
||||
explicit CppCodeModelSettingsWidget(QWidget *parent = 0);
|
||||
~CppCodeModelSettingsWidget();
|
||||
~CppCodeModelSettingsWidget() override;
|
||||
|
||||
void setSettings(const QSharedPointer<CppCodeModelSettings> &s);
|
||||
void applyToSettings() const;
|
||||
@@ -63,7 +61,6 @@ private:
|
||||
|
||||
private:
|
||||
Ui::CppCodeModelSettingsPage *m_ui = nullptr;
|
||||
QPointer<ClangDiagnosticConfigsWidget> m_clangDiagnosticConfigsWidget;
|
||||
QSharedPointer<CppCodeModelSettings> m_settings;
|
||||
};
|
||||
|
||||
|
||||
@@ -98,24 +98,61 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="clangSettingsGroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<layout class="QHBoxLayout" name="clangDiagnosticsLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Diagnostic Configuration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="CppTools::ClangDiagnosticConfigsSelectionWidget" name="clangDiagnosticConfigsSelectionWidget" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="manageButton">
|
||||
<property name="text">
|
||||
<string>Manage...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Clang Diagnostics</string>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CppTools::ClangDiagnosticConfigsSelectionWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cpptools/clangdiagnosticconfigsselectionwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -13,6 +13,7 @@ HEADERS += \
|
||||
builtinindexingsupport.h \
|
||||
clangdiagnosticconfig.h \
|
||||
clangdiagnosticconfigsmodel.h \
|
||||
clangdiagnosticconfigsselectionwidget.h \
|
||||
clangdiagnosticconfigswidget.h \
|
||||
cppcanonicalsymbol.h \
|
||||
cppchecksymbols.h \
|
||||
@@ -111,6 +112,7 @@ SOURCES += \
|
||||
builtinindexingsupport.cpp \
|
||||
clangdiagnosticconfig.cpp \
|
||||
clangdiagnosticconfigsmodel.cpp \
|
||||
clangdiagnosticconfigsselectionwidget.cpp \
|
||||
clangdiagnosticconfigswidget.cpp \
|
||||
cppcanonicalsymbol.cpp \
|
||||
cppchecksymbols.cpp \
|
||||
@@ -184,7 +186,7 @@ SOURCES += \
|
||||
compileroptionsbuilder.cpp \
|
||||
cppprojectfilecategorizer.cpp \
|
||||
cppprojectpartchooser.cpp \
|
||||
wrappablelineedit.cpp \
|
||||
wrappablelineedit.cpp
|
||||
|
||||
FORMS += \
|
||||
clangdiagnosticconfigswidget.ui \
|
||||
|
||||
@@ -48,6 +48,8 @@ Project {
|
||||
"clangdiagnosticconfig.h",
|
||||
"clangdiagnosticconfigsmodel.cpp",
|
||||
"clangdiagnosticconfigsmodel.h",
|
||||
"clangdiagnosticconfigsselectionwidget.cpp",
|
||||
"clangdiagnosticconfigsselectionwidget.h",
|
||||
"clangdiagnosticconfigswidget.cpp",
|
||||
"clangdiagnosticconfigswidget.h",
|
||||
"clangdiagnosticconfigswidget.ui",
|
||||
|
||||
@@ -66,6 +66,8 @@ const char CPP_FILE_SETTINGS_ID[] = "B.Cpp.File Naming";
|
||||
const char CPP_FILE_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppTools", "File Naming");
|
||||
const char CPP_CODE_MODEL_SETTINGS_ID[] = "C.Cpp.Code Model";
|
||||
const char CPP_CODE_MODEL_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppTools", "Code Model");
|
||||
const char CPP_DIAGNOSTIC_CONFIG_SETTINGS_ID[] = "C.Cpp.Diagnostic Config";
|
||||
const char CPP_DIAGNOSTIC_CONFIG_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppTools", "Diagnostic Configurations");
|
||||
const char CPP_SETTINGS_CATEGORY[] = "I.C++";
|
||||
|
||||
const char CPP_CLANG_FIXIT_AVAILABLE_MARKER_ID[] = "ClangFixItAvailableMarker";
|
||||
|
||||
Reference in New Issue
Block a user