Skip to content
Snippets Groups Projects
Commit c86edc0c authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files

[ #10724 ] Add bookmarks to the dataengine

parent 5df6c398
Branches
Tags
No related merge requests found
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "../../lib/sflphone_const.h" #include "../../lib/sflphone_const.h"
#include "../../klib/AkonadiBackend.h" #include "../../klib/AkonadiBackend.h"
#include "../../klib/HelperFunctions.h" #include "../../klib/HelperFunctions.h"
#include "../../klib/ConfigurationSkeleton.h"
#include "sflphoneService.h"> #include "sflphoneService.h">
CallModel<>* SFLPhoneEngine::m_pModel = NULL; CallModel<>* SFLPhoneEngine::m_pModel = NULL;
...@@ -56,6 +57,9 @@ bool SFLPhoneEngine::sourceRequestEvent(const QString &name) ...@@ -56,6 +57,9 @@ bool SFLPhoneEngine::sourceRequestEvent(const QString &name)
else if ( name == "contacts" ) { else if ( name == "contacts" ) {
updateContacts(); updateContacts();
} }
else if ( name == "bookmark" ) {
updateBookmarkList();
}
return true;//updateSourceEvent(name); return true;//updateSourceEvent(name);
} }
...@@ -67,7 +71,7 @@ bool SFLPhoneEngine::updateSourceEvent(const QString &name) ...@@ -67,7 +71,7 @@ bool SFLPhoneEngine::updateSourceEvent(const QString &name)
QStringList SFLPhoneEngine::sources() const { QStringList SFLPhoneEngine::sources() const {
QStringList toReturn; QStringList toReturn;
toReturn << "calls" << "history" << "conferences" << "info" << "accounts" << "contacts"; toReturn << "calls" << "history" << "conferences" << "info" << "accounts" << "contacts" << "bookmark";
return toReturn; return toReturn;
} }
...@@ -116,7 +120,6 @@ void SFLPhoneEngine::updateHistory() ...@@ -116,7 +120,6 @@ void SFLPhoneEngine::updateHistory()
setHistoryCategory(list,HistorySortingMode::Date); setHistoryCategory(list,HistorySortingMode::Date);
foreach (Call* oldCall, list) { foreach (Call* oldCall, list) {
qDebug() << oldCall->getStopTimeStamp();
historyCall[oldCall->getCallId()][ "peerName" ] = oldCall->getPeerName(); historyCall[oldCall->getCallId()][ "peerName" ] = oldCall->getPeerName();
historyCall[oldCall->getCallId()][ "peerNumber" ] = oldCall->getPeerPhoneNumber(); historyCall[oldCall->getCallId()][ "peerNumber" ] = oldCall->getPeerPhoneNumber();
historyCall[oldCall->getCallId()][ "length" ] = oldCall->getStopTimeStamp().toInt() - oldCall->getStartTimeStamp().toInt(); historyCall[oldCall->getCallId()][ "length" ] = oldCall->getStopTimeStamp().toInt() - oldCall->getStartTimeStamp().toInt();
...@@ -140,6 +143,38 @@ void SFLPhoneEngine::updateCallList() ...@@ -140,6 +143,38 @@ void SFLPhoneEngine::updateCallList()
} }
} }
void SFLPhoneEngine::updateBookmarkList()
{
removeAllData("bookmark");
int i=0;
QStringList cl = getModel()->getNumbersByPopularity();
for (;i < ((cl.size() < 10)?cl.size():10);i++) {
QHash<QString,QVariant> pop;
Contact* cont = AkonadiBackend::getInstance()->getContactByPhone(cl[i],true);
if (cont) {
pop["peerName" ] = cont->getFormattedName();
}
else {
pop["peerName" ] = cl[i];
}
pop["peerNumber" ] = cl[i];
pop["section" ] = "Popular";
pop["listPriority" ] = 1000;
setData("bookmark", QString::number(i), pop);
}
//TODO Wont work for now
foreach (QString nb, ConfigurationSkeleton::bookmarkList()) {
i++;
QHash<QString,QVariant> pop;
pop["peerName" ] = "TODO";
pop["peerNumber" ] = nb;
pop["section" ] = "1";
pop["listPriority" ] = 0;
setData("bookmark", QString::number(i), pop);
}
}
void SFLPhoneEngine::updateConferenceList() void SFLPhoneEngine::updateConferenceList()
{ {
foreach (Call* call, m_pModel->getCalls()) { foreach (Call* call, m_pModel->getCalls()) {
...@@ -172,6 +207,7 @@ void SFLPhoneEngine::updateCollection() ...@@ -172,6 +207,7 @@ void SFLPhoneEngine::updateCollection()
setData("contacts", QString::number(i), QVariant(cont)); setData("contacts", QString::number(i), QVariant(cont));
i++; i++;
} }
updateBookmarkList();
} }
void SFLPhoneEngine::updateContacts() void SFLPhoneEngine::updateContacts()
......
...@@ -61,6 +61,7 @@ class SFLPhoneEngine : public Plasma::DataEngine,public SortableDockCommon<> ...@@ -61,6 +61,7 @@ class SFLPhoneEngine : public Plasma::DataEngine,public SortableDockCommon<>
void updateAccounts (); void updateAccounts ();
void updateConferenceList (); void updateConferenceList ();
void updateContacts (); void updateContacts ();
void updateBookmarkList ();
void updateInfo(); void updateInfo();
private slots: private slots:
void updateCollection(); void updateCollection();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment