source: src/mvc/conferencemodel.h

Last change on this file was ffb6be7, checked in by gregor herrmann <gregor@…>, 6 months ago

Bump copyright years.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2021 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
30It also provides typed access to the conferences from ConferenceEditor.
31
32It does not actually modify anything in DB (unless methods changing the conference instance returned by conferenceFromIndex are used),
33this is performed by other classes.
34
35\see ConferenceEditor, MainWindow::showConferences()
36*/
37class ConferenceModel : public QAbstractListModel {
38    Q_OBJECT
39public:
40    ConferenceModel(QObject* parent);
41    virtual ~ConferenceModel() { }
42
43    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
44    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
45
46    const Conference& conferenceFromIndex(const QModelIndex&) const;
47    Conference& conferenceFromIndex(const QModelIndex&);
48    QModelIndex indexFromId(int id) const;
49public slots:
50    void newConferenceBegin();
51    void newConferenceEnd(int conferenceId);
52    void conferenceRemoved();
53private:
54    // reinitialize list from database
55    void reinit()
56    {
57        beginResetModel();
58        conferences = Conference::getAll();
59        endResetModel();
60    }
61
62    QList<Conference> conferences;
63};
64
65#endif
Note: See TracBrowser for help on using the repository browser.