Skip to content

Commit

Permalink
Renovate QString splits with newer enum in Gui
Browse files Browse the repository at this point in the history
  • Loading branch information
YakoYakoYokuYoku committed Dec 14, 2021
1 parent 5a18f12 commit 789599f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Gui/DocumentationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,21 @@ DocumentationManager::handler(QHttpRequest *req,
// get options
QStringList options;
if ( page.contains( QString::fromUtf8("?") ) ) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList split = page.split(QString::fromUtf8("?"), Qt::SkipEmptyParts);
page = split.takeFirst();
if (split.length() > 0) {
QString rawOptions = split.takeLast();
options = rawOptions.split(QString::fromUtf8("&"), Qt::SkipEmptyParts);
}
#else
QStringList split = page.split(QString::fromUtf8("?"), QString::SkipEmptyParts);
page = split.takeFirst();
if (split.length() > 0) {
QString rawOptions = split.takeLast();
options = rawOptions.split(QString::fromUtf8("&"), QString::SkipEmptyParts);
}
#endif
}

// default page
Expand Down Expand Up @@ -368,7 +377,11 @@ DocumentationManager::handler(QHttpRequest *req,
"</div>");
for (int i = 0; i < options.size(); ++i) {
if ( options.at(i).contains( QString::fromUtf8("id=") ) ) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList split = options.at(i).split(QString::fromUtf8("="), Qt::SkipEmptyParts);
#else
QStringList split = options.at(i).split(QString::fromUtf8("="), QString::SkipEmptyParts);
#endif
if (split.length() > 0) {
QString groupID = split.takeLast();
group = groupID;
Expand Down
8 changes: 8 additions & 0 deletions Gui/Gui40.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ Gui::updateRecentFileActions()
// split each dir, and find the common part of all dirs.
std::vector<QStringList> dirParts(dirs.size());
for (int i = 0; i < dirs.size(); ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
dirParts[i] = QDir::toNativeSeparators(dirs.at(i)).split(QDir::separator(), Qt::SkipEmptyParts);
#else
dirParts[i] = QDir::toNativeSeparators(dirs.at(i)).split(QDir::separator(), QString::SkipEmptyParts);
#endif
}
int minComps = dirParts[0].size();
for (int i = 1; i < dirs.size(); ++i) {
Expand All @@ -219,7 +223,11 @@ Gui::updateRecentFileActions()
// remove the n first element to each dirName corresponding to this filename, and recompose
for (int i = 0; i < numRecentFiles; ++i) {
if (fileNames[i] == it->first) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
dirNames[i] = QStringList(QDir::toNativeSeparators(dirNames.at(i)).split(QDir::separator(), Qt::SkipEmptyParts).mid(commonComps)).join(QDir::separator());
#else
dirNames[i] = QStringList(QDir::toNativeSeparators(dirNames.at(i)).split(QDir::separator(), QString::SkipEmptyParts).mid(commonComps)).join(QDir::separator());
#endif
}
}
}
Expand Down

0 comments on commit 789599f

Please sign in to comment.