File indexing completed on 2024-06-23 04:42:30

0001 #ifndef CONTACTSMODEL_H
0002 #define CONTACTSMODEL_H
0003 
0004 #include <QObject>
0005 
0006 #include <MauiKit3/Core/mauilist.h>
0007 
0008 class AbstractInterface;
0009 class ContactsModel : public MauiList
0010 {
0011     Q_OBJECT
0012     Q_PROPERTY(QString query READ getQuery WRITE setQuery NOTIFY queryChanged)
0013 
0014 public:
0015     explicit ContactsModel(QObject *parent = nullptr);
0016 
0017     const FMH::MODEL_LIST &items() const override final;
0018 
0019     QString getQuery() const;
0020     void setQuery(const QString &query);
0021 
0022 private:
0023     /*
0024      * *syncer (abstract interface) shouyld work with whatever interface derived from
0025      * AbstractInterface, for now we have Android and Linux interfaces
0026      */
0027 
0028     AbstractInterface *syncer;
0029 
0030     /**
0031      * There is the list that holds the conatcts data,
0032      * and the list-bk which holds a cached version of the list,
0033      * this helps to not have to fecth contents all over again
0034      * when filtering the list
0035      */
0036     FMH::MODEL_LIST list;
0037 
0038     void filter();
0039     void getList();
0040 
0041     /**
0042      * query is a property to start filtering the list, the filtering is
0043      * done over the list-bk cached list instead of the main list
0044      */
0045     QString m_query;
0046 
0047 signals:
0048     void queryChanged();
0049 
0050 public slots:
0051     bool insert(const QVariantMap &map);
0052     bool update(const QVariantMap &map, const int &index);
0053     bool remove(const int &index);
0054 
0055     void append(const QVariantMap &item, const int &at);
0056     void append(const QVariantMap &item);
0057 
0058     void clear();
0059     void reset();
0060     void refresh();
0061     QVariantList getAccounts();
0062 };
0063 
0064 #endif // CONTACTSMODEL_H