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>
This commit is contained in:
Dirk Hohndel 2020-10-26 07:27:47 -07:00
parent f8f83a9986
commit ffecc00f42
6 changed files with 44 additions and 8 deletions

View file

@ -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);
}

View file

@ -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 &timestamp)
}
// 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;

View file

@ -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;