dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
notifytablemodel.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 #ifndef NOTIFYTABLEMODEL_H
31 #define NOTIFYTABLEMODEL_H
32 
33 #include <QAbstractTableModel>
34 #include <QList>
35 #include "notificationitem.h"
36 
38 
39 class NotifyTableModel : public QAbstractTableModel
40 {
41  Q_OBJECT
42 
43  enum { eColumnCount = 4 };
44 
45 public:
46  NotifyTableModel(QList<NotificationItem *> &parentList, QObject *parent = nullptr);
47  int rowCount(const QModelIndex &parent = QModelIndex()) const
48  {
49  Q_UNUSED(parent);
50  return _list.count();
51  }
52 
53  int columnCount(const QModelIndex & /*parent*/) const { return eColumnCount; }
54 
55  Qt::ItemFlags flags(const QModelIndex &index) const
56  {
57  if (!index.isValid())
58  return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;
59 
60  return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled
61  | Qt::ItemIsDropEnabled;
62  }
63  QStringList mimeTypes() const;
64  Qt::DropActions supportedDropActions() const;
65  bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
66  const QModelIndex &parent);
67  QMimeData *mimeData(const QModelIndexList &indexes) const;
68 
69  bool setData(const QModelIndex &index, const QVariant &value, int role);
70  QVariant data(const QModelIndex &index, int role) const;
71  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
72  bool insertRows(int position, int rows, const QModelIndex &index);
73  bool removeRows(int position, int rows, const QModelIndex &index);
74  void entryAdded(NotificationItem *item);
75 
76 signals:
77  void dragRows(int position, int count);
78 
79 public slots:
80  void entryUpdated(int offset);
81 
82 private slots:
83  void dropRows(int position, int count) const;
84 
85 private:
87  QStringList _headerStrings;
88 };
89 
90 #endif // NOTIFYTABLEMODEL_H
ColumnNames
NotifyTableModel(QList< NotificationItem * > &parentList, QObject *parent=nullptr)
int columnCount(const QModelIndex &) const
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
QStringList mimeTypes() const
int rowCount(const QModelIndex &parent=QModelIndex()) const
void entryAdded(NotificationItem *item)
QMimeData * mimeData(const QModelIndexList &indexes) const
Qt::ItemFlags flags(const QModelIndex &index) const
bool removeRows(int position, int rows, const QModelIndex &index)
bool setData(const QModelIndex &index, const QVariant &value, int role)
bool insertRows(int position, int rows, const QModelIndex &index)
QVariant data(const QModelIndex &index, int role) const
Qt::DropActions supportedDropActions() const
void dragRows(int position, int count)
void entryUpdated(int offset)
QVariant headerData(int section, Qt::Orientation orientation, int role) const