Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / notify / notifytablemodel.h
blob339ab6ada634c5a69c74cfcf6be1c47f175afbad
1 /**
2 ******************************************************************************
4 * @file notifytablemodel.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @brief
7 * @see The GNU Public License (GPL) Version 3
8 * @defgroup notifyplugin
9 * @{
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef NOTIFYTABLEMODEL_H
29 #define NOTIFYTABLEMODEL_H
32 #include <QAbstractTableModel>
33 #include <QList>
34 #include <QDataStream>
35 #include "notificationitem.h"
37 enum ColumnNames { eMessageName, eRepeatValue, eExpireTimer, eTurnOn };
39 class NotifyTableModel : public QAbstractTableModel {
40 Q_OBJECT
42 enum { eColumnCount = 4 };
44 public:
46 NotifyTableModel(QList<NotificationItem *> & parentList, QObject *parent = 0);
47 int rowCount(const QModelIndex & parent = QModelIndex()) const
49 Q_UNUSED(parent);
50 return _list.count();
53 int columnCount(const QModelIndex & /*parent*/) const
55 return eColumnCount;
58 Qt::ItemFlags flags(const QModelIndex &index) const
60 if (!index.isValid()) {
61 return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;
64 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
66 QStringList mimeTypes() const;
67 Qt::DropActions supportedDropActions() const;
68 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
69 int column, const QModelIndex & parent);
70 QMimeData *mimeData(const QModelIndexList &indexes) const;
73 bool setData(const QModelIndex &index, const QVariant &value, int role);
74 QVariant data(const QModelIndex &index, int role) const;
75 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
76 bool insertRows(int position, int rows, const QModelIndex &index);
77 bool removeRows(int position, int rows, const QModelIndex &index);
78 void entryAdded(NotificationItem *item);
80 signals:
81 void dragRows(int position, int count);
83 private slots:
84 void entryUpdated(int offset);
85 void dropRows(int position, int count) const;
87 private:
88 QList<NotificationItem *> & _list;
89 QStringList _headerStrings;
92 #endif // NOTIFYTABLEMODEL_H