GUI: Refactorizations
This commit is contained in:
parent
dfc48be70e
commit
b4cf79f1b7
|
@ -52,7 +52,7 @@ bool ApplicationList::loadSettings()
|
|||
bool succeeded = true;
|
||||
if (!names.empty() && !paths.empty() && params.empty()) {
|
||||
for (int i = 0; i < paths.length(); i++)
|
||||
params << "";
|
||||
params << QString();
|
||||
succeeded = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ void CheckThread::run()
|
|||
a = addonPath + '/' + addon + '/' + addon + ".py";
|
||||
else
|
||||
continue;
|
||||
QString dumpFile = QString::fromStdString(file + ".dump");
|
||||
QString dumpFile = file + ".dump";
|
||||
QString cmd = "python " + a + ' ' + dumpFile;
|
||||
qDebug() << cmd;
|
||||
process.start(cmd);
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
QString getPath(const QString &type)
|
||||
{
|
||||
QSettings settings;
|
||||
QString path = settings.value(type, "").toString();
|
||||
QString path = settings.value(type, QString()).toString();
|
||||
if (path.isEmpty()) {
|
||||
// if not set, fallback to last check path hoping that it will be close enough
|
||||
path = settings.value(SETTINGS_LAST_CHECK_PATH, "").toString();
|
||||
path = settings.value(SETTINGS_LAST_CHECK_PATH, QString()).toString();
|
||||
if (path.isEmpty())
|
||||
// if not set, return user's home directory as the best we can do for now
|
||||
return QDir::homePath();
|
||||
|
|
|
@ -67,6 +67,5 @@ void FileViewDialog::loadTextFile(const QString &filename, QTextEdit *edit)
|
|||
QByteArray filedata = file.readAll();
|
||||
file.close();
|
||||
|
||||
QString filestringdata(filedata);
|
||||
edit->setPlainText(filestringdata);
|
||||
edit->setPlainText(filedata);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ void LogView::clearButtonClicked()
|
|||
void LogView::saveButtonClicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Log"),
|
||||
"", tr("Text files (*.txt *.log);;All files (*.*)"));
|
||||
QString(), tr("Text files (*.txt *.log);;All files (*.*)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
|
|
|
@ -554,7 +554,7 @@ void MainWindow::analyzeFiles()
|
|||
{
|
||||
QStringList selected = selectFilesToAnalyze(QFileDialog::ExistingFiles);
|
||||
|
||||
const QString file0 = (selected.size() ? selected[0].toLower() : "");
|
||||
const QString file0 = (selected.size() ? selected[0].toLower() : QString());
|
||||
if (file0.endsWith(".sln") || file0.endsWith(".vcxproj") || file0.endsWith(compile_commands_json)) {
|
||||
ImportProject p;
|
||||
p.import(selected[0].toStdString());
|
||||
|
|
|
@ -156,7 +156,7 @@ bool ProjectFile::read(const QString &filename)
|
|||
void ProjectFile::readRootPath(QXmlStreamReader &reader)
|
||||
{
|
||||
QXmlStreamAttributes attribs = reader.attributes();
|
||||
QString name = attribs.value("", RootPathNameAttrib).toString();
|
||||
QString name = attribs.value(QString(), RootPathNameAttrib).toString();
|
||||
if (!name.isEmpty())
|
||||
mRootPath = name;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)
|
|||
// Read dir-elements
|
||||
if (reader.name().toString() == DirElementName) {
|
||||
QXmlStreamAttributes attribs = reader.attributes();
|
||||
QString name = attribs.value("", DirNameAttrib).toString();
|
||||
QString name = attribs.value(QString(), DirNameAttrib).toString();
|
||||
if (!name.isEmpty())
|
||||
mIncludeDirs << name;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ void ProjectFile::readDefines(QXmlStreamReader &reader)
|
|||
// Read define-elements
|
||||
if (reader.name().toString() == DefineName) {
|
||||
QXmlStreamAttributes attribs = reader.attributes();
|
||||
QString name = attribs.value("", DefineNameAttrib).toString();
|
||||
QString name = attribs.value(QString(), DefineNameAttrib).toString();
|
||||
if (!name.isEmpty())
|
||||
mDefines << name;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ void ProjectFile::readCheckPaths(QXmlStreamReader &reader)
|
|||
// Read dir-elements
|
||||
if (reader.name().toString() == PathName) {
|
||||
QXmlStreamAttributes attribs = reader.attributes();
|
||||
QString name = attribs.value("", PathNameAttrib).toString();
|
||||
QString name = attribs.value(QString(), PathNameAttrib).toString();
|
||||
if (!name.isEmpty())
|
||||
mPaths << name;
|
||||
}
|
||||
|
@ -335,14 +335,14 @@ void ProjectFile::readExcludes(QXmlStreamReader &reader)
|
|||
// Read exclude-elements
|
||||
if (reader.name().toString() == ExcludePathName) {
|
||||
QXmlStreamAttributes attribs = reader.attributes();
|
||||
QString name = attribs.value("", ExcludePathNameAttrib).toString();
|
||||
QString name = attribs.value(QString(), ExcludePathNameAttrib).toString();
|
||||
if (!name.isEmpty())
|
||||
mExcludedPaths << name;
|
||||
}
|
||||
// Read ignore-elements - deprecated but support reading them
|
||||
else if (reader.name().toString() == IgnorePathName) {
|
||||
QXmlStreamAttributes attribs = reader.attributes();
|
||||
QString name = attribs.value("", IgnorePathNameAttrib).toString();
|
||||
QString name = attribs.value(QString(), IgnorePathNameAttrib).toString();
|
||||
if (!name.isEmpty())
|
||||
mExcludedPaths << name;
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ QString ResultsTree::severityToTranslatedString(Severity::SeverityType severity)
|
|||
|
||||
case Severity::none:
|
||||
default:
|
||||
return "";
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1033,7 +1033,7 @@ QString ResultsTree::severityToIcon(Severity::SeverityType severity) const
|
|||
case Severity::information:
|
||||
return ":images/dialog-information.png";
|
||||
default:
|
||||
return "";
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ void ResultsView::clear(bool results)
|
|||
mUI.mTree->clear();
|
||||
}
|
||||
|
||||
mUI.mDetails->setText("");
|
||||
mUI.mDetails->setText(QString());
|
||||
|
||||
mStatistics->clear();
|
||||
|
||||
|
@ -363,7 +363,7 @@ void ResultsView::readErrorsXml(const QString &filename)
|
|||
foreach (item, errors) {
|
||||
mUI.mTree->addErrorItem(item);
|
||||
}
|
||||
mUI.mTree->setCheckDirectory("");
|
||||
mUI.mTree->setCheckDirectory(QString());
|
||||
}
|
||||
|
||||
void ResultsView::updateDetails(const QModelIndex &index)
|
||||
|
@ -372,7 +372,7 @@ void ResultsView::updateDetails(const QModelIndex &index)
|
|||
QStandardItem *item = model->itemFromIndex(index);
|
||||
|
||||
if (!item) {
|
||||
mUI.mDetails->setText("");
|
||||
mUI.mDetails->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ void ResultsView::updateDetails(const QModelIndex &index)
|
|||
|
||||
// If there is no severity data then it is a parent item without summary and message
|
||||
if (!data.contains("severity")) {
|
||||
mUI.mDetails->setText("");
|
||||
mUI.mDetails->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ void ResultsView::updateDetails(const QModelIndex &index)
|
|||
.arg(tr("Message")).arg(message);
|
||||
|
||||
const QString file0 = data["file0"].toString();
|
||||
if (file0 != "" && Path::isHeader(data["file"].toString().toStdString()))
|
||||
if (!file0.isEmpty() && Path::isHeader(data["file"].toString().toStdString()))
|
||||
formattedMsg += QString("\n\n%1: %2").arg(tr("First included by")).arg(QDir::toNativeSeparators(file0));
|
||||
|
||||
if (mUI.mTree->showIdColumn())
|
||||
|
|
|
@ -47,10 +47,10 @@ void StatsDialog::setProject(const ProjectFile* projectFile)
|
|||
mUI.mIncludePaths->setText(projectFile->getIncludeDirs().join(";"));
|
||||
mUI.mDefines->setText(projectFile->getDefines().join(";"));
|
||||
} else {
|
||||
mUI.mProject->setText("");
|
||||
mUI.mPaths->setText("");
|
||||
mUI.mIncludePaths->setText("");
|
||||
mUI.mDefines->setText("");
|
||||
mUI.mProject->setText(QString());
|
||||
mUI.mPaths->setText(QString());
|
||||
mUI.mIncludePaths->setText(QString());
|
||||
mUI.mDefines->setText(QString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ QString ThreadResult::getNextFile()
|
|||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
if (mFiles.isEmpty()) {
|
||||
return "";
|
||||
return QString();
|
||||
}
|
||||
|
||||
return mFiles.takeFirst();
|
||||
|
|
|
@ -68,7 +68,7 @@ int XmlReport::determineVersion(const QString &filename)
|
|||
if (reader.name() == ResultElementName) {
|
||||
QXmlStreamAttributes attribs = reader.attributes();
|
||||
if (attribs.hasAttribute(QString(VersionAttribute))) {
|
||||
int ver = attribs.value("", VersionAttribute).toString().toInt();
|
||||
int ver = attribs.value(QString(), VersionAttribute).toString().toInt();
|
||||
return ver;
|
||||
} else
|
||||
return 1;
|
||||
|
|
|
@ -28,25 +28,25 @@
|
|||
#include "xmlreportv2.h"
|
||||
#include "cppcheck.h"
|
||||
|
||||
static const char ResultElementName[] = "results";
|
||||
static const char CppcheckElementName[] = "cppcheck";
|
||||
static const char ErrorElementName[] = "error";
|
||||
static const char ErrorsElementName[] = "errors";
|
||||
static const char LocationElementName[] = "location";
|
||||
static const char ColAttribute[] = "col";
|
||||
static const char CWEAttribute[] = "cwe";
|
||||
static const char SinceDateAttribute[] = "sinceDate";
|
||||
static const char TagAttribute[] = "tag";
|
||||
static const char FilenameAttribute[] = "file";
|
||||
static const char IncludedFromFilenameAttribute[] = "file0";
|
||||
static const char InconclusiveAttribute[] = "inconclusive";
|
||||
static const char InfoAttribute[] = "info";
|
||||
static const char LineAttribute[] = "line";
|
||||
static const char IdAttribute[] = "id";
|
||||
static const char SeverityAttribute[] = "severity";
|
||||
static const char MsgAttribute[] = "msg";
|
||||
static const char VersionAttribute[] = "version";
|
||||
static const char VerboseAttribute[] = "verbose";
|
||||
static const QString ResultElementName = "results";
|
||||
static const QString CppcheckElementName = "cppcheck";
|
||||
static const QString ErrorElementName = "error";
|
||||
static const QString ErrorsElementName = "errors";
|
||||
static const QString LocationElementName = "location";
|
||||
static const QString ColAttribute = "col";
|
||||
static const QString CWEAttribute = "cwe";
|
||||
static const QString SinceDateAttribute = "sinceDate";
|
||||
static const QString TagAttribute = "tag";
|
||||
static const QString FilenameAttribute = "file";
|
||||
static const QString IncludedFromFilenameAttribute = "file0";
|
||||
static const QString InconclusiveAttribute = "inconclusive";
|
||||
static const QString InfoAttribute = "info";
|
||||
static const QString LineAttribute = "line";
|
||||
static const QString IdAttribute = "id";
|
||||
static const QString SeverityAttribute = "severity";
|
||||
static const QString MsgAttribute = "msg";
|
||||
static const QString VersionAttribute = "version";
|
||||
static const QString VerboseAttribute = "verbose";
|
||||
|
||||
XmlReportV2::XmlReportV2(const QString &filename) :
|
||||
XmlReport(filename),
|
||||
|
@ -209,20 +209,20 @@ ErrorItem XmlReportV2::readError(QXmlStreamReader *reader)
|
|||
// Read error element from inside errors element
|
||||
if (mXmlReader->name() == ErrorElementName) {
|
||||
QXmlStreamAttributes attribs = reader->attributes();
|
||||
item.errorId = attribs.value("", IdAttribute).toString();
|
||||
item.severity = GuiSeverity::fromString(attribs.value("", SeverityAttribute).toString());
|
||||
const QString summary = attribs.value("", MsgAttribute).toString();
|
||||
item.errorId = attribs.value(QString(), IdAttribute).toString();
|
||||
item.severity = GuiSeverity::fromString(attribs.value(QString(), SeverityAttribute).toString());
|
||||
const QString summary = attribs.value(QString(), MsgAttribute).toString();
|
||||
item.summary = XmlReport::unquoteMessage(summary);
|
||||
const QString message = attribs.value("", VerboseAttribute).toString();
|
||||
const QString message = attribs.value(QString(), VerboseAttribute).toString();
|
||||
item.message = XmlReport::unquoteMessage(message);
|
||||
if (attribs.hasAttribute("", InconclusiveAttribute))
|
||||
if (attribs.hasAttribute(QString(), InconclusiveAttribute))
|
||||
item.inconclusive = true;
|
||||
if (attribs.hasAttribute("", CWEAttribute))
|
||||
item.cwe = attribs.value("", CWEAttribute).toString().toInt();
|
||||
if (attribs.hasAttribute("", SinceDateAttribute))
|
||||
item.sinceDate = attribs.value("", SinceDateAttribute).toString();
|
||||
if (attribs.hasAttribute("", TagAttribute)) {
|
||||
const QString tag = attribs.value("", TagAttribute).toString();
|
||||
if (attribs.hasAttribute(QString(), CWEAttribute))
|
||||
item.cwe = attribs.value(QString(), CWEAttribute).toString().toInt();
|
||||
if (attribs.hasAttribute(QString(), SinceDateAttribute))
|
||||
item.sinceDate = attribs.value(QString(), SinceDateAttribute).toString();
|
||||
if (attribs.hasAttribute(QString(), TagAttribute)) {
|
||||
const QString tag = attribs.value(QString(), TagAttribute).toString();
|
||||
if (tag == "fp")
|
||||
item.tag = ErrorItem::FP;
|
||||
else if (tag == "ignore")
|
||||
|
@ -240,16 +240,16 @@ ErrorItem XmlReportV2::readError(QXmlStreamReader *reader)
|
|||
// Read location element from inside error element
|
||||
if (mXmlReader->name() == LocationElementName) {
|
||||
QXmlStreamAttributes attribs = mXmlReader->attributes();
|
||||
QString file0 = attribs.value("", IncludedFromFilenameAttribute).toString();
|
||||
QString file0 = attribs.value(QString(), IncludedFromFilenameAttribute).toString();
|
||||
if (!file0.isEmpty())
|
||||
item.file0 = XmlReport::unquoteMessage(file0);
|
||||
QErrorPathItem loc;
|
||||
loc.file = XmlReport::unquoteMessage(attribs.value("", FilenameAttribute).toString());
|
||||
loc.line = attribs.value("", LineAttribute).toString().toUInt();
|
||||
if (attribs.hasAttribute("", ColAttribute))
|
||||
loc.col = attribs.value("", ColAttribute).toString().toInt();
|
||||
if (attribs.hasAttribute("", InfoAttribute))
|
||||
loc.info = XmlReport::unquoteMessage(attribs.value("", InfoAttribute).toString());
|
||||
loc.file = XmlReport::unquoteMessage(attribs.value(QString(), FilenameAttribute).toString());
|
||||
loc.line = attribs.value(QString(), LineAttribute).toString().toUInt();
|
||||
if (attribs.hasAttribute(QString(), ColAttribute))
|
||||
loc.col = attribs.value(QString(), ColAttribute).toString().toInt();
|
||||
if (attribs.hasAttribute(QString(), InfoAttribute))
|
||||
loc.info = XmlReport::unquoteMessage(attribs.value(QString(), InfoAttribute).toString());
|
||||
item.errorPath.push_front(loc);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue