Skip to content

Commit

Permalink
[libcommhistory] Refresh callmodels after backup. Fixes JB#49452
Browse files Browse the repository at this point in the history
  • Loading branch information
salmelamike committed Nov 11, 2020
1 parent 5a122db commit 14f2ab0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/callmodel.cpp
Expand Up @@ -30,6 +30,7 @@
#include "eventmodel.h"
#include "eventmodel_p.h"
#include "callmodel.h"
#include "constants.h"
#include "event.h"
#include "commonutils.h"
#include "debug.h"
Expand Down Expand Up @@ -983,6 +984,10 @@ CallModel::CallModel(QObject *parent)
{
Q_D(CallModel);
d->isInTreeMode = true;

QDBusConnection::sessionBus().connect(
QString(), QString(), COMM_HISTORY_SERVICE_NAME, GET_EVENTS_SIGNAL,
this, SLOT(getEventsSlot()));
}

CallModel::~CallModel()
Expand Down Expand Up @@ -1237,6 +1242,14 @@ bool CallModel::deleteEvent( Event &event )
return deleteEvent(event.id());
}

void CallModel::signalGetEvents()
{
auto backupDoneMsg = QDBusMessage::createSignal("/",
COMM_HISTORY_SERVICE_NAME,
GET_EVENTS_SIGNAL);
QDBusConnection::sessionBus().send(backupDoneMsg);
}

}

#include "callmodel.moc"
Expand Down
11 changes: 11 additions & 0 deletions src/callmodel.h
Expand Up @@ -193,8 +193,19 @@ class LIBCOMMHISTORY_EXPORT CallModel: public EventModel

virtual bool deleteEvent( Event &event );

/*!
* \brief Signal all callmodel objects to call getEvents()
* Used after call history restoration to display the history properly.
*/
void signalGetEvents();

private:
Q_DECLARE_PRIVATE(CallModel)
private slots:
void getEventsSlot()
{
getEvents();
}
};

}
Expand Down
1 change: 1 addition & 0 deletions src/constants.h
Expand Up @@ -33,6 +33,7 @@ namespace CommHistory {
#define EVENTS_ADDED_SIGNAL QLatin1String("eventsAdded")
#define EVENTS_UPDATED_SIGNAL QLatin1String("eventsUpdated")
#define EVENT_DELETED_SIGNAL QLatin1String("eventDeleted")
#define GET_EVENTS_SIGNAL QLatin1String("getEvents")

#define GROUPS_ADDED_SIGNAL QLatin1String("groupsAdded")
#define GROUPS_UPDATED_SIGNAL QLatin1String("groupsUpdated")
Expand Down
5 changes: 4 additions & 1 deletion tools/commhistory-tool.cpp
Expand Up @@ -25,6 +25,7 @@
#include <QDebug>
#include <QUuid>
#include <QEventLoop>
#include <unistd.h>

#include "../src/groupmodel.h"
#include "../src/conversationmodel.h"
Expand Down Expand Up @@ -1132,7 +1133,7 @@ int doImport(const QStringList &arguments, const QVariantMap &options)
int numCalls;
in >> numCalls;
if (numCalls) {
EventModel model;
CallModel model;
model.setQueryMode(EventModel::SyncQuery);
Catcher catcher(&model);

Expand All @@ -1146,6 +1147,8 @@ int doImport(const QStringList &arguments, const QVariantMap &options)
qWarning() << "Error adding calls";
} else {
catcher.waitCommit(numCalls);
sleep(10); // Wait for callmodels to settle
model.signalGetEvents();
}
}

Expand Down

0 comments on commit 14f2ab0

Please sign in to comment.