File indexing completed on 2024-06-23 04:34:41
0001 /* 0002 SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KDEVPLATFORM_ABSTRACTNAVIGATIONWIDGET_H 0008 #define KDEVPLATFORM_ABSTRACTNAVIGATIONWIDGET_H 0009 0010 #include <language/languageexport.h> 0011 #include <QPointer> 0012 #include <QWidget> 0013 0014 #include "../../interfaces/quickopendataprovider.h" 0015 #include "abstractnavigationcontext.h" 0016 0017 class QTextBrowser; 0018 0019 namespace KDevelop { 0020 class AbstractNavigationWidgetPrivate; 0021 0022 /** 0023 * This class deleted itself when its part is deleted, so always use a QPointer when referencing it. 0024 * The duchain must be read-locked for most operations 0025 * */ 0026 class KDEVPLATFORMLANGUAGE_EXPORT AbstractNavigationWidget 0027 : public QWidget 0028 , public QuickOpenEmbeddedWidgetInterface 0029 { 0030 Q_OBJECT 0031 Q_INTERFACES(KDevelop::QuickOpenEmbeddedWidgetInterface) 0032 0033 public: 0034 enum DisplayHint { 0035 NoHints = 0x0, // < Normal display 0036 EmbeddableWidget = 0x1, // < Omit parts which are only useful for the navigation popup 0037 }; 0038 Q_DECLARE_FLAGS(DisplayHints, DisplayHint) 0039 AbstractNavigationWidget(); 0040 ~AbstractNavigationWidget() override; 0041 0042 void setContext(NavigationContextPointer context, int initBrowser = 400); 0043 void setDisplayHints(DisplayHints hints); 0044 0045 QSize sizeHint() const override; 0046 0047 public Q_SLOTS: 0048 /// keyboard navigation support 0049 bool next() override; 0050 bool previous() override; 0051 bool up() override; 0052 bool down() override; 0053 void accept() override; 0054 void back() override; 0055 void resetNavigationState() override; 0056 0057 ///These are temporarily for gettings these events directly from kate 0058 ///@todo Do this through a public interface post 4.2 0059 void embeddedWidgetRight(); 0060 ///Keyboard-action "previous" 0061 void embeddedWidgetLeft(); 0062 ///Keyboard-action "accept" 0063 void embeddedWidgetAccept(); 0064 void embeddedWidgetUp(); 0065 void embeddedWidgetDown(); 0066 0067 NavigationContextPointer context() const; 0068 0069 void navigateDeclaration(const KDevelop::IndexedDeclaration& decl); 0070 0071 Q_SIGNALS: 0072 void sizeHintChanged(); 0073 /// Emitted whenever the current navigation-context has changed 0074 /// @param wasInitial whether the previous context was the initial context 0075 /// @param isInitial whether the current context is the initial context 0076 void contextChanged(bool wasInitial, bool isInitial); 0077 0078 protected: 0079 void wheelEvent(QWheelEvent*) override; 0080 void updateIdealSize() const; 0081 0082 void initBrowser(int height); 0083 void update(); 0084 0085 private: 0086 const QScopedPointer<class AbstractNavigationWidgetPrivate> d_ptr; 0087 Q_DECLARE_PRIVATE(AbstractNavigationWidget) 0088 }; 0089 } 0090 0091 #endif