KTextEditor

markinterface.h
1 /* SPDX-License-Identifier: LGPL-2.0-or-later
2 
3  Copyright (C) 2001 Christoph Cullmann ([email protected])
4  Copyright (C) 2005 Dominik Haumann ([email protected]) (documentation)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef KTEXTEDITOR_MARKINTERFACE_H
23 #define KTEXTEDITOR_MARKINTERFACE_H
24 
25 #include <ktexteditor_export.h>
26 
27 #include <QHash>
28 #include <QObject>
29 
30 class QIcon;
31 class QPixmap;
32 class QPoint;
33 class QMenu;
34 
35 namespace KTextEditor
36 {
37 class Document;
38 
54 class Mark
55 {
56 public:
58  int line;
59 
61  uint type;
62 };
63 
124 class KTEXTEDITOR_EXPORT MarkInterface
125 {
126 public:
127  MarkInterface();
128 
132  virtual ~MarkInterface();
133 
134  //
135  // slots !!!
136  //
137 public:
145  virtual uint mark(int line) = 0;
146 
160  virtual void setMark(int line, uint markType) = 0;
161 
167  virtual void clearMark(int line) = 0;
168 
177  virtual void addMark(int line, uint markType) = 0;
178 
185  virtual void removeMark(int line, uint markType) = 0;
186 
192  virtual const QHash<int, KTextEditor::Mark *> &marks() = 0;
193 
198  virtual void clearMarks() = 0;
200 
207  static int reservedMarkersCount()
208  {
209  return 7;
210  }
211 
218  enum MarkTypes {
220  markType01 = 0x1,
222  markType02 = 0x2,
224  markType03 = 0x4,
226  markType04 = 0x8,
228  markType05 = 0x10,
230  markType06 = 0x20,
232  markType07 = 0x40,
233 
234  markType08 = 0x80,
235  markType09 = 0x100,
236  markType10 = 0x200,
237  markType11 = 0x400,
238  markType12 = 0x800,
239  markType13 = 0x1000,
240  markType14 = 0x2000,
241  markType15 = 0x4000,
242  markType16 = 0x8000,
243  markType17 = 0x10000,
244  markType18 = 0x20000,
245  markType19 = 0x40000,
246  markType20 = 0x80000,
247  markType21 = 0x100000,
248  markType22 = 0x200000,
249  markType23 = 0x400000,
250  markType24 = 0x800000,
251  markType25 = 0x1000000,
252  markType26 = 0x2000000,
253  markType27 = 0x4000000,
254  markType28 = 0x8000000,
255  markType29 = 0x10000000,
256  markType30 = 0x20000000,
257  markType31 = 0x40000000,
258  markType32 = 0x80000000,
259  /* reserved marks */
260  Bookmark = markType01,
261  BreakpointActive = markType02,
262  BreakpointReached = markType03,
263  BreakpointDisabled = markType04,
264  Execution = markType05,
265  Warning = markType06,
266  Error = markType07,
267  SearchMatch = markType32,
268  };
269 
270  //
271  // signals !!!
272  //
273 public:
279  virtual void marksChanged(KTextEditor::Document *document) = 0;
280 
281  /*
282  * Methods to modify mark properties.
283  */
284 public:
291  virtual void setMarkPixmap(MarkTypes mark, const QPixmap &pixmap) = 0;
292 
299  virtual QPixmap markPixmap(MarkTypes mark) const = 0;
300 
307  virtual void setMarkDescription(MarkTypes mark, const QString &text) = 0;
308 
316  virtual QString markDescription(MarkTypes mark) const = 0;
317 
337  virtual void setEditableMarks(uint markMask) = 0;
338 
346  virtual uint editableMarks() const = 0;
347 
353  MarkAdded = 0,
355  };
356 
357  //
358  // signals !!!
359  //
360 public:
368  virtual void markChanged(KTextEditor::Document *document, KTextEditor::Mark mark, KTextEditor::MarkInterface::MarkChangeAction action) = 0;
369 
370 Q_SIGNALS:
371 
380  void markToolTipRequested(KTextEditor::Document *document, KTextEditor::Mark mark, QPoint position, bool &handled);
381 
390  void markContextMenuRequested(KTextEditor::Document *document, KTextEditor::Mark mark, QPoint pos, bool &handled);
391 
398  void markClicked(KTextEditor::Document *document, KTextEditor::Mark mark, bool &handled);
399 
400 private:
401  class MarkInterfacePrivate *const d = nullptr;
402 };
403 
435 class KTEXTEDITOR_EXPORT MarkInterfaceV2 : public MarkInterface
436 {
437  // KF6: Merge KTextEditor::MarkInterfaceV2 into KTextEditor::MarkInterface, drop QPixmap API (kossebau)
438 public:
439  virtual ~MarkInterfaceV2()
440  {
441  }
442 
449  virtual void setMarkIcon(MarkTypes markType, const QIcon &icon) = 0;
450 
457  virtual QIcon markIcon(MarkTypes markType) const = 0;
458 };
459 
460 }
461 
462 Q_DECLARE_INTERFACE(KTextEditor::MarkInterface, "org.kde.KTextEditor.MarkInterface")
463 Q_DECLARE_INTERFACE(KTextEditor::MarkInterfaceV2, "org.kde.KTextEditor.MarkInterfaceV2")
464 
465 #endif
Mark extension interface for the Document.
QString markDescription(MarkInterface::MarkTypes) const override
Get the mark&#39;s description to text.
const QHash< int, KTextEditor::Mark * > & marks() override
Get a hash holding all marks in the document.
MarkChangeAction
Possible actions on a mark.
A KParts derived class representing a text document.
Definition: document.h:199
Type type(const QSqlDatabase &db)
action: a mark was removed.
virtual ~MarkInterface()
Virtual destructor.
uint mark(int line) override
Get all marks set on the line.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Mark extension interface for the Document, version 2.
MarkTypes
Predefined mark types.
action: a mark was added.
static int reservedMarkersCount()
Get the number of predefined mark types we have so far.
QIcon markIcon(MarkInterface::MarkTypes markType) const override
Get the mark&#39;s icon.
uint editableMarks() const override
Get, which marks can be toggled by the user.
QPixmap markPixmap(MarkInterface::MarkTypes) const override
Get the mark&#39;s pixmap.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 22:55:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.