Skip to content
Snippets Groups Projects
Commit 0d723ec1 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

contactmethod: reactivate roles

Instead of returning 'N/A' return the appropriate data.

Issue: #75334
Change-Id: I071cc8f5fbe621dd2cb69f1977667e931ca01e5b
parent 32dd5e51
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
//Qt //Qt
#include <QtCore/QCryptographicHash> #include <QtCore/QCryptographicHash>
#include <QDateTime>
//Ring daemon //Ring daemon
#include "dbus/configurationmanager.h" #include "dbus/configurationmanager.h"
...@@ -455,6 +456,9 @@ QHash<QString,int> ContactMethod::alternativeNames() const ...@@ -455,6 +456,9 @@ QHash<QString,int> ContactMethod::alternativeNames() const
QVariant ContactMethod::roleData(int role) const QVariant ContactMethod::roleData(int role) const
{ {
QVariant cat; QVariant cat;
auto lastCall = d_ptr->m_lCalls.last();
switch (role) { switch (role) {
case static_cast<int>(Call::Role::Name): case static_cast<int>(Call::Role::Name):
/* the formatted name could be empty either because the name of the contact is actually /* the formatted name could be empty either because the name of the contact is actually
...@@ -472,25 +476,25 @@ QVariant ContactMethod::roleData(int role) const ...@@ -472,25 +476,25 @@ QVariant ContactMethod::roleData(int role) const
case Qt::EditRole: case Qt::EditRole:
case static_cast<int>(Role::Uri): case static_cast<int>(Role::Uri):
case static_cast<int>(Call::Role::Number): case static_cast<int>(Call::Role::Number):
cat = uri();//call->getPeerContactMethod(); cat = uri();
break; break;
case static_cast<int>(Call::Role::Direction): case static_cast<int>(Call::Role::Direction):
cat = tr("N/A");//call->getHistoryState(); cat = cat = !lastCall ? QVariant() : QVariant::fromValue(lastCall->direction());
break; break;
case static_cast<int>(Call::Role::Date): case static_cast<int>(Call::Role::Date):
cat = tr("N/A");//call->getStartTimeStamp(); cat = cat = !lastCall ? QVariant() : QDateTime::fromTime_t(lastCall->startTimeStamp());
break; break;
case static_cast<int>(Call::Role::Length): case static_cast<int>(Call::Role::Length):
cat = tr("N/A");//call->getLength(); cat = cat = !lastCall ? QVariant() : lastCall->length();
break; break;
case static_cast<int>(Call::Role::FormattedDate): case static_cast<int>(Call::Role::FormattedDate):
cat = tr("N/A");//QDateTime::fromTime_t(call->getStartTimeStamp().toUInt()).toString(); cat = !lastCall ? QVariant() : HistoryTimeCategoryModel::timeToHistoryCategory(lastCall->startTimeStamp());
break; break;
case static_cast<int>(Call::Role::HasAVRecording): case static_cast<int>(Call::Role::HasAVRecording):
cat = false;//call->hasRecording(); cat = cat = !lastCall ? QVariant() : lastCall->isAVRecording();
break; break;
case static_cast<int>(Call::Role::FuzzyDate): case static_cast<int>(Call::Role::FuzzyDate):
cat = "N/A";//timeToHistoryCategory(QDateTime::fromTime_t(call->getStartTimeStamp().toUInt()).date()); cat = cat = !lastCall ? QVariant() : HistoryTimeCategoryModel::timeToHistoryCategory(lastCall->startTimeStamp());
break; break;
case static_cast<int>(Call::Role::ContactMethod): case static_cast<int>(Call::Role::ContactMethod):
case static_cast<int>(Role::Object): case static_cast<int>(Role::Object):
......
...@@ -125,7 +125,10 @@ public: ...@@ -125,7 +125,10 @@ public:
Media::TextRecording* textRecording () const; Media::TextRecording* textRecording () const;
Certificate* certificate () const; Certificate* certificate () const;
/*
* Returns roles associated on ContactMethod based on Call::Roles
* Returns last call info when querying info on call associated to this contact method
*/
QVariant roleData(int role) const; QVariant roleData(int role) const;
//Setters //Setters
...@@ -235,4 +238,3 @@ private: ...@@ -235,4 +238,3 @@ private:
TemporaryContactMethodPrivate* d_ptr; TemporaryContactMethodPrivate* d_ptr;
Q_DECLARE_PRIVATE(TemporaryContactMethod) Q_DECLARE_PRIVATE(TemporaryContactMethod)
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment