contactengine/contactsengine.h
author John Kern <johnk@symbian.org>
Thu, 26 Aug 2010 14:34:34 -0700
changeset 40 edc0144719a1
parent 34 93c5a58496b6
permissions -rwxr-xr-x
removed invariant from data() and rowCount(). Performance should be ok now.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     1
#ifndef CONTACTSENGINE_H
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     2
#define CONTACTSENGINE_H
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     3
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     4
#include <QAbstractListModel>
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     5
#include <QContactManager>
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
     6
#include <QPointer>
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     7
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     8
#include "contactsengine.h"
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     9
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    10
using namespace QtMobility;
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    11
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    12
class ContactsEngine : public QAbstractListModel
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    13
{
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    14
    Q_OBJECT
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    15
public:
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    16
    explicit ContactsEngine(QObject *parent = 0);
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    17
    ~ContactsEngine();
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    18
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    19
    // index() and parent()  are defined by QAbstractListModel. So we do not
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    20
    // need to define the QModelIndex
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    21
    // required by list model interface.
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    22
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    23
    QVariant data(const QModelIndex &index, int role) const;
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    24
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    25
    QStringList dataSources();
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    26
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    27
public:
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    28
    void populateAddresses();
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    29
    void dumpContactMgr(); // use for debugging. Hard to inspect it via Qt Creator.
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    30
    void enumerateMgrs();
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    31
    void createManager();
31
7140311376c0 created in memory contact mgr; populateAddress populates it
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    32
    void createManagerSF();
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    33
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    34
signals:
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    35
    void errorOccurred(QString errMsg); // when a error message
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    36
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    37
public slots:
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    38
    void setManager(const QString &aMgr);
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    39
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    40
private:
31
7140311376c0 created in memory contact mgr; populateAddress populates it
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    41
    QString errorString(QContactManager::Error);
7140311376c0 created in memory contact mgr; populateAddress populates it
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    42
7140311376c0 created in memory contact mgr; populateAddress populates it
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    43
private:
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    44
    QMap<QString, QString> m_availableManagers;
34
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 31
diff changeset
    45
    // this is the default mgr. On device, it pull info from contacts as expected.
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    46
    QPointer<QContactManager> m_manager;
34
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 31
diff changeset
    47
    // this one is simply in memory. Put the Symbian Foundation contacts here.
31
7140311376c0 created in memory contact mgr; populateAddress populates it
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    48
    QPointer<QContactManager> m_manager_sf;
40
edc0144719a1 removed invariant from data() and rowCount(). Performance should be ok now.
John Kern <johnk@symbian.org>
parents: 34
diff changeset
    49
    // cache list of all contacts.
edc0144719a1 removed invariant from data() and rowCount(). Performance should be ok now.
John Kern <johnk@symbian.org>
parents: 34
diff changeset
    50
    QList<QContact> m_allContacts;
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    51
};
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    52
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    53
#endif // CONTACTSENGINE_H