diff --git a/src/account.cpp b/src/account.cpp index 49d0d792235b9c8b3971a329ff95defcc8f9b5b8..a5463cda3fd8151736acaf11842e053006740e9d 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -1020,6 +1020,7 @@ QVariant Account::roleData(int role) const //Generic case Qt::DisplayRole: case Qt::EditRole: + case CAST(Ring::Role::Name): return alias(); case Qt::CheckStateRole: return QVariant(isEnabled() ? Qt::Checked : Qt::Unchecked); @@ -1032,7 +1033,7 @@ QVariant Account::roleData(int role) const case CAST(Account::Role::Alias): return alias(); case CAST(Account::Role::Proto): - return static_cast<int>(protocol()); + return CAST(protocol()); case CAST(Account::Role::Hostname): return hostname(); case CAST(Account::Role::Username): @@ -1101,13 +1102,14 @@ QVariant Account::roleData(int role) const return DTMFType(); case CAST(Account::Role::Id): return id(); + case CAST(Ring::Role::Object): case CAST(Account::Role::Object): { QVariant var; var.setValue(const_cast<Account*>(this)); return var; } case CAST(Account::Role::TypeName): - return static_cast<int>(protocol()); + return CAST(protocol()); case CAST(Account::Role::PresenceStatus): return PresenceStatusModel::instance()->currentStatus(); case CAST(Account::Role::PresenceMessage): @@ -1122,6 +1124,7 @@ QVariant Account::roleData(int role) const return weekCallCount(); case CAST(Account::Role::TrimesterCallCount): return trimesterCallCount(); + case CAST(Ring::Role::LastUsed): case CAST(Account::Role::LastUsed): return (int)lastUsed(); case CAST(Account::Role::UserAgent): diff --git a/src/account.h b/src/account.h index b10fb0de77df8f4ef63a18c4633568e5a73c5508..8598fbfc5d3b7f2e3f0b32f3f0421843d25ee3f2 100644 --- a/src/account.h +++ b/src/account.h @@ -30,6 +30,7 @@ class QString; #include "tlsmethodmodel.h" #include "uri.h" #include "typedefs.h" +#include "itemdataroles.h" class CredentialModel ; class ContactMethod ; class SecurityEvaluationModel ; @@ -213,97 +214,97 @@ class LIB_EXPORT Account : public ItemBase { Q_ENUMS(RegistrationState) enum class Role { - Alias = 100, - Proto = 101, - Hostname = 102, - Username = 103, - Mailbox = 104, - Proxy = 105, - TlsPassword = 107, - TlsCaListCertificate = 108, - TlsCertificate = 109, - TlsPrivateKey = 110, - TlsServerName = 112, - SipStunServer = 113, - PublishedAddress = 114, - RingtonePath = 116, - RegistrationExpire = 118, - TlsNegotiationTimeoutSec = 119, - TlsNegotiationTimeoutMsec = 120, - LocalPort = 121, - BootstrapPort = 122, - PublishedPort = 123, - Enabled = 124, - AutoAnswer = 125, - TlsVerifyServer = 126, - TlsVerifyClient = 127, - TlsRequireClientCertificate = 128, - TlsEnabled = 129, - DisplaySasOnce = 130, - SrtpRtpFallback = 131, - ZrtpDisplaySas = 132, - ZrtpNotSuppWarning = 133, - ZrtpHelloHash = 134, - SipStunEnabled = 135, - PublishedSameAsLocal = 136, - RingtoneEnabled = 137, - dTMFType = 138, - Id = 139, - Object = 140, - TypeName = 141, - PresenceStatus = 142, - PresenceMessage = 143, - RegistrationState = 144, - UseDefaultPort = 145, - UsedForOutgogingCall = 146, - TotalCallCount = 147, - WeekCallCount = 148, - TrimesterCallCount = 149, - LastUsed = 150, - UserAgent = 153, - Password = 154, - SupportPresencePublish = 155, - SupportPresenceSubscribe = 156, - PresenceEnabled = 165, - IsVideoEnabled = 169, - VideoPortMax = 157, - VideoPortMin = 158, - AudioPortMin = 159, - AudioPortMax = 160, - IsUpnpEnabled = 161, - HasCustomUserAgent = 162, - LastTransportErrorCode = 163, - LastTransportErrorMessage = 164, - TurnServer = 168, - TurnServerEnabled = 194, - TurnServerUsername = 195, - TurnServerPassword = 196, - TurnServerRealm = 197, - HasProxy = 170, - DisplayName = 171, - SrtpEnabled = 172, - HasCustomBootstrap = 173, - CredentialModel = 174, - CodecModel = 175, - KeyExchangeModel = 176, - CipherModel = 177, - StatusModel = 178, - SecurityEvaluationModel = 179, - TlsMethodModel = 180, - ProtocolModel = 181, - BootstrapModel = 182, - NetworkInterfaceModel = 183, - KnownCertificateModel = 184, - BannedCertificatesModel = 185, - AllowedCertificatesModel = 186, - AllowIncomingFromHistory = 187, - AllowIncomingFromContact = 188, - AllowIncomingFromUnknown = 189, - ActiveCallLimit = 190, - HasActiveCallLimit = 191, - SecurityLevel = 192, - SecurityLevelIcon = 193, - }; //current last number = 197 + Alias = static_cast<int>(Ring::Role::UserRole) + 100, + Proto , + Hostname , + Username , + Mailbox , + Proxy , + TlsPassword , + TlsCaListCertificate , + TlsCertificate , + TlsPrivateKey , + TlsServerName , + SipStunServer , + PublishedAddress , + RingtonePath , + RegistrationExpire , + TlsNegotiationTimeoutSec , + TlsNegotiationTimeoutMsec , + LocalPort , + BootstrapPort , + PublishedPort , + Enabled , + AutoAnswer , + TlsVerifyServer , + TlsVerifyClient , + TlsRequireClientCertificate , + TlsEnabled , + DisplaySasOnce , + SrtpRtpFallback , + ZrtpDisplaySas , + ZrtpNotSuppWarning , + ZrtpHelloHash , + SipStunEnabled , + PublishedSameAsLocal , + RingtoneEnabled , + dTMFType , + Id , + Object , + TypeName , + PresenceStatus , + PresenceMessage , + RegistrationState , + UseDefaultPort , + UsedForOutgogingCall , + TotalCallCount , + WeekCallCount , + TrimesterCallCount , + LastUsed , + UserAgent , + Password , + SupportPresencePublish , + SupportPresenceSubscribe , + PresenceEnabled , + IsVideoEnabled , + VideoPortMax , + VideoPortMin , + AudioPortMin , + AudioPortMax , + IsUpnpEnabled , + HasCustomUserAgent , + LastTransportErrorCode , + LastTransportErrorMessage , + TurnServer , + TurnServerEnabled , + TurnServerUsername , + TurnServerPassword , + TurnServerRealm , + HasProxy , + DisplayName , + SrtpEnabled , + HasCustomBootstrap , + CredentialModel , + CodecModel , + KeyExchangeModel , + CipherModel , + StatusModel , + SecurityEvaluationModel , + TlsMethodModel , + ProtocolModel , + BootstrapModel , + NetworkInterfaceModel , + KnownCertificateModel , + BannedCertificatesModel , + AllowedCertificatesModel , + AllowIncomingFromHistory , + AllowIncomingFromContact , + AllowIncomingFromUnknown , + ActiveCallLimit , + HasActiveCallLimit , + SecurityLevel , + SecurityLevelIcon , + }; ///@enum RoleState Whether a role can be used in a certain context enum class RoleState { diff --git a/src/call.cpp b/src/call.cpp index 0bc7e84012ffad51b065c73bbf77494165bfcb40..6d8a969f9d1906af02576b7d07605f87fcf51812 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -2024,6 +2024,7 @@ QVariant Call::roleData(int role) const { const Person* ct = peerContactMethod()?peerContactMethod()->contact():nullptr; switch (role) { + case static_cast<int>(Ring::Role::Name): case static_cast<int>(Call::Role::Name): case Qt::DisplayRole: if (type() == Call::Type::CONFERENCE) @@ -2035,6 +2036,7 @@ QVariant Call::roleData(int role) const return tr("Account: ") + (account()?account()->alias():QString()); case Qt::EditRole: return dialNumber(); + case static_cast<int>(Ring::Role::Number): case static_cast<int>(Call::Role::Number): return peerContactMethod()->uri(); case static_cast<int>(Call::Role::Direction): @@ -2072,12 +2074,14 @@ QVariant Call::roleData(int role) const return ct?ct->preferredEmail():QVariant(); case static_cast<int>(Call::Role::Organisation): return ct?ct->organization():QVariant(); + case static_cast<int>(Ring::Role::Object): case static_cast<int>(Call::Role::Object): return QVariant::fromValue(const_cast<Call*>(this)); case static_cast<int>(Call::Role::ContactMethod): return QVariant::fromValue(peerContactMethod()); case static_cast<int>(Call::Role::Photo): return ct?ct->photo():QVariant(); + case static_cast<int>(Ring::Role::State): case static_cast<int>(Call::Role::State): return QVariant::fromValue(state()); case static_cast<int>(Call::Role::StartTime): @@ -2102,6 +2106,7 @@ QVariant Call::roleData(int role) const return d_ptr->m_mRecordings[Media::Media::Type::AUDIO][Media::Media::Direction::IN]->size() > 0; case static_cast<int>(Call::Role::HasVideoRecording): return d_ptr->m_mRecordings[Media::Media::Type::VIDEO][Media::Media::Direction::IN]->size() > 0; + case static_cast<int>(Ring::Role::FormattedState): case static_cast<int>(Call::Role::HumanStateName): return toHumanStateName(state()); case static_cast<int>(Call::Role::DropState): diff --git a/src/call.h b/src/call.h index 6c361c63936aa33a63f35e7d37aba5e84aef9127..b9589ae1c38a60e4b1b7e4c2827ccc8d89823177 100644 --- a/src/call.h +++ b/src/call.h @@ -31,6 +31,7 @@ class QTimer; #include "typedefs.h" #include "historytimecategorymodel.h" #include "media/media.h" +#include "itemdataroles.h" class Account ; class InstantMessagingModel ; class UserActionModel ; @@ -94,46 +95,46 @@ public: ///Model roles enum class Role { - Name = 100, /*!< The peer name from SIP or Persons */ - Number = 101, /*!< The peer URI / phone number (as text) */ - Direction = 102, /*!< */ - Date = 103, /*!< The date when the call started */ - Length = 104, /*!< The current length of the call */ - FormattedDate = 105, /*!< An human readable starting date */ - Historystate = 107, /*!< */ - Filter = 108, /*!< */ - FuzzyDate = 109, /*!< */ - IsBookmark = 110, /*!< */ - Security = 111, /*!< */ - Department = 112, /*!< */ - Email = 113, /*!< */ - Organisation = 114, /*!< */ - HasAVRecording = 115, /*!< */ - Object = 117, /*!< */ - Photo = 118, /*!< */ - State = 119, /*!< */ - StartTime = 121, /*!< */ - StopTime = 122, /*!< */ - IsAVRecording = 123, /*!< */ - ContactMethod = 124, /*!< */ - IsPresent = 125, /*!< */ - SupportPresence = 126, /*!< */ - IsTracked = 127, /*!< */ - CategoryIcon = 128, /*!< */ - CallCount = 129, /*!< The number of calls made with the same phone number */ - TotalSpentTime = 130, /*!< The total time spent speaking to with this phone number */ - Missed = 131, /*!< This call has been missed */ - LifeCycleState = 132, /*!< */ - Certificate = 133, /*!< The certificate (for encrypted calls) */ - HasAudioRecording = 134, /*!< */ - HasVideoRecording = 135, /*!< */ - HumanStateName = 136, /*!< */ - DropState = 300, /*!< GUI related state to keep track of metadata during drag and drop */ - DTMFAnimState = 400, /*!< GUI related state to hold animation key(s) */ - LastDTMFidx = 401, /*!< The last DTMF (button) sent on this call */ - DropPosition = 402, /*!< GUI related state to keep track of metadata during drag and drop */ - SecurityLevel = 998, //TODO REMOVE use the extensions - SecurityLevelIcon = 999, //TODO REMOVE use the extensions + Name = static_cast<int>(Ring::Role::UserRole) + 100, /*!< The peer name from SIP or Persons */ + Number , /*!< The peer URI / phone number (as text) */ + Direction , /*!< */ + Date , /*!< The date when the call started */ + Length , /*!< The current length of the call */ + FormattedDate , /*!< An human readable starting date */ + Historystate , /*!< */ + Filter , /*!< */ + FuzzyDate , /*!< */ + IsBookmark , /*!< */ + Security , /*!< */ + Department , /*!< */ + Email , /*!< */ + Organisation , /*!< */ + HasAVRecording , /*!< */ + Object , /*!< */ + Photo , /*!< */ + State , /*!< */ + StartTime , /*!< */ + StopTime , /*!< */ + IsAVRecording , /*!< */ + ContactMethod , /*!< */ + IsPresent , /*!< */ + SupportPresence , /*!< */ + IsTracked , /*!< */ + CategoryIcon , /*!< */ + CallCount , /*!< The number of calls made with the same phone number */ + TotalSpentTime , /*!< The total time spent speaking to with this phone number */ + Missed , /*!< This call has been missed */ + LifeCycleState , /*!< */ + Certificate , /*!< The certificate (for encrypted calls) */ + HasAudioRecording , /*!< */ + HasVideoRecording , /*!< */ + HumanStateName , /*!< */ + DTMFAnimState , /*!< GUI related state to hold animation key(s) */ + LastDTMFidx , /*!< The last DTMF (button) sent on this call */ + DropPosition , /*!< GUI related state to keep track of metadata during drag and drop */ + SecurityLevel , //TODO REMOVE use the extensions + SecurityLevelIcon , //TODO REMOVE use the extensions + DropState = static_cast<int>(Ring::Role::DropState), /*!< GUI related state to keep track of metadata during drag and drop */ }; enum DropAction { diff --git a/src/contactmethod.cpp b/src/contactmethod.cpp index 94c2d63eaca9cf34bf0f182d46b7dc9d171019f3..09025e0c2c078b26e795a121f2df38cfc940c48a 100644 --- a/src/contactmethod.cpp +++ b/src/contactmethod.cpp @@ -460,6 +460,7 @@ QVariant ContactMethod::roleData(int role) const auto lastCall = d_ptr->m_lCalls.isEmpty() ? nullptr : d_ptr->m_lCalls.last(); switch (role) { + case static_cast<int>(Ring::Role::Name): case static_cast<int>(Call::Role::Name): /* the formatted name could be empty either because the name of the contact is actually * empty, or because the PersonPlaceHolder was never matched to a Person, in either case @@ -475,18 +476,21 @@ QVariant ContactMethod::roleData(int role) const case Qt::DisplayRole: case Qt::EditRole: case static_cast<int>(Role::Uri): + case static_cast<int>(Ring::Role::Number): case static_cast<int>(Call::Role::Number): cat = uri(); break; case static_cast<int>(Call::Role::Direction): cat = cat = !lastCall ? QVariant() : QVariant::fromValue(lastCall->direction()); break; + case static_cast<int>(Ring::Role::LastUsed): case static_cast<int>(Call::Role::Date): cat = cat = !lastCall ? QVariant() : QDateTime::fromTime_t(lastCall->startTimeStamp()); break; case static_cast<int>(Call::Role::Length): cat = cat = !lastCall ? QVariant() : lastCall->length(); break; + case static_cast<int>(Ring::Role::FormattedLastUsed): case static_cast<int>(Call::Role::FormattedDate): cat = !lastCall ? QVariant() : HistoryTimeCategoryModel::timeToHistoryCategory(lastCall->startTimeStamp()); break; @@ -497,6 +501,7 @@ QVariant ContactMethod::roleData(int role) const cat = cat = !lastCall ? QVariant() : HistoryTimeCategoryModel::timeToHistoryCategory(lastCall->startTimeStamp()); break; case static_cast<int>(Call::Role::ContactMethod): + case static_cast<int>(Ring::Role::Object): case static_cast<int>(Role::Object): cat = QVariant::fromValue(const_cast<ContactMethod*>(this)); break; diff --git a/src/contactmethod.h b/src/contactmethod.h index edd78f88a8b5b9537ab5a155ab2aa29d29dad7fc..e9c046967903b5627b1a6c44c7bc23e9f2e1add6 100644 --- a/src/contactmethod.h +++ b/src/contactmethod.h @@ -28,6 +28,7 @@ #include <QtCore/QSharedPointer> //Ring +#include "itemdataroles.h" #include "uri.h" class Account; class Person; @@ -55,9 +56,9 @@ public: friend class CallPrivate; enum class Role { - Uri = 1000, - Object = 1001, - CategoryIcon = 1002, + Uri = static_cast<int>(Ring::Role::UserRole) + 1000, + Object , + CategoryIcon , //TODO implement all others }; diff --git a/src/person.cpp b/src/person.cpp index 813069b862c03b7973e3b053166f3a5b01eb56b6..bb5cf9a3452528e4bb50bc2ad1fee27a91f710b0 100644 --- a/src/person.cpp +++ b/src/person.cpp @@ -521,6 +521,7 @@ QVariant Person::roleData(int role) const switch (role) { case Qt::DisplayRole: case Qt::EditRole: + case static_cast<int>(Ring::Role::Name): return QVariant(formattedName()); case static_cast<int>(Person::Role::Organization): return QVariant(organization()); @@ -530,12 +531,15 @@ QVariant Person::roleData(int role) const return QVariant(department()); case static_cast<int>(Person::Role::PreferredEmail): return QVariant(preferredEmail()); + case static_cast<int>(Ring::Role::FormattedLastUsed): case static_cast<int>(Person::Role::FormattedLastUsed): return QVariant(HistoryTimeCategoryModel::timeToHistoryCategory(lastUsedTime())); case static_cast<int>(Person::Role::IndexedLastUsed): return QVariant(static_cast<int>(HistoryTimeCategoryModel::timeToHistoryConst(lastUsedTime()))); + case static_cast<int>(Ring::Role::Object): case static_cast<int>(Person::Role::Object): return QVariant::fromValue(const_cast<Person*>(this)); + case static_cast<int>(Ring::Role::LastUsed): case static_cast<int>(Person::Role::DatedLastUsed): return QVariant(QDateTime::fromTime_t( lastUsedTime())); case static_cast<int>(Person::Role::Filter): diff --git a/src/person.h b/src/person.h index 6e0bd5f8291d7e3749ce56100d29b31e56ada564..eeb89c5f184cfd111f4093b29387e69f5621e762 100644 --- a/src/person.h +++ b/src/person.h @@ -24,6 +24,7 @@ #include <itembase.h> //Ring +#include "itemdataroles.h" class ContactMethod; class PersonPrivate; class AddressPrivate; @@ -47,16 +48,16 @@ class LIB_EXPORT Person : public ItemBase public: enum class Role { - Organization = 100, - Group = 101, - Department = 102, - PreferredEmail = 103, - FormattedLastUsed = 104, - IndexedLastUsed = 105, - DatedLastUsed = 106, - Object = 108, - Filter = 200, //All roles, all at once - DropState = 300, //State for drag and drop + Organization = static_cast<int>(Ring::Role::UserRole) + 100, + Group , + Department , + PreferredEmail , + FormattedLastUsed , + IndexedLastUsed , + DatedLastUsed , + Object , + Filter , //All roles, all at once + DropState = static_cast<int>(Ring::Role::DropState), //State for drag and drop }; ///@enum Encoding How to decode the person content payload @@ -204,4 +205,3 @@ private: }; Q_DECLARE_METATYPE(Person*) -