2222#include " element_group.hpp"
2323#include " ../qtutil/util.hpp"
2424
25+
26+ // WORKAROUND:
27+ // - Qt::SplitBehavior introduced in 5.14, QString::SplitBehavior was removed in Qt6
28+ // - Support required part of Qt::SplitBehavior from 5.15 for older Qt versions
29+ #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
30+ namespace Qt {
31+ static constexpr QString::SplitBehavior SkipEmptyParts = QString::SkipEmptyParts;
32+ }
33+ #endif
34+
35+
2536namespace cvv
2637{
2738namespace stfl
@@ -162,7 +173,7 @@ template <typename Element> class STFLEngine
162173 }
163174 QList<Element> elemList;
164175 QStringList cmdStrings =
165- query.split (" #" , QString ::SkipEmptyParts);
176+ query.split (" #" , Qt ::SkipEmptyParts);
166177 elemList = executeFilters (elements, cmdStrings);
167178 elemList = executeSortCmds (elemList, cmdStrings);
168179 auto groups = executeGroupCmds (elemList, cmdStrings);
@@ -549,7 +560,7 @@ template <typename Element> class STFLEngine
549560 {
550561 using namespace std ::placeholders;
551562 QStringList arr =
552- cmdString.split (" " , QString ::SkipEmptyParts);
563+ cmdString.split (" " , Qt ::SkipEmptyParts);
553564 QString cmd;
554565 if (arr.empty ())
555566 {
@@ -570,7 +581,7 @@ template <typename Element> class STFLEngine
570581 else if (isFilterCSCmd (cmd))
571582 {
572583 QStringList arguments = arr.join (" " ).split (
573- " ," , QString ::SkipEmptyParts);
584+ " ," , Qt ::SkipEmptyParts);
574585 std::for_each (arguments.begin (),
575586 arguments.end (), [](QString &str)
576587 { str.replace (" \\ ," , " ," ); });
@@ -609,7 +620,7 @@ template <typename Element> class STFLEngine
609620 for (QString cmdString : cmdStrings)
610621 {
611622 QStringList arr =
612- cmdString.split (" " , QString ::SkipEmptyParts);
623+ cmdString.split (" " , Qt ::SkipEmptyParts);
613624 if (arr.size () < 2 )
614625 {
615626 continue ;
@@ -619,7 +630,7 @@ template <typename Element> class STFLEngine
619630 {
620631 arr.removeFirst ();
621632 }
622- arr = arr.join (" " ).split (" ," , QString ::SkipEmptyParts);
633+ arr = arr.join (" " ).split (" ," , Qt ::SkipEmptyParts);
623634 for (QString cmdPart : arr)
624635 {
625636 cmdPart = cmdPart.trimmed ();
@@ -647,15 +658,15 @@ template <typename Element> class STFLEngine
647658 if (sortCmd.second )
648659 {
649660 auto sortFunc = sortFuncs[sortCmd.first ];
650- qStableSort (resList.begin (), resList.end (),
661+ std::stable_sort (resList.begin (), resList.end (),
651662 [&](const Element &elem1,
652663 const Element &elem2)
653664 { return sortFunc (elem1, elem2); });
654665 }
655666 else
656667 {
657668 auto sortFunc = sortFuncs[sortCmd.first ];
658- qStableSort (resList.begin (), resList.end (),
669+ std::stable_sort (resList.begin (), resList.end (),
659670 [&](const Element &elem1,
660671 const Element &elem2)
661672 { return sortFunc (elem2, elem1); });
@@ -675,7 +686,7 @@ template <typename Element> class STFLEngine
675686 for (QString cmdString : cmdStrings)
676687 {
677688 QStringList arr =
678- cmdString.split (" " , QString ::SkipEmptyParts);
689+ cmdString.split (" " , Qt ::SkipEmptyParts);
679690 if (arr.size () < 2 )
680691 {
681692 continue ;
@@ -689,7 +700,7 @@ template <typename Element> class STFLEngine
689700 {
690701 arr.removeFirst ();
691702 }
692- arr = arr.join (" " ).split (" ," , QString ::SkipEmptyParts);
703+ arr = arr.join (" " ).split (" ," , Qt ::SkipEmptyParts);
693704 for (QString cmdPart : arr)
694705 {
695706 QStringList cmdPartList = cmdPart.split (" " );
@@ -720,7 +731,7 @@ template <typename Element> class STFLEngine
720731 for (auto it = groups.begin (); it != groups.end (); ++it)
721732 {
722733 ElementGroup<Element> elementGroup (
723- it->first .split (" \\ |" , QString ::SkipEmptyParts),
734+ it->first .split (" \\ |" , Qt ::SkipEmptyParts),
724735 it->second );
725736 groupList.push_back (elementGroup);
726737 }
@@ -733,7 +744,7 @@ template <typename Element> class STFLEngine
733744 for (QString cmdString : cmdStrings)
734745 {
735746 QStringList arr =
736- cmdString.split (" " , QString ::SkipEmptyParts);
747+ cmdString.split (" " , Qt ::SkipEmptyParts);
737748 if (arr.isEmpty ())
738749 {
739750 continue ;
@@ -743,7 +754,7 @@ template <typename Element> class STFLEngine
743754 {
744755 continue ;
745756 }
746- arr = arr.join (" " ).split (" ," , QString ::SkipEmptyParts);
757+ arr = arr.join (" " ).split (" ," , Qt ::SkipEmptyParts);
747758 additionalCommandFuncs[cmd](arr, groups);
748759 }
749760 }
@@ -762,11 +773,11 @@ template <typename Element> class STFLEngine
762773 if (cmd == " group" || cmd == " sort" )
763774 {
764775 int frontCut =
765- std::min (1 + (hasByString ? 1 : 0 ), tokens.size ());
766- tokens = cmdQuery.split (" " , QString ::SkipEmptyParts)
776+ std::min (size_t (hasByString ? 2 : 1 ), size_t ( tokens.size () ));
777+ tokens = cmdQuery.split (" " , Qt ::SkipEmptyParts)
767778 .mid (frontCut, tokens.size ());
768779 QStringList args = tokens.join (" " ).split (
769- " ," , QString ::SkipEmptyParts);
780+ " ," , Qt ::SkipEmptyParts);
770781 args.removeDuplicates ();
771782 for (auto &arg : args)
772783 {
@@ -806,7 +817,7 @@ template <typename Element> class STFLEngine
806817 else
807818 {
808819 QStringList args = rejoined.split (
809- " ," , QString ::SkipEmptyParts);
820+ " ," , Qt ::SkipEmptyParts);
810821 if (isFilterCmd (cmd))
811822 {
812823 suggs = getSuggestionsForFilterCSCmd (cmd, args);
@@ -902,7 +913,7 @@ template <typename Element> class STFLEngine
902913 QStringList getSuggestionsForFilterCmd (const QString &cmd,
903914 const QString &argument)
904915 {
905- QStringList pool (filterPool[cmd].toList ());
916+ QStringList pool (filterPool[cmd].values ());
906917 return sortStringsByStringEquality (pool, argument);
907918 }
908919
@@ -918,7 +929,7 @@ template <typename Element> class STFLEngine
918929 {
919930 last = args[args.size () - 1 ];
920931 }
921- QStringList pool (filterCSPool[cmd].toList ());
932+ QStringList pool (filterCSPool[cmd].values ());
922933 QStringList list = sortStringsByStringEquality (pool, last);
923934 for (QString &item : list)
924935 {
@@ -1022,7 +1033,7 @@ template <typename Element> class STFLEngine
10221033 void addQueryToStore (QString query)
10231034 {
10241035 QStringList storedCmds = getStoredCmds ();
1025- QStringList cmds = query.split (" #" , QString ::SkipEmptyParts);
1036+ QStringList cmds = query.split (" #" , Qt ::SkipEmptyParts);
10261037 cmds.removeDuplicates ();
10271038 for (QString cmd : cmds)
10281039 {
@@ -1082,12 +1093,12 @@ template <typename Element> class STFLEngine
10821093 {
10831094 QMap<int , QStringList> weightedStrings;
10841095 auto compareWithWords =
1085- compareWith.split (" " , QString ::SkipEmptyParts);
1096+ compareWith.split (" " , Qt ::SkipEmptyParts);
10861097 for (const QString &str : strings)
10871098 {
10881099 int strEqu = 0xFFFFFF ; // infinity...
10891100 for (auto word :
1090- str.split (" " , QString ::SkipEmptyParts))
1101+ str.split (" " , Qt ::SkipEmptyParts))
10911102 {
10921103 auto wordA = word.leftJustified (15 , ' ' );
10931104 for (const auto &word2 : compareWithWords)
0 commit comments