Commit 5b27e609 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make it compile without deprecated methods

parent ff278c24
......@@ -52,11 +52,13 @@ set (
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
${CMAKE_MODULE_PATH}
)
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
endif()
add_definitions(
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_DISABLE_DEPRECATED_BEFORE=0x050700
)
add_definitions (-DTRANSLATION_DOMAIN=\"kactivities5\")
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po")
......
......@@ -20,7 +20,6 @@
#include <QStringList>
#include <QString>
#include <QSignalMapper>
#include <QAction>
#include <KActionCollection>
......@@ -35,7 +34,6 @@ const auto objectNamePatternLength = objectNamePattern.length() - 2;
GlobalShortcutsPlugin::GlobalShortcutsPlugin(QObject *parent, const QVariantList &args)
: Plugin(parent)
, m_activitiesService(nullptr)
, m_signalMapper(new QSignalMapper(this))
, m_actionCollection(new KActionCollection(this))
{
Q_UNUSED(args);
......@@ -61,10 +59,10 @@ bool GlobalShortcutsPlugin::init(QHash<QString, QObject *> &modules)
for (const auto &activity: m_activitiesList) {
activityAdded(activity);
}
connect(m_signalMapper, SIGNAL(mapped(QString)),
connect(this, SIGNAL(currentActivityChanged(QString)),
m_activitiesService, SLOT(SetCurrentActivity(QString)),
Qt::QueuedConnection);
connect(m_activitiesService, SIGNAL(ActivityAdded(QString)),
this, SLOT(activityAdded(QString)));
connect(m_activitiesService, SIGNAL(ActivityRemoved(QString)),
......@@ -91,8 +89,7 @@ void GlobalShortcutsPlugin::activityAdded(const QString &activity)
action->setText(i18nc("@action", "Switch to activity \"%1\"", activityName(activity)));
KGlobalAccel::self()->setDefaultShortcut(action, QList<QKeySequence>{});
connect(action, SIGNAL(triggered()), m_signalMapper, SLOT(map()));
m_signalMapper->setMapping(action, activity);
connect(action, &QAction::triggered, [this, activity]() { Q_EMIT currentActivityChanged(activity);});
// m_actionCollection->writeSettings();
}
......
......@@ -20,8 +20,6 @@
#define PLUGINS_GLOBAL_SHORTCUTS_PLUGIN_H
#include <Plugin.h>
class QSignalMapper;
class KActionCollection;
class QAction;
......@@ -40,12 +38,14 @@ private Q_SLOTS:
void activityRemoved(const QString &activity);
void activityChanged(const QString &activity);
Q_SIGNALS:
void currentActivityChanged(const QString &activity);
private:
inline QString activityName(const QString &activity) const;
inline QString activityForAction(QAction *action) const;
QObject *m_activitiesService;
QSignalMapper *m_signalMapper;
QStringList m_activitiesList;
KActionCollection *m_actionCollection;
};
......
......@@ -163,7 +163,7 @@ void ResourceScoreCache::update()
":usedActivity", d->activity,
":initiatingAgent", d->application,
":targettedResource", d->resource,
":firstUpdate", currentTime.toTime_t()
":firstUpdate", currentTime.toSecsSinceEpoch()
);
// Getting the old score
......@@ -177,8 +177,8 @@ void ResourceScoreCache::update()
// Only and always one result
for (const auto &result: Queries::self().getResourceScoreCacheQuery) {
lastUpdate.setTime_t(result["lastUpdate"].toUInt());
firstUpdate.setTime_t(result["firstUpdate"].toUInt());
lastUpdate.setSecsSinceEpoch(result["lastUpdate"].toUInt());
firstUpdate.setSecsSinceEpoch(result["firstUpdate"].toUInt());
qCDebug(KAMD_LOG_RESOURCES) << "Already in database? " << (!isCacheNew);
qCDebug(KAMD_LOG_RESOURCES) << " First update : " << firstUpdate;
......@@ -209,10 +209,10 @@ void ResourceScoreCache::update()
":usedActivity", d->activity,
":initiatingAgent", d->application,
":targettedResource", d->resource,
":start", lastUpdate.toTime_t()
":start", lastUpdate.toSecsSinceEpoch()
);
uint lastEventStart = currentTime.toTime_t();
uint lastEventStart = currentTime.toSecsSinceEpoch();
for (const auto &result: Queries::self().getScoreAdditionQuery) {
lastEventStart = result["start"].toUInt();
......@@ -224,10 +224,10 @@ void ResourceScoreCache::update()
if (intervalLength == 0) {
// We have an Accessed event - otherwise, this wouldn't be 0
score += d->timeFactor(QDateTime::fromTime_t(end), currentTime); // like it is open for 1 minute
score += d->timeFactor(QDateTime::fromSecsSinceEpoch(end), currentTime); // like it is open for 1 minute
} else {
score += d->timeFactor(QDateTime::fromTime_t(end), currentTime) * intervalLength / 60.0;
score += d->timeFactor(QDateTime::fromSecsSinceEpoch(end), currentTime) * intervalLength / 60.0;
}
}
......@@ -258,6 +258,6 @@ void ResourceScoreCache::update()
Q_ARG(QString, d->resource),
Q_ARG(double, score),
Q_ARG(uint, lastEventStart),
Q_ARG(uint, firstUpdate.toTime_t())
Q_ARG(uint, firstUpdate.toSecsSinceEpoch())
);
}
......@@ -175,8 +175,8 @@ void StatsPlugin::openResourceEvent(const QString &usedActivity,
":usedActivity" , usedActivity ,
":initiatingAgent" , initiatingAgent ,
":targettedResource" , targettedResource ,
":start" , start.toTime_t() ,
":end" , (end.isNull()) ? QVariant() : end.toTime_t()
":start" , start.toSecsSinceEpoch() ,
":end" , (end.isNull()) ? QVariant() : end.toSecsSinceEpoch()
);
}
......@@ -209,7 +209,7 @@ void StatsPlugin::closeResourceEvent(const QString &usedActivity,
":usedActivity" , usedActivity ,
":initiatingAgent" , initiatingAgent ,
":targettedResource" , targettedResource ,
":end" , end.toTime_t()
":end" , end.toSecsSinceEpoch()
);
}
......@@ -495,12 +495,12 @@ void StatsPlugin::DeleteRecentStats(const QString &activity, int count,
Utils::exec(Utils::FailOnError, removeEventsQuery,
":usedActivity", usedActivity,
":since", since.toTime_t()
":since", since.toSecsSinceEpoch()
);
Utils::exec(Utils::FailOnError, removeScoreCachesQuery,
":usedActivity", usedActivity,
":since", since.toTime_t()
":since", since.toSecsSinceEpoch()
);
}
......@@ -536,12 +536,12 @@ void StatsPlugin::DeleteEarlierStats(const QString &activity, int months)
Utils::exec(Utils::FailOnError, removeEventsQuery,
":usedActivity", usedActivity,
":time", time.toTime_t()
":time", time.toSecsSinceEpoch()
);
Utils::exec(Utils::FailOnError, removeScoreCachesQuery,
":usedActivity", usedActivity,
":time", time.toTime_t()
":time", time.toSecsSinceEpoch()
);
emit EarlierStatsDeleted(activity, months);
......
Markdown is supported
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