source: src/mvc/eventmodel.h @ b6cd05c

qt5
Last change on this file since b6cd05c was 67c59a7, checked in by pavelpa <pavelpa@…>, 13 years ago

implemented method to force 'EventModel?' emit a signal
dataChanged() - so 'TreeView?' know it has to redraw items
corresponding to chanded indices (range of indeces)

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#ifndef EVENTMODEL_H
2#define EVENTMODEL_H
3
4#include <QAbstractItemModel>
5
6#include "event.h"
7
8class EventModel : public QAbstractItemModel
9{
10public:
11    EventModel();
12    QVariant data(const QModelIndex& index, int role) const;
13    QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
14    QModelIndex parent ( const QModelIndex & index ) const;
15    int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
16    int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
17    void loadEvents(const QDate &aDate, int aConferenceId); // loads Events from the DB
18    void loadFavEvents(const QDate &aDate, int aConferenceId); // loads Favourite events from the DB
19   
20    // a method to force 'EventModel' emit signal 'dataChanged()'
21    // a 'view', eg. 'TreeView' listens for this signal and redraws changed items(indexes)
22    void emitDataChangedSignal(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);
23
24private:
25    struct Group
26    {
27        Group(const QString & title,
28              int firstEventIndex) :
29
30            mTitle(title),
31            mFirstEventIndex(firstEventIndex),
32            mChildCount(0)
33        {}
34
35        QString mTitle;
36        int mFirstEventIndex;
37        int mChildCount;
38    };
39
40private:
41    void createTimeGroups();
42
43private:
44    QList<Event> mEvents;
45    QList<Group> mGroups;
46    QHash<int, int> mParents;
47};
48
49#endif // EVENTMODEL_H
50
Note: See TracBrowser for help on using the repository browser.