* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest.h>
+#include <QTest>
#include <QSignalSpy>
+
+#include <algorithm>
+#include <random>
+
#include "kitemviews/kfileitemmodel.h"
#include "kitemviews/private/kfileitemmodelsortalgorithm.h"
#include "testdir.h"
-#include <KRandomSequence>
-
-void myMessageOutput(QtMsgType type, const char* msg)
+void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
+ Q_UNUSED(context);
+
switch (type) {
case QtDebugMsg:
break;
case QtWarningMsg:
break;
case QtCriticalMsg:
- fprintf(stderr, "Critical: %s\n", msg);
+ fprintf(stderr, "Critical: %s\n", msg.toLocal8Bit().data());
break;
case QtFatalMsg:
- fprintf(stderr, "Fatal: %s\n", msg);
+ fprintf(stderr, "Fatal: %s\n", msg.toLocal8Bit().data());
abort();
default:
break;
}
}
-namespace {
- const int DefaultTimeout = 5000;
-};
-
Q_DECLARE_METATYPE(KFileItemList)
Q_DECLARE_METATYPE(KItemRangeList)
// Avoid overhead caused by natural sorting
// and determining the isDir/isLink roles.
model.m_naturalSorting = false;
- model.setRoles(QSet<QByteArray>() << "text");
+ model.setRoles({"text"});
QSignalSpy spyItemsInserted(&model, SIGNAL(itemsInserted(KItemRangeList)));
QSignalSpy spyItemsRemoved(&model, SIGNAL(itemsRemoved(KItemRangeList)));
}
// Bring the items into random order.
- KRandomSequence randomSequence(0);
- randomSequence.randomize(newItems);
+ std::random_device rd;
+ std::mt19937 g(rd());
+ std::shuffle(newItems.begin(), newItems.end(), g);
// Measure how long it takes to insert and then remove all files.
QBENCHMARK {
KFileItemList KFileItemModelBenchmark::createFileItemList(const QStringList& fileNames, const QString& prefix)
{
// Suppress 'file does not exist anymore' messages from KFileItemPrivate::init().
- qInstallMsgHandler(myMessageOutput);
+ qInstallMessageHandler(myMessageOutput);
KFileItemList result;
foreach (const QString& name, fileNames) {