blob: bfc5788178b48df2b05b07343283e065f0f3fe3b [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
Yingdi Yu95dbc712016-03-21 09:56:57 -070027KeyTreeItem::KeyTreeItem(const QVariant& name, const QVariant& data,
28 Type type, KeyTreeItem* parent)
Yingdi Yu1f824642016-03-20 17:07:22 -070029 : m_name(name)
30 , m_data(data)
31 , m_type(type)
Yingdi Yu95dbc712016-03-21 09:56:57 -070032 , m_isDefault(false)
Yingdi Yu1f824642016-03-20 17:07:22 -070033 , m_parentItem(parent)
34{
35}
36
37KeyTreeItem::~KeyTreeItem()
38{
39 qDeleteAll(m_childItems);
40}
41
42void
Yingdi Yu95dbc712016-03-21 09:56:57 -070043KeyTreeItem::setDefault(bool isDefault)
44{
45 m_isDefault = isDefault;
46}
47
48void
Yingdi Yu1f824642016-03-20 17:07:22 -070049KeyTreeItem::setParent(KeyTreeItem* parent)
50{
51 m_parentItem = parent;
52}
53
54void
55KeyTreeItem::appendChild(KeyTreeItem* item)
56{
57 m_childItems.append(item);
58}
59
60KeyTreeItem*
61KeyTreeItem::child(int row)
62{
63 return m_childItems.value(row);
64}
65
66int
67KeyTreeItem::childCount() const
68{
69 return m_childItems.count();
70}
71
72int
73KeyTreeItem::columnCount() const
74{
75 return 1;
76}
77
78QVariant
79KeyTreeItem::name() const
80{
81 return m_name;
82}
83
84QVariant
85KeyTreeItem::data() const
86{
87 return m_data;
88}
89
90KeyTreeItem::Type
91KeyTreeItem::type() const
92{
93 return m_type;
94}
95
96KeyTreeItem*
97KeyTreeItem::parentItem()
98{
99 return m_parentItem;
100}
101
102int
103KeyTreeItem::row() const
104{
105 if (m_parentItem)
106 return m_parentItem->m_childItems.indexOf(const_cast<KeyTreeItem*>(this));
107
108 return 0;
109}
110
111} // namespace ndn
112} // namespace ncc