Commit f6e008cb authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use std::chrono_literals

parent db5f99e1
......@@ -10,6 +10,7 @@
#include "itemfetchjob.h"
#include <QTimer>
using namespace std::chrono_literals;
FakeServerData::FakeServerData(EntityTreeModel *model, FakeSession *session, FakeMonitor *monitor, QObject *parent)
: QObject(parent)
......@@ -24,7 +25,7 @@ FakeServerData::FakeServerData(EntityTreeModel *model, FakeSession *session, Fak
// the slot gets called
connect(session, &FakeSession::jobAdded, [this](Akonadi::Job *job) {
Collection::Id fetchColId = job->property("FetchCollectionId").toULongLong();
QTimer::singleShot(0, [this, fetchColId]() {
QTimer::singleShot(0s, [this, fetchColId]() {
jobAdded(fetchColId);
});
});
......@@ -40,7 +41,7 @@ FakeServerData::FakeServerData(TagModel *model, FakeSession *session, FakeMonito
, m_nextTagId(1)
{
connect(session, &FakeSession::jobAdded, [this](Akonadi::Job * /*unused*/) {
QTimer::singleShot(0, [this]() {
QTimer::singleShot(0s, [this]() {
jobAdded();
});
});
......
......@@ -11,7 +11,7 @@
#include <QCoreApplication>
#include <QTimer>
using namespace std::chrono_literals;
class FakeSessionPrivate : public SessionPrivate
{
public:
......@@ -48,7 +48,7 @@ public:
}
// Like Session does: delay the actual disconnect+reconnect
QTimer::singleShot(10, q_ptr, [&]() {
QTimer::singleShot(10ms, q_ptr, [&]() {
socketDisconnected();
Q_EMIT q_ptr->reconnected();
connected = true;
......
......@@ -5,7 +5,7 @@
*/
#include "inspectablechangerecorder.h"
using namespace std::chrono_literals;
InspectableChangeRecorderPrivate::InspectableChangeRecorderPrivate(FakeMonitorDependenciesFactory *dependenciesFactory, InspectableChangeRecorder *parent)
: ChangeRecorderPrivate(dependenciesFactory, parent)
{
......@@ -14,7 +14,7 @@ InspectableChangeRecorderPrivate::InspectableChangeRecorderPrivate(FakeMonitorDe
InspectableChangeRecorder::InspectableChangeRecorder(FakeMonitorDependenciesFactory *dependenciesFactory, QObject *parent)
: ChangeRecorder(new Akonadi::ChangeRecorderPrivate(dependenciesFactory, this), parent)
{
QTimer::singleShot(0, this, &InspectableChangeRecorder::doConnectToNotificationManager);
QTimer::singleShot(0s, this, &InspectableChangeRecorder::doConnectToNotificationManager);
}
void InspectableChangeRecorder::doConnectToNotificationManager()
......
......@@ -5,7 +5,7 @@
*/
#include "inspectablemonitor.h"
using namespace std::chrono_literals;
InspectableMonitorPrivate::InspectableMonitorPrivate(FakeMonitorDependenciesFactory *dependenciesFactory, InspectableMonitor *parent)
: Akonadi::MonitorPrivate(dependenciesFactory, parent)
{
......@@ -36,7 +36,7 @@ InspectableMonitor::InspectableMonitor(FakeMonitorDependenciesFactory *dependenc
connect(this, &Akonadi::Monitor::collectionSubscribed, this, &InspectableMonitor::dummySignal);
connect(this, &Akonadi::Monitor::collectionUnsubscribed, this, &InspectableMonitor::dummySignal);
QTimer::singleShot(0, this, [this]() {
QTimer::singleShot(0s, this, [this]() {
doConnectToNotificationManager();
});
}
......@@ -29,7 +29,7 @@ using namespace Akonadi;
Q_DECLARE_METATYPE(KJob *)
Q_DECLARE_METATYPE(ItemSync::TransactionMode)
using namespace std::chrono_literals;
class ItemsyncTest : public QObject
{
Q_OBJECT
......@@ -679,7 +679,7 @@ private Q_SLOTS:
syncer->setFullSyncItems(origItems);
// When the user cancels the ItemSync
QTimer::singleShot(10, syncer, &ItemSync::rollback);
QTimer::singleShot(10ms, syncer, &ItemSync::rollback);
// Then the itemsync should finish at some point, and not crash
QVERIFY(!syncer->exec());
......
......@@ -24,6 +24,9 @@
#include <QFile>
#include <QSettings>
#include <QTimer>
#include <chrono>
using namespace std::chrono_literals;
bool SetupTest::startAkonadiDaemon()
{
......@@ -323,7 +326,7 @@ void SetupTest::shutdown()
qCInfo(AKONADITEST_LOG) << "Shutting down Akonadi control...";
Akonadi::ServerManager::self()->stop();
// safety timeout
QTimer::singleShot(30 * 1000, this, &SetupTest::shutdownHarder);
QTimer::singleShot(30s, this, &SetupTest::shutdownHarder);
break;
case Akonadi::ServerManager::NotRunning:
case Akonadi::ServerManager::Broken:
......@@ -331,7 +334,7 @@ void SetupTest::shutdown()
break;
case Akonadi::ServerManager::Stopping:
// safety timeout
QTimer::singleShot(30 * 1000, this, &SetupTest::shutdownHarder);
QTimer::singleShot(30s, this, &SetupTest::shutdownHarder);
break;
}
}
......
......@@ -22,7 +22,7 @@
#include <aktest.h>
using namespace Akonadi::Server;
using namespace std::chrono_literals;
struct JobResult {
qint64 pimItemId;
QByteArray partname;
......@@ -68,7 +68,7 @@ public:
}
}
QTimer::singleShot(0, this, [this]() {
QTimer::singleShot(0s, this, [this]() {
Q_EMIT requestCompleted(this);
});
}
......
......@@ -25,7 +25,7 @@
#include <QTest>
#include <memory>
using namespace std::chrono_literals;
using namespace Akonadi;
/***
......@@ -125,7 +125,7 @@ class TagEditWidgetTest : public QObject
// Clicking the button blocks (QDialog::exec), so we need to confirm the
// dialog from event loop
bool confirmed = false;
QTimer::singleShot(100, [this, confirmDeletion, &confirmed]() {
QTimer::singleShot(100ms, [this, confirmDeletion, &confirmed]() {
confirmed = confirmDialog(confirmDeletion);
QVERIFY(confirmed);
});
......
......@@ -26,7 +26,7 @@
#include <memory>
using namespace Akonadi;
using namespace std::chrono_literals;
class TagWidgetTest : public QObject
{
Q_OBJECT
......@@ -161,7 +161,7 @@ private Q_SLOTS:
bool ok = false;
// Clicking on the Edit button opens the dialog in a blocking way, so
// we need to dispatch the test from event loop
QTimer::singleShot(100, this, [&test, &selection, &ok]() {
QTimer::singleShot(100ms, this, [&test, &selection, &ok]() {
QVERIFY(test.selectTagsInDialog(selection));
ok = true;
});
......
......@@ -55,7 +55,7 @@
#include <thread>
using namespace Akonadi;
using namespace std::chrono_literals;
static AgentBase *sAgentBase = nullptr;
AgentBase::Observer::Observer()
......@@ -422,7 +422,7 @@ void AgentBasePrivate::init()
mResourceTypeName = AgentManager::self()->instance(mId).type().name();
setProgramName();
QTimer::singleShot(0, q, [this] {
QTimer::singleShot(0s, q, [this] {
delayedInit();
});
}
......@@ -734,7 +734,7 @@ void AgentBasePrivate::collectionUnsubscribed(const Akonadi::Collection &collect
void AgentBasePrivate::changeProcessed()
{
mChangeRecorder->changeProcessed();
QTimer::singleShot(0, mChangeRecorder, &ChangeRecorder::replayNext);
QTimer::singleShot(0s, mChangeRecorder, &ChangeRecorder::replayNext);
}
void AgentBasePrivate::slotStatus(int status, const QString &message)
......
......@@ -18,14 +18,14 @@
#include <QDBusConnection>
using namespace Akonadi;
using namespace std::chrono_literals;
AgentSearchInterfacePrivate::AgentSearchInterfacePrivate(AgentSearchInterface *qq)
: q(qq)
{
new Akonadi__SearchAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Search"), this, QDBusConnection::ExportAdaptors);
QTimer::singleShot(0, this, &AgentSearchInterfacePrivate::delayedInit);
QTimer::singleShot(0s, this, &AgentSearchInterfacePrivate::delayedInit);
}
void AgentSearchInterfacePrivate::delayedInit()
......
......@@ -52,7 +52,7 @@
using namespace Akonadi;
using namespace AkRanges;
using namespace std::chrono_literals;
class Akonadi::ResourceBasePrivate : public AgentBasePrivate
{
Q_OBJECT
......@@ -114,7 +114,7 @@ public:
{
if (m_recursiveMover) {
m_recursiveMover->changeProcessed();
QTimer::singleShot(0, m_recursiveMover.data(), &RecursiveMover::replayNext);
QTimer::singleShot(0s, m_recursiveMover.data(), &RecursiveMover::replayNext);
return;
}
......
......@@ -17,7 +17,7 @@
#include <QTimer>
using namespace Akonadi;
using namespace std::chrono_literals;
qint64 ResourceScheduler::Task::latestSerial = 0;
static QDBusAbstractInterface *s_resourcetracker = nullptr;
......@@ -366,7 +366,7 @@ void ResourceScheduler::scheduleNext()
if (mCurrentTask.type != Invalid || isEmpty() || !mOnline) {
return;
}
QTimer::singleShot(0, this, &ResourceScheduler::executeNext);
QTimer::singleShot(0s, this, &ResourceScheduler::executeNext);
}
void ResourceScheduler::executeNext()
......
......@@ -16,7 +16,7 @@
#include <QTimer>
using namespace Akonadi;
using namespace std::chrono_literals;
AgentServer::AgentServer(QObject *parent)
: QObject(parent)
{
......@@ -35,7 +35,7 @@ void AgentServer::agentInstanceConfigure(const QString &identifier, qlonglong wi
{
m_configureQueue.enqueue(ConfigureInfo(identifier, windowId));
if (!m_processingConfigureRequests) { // Start processing the requests if needed.
QTimer::singleShot(0, this, &AgentServer::processConfigureRequest);
QTimer::singleShot(0s, this, &AgentServer::processConfigureRequest);
}
}
......
......@@ -10,7 +10,7 @@
#include <QTimer>
#include "controlmanageradaptor.h"
using namespace std::chrono_literals;
ControlManager::ControlManager(QObject *parent)
: QObject(parent)
{
......@@ -24,5 +24,5 @@ ControlManager::~ControlManager()
void ControlManager::shutdown()
{
QTimer::singleShot(0, QCoreApplication::instance(), &QCoreApplication::quit);
QTimer::singleShot(0s, QCoreApplication::instance(), &QCoreApplication::quit);
}
......@@ -37,7 +37,7 @@
//#define PIPELINE_LENGTH 2
using namespace Akonadi;
using namespace std::chrono_literals;
/// @cond PRIVATE
void SessionPrivate::startNext()
......@@ -104,7 +104,7 @@ bool SessionPrivate::handleCommands()
if (hello.isError()) {
qCWarning(AKONADICORE_LOG) << "Error when establishing connection with Akonadi server:" << hello.errorMessage();
connection->closeConnection();
QTimer::singleShot(1000, connection, &Connection::reconnect);
QTimer::singleShot(1s, connection, &Connection::reconnect);
return false;
}
......@@ -123,7 +123,7 @@ bool SessionPrivate::handleCommands()
if (login.isError()) {
qCWarning(AKONADICORE_LOG) << "Unable to login to Akonadi server:" << login.errorMessage();
connection->closeConnection();
QTimer::singleShot(1000, mParent, [this]() {
QTimer::singleShot(1s, mParent, [this]() {
reconnect();
});
return false;
......
......@@ -43,7 +43,7 @@
using namespace Akonadi;
using namespace Akonadi::Server;
using namespace std::chrono_literals;
namespace
{
class AkonadiDataStore : public DataStore
......@@ -204,7 +204,7 @@ bool AkonadiServer::quit()
qCCritical(AKONADISERVER_LOG) << "Failed to remove runtime connection config file";
}
QTimer::singleShot(0, this, &AkonadiServer::doQuit);
QTimer::singleShot(0s, this, &AkonadiServer::doQuit);
return true;
}
......
......@@ -25,7 +25,7 @@
#include <memory>
using namespace Akonadi;
using namespace std::chrono_literals;
AgentConfigurationWidget::Private::Private(const AgentInstance &instance)
: agentInstance(instance)
{
......@@ -88,7 +88,7 @@ AgentConfigurationWidget::AgentConfigurationWidget(const AgentInstance &instance
if (auto dlg = qobject_cast<AgentConfigurationDialog *>(parent)) {
const_cast<AgentInstance &>(instance).configure(topLevelWidget()->parentWidget());
// If we are inside the AgentConfigurationDialog, hide the dialog
QTimer::singleShot(0, this, [dlg]() {
QTimer::singleShot(0s, this, [dlg]() {
dlg->reject();
});
} else {
......
......@@ -20,7 +20,7 @@
#include <QTimer>
using namespace Akonadi;
using namespace std::chrono_literals;
namespace Akonadi
{
namespace Internal
......@@ -248,7 +248,7 @@ void ControlGui::widgetNeedsAkonadi(QWidget *widget)
s_instance->d->mPendingOverlays.append(widget);
// delay the overlay creation since we rely on widget being reparented
// correctly already
QTimer::singleShot(0, s_instance, []() {
QTimer::singleShot(0s, s_instance, []() {
s_instance->d->createErrorOverlays();
});
}
......
......@@ -15,7 +15,7 @@
#include <QTimer>
using namespace Akonadi;
using namespace std::chrono_literals;
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
{
......@@ -59,7 +59,7 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
view->expandAll();
setCentralWidget(view);
QTimer::singleShot(5000, this, &MainWindow::moveCollection);
QTimer::singleShot(5s, this, &MainWindow::moveCollection);
}
void MainWindow::moveCollection()
......
Supports Markdown
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