diff --git a/languages/plugins/custom-definesandincludes/kcm_widget/customdefinesandincludes.kcfg b/languages/plugins/custom-definesandincludes/kcm_widget/customdefinesandincludes.kcfg
index cd2c1cd096..97e35592e2 100644
--- a/languages/plugins/custom-definesandincludes/kcm_widget/customdefinesandincludes.kcfg
+++ b/languages/plugins/custom-definesandincludes/kcm_widget/customdefinesandincludes.kcfg
@@ -1,19 +1,13 @@
true
-
- true
-
-
- false
-
diff --git a/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp b/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp
index c06599b533..9753df73f3 100644
--- a/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp
+++ b/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp
@@ -1,102 +1,132 @@
/*
* This file is part of KDevelop
*
* Copyright 2015 Sergey Kalinichev
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
#include "parserwidget.h"
#include "ui_parserwidget.h"
#include "compilerprovider/settingsmanager.h"
#include
+namespace
+{
+
QString languageStandard(const QString& arguments)
{
int idx = arguments.indexOf("-std=");
if(idx == -1){
return QStringLiteral("c++11");
}
idx += 5;
int end = arguments.indexOf(' ', idx) != -1 ? arguments.indexOf(' ', idx) : arguments.size();
return arguments.mid(idx, end - idx);
}
+bool isCustomParserArguments(const QString& arguments, const QStringList& standards)
+{
+ const auto defaultArguments = SettingsManager::globalInstance()->defaultParserArguments();
+
+ auto standard = languageStandard(arguments);
+
+ auto tmpArgs(arguments);
+ tmpArgs.replace(standard, "c++11");
+
+ if (tmpArgs == defaultArguments && standards.contains(standard)) {
+ return false;
+ }
+
+ return true;
+}
+
+const int customProfileIdx = 0;
+}
+
ParserWidget::ParserWidget(QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::ParserWidget())
{
m_ui->setupUi(this);
connect(m_ui->parserOptions, &QLineEdit::textEdited, this, &ParserWidget::textEdited);
connect(m_ui->languageStandards, static_cast(&QComboBox::activated), this,
&ParserWidget::languageStandardChanged);
- connect(m_ui->kcfg_useProfile, &QRadioButton::toggled, this,
-&ParserWidget::updateEnablements);
updateEnablements();
}
ParserWidget::~ParserWidget() = default;
void ParserWidget::textEdited()
{
- const auto parserOptions = m_ui->parserOptions->text();
- m_ui->languageStandards->setCurrentText(languageStandard(m_ui->parserOptions->text()));
-
emit changed();
}
void ParserWidget::languageStandardChanged(const QString& standard)
{
- auto text = m_ui->parserOptions->text();
-
- auto currentStandard = languageStandard(text);
-
- m_ui->parserOptions->setText(text.replace(currentStandard, standard));
+ if (m_ui->languageStandards->currentIndex() == customProfileIdx) {
+ m_ui->parserOptions->setText(SettingsManager::globalInstance()->defaultParserArguments());
+ } else {
+ auto text = SettingsManager::globalInstance()->defaultParserArguments();
+ auto currentStandard = languageStandard(text);
+ m_ui->parserOptions->setText(text.replace(currentStandard, standard));
+ }
textEdited();
+ updateEnablements();
}
void ParserWidget::setParserArguments(const QString& arguments)
{
+ QStringList standards;
+ for (int i = 1; i < m_ui->languageStandards->count(); i++) {
+ standards << m_ui->languageStandards->itemText(i);
+ }
+
+ if (isCustomParserArguments(arguments, standards)) {
+ m_ui->languageStandards->setCurrentIndex(customProfileIdx);
+ } else {
+ m_ui->languageStandards->setCurrentText(languageStandard(arguments));
+ }
+
m_ui->parserOptions->setText(arguments);
- m_ui->languageStandards->setCurrentText(languageStandard(arguments));
+ updateEnablements();
}
QString ParserWidget::parserArguments() const
{
return m_ui->parserOptions->text();
}
void ParserWidget::updateEnablements()
{
- if (m_ui->kcfg_useProfile->isChecked()) {
- m_ui->languageStandards->setHidden(false);
- m_ui->parserOptions->setHidden(true);
- setParserArguments(SettingsManager::globalInstance()->defaultParserArguments());
- } else {
- m_ui->languageStandards->setHidden(true);
+ if (m_ui->languageStandards->currentIndex() == customProfileIdx) {
m_ui->parserOptions->setHidden(false);
+ m_ui->argumentsLabel->setHidden(false);
+ } else {
+ m_ui->parserOptions->setHidden(true);
+ m_ui->argumentsLabel->setHidden(true);
}
}
diff --git a/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui b/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui
index d1175650ec..747b505eab 100644
--- a/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui
+++ b/languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui
@@ -1,177 +1,147 @@
ParserWidget
0
0
579
407
Form
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 406
-
-
-
-
- -
+
+
-
-
-
-
-
-
- Predefined profi&le
-
-
- true
-
-
-
+
-
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Minimum
+
+
+ Profile
-
-
- 40
- 0
-
-
-
+
-
0
0
100
0
- <html><head/><body><p>Use predefined command-line arguments</p></body></html>
+ <html><head/><body><p>Choose language profile. </p><p>Use "Custom" profile to modify parser command-line arguments</p></body></html>
+
-
+
+ Custom
+
+
-
c99
-
gnu99
-
c11
-
gnu11
-
c++03
-
c++11
-
c++14
-
Qt::Horizontal
40
0
-
-
-
- Co&mmand-line arguments
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Minimum
+
+
-
+
+
+ Command-line arguments:
-
-
- 40
- 20
-
-
-
+
- -
+
-
100
0
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 406
+
+
+
+