summaryrefslogtreecommitdiffstats
path: root/examples/declarative/support/contactmodel.h
blob: e2623589c5c43079396fa3c5e2a73086b712976b (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
45
46
47
48
49
50
51
52
53
54
55
/****************************************************************************
**
** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved.
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
** $TROLLTECH_DUAL_LICENSE$
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef _CONTACTMODEL_H_
#define _CONTACTMODEL_H_

#include <qlistmodelinterface.h>
#include "contact.h"

class ContactModel : public QListModelInterface
{
    Q_OBJECT
public:
    ContactModel(QObject *parent = 0);
    ~ContactModel();

    enum Roles {
        PortraitRole,
        FirstNameRole,
        LastNameRole,
        CompanyRole,
        EmailsRole,
        AddressesRole,
        NumbersRole
    };

    int count() const;

    QHash<int,QVariant> data(int index, const QList<int> &roles) const;
    QList<int> roles() const;


    QString toString(int role) const;

    void deleteContact(int index);
    int insertContact(Contact *contact); 

    int isAfter(QString &name1, QString &name2) const;
    int findIndex(QString &searchName) const;

private:
    QList<Contact*> contactList;
};

#endif