Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 1 | /* -*- 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 NDN_NCC_KEY_TREE_ITEM_HPP |
| 21 | #define NDN_NCC_KEY_TREE_ITEM_HPP |
| 22 | |
| 23 | #include <string> |
| 24 | #include <QList> |
| 25 | #include <QVariant> |
| 26 | |
| 27 | namespace ndn { |
| 28 | namespace ncc { |
| 29 | |
| 30 | class KeyTreeItem |
| 31 | { |
| 32 | public: |
| 33 | enum class Type { |
| 34 | ROOT = 0, |
| 35 | ID = 1, |
| 36 | KEY = 2, |
| 37 | CERT = 3 |
| 38 | }; |
| 39 | |
| 40 | public: |
| 41 | explicit |
| 42 | KeyTreeItem(const QVariant& name, |
| 43 | const QVariant& data = QVariant(), |
| 44 | Type type = Type::ROOT, |
| 45 | KeyTreeItem* parent = nullptr); |
| 46 | |
| 47 | ~KeyTreeItem(); |
| 48 | |
| 49 | void |
Yingdi Yu | 95dbc71 | 2016-03-21 09:56:57 -0700 | [diff] [blame] | 50 | setDefault(bool isDefault); |
| 51 | |
| 52 | bool |
| 53 | isDefault() |
| 54 | { |
| 55 | return m_isDefault; |
| 56 | } |
| 57 | |
| 58 | void |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 59 | setParent(KeyTreeItem* parent); |
| 60 | |
| 61 | void |
| 62 | appendChild(KeyTreeItem* child); |
| 63 | |
| 64 | KeyTreeItem* |
| 65 | child(int row); |
| 66 | |
| 67 | int |
| 68 | childCount() const; |
| 69 | |
| 70 | int |
| 71 | columnCount() const; |
| 72 | |
| 73 | QVariant |
| 74 | name() const; |
| 75 | |
| 76 | QVariant |
| 77 | data() const; |
| 78 | |
| 79 | Type |
| 80 | type() const; |
| 81 | |
| 82 | int |
| 83 | row() const; |
| 84 | |
| 85 | KeyTreeItem* |
| 86 | parentItem(); |
| 87 | |
| 88 | private: |
| 89 | QList<KeyTreeItem*> m_childItems; |
| 90 | QVariant m_name; |
| 91 | QVariant m_data; |
| 92 | Type m_type; |
Yingdi Yu | 95dbc71 | 2016-03-21 09:56:57 -0700 | [diff] [blame] | 93 | bool m_isDefault; |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 94 | KeyTreeItem* m_parentItem; |
| 95 | }; |
| 96 | |
| 97 | } // namespace ndn |
| 98 | } // namespace ncc |
| 99 | |
| 100 | #endif // NDN_NCC_KEY_TREE_ITEM_HPP |