1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
/* This file is part of KDevelop
Copyright 2013 Christoph Thielecke <crissi99@gmx.de>
Copyright 2016 Anton Anikin <anton.anikin@htower.ru>
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, o (at your option) any later version.
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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "projectconfigpage.h"
#include "ui_projectconfigpage.h"
#include "projectsettings.h"
#include <interfaces/iproject.h>
#include <QFontDatabase>
namespace cppcheck
{
ProjectConfigPage::ProjectConfigPage(KDevelop::IPlugin* plugin, KDevelop::IProject* project, QWidget* parent)
: ConfigPage(plugin, new ProjectSettings, parent)
, ui(new Ui::ProjectConfigPage)
, m_parameters(new Parameters(project))
{
configSkeleton()->setSharedConfig(project->projectConfiguration());
configSkeleton()->load();
ui->setupUi(this);
ui->commandLine->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
connect(this, &ProjectConfigPage::changed, this, &ProjectConfigPage::updateCommandLine);
connect(ui->commandLineFilter, &QLineEdit::textChanged, this, &ProjectConfigPage::updateCommandLine);
connect(ui->commandLineBreaks, &QCheckBox::stateChanged, this, &ProjectConfigPage::updateCommandLine);
}
ProjectConfigPage::~ProjectConfigPage()
{
}
QIcon ProjectConfigPage::icon() const
{
return QIcon::fromTheme(QStringLiteral("cppcheck"));
}
void ProjectConfigPage::defaults()
{
ConfigPage::defaults();
updateCommandLine();
}
void ProjectConfigPage::reset()
{
ConfigPage::reset();
updateCommandLine();
}
QString ProjectConfigPage::name() const
{
return i18nc("@title:tab", "Cppcheck");
}
void ProjectConfigPage::updateCommandLine()
{
m_parameters->checkStyle = ui->kcfg_checkStyle->isChecked();
m_parameters->checkPerformance = ui->kcfg_checkPerformance->isChecked();
m_parameters->checkPortability = ui->kcfg_checkPortability->isChecked();
m_parameters->checkInformation = ui->kcfg_checkInformation->isChecked();
m_parameters->checkUnusedFunction = ui->kcfg_checkUnusedFunction->isChecked();
m_parameters->checkMissingInclude = ui->kcfg_checkMissingInclude->isChecked();
m_parameters->inconclusiveAnalysis = ui->kcfg_inconclusiveAnalysis->isChecked();
m_parameters->forceCheck = ui->kcfg_forceCheck->isChecked();
m_parameters->checkConfig = ui->kcfg_checkConfig->isChecked();
m_parameters->useProjectIncludes = ui->kcfg_useProjectIncludes->isChecked();
m_parameters->useSystemIncludes = ui->kcfg_useSystemIncludes->isChecked();
m_parameters->ignoredIncludes = ui->kcfg_ignoredIncludes->text();
m_parameters->extraParameters = ui->kcfg_extraParameters->text().trimmed();
QString message;
QString commandLine = m_parameters->commandLine(message).join(QLatin1Char(' '));
if (message.isEmpty()) {
ui->messageWidget->hide();
} else {
ui->messageWidget->setText(message);
ui->messageWidget->show();
}
if (!ui->commandLineBreaks->isChecked()) {
ui->commandLine->setPlainText(commandLine);
return;
}
commandLine.replace(QLatin1String(" -"), QLatin1String("\n-"));
QString filterText = ui->commandLineFilter->text();
if (filterText.isEmpty()) {
ui->commandLine->setPlainText(commandLine);
ui->commandLineBreaks->setEnabled(true);
return;
}
QStringList lines = commandLine.split(QLatin1Char('\n'));
QMutableStringListIterator i(lines);
while (i.hasNext()) {
if (!i.next().contains(filterText)) {
i.remove();
}
}
ui->commandLine->setPlainText(lines.join(QLatin1Char('\n')));
ui->commandLineBreaks->setEnabled(false);
}
}
|