diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-10-26 07:27:47 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-26 19:27:03 -0700 |
commit | ffecc00f42f2e02f76cf616d03d179e8741f4fba (patch) | |
tree | 43cca48ab6f8f64bcf0e6ecfce7164f1ffa32229 | |
parent | f8f83a9986917de1f879abd474330812c4a1e51a (diff) | |
download | subsurface-ffecc00f42f2e02f76cf616d03d179e8741f4fba.tar.gz |
cleanup: SkipEmptyParts syntax has changed
Sadly, the new enum has only been available since Qt 5.14, so this is a rather
ugly replacement.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/filterconstraint.cpp | 12 | ||||
-rw-r--r-- | core/metadata.cpp | 8 | ||||
-rw-r--r-- | core/qthelper.cpp | 8 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 8 | ||||
-rw-r--r-- | desktop-widgets/tagwidget.cpp | 8 | ||||
-rw-r--r-- | qt-models/completionmodels.cpp | 8 |
6 files changed, 44 insertions, 8 deletions
diff --git a/core/filterconstraint.cpp b/core/filterconstraint.cpp index 54654457f..0468a935c 100644 --- a/core/filterconstraint.cpp +++ b/core/filterconstraint.cpp @@ -25,6 +25,12 @@ enum filter_constraint_units { FILTER_CONSTRAINT_PERCENTAGE_UNIT }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +#define SKIP_EMPTY Qt::SkipEmptyParts +#else +#define SKIP_EMPTY QString::SkipEmptyParts +#endif + static struct type_description { filter_constraint_type type; const char *token; // untranslated token, which will be written to the log and should not contain spaces @@ -680,7 +686,7 @@ void filter_constraint_set_stringlist(filter_constraint &c, const QString &s) return; } c.data.string_list->clear(); - for (const QString &s: s.split(",", QString::SkipEmptyParts)) + for (const QString &s: s.split(",", SKIP_EMPTY)) c.data.string_list->push_back(s.trimmed()); } @@ -859,9 +865,9 @@ static bool has_tags(const filter_constraint &c, const struct dive *d) static bool has_people(const filter_constraint &c, const struct dive *d) { QStringList dive_people; - for (const QString &s: QString(d->buddy).split(",", QString::SkipEmptyParts)) + for (const QString &s: QString(d->buddy).split(",", SKIP_EMPTY)) dive_people.push_back(s.trimmed()); - for (const QString &s: QString(d->divemaster).split(",", QString::SkipEmptyParts)) + for (const QString &s: QString(d->divemaster).split(",", SKIP_EMPTY)) dive_people.push_back(s.trimmed()); return check(c, dive_people); } diff --git a/core/metadata.cpp b/core/metadata.cpp index 81371ba3f..bca750b73 100644 --- a/core/metadata.cpp +++ b/core/metadata.cpp @@ -12,6 +12,12 @@ #define UINT64_MAX (~0ULL) #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +#define SKIP_EMPTY Qt::SkipEmptyParts +#else +#define SKIP_EMPTY QString::SkipEmptyParts +#endif + // The following functions fetch an arbitrary-length _unsigned_ integer from either // a file or a memory location in big-endian or little-endian mode. The size of the // integer is passed via a template argument [e.g. getBE<uint16_t>(...)]. @@ -287,7 +293,7 @@ static bool parseDate(const QString &s_in, timestamp_t ×tamp) } // I've also seen "Weekday Mon Day hh:mm:ss yyyy"(!) - QStringList items = s.split(' ', QString::SkipEmptyParts); + QStringList items = s.split(' ', SKIP_EMPTY); if (items.size() < 4) return false; diff --git a/core/qthelper.cpp b/core/qthelper.cpp index d3e225639..1dacbab38 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -1260,9 +1260,15 @@ QString get_taglist_string(struct tag_entry *tag_list) return ret; } +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +#define SKIP_EMPTY Qt::SkipEmptyParts +#else +#define SKIP_EMPTY QString::SkipEmptyParts +#endif + QStringList stringToList(const QString &s) { - QStringList res = s.split(",", QString::SkipEmptyParts); + QStringList res = s.split(",", SKIP_EMPTY); for (QString &str: res) str = str.trimmed(); return res; diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index 943da56c3..135326ecf 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -629,6 +629,12 @@ QString TextHyperlinkEventFilter::tryToFormulateUrl(QTextCursor *cursor) return stringMeetsOurUrlRequirements(maybeUrlStr) ? maybeUrlStr : QString(); } +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +#define SKIP_EMPTY Qt::SkipEmptyParts +#else +#define SKIP_EMPTY QString::SkipEmptyParts +#endif + QString TextHyperlinkEventFilter::fromCursorTilWhitespace(QTextCursor *cursor, bool searchBackwards) { // fromCursorTilWhitespace calls cursor->movePosition repeatedly, while @@ -666,7 +672,7 @@ QString TextHyperlinkEventFilter::fromCursorTilWhitespace(QTextCursor *cursor, b "mn.abcd." for the url (wrong). So we have to go to 'i', to capture "mn.abcd.edu " (with trailing space), and then clean it up. */ - QStringList list = grownText.split(QRegExp("\\s"), QString::SkipEmptyParts); + QStringList list = grownText.split(QRegExp("\\s"), SKIP_EMPTY); if (!list.isEmpty()) { result = list[0]; } diff --git a/desktop-widgets/tagwidget.cpp b/desktop-widgets/tagwidget.cpp index 5327b0a2c..01ddd15be 100644 --- a/desktop-widgets/tagwidget.cpp +++ b/desktop-widgets/tagwidget.cpp @@ -39,6 +39,12 @@ void TagWidget::setCompleter(QCompleter *completer) connect(m_completer, SIGNAL(highlighted(QString)), this, SLOT(completionHighlighted(QString))); } +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +#define SKIP_EMPTY Qt::SkipEmptyParts +#else +#define SKIP_EMPTY QString::SkipEmptyParts +#endif + QPair<int, int> TagWidget::getCursorTagPosition() { int i = 0, start = 0, end = 0; @@ -71,7 +77,7 @@ void TagWidget::highlight() { removeAllBlocks(); int lastPos = 0; - const auto l = text().split(QChar(','), QString::SkipEmptyParts); + const auto l = text().split(QChar(','), SKIP_EMPTY); for (const QString &s: l) { QString trimmed = s.trimmed(); if (trimmed.isEmpty()) diff --git a/qt-models/completionmodels.cpp b/qt-models/completionmodels.cpp index 0ffc8075e..701848384 100644 --- a/qt-models/completionmodels.cpp +++ b/qt-models/completionmodels.cpp @@ -22,6 +22,12 @@ setStringList(list); \ } +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +#define SKIP_EMPTY Qt::SkipEmptyParts +#else +#define SKIP_EMPTY QString::SkipEmptyParts +#endif + #define CREATE_CSV_UPDATE_METHOD(Class, diveStructMember) \ void Class::updateModel() \ { \ @@ -31,7 +37,7 @@ for_each_dive (i, dive) \ { \ QString buddy(dive->diveStructMember); \ - foreach (const QString &value, buddy.split(",", QString::SkipEmptyParts)) \ + foreach (const QString &value, buddy.split(",", SKIP_EMPTY)) \ { \ set.insert(value.trimmed()); \ } \ |