From c4b2be45d29a247422e60bb8fdf1664c10384eee Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Mon, 6 Dec 2021 03:51:08 -0600 Subject: First pass for Qt6 compatibility --- CMakeLists.txt | 3 ++ src/bbcode.cpp | 92 +++++++++++++++++++++--------------------- src/browserdialog.cpp | 20 ++++----- src/browserview.cpp | 4 +- src/categories.cpp | 2 +- src/categoriesdialog.cpp | 6 +-- src/csvbuilder.cpp | 2 +- src/directoryrefresher.h | 14 +++---- src/dlls.manifest.debug.qt5 | 67 ++++++++++++++++++------------ src/dlls.manifest.qt5 | 53 +++++++++++++++--------- src/editexecutablesdialog.cpp | 2 +- src/env.cpp | 6 +-- src/envmetrics.cpp | 2 +- src/envshell.cpp | 8 ++-- src/executableslist.cpp | 2 +- src/filedialogmemory.h | 2 +- src/filerenamer.cpp | 4 +- src/filetree.cpp | 4 +- src/filetreemodel.cpp | 4 +- src/glob_matching.h | 4 +- src/iconfetcher.cpp | 6 +-- src/iconfetcher.h | 7 ++-- src/instancemanager.cpp | 2 +- src/instancemanagerdialog.cpp | 2 +- src/loglist.cpp | 2 +- src/loot.cpp | 2 +- src/lootdialog.cpp | 2 +- src/mainwindow.cpp | 4 +- src/moapplication.cpp | 4 -- src/modinfo.cpp | 10 ++--- src/modinfo.h | 4 +- src/modinfodialogconflicts.cpp | 2 +- src/modinfodialogfiletree.cpp | 4 +- src/modinfodialogimages.cpp | 4 +- src/modinforegular.cpp | 2 +- src/modlistsortproxy.cpp | 4 +- src/nexusinterface.cpp | 6 +-- src/nxmaccessmanager.cpp | 5 --- src/organizercore.cpp | 21 +++++----- src/pch.h | 6 +-- src/pluginlistsortproxy.cpp | 6 +-- src/processrunner.cpp | 4 +- src/qtgroupingproxy.cpp | 74 ++++++++++++++++----------------- src/qtgroupingproxy.h | 2 +- src/settingsdialoggeneral.cpp | 9 +++-- src/spawn.cpp | 8 ++-- src/statusbar.cpp | 2 +- src/texteditor.cpp | 2 +- 48 files changed, 268 insertions(+), 239 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7129c77c..03ed0307 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,9 @@ set(project_type exe) set(executable_name ModOrganizer) set(enable_warnings OFF) +set(OPENSSL_USE_STATIC_LIBS FALSE CACHE STRING "" FORCE) +set(MySQL_INCLUDE_DIRS CACHE STRING "" FORCE) + # appveyor does not build modorganizer in its standard location, so use # DEPENDENCIES_DIR to find cmake_common if(DEFINED DEPENDENCIES_DIR) diff --git a/src/bbcode.cpp b/src/bbcode.cpp index e56c4ea2..5e888b91 100644 --- a/src/bbcode.cpp +++ b/src/bbcode.cpp @@ -19,7 +19,7 @@ along with Mod Organizer. If not, see . #include "bbcode.h" #include -#include +#include #include namespace BBCode { @@ -28,7 +28,7 @@ namespace log = MOBase::log; class BBCodeMap { - typedef std::map > TagMap; + typedef std::map > TagMap; public: @@ -40,8 +40,8 @@ public: QString convertTag(QString input, int &length) { // extract the tag name - m_TagNameExp.indexIn(input, 1, QRegExp::CaretAtOffset); - QString tagName = m_TagNameExp.cap(0).toLower(); + auto match = m_TagNameExp.match(input, 1, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption); + QString tagName = match.captured(0).toLower(); TagMap::iterator tagIter = m_TagMap.find(tagName); if (tagIter != m_TagMap.end()) { // recognized tag @@ -53,7 +53,7 @@ public: int closeTagLength = 0; if (tagName == "*") { // ends at the next bullet point - closeTagPos = input.indexOf(QRegExp("(\\[\\*\\]|)", Qt::CaseInsensitive), 3); + closeTagPos = input.indexOf(QRegularExpression("(\\[\\*\\]|)", QRegularExpression::CaseInsensitiveOption), 3); // leave closeTagLength at 0 because we don't want to "eat" the next bullet point } else if (tagName == "line") { // ends immediately after the tag @@ -73,11 +73,12 @@ public: if (closeTagPos > -1) { length = closeTagPos + closeTagLength; QString temp = input.mid(0, length); - if (tagIter->second.first.indexIn(temp) == 0) { + auto match = tagIter->second.first.match(temp); + if (match.hasMatch()) { if (tagIter->second.second.isEmpty()) { if (tagName == "color") { - QString color = tagIter->second.first.cap(1); - QString content = tagIter->second.first.cap(2); + QString color = match.captured(1); + QString content = match.captured(2); if (color.at(0) == '#') { return temp.replace(tagIter->second.first, QString("%2").arg(color, content)); } else { @@ -92,7 +93,7 @@ public: } } else { if (tagName == "*") { - temp.remove(QRegExp("(\\[/\\*\\])?(
)?$")); + temp.remove(QRegularExpression("(\\[/\\*\\])?(
)?$")); } return temp.replace(tagIter->second.first, tagIter->second.second); } @@ -115,84 +116,83 @@ private: BBCodeMap() : m_TagNameExp("^[a-zA-Z*]*=?") { - m_TagMap["b"] = std::make_pair(QRegExp("\\[b\\](.*)\\[/b\\]"), + m_TagMap["b"] = std::make_pair(QRegularExpression("\\[b\\](.*)\\[/b\\]"), "\\1"); - m_TagMap["i"] = std::make_pair(QRegExp("\\[i\\](.*)\\[/i\\]"), + m_TagMap["i"] = std::make_pair(QRegularExpression("\\[i\\](.*)\\[/i\\]"), "\\1"); - m_TagMap["u"] = std::make_pair(QRegExp("\\[u\\](.*)\\[/u\\]"), + m_TagMap["u"] = std::make_pair(QRegularExpression("\\[u\\](.*)\\[/u\\]"), "\\1"); - m_TagMap["s"] = std::make_pair(QRegExp("\\[s\\](.*)\\[/s\\]"), + m_TagMap["s"] = std::make_pair(QRegularExpression("\\[s\\](.*)\\[/s\\]"), "\\1"); - m_TagMap["sub"] = std::make_pair(QRegExp("\\[sub\\](.*)\\[/sub\\]"), + m_TagMap["sub"] = std::make_pair(QRegularExpression("\\[sub\\](.*)\\[/sub\\]"), "\\1"); - m_TagMap["sup"] = std::make_pair(QRegExp("\\[sup\\](.*)\\[/sup\\]"), + m_TagMap["sup"] = std::make_pair(QRegularExpression("\\[sup\\](.*)\\[/sup\\]"), "\\1"); - m_TagMap["size="] = std::make_pair(QRegExp("\\[size=([^\\]]*)\\](.*)\\[/size\\]"), + m_TagMap["size="] = std::make_pair(QRegularExpression("\\[size=([^\\]]*)\\](.*)\\[/size\\]"), "\\2"); - m_TagMap["color="] = std::make_pair(QRegExp("\\[color=([^\\]]*)\\](.*)\\[/color\\]"), + m_TagMap["color="] = std::make_pair(QRegularExpression("\\[color=([^\\]]*)\\](.*)\\[/color\\]"), ""); - m_TagMap["font="] = std::make_pair(QRegExp("\\[font=([^\\]]*)\\](.*)\\[/font\\]"), + m_TagMap["font="] = std::make_pair(QRegularExpression("\\[font=([^\\]]*)\\](.*)\\[/font\\]"), "\\2"); - m_TagMap["center"] = std::make_pair(QRegExp("\\[center\\](.*)\\[/center\\]"), + m_TagMap["center"] = std::make_pair(QRegularExpression("\\[center\\](.*)\\[/center\\]"), "
\\1
"); - m_TagMap["quote"] = std::make_pair(QRegExp("\\[quote\\](.*)\\[/quote\\]"), + m_TagMap["quote"] = std::make_pair(QRegularExpression("\\[quote\\](.*)\\[/quote\\]"), "
\\1
"); - m_TagMap["quote="] = std::make_pair(QRegExp("\\[quote=([^\\]]*)\\](.*)\\[/quote\\]"), + m_TagMap["quote="] = std::make_pair(QRegularExpression("\\[quote=([^\\]]*)\\](.*)\\[/quote\\]"), "
\\2
"); - m_TagMap["spoiler"] = std::make_pair(QRegExp("\\[spoiler\\](.*)\\[/spoiler\\]"), + m_TagMap["spoiler"] = std::make_pair(QRegularExpression("\\[spoiler\\](.*)\\[/spoiler\\]"), "
Spoiler:
Show
\\1
"); - m_TagMap["code"] = std::make_pair(QRegExp("\\[code\\](.*)\\[/code\\]"), + m_TagMap["code"] = std::make_pair(QRegularExpression("\\[code\\](.*)\\[/code\\]"), "\\1"); - m_TagMap["heading"]= std::make_pair(QRegExp("\\[heading\\](.*)\\[/heading\\]"), + m_TagMap["heading"]= std::make_pair(QRegularExpression("\\[heading\\](.*)\\[/heading\\]"), "

