Debian Codegraph @

src/models/hostlistmodel.h

raw
1 /*
2 This file is part of Icecream.
3
4 Copyright (c) 2012 Kevin Funk <[email protected]>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #ifndef ICEMON_HOSTLISTMODEL_H
22 #define ICEMON_HOSTLISTMODEL_H
23
24 #include <QAbstractItemModel>
25 #include <QPointer>
26
27 #include "hostinfo.h"
28 #include "types.h"
29
30 class Monitor;
31
32 class HostListModel
33 : public QAbstractListModel
34 {
35 Q_OBJECT
36
37 public:
38 enum Column
39 {
40 ColumnID,
41 ColumnName,
42 ColumnNoRemote,
43 ColumnColor,
44 ColumnIP,
45 ColumnPlatform,
46 ColumnProtocol,
47 ColumnFeatures,
48 ColumnMaxJobs,
49 ColumnSpeed,
50 ColumnLoad,
51 _ColumnCount
52 };
53
54 enum Role
55 {
56 HostIdRole = Qt::UserRole
57 };
58
59 explicit HostListModel(QObject *parent = nullptr);
60
61 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
62 QVariant data(const QModelIndex &index, int role) const override;
63 int columnCount(const QModelIndex &parent) const override;
64 int rowCount(const QModelIndex &parent) const override;
65 QModelIndex parent(const QModelIndex &child) const override;
66
67 Monitor *monitor() const;
68 void setMonitor(Monitor *monitor);
69
70 HostInfo hostInfoForIndex(const QModelIndex &index) const;
71 QModelIndex indexForHostInfo(const HostInfo &info, int column) const;
72
73 private Q_SLOTS:
74 void checkNode(HostId hostId);
75 void removeNodeById(HostId hostId);
76
77 private:
78 void fill();
79
80 QPointer<Monitor> m_monitor;
81 QVector<HostInfo> m_hostInfos;
82 };
83
84 #endif // ICEMON_HOSTLISTMODEL_H
85
86 class Monitor;