itom
Loading...
Searching...
No Matches
panelsManager.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität 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 PANELSMANAGER_H
39#define PANELSMANAGER_H
40
41/*
42This module contains the panels controller, responsible of drawing panel
43inside CodeEdit's margins
44*/
45
46#include "manager.h"
47
48#include <qpoint.h>
49#include <qlist.h>
50#include <qmap.h>
51#include <qstring.h>
52#include <qstringlist.h>
53#include <qrect.h>
54#include <qvector.h>
55
56#include "../panel.h"
57
58namespace ito {
59
60/*
61Manages the list of panels and draws them inside the margin of the code
62edit widget.
63*/
64class PanelsManager : public Manager
65{
66 Q_OBJECT
67
68public:
69
70
71 PanelsManager(CodeEditor *editor, QObject *parent = NULL);
72 virtual ~PanelsManager();
73
74 QList<Panel::Ptr> panelsForZone(Panel::Position zone) const;
75 QList<Panel::Ptr> panelsForZoneSortedByOrderReverse(Panel::Position zone) const;
76 int marginSize(Panel::Position zone = Panel::Left);
77
78 Panel::Ptr append(Panel::Ptr panel, Panel::Position pos = Panel::Left);
79 Panel::Ptr remove(const QString &nameOrClass);
80 void clear();
81
82 void resize();
83 void refresh();
84
85 Panel::Ptr get(const QString &nameOrClass);
86
87private:
88 struct ZoneItems
89 {
90 ZoneItems(int margin) : marginSize(margin) {}
91 int marginSize;
92 QStringList names;
93 QList<Panel::Ptr> panels;
94
95 int len() const { return panels.size(); }
96 void add(Panel::Ptr p, const QString &name);
97 Panel::Ptr removeFirst(const QString &name);
98 Panel::Ptr get(const QString &name) const;
99 };
100
101 QPoint m_cachedCursorPos;
102 int m_top;
103 int m_bottom;
104 int m_left;
105 int m_right;
106 QList<ZoneItems> m_panels;
107
108
109 QVector<int> computeZonesSizes();
110
111
112private slots:
113 void updateViewportMargins();
114 void update(const QRect & rect, int dy, bool forceUpdateMargins = false);
115};
116
117
118} //end namespace ito
119
120#endif //PANELSMANAGER_H
Definition codeEditor.h:110
Definition manager.h:72
Definition panelsManager.h:65
Definition apiFunctionsGraph.cpp:40
Definition panelsManager.h:89