File indexing completed on 2024-05-05 04:39:49
0001 /* 0002 SPDX-FileCopyrightText: 2008 Hamish Rodda <rodda@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KDEVPLATFORM_PLUGIN_OVERRIDESPAGE_H 0008 #define KDEVPLATFORM_PLUGIN_OVERRIDESPAGE_H 0009 0010 #include <QWidget> 0011 0012 #include "language/duchain/declaration.h" 0013 #include "ipagefocus.h" 0014 0015 class QTreeWidget; 0016 class QTreeWidgetItem; 0017 0018 namespace KDevelop { 0019 0020 /** 0021 * Assistant page for choosing class functions, overridden from base classes. 0022 */ 0023 class OverridesPage : public QWidget, public IPageFocus 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 explicit OverridesPage(QWidget* parent); 0029 ~OverridesPage() override; 0030 0031 /** 0032 * Default implementation populates the tree with all virtual functions in the base classes. 0033 * Calls @c addPotentialOverride() on each function, where more filtering can be applied. 0034 * 0035 * @param directBases Declarations of base classes from which the new class inherits directly. 0036 * @param allBases Declarations of all base classes from which functions can be overridden 0037 */ 0038 virtual void addBaseClasses(const QList<DeclarationPointer>& directBases, 0039 const QList<DeclarationPointer>& allBases); 0040 /** 0041 * Add @p childDeclaration as potential override. 0042 * 0043 * Don't call @c KDevelop::OverridesPage::addPotentialOverride() in overloaded 0044 * class to filter a declaration. 0045 * 0046 * @p classItem The parent class from which @p childDeclaration stems from. 0047 * Should be used as parent for the override item. 0048 * @p childDeclaration The overridable function. 0049 */ 0050 virtual void addPotentialOverride(QTreeWidgetItem* classItem, 0051 const DeclarationPointer& childDeclaration); 0052 0053 /** 0054 * Add @p declarations as potential overrides under the category @p category. 0055 * 0056 * The DUChain must be locked for reading before calling this function 0057 * 0058 * @param category the user-visible category name 0059 * @param declarations a list of declarations that can be overridden or implemented in the new class 0060 */ 0061 void addCustomDeclarations(const QString& category, const QList< KDevelop::DeclarationPointer >& declarations); 0062 0063 QList<DeclarationPointer> selectedOverrides() const; 0064 0065 void clear(); 0066 0067 QTreeWidget* overrideTree() const; 0068 0069 QWidget* extraFunctionsContainer() const; 0070 0071 void setFocusToFirstEditWidget() override; 0072 0073 public Q_SLOTS: 0074 /** 0075 * Selects all functions for overriding 0076 */ 0077 virtual void selectAll(); 0078 /** 0079 * Deselects all potential overrides 0080 */ 0081 virtual void deselectAll(); 0082 0083 private: 0084 struct OverridesPagePrivate* const d; 0085 }; 0086 0087 } 0088 0089 #endif // KDEVPLATFORM_PLUGIN_OVERRIDESPAGE_H