• 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
usesnavigationcontext.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2008 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 #include "usesnavigationcontext.h"
20 
21 #include "useswidget.h"
22 #include <KLocalizedString>
23 #include <language/duchain/declaration.h>
24 #include <language/duchain/duchain.h>
25 #include <language/duchain/duchainlock.h>
26 
27 using namespace KDevelop;
28 
29 UsesNavigationContext::UsesNavigationContext(IndexedDeclaration declaration, AbstractNavigationContext* previousContext)
30  : AbstractNavigationContext(TopDUContextPointer(), previousContext)
31  , m_declaration(declaration)
32 {
33  m_widget = new UsesWidget(m_declaration);
34 }
35 
36 UsesNavigationContext::~UsesNavigationContext()
37 {
38  delete m_widget;
39 }
40 
41 QString UsesNavigationContext::name() const
42 {
43  return QStringLiteral("Uses");
44 }
45 
46 QString UsesNavigationContext::html(bool shorten)
47 {
48  Q_UNUSED(shorten);
49  clear();
50  modifyHtml() += QStringLiteral("<html><body><p>");
51 
52  if (auto context = previousContext()) {
53  modifyHtml() += navigationHighlight(i18n("Uses of "));
54  makeLink(context->name(), context->name(), NavigationAction(context));
55  } else {
56  KDevelop::DUChainReadLocker lock(DUChain::lock());
57  if (Declaration* decl = m_declaration.data()) {
58  makeLink(i18n("Uses of %1", decl->toString()), DeclarationPointer(
59  decl), NavigationAction::NavigateDeclaration);
60  }
61  }
62 
63  modifyHtml() += QStringLiteral("</p></body></html>");
64 
65  return currentHtml();
66 }
67 
68 QWidget* UsesNavigationContext::widget() const
69 {
70  return m_widget;
71 }
duchainlock.h
KDevelop::DUChainReadLocker
Customized read locker for the definition-use chain.
Definition: duchainlock.h:114
KDevelop::UsesNavigationContext::html
QString html(bool shorten) override
Here the context can return html to be displayed.
Definition: usesnavigationcontext.cpp:46
KDevelop::AbstractNavigationContext::currentHtml
QString currentHtml() const
Returns the html text being built in its current state.
Definition: abstractnavigationcontext.cpp:587
KDevelop::DUChain::lock
static DUChainLock * lock()
Retrieve the read write lock for the entire definition-use chain.
Definition: duchain.cpp:1283
KDevelop::UsesNavigationContext::~UsesNavigationContext
~UsesNavigationContext() override
Definition: usesnavigationcontext.cpp:36
QWidget
KDevelop::UsesWidget
A widget that allows browsing through all the uses of a declaration, and also through all declaration...
Definition: useswidget.h:154
KDevelop::DUChainPointer< TopDUContext >
KDevelop::UsesNavigationContext::widget
QWidget * widget() const override
Here the context can return a widget to be displayed.
Definition: usesnavigationcontext.cpp:68
KDevelop::Declaration
Represents a single declaration in a definition-use chain.
Definition: declaration.h:51
KDevelop::AbstractNavigationContext::makeLink
virtual void makeLink(const QString &name, const DeclarationPointer &declaration, NavigationAction::Type actionType)
Creates and registers a link to the given declaration, labeled by the given name.
Definition: abstractnavigationcontext.cpp:93
KDevelop::IndexedDeclaration
Represents a declaration only by its global indices.
Definition: indexeddeclaration.h:33
useswidget.h
declaration.h
KDevelop::NavigationAction
Definition: navigationaction.h:31
QString
KDevelop::AbstractNavigationContext::clear
void clear()
Definition: abstractnavigationcontext.cpp:146
KDevelop::AbstractNavigationContext::modifyHtml
TextHandler modifyHtml()
Returns a convenience object that allows writing "modifyHtml() += "Hallo";".
Definition: abstractnavigationcontext.h:139
KDevelop::AbstractNavigationContext::navigationHighlight
static const Colorizer navigationHighlight
Definition: abstractnavigationcontext.h:167
KDevelop::NavigationAction::NavigateDeclaration
Definition: navigationaction.h:35
KDevelop::IndexedDeclaration::data
Declaration * data() const
Definition: indexeddeclaration.h:47
KDevelop::AbstractNavigationContext
Definition: abstractnavigationcontext.h:64
duchain.h
usesnavigationcontext.h
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
KDevelop::UsesNavigationContext::name
QString name() const override
Definition: usesnavigationcontext.cpp:41
KDevelop::UsesNavigationContext::UsesNavigationContext
UsesNavigationContext(KDevelop::IndexedDeclaration declaration, AbstractNavigationContext *previousContext=nullptr)
Definition: usesnavigationcontext.cpp:29
KDevelop::AbstractNavigationContext::previousContext
AbstractNavigationContext * previousContext() const
Definition: abstractnavigationcontext.cpp:253
KDevelop::DeclarationPointer
DUChainPointer< Declaration > DeclarationPointer
Definition: duchainpointer.h:200
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 23:38:35 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