~ubuntu-branches/ubuntu/natty/kdebase-runtime/natty-updates

« back to all changes in this revision

Viewing changes to plasma/declarativeimports/core/datamodel.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-12-22 15:23:10 UTC
  • mfrom: (1.1.48 upstream)
  • Revision ID: james.westby@ubuntu.com-20101222152310-e3e1ayul5vvoupt3
Tags: 4:4.5.90-0ubuntu1
New upstream RC release

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    Q_PROPERTY(QString filterRole READ filterRole WRITE setFilterRole)
44
44
    Q_PROPERTY(QString sortRole READ sortRole WRITE setSortRole)
45
45
    Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder)
 
46
    Q_PROPERTY(int count READ count NOTIFY countChanged)
46
47
 
47
48
    friend class DataModel;
48
49
 
64
65
 
65
66
    void setSortOrder(const Qt::SortOrder order);
66
67
 
 
68
    int count() const {return QSortFilterProxyModel::rowCount();}
 
69
 
 
70
Q_SIGNALS:
 
71
    void countChanged();
 
72
 
67
73
protected:
68
74
    int roleNameToId(const QString &name);
69
75
 
81
87
    Q_OBJECT
82
88
    Q_PROPERTY(QObject *dataSource READ dataSource WRITE setDataSource)
83
89
    Q_PROPERTY(QString keyRoleFilter READ keyRoleFilter WRITE setKeyRoleFilter)
 
90
    Q_PROPERTY(int count READ count NOTIFY countChanged)
84
91
 
85
92
public:
86
93
    DataModel(QObject* parent=0);
104
111
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
105
112
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
106
113
 
 
114
    int count() const {return countItems();}
 
115
 
107
116
protected:
108
117
    void setItems(const QString &sourceName, const QVariantList &list);
109
118
    inline int countItems() const;
111
120
Q_SIGNALS:
112
121
    void modelAboutToBeReset();
113
122
    void modelReset();
 
123
    void countChanged();
114
124
 
115
125
private Q_SLOTS:
116
126
    void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
124
134
    QHash<QString, int> m_roleIds;
125
135
};
126
136
 
 
137
int DataModel::countItems() const
 
138
{
 
139
    int count = 0;
 
140
    foreach (const QVector<QVariant> &v, m_items) {
 
141
        count += v.count();
 
142
    }
 
143
    return count;
 
144
}
 
145
 
127
146
}
128
147
#endif