22
22
#include " element_group.hpp"
23
23
#include " ../qtutil/util.hpp"
24
24
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
+
25
36
namespace cvv
26
37
{
27
38
namespace stfl
@@ -162,7 +173,7 @@ template <typename Element> class STFLEngine
162
173
}
163
174
QList<Element> elemList;
164
175
QStringList cmdStrings =
165
- query.split (" #" , QString ::SkipEmptyParts);
176
+ query.split (" #" , Qt ::SkipEmptyParts);
166
177
elemList = executeFilters (elements, cmdStrings);
167
178
elemList = executeSortCmds (elemList, cmdStrings);
168
179
auto groups = executeGroupCmds (elemList, cmdStrings);
@@ -549,7 +560,7 @@ template <typename Element> class STFLEngine
549
560
{
550
561
using namespace std ::placeholders;
551
562
QStringList arr =
552
- cmdString.split (" " , QString ::SkipEmptyParts);
563
+ cmdString.split (" " , Qt ::SkipEmptyParts);
553
564
QString cmd;
554
565
if (arr.empty ())
555
566
{
@@ -570,7 +581,7 @@ template <typename Element> class STFLEngine
570
581
else if (isFilterCSCmd (cmd))
571
582
{
572
583
QStringList arguments = arr.join (" " ).split (
573
- " ," , QString ::SkipEmptyParts);
584
+ " ," , Qt ::SkipEmptyParts);
574
585
std::for_each (arguments.begin (),
575
586
arguments.end (), [](QString &str)
576
587
{ str.replace (" \\ ," , " ," ); });
@@ -609,7 +620,7 @@ template <typename Element> class STFLEngine
609
620
for (QString cmdString : cmdStrings)
610
621
{
611
622
QStringList arr =
612
- cmdString.split (" " , QString ::SkipEmptyParts);
623
+ cmdString.split (" " , Qt ::SkipEmptyParts);
613
624
if (arr.size () < 2 )
614
625
{
615
626
continue ;
@@ -619,7 +630,7 @@ template <typename Element> class STFLEngine
619
630
{
620
631
arr.removeFirst ();
621
632
}
622
- arr = arr.join (" " ).split (" ," , QString ::SkipEmptyParts);
633
+ arr = arr.join (" " ).split (" ," , Qt ::SkipEmptyParts);
623
634
for (QString cmdPart : arr)
624
635
{
625
636
cmdPart = cmdPart.trimmed ();
@@ -647,15 +658,15 @@ template <typename Element> class STFLEngine
647
658
if (sortCmd.second )
648
659
{
649
660
auto sortFunc = sortFuncs[sortCmd.first ];
650
- qStableSort (resList.begin (), resList.end (),
661
+ std::stable_sort (resList.begin (), resList.end (),
651
662
[&](const Element &elem1,
652
663
const Element &elem2)
653
664
{ return sortFunc (elem1, elem2); });
654
665
}
655
666
else
656
667
{
657
668
auto sortFunc = sortFuncs[sortCmd.first ];
658
- qStableSort (resList.begin (), resList.end (),
669
+ std::stable_sort (resList.begin (), resList.end (),
659
670
[&](const Element &elem1,
660
671
const Element &elem2)
661
672
{ return sortFunc (elem2, elem1); });
@@ -675,7 +686,7 @@ template <typename Element> class STFLEngine
675
686
for (QString cmdString : cmdStrings)
676
687
{
677
688
QStringList arr =
678
- cmdString.split (" " , QString ::SkipEmptyParts);
689
+ cmdString.split (" " , Qt ::SkipEmptyParts);
679
690
if (arr.size () < 2 )
680
691
{
681
692
continue ;
@@ -689,7 +700,7 @@ template <typename Element> class STFLEngine
689
700
{
690
701
arr.removeFirst ();
691
702
}
692
- arr = arr.join (" " ).split (" ," , QString ::SkipEmptyParts);
703
+ arr = arr.join (" " ).split (" ," , Qt ::SkipEmptyParts);
693
704
for (QString cmdPart : arr)
694
705
{
695
706
QStringList cmdPartList = cmdPart.split (" " );
@@ -720,7 +731,7 @@ template <typename Element> class STFLEngine
720
731
for (auto it = groups.begin (); it != groups.end (); ++it)
721
732
{
722
733
ElementGroup<Element> elementGroup (
723
- it->first .split (" \\ |" , QString ::SkipEmptyParts),
734
+ it->first .split (" \\ |" , Qt ::SkipEmptyParts),
724
735
it->second );
725
736
groupList.push_back (elementGroup);
726
737
}
@@ -733,7 +744,7 @@ template <typename Element> class STFLEngine
733
744
for (QString cmdString : cmdStrings)
734
745
{
735
746
QStringList arr =
736
- cmdString.split (" " , QString ::SkipEmptyParts);
747
+ cmdString.split (" " , Qt ::SkipEmptyParts);
737
748
if (arr.isEmpty ())
738
749
{
739
750
continue ;
@@ -743,7 +754,7 @@ template <typename Element> class STFLEngine
743
754
{
744
755
continue ;
745
756
}
746
- arr = arr.join (" " ).split (" ," , QString ::SkipEmptyParts);
757
+ arr = arr.join (" " ).split (" ," , Qt ::SkipEmptyParts);
747
758
additionalCommandFuncs[cmd](arr, groups);
748
759
}
749
760
}
@@ -762,11 +773,11 @@ template <typename Element> class STFLEngine
762
773
if (cmd == " group" || cmd == " sort" )
763
774
{
764
775
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)
767
778
.mid (frontCut, tokens.size ());
768
779
QStringList args = tokens.join (" " ).split (
769
- " ," , QString ::SkipEmptyParts);
780
+ " ," , Qt ::SkipEmptyParts);
770
781
args.removeDuplicates ();
771
782
for (auto &arg : args)
772
783
{
@@ -806,7 +817,7 @@ template <typename Element> class STFLEngine
806
817
else
807
818
{
808
819
QStringList args = rejoined.split (
809
- " ," , QString ::SkipEmptyParts);
820
+ " ," , Qt ::SkipEmptyParts);
810
821
if (isFilterCmd (cmd))
811
822
{
812
823
suggs = getSuggestionsForFilterCSCmd (cmd, args);
@@ -902,7 +913,7 @@ template <typename Element> class STFLEngine
902
913
QStringList getSuggestionsForFilterCmd (const QString &cmd,
903
914
const QString &argument)
904
915
{
905
- QStringList pool (filterPool[cmd].toList ());
916
+ QStringList pool (filterPool[cmd].values ());
906
917
return sortStringsByStringEquality (pool, argument);
907
918
}
908
919
@@ -918,7 +929,7 @@ template <typename Element> class STFLEngine
918
929
{
919
930
last = args[args.size () - 1 ];
920
931
}
921
- QStringList pool (filterCSPool[cmd].toList ());
932
+ QStringList pool (filterCSPool[cmd].values ());
922
933
QStringList list = sortStringsByStringEquality (pool, last);
923
934
for (QString &item : list)
924
935
{
@@ -1022,7 +1033,7 @@ template <typename Element> class STFLEngine
1022
1033
void addQueryToStore (QString query)
1023
1034
{
1024
1035
QStringList storedCmds = getStoredCmds ();
1025
- QStringList cmds = query.split (" #" , QString ::SkipEmptyParts);
1036
+ QStringList cmds = query.split (" #" , Qt ::SkipEmptyParts);
1026
1037
cmds.removeDuplicates ();
1027
1038
for (QString cmd : cmds)
1028
1039
{
@@ -1082,12 +1093,12 @@ template <typename Element> class STFLEngine
1082
1093
{
1083
1094
QMap<int , QStringList> weightedStrings;
1084
1095
auto compareWithWords =
1085
- compareWith.split (" " , QString ::SkipEmptyParts);
1096
+ compareWith.split (" " , Qt ::SkipEmptyParts);
1086
1097
for (const QString &str : strings)
1087
1098
{
1088
1099
int strEqu = 0xFFFFFF ; // infinity...
1089
1100
for (auto word :
1090
- str.split (" " , QString ::SkipEmptyParts))
1101
+ str.split (" " , Qt ::SkipEmptyParts))
1091
1102
{
1092
1103
auto wordA = word.leftJustified (15 , ' ' );
1093
1104
for (const auto &word2 : compareWithWords)
0 commit comments