File indexing completed on 2025-03-16 08:32:46
0001 /* 0002 SPDX-FileCopyrightText: 2008, 2009, 2012 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 KGPGEXPANDABLENODE_H 0008 #define KGPGEXPANDABLENODE_H 0009 0010 #include "KGpgNode.h" 0011 0012 class KGpgRefNode; 0013 0014 /** 0015 * @brief The abstract base class for all classes that may have child objects 0016 * 0017 * Every class that represents something in the keyring that may have 0018 * child objects inherits from this class. That does not mean that every 0019 * child object always has children, but every child \em may have children. 0020 */ 0021 class KGpgExpandableNode : public KGpgNode 0022 { 0023 Q_OBJECT 0024 0025 friend class KGpgRefNode; 0026 protected: 0027 KGpgNode::List children; 0028 0029 /** 0030 * reimplemented in every base class to read in the child data 0031 * 0032 * This allows the child objects to delay the loading of the 0033 * child objects until they are really needed to avoid time 0034 * consuming operations for data never used. 0035 */ 0036 virtual void readChildren() = 0; 0037 0038 explicit KGpgExpandableNode(KGpgExpandableNode *parent = nullptr); 0039 public: 0040 ~KGpgExpandableNode() override; 0041 0042 /** 0043 * check if there are any child nodes 0044 * 0045 * The default implementation returns true if any child nodes were loaded. 0046 * This may be reimplemented by child classes so they can indicate that 0047 * there are child nodes before actually loading them. 0048 * 0049 * This method indicates if there are children if this node is expanded. 0050 * In contrast wasExpanded() will only return true if the child nodes 0051 * are actually present in memory. 0052 */ 0053 bool hasChildren() const override; 0054 /** 0055 * check if there are any child nodes present in memory 0056 * 0057 * Returns true if any child nodes were loaded. 0058 * 0059 * This method indicates if the children of this node are already loaded 0060 * into memory. In contrast hasChildren() may return true even if the child 0061 * objects are not present in memory. 0062 */ 0063 virtual bool wasExpanded() const; 0064 int getChildCount() override; 0065 virtual const KGpgNode::List &getChildren() const; 0066 KGpgNode *getChild(const int index) const override; 0067 int getChildIndex(KGpgNode *node) const override; 0068 virtual void deleteChild(KGpgNode *child); 0069 }; 0070 0071 #endif /* KGPGEXPANDABLENODE_H */