blob: 45658b35d5f414bbb7530570035bef5b66404d5c [file] [log] [blame]
Qi Zhaobd19e072017-03-05 15:12:46 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2017, Regents of the University of California,
4 *
5 * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD
6 * authors and contributors.
7 *
8 * NFD Control Center is free software: you can redistribute it and/or modify it under the
9 * terms of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with NFD
17 * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef NCC_CHANNEL_STATUS_HPP
21#define NCC_CHANNEL_STATUS_HPP
22
23#include <QtCore/QAbstractListModel>
24#include <QtCore/QStringList>
25
26#include <ndn-cxx/mgmt/nfd/channel-status.hpp>
27
28namespace ndn {
29
30class ChannelStatusItem
31{
32public:
33 ChannelStatusItem(const QString& channel)
34 : m_channel(channel)
35 {
36 }
37
38 const QString&
39 channel() const
40 {
41 return m_channel;
42 }
43
44private:
45 QString m_channel;
46};
47
48
49class ChannelStatusModel : public QAbstractListModel
50{
51 Q_OBJECT
52
53signals:
54 void
55 onDataReceived(std::vector<ndn::nfd::ChannelStatus> status);
56
57public:
58
59 enum ChannelStatusRoles {
60 ChannelRole = Qt::UserRole + 1
61 };
62
63 explicit
64 ChannelStatusModel(QObject* parent = 0);
65
66 int
67 rowCount(const QModelIndex& parent = QModelIndex()) const;
68
69 void
70 addItem(const ChannelStatusItem& item);
71
72 QVariant
73 data(const QModelIndex& index, int role) const;
74
75 QHash<int, QByteArray>
76 roleNames() const;
77
78 void
79 clear();
80
81 void
82 onTimeout();
83
84private slots:
85
86 void
87 updateStatus(std::vector<ndn::nfd::ChannelStatus> status);
88
89private:
90 QList<ChannelStatusItem> m_items;
91};
92
93} // namespace ndn
94
95#endif // NCC_CHANNEL_STATUS_HPP