Bump copyright year.
[toast/confclerk.git] / src / mvc / conferencemodel.h
1 /*
2  * Copyright (C) 2010 Ixonos Plc.
3  * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
4  *
5  * This file is part of ConfClerk.
6  *
7  * ConfClerk is free software: you can redistribute it and/or modify it
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  *
12  * ConfClerk is distributed in the hope that it will be useful, but
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
18  * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
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(int conferenceId);
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