Skip to content

Commit

Permalink
Fix compatability errors with Qt < 5.14
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttyartist committed Aug 30, 2024
1 parent 6fb179e commit 18544b2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dbmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2436,7 +2436,11 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens
if (folder.id() != SpecialNodeID::RootFolder) { // Skip root folder
QStringList folderNames;
QString currentPath = folder.absolutePath();
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
QStringList pathParts = currentPath.split(QDir::separator(), Qt::SkipEmptyParts);

Check failure on line 2440 in src/dbmanager.cpp

View workflow job for this annotation

GitHub Actions / Linux / deb (release, Qt 5, ubuntu-20_04)

'SkipEmptyParts' is not a member of 'Qt'
#else
QStringList pathParts = currentPath.split(QDir::separator(), QString::SkipEmptyParts);
#endif
for (const auto &part : pathParts) {
int id = part.toInt();
if (id == SpecialNodeID::RootFolder)
Expand Down Expand Up @@ -2471,7 +2475,9 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens
}

// Export each note as a .txt file in its corresponding directory
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QTextDocument doc;
#endif
while (query.next()) {
// int noteId = query.value(0).toInt();
QString title = query.value(1).toString();
Expand All @@ -2483,8 +2489,12 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens
if (safeTitle.contains("<br />"))
safeTitle = safeTitle.section("<br />", 0, 0, QString::SectionSkipEmpty);
safeTitle = safeTitle.simplified();
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#else
// Convert Markdown to plain text, only available in Qt 5.14+
doc.setMarkdown(safeTitle);
safeTitle = doc.toPlainText();
#endif
safeTitle.replace(QRegularExpression(R"([\/\\:*?"<>|])"),
"_"); // Make the title filesystem-safe
QString filePath = notePath + QDir::separator() + safeTitle + extension;
Expand Down

0 comments on commit 18544b2

Please sign in to comment.