File indexing completed on 2024-05-05 03:53:33

0001 #include <QString>
0002 #include <ksortablelist.h>
0003 
0004 int main(int /*argc*/, char ** /*argv*/)
0005 {
0006     KSortableList<QString> list;
0007     list.insert(1, QStringLiteral("FOO           (1)"));
0008     list.insert(2, QStringLiteral("Test          (2)"));
0009     list.insert(1, QStringLiteral("Huba!         (1)"));
0010     list.insert(5, QStringLiteral("MAAOOAM!      (5)"));
0011     list.insert(10, QStringLiteral("Teeheeest    (10)"));
0012     list.insert(2, QStringLiteral("I was here :) (2)"));
0013     list.insert(4, QStringLiteral("Yeehaa...     (4)"));
0014 
0015     QList<KSortableItem<QString>>::iterator it = list.begin();
0016 
0017     qDebug("Insertion order:");
0018     qDebug("================");
0019     for (; it != list.end(); ++it) {
0020         qDebug("%i: %s", (*it).key(), (*it).value().toLatin1().constData());
0021     }
0022 
0023     list.sort();
0024 
0025     qDebug("\nSorted:");
0026     qDebug("=======");
0027 
0028     it = list.begin();
0029     for (; it != list.end(); ++it) {
0030         qDebug("%i: %s", (*it).key(), (*it).value().toLatin1().constData());
0031     }
0032 
0033     return 0;
0034 }