itom  4.1.0
textDecorationsManager.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 
22  Further hints:
23  ------------------------
24 
25  This file belongs to the code editor of itom. The code editor is
26  in major parts a fork / rewritten version of the python-based source
27  code editor PyQode from Colin Duquesnoy and others
28  (see https://github.com/pyQode). PyQode itself is licensed under
29  the MIT License (MIT).
30 
31  Some parts of the code editor of itom are also inspired by the
32  source code editor of the Spyder IDE (https://github.com/spyder-ide),
33  also licensed under the MIT License and developed by the Spyder Project
34  Contributors.
35 
36 *********************************************************************** */
37 
38 #ifndef TEXTDECORATIONSMANAGER_H
39 #define TEXTDECORATIONSMANAGER_H
40 
41 /*
42 Contains the text decorations manager
43 */
44 
45 #include "manager.h"
46 
47 #include <qlist.h>
48 #include "../textDecoration.h"
49 
50 namespace ito {
51 
52 /*
53 Manages the collection of TextDecoration that have been set on the editor
54 widget.
55 */
57 {
58  Q_OBJECT
59 
60 public:
61  TextDecorationsManager(CodeEditor *editor, QObject *parent = NULL);
62  virtual ~TextDecorationsManager();
63 
64  typedef QList<TextDecoration::Ptr>::const_iterator const_iterator;
65  typedef QList<TextDecoration::Ptr>::iterator iterator;
66 
67  bool append(TextDecoration::Ptr decoration);
68  bool remove(TextDecoration::Ptr decoration);
69  void clear();
70 
71  bool contains(const TextDecoration::Ptr &deco)
72  {
73  foreach (const TextDecoration::Ptr &t, m_decorations)
74  {
75  if (t == deco)
76  {
77  return true;
78  }
79  }
80  return false;
81  }
82 
83  const_iterator constBegin() const
84  {
85  return m_decorations.constBegin();
86  }
87  const_iterator constEnd() const
88  {
89  return m_decorations.constEnd();
90  }
91 
92  iterator begin()
93  {
94  return m_decorations.begin();
95  }
96  iterator end()
97  {
98  return m_decorations.end();
99  }
100 
101 private:
102  QList<QTextEdit::ExtraSelection> getExtraSelections() const;
103 
104  QList<TextDecoration::Ptr> m_decorations;
105 };
106 
107 } //end namespace ito
108 
109 #endif
Definition: codeEditor.h:110
Definition: apiFunctionsGraph.cpp:39
Definition: textDecorationsManager.h:56
Definition: manager.h:71