summaryrefslogtreecommitdiff
path: root/saltoqd/contactsmanager.h
blob: d8c293fc7caee6fd6c251d71f1110bab6bb888d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef CONTACTSMANAGER_H
#define CONTACTSMANAGER_H

#include <QtContacts/QContactManager>
#include <QtContacts/QContactPhoneNumber>
#include "storagemanager.h"

class ContactsManager : public QObject
{
	Q_OBJECT
public:
	explicit ContactsManager(StorageManager *storage, ToqManager *toq);

	qint64 getRecordIdForContact(uint contactId);

	struct NameType {
		bool found;
		QString name;
		QString type;
		bool favorite;
	};

	NameType findNameTypeForPhoneNumber(const QString &phoneNumber) const;

public slots:
	void scheduleRefresh();

signals:
	void changed();

private slots:
	void refresh();

private:
	static QString typeForContactPhone(const QtContacts::QContactPhoneNumber &number);

private:
	ToqManager *_toq;
	StorageManager *_storage;
	QtContacts::QContactManager *_contacts;
	QTimer *_refreshTimer;
};

#endif // CONTACTSMANAGER_H