diff --git a/src/call.h b/src/call.h index a94d7841392a473c0a1340bd3b85af777c08e29b..89b3b72d4a20094284bbd60a61d5ef256c52155b 100644 --- a/src/call.h +++ b/src/call.h @@ -127,20 +127,20 @@ public: ///Possible call states enum class State : unsigned int{ - INCOMING = 0, /** Ringing incoming call */ - RINGING = 1, /** Ringing outgoing call */ - CURRENT = 2, /** Call to which the user can speak and hear */ - DIALING = 3, /** Call which numbers are being added by the user */ - HOLD = 4, /** Call is on hold */ - FAILURE = 5, /** Call has failed */ - BUSY = 6, /** Call is busy */ - TRANSFERRED = 7, /** Call is being transferred. During this state, the user can enter the new number. */ - TRANSF_HOLD = 8, /** Call is on hold for transfer */ - OVER = 9, /** Call is over and should not be used */ - ERROR = 10,/** This state should never be reached */ - CONFERENCE = 11,/** This call is the current conference*/ - CONFERENCE_HOLD = 12,/** This call is a conference on hold*/ - INITIALIZATION = 13,/** The call have been placed, but the peer hasn't confirmed yet */ + INCOMING = 0, /*!< Ringing incoming call */ + RINGING = 1, /*!< Ringing outgoing call */ + CURRENT = 2, /*!< Call to which the user can speak and hear */ + DIALING = 3, /*!< Call which numbers are being added by the user */ + HOLD = 4, /*!< Call is on hold */ + FAILURE = 5, /*!< Call has failed */ + BUSY = 6, /*!< Call is busy */ + TRANSFERRED = 7, /*!< Call is being transferred. During this state, the user can enter the new number. */ + TRANSF_HOLD = 8, /*!< Call is on hold for transfer */ + OVER = 9, /*!< Call is over and should not be used */ + ERROR = 10,/*!< This state should never be reached */ + CONFERENCE = 11,/*!< This call is the current conference*/ + CONFERENCE_HOLD = 12,/*!< This call is a conference on hold*/ + INITIALIZATION = 13,/*!< The call have been placed, but the peer hasn't confirmed yet */ __COUNT, }; Q_ENUMS(State) @@ -152,7 +152,7 @@ public: * * SFLPhone-KDE will keep support for at least a year */ - enum class LegacyHistoryState : int //FIXME remove + enum class LegacyHistoryState : int //DEPRECATED remove { INCOMING, OUTGOING, @@ -162,16 +162,16 @@ public: ///@enum Direction If the user have been called or have called enum class Direction : int { - INCOMING, /** Someone has called */ - OUTGOING, /** The user called someone */ + INCOMING, /*!< Someone has called */ + OUTGOING, /*!< The user called someone */ }; Q_ENUMS(Direction) ///Is the call between one or more participants enum class Type { - CALL , /** A simple call */ - CONFERENCE, /** A composition of other calls */ - HISTORY , /** A call from a previous session */ + CALL , /*!< A simple call */ + CONFERENCE, /*!< A composition of other calls */ + HISTORY , /*!< A call from a previous session */ }; /** @enum Call::DaemonState @@ -179,12 +179,12 @@ public: */ enum class DaemonState : unsigned int { - RINGING = 0, /** Ringing outgoing or incoming call */ - CURRENT = 1, /** Call to which the user can speak and hear */ - BUSY = 2, /** Call is busy */ - HOLD = 3, /** Call is on hold */ - HUNG_UP = 4, /** Call is over */ - FAILURE = 5, /** Call has failed */ + RINGING = 0, /*!< Ringing outgoing or incoming call */ + CURRENT = 1, /*!< Call to which the user can speak and hear */ + BUSY = 2, /*!< Call is busy */ + HOLD = 3, /*!< Call is on hold */ + HUNG_UP = 4, /*!< Call is over */ + FAILURE = 5, /*!< Call has failed */ __COUNT, }; @@ -193,11 +193,11 @@ public: */ enum class Action : unsigned int { - ACCEPT = 0, /** Accept, create or place call or place transfer */ - REFUSE = 1, /** Red button, refuse or hang up */ - TRANSFER = 2, /** Put into or out of transfer mode*/ - HOLD = 3, /** Hold or unhold the call */ - RECORD = 4, /** Enable or disable recording */ + ACCEPT = 0, /*!< Accept, create or place call or place transfer */ + REFUSE = 1, /*!< Red button, refuse or hang up */ + TRANSFER = 2, /*!< Put into or out of transfer mode*/ + HOLD = 3, /*!< Hold or unhold the call */ + RECORD = 4, /*!< Enable or disable recording */ __COUNT, }; @@ -208,9 +208,9 @@ public: * as BUSY OR FAILURE while also finished */ enum class LifeCycleState { - INITIALIZATION = 0, /** Anything before the media transfer start */ - PROGRESS = 1, /** The peers are in communication (or hold) */ - FINISHED = 2, /** Everything is over, there is no going back */ + INITIALIZATION = 0, /*!< Anything before the media transfer start */ + PROGRESS = 1, /*!< The peers are in communication (or hold) */ + FINISHED = 2, /*!< Everything is over, there is no going back */ __COUNT }; @@ -327,7 +327,7 @@ public: private: explicit Call(const QString& confId, const QString& account); - Call(Call::State startState, const QString& callId, const QString& peerName = QString(), PhoneNumber* number = nullptr, Account* account = nullptr); + Call(Call::State startState, const QString& callId, const QString& peerName = QString(), PhoneNumber* number = nullptr, Account* account = nullptr); //TODO MOVE TO PRIVATE QScopedPointer<CallPrivate> d_ptr; Q_DECLARE_PRIVATE(Call) diff --git a/src/callmodel.cpp b/src/callmodel.cpp index f8c56a578d395e1a73360b158af5513af5a23a41..829c45bc937fbc5f622944c5e05aef8da670b636 100644 --- a/src/callmodel.cpp +++ b/src/callmodel.cpp @@ -238,7 +238,7 @@ int CallModel::size() } ///Return the action call list - CallList CallModel::getCallList() + CallList CallModel::getActiveCalls() { CallList callList; #pragma GCC diagnostic ignored "-Wshadow" @@ -255,7 +255,7 @@ int CallModel::size() } //getCallList ///Return all conferences -CallList CallModel::getConferenceList() +CallList CallModel::getActiveConferences() { CallList confList; @@ -366,7 +366,7 @@ Call* CallModel::dialingCall(const QString& peerName, Account* account) { //Having multiple dialing calls could be supported, but for now we decided not to //handle this corner case as it will create issues of its own - foreach (Call* call, getCallList()) { + foreach (Call* call, getActiveCalls()) { if (call->state() == Call::State::DIALING) return call; } diff --git a/src/callmodel.h b/src/callmodel.h index 191b7b3a6f6011525ea92f4931d3abfc9b0fa6bc..4376ee725eefbaeb204b3974990513b855c0675c 100644 --- a/src/callmodel.h +++ b/src/callmodel.h @@ -75,8 +75,8 @@ class LIB_EXPORT CallModel : public QAbstractItemModel //Getters Q_INVOKABLE bool isValid (); Q_INVOKABLE int size (); - Q_INVOKABLE CallList getCallList (); - Q_INVOKABLE CallList getConferenceList (); + Q_INVOKABLE CallList getActiveCalls (); + Q_INVOKABLE CallList getActiveConferences(); Q_INVOKABLE int acceptedPayloadTypes(); Q_INVOKABLE bool hasConference () const; @@ -88,7 +88,7 @@ class LIB_EXPORT CallModel : public QAbstractItemModel virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const; virtual Qt::ItemFlags flags ( const QModelIndex& index ) const; - virtual int columnCount ( const QModelIndex& parent = QModelIndex() ) const __attribute__ ((const)); + virtual int columnCount ( const QModelIndex& parent = QModelIndex() ) const; virtual QModelIndex parent ( const QModelIndex& index ) const; virtual QModelIndex index ( int row, int column, const QModelIndex& parent=QModelIndex()) const; virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; diff --git a/src/contact.h b/src/contact.h index ff72c500246adbb0d09c5a4e36943e067fb697a7..6d4f5579b9fbfdc713233e3f4f3d31fcedd95b4f 100644 --- a/src/contact.h +++ b/src/contact.h @@ -52,7 +52,7 @@ class LIB_EXPORT Contact : public QObject { public: friend class ContactPrivate; - class PhoneNumbers : public QVector<PhoneNumber*>, public CategorizedCompositeNode { + class PhoneNumbers : public QVector<PhoneNumber*>, public CategorizedCompositeNode { //TODO private public: virtual QObject* getSelf() const __attribute__ ((const)); explicit PhoneNumbers(Contact* parent); @@ -136,7 +136,7 @@ public: bool operator==(const Contact& other) const; private Q_SLOTS: - void slotPresenceChanged(); + void slotPresenceChanged(); //TODO remove Q_SIGNALS: void presenceChanged( PhoneNumber* ); diff --git a/src/historymodel.h b/src/historymodel.h index 3a8a4e87f8e6aa32650436f31b05108ce1e594eb..00660cb4d1180640871d5a99503403cb4057281f 100644 --- a/src/historymodel.h +++ b/src/historymodel.h @@ -36,7 +36,7 @@ typedef QList<Call*> CallList; class HistoryItemNode; class AbstractHistoryBackend; class HistoryModelPrivate; - +//TODO split ASAP ///HistoryModel: History call manager class LIB_EXPORT HistoryModel : public QAbstractItemModel, public CommonBackendManagerInterface<AbstractHistoryBackend> { #pragma GCC diagnostic push @@ -80,7 +80,7 @@ public: virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const override; virtual Qt::ItemFlags flags ( const QModelIndex& index ) const override; - virtual int columnCount ( const QModelIndex& parent = QModelIndex() ) const override __attribute__ ((const)); + virtual int columnCount ( const QModelIndex& parent = QModelIndex() ) const override; virtual QModelIndex parent ( const QModelIndex& index ) const override; virtual QModelIndex index ( int row, int column, const QModelIndex& parent=QModelIndex()) const override; virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; diff --git a/src/imconversationmanager.cpp b/src/imconversationmanager.cpp index 4780e188f1770cb989bb9d44e3965e5d332f4fec..7b13b90a3e4bbc06800ae477173d73fc2121c3b9 100644 --- a/src/imconversationmanager.cpp +++ b/src/imconversationmanager.cpp @@ -26,6 +26,26 @@ IMConversationManager* IMConversationManager::m_spInstance = nullptr; +class IMConversationManagerPrivate : public QObject +{ + Q_OBJECT +public: + IMConversationManagerPrivate(IMConversationManager* parent); + + //Attributes + QHash<QString,InstantMessagingModel*> m_lModels; + +private: + IMConversationManager* q_ptr; + +private Q_SLOTS: + void newMessage(const QString& callId, const QString& from, const QString& message); +}; + +IMConversationManagerPrivate::IMConversationManagerPrivate(IMConversationManager* parent) : QObject(parent), q_ptr(parent) +{ +} + ///Signleton IMConversationManager* IMConversationManager::instance() { @@ -35,26 +55,27 @@ IMConversationManager* IMConversationManager::instance() return m_spInstance; } -void IMConversationManager::init() { - instance(); +IMConversationManager::~IMConversationManager() +{ + delete d_ptr; } ///Constructor -IMConversationManager::IMConversationManager() : QObject(nullptr) +IMConversationManager::IMConversationManager() : QObject(nullptr), d_ptr(new IMConversationManagerPrivate(this)) { CallManagerInterface& callManager = DBus::CallManager::instance(); - connect(&callManager, SIGNAL(incomingMessage(QString,QString,QString)), this, SLOT(newMessage(QString,QString,QString))); + connect(&callManager, SIGNAL(incomingMessage(QString,QString,QString)), d_ptr, SLOT(newMessage(QString,QString,QString))); } ///Called when a new message is incoming -void IMConversationManager::newMessage(QString callId, QString from, QString message) +void IMConversationManagerPrivate::newMessage(const QString& callId, const QString& from, const QString& message) { if (!m_lModels[callId] && CallModel::instance()) { Call* call = CallModel::instance()->getCall(callId); if (call) { qDebug() << "Creating messaging model for call" << callId; m_lModels[callId] = new InstantMessagingModel(call); - emit newMessagingModel(call,m_lModels[callId]); + emit q_ptr->newMessagingModel(call,m_lModels[callId]); m_lModels[callId]->d_ptr->addIncommingMessage(from,message); } } @@ -66,9 +87,11 @@ void IMConversationManager::newMessage(QString callId, QString from, QString mes ///Singleton InstantMessagingModel* IMConversationManager::getModel(Call* call) { const QString key = call->id(); - if (!m_lModels[key]) { - m_lModels[key] = new InstantMessagingModel(call); - emit newMessagingModel(call,m_lModels[key]); + if (!d_ptr->m_lModels[key]) { + d_ptr->m_lModels[key] = new InstantMessagingModel(call); + emit newMessagingModel(call,d_ptr->m_lModels[key]); } - return m_lModels[key]; -} \ No newline at end of file + return d_ptr->m_lModels[key]; +} + +#include <imconversationmanager.moc> diff --git a/src/imconversationmanager.h b/src/imconversationmanager.h index 95362241d5d3527c1c6bfdd1be283d76ba5bbf01..22d45c0a992c639b257ca61020937bd52e424289 100644 --- a/src/imconversationmanager.h +++ b/src/imconversationmanager.h @@ -24,6 +24,7 @@ //SFLPhone class Call; class InstantMessagingModel; +class IMConversationManagerPrivate; ///Manager for all IM conversations class LIB_EXPORT IMConversationManager : public QObject @@ -36,25 +37,21 @@ public: //Singleton static IMConversationManager* instance(); - static void init(); //Getter InstantMessagingModel* getModel(Call* call); private: //Constructor explicit IMConversationManager(); + ~IMConversationManager(); - //Attributes - QHash<QString,InstantMessagingModel*> m_lModels; + IMConversationManagerPrivate* d_ptr; + Q_DECLARE_PRIVATE(IMConversationManager) //Static attributes static IMConversationManager* m_spInstance; -private Q_SLOTS: - void newMessage(QString callId, QString from, QString message); - - Q_SIGNALS: ///Emitted when a new message is available void newMessagingModel(Call*,InstantMessagingModel*); diff --git a/src/instantmessagingmodel.h b/src/instantmessagingmodel.h index 9d4c3fe5a23f198726b2ffe68ee51ff3328bb23c..bd1ab58ce3e4d8b9cdf6bb9b52fe5287556da85a 100644 --- a/src/instantmessagingmodel.h +++ b/src/instantmessagingmodel.h @@ -36,6 +36,8 @@ class LIB_EXPORT InstantMessagingModel : public QAbstractListModel #pragma GCC diagnostic pop friend class Call; friend class IMConversationManager; + friend class IMConversationManagerPrivate; + public: //Role const enum Role { diff --git a/src/itembackendmodel.cpp b/src/itembackendmodel.cpp index 50ec1e3b7fdb8339d5b881a7225d648324091c0f..1b5e4ad0a822cee7583fdbb4eacd4a4df9f6842f 100644 --- a/src/itembackendmodel.cpp +++ b/src/itembackendmodel.cpp @@ -21,21 +21,55 @@ #include "visitors/itemmodelstateserializationvisitor.h" #include "abstractitembackendmodelextension.h" -CommonItemBackendModel::CommonItemBackendModel(QObject* parent) : QAbstractTableModel(parent) +class CommonItemBackendModelPrivate : public QObject { - connect(ContactModel::instance(),SIGNAL(newBackendAdded(AbstractContactBackend*)),this,SLOT(slotUpdate())); + Q_OBJECT +public: + CommonItemBackendModelPrivate(CommonItemBackendModel* parent); + + /* + * This is not very efficient, it doesn't really have to be given the low + * volume. If it ever have to scale, a better mapToSource using persistent + * index have to be implemented. + */ + struct ProxyItem { + ProxyItem() : parent(nullptr),col(1),row(0),backend(nullptr){} + int row; + int col; + AbstractContactBackend* backend; + ProxyItem* parent; + QVector<ProxyItem*> m_Children; + }; + QHash<AbstractContactBackend*,ProxyItem*> m_hBackendsNodes; + QVector<ProxyItem*> m_lTopLevelBackends; + QVector<AbstractItemBackendModelExtension*> m_lExtensions; + +private: + CommonItemBackendModel* q_ptr; + +private Q_SLOTS: + void slotUpdate(); + void slotExtensionDataChanged(const QModelIndex& idx); +}; + +CommonItemBackendModelPrivate::CommonItemBackendModelPrivate(CommonItemBackendModel* parent) : QObject(parent),q_ptr(parent) +{} + +CommonItemBackendModel::CommonItemBackendModel(QObject* parent) : QAbstractTableModel(parent), d_ptr(new CommonItemBackendModelPrivate(this)) +{ + connect(ContactModel::instance(),SIGNAL(newBackendAdded(AbstractContactBackend*)),d_ptr.data(),SLOT(slotUpdate())); load(); } CommonItemBackendModel::~CommonItemBackendModel() { - while (m_lTopLevelBackends.size()) { - ProxyItem* item = m_lTopLevelBackends[0]; - m_lTopLevelBackends.remove(0); + while (d_ptr->m_lTopLevelBackends.size()) { + CommonItemBackendModelPrivate::ProxyItem* item = d_ptr->m_lTopLevelBackends[0]; + d_ptr->m_lTopLevelBackends.remove(0); while (item->m_Children.size()) { //FIXME I don't think it can currently happen, but there may be //more than 2 levels. - ProxyItem* item2 = item->m_Children[0]; + CommonItemBackendModelPrivate::ProxyItem* item2 = item->m_Children[0]; item->m_Children.remove(0); delete item2; } @@ -46,10 +80,10 @@ CommonItemBackendModel::~CommonItemBackendModel() QVariant CommonItemBackendModel::data (const QModelIndex& idx, int role) const { if (idx.isValid()) { - ProxyItem* item = static_cast<ProxyItem*>(idx.internalPointer()); + CommonItemBackendModelPrivate::ProxyItem* item = static_cast<CommonItemBackendModelPrivate::ProxyItem*>(idx.internalPointer()); if (idx.column() > 0) - return m_lExtensions[idx.column()-1]->data(item->backend,idx,role); + return d_ptr->m_lExtensions[idx.column()-1]->data(item->backend,idx,role); switch(role) { case Qt::DisplayRole: @@ -67,7 +101,7 @@ QVariant CommonItemBackendModel::data (const QModelIndex& idx, int role) const }; } //else { -// ProxyItem* item = static_cast<ProxyItem*>(idx.internalPointer()); +// CommonItemBackendModelPrivate::ProxyItem* item = static_cast<CommonItemBackendModelPrivate::ProxyItem*>(idx.internalPointer()); // return item->model->data(item->model->index(item->row,item->col)); //} return QVariant(); @@ -86,7 +120,7 @@ int CommonItemBackendModel::rowCount (const QModelIndex& parent) const return result; } else { - ProxyItem* item = static_cast<ProxyItem*>(parent.internalPointer()); + CommonItemBackendModelPrivate::ProxyItem* item = static_cast<CommonItemBackendModelPrivate::ProxyItem*>(parent.internalPointer()); return item->backend->childrenBackends().size(); } } @@ -94,17 +128,17 @@ int CommonItemBackendModel::rowCount (const QModelIndex& parent) const int CommonItemBackendModel::columnCount (const QModelIndex& parent) const { Q_UNUSED(parent) - return 1+m_lExtensions.size(); + return 1+d_ptr->m_lExtensions.size(); } Qt::ItemFlags CommonItemBackendModel::flags(const QModelIndex& idx) const { if (!idx.isValid()) return 0; - ProxyItem* item = static_cast<ProxyItem*>(idx.internalPointer()); + CommonItemBackendModelPrivate::ProxyItem* item = static_cast<CommonItemBackendModelPrivate::ProxyItem*>(idx.internalPointer()); if (idx.column() > 0) { //Make sure the cell is disabled if the row is - Qt::ItemFlags f = m_lExtensions[idx.column()-1]->flags(item->backend,idx); + Qt::ItemFlags f = d_ptr->m_lExtensions[idx.column()-1]->flags(item->backend,idx); return (((f&Qt::ItemIsEnabled)&&(!item->backend->isEnabled()))?f^Qt::ItemIsEnabled:f); } const bool checkable = item->backend->supportedFeatures() & (AbstractContactBackend::SupportedFeatures::ENABLEABLE | @@ -118,12 +152,12 @@ bool CommonItemBackendModel::setData (const QModelIndex& idx, const QVariant &va Q_UNUSED(value) Q_UNUSED(role) if (idx.isValid() && idx.column() > 0) { - ProxyItem* item = static_cast<ProxyItem*>(idx.internalPointer()); - return m_lExtensions[idx.column()-1]->setData(item->backend,idx,value,role); + CommonItemBackendModelPrivate::ProxyItem* item = static_cast<CommonItemBackendModelPrivate::ProxyItem*>(idx.internalPointer()); + return d_ptr->m_lExtensions[idx.column()-1]->setData(item->backend,idx,value,role); } if (role == Qt::CheckStateRole && idx.column() == 0) { - ProxyItem* item = static_cast<ProxyItem*>(idx.internalPointer()); + CommonItemBackendModelPrivate::ProxyItem* item = static_cast<CommonItemBackendModelPrivate::ProxyItem*>(idx.internalPointer()); if (item) { const bool old = item->backend->isEnabled(); ItemModelStateSerializationVisitor::instance()->setChecked(item->backend,value==Qt::Checked); @@ -140,7 +174,7 @@ bool CommonItemBackendModel::setData (const QModelIndex& idx, const QVariant &va QModelIndex CommonItemBackendModel::parent( const QModelIndex& idx ) const { if (idx.isValid()) { - ProxyItem* item = static_cast<ProxyItem*>(idx.internalPointer()); + CommonItemBackendModelPrivate::ProxyItem* item = static_cast<CommonItemBackendModelPrivate::ProxyItem*>(idx.internalPointer()); if (!item->parent) return QModelIndex(); return createIndex(item->row,item->col,item->parent); @@ -151,12 +185,12 @@ QModelIndex CommonItemBackendModel::parent( const QModelIndex& idx ) const QModelIndex CommonItemBackendModel::index( int row, int column, const QModelIndex& parent ) const { if (parent.isValid()) { - ProxyItem* parentItem = static_cast<ProxyItem*>(parent.internalPointer()); - ProxyItem* item = nullptr; + CommonItemBackendModelPrivate::ProxyItem* parentItem = static_cast<CommonItemBackendModelPrivate::ProxyItem*>(parent.internalPointer()); + CommonItemBackendModelPrivate::ProxyItem* item = nullptr; if (row < parentItem->m_Children.size()) item = parentItem->m_Children[row]; else { - item = new ProxyItem(); + item = new CommonItemBackendModelPrivate::ProxyItem(); item->parent = parentItem; item->backend = static_cast<AbstractContactBackend*>(parentItem->backend->childrenBackends()[row]); parentItem->m_Children << item; @@ -166,13 +200,13 @@ QModelIndex CommonItemBackendModel::index( int row, int column, const QModelInde return createIndex(row,column,item); } else { //Top level - ProxyItem* item = nullptr; - if (row < m_lTopLevelBackends.size()) - item = m_lTopLevelBackends[row]; + CommonItemBackendModelPrivate::ProxyItem* item = nullptr; + if (row < d_ptr->m_lTopLevelBackends.size()) + item = d_ptr->m_lTopLevelBackends[row]; else { - item = new ProxyItem(); + item = new CommonItemBackendModelPrivate::ProxyItem(); item->backend = ContactModel::instance()->backends()[row]; - const_cast<CommonItemBackendModel*>(this)->m_lTopLevelBackends << item; + d_ptr->m_lTopLevelBackends << item; } item->row = row; item->col = column; @@ -180,9 +214,9 @@ QModelIndex CommonItemBackendModel::index( int row, int column, const QModelInde } } -void CommonItemBackendModel::slotUpdate() +void CommonItemBackendModelPrivate::slotUpdate() { - emit layoutChanged(); + emit q_ptr->layoutChanged(); } QVariant CommonItemBackendModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -190,7 +224,7 @@ QVariant CommonItemBackendModel::headerData(int section, Qt::Orientation orienta Q_UNUSED(section) if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { if (section > 0) - return m_lExtensions[section-1]->headerName(); + return d_ptr->m_lExtensions[section-1]->headerName(); return QVariant(tr("Name")); } return QVariant(); @@ -201,7 +235,7 @@ bool CommonItemBackendModel::save() if (ItemModelStateSerializationVisitor::instance()) { //Load newly enabled backends - foreach(ProxyItem* top ,m_lTopLevelBackends) { + foreach(CommonItemBackendModelPrivate::ProxyItem* top, d_ptr->m_lTopLevelBackends) { AbstractContactBackend* current = top->backend; bool check = ItemModelStateSerializationVisitor::instance()->isChecked(current); bool wasChecked = current->isEnabled(); @@ -211,7 +245,7 @@ bool CommonItemBackendModel::save() current->enable(false); //TODO implement real tree digging - foreach(ProxyItem* leaf ,top->m_Children) { + foreach(CommonItemBackendModelPrivate::ProxyItem* leaf ,top->m_Children) { current = leaf->backend; check = ItemModelStateSerializationVisitor::instance()->isChecked(current); wasChecked = current->isEnabled(); @@ -240,19 +274,20 @@ AbstractContactBackend* CommonItemBackendModel::backendAt(const QModelIndex& ind { if (!index.isValid()) return nullptr; - return static_cast<ProxyItem*>(index.internalPointer())->backend; + return static_cast<CommonItemBackendModelPrivate::ProxyItem*>(index.internalPointer())->backend; } void CommonItemBackendModel::addExtension(AbstractItemBackendModelExtension* extension) { emit layoutAboutToBeChanged(); - m_lExtensions << extension; - connect(extension,SIGNAL(dataChanged(QModelIndex)),this,SLOT(slotExtensionDataChanged(QModelIndex))); + d_ptr->m_lExtensions << extension; + connect(extension,SIGNAL(dataChanged(QModelIndex)),d_ptr.data(),SLOT(slotExtensionDataChanged(QModelIndex))); emit layoutChanged(); } -void CommonItemBackendModel::slotExtensionDataChanged(const QModelIndex& idx) +void CommonItemBackendModelPrivate::slotExtensionDataChanged(const QModelIndex& idx) { - emit dataChanged(idx,idx); + emit q_ptr->dataChanged(idx,idx); } +#include <itembackendmodel.moc> diff --git a/src/itembackendmodel.h b/src/itembackendmodel.h index 1d71403dce2e840cf4c11dd0da06a674165c0d6b..26187fc1bf164e3d974dd1a743fd0e42ad392f20 100644 --- a/src/itembackendmodel.h +++ b/src/itembackendmodel.h @@ -30,22 +30,23 @@ //SFLPhone class AbstractItemBackendModelExtension; +class CommonItemBackendModelPrivate; class LIB_EXPORT CommonItemBackendModel : public QAbstractTableModel { Q_OBJECT public: explicit CommonItemBackendModel(QObject* parent = nullptr); - ~CommonItemBackendModel(); + virtual ~CommonItemBackendModel(); - QVariant data (const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount (const QModelIndex& parent = QModelIndex() ) const; - virtual int columnCount (const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags (const QModelIndex& index ) const; - virtual QVariant headerData (int section, Qt::Orientation orientation, int role ) const; - virtual bool setData (const QModelIndex& index, const QVariant &value, int role ); - virtual QModelIndex parent ( const QModelIndex& index ) const; - virtual QModelIndex index ( int row, int column, const QModelIndex& parent=QModelIndex()) const; + virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount (const QModelIndex& parent = QModelIndex() ) const override; + virtual int columnCount (const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags (const QModelIndex& index ) const override; + virtual QVariant headerData (int section, Qt::Orientation orientation, int role ) const override; + virtual bool setData (const QModelIndex& index, const QVariant &value, int role ) override; + virtual QModelIndex parent ( const QModelIndex& index ) const override; + virtual QModelIndex index ( int row, int column, const QModelIndex& parent=QModelIndex()) const override; AbstractContactBackend* backendAt(const QModelIndex& index); @@ -54,30 +55,12 @@ public: bool save(); bool load(); -private Q_SLOTS: - void slotUpdate(); - void slotExtensionDataChanged(const QModelIndex& idx); - Q_SIGNALS: void checkStateChanged(); private: - /* - * This is not very efficient, it doesn't really have to be given the low - * volume. If it ever have to scale, a better mapToSource using persistent - * index have to be implemented. - */ - struct ProxyItem { - ProxyItem() : parent(nullptr),col(1),row(0),backend(nullptr){} - int row; - int col; - AbstractContactBackend* backend; - ProxyItem* parent; - QVector<ProxyItem*> m_Children; - }; - QHash<AbstractContactBackend*,ProxyItem*> m_hBackendsNodes; - QVector<ProxyItem*> m_lTopLevelBackends; - QVector<AbstractItemBackendModelExtension*> m_lExtensions; + QScopedPointer<CommonItemBackendModelPrivate> d_ptr; + Q_DECLARE_PRIVATE(CommonItemBackendModel) }; diff --git a/src/lastusednumbermodel.cpp b/src/lastusednumbermodel.cpp index 1331aee57fbeb5050477720fd4361c7835ef428b..7431721daa213f5c21237a9edd797d20f220bc57 100644 --- a/src/lastusednumbermodel.cpp +++ b/src/lastusednumbermodel.cpp @@ -22,6 +22,7 @@ LastUsedNumberModel* LastUsedNumberModel::m_spInstance = nullptr; + struct ChainedPhoneNumber { ChainedPhoneNumber(PhoneNumber* n) : m_pPrevious(nullptr),m_pNext(nullptr),m_pSelf(n){} ChainedPhoneNumber* m_pPrevious; @@ -29,9 +30,33 @@ struct ChainedPhoneNumber { PhoneNumber* m_pSelf; }; -LastUsedNumberModel::LastUsedNumberModel() : QAbstractListModel(),m_pFirstNode(nullptr),m_IsValid(false) +class LastUsedNumberModelPrivate +{ +public: + LastUsedNumberModelPrivate(); + + //Const + constexpr static const int MAX_ITEM = 15; + + //Attributes + ChainedPhoneNumber* m_pFirstNode; + QHash<PhoneNumber*,ChainedPhoneNumber*> m_hNumbers; + bool m_IsValid; + ChainedPhoneNumber* m_lLastNumbers[MAX_ITEM]; +}; + +LastUsedNumberModelPrivate::LastUsedNumberModelPrivate():m_pFirstNode(nullptr),m_IsValid(false) +{} + +LastUsedNumberModel::LastUsedNumberModel() : QAbstractListModel(),d_ptr(new LastUsedNumberModelPrivate()) +{ + for (int i=0;i<LastUsedNumberModelPrivate::MAX_ITEM;i++) + d_ptr->m_lLastNumbers[i] = nullptr; +} + +LastUsedNumberModel::~LastUsedNumberModel() { - for (int i=0;i<MAX_ITEM;i++) m_lLastNumbers[i] = nullptr; + delete d_ptr; } LastUsedNumberModel* LastUsedNumberModel::instance() @@ -46,16 +71,15 @@ LastUsedNumberModel* LastUsedNumberModel::instance() void LastUsedNumberModel::addCall(Call* call) { PhoneNumber* number = call->peerPhoneNumber(); - ChainedPhoneNumber* node = m_hNumbers[number]; - if (!number || ( node && m_pFirstNode == node) ) { - + ChainedPhoneNumber* node = d_ptr->m_hNumbers[number]; + if (!number || ( node && d_ptr->m_pFirstNode == node) ) { //TODO enable threaded numbers now return; } if (!node) { node = new ChainedPhoneNumber(number); - m_hNumbers[number] = node; + d_ptr->m_hNumbers[number] = node; } else { if (node->m_pPrevious) @@ -63,12 +87,12 @@ void LastUsedNumberModel::addCall(Call* call) if (node->m_pNext) node->m_pNext->m_pPrevious = node->m_pPrevious; } - if (m_pFirstNode) { - m_pFirstNode->m_pPrevious = node; - node->m_pNext = m_pFirstNode; + if (d_ptr->m_pFirstNode) { + d_ptr->m_pFirstNode->m_pPrevious = node; + node->m_pNext = d_ptr->m_pFirstNode; } - m_pFirstNode = node; - m_IsValid = false; + d_ptr->m_pFirstNode = node; + d_ptr->m_IsValid = false; emit layoutChanged(); } @@ -77,19 +101,19 @@ QVariant LastUsedNumberModel::data( const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); - if (!m_IsValid) { - ChainedPhoneNumber* current = m_pFirstNode; - for (int i=0;i<MAX_ITEM;i++) { //Can only grow, no need to clear - const_cast<LastUsedNumberModel*>(this)->m_lLastNumbers[i] = current; + if (!d_ptr->m_IsValid) { + ChainedPhoneNumber* current = d_ptr->m_pFirstNode; + for (int i=0;i<LastUsedNumberModelPrivate::MAX_ITEM;i++) { //Can only grow, no need to clear + d_ptr->m_lLastNumbers[i] = current; current = current->m_pNext; if (!current) break; } - const_cast<LastUsedNumberModel*>(this)->m_IsValid = true; + d_ptr->m_IsValid = true; } switch (role) { case Qt::DisplayRole: { - return m_lLastNumbers[index.row()]->m_pSelf->uri(); + return d_ptr->m_lLastNumbers[index.row()]->m_pSelf->uri(); } }; return QVariant(); @@ -99,7 +123,7 @@ int LastUsedNumberModel::rowCount( const QModelIndex& parent) const { if (parent.isValid()) return 0; - return m_hNumbers.size() < LastUsedNumberModel::MAX_ITEM?m_hNumbers.size():LastUsedNumberModel::MAX_ITEM; + return d_ptr->m_hNumbers.size() < LastUsedNumberModelPrivate::MAX_ITEM?d_ptr->m_hNumbers.size():LastUsedNumberModelPrivate::MAX_ITEM; } Qt::ItemFlags LastUsedNumberModel::flags( const QModelIndex& index) const diff --git a/src/lastusednumbermodel.h b/src/lastusednumbermodel.h index ec0eee44d785b017bf5efbd942d100ea62ec079c..9efbe3a9ca0b2d45126123518bbf033bce202995 100644 --- a/src/lastusednumbermodel.h +++ b/src/lastusednumbermodel.h @@ -22,11 +22,13 @@ #include <QtCore/QAbstractListModel> -struct ChainedPhoneNumber; class Call; class PhoneNumber; -class LIB_EXPORT LastUsedNumberModel : public QAbstractListModel { +class LastUsedNumberModelPrivate; + +class LIB_EXPORT LastUsedNumberModel : public QAbstractListModel +{ Q_OBJECT public: @@ -34,25 +36,21 @@ public: static LastUsedNumberModel* instance(); //Model functions - QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; - int rowCount ( const QModelIndex& parent = QModelIndex() ) const; - Qt::ItemFlags flags ( const QModelIndex& index ) const; - virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) ; + virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags ( const QModelIndex& index ) const override; + virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override; //Mutator - void addCall(Call* call); -private: - //Const - static const int MAX_ITEM = 15; + Q_INVOKABLE void addCall(Call* call); +private: //Private constructor LastUsedNumberModel(); + ~LastUsedNumberModel(); - //Attributes - ChainedPhoneNumber* m_pFirstNode; - QHash<PhoneNumber*,ChainedPhoneNumber*> m_hNumbers; - bool m_IsValid; - ChainedPhoneNumber* m_lLastNumbers[MAX_ITEM]; + LastUsedNumberModelPrivate* d_ptr; + Q_DECLARE_PRIVATE(LastUsedNumberModel) //Static attributes static LastUsedNumberModel* m_spInstance; diff --git a/src/legacyhistorybackend.h b/src/legacyhistorybackend.h index e6d107df746f656472f8b608b27d5acf74214d85..8e5dc301bb7239e59f145fd65f974cd8b654c8f6 100644 --- a/src/legacyhistorybackend.h +++ b/src/legacyhistorybackend.h @@ -21,33 +21,34 @@ #include "abstractitembackend.h" +/// @deprecated Remove once the daemon drop configurationmanager::getHistory() class LIB_EXPORT LegacyHistoryBackend : public AbstractHistoryBackend { public: explicit LegacyHistoryBackend(QObject* parent = nullptr); virtual ~LegacyHistoryBackend(); - virtual bool load(); - virtual bool reload(); - virtual bool save(const Call* call); - virtual bool append(const Call* item); + virtual bool load() override; + virtual bool reload() override; + virtual bool save(const Call* call) override; + virtual bool append(const Call* item) override; - virtual QString name () const; - virtual QVariant icon() const; - virtual bool isEnabled() const; - virtual QByteArray id() const; + virtual QString name () const override; + virtual QVariant icon() const override; + virtual bool isEnabled() const override; + virtual QByteArray id() const override; - virtual SupportedFeatures supportedFeatures() const; + virtual SupportedFeatures supportedFeatures() const override; virtual QList<Call*> items() const override; ///Edit 'item', the implementation may be a GUI or somehting else - virtual bool edit( Call* call); + virtual bool edit( Call* call) override; ///Add a new item to the backend - virtual bool addNew( Call* call); + virtual bool addNew( Call* call) override; ///Add a new phone number to an existing item - virtual bool addPhoneNumber( Call* call , PhoneNumber* number ); + virtual bool addPhoneNumber( Call* call , PhoneNumber* number ) override; }; #endif diff --git a/src/numbercategory.cpp b/src/numbercategory.cpp index de5f9fccad16b0eeb7838feef56b7b7c56570d34..e19ea85dd9993b7b2163e9548b329bef6cd36ada 100644 --- a/src/numbercategory.cpp +++ b/src/numbercategory.cpp @@ -24,9 +24,11 @@ NumberCategory::NumberCategory(QObject* parent, const QString& name) : QObject(parent), m_pIcon(nullptr),m_Name(name) { - } +NumberCategory::~NumberCategory() +{} + QVariant NumberCategory::icon(bool isTracked, bool isPresent) const { return PixmapManipulationVisitor::instance()->numberCategoryIcon(m_pIcon,QSize(),isTracked,isPresent); diff --git a/src/numbercategory.h b/src/numbercategory.h index 0bf343e8fd308500f2fbaa1a547a52979fe44d79..d0ca8ed6deb4a9e7aa80660fa5ff9a6e0ed24bf0 100644 --- a/src/numbercategory.h +++ b/src/numbercategory.h @@ -32,7 +32,6 @@ class LIB_EXPORT NumberCategory : public QObject { Q_OBJECT public: friend class NumberCategoryModel; - virtual ~NumberCategory(){} //Getter QVariant icon(bool isTracked = false, bool isPresent = false) const; @@ -44,6 +43,7 @@ public: private: NumberCategory(QObject* parent, const QString& name); + virtual ~NumberCategory(); //Attributes QString m_Name; diff --git a/src/numbercategorymodel.cpp b/src/numbercategorymodel.cpp index 3efb00b12b7b0b9c089b6dfe124d4aa36bff90fc..1cd009a843251c3df335e5c361f0293073a256c7 100644 --- a/src/numbercategorymodel.cpp +++ b/src/numbercategorymodel.cpp @@ -21,11 +21,31 @@ #include "numbercategory.h" NumberCategoryModel* NumberCategoryModel::m_spInstance = nullptr; -NumberCategory* NumberCategoryModel::m_spOther = nullptr; -NumberCategoryModel::NumberCategoryModel(QObject* parent) : QAbstractListModel(parent),m_pVisitor(nullptr) +class NumberCategoryModelPrivate +{ +public: + struct InternalTypeRepresentation { + NumberCategory* category; + int index ; + bool enabled ; + int counter ; + }; + QVector<InternalTypeRepresentation*> m_lCategories; + QHash<int,InternalTypeRepresentation*> m_hByIdx; + QHash<QString,InternalTypeRepresentation*> m_hByName; + static NumberCategory* m_spOther ; +}; + +NumberCategory* NumberCategoryModelPrivate::m_spOther = nullptr; + +NumberCategoryModel::NumberCategoryModel(QObject* parent) : QAbstractListModel(parent),d_ptr(new NumberCategoryModelPrivate()) { - +} + +NumberCategoryModel::~NumberCategoryModel() +{ + delete d_ptr; } //Abstract model member @@ -34,17 +54,17 @@ QVariant NumberCategoryModel::data(const QModelIndex& index, int role) const if (!index.isValid()) return QVariant(); switch (role) { case Qt::DisplayRole: { - const QString name = m_lCategories[index.row()]->category->name(); + const QString name = d_ptr->m_lCategories[index.row()]->category->name(); return name.isEmpty()?tr("Uncategorized"):name; } case Qt::DecorationRole: - return m_lCategories[index.row()]->category->icon();//m_pVisitor->icon(m_lCategories[index.row()]->icon); + return d_ptr->m_lCategories[index.row()]->category->icon();//m_pVisitor->icon(m_lCategories[index.row()]->icon); case Qt::CheckStateRole: - return m_lCategories[index.row()]->enabled?Qt::Checked:Qt::Unchecked; + return d_ptr->m_lCategories[index.row()]->enabled?Qt::Checked:Qt::Unchecked; case Role::INDEX: - return m_lCategories[index.row()]->index; + return d_ptr->m_lCategories[index.row()]->index; case Qt::UserRole: - return 'x'+QString::number(m_lCategories[index.row()]->counter); + return 'x'+QString::number(d_ptr->m_lCategories[index.row()]->counter); } return QVariant(); } @@ -52,19 +72,19 @@ QVariant NumberCategoryModel::data(const QModelIndex& index, int role) const int NumberCategoryModel::rowCount(const QModelIndex& parent) const { if (parent.isValid()) return 0; - return m_lCategories.size(); + return d_ptr->m_lCategories.size(); } Qt::ItemFlags NumberCategoryModel::flags(const QModelIndex& index) const { Q_UNUSED(index) - return (m_lCategories[index.row()]->category->name().isEmpty()?Qt::NoItemFlags :Qt::ItemIsEnabled) | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable; + return (d_ptr->m_lCategories[index.row()]->category->name().isEmpty()?Qt::NoItemFlags :Qt::ItemIsEnabled) | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable; } bool NumberCategoryModel::setData(const QModelIndex& idx, const QVariant &value, int role) { if (idx.isValid() && role == Qt::CheckStateRole) { - m_lCategories[idx.row()]->enabled = value.toBool(); + d_ptr->m_lCategories[idx.row()]->enabled = value.toBool(); emit dataChanged(idx,idx); return true; } @@ -73,9 +93,9 @@ bool NumberCategoryModel::setData(const QModelIndex& idx, const QVariant &value, NumberCategory* NumberCategoryModel::addCategory(const QString& name, QPixmap* icon, int index, bool enabled) { - InternalTypeRepresentation* rep = m_hByName[name]; + NumberCategoryModelPrivate::InternalTypeRepresentation* rep = d_ptr->m_hByName[name]; if (!rep) { - rep = new InternalTypeRepresentation(); + rep = new NumberCategoryModelPrivate::InternalTypeRepresentation(); rep->counter = 0 ; } NumberCategory* cat = new NumberCategory(this,name); @@ -83,9 +103,9 @@ NumberCategory* NumberCategoryModel::addCategory(const QString& name, QPixmap* i rep->category = cat ; rep->index = index ; rep->enabled = enabled; - m_hByIdx[index] = rep ; - m_hByName[name] = rep ; - m_lCategories << rep ; + d_ptr->m_hByIdx[index] = rep ; + d_ptr->m_hByName[name] = rep ; + d_ptr->m_lCategories << rep ; emit layoutChanged() ; return cat; } @@ -99,63 +119,48 @@ NumberCategoryModel* NumberCategoryModel::instance() void NumberCategoryModel::setIcon(int idx, QPixmap* icon) { - InternalTypeRepresentation* rep = m_hByIdx[idx]; + NumberCategoryModelPrivate::InternalTypeRepresentation* rep = d_ptr->m_hByIdx[idx]; if (rep) { rep->category->setIcon(icon); - emit dataChanged(index(m_lCategories.indexOf(rep),0),index(m_lCategories.indexOf(rep),0)); + emit dataChanged(index(d_ptr->m_lCategories.indexOf(rep),0),index(d_ptr->m_lCategories.indexOf(rep),0)); } } -void NumberCategoryModel::setVisitor(NumberCategoryVisitor* visitor) -{ - m_pVisitor = visitor; - m_pVisitor->load(this); -} - -NumberCategoryVisitor* NumberCategoryModel::visitor() const -{ - return m_pVisitor; -} - void NumberCategoryModel::save() { - if (m_pVisitor) { - m_pVisitor->serialize(this); - } - else - qDebug() << "Cannot save NumberCategoryModel as there is no defined backend"; + NumberCategoryVisitor::instance()->serialize(this); } QModelIndex NumberCategoryModel::nameToIndex(const QString& name) const { - if (!m_hByName[name]) + if (!d_ptr->m_hByName[name]) return QModelIndex(); else { - return index(m_hByName[name]->index,0); + return index(d_ptr->m_hByName[name]->index,0); } } ///Be sure the category exist, increment the counter void NumberCategoryModel::registerNumber(PhoneNumber* number) { - InternalTypeRepresentation* rep = m_hByName[number->category()->name()]; + NumberCategoryModelPrivate::InternalTypeRepresentation* rep = d_ptr->m_hByName[number->category()->name()]; if (!rep) { addCategory(number->category()->name(),nullptr,-1,true); - rep = m_hByName[number->category()->name()]; + rep = d_ptr->m_hByName[number->category()->name()]; } rep->counter++; } void NumberCategoryModel::unregisterNumber(PhoneNumber* number) { - InternalTypeRepresentation* rep = m_hByName[number->category()->name()]; + NumberCategoryModelPrivate::InternalTypeRepresentation* rep = d_ptr->m_hByName[number->category()->name()]; if (rep) rep->counter--; } NumberCategory* NumberCategoryModel::getCategory(const QString& type) { - InternalTypeRepresentation* internal = m_hByName[type]; + NumberCategoryModelPrivate::InternalTypeRepresentation* internal = d_ptr->m_hByName[type]; if (internal) return internal->category; return addCategory(type,nullptr); @@ -164,9 +169,11 @@ NumberCategory* NumberCategoryModel::getCategory(const QString& type) NumberCategory* NumberCategoryModel::other() { - if (instance()->m_hByName["Other"]) - return instance()->m_hByName["Other"]->category; - if (!m_spOther) - m_spOther = new NumberCategory(instance(),"Other"); - return m_spOther; + if (instance()->d_ptr->m_hByName["Other"]) + return instance()->d_ptr->m_hByName["Other"]->category; + if (NumberCategoryModelPrivate::m_spOther) + NumberCategoryModelPrivate::m_spOther = new NumberCategory(instance(),"Other"); + return NumberCategoryModelPrivate::m_spOther; } + +#include <numbercategorymodel.moc> diff --git a/src/numbercategorymodel.h b/src/numbercategorymodel.h index 109a52b71fe1593cd723a1487dd6060284cb786e..ce78cd58a488b7c10727f10071084324f4c469e7 100644 --- a/src/numbercategorymodel.h +++ b/src/numbercategorymodel.h @@ -27,21 +27,21 @@ class QPixmap; class NumberCategoryVisitor; class PhoneNumber; class NumberCategory; +class NumberCategoryModelPrivate; class LIB_EXPORT NumberCategoryModel : public QAbstractListModel { Q_OBJECT public: - explicit NumberCategoryModel(QObject* parent = nullptr); enum Role { INDEX = 100, }; //Abstract model member - virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount(const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags(const QModelIndex& index ) const; - virtual bool setData(const QModelIndex& index, const QVariant &value, int role); + virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount(const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags(const QModelIndex& index ) const override; + virtual bool setData(const QModelIndex& index, const QVariant &value, int role) override; //Mutator NumberCategory* addCategory(const QString& name, QPixmap* icon, int index = -1, bool enabled = true); @@ -51,11 +51,7 @@ public: //Singleton static NumberCategoryModel* instance(); - //Setter - void setVisitor(NumberCategoryVisitor* visitor); - //Getter - NumberCategoryVisitor* visitor() const; QModelIndex nameToIndex(const QString& name) const; NumberCategory* getCategory(const QString& type); static NumberCategory* other(); @@ -65,18 +61,14 @@ public: void unregisterNumber(PhoneNumber* number); private: - struct InternalTypeRepresentation { - NumberCategory* category; - int index ; - bool enabled ; - int counter ; - }; - QVector<InternalTypeRepresentation*> m_lCategories; - QHash<int,InternalTypeRepresentation*> m_hByIdx; - QHash<QString,InternalTypeRepresentation*> m_hByName; - static NumberCategoryModel* m_spInstance ; - NumberCategoryVisitor* m_pVisitor ; - static NumberCategory* m_spOther ; + explicit NumberCategoryModel(QObject* parent = nullptr); + ~NumberCategoryModel(); + + NumberCategoryModelPrivate* d_ptr; + Q_DECLARE_PRIVATE(NumberCategoryModel) + + //Singleton + static NumberCategoryModel* m_spInstance; }; #endif //NUMBERCATEGORYMODEL_H diff --git a/src/phonenumber.h b/src/phonenumber.h index e6be50f58fa0a096431ff9251487fc9566c3ab2e..35788661d1730a8199b7d05012f93edb3047b351 100644 --- a/src/phonenumber.h +++ b/src/phonenumber.h @@ -155,28 +155,6 @@ protected: private: friend class PhoneNumberPrivate; - /*//Attributes - NumberCategory* m_pCategory ; - bool m_Present ; - QString m_PresentMessage ; - bool m_Tracked ; - Contact* m_pContact ; - Account* m_pAccount ; - time_t m_LastUsed ; - QList<Call*> m_lCalls ; - int m_PopularityIndex ; - QString m_MostCommonName ; - QHash<QString,int> m_hNames ; - bool m_hasType ; - uint m_LastWeekCount ; - uint m_LastTrimCount ; - bool m_HaveCalled ; - int m_Index ; - bool m_IsBookmark ; - int m_TotalSeconds ; - QString m_Uid ; - QString m_PrimaryName_cache;*/ - //Static attributes static QHash<int,Call*> m_shMostUsed ; static const PhoneNumber* m_spBlank ; diff --git a/src/presencestatusmodel.cpp b/src/presencestatusmodel.cpp index 5e9d6d48268de937f9e38db1471aded4f2cd7482..cf2d27e36867166b2e791bc4362066324d6c5f69 100644 --- a/src/presencestatusmodel.cpp +++ b/src/presencestatusmodel.cpp @@ -28,19 +28,37 @@ //Static PresenceStatusModel* PresenceStatusModel::m_spInstance = nullptr; +class PresenceStatusModelPrivate +{ +public: + PresenceStatusModelPrivate(); + //Attributes + QVector<PresenceStatusModel::StatusData*> m_lStatuses; + QString m_CustomMessage ; + bool m_UseCustomStatus ; + bool m_CustomStatus ; + PresenceStatusModel::StatusData* m_pCurrentStatus ; + PresenceStatusModel::StatusData* m_pDefaultStatus ; +}; + +PresenceStatusModelPrivate::PresenceStatusModelPrivate() : +m_pCurrentStatus(nullptr),m_pDefaultStatus(nullptr),m_UseCustomStatus(false),m_CustomStatus(false) +{ + +} + ///Constructor PresenceStatusModel::PresenceStatusModel(QObject* parent) : QAbstractTableModel(parent?parent:QCoreApplication::instance()), -m_pCurrentStatus(nullptr),m_pDefaultStatus(nullptr),m_UseCustomStatus(false),m_CustomStatus(false),m_pVisitor(nullptr) +d_ptr(new PresenceStatusModelPrivate()) { setObjectName("PresenceStatusModel"); } PresenceStatusModel::~PresenceStatusModel() { - foreach (StatusData* data, m_lStatuses) { + foreach (StatusData* data, d_ptr->m_lStatuses) { delete data; } - if (m_pVisitor) delete m_pVisitor; } ///Get model data @@ -52,28 +70,28 @@ QVariant PresenceStatusModel::data(const QModelIndex& index, int role ) const switch (role) { case Qt::DisplayRole: case Qt::EditRole: - return m_lStatuses[index.row()]->name; + return d_ptr->m_lStatuses[index.row()]->name; case Qt::ToolTipRole: - return m_lStatuses[index.row()]->message; + return d_ptr->m_lStatuses[index.row()]->message; } break; case PresenceStatusModel::Columns::Message: switch (role) { case Qt::DisplayRole: case Qt::EditRole: - return m_lStatuses[index.row()]->message; + return d_ptr->m_lStatuses[index.row()]->message; } break; case PresenceStatusModel::Columns::Color: switch (role) { case Qt::BackgroundColorRole: - return m_lStatuses[index.row()]->color; + return d_ptr->m_lStatuses[index.row()]->color; } break; case PresenceStatusModel::Columns::Status: switch (role) { case Qt::CheckStateRole: - return m_lStatuses[index.row()]->status?Qt::Checked:Qt::Unchecked; + return d_ptr->m_lStatuses[index.row()]->status?Qt::Checked:Qt::Unchecked; case Qt::TextAlignmentRole: return Qt::AlignCenter; } @@ -81,7 +99,7 @@ QVariant PresenceStatusModel::data(const QModelIndex& index, int role ) const case PresenceStatusModel::Columns::Default: switch (role) { case Qt::CheckStateRole: - return m_lStatuses[index.row()]->defaultStatus?Qt::Checked:Qt::Unchecked; + return d_ptr->m_lStatuses[index.row()]->defaultStatus?Qt::Checked:Qt::Unchecked; case Qt::TextAlignmentRole: return Qt::AlignCenter; } @@ -95,7 +113,7 @@ QVariant PresenceStatusModel::data(const QModelIndex& index, int role ) const int PresenceStatusModel::rowCount(const QModelIndex& parent ) const { if (parent.isValid()) return 0; - return m_lStatuses.size(); + return d_ptr->m_lStatuses.size(); } ///Return the number of column (static: {"Name","Message","Color","Present","Default"}) @@ -122,7 +140,7 @@ bool PresenceStatusModel::setData(const QModelIndex& index, const QVariant &valu Q_UNUSED(value) Q_UNUSED(role) if (index.isValid()) { - StatusData* dat = m_lStatuses[index.row()]; + StatusData* dat = d_ptr->m_lStatuses[index.row()]; switch(static_cast<PresenceStatusModel::Columns>(index.column())) { case PresenceStatusModel::Columns::Name: if (role == Qt::EditRole) { @@ -177,36 +195,28 @@ QVariant PresenceStatusModel::headerData(int section, Qt::Orientation orientatio ///Add a status to the model void PresenceStatusModel::addStatus(StatusData* status) { - m_lStatuses << status; + d_ptr->m_lStatuses << status; if (status->defaultStatus) { - m_pDefaultStatus = status; - if (!m_pCurrentStatus) - setCurrentIndex(index(m_lStatuses.size()-1,0)); + d_ptr->m_pDefaultStatus = status; + if (!d_ptr->m_pCurrentStatus) + setCurrentIndex(index(d_ptr->m_lStatuses.size()-1,0)); } } - -void PresenceStatusModel::setPresenceVisitor(PresenceSerializationVisitor* visitor) -{ - m_pVisitor = visitor; - if (m_pVisitor) - m_pVisitor->load(); -} - ///Add a new status void PresenceStatusModel::addRow() { StatusData* newRow = new StatusData(); newRow->status = false; - m_lStatuses << newRow; + d_ptr->m_lStatuses << newRow; emit layoutChanged(); } ///Remove status[index] void PresenceStatusModel::removeRow(const QModelIndex& index) { - StatusData* toDel = m_lStatuses[index.row()]; - m_lStatuses.remove(index.row()); + StatusData* toDel = d_ptr->m_lStatuses[index.row()]; + d_ptr->m_lStatuses.remove(index.row()); emit layoutChanged(); delete toDel; } @@ -214,8 +224,7 @@ void PresenceStatusModel::removeRow(const QModelIndex& index) ///Serialize model TODO a backend visitor need to be created void PresenceStatusModel::save() { - if (m_pVisitor) - m_pVisitor->serialize(); + PresenceSerializationVisitor::instance()->serialize(); } ///Singleton @@ -232,9 +241,9 @@ void PresenceStatusModel::moveUp(const QModelIndex& idx) { const int row = idx.row(); if (row > 0) { - StatusData* tmp = m_lStatuses[row-1]; - m_lStatuses[ row-1 ] = m_lStatuses[row ]; - m_lStatuses[ row] = tmp; + StatusData* tmp = d_ptr->m_lStatuses[row-1]; + d_ptr->m_lStatuses[ row-1 ] = d_ptr->m_lStatuses[row ]; + d_ptr->m_lStatuses[ row] = tmp; emit dataChanged(index(row-1,0),index(row,0)); } } @@ -243,10 +252,10 @@ void PresenceStatusModel::moveUp(const QModelIndex& idx) void PresenceStatusModel::moveDown(const QModelIndex& idx) { const int row = idx.row(); - if (row-1 < m_lStatuses.size()) { - StatusData* tmp = m_lStatuses[row+1]; - m_lStatuses[ row+1 ] = m_lStatuses[row ]; - m_lStatuses[ row ] = tmp; + if (row-1 < d_ptr->m_lStatuses.size()) { + StatusData* tmp = d_ptr->m_lStatuses[row+1]; + d_ptr->m_lStatuses[ row+1 ] = d_ptr->m_lStatuses[row ]; + d_ptr->m_lStatuses[ row ] = tmp; emit dataChanged(index(row,0),index(row+1,0)); } } @@ -254,17 +263,17 @@ void PresenceStatusModel::moveDown(const QModelIndex& idx) ///Return the (user defined) custom message; QString PresenceStatusModel::customMessage() const { - return m_CustomMessage; + return d_ptr->m_CustomMessage; } ///Set the (user defined) custom message void PresenceStatusModel::setCustomMessage(const QString& message) { - const bool hasChanged = m_CustomMessage != message; - m_CustomMessage = message; + const bool hasChanged = d_ptr->m_CustomMessage != message; + d_ptr->m_CustomMessage = message; if (hasChanged) { emit customMessageChanged(message); - if (m_UseCustomStatus) + if (d_ptr->m_UseCustomStatus) emit currentMessageChanged(message); } } @@ -272,11 +281,11 @@ void PresenceStatusModel::setCustomMessage(const QString& message) ///Set the custom status void PresenceStatusModel::setCustomStatus(bool status) { - const bool hasChanged = status != m_CustomStatus; - m_CustomStatus = status; + const bool hasChanged = status != d_ptr->m_CustomStatus; + d_ptr->m_CustomStatus = status; if (hasChanged) { emit customStatusChanged(status); - if (m_UseCustomStatus) + if (d_ptr->m_UseCustomStatus) emit currentStatusChanged(status); } } @@ -284,41 +293,41 @@ void PresenceStatusModel::setCustomStatus(bool status) ///Switch between the pre-defined status list and custom ones void PresenceStatusModel::setUseCustomStatus(bool useCustom) { - const bool changed = m_UseCustomStatus != useCustom; - m_UseCustomStatus = useCustom; + const bool changed = d_ptr->m_UseCustomStatus != useCustom; + d_ptr->m_UseCustomStatus = useCustom; if (changed) { - emit useCustomStatusChanged( useCustom ); - emit currentIndexChanged ( useCustom||!m_pCurrentStatus?index(-1,-1):index(m_lStatuses.indexOf(m_pCurrentStatus),0) ); - emit currentNameChanged ( useCustom?tr("Custom"):(m_pCurrentStatus?m_pCurrentStatus->name:tr("N/A")) ); - emit currentStatusChanged ( useCustom?m_CustomStatus:(m_pCurrentStatus?m_pCurrentStatus->status:false) ); - emit currentMessageChanged ( useCustom?m_CustomMessage:(m_pCurrentStatus?m_pCurrentStatus->message:tr("N/A")) ); + emit useCustomStatusChanged( useCustom ); + emit currentIndexChanged ( useCustom||!d_ptr->m_pCurrentStatus?index(-1,-1):index(d_ptr->m_lStatuses.indexOf(d_ptr->m_pCurrentStatus),0) ); + emit currentNameChanged ( useCustom?tr("Custom"):(d_ptr->m_pCurrentStatus?d_ptr->m_pCurrentStatus->name:tr("N/A")) ); + emit currentStatusChanged ( useCustom?d_ptr->m_CustomStatus:(d_ptr->m_pCurrentStatus?d_ptr->m_pCurrentStatus->status:false) ); + emit currentMessageChanged ( useCustom?d_ptr->m_CustomMessage:(d_ptr->m_pCurrentStatus?d_ptr->m_pCurrentStatus->message:tr("N/A")) ); } } ///Return if the presence status is from the predefined list or custom bool PresenceStatusModel::useCustomStatus() const { - return m_UseCustomStatus; + return d_ptr->m_UseCustomStatus; } ///Return the custom status bool PresenceStatusModel::customStatus() const { - return m_CustomStatus; + return d_ptr->m_CustomStatus; } ///Set the current status and publish it on the network void PresenceStatusModel::setCurrentIndex (const QModelIndex& index) { if (!index.isValid()) return; - m_pCurrentStatus = m_lStatuses[index.row()]; + d_ptr->m_pCurrentStatus = d_ptr->m_lStatuses[index.row()]; emit currentIndexChanged(index); - emit currentNameChanged(m_pCurrentStatus->name); - emit currentMessageChanged(m_pCurrentStatus->message); - emit currentStatusChanged(m_pCurrentStatus->status); + emit currentNameChanged(d_ptr->m_pCurrentStatus->name); + emit currentMessageChanged(d_ptr->m_pCurrentStatus->message); + emit currentStatusChanged(d_ptr->m_pCurrentStatus->status); for (int i=0; i < AccountModel::instance()->size(); i++) { DBus::PresenceManager::instance().publish( - (*AccountModel::instance())[1]->id(), m_pCurrentStatus->status,m_pCurrentStatus->message + (*AccountModel::instance())[1]->id(), d_ptr->m_pCurrentStatus->status,d_ptr->m_pCurrentStatus->message ); } } @@ -326,53 +335,53 @@ void PresenceStatusModel::setCurrentIndex (const QModelIndex& index) ///Return the current status bool PresenceStatusModel::currentStatus() const { - if (m_UseCustomStatus) return m_CustomStatus; - if (!m_pCurrentStatus) return false; - return m_UseCustomStatus?m_CustomStatus:m_pCurrentStatus->status; + if (d_ptr->m_UseCustomStatus) return d_ptr->m_CustomStatus; + if (!d_ptr->m_pCurrentStatus) return false; + return d_ptr->m_UseCustomStatus?d_ptr->m_CustomStatus:d_ptr->m_pCurrentStatus->status; } ///Return the current status message QString PresenceStatusModel::currentMessage() const { - if (m_UseCustomStatus) return m_CustomMessage; - if (!m_pCurrentStatus) return tr("N/A"); - return m_pCurrentStatus->message; + if (d_ptr->m_UseCustomStatus) return d_ptr->m_CustomMessage; + if (!d_ptr->m_pCurrentStatus) return tr("N/A"); + return d_ptr->m_pCurrentStatus->message; } ///Return current name QString PresenceStatusModel::currentName() const { - return m_UseCustomStatus?tr("Custom"):m_pCurrentStatus?m_pCurrentStatus->name:tr("N/A"); + return d_ptr->m_UseCustomStatus?tr("Custom"):d_ptr->m_pCurrentStatus?d_ptr->m_pCurrentStatus->name:tr("N/A"); } ///Return the default status index QModelIndex PresenceStatusModel::defaultStatus() const { - if (!m_pDefaultStatus) return index(-1,-1); - return index(m_lStatuses.indexOf(m_pDefaultStatus),0); + if (!d_ptr->m_pDefaultStatus) return index(-1,-1); + return index(d_ptr->m_lStatuses.indexOf(d_ptr->m_pDefaultStatus),0); } ///Set the new default status void PresenceStatusModel::setDefaultStatus( const QModelIndex& idx ) { if (!idx.isValid()) return; - if (m_pDefaultStatus) { - m_pDefaultStatus->defaultStatus = false; - const QModelIndex& oldIdx = index(m_lStatuses.indexOf(m_pDefaultStatus),static_cast<int>(PresenceStatusModel::Columns::Default)); + if (d_ptr->m_pDefaultStatus) { + d_ptr->m_pDefaultStatus->defaultStatus = false; + const QModelIndex& oldIdx = index(d_ptr->m_lStatuses.indexOf(d_ptr->m_pDefaultStatus),static_cast<int>(PresenceStatusModel::Columns::Default)); emit dataChanged(oldIdx,oldIdx); } - m_pDefaultStatus = m_lStatuses[idx.row()]; - m_pDefaultStatus->defaultStatus = true; + d_ptr->m_pDefaultStatus = d_ptr->m_lStatuses[idx.row()]; + d_ptr->m_pDefaultStatus->defaultStatus = true; emit defaultStatusChanged(idx); emit dataChanged(idx,idx); } bool PresenceStatusModel::isAutoTracked(AbstractItemBackendBase* backend) const { - return m_pVisitor->isTracked(backend); + return PresenceSerializationVisitor::instance()->isTracked(backend); } void PresenceStatusModel::setAutoTracked(AbstractItemBackendBase* backend, bool tracked) const { - m_pVisitor->setTracked(backend,tracked); + PresenceSerializationVisitor::instance()->setTracked(backend,tracked); } diff --git a/src/presencestatusmodel.h b/src/presencestatusmodel.h index eb180d9317be46a2ae75c7995d78941090d9c136..859881ada38b8245e888b388d41ad84d42655f2b 100644 --- a/src/presencestatusmodel.h +++ b/src/presencestatusmodel.h @@ -25,6 +25,7 @@ class PresenceSerializationVisitor; class AbstractItemBackendBase; +class PresenceStatusModelPrivate; ///CredentialModel: A model for account credentials class LIB_EXPORT PresenceStatusModel : public QAbstractTableModel { @@ -54,7 +55,6 @@ public: //Methods void addStatus(StatusData* status); - void setPresenceVisitor(PresenceSerializationVisitor* visitor); //Properties Q_PROPERTY( QString customMessage READ customMessage WRITE setCustomMessage NOTIFY customMessageChanged(QString) ) @@ -70,12 +70,12 @@ public: virtual ~PresenceStatusModel(); //Abstract model members - virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount (const QModelIndex& parent = QModelIndex() ) const; - virtual int columnCount(const QModelIndex& parent = QModelIndex() ) const; - virtual Qt::ItemFlags flags (const QModelIndex& index ) const; - virtual bool setData (const QModelIndex& index, const QVariant &value, int role ) ; - virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; + virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole ) const override; + virtual int rowCount (const QModelIndex& parent = QModelIndex() ) const override; + virtual int columnCount(const QModelIndex& parent = QModelIndex() ) const override; + virtual Qt::ItemFlags flags (const QModelIndex& index ) const override; + virtual bool setData (const QModelIndex& index, const QVariant &value, int role ) override; + virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; //Singleton static PresenceStatusModel* instance(); @@ -95,15 +95,7 @@ public: bool isAutoTracked(AbstractItemBackendBase* backend) const; private: - - //Attributes - QVector<StatusData*> m_lStatuses ; - QString m_CustomMessage ; - bool m_UseCustomStatus ; - bool m_CustomStatus ; - StatusData* m_pCurrentStatus ; - StatusData* m_pDefaultStatus ; - PresenceSerializationVisitor* m_pVisitor; + QScopedPointer<PresenceStatusModelPrivate> d_ptr; //Singleton static PresenceStatusModel* m_spInstance; diff --git a/src/visitors/numbercategoryvisitor.cpp b/src/visitors/numbercategoryvisitor.cpp index b13fde8b7ec7aa47d2275362c96382febebe5e6c..4417896a0fe6fc8f98c4604f026abb9c0b87cc5d 100644 --- a/src/visitors/numbercategoryvisitor.cpp +++ b/src/visitors/numbercategoryvisitor.cpp @@ -16,3 +16,38 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ #include "numbercategoryvisitor.h" +#include "../numbercategorymodel.h" + +class DummyNumberCategoryVisitor : public NumberCategoryVisitor{ +public: + virtual void serialize(NumberCategoryModel* model) override; + virtual void load (NumberCategoryModel* model) override; + virtual ~DummyNumberCategoryVisitor(); +}; + +NumberCategoryVisitor* NumberCategoryVisitor::m_spInstance = new DummyNumberCategoryVisitor(); + + +void DummyNumberCategoryVisitor::serialize(NumberCategoryModel* model) +{ + Q_UNUSED(model) +} + +void DummyNumberCategoryVisitor::load(NumberCategoryModel* model) +{ + Q_UNUSED(model) +} + +DummyNumberCategoryVisitor::~DummyNumberCategoryVisitor() +{} + +NumberCategoryVisitor* NumberCategoryVisitor::instance() +{ + return m_spInstance; +} + +void NumberCategoryVisitor::setInstance(NumberCategoryVisitor* ins) +{ + m_spInstance = ins; + ins->load(NumberCategoryModel::instance()); +} \ No newline at end of file diff --git a/src/visitors/numbercategoryvisitor.h b/src/visitors/numbercategoryvisitor.h index f7400dc95821b3213e4065fb4e10be52d2805938..278376b2eb9bdb97473a091edc2f383c17a9fe7e 100644 --- a/src/visitors/numbercategoryvisitor.h +++ b/src/visitors/numbercategoryvisitor.h @@ -28,6 +28,12 @@ public: virtual void load (NumberCategoryModel* model) = 0; // virtual QVariant icon (QPixmap* icon ) = 0; virtual ~NumberCategoryVisitor(){}; + + static NumberCategoryVisitor* instance(); + static void setInstance(NumberCategoryVisitor* ins); + +private: + static NumberCategoryVisitor* m_spInstance; }; #endif //NUMBERCATEGORYVISITOR_H diff --git a/src/visitors/presenceserializationvisitor.cpp b/src/visitors/presenceserializationvisitor.cpp index f246a1fa2ca7afaa544d2a8b9470efa2f679319a..614e8d4fa504473376b5d0b02cb00245fdae4ce0 100644 --- a/src/visitors/presenceserializationvisitor.cpp +++ b/src/visitors/presenceserializationvisitor.cpp @@ -16,3 +16,50 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ #include "presenceserializationvisitor.h" + +class LIB_EXPORT DummyPresenceSerializationVisitor : public PresenceSerializationVisitor { +public: + virtual void serialize() override; + virtual void load () override; + virtual bool isTracked(AbstractItemBackendBase* backend) override; + virtual void setTracked(AbstractItemBackendBase* backend, bool tracked) override; + virtual ~DummyPresenceSerializationVisitor(); + +}; + +PresenceSerializationVisitor* PresenceSerializationVisitor::m_spInstance = new DummyPresenceSerializationVisitor(); + +void DummyPresenceSerializationVisitor::serialize() +{ + +} +void DummyPresenceSerializationVisitor::load() +{ + +} + +bool DummyPresenceSerializationVisitor::isTracked(AbstractItemBackendBase* backend) +{ + Q_UNUSED(backend) + return false; +} + +void DummyPresenceSerializationVisitor::setTracked(AbstractItemBackendBase* backend, bool tracked) +{ + Q_UNUSED(backend) + Q_UNUSED(tracked) +} + +DummyPresenceSerializationVisitor::~DummyPresenceSerializationVisitor() +{} + +PresenceSerializationVisitor* PresenceSerializationVisitor::instance() +{ + return m_spInstance; +} + +void PresenceSerializationVisitor::setInstance(PresenceSerializationVisitor* ins) +{ + m_spInstance = ins; + ins->load(); +} \ No newline at end of file diff --git a/src/visitors/presenceserializationvisitor.h b/src/visitors/presenceserializationvisitor.h index ce4e2faaaa03859c0b7a20196a14a4aba09a7c17..a18ac79008dc50655b32e35e0f0fcc1d47965512 100644 --- a/src/visitors/presenceserializationvisitor.h +++ b/src/visitors/presenceserializationvisitor.h @@ -30,6 +30,11 @@ public: virtual bool isTracked(AbstractItemBackendBase* backend) = 0; virtual void setTracked(AbstractItemBackendBase* backend, bool tracked) = 0; virtual ~PresenceSerializationVisitor(){}; + + static PresenceSerializationVisitor* instance(); + static void setInstance(PresenceSerializationVisitor* ins); +private: + static PresenceSerializationVisitor* m_spInstance; }; #endif //PRESENCESERIALIZATIONVISITOR_H