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

contact: Add CategorizedContactModel singleton

Refs #70196
parent 4a6c3961
No related branches found
No related tags found
No related merge requests found
......@@ -71,7 +71,6 @@ public:
void slotContactMethodCountChanged (int,int);
void slotContactMethodCountAboutToChange(int,int);
};
class CategorizedContactModelPrivate : public QObject
{
Q_OBJECT
......@@ -94,6 +93,9 @@ public:
ContactTreeNode* getContactTopLevelItem(const QString& category);
QModelIndex getIndex(int row, int column, ContactTreeNode* parent);
//Singleton
static CategorizedContactModel* m_spInstance;
private:
CategorizedContactModel* q_ptr;
......@@ -102,6 +104,8 @@ public Q_SLOTS:
void slotContactAdded(const Person* c);
};
CategorizedContactModel* CategorizedContactModelPrivate::m_spInstance = nullptr;
ContactTreeNode::ContactTreeNode(const Person* ct, CategorizedContactModel* parent) : CategorizedCompositeNode(CategorizedCompositeNode::Type::CONTACT),
m_pContact(ct),m_Index(-1),m_pContactMethod(nullptr),m_Type(ContactTreeNode::NodeType::PERSON),m_pParent(nullptr),m_pModel(parent)
{
......@@ -204,6 +208,13 @@ CategorizedContactModel::~CategorizedContactModel()
}
}
CategorizedContactModel* CategorizedContactModel::instance()
{
if (!CategorizedContactModelPrivate::m_spInstance)
CategorizedContactModelPrivate::m_spInstance = new CategorizedContactModel();
return CategorizedContactModelPrivate::m_spInstance;
}
QHash<int,QByteArray> CategorizedContactModel::roleNames() const
{
static QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
......
......@@ -68,6 +68,9 @@ public:
bool isSortAlphabetical () const;
QString defaultCategory () const;
//Singleton
static CategorizedContactModel* instance();
private:
QScopedPointer<CategorizedContactModelPrivate> d_ptr;
Q_DECLARE_PRIVATE(CategorizedContactModel)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment