• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/language/duchain

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • language
  • duchain
  • navigation
abstractnavigationcontext.h
Go to the documentation of this file.
1 /*
2  Copyright 2007 David Nolden <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KDEVPLATFORM_ABSTRACTNAVIGATIONCONTEXT_H
20 #define KDEVPLATFORM_ABSTRACTNAVIGATIONCONTEXT_H
21 
22 #include <QExplicitlySharedDataPointer>
23 
24 #include <language/languageexport.h>
25 #include "../indexeddeclaration.h"
26 #include "navigationaction.h"
27 
28 namespace KDevelop {
29 class AbstractNavigationContextPrivate;
30 
36 struct KDEVPLATFORMLANGUAGE_EXPORT Colorizer
37 {
38  enum FormattingFlag {
39  Nothing = 0x0,
40  Bold = 0x1,
41  Italic = 0x2,
42  Fixed = 0x4
43  };
44  Q_DECLARE_FLAGS(Formatting, FormattingFlag)
45  explicit Colorizer(const QString& color, Formatting formatting = Nothing)
46  : m_color(color)
47  , m_formatting(formatting)
48  {
49  }
50 
51  QString operator()(const QString& str) const;
52 
53  QString m_color;
54  Formatting m_formatting;
55 };
56 
57 #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
58 Q_DECLARE_OPERATORS_FOR_FLAGS(Colorizer::Formatting)
59 #endif
60 
61 class AbstractNavigationContext;
62 using NavigationContextPointer = QExplicitlySharedDataPointer<AbstractNavigationContext>;
63 
64 class KDEVPLATFORMLANGUAGE_EXPORT AbstractNavigationContext
65  : public QObject
66  , public QSharedData
67 {
68  Q_OBJECT
69 
70 public:
71  explicit AbstractNavigationContext(const TopDUContextPointer& topContext = TopDUContextPointer(),
72  AbstractNavigationContext* previousContext = nullptr);
73  ~AbstractNavigationContext() override;
74 
75  int linkCount() const;
76  bool nextLink();
77  bool previousLink();
78  bool up();
79  bool down();
80  void resetNavigation();
81 
82  NavigationContextPointer accept();
83  NavigationContextPointer back();
84  NavigationContextPointer accept(IndexedDeclaration decl);
85  NavigationContextPointer acceptLink(const QString& link);
86  NavigationAction currentAction() const;
87 
88  virtual QString name() const = 0;
91  virtual QString html(bool shorten = false);
96  virtual QWidget* widget() const;
97 
100  virtual bool isWidgetMaximized() const;
101 
104  bool alreadyComputed() const;
105 
106  TopDUContextPointer topContext() const;
107  void setTopContext(const TopDUContextPointer& context);
108 
109  void executeLink(const QString& link);
110  NavigationContextPointer execute(const NavigationAction& action);
111 
112 Q_SIGNALS:
113  void contentsChanged();
114 
115 protected:
116  AbstractNavigationContext* previousContext() const;
117  virtual void setPreviousContext(AbstractNavigationContext* previousContext);
118 
119  struct TextHandler
120  {
121  explicit TextHandler(AbstractNavigationContext* c) : context(c)
122  {
123  }
124  void operator+=(const QString& str) const
125  {
126  context->addHtml(str);
127  }
128  AbstractNavigationContext* context;
129  };
130 
132  virtual NavigationContextPointer executeKeyAction(const QString& key);
133 
135  void addHtml(const QString& html);
137  QString currentHtml() const;
139  TextHandler modifyHtml()
140  {
141  return TextHandler(this);
142  }
143 
144  //Clears the computed html and links
145  void clear();
146 
148  virtual void makeLink(const QString& name, const DeclarationPointer& declaration,
149  NavigationAction::Type actionType);
150 
152  void makeLink(const QString& name, const QString& targetId, const NavigationAction& action);
153 
155  QString createLink(const QString& name, const QString& targetId, const NavigationAction& action);
156 
157  NavigationContextPointer registerChild(const DeclarationPointer& /*declaration*/);
158  NavigationContextPointer registerChild(AbstractNavigationContext* context);
159 
160  virtual QString declarationKind(const DeclarationPointer& decl);
161 
162  static const Colorizer typeHighlight;
163  static const Colorizer errorHighlight;
164  static const Colorizer labelHighlight;
165  static const Colorizer codeHighlight;
166  static const Colorizer propertyHighlight;
167  static const Colorizer navigationHighlight;
168  static const Colorizer importantHighlight;
169  static const Colorizer commentHighlight;
170  static const Colorizer nameHighlight;
171 
172 private:
173  const QScopedPointer<class AbstractNavigationContextPrivate> d_ptr;
174  Q_DECLARE_PRIVATE(AbstractNavigationContext)
175 };
176 
177 }
178 
179 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
180 Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::Colorizer::Formatting)
181 #endif
182 
183 #endif
QSharedData
KDevelop::AbstractNavigationContext::typeHighlight
static const Colorizer typeHighlight
Definition: abstractnavigationcontext.h:162
KDevelop::AbstractNavigationContext::TextHandler::TextHandler
TextHandler(AbstractNavigationContext *c)
Definition: abstractnavigationcontext.h:121
KDevelop::AbstractNavigationContext::labelHighlight
static const Colorizer labelHighlight
Definition: abstractnavigationcontext.h:164
KDevelop::Colorizer::FormattingFlag
FormattingFlag
Definition: abstractnavigationcontext.h:38
QWidget
KDevelop::AbstractNavigationContext::commentHighlight
static const Colorizer commentHighlight
Definition: abstractnavigationcontext.h:169
KDevelop::AbstractNavigationContext::codeHighlight
static const Colorizer codeHighlight
Definition: abstractnavigationcontext.h:165
KDevelop::DUChainPointer< TopDUContext >
QExplicitlySharedDataPointer
Definition: topducontext.h:28
KDevelop::Colorizer::m_color
QString m_color
Definition: abstractnavigationcontext.h:53
KDevelop::IndexedDeclaration
Represents a declaration only by its global indices.
Definition: indexeddeclaration.h:33
QObject
KDevelop::AbstractNavigationContext::TextHandler::context
AbstractNavigationContext * context
Definition: abstractnavigationcontext.h:128
KDevelop::NavigationAction
Definition: navigationaction.h:31
KDevelop::AbstractNavigationContext::propertyHighlight
static const Colorizer propertyHighlight
Definition: abstractnavigationcontext.h:166
KDevelop::NavigationAction::Type
Type
Definition: navigationaction.h:33
QString
KDevelop::AbstractNavigationContext::TextHandler
Definition: abstractnavigationcontext.h:119
KDevelop::AbstractNavigationContext::modifyHtml
TextHandler modifyHtml()
Returns a convenience object that allows writing "modifyHtml() += "Hallo";".
Definition: abstractnavigationcontext.h:139
KDevelop::Colorizer
A helper-class for elegant colorization of html-strings .
Definition: abstractnavigationcontext.h:36
KDevelop::AbstractNavigationContext::navigationHighlight
static const Colorizer navigationHighlight
Definition: abstractnavigationcontext.h:167
KDevelop::AbstractNavigationContext::TextHandler::operator+=
void operator+=(const QString &str) const
Definition: abstractnavigationcontext.h:124
QScopedPointer< class AbstractNavigationContextPrivate >
KDevelop::AbstractNavigationContext
Definition: abstractnavigationcontext.h:64
KDevelop::AbstractNavigationContext::importantHighlight
static const Colorizer importantHighlight
Definition: abstractnavigationcontext.h:168
KDevelop::Colorizer::m_formatting
Formatting m_formatting
Definition: abstractnavigationcontext.h:54
KDevelop::TopDUContextPointer
DUChainPointer< TopDUContext > TopDUContextPointer
Definition: duchainpointer.h:199
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
KDevelop::AbstractNavigationContext::errorHighlight
static const Colorizer errorHighlight
Definition: abstractnavigationcontext.h:163
navigationaction.h
KDevelop::AbstractNavigationContext::nameHighlight
static const Colorizer nameHighlight
Definition: abstractnavigationcontext.h:170
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Mar 7 2021 23:29:30 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/language/duchain

Skip menu "kdevplatform/language/duchain"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal