blob: 90bdf867681f94cbe1849d96b0a392addba72abd [file] [log] [blame]
taylorchuc27dd482014-05-17 20:06:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2014, 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_FORWARDER_STATUS_HPP
21#define NCC_FORWARDER_STATUS_HPP
22
23#include <QtCore/QAbstractListModel>
24#include <QtCore/QStringList>
25
26#include <ndn-cxx/face.hpp>
27
28namespace ndn {
29
30class ForwarderStatusItem
31{
32public:
33 ForwarderStatusItem(const QString& type, const QString& value)
34 : m_type(type)
35 , m_value(value)
36 {
37 }
38
39 const QString&
40 type() const
41 {
42 return m_type;
43 }
44
45 const QString&
46 value() const
47 {
48 return m_value;
49 }
50
51private:
52 QString m_type;
53 QString m_value;
54};
55
56
57class ForwarderStatusModel : public QAbstractListModel
58{
59 Q_OBJECT
60
61signals:
62 void
63 onDataReceived(ndn::shared_ptr<const ndn::Data>);
64
65public:
66
67 enum ForwarderStatusRoles {
68 TypeRole = Qt::UserRole + 1,
69 ValueRole
70 };
71
72 explicit
Alexander Afanasyev4086d512014-07-11 15:56:33 -070073 ForwarderStatusModel(QObject* parent = 0);
taylorchuc27dd482014-05-17 20:06:49 -070074
75 int
76 rowCount(const QModelIndex& parent = QModelIndex()) const;
77
78 void
79 addItem(const ForwarderStatusItem& item);
80
81 QVariant
82 data(const QModelIndex& index, int role) const;
83
84 QHash<int, QByteArray>
85 roleNames() const;
86
taylorchuc27dd482014-05-17 20:06:49 -070087 void
88 clear();
89
90 void
91 afterFetchedVersionInformation(const Data& data);
92
93 void
94 onTimeout(const Interest& interest);
95
96private slots:
97
98 void
99 updateStatus(ndn::shared_ptr<const ndn::Data> data);
100
101private:
taylorchuc27dd482014-05-17 20:06:49 -0700102 QList<ForwarderStatusItem> m_items;
103};
104
105} // namespace ndn
106
107#endif // NCC_FORWARDER_STATUS_HPP