blob: 070537e5337b6feafae6bed005260fed9216f782 [file] [log] [blame]
Yingdi Yu1f824642016-03-20 17:07:22 -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
21#include <QStringList>
22#include "key-tree-item.hpp"
23
24namespace ndn {
25namespace ncc {
26
27KeyTreeItem::KeyTreeItem(const QVariant& name, const QVariant& data, Type type, KeyTreeItem* parent)
28 : m_name(name)
29 , m_data(data)
30 , m_type(type)
31 , m_parentItem(parent)
32{
33}
34
35KeyTreeItem::~KeyTreeItem()
36{
37 qDeleteAll(m_childItems);
38}
39
40void
41KeyTreeItem::setParent(KeyTreeItem* parent)
42{
43 m_parentItem = parent;
44}
45
46void
47KeyTreeItem::appendChild(KeyTreeItem* item)
48{
49 m_childItems.append(item);
50}
51
52KeyTreeItem*
53KeyTreeItem::child(int row)
54{
55 return m_childItems.value(row);
56}
57
58int
59KeyTreeItem::childCount() const
60{
61 return m_childItems.count();
62}
63
64int
65KeyTreeItem::columnCount() const
66{
67 return 1;
68}
69
70QVariant
71KeyTreeItem::name() const
72{
73 return m_name;
74}
75
76QVariant
77KeyTreeItem::data() const
78{
79 return m_data;
80}
81
82KeyTreeItem::Type
83KeyTreeItem::type() const
84{
85 return m_type;
86}
87
88KeyTreeItem*
89KeyTreeItem::parentItem()
90{
91 return m_parentItem;
92}
93
94int
95KeyTreeItem::row() const
96{
97 if (m_parentItem)
98 return m_parentItem->m_childItems.indexOf(const_cast<KeyTreeItem*>(this));
99
100 return 0;
101}
102
103} // namespace ndn
104} // namespace ncc