[b431d47] | 1 | /* |
---|
| 2 | * Copyright (C) 2010 Ixonos Plc. |
---|
[68b2df2] | 3 | * Copyright (C) 2011 Philipp Spitzer, gregor herrmann |
---|
[b431d47] | 4 | * |
---|
[6df32f2] | 5 | * This file is part of ConfClerk. |
---|
[b431d47] | 6 | * |
---|
[6df32f2] | 7 | * ConfClerk is free software: you can redistribute it and/or modify it |
---|
[b431d47] | 8 | * under the terms of the GNU General Public License as published by the Free |
---|
| 9 | * Software Foundation, either version 2 of the License, or (at your option) |
---|
| 10 | * any later version. |
---|
| 11 | * |
---|
[6df32f2] | 12 | * ConfClerk is distributed in the hope that it will be useful, but |
---|
[b431d47] | 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
---|
| 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
| 15 | * more details. |
---|
| 16 | * |
---|
| 17 | * You should have received a copy of the GNU General Public License along with |
---|
[6df32f2] | 18 | * ConfClerk. If not, see <http://www.gnu.org/licenses/>. |
---|
[b431d47] | 19 | */ |
---|
| 20 | #ifndef CONFERENCE_MODEL_H |
---|
| 21 | #define CONFERENCE_MODEL_H |
---|
| 22 | |
---|
| 23 | #include <QAbstractListModel> |
---|
| 24 | #include <QList> |
---|
| 25 | |
---|
| 26 | #include "conference.h" |
---|
| 27 | |
---|
| 28 | /** ConferenceModel class represents list of conferences for ListViews that may need it. |
---|
| 29 | |
---|
| 30 | It also provides typed access to the conferences from ConferenceEditor. |
---|
| 31 | |
---|
| 32 | It does not actually modify anything in DB, this is performed by other classes. |
---|
| 33 | |
---|
| 34 | \see ConferenceEditor, MainWindow::showConferences() |
---|
| 35 | */ |
---|
| 36 | class ConferenceModel : public QAbstractListModel { |
---|
| 37 | Q_OBJECT |
---|
| 38 | public: |
---|
| 39 | ConferenceModel(QObject* parent); |
---|
| 40 | virtual ~ConferenceModel() { } |
---|
| 41 | |
---|
| 42 | virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; |
---|
| 43 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; |
---|
| 44 | |
---|
| 45 | const Conference& conferenceFromIndex(const QModelIndex&) const; |
---|
| 46 | QModelIndex indexFromId(int id) const; |
---|
| 47 | public slots: |
---|
| 48 | void newConferenceBegin(); |
---|
| 49 | void newConferenceEnd(const QString& title); |
---|
| 50 | void conferenceRemoved(); |
---|
| 51 | private: |
---|
| 52 | // reinitialize list from database |
---|
| 53 | void reinit() |
---|
| 54 | { |
---|
| 55 | conferences = Conference::getAll(); |
---|
| 56 | reset(); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | QList<Conference> conferences; |
---|
| 60 | }; |
---|
| 61 | |
---|
| 62 | #endif |
---|