File indexing completed on 2024-04-28 04:38:22
0001 /* 0002 SPDX-FileCopyrightText: 2008 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_PLUGIN_CONTEXTBROWSERVIEW_H 0008 #define KDEVPLATFORM_PLUGIN_CONTEXTBROWSERVIEW_H 0009 0010 #include <QWidget> 0011 #include <QPointer> 0012 0013 #include <language/duchain/topducontext.h> 0014 #include <interfaces/itoolviewactionlistener.h> 0015 0016 class ContextBrowserPlugin; 0017 class QVBoxLayout; 0018 class QHBoxLayout; 0019 class QAction; 0020 class KToggleAction; 0021 0022 namespace KDevelop { 0023 class IDocument; 0024 } 0025 0026 class ContextBrowserView 0027 : public QWidget 0028 , public KDevelop::IToolViewActionListener 0029 { 0030 Q_OBJECT 0031 Q_INTERFACES(KDevelop::IToolViewActionListener) 0032 0033 public: 0034 ContextBrowserView(ContextBrowserPlugin*, QWidget* parent); 0035 ~ContextBrowserView() override; 0036 0037 //duchain must be locked 0038 void setContext(KDevelop::DUContext* context); 0039 void setDeclaration(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext, bool force = false); 0040 void setSpecialNavigationWidget(QWidget*); 0041 void updateMainWidget(QWidget*); 0042 0043 /** Allows a single update of the view even if in locked state. 0044 * This is needed to browse while the locked button is checked. */ 0045 void allowLockedUpdate(); 0046 0047 ///Returns the currently locked declaration, or invalid of none is locked atm. 0048 KDevelop::IndexedDeclaration lockedDeclaration() const; 0049 0050 void setNavigationWidget(QWidget* widget); 0051 0052 QWidget* navigationWidget() 0053 { 0054 return m_navigationWidget; 0055 } 0056 0057 //duchain must be locked 0058 KDevelop::AbstractNavigationWidget* createWidget(KDevelop::DUContext* context); 0059 0060 //duchain must be locked 0061 KDevelop::AbstractNavigationWidget* createWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext); 0062 0063 KDevelop::IndexedDeclaration declaration() const; 0064 0065 ///Returns whether the view is currently locked 0066 bool isLocked() const; 0067 0068 private Q_SLOTS: 0069 void declarationMenu(); 0070 void navigationContextChanged(bool wasInitial, bool isInitial); 0071 void selectNextItem() override; 0072 void selectPreviousItem() override; 0073 0074 private: 0075 void showEvent(QShowEvent* event) override; 0076 bool event(QEvent* event) override; 0077 0078 void focusInEvent(QFocusEvent* event) override; 0079 void focusOutEvent(QFocusEvent* event) override; 0080 void resetWidget(); 0081 0082 private: 0083 0084 KDevelop::IndexedDeclaration m_declaration; 0085 0086 ContextBrowserPlugin* m_plugin; 0087 QVBoxLayout* m_layout; 0088 KToggleAction* m_lockAction; 0089 QAction* m_declarationMenuAction; 0090 QHBoxLayout* m_buttons; 0091 0092 QPointer<QWidget> m_navigationWidget; 0093 KDevelop::DeclarationId m_navigationWidgetDeclaration; 0094 bool m_allowLockedUpdate; 0095 KDevelop::IndexedTopDUContext m_lastUsedTopContext; 0096 0097 KDevelop::IndexedDUContext m_context; 0098 // Whether the lock-button was activated automatically due to user navigation 0099 bool m_autoLocked; 0100 }; 0101 0102 #endif