85
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: caitemmodel.h
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CASTANDARDITEMMODEL_H
|
|
19 |
#define CASTANDARDITEMMODEL_H
|
|
20 |
|
|
21 |
// System includes
|
|
22 |
#include <QAbstractItemModel>
|
|
23 |
#include <QAbstractItemView>
|
|
24 |
|
|
25 |
// User includes
|
|
26 |
#include "caclient_global.h"
|
|
27 |
#include "caquery.h"
|
|
28 |
|
|
29 |
// Forward declarations
|
|
30 |
class CaEntry;
|
|
31 |
class CaItemModelPrivate;
|
|
32 |
CA_CLIENT_TEST_CLASS(TestCaClient)
|
|
33 |
|
|
34 |
// Class declaration
|
|
35 |
class CACLIENT_EXPORT CaItemModel: public QAbstractItemModel
|
|
36 |
{
|
|
37 |
|
|
38 |
Q_OBJECT
|
|
39 |
CA_CLIENT_TEST_FRIEND_CLASS(TestCaClient)
|
|
40 |
|
|
41 |
public:
|
|
42 |
|
|
43 |
// Data types
|
|
44 |
enum CaItemRole
|
|
45 |
{
|
|
46 |
IdRole = Qt::UserRole + 1,
|
|
47 |
ParentIdRole,
|
|
48 |
TypeRole,
|
|
49 |
FlagsRole,
|
|
50 |
TextRole//contains title represented as QString,
|
|
51 |
//convinient for operations such as search
|
|
52 |
};
|
|
53 |
|
|
54 |
// Function declarations
|
|
55 |
CaItemModel(const CaQuery &query, QObject *parent = 0);
|
|
56 |
~CaItemModel();
|
|
57 |
|
|
58 |
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
59 |
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
60 |
virtual QModelIndex index(int row, int column = 0,
|
|
61 |
const QModelIndex &parent = QModelIndex()) const;
|
|
62 |
virtual QModelIndex parent(const QModelIndex &index) const;
|
|
63 |
QModelIndex root() const;
|
|
64 |
virtual QVariant data(const QModelIndex &index, int role =
|
|
65 |
Qt::DisplayRole) const;
|
|
66 |
void setAutoUpdate(bool autoUpdate);
|
|
67 |
void setSecondLineVisibility(bool secondLineVisible);
|
|
68 |
bool secondLineVisibility() const;
|
|
69 |
bool isAutoUpdate() const;
|
|
70 |
void setSort(SortAttribute sortAttribute, Qt::SortOrder sortOrder =
|
|
71 |
Qt::AscendingOrder);
|
|
72 |
void setIconSize(const QSize &size);
|
|
73 |
QSize getIconSize() const;
|
|
74 |
void updateModel();
|
|
75 |
void setParentId(int parentId);
|
87
|
76 |
void setFlagsOn(const EntryFlags &onFlags);
|
|
77 |
void setFlagsOff(const EntryFlags &offFlags);
|
85
|
78 |
CaEntry* entry(const QModelIndex &index) const;
|
|
79 |
|
|
80 |
signals:
|
|
81 |
|
|
82 |
void scrollTo(int row, QAbstractItemView::ScrollHint hint =
|
|
83 |
QAbstractItemView::EnsureVisible);
|
|
84 |
|
|
85 |
protected:
|
|
86 |
// data
|
|
87 |
|
|
88 |
CaItemModelPrivate * const m_d;
|
|
89 |
friend class CaItemModelPrivate;
|
|
90 |
|
|
91 |
};
|
|
92 |
|
|
93 |
#endif // CASTANDARDITEMMODEL_H
|