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