\\1

"); - m_TagMap["line"] = std::make_pair(QRegExp("\\[line\\]"), + m_TagMap["line"] = std::make_pair(QRegularExpression("\\[line\\]"), "
"); // lists - m_TagMap["list"] = std::make_pair(QRegExp("\\[list\\](.*)\\[/list\\]"), + m_TagMap["list"] = std::make_pair(QRegularExpression("\\[list\\](.*)\\[/list\\]"), "
    \\1
"); - m_TagMap["list="] = std::make_pair(QRegExp("\\[list.*\\](.*)\\[/list\\]"), + m_TagMap["list="] = std::make_pair(QRegularExpression("\\[list.*\\](.*)\\[/list\\]"), "
    \\1
"); - m_TagMap["ul"] = std::make_pair(QRegExp("\\[ul\\](.*)\\[/ul\\]"), + m_TagMap["ul"] = std::make_pair(QRegularExpression("\\[ul\\](.*)\\[/ul\\]"), "
    \\1
"); - m_TagMap["ol"] = std::make_pair(QRegExp("\\[ol\\](.*)\\[/ol\\]"), + m_TagMap["ol"] = std::make_pair(QRegularExpression("\\[ol\\](.*)\\[/ol\\]"), "
    \\1
"); - m_TagMap["li"] = std::make_pair(QRegExp("\\[li\\](.*)\\[/li\\]"), + m_TagMap["li"] = std::make_pair(QRegularExpression("\\[li\\](.*)\\[/li\\]"), "
  • \\1
  • "); // tables - m_TagMap["table"] = std::make_pair(QRegExp("\\[table\\](.*)\\[/table\\]"), + m_TagMap["table"] = std::make_pair(QRegularExpression("\\[table\\](.*)\\[/table\\]"), "\\1
    "); - m_TagMap["tr"] = std::make_pair(QRegExp("\\[tr\\](.*)\\[/tr\\]"), + m_TagMap["tr"] = std::make_pair(QRegularExpression("\\[tr\\](.*)\\[/tr\\]"), "\\1"); - m_TagMap["th"] = std::make_pair(QRegExp("\\[th\\](.*)\\[/th\\]"), + m_TagMap["th"] = std::make_pair(QRegularExpression("\\[th\\](.*)\\[/th\\]"), "\\1"); - m_TagMap["td"] = std::make_pair(QRegExp("\\[td\\](.*)\\[/td\\]"), + m_TagMap["td"] = std::make_pair(QRegularExpression("\\[td\\](.*)\\[/td\\]"), "\\1"); // web content - m_TagMap["url"] = std::make_pair(QRegExp("\\[url\\](.*)\\[/url\\]"), + m_TagMap["url"] = std::make_pair(QRegularExpression("\\[url\\](.*)\\[/url\\]"), "\\1"); - m_TagMap["url="] = std::make_pair(QRegExp("\\[url=([^\\]]*)\\](.*)\\[/url\\]"), + m_TagMap["url="] = std::make_pair(QRegularExpression("\\[url=([^\\]]*)\\](.*)\\[/url\\]"), "\\2"); - m_TagMap["img"] = std::make_pair(QRegExp("\\[img(?:\\s*width=\\d+\\s*,?\\s*height=\\d+)?\\](.*)\\[/img\\]"), + m_TagMap["img"] = std::make_pair(QRegularExpression("\\[img(?:\\s*width=\\d+\\s*,?\\s*height=\\d+)?\\](.*)\\[/img\\]"), ""); - m_TagMap["img="] = std::make_pair(QRegExp("\\[img=([^\\]]*)\\](.*)\\[/img\\]"), + m_TagMap["img="] = std::make_pair(QRegularExpression("\\[img=([^\\]]*)\\](.*)\\[/img\\]"), "\"\\1\""); - m_TagMap["email="] = std::make_pair(QRegExp("\\[email=\"?([^\\]]*)\"?\\](.*)\\[/email\\]"), + m_TagMap["email="] = std::make_pair(QRegularExpression("\\[email=\"?([^\\]]*)\"?\\](.*)\\[/email\\]"), "\\2"); - m_TagMap["youtube"] = std::make_pair(QRegExp("\\[youtube\\](.*)\\[/youtube\\]"), + m_TagMap["youtube"] = std::make_pair(QRegularExpression("\\[youtube\\](.*)\\[/youtube\\]"), "https://www.youtube.com/watch?v=\\1"); // make all patterns non-greedy and case-insensitive for (TagMap::iterator iter = m_TagMap.begin(); iter != m_TagMap.end(); ++iter) { - iter->second.first.setCaseSensitivity(Qt::CaseInsensitive); - iter->second.first.setMinimal(true); + iter->second.first.setPatternOptions(QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption); } // this tag is in fact greedy - m_TagMap["*"] = std::make_pair(QRegExp("\\[\\*\\](.*)"), + m_TagMap["*"] = std::make_pair(QRegularExpression("\\[\\*\\](.*)"), "
  • \\1
  • "); m_ColorMap.insert(std::make_pair("red", "FF0000")); @@ -216,7 +216,7 @@ private: private: - QRegExp m_TagNameExp; + QRegularExpression m_TagNameExp; TagMap m_TagMap; std::map m_ColorMap; }; @@ -241,7 +241,7 @@ QString convertToHTML(const QString &inputParam) // iterate over the input buffer while ((pos = input.indexOf('[', lastBlock)) != -1) { // append everything between the previous tag-block and the current one - result.append(input.midRef(lastBlock, pos - lastBlock)); + result.append(input.mid(lastBlock, pos - lastBlock)); if ((pos < (input.size() - 1)) && (input.at(pos + 1) == '/')) { // skip invalid end tag @@ -272,7 +272,7 @@ QString convertToHTML(const QString &inputParam) } // append the remainder (everything after the last tag) - result.append(input.midRef(lastBlock)); + result.append(input.mid(lastBlock)); return result; } diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp index 72cb8862..8e341363 100644 --- a/src/browserdialog.cpp +++ b/src/browserdialog.cpp @@ -174,16 +174,18 @@ void BrowserDialog::titleChanged(const QString &title) QString BrowserDialog::guessFileName(const QString &url) { - QRegExp uploadsExp(QString("https://.+/uploads/([^/]+)$")); - if (uploadsExp.indexIn(url) != -1) { + QRegularExpression uploadsExp(QString("https://.+/uploads/([^/]+)$")); + auto match = uploadsExp.match(url); + if (match.hasMatch()) { // these seem to be premium downloads - return uploadsExp.cap(1); + return match.captured(1); } - QRegExp filesExp(QString("https://.+\\?file=([^&]+)")); - if (filesExp.indexIn(url) != -1) { + QRegularExpression filesExp(QString("https://.+\\?file=([^&]+)")); + match = filesExp.match(url); + if (match.hasMatch()) { // a regular manual download? - return filesExp.cap(1); + return match.captured(1); } return "unknown"; } @@ -196,13 +198,13 @@ void BrowserDialog::unsupportedContent(QNetworkReply *reply) log::error("sender not a page"); return; } - BrowserView *view = qobject_cast(page->view()); + /*browserview *view = qobject_cast(page->view()); if (view == nullptr) { log::error("no view?"); return; - } + }*/ - emit requestDownload(view->url(), reply); + emit requestDownload(page->url(), reply); } catch (const std::exception &e) { if (isVisible()) { MessageDialog::showMessage(tr("failed to start download"), this); diff --git a/src/browserview.cpp b/src/browserview.cpp index 0b871e23..81fd8a74 100644 --- a/src/browserview.cpp +++ b/src/browserview.cpp @@ -22,7 +22,7 @@ along with Mod Organizer. If not, see . #include #include #include -#include +#include #include #include #include @@ -55,7 +55,7 @@ bool BrowserView::eventFilter(QObject *obj, QEvent *event) } } else if (event->type() == QEvent::MouseButtonPress) { QMouseEvent *mouseEvent = static_cast(event); - if (mouseEvent->button() == Qt::MidButton) { + if (mouseEvent->button() == Qt::MouseButton::MiddleButton) { mouseEvent->ignore(); return true; } diff --git a/src/categories.cpp b/src/categories.cpp index 4ddd71d9..01383031 100644 --- a/src/categories.cpp +++ b/src/categories.cpp @@ -160,7 +160,7 @@ void CategoryFactory::saveCategories() QByteArray line; line.append(QByteArray::number(iter->m_ID)).append("|") .append(iter->m_Name.toUtf8()).append("|") - .append(VectorJoin(iter->m_NexusIDs, ",")).append("|") + .append(VectorJoin(iter->m_NexusIDs, ",").toUtf8()).append("|") .append(QByteArray::number(iter->m_ParentID)).append("\n"); categoryFile.write(line); } diff --git a/src/categoriesdialog.cpp b/src/categoriesdialog.cpp index b5194bf0..5181d9f1 100644 --- a/src/categoriesdialog.cpp +++ b/src/categoriesdialog.cpp @@ -23,7 +23,7 @@ along with Mod Organizer. If not, see . #include "utility.h" #include "settings.h" #include -#include +#include #include #include @@ -134,7 +134,7 @@ void CategoriesDialog::commitChanges() for (int i = 0; i < ui->categoriesTable->rowCount(); ++i) { int index = ui->categoriesTable->verticalHeader()->logicalIndex(i); QString nexusIDString = ui->categoriesTable->item(index, 2)->text(); - QStringList nexusIDStringList = nexusIDString.split(',', QString::SkipEmptyParts); + QStringList nexusIDStringList = nexusIDString.split(',', Qt::SkipEmptyParts); std::vector nexusIDs; for (QStringList::iterator iter = nexusIDStringList.begin(); iter != nexusIDStringList.end(); ++iter) { @@ -189,7 +189,7 @@ void CategoriesDialog::fillTable() table->setItemDelegateForColumn(0, new ValidatingDelegate(this, new NewIDValidator(m_IDs))); - table->setItemDelegateForColumn(2, new ValidatingDelegate(this, new QRegExpValidator(QRegExp("([0-9]+)?(,[0-9]+)*"), this))); + table->setItemDelegateForColumn(2, new ValidatingDelegate(this, new QRegularExpressionValidator(QRegularExpression("([0-9]+)?(,[0-9]+)*"), this))); table->setItemDelegateForColumn(3, new ValidatingDelegate(this, new ExistingIDValidator(m_IDs))); int row = 0; diff --git a/src/csvbuilder.cpp b/src/csvbuilder.cpp index fa4218a2..788c9438 100644 --- a/src/csvbuilder.cpp +++ b/src/csvbuilder.cpp @@ -4,7 +4,7 @@ CSVBuilder::CSVBuilder(QIODevice *target) : m_Out(target), m_Separator(','), m_LineBreak(BREAK_CRLF) { - m_Out.setCodec("UTF-8"); + m_Out.setEncoding(QStringConverter::Encoding::Utf8); m_QuoteMode[TYPE_INTEGER] = QUOTE_NEVER; m_QuoteMode[TYPE_FLOAT] = QUOTE_NEVER; diff --git a/src/directoryrefresher.h b/src/directoryrefresher.h index 0677998b..7cdda99d 100644 --- a/src/directoryrefresher.h +++ b/src/directoryrefresher.h @@ -34,8 +34,7 @@ along with Mod Organizer. If not, see . **/ class DirectoryRefresher : public QObject { - - Q_OBJECT + Q_OBJECT; public: struct EntryInfo @@ -54,11 +53,8 @@ public: int priority; }; - DirectoryRefresher(std::size_t threadCount); - // noncopyable - DirectoryRefresher(const DirectoryRefresher&) = delete; - DirectoryRefresher& operator=(const DirectoryRefresher&) = delete; + DirectoryRefresher(std::size_t threadCount); /** * @brief retrieve the updated directory structure @@ -82,7 +78,7 @@ public: * @param modDirectory the mod directory * @note this function could be obsoleted easily by storing absolute paths in the parameter to setMods. This is legacy */ - void setModDirectory(const QString &modDirectory); + //void setModDirectory(const QString &modDirectory); /** * @brief remove files from the directory structure that are known to be irrelevant to the game @@ -157,9 +153,9 @@ private: }; -class DirectoryRefreshProgress : QObject +class DirectoryRefreshProgress : public QObject { - Q_OBJECT; + Q_OBJECT public: DirectoryRefreshProgress(DirectoryRefresher* r) : diff --git a/src/dlls.manifest.debug.qt5 b/src/dlls.manifest.debug.qt5 index a2f75206..728c01b2 100644 --- a/src/dlls.manifest.debug.qt5 +++ b/src/dlls.manifest.debug.qt5 @@ -1,29 +1,46 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dlls.manifest.qt5 b/src/dlls.manifest.qt5 index cae74df1..ebda0f8a 100644 --- a/src/dlls.manifest.qt5 +++ b/src/dlls.manifest.qt5 @@ -4,26 +4,43 @@ + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 7272e3fd..ea7d20de 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -482,7 +482,7 @@ void EditExecutablesDialog::save() e->title(newTitle); } - e->binaryInfo(ui->binary->text()); + e->binaryInfo(QFileInfo(ui->binary->text())); e->workingDirectory(ui->workingDirectory->text()); e->arguments(ui->arguments->text()); diff --git a/src/env.cpp b/src/env.cpp index 4f4bc555..818ce8fb 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -801,7 +801,7 @@ std::pair splitExeAndArguments(const QString& cmd) } } else { // no double-quotes, find the first whitespace - exeEnd = cmd.indexOf(QRegExp("\\s")); + exeEnd = cmd.indexOf(QRegularExpression("\\s")); if (exeEnd == -1) { exeEnd = cmd.size(); } @@ -844,7 +844,7 @@ Association getAssociation(const QFileInfo& targetInfo) log::debug("split into exe='{}' and cmd='{}'", p.first, p.second); - return {p.first, *cmd, p.second}; + return {QFileInfo(p.first), *cmd, p.second}; } @@ -1108,7 +1108,7 @@ DWORD findOtherPid() // going through processes, trying to find one with the same name and a // different pid than this process has for (const auto& p : processes) { - if (p.name() == filename) { + if (p.name().toStdWString() == filename) { if (p.pid() != thisPid) { return p.pid(); } diff --git a/src/envmetrics.cpp b/src/envmetrics.cpp index 5fb80449..b47ca2f5 100644 --- a/src/envmetrics.cpp +++ b/src/envmetrics.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace env { diff --git a/src/envshell.cpp b/src/envshell.cpp index 33ec0624..d38859a2 100644 --- a/src/envshell.cpp +++ b/src/envshell.cpp @@ -70,9 +70,9 @@ public: { } - bool nativeEventFilter(const QByteArray& type, void* m, long* lresultOut) override + bool nativeEventFilter(const QByteArray& eventType, void* message, qintptr* result) override { - MSG* msg = (MSG*)m; + MSG* msg = (MSG*)message; if (!msg) { return false; } @@ -81,8 +81,8 @@ public: const bool r = m_f(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lr); - if (lresultOut) { - *lresultOut = lr; + if (result) { + *result = lr; } return r; diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 78aa981d..137f38dc 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -94,7 +94,7 @@ void ExecutablesList::load(const MOBase::IPluginGame* game, const Settings& s) setExecutable(Executable() .title(map["title"].toString()) - .binaryInfo(map["binary"].toString()) + .binaryInfo(QFileInfo(map["binary"].toString())) .arguments(map["arguments"].toString()) .steamAppID(map["steamAppID"].toString()) .workingDirectory(map["workingDirectory"].toString()) diff --git a/src/filedialogmemory.h b/src/filedialogmemory.h index 8b8a3b76..11b156ed 100644 --- a/src/filedialogmemory.h +++ b/src/filedialogmemory.h @@ -38,7 +38,7 @@ public: static QString getOpenFileName( const QString &dirID, QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), - QString *selectedFilter = 0, QFileDialog::Options options = 0); + QString *selectedFilter = 0, QFileDialog::Options options = QFileDialog::Option(0)); static QString getExistingDirectory( const QString &dirID, QWidget *parent = 0, const QString &caption = QString(), diff --git a/src/filerenamer.cpp b/src/filerenamer.cpp index 7fc90eb2..dd5876b6 100644 --- a/src/filerenamer.cpp +++ b/src/filerenamer.cpp @@ -38,7 +38,7 @@ FileRenamer::RenameResults FileRenamer::rename(const QString& oldName, const QSt log::debug("removing {}", newName); // user wants to replace the file, so remove it - const auto r = shell::Delete(newName); + const auto r = shell::Delete(QFileInfo(newName)); if (!r.success()) { log::error("failed to remove '{}': {}", newName, r.toString()); @@ -68,7 +68,7 @@ FileRenamer::RenameResults FileRenamer::rename(const QString& oldName, const QSt } // target either didn't exist or was removed correctly - const auto r = shell::Rename(oldName, newName); + const auto r = shell::Rename(QFileInfo(oldName), QFileInfo(newName)); if (!r.success()) { log::error( diff --git a/src/filetree.cpp b/src/filetree.cpp index cf20d4fd..02c85fdd 100644 --- a/src/filetree.cpp +++ b/src/filetree.cpp @@ -568,7 +568,7 @@ bool FileTree::showShellMenu(QPoint pos) .arg(item->realPath())); } - itor->second.addFile(item->realPath()); + itor->second.addFile(QFileInfo(item->realPath())); ++totalFiles; if (item->isConflicted()) { @@ -611,7 +611,7 @@ bool FileTree::showShellMenu(QPoint pos) .arg(QString::fromStdWString(fullPath))); } - itor->second.addFile(QString::fromStdWString(fullPath)); + itor->second.addFile(QFileInfo(QString::fromStdWString(fullPath))); } } } diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp index 22bcda28..bd9cd067 100644 --- a/src/filetreemodel.cpp +++ b/src/filetreemodel.cpp @@ -1100,8 +1100,8 @@ QVariant FileTreeModel::displayData(const FileTreeItem* item, int column) const case LastModified: { if (auto d=item->lastModified()) { - if (d->isValid()) { - return d->toString(Qt::SystemLocaleDate); + if (d.has_value() && d.value().isValid()) { + return QLocale::system().toString(d.value(), QLocale::ShortFormat); } } diff --git a/src/glob_matching.h b/src/glob_matching.h index 69e2d2a4..e7e7b621 100644 --- a/src/glob_matching.h +++ b/src/glob_matching.h @@ -114,8 +114,8 @@ namespace MOShared { while (str_it != str_end) { - CharT current_pat = 0; - CharT current_str = -1; + CharT current_pat = QChar(0); + CharT current_str = QChar(-1); if (pat_it != pat_end) { current_pat = case_sensitive ? *pat_it : traits::tolower(*pat_it); diff --git a/src/iconfetcher.cpp b/src/iconfetcher.cpp index c10adc8d..32b0d58b 100644 --- a/src/iconfetcher.cpp +++ b/src/iconfetcher.cpp @@ -53,7 +53,7 @@ QVariant IconFetcher::icon(const QString& path) const return m_quickCache.file; } - return extensionIcon(path.midRef(dot)); + return extensionIcon(QStringView{path}.mid(dot)); } } @@ -110,7 +110,7 @@ void IconFetcher::checkCache(Cache& cache) std::map map; for (auto&& ext : queue) { - map.emplace(std::move(ext), getPixmapIcon(ext)); + map.emplace(std::move(ext), getPixmapIcon(QFileInfo(ext))); } { @@ -145,7 +145,7 @@ QVariant IconFetcher::fileIcon(const QString& path) const return {}; } -QVariant IconFetcher::extensionIcon(const QStringRef& ext) const +QVariant IconFetcher::extensionIcon(const QStringView& ext) const { { std::scoped_lock lock(m_extensionCache.mapMutex); diff --git a/src/iconfetcher.h b/src/iconfetcher.h index 030bfb79..78857d05 100644 --- a/src/iconfetcher.h +++ b/src/iconfetcher.h @@ -1,8 +1,9 @@ #ifndef MODORGANIZER_ICONFETCHER_INCLUDED #define MODORGANIZER_ICONFETCHER_INCLUDED - -#include +#include #include +#include +#include class IconFetcher { @@ -70,7 +71,7 @@ private: void queue(Cache& cache, QString path) const; QVariant fileIcon(const QString& path) const; - QVariant extensionIcon(const QStringRef& ext) const; + QVariant extensionIcon(const QStringView& ext) const; }; #endif // MODORGANIZER_ICONFETCHER_INCLUDED diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp index f2c031d0..3a5aee4c 100644 --- a/src/instancemanager.cpp +++ b/src/instancemanager.cpp @@ -590,7 +590,7 @@ QString InstanceManager::instancePath(const QString& instanceName) const QString InstanceManager::globalInstancesRootPath() const { return QDir::fromNativeSeparators( - QStandardPaths::writableLocation(QStandardPaths::DataLocation)); + QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); } QString InstanceManager::iniPath(const QString& instanceDir) const diff --git a/src/instancemanagerdialog.cpp b/src/instancemanagerdialog.cpp index f21ff695..776b2496 100644 --- a/src/instancemanagerdialog.cpp +++ b/src/instancemanagerdialog.cpp @@ -416,7 +416,7 @@ void InstanceManagerDialog::rename() log::info("renaming {} to {}", src, dest); - const auto r = shell::Rename(src, dest, false); + const auto r = shell::Rename(QFileInfo(src), QFileInfo(dest), false); if (!r) { QMessageBox::critical( diff --git a/src/loglist.cpp b/src/loglist.cpp index e6b8b724..07592edc 100644 --- a/src/loglist.cpp +++ b/src/loglist.cpp @@ -139,7 +139,7 @@ QVariant LogModel::data(const QModelIndex& index, int role) const const std::time_t tt = s.count(); const int frac = static_cast(ms.count() % 1000); - const auto time = QDateTime::fromTime_t(tt).time().addMSecs(frac); + const auto time = QDateTime::fromSecsSinceEpoch(tt).time().addMSecs(frac); return time.toString("hh:mm:ss.zzz"); } else if (index.column() == 2) { return QString::fromStdString(e.message); diff --git a/src/loot.cpp b/src/loot.cpp index d41fd77b..9c9ab2ae 100644 --- a/src/loot.cpp +++ b/src/loot.cpp @@ -714,7 +714,7 @@ void Loot::deleteReportFile() { if (QFile::exists(LootReportPath)) { log::debug("deleting temporary loot report '{}'", LootReportPath); - const auto r = shell::Delete(LootReportPath); + const auto r = shell::Delete(QFileInfo(LootReportPath)); if (!r) { log::error( diff --git a/src/lootdialog.cpp b/src/lootdialog.cpp index 3673c5c6..9f7b16f0 100644 --- a/src/lootdialog.cpp +++ b/src/lootdialog.cpp @@ -114,7 +114,7 @@ void LootDialog::addOutput(const QString& s) return; } - const auto lines = s.split(QRegExp("[\\r\\n]"), QString::SkipEmptyParts); + const auto lines = s.split(QRegularExpression("[\\r\\n]"), Qt::SkipEmptyParts); for (auto&& line : lines) { if (line.isEmpty()) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 028aabfd..906e40d6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -387,8 +387,8 @@ MainWindow::MainWindow(Settings &settings connect(&m_OrganizerCore, &OrganizerCore::directoryStructureReady, this, &MainWindow::onDirectoryStructureChanged); - connect(m_OrganizerCore.directoryRefresher(), &DirectoryRefresher::progress, - this, &MainWindow::refresherProgress); + connect(m_OrganizerCore.directoryRefresher(), SIGNAL(progress(DirectoryRefreshProgress*)), + this, SLOT(refresherProgress(DirectoryRefreshProgress*))); connect(m_OrganizerCore.directoryRefresher(), SIGNAL(error(QString)), this, SLOT(showError(QString))); connect(&m_OrganizerCore.settings(), SIGNAL(languageChanged(QString)), this, SLOT(languageChange(QString))); diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 2e3af26e..744b6b63 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -232,10 +232,6 @@ int MOApplication::setup(MOMultiProcess& multiProcess, bool forceSelect) purgeOldFiles(); } - QWindowsWindowFunctions::setWindowActivationBehavior( - QWindowsWindowFunctions::AlwaysActivateWindow); - - // loading settings m_settings.reset(new Settings(m_instance->iniPath(), true)); log::getDefault().setLevel(m_settings->diagnostics().logLevel()); diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 59026262..3c54fc27 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -55,7 +55,7 @@ ModInfo::Ptr ModInfo::s_Overwrite; std::map ModInfo::s_ModsByName; std::map, std::vector> ModInfo::s_ModsByModID; int ModInfo::s_NextID; -QMutex ModInfo::s_Mutex(QMutex::Recursive); +QRecursiveMutex ModInfo::s_Mutex; QString ModInfo::s_HiddenExt(".mohidden"); @@ -67,14 +67,14 @@ bool ModInfo::ByName(const ModInfo::Ptr &LHS, const ModInfo::Ptr &RHS) bool ModInfo::isSeparatorName(const QString& name) { - static QRegExp separatorExp(".*_separator"); - return separatorExp.exactMatch(name); + static QRegularExpression separatorExp(QRegularExpression::anchoredPattern(".*_separator")); + return separatorExp.match(name).hasMatch(); } bool ModInfo::isBackupName(const QString& name) { - static QRegExp backupExp(".*backup[0-9]*"); - return backupExp.exactMatch(name); + static QRegularExpression backupExp(QRegularExpression::anchoredPattern(".*backup[0-9]*")); + return backupExp.match(name).hasMatch(); } bool ModInfo::isRegularName(const QString& name) diff --git a/src/modinfo.h b/src/modinfo.h index b835f352..8f82a453 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -29,7 +29,7 @@ class PluginContainer; class QDir; class QDateTime; -#include +#include #include #include #include @@ -980,7 +980,7 @@ protected: protected: - static QMutex s_Mutex; + static QRecursiveMutex s_Mutex; static std::vector s_Collection; static ModInfo::Ptr s_Overwrite; static std::map s_ModsByName; diff --git a/src/modinfodialogconflicts.cpp b/src/modinfodialogconflicts.cpp index bb3346f7..923e9778 100644 --- a/src/modinfodialogconflicts.cpp +++ b/src/modinfodialogconflicts.cpp @@ -245,7 +245,7 @@ void ConflictsTab::openItems(QTreeView* tree, bool hooked) void ConflictsTab::openItem(const ConflictItem* item, bool hooked) { core().processRunner() - .setFromFile(parentWidget(), item->fileName()) + .setFromFile(parentWidget(), QFileInfo(item->fileName())) .setHooked(hooked) .setWaitForCompletion() .run(); diff --git a/src/modinfodialogfiletree.cpp b/src/modinfodialogfiletree.cpp index cc0e6493..9f39447d 100644 --- a/src/modinfodialogfiletree.cpp +++ b/src/modinfodialogfiletree.cpp @@ -172,7 +172,7 @@ void FileTreeTab::onOpen() const auto path = m_fs->filePath(selection); core().processRunner() - .setFromFile(parentWidget(), path) + .setFromFile(parentWidget(), QFileInfo(path)) .setHooked(false) .setWaitForCompletion() .run(); @@ -187,7 +187,7 @@ void FileTreeTab::onRunHooked() const auto path = m_fs->filePath(selection); core().processRunner() - .setFromFile(parentWidget(), path) + .setFromFile(parentWidget(), QFileInfo(path)) .setHooked(true) .setWaitForCompletion() .run(); diff --git a/src/modinfodialogimages.cpp b/src/modinfodialogimages.cpp index 0abbe53a..530d23d5 100644 --- a/src/modinfodialogimages.cpp +++ b/src/modinfodialogimages.cpp @@ -234,8 +234,8 @@ void ImagesTab::getSupportedFormats() } // make sure it starts with a dot - if (s[0] != ".") { - s = "." + s; + if (s[0] != '.') { + s = '.' + s; } m_supportedFormats.emplace_back(std::move(s)); diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index 94f2fc31..f3dd1caa 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -186,7 +186,7 @@ void ModInfoRegular::readMeta() QString categoriesString = metaFile.value("category", "").toString(); - QStringList categories = categoriesString.split(',', QString::SkipEmptyParts); + QStringList categories = categoriesString.split(',', Qt::SkipEmptyParts); for (QStringList::iterator iter = categories.begin(); iter != categories.end(); ++iter) { bool ok = false; int categoryID = iter->toInt(&ok); diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 4084af24..a34f730f 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -462,13 +462,13 @@ bool ModListSortProxy::filterMatchesMod(ModInfo::Ptr info, bool enabled) const bool display = false; QString filterCopy = QString(m_Filter); filterCopy.replace("||", ";").replace("OR", ";").replace("|", ";"); - QStringList ORList = filterCopy.split(";", QString::SkipEmptyParts); + QStringList ORList = filterCopy.split(";", Qt::SkipEmptyParts); bool segmentGood = true; //split in ORSegments that internally use AND logic for (auto& ORSegment : ORList) { - QStringList ANDKeywords = ORSegment.split(" ", QString::SkipEmptyParts); + QStringList ANDKeywords = ORSegment.split(" ", Qt::SkipEmptyParts); segmentGood = true; bool foundKeyword = false; diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 2e4496e1..5bda2b93 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -103,7 +103,7 @@ void NexusBridge::nxmFilesAvailable(QString gameName, int modID, QVariant userDa if (iter != m_RequestIDs.end()) { m_RequestIDs.erase(iter); - QList fileInfoList; + QList fileInfoList; QVariantMap resultInfo = resultData.toMap(); QList resultList = resultInfo["files"].toList(); @@ -118,7 +118,7 @@ void NexusBridge::nxmFilesAvailable(QString gameName, int modID, QVariant userDa temp.categoryID = fileInfo["category_id"].toInt(); temp.fileID = fileInfo["file_id"].toInt(); temp.fileSize = fileInfo["size"].toInt(); - fileInfoList.append(temp); + fileInfoList.append(&temp); } emit filesAvailable(gameName, modID, userData, fileInfoList); @@ -325,7 +325,7 @@ void NexusInterface::interpretNexusFileName(const QString &fileName, QString &mo if (query) { SelectionDialog selection(tr("Please pick the mod ID for \"%1\"").arg(fileName)); int index = 0; - auto splits = fileName.split(QRegExp("[^0-9]"), QString::KeepEmptyParts); + auto splits = fileName.split(QRegularExpression("[^0-9]"), Qt::KeepEmptyParts); for (auto substr : splits) { bool ok = false; int value = substr.toInt(&ok); diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 001e1bb1..f05aeb36 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -786,11 +786,6 @@ NXMAccessManager::NXMAccessManager(QObject *parent, Settings* s, const QString & setCookieJar(new PersistentCookieJar(QDir::fromNativeSeparators( m_Settings->paths().cache() + "/nexus_cookies.dat"))); } - - if (networkAccessible() == QNetworkAccessManager::UnknownAccessibility) { - // why is this necessary all of a sudden? - setNetworkAccessible(QNetworkAccessManager::Accessible); - } } void NXMAccessManager::setTopLevelWidget(QWidget* w) diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 7cf3212a..0807957b 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1428,17 +1428,20 @@ void OrganizerCore::requestDownload(const QUrl &url, QNetworkReply *reply) QString gameName = ""; int modID = 0; int fileID = 0; - QRegExp nameExp("www\\.nexusmods\\.com/(\\a+)/"); - if (nameExp.indexIn(url.toString()) != -1) { - gameName = nameExp.cap(1); + QRegularExpression nameExp("www\\.nexusmods\\.com/(\\a+)/"); + auto match = nameExp.match(url.toString()); + if (match.hasMatch()) { + gameName = match.captured(1); } - QRegExp modExp("mods/(\\d+)"); - if (modExp.indexIn(url.toString()) != -1) { - modID = modExp.cap(1).toInt(); + QRegularExpression modExp("mods/(\\d+)"); + match = modExp.match(url.toString()); + if (match.hasMatch()) { + modID = match.captured(1).toInt(); } - QRegExp fileExp("fid=(\\d+)"); - if (fileExp.indexIn(reply->url().toString()) != -1) { - fileID = fileExp.cap(1).toInt(); + QRegularExpression fileExp("fid=(\\d+)"); + match = fileExp.match(url.toString()); + if (match.hasMatch()) { + fileID = match.captured(1).toInt(); } m_DownloadManager.addDownload(reply, new ModRepositoryFileInfo(gameName, modID, fileID)); diff --git a/src/pch.h b/src/pch.h index bfc7f2d2..b9958710 100644 --- a/src/pch.h +++ b/src/pch.h @@ -184,9 +184,8 @@ #include #include #include -#include -#include #include +#include #include #include #include @@ -243,7 +242,7 @@ #include #include #include -#include +#include #include #include #include @@ -263,7 +262,6 @@ #include #include #include -#include #include #include #include diff --git a/src/pluginlistsortproxy.cpp b/src/pluginlistsortproxy.cpp index 44285fd1..308a1398 100644 --- a/src/pluginlistsortproxy.cpp +++ b/src/pluginlistsortproxy.cpp @@ -72,7 +72,7 @@ bool PluginListSortProxy::lessThan(const QModelIndex &left, } else { for (int i = 0; i < lhsList.size(); ++i) { if (lhsList.at(i) != rhsList.at(i)) { - return lhsList.at(i) < rhsList.at(i); + return lhsList.at(i).toString() < rhsList.at(i).toString(); } } return false; @@ -122,13 +122,13 @@ bool PluginListSortProxy::filterMatchesPlugin(const QString &plugin) const bool display = false; QString filterCopy = QString(m_CurrentFilter); filterCopy.replace("||", ";").replace("OR", ";").replace("|", ";"); - QStringList ORList = filterCopy.split(";", QString::SkipEmptyParts); + QStringList ORList = filterCopy.split(";", Qt::SkipEmptyParts); bool segmentGood = true; //split in ORSegments that internally use AND logic for (auto& ORSegment : ORList) { - QStringList ANDKeywords = ORSegment.split(" ", QString::SkipEmptyParts); + QStringList ANDKeywords = ORSegment.split(" ", Qt::SkipEmptyParts); segmentGood = true; //check each word in the segment for match, each word needs to be matched but it doesn't matter where. diff --git a/src/processrunner.cpp b/src/processrunner.cpp index 4d83d0c8..4a954dee 100644 --- a/src/processrunner.cpp +++ b/src/processrunner.cpp @@ -649,7 +649,7 @@ ProcessRunner& ProcessRunner::setFromFileOrExecutable( throw MyException(QObject::tr("No profile set")); } - setBinary(executable); + setBinary(QFileInfo(executable)); setArguments(args.join(" ")); setCurrentDirectory(cwd); setProfileName(profileOverride); @@ -659,7 +659,7 @@ ProcessRunner& ProcessRunner::setFromFileOrExecutable( if (m_sp.binary.isRelative()) { // relative path, should be relative to game directory - setBinary(m_core.managedGame()->gameDirectory().absoluteFilePath(executable)); + setBinary(QFileInfo(m_core.managedGame()->gameDirectory().absoluteFilePath(executable))); } if (cwd == "") { diff --git a/src/qtgroupingproxy.cpp b/src/qtgroupingproxy.cpp index a8c7ce1d..d00bd288 100644 --- a/src/qtgroupingproxy.cpp +++ b/src/qtgroupingproxy.cpp @@ -152,7 +152,7 @@ QtGroupingProxy::belongsTo( const QModelIndex &idx ) return rowDataList; } -/* m_groupHash layout +/* m_groupMap layout * key : index of the group in m_groupMaps * value : a QList of the original rows in sourceModel() for the children of this group * @@ -167,7 +167,7 @@ QtGroupingProxy::buildTree() return; beginResetModel(); - m_groupHash.clear(); + m_groupMap.clear(); //don't clear the data maps since most of it will probably be needed again. m_parentCreateList.clear(); @@ -189,9 +189,9 @@ QtGroupingProxy::buildTree() quint32 quint32max = std::numeric_limits::max(); std::vector rmgroups; - QHash > temp; + QMap > temp; - for (auto iter = m_groupHash.begin(); iter != m_groupHash.end(); ++iter) { + for (auto iter = m_groupMap.begin(); iter != m_groupMap.end(); ++iter) { if ((iter.key() == quint32max) || (iter->count() < 2)) { temp[quint32max].append(iter.value()); @@ -202,7 +202,7 @@ QtGroupingProxy::buildTree() temp[currentKey++] = *iter; } } - m_groupHash = temp; + m_groupMap = temp; // second loop is necessary because qt containers can't be iterated from end to front // and removing by index from begin to end is ugly @@ -225,8 +225,8 @@ QtGroupingProxy::addSourceRow( const QModelIndex &idx ) if( groupData.isEmpty() ) { updatedGroups << -1; - if( !m_groupHash.keys().contains( std::numeric_limits::max() ) ) - m_groupHash.insert( std::numeric_limits::max(), QList() ); //add an empty placeholder + if( !m_groupMap.keys().contains( std::numeric_limits::max() ) ) + m_groupMap.insert( std::numeric_limits::max(), QList() ); //add an empty placeholder } //an item can be in multiple groups @@ -254,16 +254,16 @@ QtGroupingProxy::addSourceRow( const QModelIndex &idx ) updatedGroup = m_groupMaps.count() - 1; } - if( !m_groupHash.keys().contains( updatedGroup ) ) - m_groupHash.insert( updatedGroup, QList() ); //add an empty placeholder + if( !m_groupMap.keys().contains( updatedGroup ) ) + m_groupMap.insert( updatedGroup, QList() ); //add an empty placeholder } if( !updatedGroups.contains( updatedGroup ) ) updatedGroups << updatedGroup; } - //update m_groupHash to the new source-model layout (one row added) - QMutableHashIterator > i( m_groupHash ); + //update m_groupMap to the new source-model layout (one row added) + QMutableMapIterator > i( m_groupMap ); while( i.hasNext() ) { i.next(); @@ -360,7 +360,7 @@ QtGroupingProxy::rowCount( const QModelIndex &index ) const if( !index.isValid() ) { //the number of top level groups + the number of non-grouped items - int rows = m_groupMaps.count() + m_groupHash.value( std::numeric_limits::max() ).count(); + int rows = m_groupMaps.count() + m_groupMap.value( std::numeric_limits::max() ).count(); return rows; } @@ -368,7 +368,7 @@ QtGroupingProxy::rowCount( const QModelIndex &index ) const if( isGroup( index ) ) { qint64 groupIndex = index.row(); - int rows = m_groupHash.value( groupIndex ).count(); + int rows = m_groupMap.value( groupIndex ).count(); return rows; } else { QModelIndex originalIndex = mapToSource( index ); @@ -455,7 +455,7 @@ QtGroupingProxy::data( const QModelIndex &index, int role ) const } break; case Qt::CheckStateRole: { if (column != 0) return QVariant(); - int childCount = m_groupHash.value( row ).count(); + int childCount = m_groupMap.value( row ).count(); int checked = 0; QModelIndex parentIndex = this->index( row, 0, index.parent() ); for( int childRow = 0; childRow < childCount; ++childRow ) @@ -470,7 +470,7 @@ QtGroupingProxy::data( const QModelIndex &index, int role ) const } break; default: { QModelIndex parentIndex = this->index( row, 0, index.parent() ); - if (m_groupHash.value( row ).count() > 0) { + if (m_groupMap.value( row ).count() > 0) { return this->index(0, column, parentIndex).data(role); } else { return QVariant(); @@ -498,7 +498,7 @@ QtGroupingProxy::data( const QModelIndex &index, int role ) const //map all data from children to columns of group to allow grouping one level up QVariantList variantsOfChildren; - int childCount = m_groupHash.value( row ).count(); + int childCount = m_groupMap.value( row ).count(); if( childCount == 0 ) return QVariant(); @@ -573,7 +573,7 @@ QtGroupingProxy::setData( const QModelIndex &idx, const QVariant &value, int rol m_groupMaps[idx.row()].insert( idx.column(), columnData ); int columnToChange = idx.column() ? idx.column() : m_groupedColumn; - foreach( int originalRow, m_groupHash.value( idx.row() ) ) + foreach( int originalRow, m_groupMap.value( idx.row() ) ) { QModelIndex childIdx = sourceModel()->index( originalRow, columnToChange, m_rootNode ); @@ -620,7 +620,7 @@ QtGroupingProxy::mapToSource( const QModelIndex &index ) const if( !proxyParent.isValid() ) indexInGroup -= m_groupMaps.count(); - QList childRows = m_groupHash.value( proxyParent.row() ); + QList childRows = m_groupMap.value( proxyParent.row() ); if( childRows.isEmpty() || indexInGroup >= childRows.count() || indexInGroup < 0 ) return QModelIndex(); @@ -663,7 +663,7 @@ QtGroupingProxy::mapFromSource( const QModelIndex &idx ) const { //idx is an item in the top level of the source model (child of the rootnode) int groupRow = -1; - QHashIterator > iterator( m_groupHash ); + QMapIterator > iterator( m_groupMap ); while( iterator.hasNext() ) { iterator.next(); @@ -677,14 +677,14 @@ QtGroupingProxy::mapFromSource( const QModelIndex &idx ) const if( groupRow != -1 ) //it's in a group, let's find the correct row. { proxyParent = this->index( groupRow, 0, QModelIndex() ); - proxyRow = m_groupHash.value( groupRow ).indexOf( sourceRow ); + proxyRow = m_groupMap.value( groupRow ).indexOf( sourceRow ); } else { proxyParent = QModelIndex(); // if the proxy item is not in a group it will be below the groups. int groupLength = m_groupMaps.count(); - int i = m_groupHash.value( std::numeric_limits::max() ).indexOf( sourceRow ); + int i = m_groupMap.value( std::numeric_limits::max() ).indexOf( sourceRow ); proxyRow = groupLength + i; } @@ -702,7 +702,7 @@ QtGroupingProxy::flags( const QModelIndex &idx ) const if( rootFlags.testFlag( Qt::ItemIsDropEnabled ) ) return Qt::ItemFlags( Qt::ItemIsDropEnabled ); - return 0; + return Qt::ItemFlags(0); } //only if the grouped column has the editable flag set allow the @@ -716,7 +716,7 @@ QtGroupingProxy::flags( const QModelIndex &idx ) const if (idx.column() == 0) { bool checkable = true; - foreach ( int originalRow, m_groupHash.value( idx.row() ) ) + foreach ( int originalRow, m_groupMap.value( idx.row() ) ) { QModelIndex originalIdx = sourceModel()->index( originalRow, 0, m_rootNode.parent() ); @@ -732,7 +732,7 @@ QtGroupingProxy::flags( const QModelIndex &idx ) const } //it's possible to have empty groups - if( m_groupHash.value( idx.row() ).count() == 0 ) + if( m_groupMap.value( idx.row() ).count() == 0 ) { //check the flags of this column with the root node QModelIndex originalRootNode = sourceModel()->index( m_rootNode.row(), m_groupedColumn, @@ -741,7 +741,7 @@ QtGroupingProxy::flags( const QModelIndex &idx ) const } else { - foreach( int originalRow, m_groupHash.value( idx.row() ) ) + foreach( int originalRow, m_groupMap.value( idx.row() ) ) { QModelIndex originalIdx = sourceModel()->index( originalRow, m_groupedColumn, m_rootNode ); @@ -815,7 +815,7 @@ bool QtGroupingProxy::removeGroup( const QModelIndex &idx ) { beginRemoveRows( idx.parent(), idx.row(), idx.row() ); - m_groupHash.remove( idx.row() ); + m_groupMap.remove( idx.row() ); m_groupMaps.removeAt( idx.row() ); m_parentCreateList.removeAt( idx.internalId() ); endRemoveRows(); @@ -832,7 +832,7 @@ QtGroupingProxy::hasChildren( const QModelIndex &parent ) const } if( isGroup( parent ) ) { - return !m_groupHash.value( parent.row() ).isEmpty(); + return !m_groupMap.value( parent.row() ).isEmpty(); } return sourceModel()->hasChildren( mapToSource( parent ) ); @@ -843,7 +843,7 @@ QtGroupingProxy::dropMimeData(const QMimeData *data, Qt::DropAction action, int { QModelIndex idx = index(row, column, parent); if (isGroup(idx)) { - QList childRows = m_groupHash.value(idx.row()); + QList childRows = m_groupMap.value(idx.row()); int max = *std::max_element(childRows.begin(), childRows.end()); QModelIndex newIdx = mapToSource(index(max, column, idx)); @@ -900,12 +900,12 @@ QtGroupingProxy::modelRowsAboutToBeRemoved( const QModelIndex &parent, int start { if( parent == m_rootNode ) { - QHash >::const_iterator i; + QMap >::const_iterator i; //HACK, we are going to call beginRemoveRows() multiple times without // endRemoveRows() if a source index is in multiple groups. // This can be a problem for some views/proxies, but Q*Views can handle it. // TODO: investigate a queue for applying proxy model changes in the correct order - for( i = m_groupHash.constBegin(); i != m_groupHash.constEnd(); ++i ) + for( i = m_groupMap.constBegin(); i != m_groupMap.constEnd(); ++i ) { int groupIndex = i.key(); const QList &groupList = i.value(); @@ -936,7 +936,7 @@ QtGroupingProxy::modelRowsRemoved( const QModelIndex &parent, int start, int end { if( parent == m_rootNode ) { - //TODO: can be optimised by iterating over m_groupHash and checking start <= r < end + //TODO: can be optimised by iterating over m_groupMap and checking start <= r < end //rather than increasing i we change the stored sourceRows in-place and reuse argument start //X-times (where X = end - start). @@ -945,7 +945,7 @@ QtGroupingProxy::modelRowsRemoved( const QModelIndex &parent, int start, int end //HACK: we are going to iterate the hash in reverse so calls to endRemoveRows() // are matched up with the beginRemoveRows() in modelRowsAboutToBeRemoved() //NOTE: easier to do reverse with java style iterator - QMutableHashIterator > iter( m_groupHash ); + QMutableMapIterator > iter( m_groupMap ); iter.toBack(); while( iter.hasPrevious() ) { @@ -1020,19 +1020,19 @@ QtGroupingProxy::dumpGroups() const QString s; QDebug debug(&s); - debug << "m_groupHash:\n"; - for( int groupIndex = -1; groupIndex < m_groupHash.keys().count() - 1; groupIndex++ ) + debug << "m_groupMap:\n"; + for( int groupIndex = -1; groupIndex < m_groupMap.keys().count() - 1; groupIndex++ ) { - debug << groupIndex << " : " << m_groupHash.value( groupIndex ) << "\n"; + debug << groupIndex << " : " << m_groupMap.value( groupIndex ) << "\n"; } debug << "m_groupMaps:\n"; for( int groupIndex = 0; groupIndex < m_groupMaps.count(); groupIndex++ ) { - debug << m_groupMaps[groupIndex] << ": " << m_groupHash.value( groupIndex ) << "\n"; + debug << m_groupMaps[groupIndex] << ": " << m_groupMap.value( groupIndex ) << "\n"; } - debug << m_groupHash.value( std::numeric_limits::max() ); + debug << m_groupMap.value( std::numeric_limits::max() ); log::debug("{}", s); } diff --git a/src/qtgroupingproxy.h b/src/qtgroupingproxy.h index c4459297..c6116d8a 100644 --- a/src/qtgroupingproxy.h +++ b/src/qtgroupingproxy.h @@ -115,7 +115,7 @@ protected: * reordered when rows are inserted or removed. * TODO:use some auto-incrementing container class (steveire's?) for the list */ - QHash > m_groupHash; + QMap > m_groupMap; /** The data cache of the groups. * This can be pre-loaded with data in belongsTo() */ diff --git a/src/settingsdialoggeneral.cpp b/src/settingsdialoggeneral.cpp index b0f40882..48045245 100644 --- a/src/settingsdialoggeneral.cpp +++ b/src/settingsdialoggeneral.cpp @@ -72,7 +72,7 @@ void GeneralSettingsTab::addLanguages() QString::fromStdWString(AppConfig::translationPrefix()) + "_([a-z]{2,3}(_[A-Z]{2,2})?).qm"; - const QRegExp exp(pattern); + const QRegularExpression exp(QRegularExpression::anchoredPattern(pattern)); QDirIterator iter( QCoreApplication::applicationDirPath() + "/translations", @@ -84,11 +84,12 @@ void GeneralSettingsTab::addLanguages() iter.next(); const QString file = iter.fileName(); - if (!exp.exactMatch(file)) { + auto match = exp.match(file); + if (!match.hasMatch()) { continue; } - const QString languageCode = exp.cap(1); + const QString languageCode = match.captured(1); const QLocale locale(languageCode); QString languageString = QString("%1 (%2)") @@ -103,7 +104,7 @@ void GeneralSettingsTab::addLanguages() } } - languages.push_back({languageString, exp.cap(1)}); + languages.push_back({languageString, match.captured(1)}); } if (!ui->languageBox->findText("English")) { diff --git a/src/spawn.cpp b/src/spawn.cpp index fbd4c286..cc8f47bb 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -252,7 +252,7 @@ void helperFailed( const std::wstring& cwd, const std::wstring& args) { SpawnParameters sp; - sp.binary = QString::fromStdWString(binary); + sp.binary = QFileInfo(QString::fromStdWString(binary)); sp.currentDirectory.setPath(QString::fromStdWString(cwd)); sp.arguments = QString::fromStdWString(args); @@ -620,7 +620,7 @@ bool startSteam(QWidget* parent) } SpawnParameters sp; - sp.binary = exe; + sp.binary = QFileInfo(exe); // See if username and password supplied. If so, pass them into steam. QString username, password; @@ -911,7 +911,7 @@ QFileInfo getCmdPath() { const auto p = env::get("COMSPEC"); if (!p.isEmpty()) { - return p; + return QFileInfo(p); } QString systemDirectory; @@ -930,7 +930,7 @@ QFileInfo getCmdPath() systemDirectory = "C:\\Windows\\System32\\"; } - return systemDirectory + "cmd.exe"; + return QFileInfo(systemDirectory + "cmd.exe"); } FileExecutionTypes getFileExecutionType(const QFileInfo& target) diff --git a/src/statusbar.cpp b/src/statusbar.cpp index 39acc32e..094aa743 100644 --- a/src/statusbar.cpp +++ b/src/statusbar.cpp @@ -229,7 +229,7 @@ QString StatusBarAction::cleanupActionText(const QString& original) const { QString s = original; - s.replace(QRegExp("\\&([^&])"), "\\1"); // &Item -> Item + s.replace(QRegularExpression("\\&([^&])"), "\\1"); // &Item -> Item s.replace("&&", "&"); // &&Item -> &Item if (s.endsWith("...")) { diff --git a/src/texteditor.cpp b/src/texteditor.cpp index 4a8080f4..af4c63c8 100644 --- a/src/texteditor.cpp +++ b/src/texteditor.cpp @@ -284,7 +284,7 @@ void TextEditor::resizeEvent(QResizeEvent* e) void TextEditor::paintLineNumbers(QPaintEvent* e, const QColor& textColor) { QStyleOption opt; - opt.init(m_lineNumbers); + opt.initFrom(m_lineNumbers); QPainter painter(m_lineNumbers); -- cgit v1.3.1