blob: 1d89875e9e3d0540eee5cf0c91273b8086442b85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
/* Copyright 2008,2009 Rolf Eike Beer <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KGPGNODE_H
#define KGPGNODE_H
#include <QPixmap>
#include "kgpgkey.h"
class KGpgExpandableNode;
class KGpgKeyNode;
class KGpgRootNode;
class KGpgUidNode;
class KGpgSignableNode;
class KGpgSubkeyNode;
class KGpgUatNode;
class KGpgGroupNode;
class KGpgRefNode;
class KGpgGroupMemberNode;
class KGpgSignNode;
class KGpgOrphanNode;
class KGpgItemModel;
/**
* @brief The abstract base class for all classes representing keyring data
*/
class KGpgNode : public QObject
{
Q_OBJECT
friend class KGpgItemModel;
KGpgNode(); // = delete C++0x
protected:
KGpgExpandableNode *m_parent;
KGpgItemModel *m_model;
/**
* constructor
* @param parent the parent node in item hierarchy
*/
explicit KGpgNode(KGpgExpandableNode *parent);
public:
typedef QList<KGpgNode *> List;
/**
* destructor
*/
virtual ~KGpgNode();
/**
* Returns if this node has child nodes
*
* This may be reimplemented by child classes so they can indicate that
* there are child nodes before actually loading them.
*/
virtual bool hasChildren() const;
/**
* Return how many child nodes exist
*
* When the child nodes do not already exist this will create them.
* This is the reason why this method is not const.
*/
virtual int getChildCount();
/**
* Returns the child node at the given index
* @param index child index
*
* index may be in range 0 to getChildCount() - 1.
*/
virtual KGpgNode *getChild(const int index) const;
/**
* Returns the index for a given child node
* @return -1 if the given node is not a child of this object
*/
virtual int getChildIndex(KGpgNode *node) const;
/**
* Returns the item type of this object
*
* Since every subclass returns a distinct value you can use the
* result of this function to decide which cast to take. Note that
* there are subclasses (KGpgKeyNode, KGpgGroupMemberNode) that
* can return two different values.
*/
virtual KgpgCore::KgpgItemType getType() const = 0;
virtual KgpgCore::KgpgKeyTrust getTrust() const;
/**
* Returns a string describing the size of this object
*
* Subclasses may return a value that makes sense for whatever
* object they represent.
*
* The default implementation returns an empty string.
*/
virtual QString getSize() const;
virtual QString getName() const;
virtual QString getEmail() const;
virtual QDateTime getExpiration() const;
virtual QDateTime getCreation() const;
virtual QString getId() const;
virtual QString getComment() const;
virtual QString getNameComment() const;
/**
* Returns the parent node in the key hierarchy
*
* For all "primary" items like keys and key groups this will
* return the (invisible) root node. Calling this function for
* the root node will return %NULL. No other node but the root
* node has a %NULL parent.
*/
KGpgExpandableNode *getParentKeyNode() const;
KGpgExpandableNode *toExpandableNode();
const KGpgExpandableNode *toExpandableNode() const;
KGpgSignableNode *toSignableNode();
const KGpgSignableNode *toSignableNode() const;
KGpgKeyNode *toKeyNode();
const KGpgKeyNode *toKeyNode() const;
KGpgRootNode *toRootNode();
const KGpgRootNode *toRootNode() const;
KGpgUidNode *toUidNode();
const KGpgUidNode *toUidNode() const;
KGpgSubkeyNode *toSubkeyNode();
const KGpgSubkeyNode *toSubkeyNode() const;
KGpgUatNode *toUatNode();
const KGpgUatNode *toUatNode() const;
KGpgGroupNode *toGroupNode();
const KGpgGroupNode *toGroupNode() const;
KGpgRefNode *toRefNode();
const KGpgRefNode *toRefNode() const;
KGpgGroupMemberNode *toGroupMemberNode();
const KGpgGroupMemberNode *toGroupMemberNode() const;
KGpgSignNode *toSignNode();
const KGpgSignNode *toSignNode() const;
KGpgOrphanNode *toOrphanNode();
const KGpgOrphanNode *toOrphanNode() const;
};
#endif /* KGPGNODE_H */
|