fixed most of the Qt deprecation warnings (#3779)

This commit is contained in:
Oliver Stöneberg 2022-02-01 17:26:16 +01:00 committed by GitHub
parent 4127885282
commit d6ae089ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 39 additions and 6 deletions

View File

@ -104,5 +104,5 @@ QStringList CheckStatistics::getTools() const
foreach (QString tool, mPerformance.keys()) ret.insert(tool); foreach (QString tool, mPerformance.keys()) ret.insert(tool);
foreach (QString tool, mPortability.keys()) ret.insert(tool); foreach (QString tool, mPortability.keys()) ret.insert(tool);
foreach (QString tool, mError.keys()) ret.insert(tool); foreach (QString tool, mError.keys()) ret.insert(tool);
return QStringList(ret.toList()); return QStringList(ret.values());
} }

View File

@ -336,7 +336,11 @@ int CodeEditor::lineNumberAreaWidth()
++digits; ++digits;
} }
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
#else
int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
#endif
return space; return space;
} }

View File

@ -119,7 +119,11 @@ StyleEditDialog::StyleEditDialog(const CodeEditorStyle& newStyle,
mSampleEditor = new CodeEditor(this); mSampleEditor = new CodeEditor(this);
QFont sampleFont("Monospace"); QFont sampleFont("Monospace");
QFontMetrics fm(sampleFont); QFontMetrics fm(sampleFont);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
mSampleEditor->setMinimumWidth(fm.horizontalAdvance(QString(40, 'W')));
#else
mSampleEditor->setMinimumWidth(fm.width(QString(40, 'W'))); mSampleEditor->setMinimumWidth(fm.width(QString(40, 'W')));
#endif
// designate highlight, errors, and symbols // designate highlight, errors, and symbols
mSampleEditor->setError(mSampleDocument, mErrLineNum, mErrSymbolsList); mSampleEditor->setError(mSampleDocument, mErrLineNum, mErrSymbolsList);
// End Controls // End Controls

View File

@ -41,7 +41,11 @@ bool CsvReport::create()
void CsvReport::writeHeader() void CsvReport::writeHeader()
{ {
// Added 5 columns to the header. // Added 5 columns to the header.
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
mTxtWriter << "File, Line, Severity, Id, Summary" << Qt::endl;
#else
mTxtWriter << "File, Line, Severity, Id, Summary" << endl; mTxtWriter << "File, Line, Severity, Id, Summary" << endl;
#endif
} }
void CsvReport::writeFooter() void CsvReport::writeFooter()
@ -59,5 +63,9 @@ void CsvReport::writeError(const ErrorItem &error)
const QString file = QDir::toNativeSeparators(error.errorPath.back().file); const QString file = QDir::toNativeSeparators(error.errorPath.back().file);
QString line = QString("%1,%2,").arg(file).arg(error.errorPath.back().line); QString line = QString("%1,%2,").arg(file).arg(error.errorPath.back().line);
line += QString("%1,%2,%3").arg(GuiSeverity::toString(error.severity)).arg(error.errorId).arg(error.summary); line += QString("%1,%2,%3").arg(GuiSeverity::toString(error.severity)).arg(error.errorId).arg(error.summary);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
mTxtWriter << line << Qt::endl;
#else
mTxtWriter << line << endl; mTxtWriter << line << endl;
#endif
} }

View File

@ -410,7 +410,11 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
projectFile->setAddons(list); projectFile->setAddons(list);
projectFile->setClangAnalyzer(mUI.mToolClangAnalyzer->isChecked()); projectFile->setClangAnalyzer(mUI.mToolClangAnalyzer->isChecked());
projectFile->setClangTidy(mUI.mToolClangTidy->isChecked()); projectFile->setClangTidy(mUI.mToolClangTidy->isChecked());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
projectFile->setTags(mUI.mEditTags->text().split(";", Qt::SkipEmptyParts));
#else
projectFile->setTags(mUI.mEditTags->text().split(";", QString::SkipEmptyParts)); projectFile->setTags(mUI.mEditTags->text().split(";", QString::SkipEmptyParts));
#endif
} }
void ProjectFileDialog::ok() void ProjectFileDialog::ok()
@ -584,13 +588,21 @@ QStringList ProjectFileDialog::getIncludePaths() const
QStringList ProjectFileDialog::getDefines() const QStringList ProjectFileDialog::getDefines() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return mUI.mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), Qt::SkipEmptyParts);
#else
return mUI.mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), QString::SkipEmptyParts); return mUI.mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), QString::SkipEmptyParts);
#endif
} }
QStringList ProjectFileDialog::getUndefines() const QStringList ProjectFileDialog::getUndefines() const
{ {
const QString undefine = mUI.mEditUndefines->text().trimmed(); const QString undefine = mUI.mEditUndefines->text().trimmed();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList undefines = undefine.split(QRegExp("\\s*;\\s*"), Qt::SkipEmptyParts);
#else
QStringList undefines = undefine.split(QRegExp("\\s*;\\s*"), QString::SkipEmptyParts); QStringList undefines = undefine.split(QRegExp("\\s*;\\s*"), QString::SkipEmptyParts);
#endif
undefines.removeDuplicates(); undefines.removeDuplicates();
return undefines; return undefines;
} }

View File

@ -1058,7 +1058,7 @@ void ResultsTree::suppressSelectedIds()
} }
emit suppressIds(selectedIds.toList()); emit suppressIds(selectedIds.values());
} }
void ResultsTree::suppressHash() void ResultsTree::suppressHash()

View File

@ -157,7 +157,7 @@ void StatsDialog::pdfExport()
} }
QPrinter printer(QPrinter::PrinterResolution); QPrinter printer(QPrinter::PrinterResolution);
printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPaperSize(QPrinter::A4); printer.setPageSize(QPageSize(QPageSize::A4));
printer.setOutputFileName(fileName); printer.setOutputFileName(fileName);
QTextDocument doc; QTextDocument doc;

View File

@ -112,7 +112,7 @@ void ThreadHandler::check(const Settings &settings)
mAnalyseWholeProgram = true; mAnalyseWholeProgram = true;
mTime.start(); mTimer.start();
} }
bool ThreadHandler::isChecking() const bool ThreadHandler::isChecking() const
@ -168,7 +168,7 @@ void ThreadHandler::threadDone()
if (mRunningThreadCount == 0) { if (mRunningThreadCount == 0) {
emit done(); emit done();
mScanDuration = mTime.elapsed(); mScanDuration = mTimer.elapsed();
// Set date/time used by the recheck // Set date/time used by the recheck
if (!mCheckStartTime.isNull()) { if (!mCheckStartTime.isNull()) {

View File

@ -23,6 +23,7 @@
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <QDateTime> #include <QDateTime>
#include <QElapsedTimer>
#include <set> #include <set>
#include "threadresult.h" #include "threadresult.h"
#include "suppressions.h" #include "suppressions.h"
@ -222,7 +223,7 @@ protected:
* @brief Timer used for measuring scan duration * @brief Timer used for measuring scan duration
* *
*/ */
QTime mTime; QElapsedTimer mTimer;
/** /**
* @brief The previous scan duration in milliseconds. * @brief The previous scan duration in milliseconds.

View File

@ -76,5 +76,9 @@ void TxtReport::writeError(const ErrorItem &error)
line += temp.arg(GuiSeverity::toString(error.severity)); line += temp.arg(GuiSeverity::toString(error.severity));
line += error.summary; line += error.summary;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
mTxtWriter << line << Qt::endl;
#else
mTxtWriter << line << endl; mTxtWriter << line << endl;
#endif
} }