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

kdevplatform/debugger

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • debugger
  • variable
variablecollection.h
Go to the documentation of this file.
1 /*
2  * KDevelop Debugger Support
3  *
4  * Copyright 2007 Hamish Rodda <[email protected]>
5  * Copyright 2008 Vladimir Prus <[email protected]>
6  * Copyright 2009 Niko Sams <[email protected]>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this program; if not, write to the
20  * Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef KDEVPLATFORM_VARIABLECOLLECTION_H
25 #define KDEVPLATFORM_VARIABLECOLLECTION_H
26 
27 #include <QPointer>
28 
29 #include <KLocalizedString>
30 #include <KTextEditor/TextHintInterface>
31 
32 #include <debugger/debuggerexport.h>
33 #include "../util/treemodel.h"
34 #include "../util/treeitem.h"
35 #include "../../interfaces/idocument.h"
36 #include "../../interfaces/idebugcontroller.h"
37 
38 namespace KDevMI { namespace GDB {
39  class GdbTest;
40 }
41 }
42 
43 namespace KDevelop
44 {
45 class VariableToolTip;
46 class IDebugSession;
47 
48 class KDEVPLATFORMDEBUGGER_EXPORT Variable : public TreeItem
49 {
50  Q_OBJECT
51  friend class KDevMI::GDB::GdbTest;
52 public:
53 protected:
54  Variable(TreeModel* model, TreeItem* parent,
55  const QString& expression,
56  const QString& display = {});
57 
58 public:
59  enum format_t { Natural, Binary, Octal, Decimal, Hexadecimal };
60  static format_t str2format(const QString& str);
61  static QString format2str(format_t format);
62 
63  QString expression() const;
64  bool inScope() const;
65  void setInScope(bool v);
66  void setValue(const QString &v);
67  QString value() const;
68  void setType(const QString& type);
69  QString type() const;
70  void setTopLevel(bool v);
71  void setShowError(bool v);
72  bool showError();
73 
74  using TreeItem::setHasMore;
75  using TreeItem::setHasMoreInitial;
76  using TreeItem::appendChild;
77  using TreeItem::deleteChildren;
78  using TreeItem::isExpanded;
79  using TreeItem::parent;
80 
81  using TreeItem::model;
82 
83  ~Variable() override;
84 
85  /* Connects this variable to debugger, fetching the current value and
86  otherwise preparing this variable to be displayed everywhere.
87  The attempt may fail, for example if the expression is invalid.
88  Calls slot 'callbackMethod' in 'callback' to notify of the result.
89  The slot should be taking 'bool ok' parameter. */
90  virtual void attachMaybe(QObject *callback = nullptr, const char *callbackMethod = nullptr) = 0;
91 
92  virtual bool canSetFormat() const { return false; }
93 
94  void setFormat(format_t format);
95  format_t format() const { return m_format; }
96  virtual void formatChanged();
97 
98  // get/set 'changed' state, if the variable changed it will be highlighted
99  bool isChanged() const { return m_changed; }
100  void setChanged(bool c);
101  void resetChanged();
102 
103 public Q_SLOTS:
104  void die();
105 
106 protected:
107  bool topLevel() const { return m_topLevel; }
108 
109 private: // TreeItem overrides
110  QVariant data(int column, int role) const override;
111 
112 private:
113  bool isPotentialProblematicValue() const;
114 
115  QString m_expression;
116  bool m_inScope;
117  bool m_topLevel;
118  bool m_changed;
119  bool m_showError;
120 
121  format_t m_format;
122 };
123 
124 class KDEVPLATFORMDEBUGGER_EXPORT TooltipRoot : public TreeItem
125 {
126  Q_OBJECT
127 public:
128  explicit TooltipRoot(TreeModel* model)
129  : TreeItem(model)
130  {}
131 
132  void init(Variable *var)
133  {
134  appendChild(var);
135  }
136 
137  void fetchMoreChildren() override {}
138 };
139 
140 class KDEVPLATFORMDEBUGGER_EXPORT Watches : public TreeItem
141 {
142  Q_OBJECT
143  friend class KDevMI::GDB::GdbTest;
144 public:
145  Watches(TreeModel* model, TreeItem* parent);
146  Variable* add(const QString& expression);
147 
148  void reinstall();
149 
150  Variable *addFinishResult(const QString& convenienceVarible);
151  void removeFinishResult();
152  void resetChanged();
153 
154  using TreeItem::childCount;
155  friend class VariableCollection;
156  friend class IVariableController;
157 private:
158 
159  QVariant data(int column, int role) const override;
160 
161  void fetchMoreChildren() override {}
162 
163  Variable* finishResult_;
164 };
165 
166 class KDEVPLATFORMDEBUGGER_EXPORT Locals : public TreeItem
167 {
168  Q_OBJECT
169 public:
170  Locals(TreeModel* model, TreeItem* parent, const QString &name);
171  QList<Variable*> updateLocals(const QStringList& locals);
172  void resetChanged();
173 
174  using TreeItem::deleteChildren;
175  using TreeItem::setHasMore;
176 
177  friend class VariableCollection;
178  friend class IVariableController;
179 
180 private:
181  void fetchMoreChildren() override {}
182 };
183 
184 class KDEVPLATFORMDEBUGGER_EXPORT VariablesRoot : public TreeItem
185 {
186  Q_OBJECT
187 public:
188  explicit VariablesRoot(TreeModel* model);
189 
190  Watches *watches() const { return m_watches; }
191  Locals *locals(const QString &name = QStringLiteral("Locals"));
192  QHash<QString, Locals*> allLocals() const;
193 
194  void fetchMoreChildren() override {}
195 
196  void resetChanged();
197 
198 private:
199  Watches *m_watches;
200  QHash<QString, Locals*> m_locals;
201 };
202 
203 class VariableProvider : public KTextEditor::TextHintProvider
204 {
205 public:
206  explicit VariableProvider(VariableCollection* collection);
207  QString textHint(KTextEditor::View* view, const KTextEditor::Cursor& position) override;
208 
209 private:
210  VariableCollection* m_collection;
211 };
212 
213 class KDEVPLATFORMDEBUGGER_EXPORT VariableCollection : public TreeModel
214 {
215  Q_OBJECT
216 
217 public:
218  enum Column {
219  NameColumn,
220  ValueColumn,
221  TypeColumn
222  };
223 
224  explicit VariableCollection(IDebugController* parent);
225  ~VariableCollection() override;
226 
227  VariablesRoot* root() const { return m_universe; }
228  Watches* watches() const { return m_universe->watches(); }
229  Locals* locals(const QString &name = QString()) const;
230  QHash<QString, Locals*> allLocals() const { return m_universe->allLocals(); }
231 
232 public Q_SLOTS:
233  void variableWidgetShown();
234  void variableWidgetHidden();
235 
236 private Q_SLOTS:
237  void updateAutoUpdate(KDevelop::IDebugSession* session = nullptr);
238 
239  void textDocumentCreated( KDevelop::IDocument*);
240  void viewCreated(KTextEditor::Document*, KTextEditor::View*);
241 
242 private:
243  VariablesRoot* m_universe;
244  QPointer<VariableToolTip> m_activeTooltip;
245  bool m_widgetVisible;
246 
247  friend class VariableProvider;
248  VariableProvider m_textHintProvider;
249 
250  QVector<KTextEditor::View*> m_textHintProvidedViews;
251 };
252 
253 }
254 
255 #endif
KDevelop::TooltipRoot::TooltipRoot
TooltipRoot(TreeModel *model)
Definition: variablecollection.h:128
QPointer
KDevelop::VariableCollection::allLocals
QHash< QString, Locals * > allLocals() const
Definition: variablecollection.h:230
KDevelop::VariableCollection::ValueColumn
Definition: variablecollection.h:220
KDevelop::Variable
Definition: variablecollection.h:48
KDevMI
Definition: variablecollection.h:38
KDevelop::VariableCollection::Column
Column
Definition: variablecollection.h:218
KDevelop::Variable::canSetFormat
virtual bool canSetFormat() const
Definition: variablecollection.h:92
KDevelop::VariablesRoot::watches
Watches * watches() const
Definition: variablecollection.h:190
KDevelop::Variable::topLevel
bool topLevel() const
Definition: variablecollection.h:107
KDevelop::VariableProvider
Definition: variablecollection.h:203
KDevelop::TreeItem::setHasMoreInitial
void setHasMoreInitial(bool more)
Definition: treeitem.cpp:240
KDevelop::Variable::format_t
format_t
Definition: variablecollection.h:59
KDevelop::TreeItem::isExpanded
bool isExpanded() const
Definition: treeitem.h:92
QList
KDevelop::TreeItem::appendChild
void appendChild(TreeItem *child, bool initial=false)
Adds a new child and notifies the interested parties.
Definition: treeitem.cpp:51
KDevelop::Variable::Octal
Definition: variablecollection.h:59
KDevelop::TreeModel
Definition: treemodel.h:38
KDevelop::TooltipRoot::fetchMoreChildren
void fetchMoreChildren() override
Fetches more children, and adds them by calling appendChild.
Definition: variablecollection.h:137
KDevelop::VariableProvider::textHint
QString textHint(KTextEditor::View *view, const KTextEditor::Cursor &position) override
Definition: variablecollection.cpp:529
KDevelop::TreeItem::setHasMore
void setHasMore(bool more)
Sets a flag that tells if we have some more children that are not fetched yet.
Definition: treeitem.cpp:212
KDevelop::TreeItem::parent
TreeItem * parent()
Definition: treeitem.cpp:172
QObject
KDevelop::TreeItem::model
TreeModel * model()
Definition: treeitem.h:90
KDevelop::VariablesRoot
Definition: variablecollection.h:184
KDevelop::TreeItem
Definition: treeitem.h:37
QString
KDevelop::Variable::isChanged
bool isChanged() const
Definition: variablecollection.h:99
KDevelop::VariableCollection::NameColumn
Definition: variablecollection.h:219
KDevelop::TooltipRoot::init
void init(Variable *var)
Definition: variablecollection.h:132
KDevelop::IDebugSession
Definition: idebugsession.h:54
KDevelop::Variable::format
format_t format() const
Definition: variablecollection.h:95
KDevelop::VariableProvider::VariableProvider
VariableProvider(VariableCollection *collection)
Definition: variablecollection.cpp:523
KDevelop::VariableCollection
Definition: variablecollection.h:213
KDevelop::VariableCollection::watches
Watches * watches() const
Definition: variablecollection.h:228
KDevelop::TooltipRoot
Definition: variablecollection.h:124
KDevelop::TreeItem::deleteChildren
void deleteChildren()
Definition: treeitem.cpp:118
KDevelop
The variables widget is passive, and is invoked by the rest of the code via two main Q_SLOTS:
Definition: breakpoint.h:34
KDevelop::IVariableController
Definition: ivariablecontroller.h:41
QVector< KTextEditor::View * >
KDevelop::Watches
Definition: variablecollection.h:140
QVariant
KDevelop::TreeItem::childCount
int childCount() const
Definition: treeitem.cpp:153
KDevelop::VariableCollection::root
VariablesRoot * root() const
Definition: variablecollection.h:227
KDevelop::VariablesRoot::fetchMoreChildren
void fetchMoreChildren() override
Fetches more children, and adds them by calling appendChild.
Definition: variablecollection.h:194
QHash
QStringList
KDevelop::Locals
Definition: variablecollection.h:166
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Apr 10 2021 23:29:51 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/debugger

Skip menu "kdevplatform/debugger"
  • 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