Changeset View
Changeset View
Standalone View
Standalone View
src/ViewSplitter.h
Show All 23 Lines | |||||
24 | 24 | | |||
25 | // Qt | 25 | // Qt | ||
26 | #include <QList> | 26 | #include <QList> | ||
27 | #include <QSplitter> | 27 | #include <QSplitter> | ||
28 | 28 | | |||
29 | class QFocusEvent; | 29 | class QFocusEvent; | ||
30 | 30 | | |||
31 | namespace Konsole { | 31 | namespace Konsole { | ||
32 | class TabbedViewContainer; | 32 | class TerminalDisplay; | ||
33 | 33 | | |||
34 | /** | 34 | /** | ||
35 | * A splitter which holds a number of ViewContainer objects and allows | 35 | * A splitter which holds a number of ViewContainer objects and allows | ||
36 | * the user to control the size of each view container by dragging a splitter | 36 | * the user to control the size of each view container by dragging a splitter | ||
37 | * bar between them. | 37 | * bar between them. | ||
38 | * | 38 | * | ||
39 | * Each splitter can also contain child ViewSplitter widgets, allowing | 39 | * Each splitter can also contain child ViewSplitter widgets, allowing | ||
40 | * for a hierarchy of view splitters and containers. | 40 | * for a hierarchy of view splitters and containers. | ||
Show All 19 Lines | 50 | public: | |||
60 | * is the same as the ViewSplitter into which the | 60 | * is the same as the ViewSplitter into which the | ||
61 | * container is to be inserted, or if the splitter | 61 | * container is to be inserted, or if the splitter | ||
62 | * has fewer than two child widgets then the container | 62 | * has fewer than two child widgets then the container | ||
63 | * will be added to that splitter. If the orientation | 63 | * will be added to that splitter. If the orientation | ||
64 | * is different, then a new child splitter | 64 | * is different, then a new child splitter | ||
65 | * will be created, into which the container will | 65 | * will be created, into which the container will | ||
66 | * be inserted. | 66 | * be inserted. | ||
67 | */ | 67 | */ | ||
68 | void addContainer(TabbedViewContainer *container, Qt::Orientation orientation); | 68 | void addTerminalDisplay(TerminalDisplay *terminalDisplay, Qt::Orientation orientation); | ||
69 | 69 | | |||
70 | /** Removes a container from the splitter. The container is not deleted. */ | 70 | /** Removes a container from the splitter. The container is not deleted. */ | ||
71 | void removeContainer(TabbedViewContainer *container); | 71 | void removeTerminalDisplay(TerminalDisplay *terminalDisplay); | ||
72 | 72 | | |||
73 | /** Returns the child ViewSplitter widget which currently has the focus */ | 73 | /** Returns the child ViewSplitter widget which currently has the focus */ | ||
74 | ViewSplitter *activeSplitter(); | 74 | ViewSplitter *activeSplitter(); | ||
75 | 75 | | |||
76 | /** | 76 | /** | ||
77 | * Returns the container which currently has the focus or 0 if none | 77 | * Returns the container which currently has the focus or 0 if none | ||
78 | * of the immediate child containers have the focus. This does not | 78 | * of the immediate child containers have the focus. This does not | ||
79 | * search through child splitters. activeSplitter() can be used | 79 | * search through child splitters. activeSplitter() can be used | ||
80 | * to search recursively through child splitters for the splitter | 80 | * to search recursively through child splitters for the splitter | ||
81 | * which currently has the focus. | 81 | * which currently has the focus. | ||
82 | * | 82 | * | ||
83 | * To find the currently active container, use | 83 | * To find the currently active container, use | ||
84 | * mySplitter->activeSplitter()->activeContainer() where mySplitter | 84 | * mySplitter->activeSplitter()->activeContainer() where mySplitter | ||
85 | * is the ViewSplitter widget at the top of the hierarchy. | 85 | * is the ViewSplitter widget at the top of the hierarchy. | ||
86 | */ | 86 | */ | ||
87 | TabbedViewContainer *activeContainer() const; | 87 | TerminalDisplay *activeTerminalDisplay() const; | ||
88 | 88 | | |||
89 | /** | 89 | /** | ||
90 | * Gives the focus to the active view in the specified container | 90 | * Gives the focus to the active view in the specified container | ||
91 | */ | 91 | */ | ||
92 | void setActiveContainer(TabbedViewContainer *container); | 92 | void setActiveTerminalDisplay(TerminalDisplay *container); | ||
93 | | ||||
94 | /** | | |||
95 | * Returns a list of the containers held by this splitter | | |||
96 | */ | | |||
97 | QList<TabbedViewContainer *> containers() const | | |||
98 | { | | |||
99 | return _containers; | | |||
100 | } | | |||
101 | 93 | | |||
102 | /** | 94 | /** | ||
103 | * Gives the focus to the active view in the next container | 95 | * Gives the focus to the active view in the next container | ||
104 | */ | 96 | */ | ||
105 | void activateNextContainer(); | 97 | void activateNextTerminalDisplay(); | ||
106 | 98 | | |||
107 | /** | 99 | /** | ||
108 | * Changes the size of the specified @p container by a given @p percentage. | 100 | * Changes the size of the specified @p container by a given @p percentage. | ||
109 | * @p percentage may be positive ( in which case the size of the container | 101 | * @p percentage may be positive ( in which case the size of the container | ||
110 | * is increased ) or negative ( in which case the size of the container | 102 | * is increased ) or negative ( in which case the size of the container | ||
111 | * is decreased ). | 103 | * is decreased ). | ||
112 | * | 104 | * | ||
113 | * The sizes of the remaining containers are increased or decreased | 105 | * The sizes of the remaining containers are increased or decreased | ||
114 | * uniformly to maintain the width of the splitter. | 106 | * uniformly to maintain the width of the splitter. | ||
115 | */ | 107 | */ | ||
116 | void adjustContainerSize(TabbedViewContainer *container, int percentage); | 108 | void adjustTerminalDisplaySize(TerminalDisplay *container, int percentage); | ||
117 | 109 | | |||
118 | /** | 110 | /** | ||
119 | * Gives the focus to the active view in the previous container | 111 | * Gives the focus to the active view in the previous container | ||
120 | */ | 112 | */ | ||
121 | void activatePreviousContainer(); | 113 | void activatePreviousTerminalDisplay(); | ||
122 | | ||||
123 | /** | | |||
124 | * Specifies whether the view may be split recursively. | | |||
125 | * | | |||
126 | * If this is false, all containers will be placed into the same | | |||
127 | * top-level splitter. Adding a container with an orientation | | |||
128 | * which is different to that specified when adding the previous | | |||
129 | * containers will change the orientation for all dividers | | |||
130 | * between containers. | | |||
131 | * | | |||
132 | * If this is true, adding a container to the view splitter with | | |||
133 | * an orientation different to the orientation of the previous | | |||
134 | * area will result in the previously active container being | | |||
135 | * replaced with a new splitter containing the active container | | |||
136 | * and the newly added container. | | |||
137 | */ | | |||
138 | void setRecursiveSplitting(bool recursive); | | |||
139 | | ||||
140 | /** | | |||
141 | * Returns whether the view may be split recursively. | | |||
142 | * See setRecursiveSplitting() | | |||
143 | */ | | |||
144 | bool recursiveSplitting() const; | | |||
145 | 114 | | |||
115 | void focusUp(); | ||||
116 | void focusDown(); | ||||
117 | void focusLeft(); | ||||
118 | void focusRight(); | ||||
146 | Q_SIGNALS: | 119 | Q_SIGNALS: | ||
147 | /** Signal emitted when the last child widget is removed from the splitter */ | 120 | /** Signal emitted when the last child widget is removed from the splitter */ | ||
148 | void empty(ViewSplitter *splitter); | 121 | void empty(ViewSplitter *splitter); | ||
149 | 122 | | |||
150 | /** | | |||
151 | * Signal emitted when the containers held by this splitter become empty, this | | |||
152 | * differs from the empty() signal which is only emitted when all of the containers | | |||
153 | * are deleted. This signal is emitted even if there are still container widgets. | | |||
154 | * | | |||
155 | * TODO: This does not yet work recursively (ie. when splitters inside splitters have empty containers) | | |||
156 | */ | | |||
157 | void allContainersEmpty(); | | |||
158 | | ||||
159 | protected: | | |||
160 | //virtual void focusEvent(QFocusEvent* event); | | |||
161 | | ||||
162 | private: | 123 | private: | ||
163 | // Adds container to splitter's internal list and | | |||
164 | // connects signals and slots | | |||
165 | void registerContainer(TabbedViewContainer *container); | | |||
166 | // Removes container from splitter's internal list and | | |||
167 | // removes signals and slots | | |||
168 | void unregisterContainer(TabbedViewContainer *container); | | |||
169 | | ||||
170 | void updateSizes(); | 124 | void updateSizes(); | ||
171 | 125 | void childDestroyed(QObject *terminalDisplay); | |||
172 | private Q_SLOTS: | | |||
173 | // Called to indicate that a child ViewContainer is empty | | |||
174 | void containerEmpty(TabbedViewContainer *container); | | |||
175 | | ||||
176 | // Called to indicate that a child ViewSplitter is empty | | |||
177 | // (ie. all child widgets have been deleted) | | |||
178 | void childEmpty(ViewSplitter *splitter); | | |||
179 | | ||||
180 | private: | | |||
181 | QList<TabbedViewContainer *> _containers; | | |||
182 | bool _recursiveSplitting; | | |||
183 | }; | 126 | }; | ||
184 | } | 127 | } | ||
185 | #endif //VIEWSPLITTER_H | 128 | #endif //VIEWSPLITTER_H |