Commit 280a47d9 authored by Anjani Kumar's avatar Anjani Kumar
Browse files

Define and use macros for Qt::SplitBehavior in QString::split() calls

parent 26a7e880
......@@ -63,6 +63,18 @@ class QKeySequence;
#define QT_ENDL endl
#endif
/**
* Macro for Qt::KeepEmptyParts and Qt::SkipEmptyParts which were introduced in Qt 5.14.0
* to be used with QString::split()
*/
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
#define QT_KEEP_EMPTY_PARTS Qt::KeepEmptyParts
#define QT_SKIP_EMPTY_PARTS Qt::SkipEmptyParts
#else
#define QT_KEEP_EMPTY_PARTS QString::KeepEmptyParts
#define QT_SKIP_EMPTY_PARTS QString::SkipEmptyParts
#endif
namespace Digikam
{
......
......@@ -50,6 +50,7 @@
// Local includes
#include "digikam_debug.h"
#include "digikam_globals.h"
#include "abstractthemeparameter.h"
#include "galleryelement.h"
#include "galleryelementfunctor.h"
......@@ -532,15 +533,8 @@ public:
{
// Forth case: both apos and quote :-(
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
const QStringList lst = txt.split(QLatin1Char(apos), QT_KEEP_EMPTY_PARTS);
const QStringList lst = txt.split(QLatin1Char(apos), Qt::KeepEmptyParts);
#else
const QStringList lst = txt.split(QLatin1Char(apos), QString::KeepEmptyParts);
#endif
QStringList::ConstIterator it = lst.constBegin();
QStringList::ConstIterator end = lst.constEnd();
param = QLatin1String("concat(");
......
......@@ -562,15 +562,7 @@ void FlickrListViewItem::updateItemWidgets()
QStringList FlickrListViewItem::extraTags() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return d->tagLineEdit->text().split(QLatin1Char(','), Qt::SkipEmptyParts);
#else
return d->tagLineEdit->text().split(QLatin1Char(','), QString::SkipEmptyParts);
#endif
return d->tagLineEdit->text().split(QLatin1Char(','), QT_SKIP_EMPTY_PARTS);
}
void FlickrListViewItem::toggled()
......
......@@ -406,15 +406,7 @@ void FlickrTalker::getPhotoProperty(const QString& method, const QStringList& ar
for (QStringList::const_iterator it = argList.constBegin(); it != argList.constEnd(); ++it)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList str = (*it).split(QLatin1Char('='), Qt::SkipEmptyParts);
#else
QStringList str = (*it).split(QLatin1Char('='), QString::SkipEmptyParts);
#endif
QStringList str = (*it).split(QLatin1Char('='), QT_SKIP_EMPTY_PARTS);
reqParams << O0RequestParameter(str[0].toLatin1(), str[1].toLatin1());
}
......
......@@ -683,15 +683,7 @@ void FlickrWindow::slotUser1()
temp.is_friend = lvItem->isFriends() ? 1 : 0;
temp.safety_level = lvItem->safetyLevel();
temp.content_type = lvItem->contentType();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList tagsFromDialog = d->tagsLineEdit->text().split(QLatin1Char(','), Qt::SkipEmptyParts);
#else
QStringList tagsFromDialog = d->tagsLineEdit->text().split(QLatin1Char(','), QString::SkipEmptyParts);
#endif
QStringList tagsFromDialog = d->tagsLineEdit->text().split(QLatin1Char(','), QT_SKIP_EMPTY_PARTS);
QStringList tagsFromList = lvItem->extraTags();
QStringList allTags;
......
......@@ -382,15 +382,7 @@ void ImageShackWindow::uploadNextItem()
{
QString str = d->widget->d->tagsFld->text();
QStringList tagsList;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
tagsList = str.split(QRegExp(QLatin1String("\\W+")), Qt::SkipEmptyParts);
#else
tagsList = str.split(QRegExp(QLatin1String("\\W+")), QString::SkipEmptyParts);
#endif
tagsList = str.split(QRegExp(QLatin1String("\\W+")), QT_SKIP_EMPTY_PARTS);
opts[QLatin1String("tags")] = tagsList.join(QLatin1Char(','));
}
......
......@@ -46,6 +46,7 @@
// Local includes
#include "digikam_debug.h"
#include "digikam_globals.h"
namespace DigikamGenericMediaWikiPlugin
{
......@@ -242,15 +243,7 @@ QString MediaWikiTalker::buildWikiText(const QMap<QString, QString>& info) const
if (!info[QLatin1String("categories")].isEmpty())
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
categories = info[QLatin1String("categories")].split(QLatin1Char('\n'), Qt::SkipEmptyParts);
#else
categories = info[QLatin1String("categories")].split(QLatin1Char('\n'), QString::SkipEmptyParts);
#endif
categories = info[QLatin1String("categories")].split(QLatin1Char('\n'), QT_SKIP_EMPTY_PARTS);
for (int i = 0 ; i < categories.size() ; ++i)
{
......@@ -260,15 +253,8 @@ QString MediaWikiTalker::buildWikiText(const QMap<QString, QString>& info) const
if (!info[QLatin1String("genCategories")].isEmpty())
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
categories = info[QLatin1String("genCategories")].split(QLatin1Char('\n'), Qt::SkipEmptyParts);
#else
categories = info[QLatin1String("genCategories")].split(QLatin1Char('\n'), QString::SkipEmptyParts);
categories = info[QLatin1String("genCategories")].split(QLatin1Char('\n'), QT_SKIP_EMPTY_PARTS);
#endif
for (int i = 0 ; i < categories.size() ; ++i)
{
text.append(QLatin1String("[[Category:")).append(categories[i]).append(QLatin1String("]]\n"));
......
......@@ -933,14 +933,7 @@ void MediaWikiWidget::slotApplyTitle()
// If there is at least one #, replace it the correct number
if (minLength > 0)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
parts = imageTitle.split(QLatin1Char('#'), Qt::KeepEmptyParts);
#else
parts = imageTitle.split(QLatin1Char('#'), QString::KeepEmptyParts);
#endif
parts = imageTitle.split(QLatin1Char('#'), QT_KEEP_EMPTY_PARTS);
imageTitle = parts.first().append(QLatin1Char('#')).append(parts.last());
number = QString::number(i + 1);
......
......@@ -275,15 +275,8 @@ void DarkTableRawImportPlugin::slotProcessFinished(int code, QProcess::ExitStatu
void DarkTableRawImportPlugin::slotProcessReadyRead()
{
QByteArray data = d->darktable->readAllStandardError();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), QT_SKIP_EMPTY_PARTS);
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), Qt::SkipEmptyParts);
#else
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), QString::SkipEmptyParts);
#endif
foreach (const QString& one, lines)
{
qCDebug(DIGIKAM_GENERAL_LOG) << "DarkTable ::" << one;
......
......@@ -220,15 +220,8 @@ void RawTherapeeRawImportPlugin::slotProcessFinished(int code, QProcess::ExitSta
void RawTherapeeRawImportPlugin::slotProcessReadyRead()
{
QByteArray data = d->rawtherapee->readAllStandardError();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), QT_SKIP_EMPTY_PARTS);
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), Qt::SkipEmptyParts);
#else
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), QString::SkipEmptyParts);
#endif
foreach (const QString& one, lines)
{
qCDebug(DIGIKAM_GENERAL_LOG) << "RawTherapee ::" << one;
......
......@@ -214,15 +214,8 @@ void UFRawRawImportPlugin::slotProcessFinished(int code, QProcess::ExitStatus st
void UFRawRawImportPlugin::slotProcessReadyRead()
{
QByteArray data = d->ufraw->readAllStandardError();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), QT_SKIP_EMPTY_PARTS);
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), Qt::SkipEmptyParts);
#else
QStringList lines = QString::fromUtf8(data).split(QLatin1Char('\n'), QString::SkipEmptyParts);
#endif
foreach (const QString& one, lines)
{
qCDebug(DIGIKAM_GENERAL_LOG) << "UFRaw ::" << one;
......
......@@ -868,18 +868,8 @@ static QStringList joinMainAndUserFilterString(const QChar& sep, const QString&
QStringList filterList;
QStringList userFilterList;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
filterList = filter.split(sep, Qt::SkipEmptyParts);
userFilterList = userFilter.split(sep, Qt::SkipEmptyParts);
#else
filterList = filter.split(sep, QString::SkipEmptyParts);
userFilterList = userFilter.split(sep, QString::SkipEmptyParts);
#endif
filterList = filter.split(sep, QT_SKIP_EMPTY_PARTS);
userFilterList = userFilter.split(sep, QT_SKIP_EMPTY_PARTS);
foreach (const QString& userFormat, userFilterList)
{
......
......@@ -29,6 +29,10 @@
#include <QStringList>
// Local includes
#include "digikam_globals.h"
namespace Digikam
{
......@@ -47,16 +51,7 @@ CoreDbNameFilter::CoreDbNameFilter(const QString& filter)
sep = QLatin1Char(' ');
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList list = filter.split(sep, Qt::SkipEmptyParts);
#else
QStringList list = filter.split(sep, QString::SkipEmptyParts);
#endif
QStringList list = filter.split(sep, QT_SKIP_EMPTY_PARTS);
QStringList::const_iterator it = list.constBegin();
while ( it != list.constEnd() )
......
......@@ -51,6 +51,7 @@
#include "itemquerybuilder.h"
#include "collectionscannerobserver.h"
#include "digikam_config.h"
#include "digikam_globals.h"
namespace Digikam
{
......@@ -857,15 +858,7 @@ static QStringList cleanUserFilterString(const QString& filterString)
sep = QChar(QLatin1Char(' '));
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sepList = filterString.split(sep, Qt::SkipEmptyParts);
#else
QStringList sepList = filterString.split(sep, QString::SkipEmptyParts);
#endif
QStringList sepList = filterString.split(sep, QT_SKIP_EMPTY_PARTS);
foreach (const QString& f, sepList)
{
......
......@@ -24,6 +24,10 @@
#include "coredbsearchxml.h"
// Local includes
#include "digikam_globals.h"
namespace Digikam
{
......@@ -830,15 +834,8 @@ QString SearchXmlWriter::keywordSearch(const QString& keyword)
QStringList KeywordSearch::split(const QString& keywords)
{
// get groups with quotation marks
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList quotationMarkList = keywords.split(QLatin1Char('"'), Qt::KeepEmptyParts);
#else
QStringList quotationMarkList = keywords.split(QLatin1Char('"'), QT_KEEP_EMPTY_PARTS);
QStringList quotationMarkList = keywords.split(QLatin1Char('"'), QString::KeepEmptyParts);
#endif
// split down to single words
QStringList keywordList;
int quotationMarkCount = (keywords.startsWith(QLatin1Char('"')) ? 1 : 0);
......@@ -856,14 +853,7 @@ QStringList KeywordSearch::split(const QString& keywords)
else
{
// not in quotation marks: split by whitespace
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
keywordList << group.split(QRegExp(QLatin1String("\\s+")), Qt::SkipEmptyParts);
#else
keywordList << group.split(QRegExp(QLatin1String("\\s+")), QString::SkipEmptyParts);
#endif
keywordList << group.split(QRegExp(QLatin1String("\\s+")), QT_SKIP_EMPTY_PARTS);
}
++quotationMarkCount;
......
......@@ -33,6 +33,7 @@
#include "collectionmanager.h"
#include "collectionlocation.h"
#include "digikam_debug.h"
#include "digikam_globals.h"
namespace Digikam
{
......@@ -362,15 +363,8 @@ int CoreDbUrl::tagId() const
QList<int> CoreDbUrl::tagIds() const
{
QList<int> ids;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList stringIds = path().split(QLatin1Char('/'), QT_SKIP_EMPTY_PARTS);
QStringList stringIds = path().split(QLatin1Char('/'), Qt::SkipEmptyParts);
#else
QStringList stringIds = path().split(QLatin1Char('/'), QString::SkipEmptyParts);
#endif
for (int i=0; i<stringIds.count(); ++i)
{
ids << stringIds.at(i).toInt();
......
......@@ -173,14 +173,7 @@ QStringList ItemExtendedProperties::readFakeListProperty(const QString& property
{
QString value = CoreDbAccess().db()->getImageProperty(m_id, property);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return value.split(QLatin1Char(';'), Qt::SkipEmptyParts);
#else
return value.split(QLatin1Char(';'), QString::SkipEmptyParts);
#endif
return value.split(QLatin1Char(';'), QT_SKIP_EMPTY_PARTS);
}
void ItemExtendedProperties::setFakeListProperty(const QString& property, const QStringList& value)
......
......@@ -25,6 +25,10 @@
#include "itemquerybuilder_p.h"
// Local includes
#include "digikam_globals.h"
namespace Digikam
{
......@@ -456,14 +460,7 @@ bool ItemQueryBuilder::buildField(QString& sql, SearchXmlCachingReader& reader,
if (readerString.contains(QRegExp(QLatin1String("^\\d+:\\d+$"))))
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList ratioNum = readerString.split(QLatin1Char(':'), Qt::SkipEmptyParts);
#else
QStringList ratioNum = readerString.split(QLatin1Char(':'), QString::SkipEmptyParts);
#endif
QStringList ratioNum = readerString.split(QLatin1Char(':'), QT_SKIP_EMPTY_PARTS);
int num = ratioNum.at(0).toInt();
int denominator = ratioNum.at(1).toInt();
query = QString::fromUtf8("ABS((ImageInformation.width/CAST(ImageInformation.height AS DOUBLE)) - ?) < 0.1");
......@@ -517,14 +514,7 @@ bool ItemQueryBuilder::buildField(QString& sql, SearchXmlCachingReader& reader,
if (value.contains(QLatin1Char(':')))
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList ratioNum = value.split(QLatin1Char(':'), Qt::SkipEmptyParts);
#else
QStringList ratioNum = value.split(QLatin1Char(':'), QString::SkipEmptyParts);
#endif
QStringList ratioNum = value.split(QLatin1Char(':'), QT_SKIP_EMPTY_PARTS);
int num = ratioNum.at(0).toInt();
int denominator = ratioNum.at(1).toInt();
ratioValues << (double)num/denominator;
......@@ -551,15 +541,7 @@ bool ItemQueryBuilder::buildField(QString& sql, SearchXmlCachingReader& reader,
if (value.contains(QLatin1Char(':')))
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList ratioNum = value.split(QLatin1Char(':'), Qt::SkipEmptyParts);
#else
QStringList ratioNum = value.split(QLatin1Char(':'), QString::SkipEmptyParts);
#endif
QStringList ratioNum = value.split(QLatin1Char(':'), QT_SKIP_EMPTY_PARTS);
int num = ratioNum.at(0).toInt();
int denominator = ratioNum.at(1).toInt();
*boundValues << (double)num/denominator;
......@@ -1268,15 +1250,8 @@ QString ItemQueryBuilder::convertFromUrlToXml(const QUrl& url) const
writer.writeAttribute(QLatin1String("convertedFrom09Url"), QLatin1String("true"));
writer.writeGroup();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList strList = url.path().split(QLatin1Char(' '), Qt::SkipEmptyParts);
#else
QStringList strList = url.path().split(QLatin1Char(' '), QT_SKIP_EMPTY_PARTS);
QStringList strList = url.path().split(QLatin1Char(' '), QString::SkipEmptyParts);
#endif
for (QStringList::const_iterator it = strList.constBegin() ; it != strList.constEnd() ; ++it)
{
bool ok;
......@@ -1435,15 +1410,8 @@ QString ItemQueryBuilder::buildQueryFromUrl(const QUrl& url, QList<QVariant>* bo
QString sqlQuery;
SubQueryBuilder subQuery;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList strList = url.path().split(QLatin1Char(' '), Qt::SkipEmptyParts);
#else
QStringList strList = url.path().split(QLatin1Char(' '), QString::SkipEmptyParts);
QStringList strList = url.path().split(QLatin1Char(' '), QT_SKIP_EMPTY_PARTS);
#endif
for (QStringList::const_iterator it = strList.constBegin() ; it != strList.constEnd() ; ++it)
{
bool ok;
......
......@@ -711,14 +711,8 @@ bool ItemFilterSettings::matches(const ItemInfo& info, bool* const foundText) co
if ((expRatio.indexIn(m_textFilterSettings.text) > -1) && m_textFilterSettings.text.contains(QRegExp(QLatin1String(":\\d+"))))
{
QString trimmedTextFilterSettingsText = m_textFilterSettings.text;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList numberStringList = trimmedTextFilterSettingsText.split(QLatin1Char(':'), QT_SKIP_EMPTY_PARTS);
QStringList numberStringList = trimmedTextFilterSettingsText.split(QLatin1Char(':'), Qt::SkipEmptyParts);
#else
QStringList numberStringList = trimmedTextFilterSettingsText.split(QLatin1Char(':'), QString::SkipEmptyParts);
#endif
if (numberStringList.length() == 2)
{
QString numString = (QString)numberStringList.at(0), denomString = (QString)numberStringList.at(1);
......
......@@ -537,15 +537,8 @@ int TagsCache::tagForPath(const QString& tagPath) const
{
// split full tag "url" into list of single tag names
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList tagHierarchy = tagPath.split(QLatin1Char('/'), QT_SKIP_EMPTY_PARTS);
QStringList tagHierarchy = tagPath.split(QLatin1Char('/'), Qt::SkipEmptyParts);
#else
QStringList tagHierarchy = tagPath.split(QLatin1Char('/'), QString::SkipEmptyParts);
#endif
if (tagHierarchy.isEmpty())
{
return 0;
......@@ -634,15 +627,8 @@ int TagsCache::createTag(const QString& tagPathToCreate)
{
// split full tag "url" into list of single tag names
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList tagHierarchy = tagPathToCreate.split(QLatin1Char('/'), Qt::SkipEmptyParts);
#else
QStringList tagHierarchy = tagPathToCreate.split(QLatin1Char('/'), QString::SkipEmptyParts);
QStringList tagHierarchy = tagPathToCreate.split(QLatin1Char('/'), QT_SKIP_EMPTY_PARTS);
#endif
if (tagHierarchy.isEmpty())
{
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment