Warning, file /utilities/kgpg/core/KGpgNode.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2008, 2009 Rolf Eike Beer <kde@opensource.sf-tec.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef KGPGNODE_H 0008 #define KGPGNODE_H 0009 0010 #include "kgpgkey.h" 0011 0012 class KGpgExpandableNode; 0013 class KGpgKeyNode; 0014 class KGpgRootNode; 0015 class KGpgUidNode; 0016 class KGpgSignableNode; 0017 class KGpgSubkeyNode; 0018 class KGpgUatNode; 0019 class KGpgGroupNode; 0020 class KGpgRefNode; 0021 class KGpgGroupMemberNode; 0022 class KGpgSignNode; 0023 class KGpgOrphanNode; 0024 class KGpgItemModel; 0025 0026 /** 0027 * @brief The abstract base class for all classes representing keyring data 0028 */ 0029 class KGpgNode : public QObject 0030 { 0031 Q_OBJECT 0032 0033 friend class KGpgItemModel; 0034 0035 KGpgNode() = delete; 0036 protected: 0037 KGpgExpandableNode * const m_parent; 0038 KGpgItemModel *m_model; 0039 0040 /** 0041 * constructor 0042 * @param parent the parent node in item hierarchy 0043 */ 0044 explicit KGpgNode(KGpgExpandableNode *parent); 0045 0046 public: 0047 typedef QList<KGpgNode *> List; 0048 0049 /** 0050 * destructor 0051 */ 0052 ~KGpgNode() override; 0053 0054 /** 0055 * Returns if this node has child nodes 0056 * 0057 * This may be reimplemented by child classes so they can indicate that 0058 * there are child nodes before actually loading them. 0059 */ 0060 virtual bool hasChildren() const; 0061 /** 0062 * Return how many child nodes exist 0063 * 0064 * When the child nodes do not already exist this will create them. 0065 * This is the reason why this method is not const. 0066 */ 0067 virtual int getChildCount(); 0068 /** 0069 * Returns the child node at the given index 0070 * @param index child index 0071 * 0072 * index may be in range 0 to getChildCount() - 1. 0073 */ 0074 virtual KGpgNode *getChild(const int index) const; 0075 /** 0076 * Returns the index for a given child node 0077 * @return -1 if the given node is not a child of this object 0078 */ 0079 virtual int getChildIndex(KGpgNode *node) const; 0080 0081 /** 0082 * Returns the item type of this object 0083 * 0084 * Since every subclass returns a distinct value you can use the 0085 * result of this function to decide which cast to take. Note that 0086 * there are subclasses (KGpgKeyNode, KGpgGroupMemberNode) that 0087 * can return two different values. 0088 */ 0089 virtual KgpgCore::KgpgItemType getType() const = 0; 0090 virtual KgpgCore::KgpgKeyTrust getTrust() const; 0091 /** 0092 * Returns a string describing the size of this object 0093 * 0094 * Subclasses may return a value that makes sense for whatever 0095 * object they represent. 0096 * 0097 * The default implementation returns an empty string. 0098 */ 0099 virtual QString getSize() const; 0100 virtual QString getName() const; 0101 virtual QString getEmail() const; 0102 virtual QDateTime getExpiration() const; 0103 virtual QDateTime getCreation() const; 0104 virtual QString getId() const; 0105 virtual QString getComment() const; 0106 virtual QString getNameComment() const; 0107 /** 0108 * Returns the parent node in the key hierarchy 0109 * 0110 * For all "primary" items like keys and key groups this will 0111 * return the (invisible) root node. Calling this function for 0112 * the root node will return %nullptr. No other node but the root 0113 * node has a %nullptr parent. 0114 */ 0115 KGpgExpandableNode *getParentKeyNode() const; 0116 0117 KGpgExpandableNode *toExpandableNode(); 0118 const KGpgExpandableNode *toExpandableNode() const; 0119 KGpgSignableNode *toSignableNode(); 0120 const KGpgSignableNode *toSignableNode() const; 0121 KGpgKeyNode *toKeyNode(); 0122 const KGpgKeyNode *toKeyNode() const; 0123 KGpgRootNode *toRootNode(); 0124 const KGpgRootNode *toRootNode() const; 0125 KGpgUidNode *toUidNode(); 0126 const KGpgUidNode *toUidNode() const; 0127 KGpgSubkeyNode *toSubkeyNode(); 0128 const KGpgSubkeyNode *toSubkeyNode() const; 0129 KGpgUatNode *toUatNode(); 0130 const KGpgUatNode *toUatNode() const; 0131 KGpgGroupNode *toGroupNode(); 0132 const KGpgGroupNode *toGroupNode() const; 0133 KGpgRefNode *toRefNode(); 0134 const KGpgRefNode *toRefNode() const; 0135 KGpgGroupMemberNode *toGroupMemberNode(); 0136 const KGpgGroupMemberNode *toGroupMemberNode() const; 0137 KGpgSignNode *toSignNode(); 0138 const KGpgSignNode *toSignNode() const; 0139 KGpgOrphanNode *toOrphanNode(); 0140 const KGpgOrphanNode *toOrphanNode() const; 0141 }; 0142 0143 #endif /* KGPGNODE_H */