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 |
| 50 | setParent(KeyTreeItem* parent); |
| 51 | |
| 52 | void |
| 53 | appendChild(KeyTreeItem* child); |
| 54 | |
| 55 | KeyTreeItem* |
| 56 | child(int row); |
| 57 | |
| 58 | int |
| 59 | childCount() const; |
| 60 | |
| 61 | int |
| 62 | columnCount() const; |
| 63 | |
| 64 | QVariant |
| 65 | name() const; |
| 66 | |
| 67 | QVariant |
| 68 | data() const; |
| 69 | |
| 70 | Type |
| 71 | type() const; |
| 72 | |
| 73 | int |
| 74 | row() const; |
| 75 | |
| 76 | KeyTreeItem* |
| 77 | parentItem(); |
| 78 | |
| 79 | private: |
| 80 | QList<KeyTreeItem*> m_childItems; |
| 81 | QVariant m_name; |
| 82 | QVariant m_data; |
| 83 | Type m_type; |
| 84 | KeyTreeItem* m_parentItem; |
| 85 | }; |
| 86 | |
| 87 | } // namespace ndn |
| 88 | } // namespace ncc |
| 89 | |
| 90 | #endif // NDN_NCC_KEY_TREE_ITEM_HPP |