1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
/* This file is part of the KDE libraries
Copyright (C) 2005 Christoph Cullmann <[email protected]>
Copyright (C) 2002, 2003 Joseph Wenninger <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __KATE_MDI_H__
#define __KATE_MDI_H__
#include <tdeparts/mainwindow.h>
#include <tdemultitabbar.h>
#include <tqdict.h>
#include <tqintdict.h>
#include <tqsplitter.h>
namespace KateMDI {
/** This class is needed because TQSplitter cant return an index for a widget. */
class Splitter : public TQSplitter
{
Q_OBJECT
public:
Splitter(Qt::Orientation o, TQWidget* parent=0, const char* name=0);
~Splitter();
/** Since there is supposed to be only 2 childs of a katesplitter,
* any child other than the last is the first.
* This method uses TQSplitter::idAfter(widget) which
* returns 0 if there is no widget after this one.
* This results in an error if widget is not a child
* in this splitter */
bool isLastChild(TQWidget* w) const;
int idAfter ( TQWidget * w ) const;
};
class ToggleToolViewAction : public TDEToggleAction
{
Q_OBJECT
public:
ToggleToolViewAction ( const TQString& text, const TDEShortcut& cut,
class ToolView *tv, TQObject* parent = 0, const char* name = 0 );
virtual ~ToggleToolViewAction();
protected slots:
void slotToggled(bool);
void visibleChanged(bool);
private:
ToolView *m_tv;
};
class GUIClient : public TQObject, public KXMLGUIClient
{
Q_OBJECT
public:
GUIClient ( class MainWindow *mw );
virtual ~GUIClient();
void registerToolView (ToolView *tv);
private slots:
void clientAdded( KXMLGUIClient *client );
void updateActions();
private:
MainWindow *m_mw;
};
class ToolView : public TQVBox
{
Q_OBJECT
friend class Sidebar;
friend class MainWindow;
friend class GUIClient;
friend class ToggleToolViewAction;
protected:
/**
* ToolView
* Objects of this clas represent a toolview in the mainwindow
* you should only add one widget as child to this toolview, it will
* be automatically set to be the focus proxy of the toolview
* @param mainwin main window for this toolview
* @param sidebar sidebar of this toolview
* @param parent parent widget, e.g. the splitter of one of the sidebars
*/
ToolView (class MainWindow *mainwin, class Sidebar *sidebar, TQWidget *parent);
public:
/**
* destuct me, this is allowed for all, will care itself that the toolview is removed
* from the mainwindow and sidebar
*/
virtual ~ToolView ();
signals:
/**
* toolview hidden or shown
* @param bool is this toolview made visible?
*/
void visibleChanged (bool visible);
/**
* some internal methodes needed by the main window and the sidebars
*/
protected:
MainWindow *mainWindow () { return m_mainWin; }
Sidebar *sidebar () { return m_sidebar; }
void setVisible (bool vis);
public:
bool visible () const;
protected:
void childEvent ( TQChildEvent *ev );
private:
MainWindow *m_mainWin;
Sidebar *m_sidebar;
/**
* unique id
*/
TQString id;
/**
* is visible in sidebar
*/
bool m_visible;
/**
* is this view persistent?
*/
bool persistent;
TQPixmap icon;
TQString text;
};
class Sidebar : public KMultiTabBar
{
Q_OBJECT
public:
Sidebar (KMultiTabBar::KMultiTabBarPosition pos, class MainWindow *mainwin, TQWidget *parent);
virtual ~Sidebar ();
void setSplitter (Splitter *sp);
//HACK use these functions intead of their respective functions in
//KMultiTabBar so that we know what they were set to.
void setSidebarPosition( KMultiTabBarPosition pos );
KMultiTabBar::KMultiTabBarPosition sidebarPosition() const { return m_pos; }
void setSidebarStyle( KMultiTabBarStyle style );
KMultiTabBar::KMultiTabBarStyle sidebarTabStyle() const { return m_sidebarTabStyle; }
public:
ToolView *addWidget (const TQPixmap &icon, const TQString &text, ToolView *widget);
bool removeWidget (ToolView *widget);
bool showWidget (ToolView *widget);
bool hideWidget (ToolView *widget);
void setLastSize (int s) { m_lastSize = s; }
int lastSize () const { return m_lastSize; }
void updateLastSize ();
bool splitterVisible () const { return m_ownSplit->isVisible(); }
void restoreSession ();
/**
* restore the current session config from given object, use current group
* @param config config object to use
*/
void restoreSession (TDEConfig *config);
/**
* save the current session config to given object, use current group
* @param config config object to use
*/
void saveSession (TDEConfig *config);
private slots:
void tabClicked(int);
protected:
bool eventFilter(TQObject *obj, TQEvent *ev);
private slots:
void buttonPopupActivate (int id);
private:
MainWindow *m_mainWin;
KMultiTabBar::KMultiTabBarStyle m_sidebarTabStyle;
KMultiTabBar::KMultiTabBarPosition m_pos;
Splitter *m_splitter;
KMultiTabBar *m_tabBar;
Splitter *m_ownSplit;
TQIntDict<ToolView> m_idToWidget;
TQMap<ToolView*, int> m_widgetToId;
/**
* list of all toolviews around in this sidebar
*/
TQValueList<ToolView*> m_toolviews;
int m_lastSize;
int m_popupButton;
};
class MainWindow : public KParts::MainWindow
{
Q_OBJECT
friend class ToolView;
//
// Constructor area
//
public:
/**
* Constructor
*/
MainWindow (TQWidget* parentWidget = 0, const char* name = 0);
/**
* Destructor
*/
virtual ~MainWindow ();
//
// public interfaces
//
public:
/**
* central widget ;)
* use this as parent for your content
* this widget will get focus if a toolview is hidden
* @return central widget
*/
TQWidget *centralWidget () const;
/**
* add a given widget to the given sidebar if possible, name is very important
* @param identifier unique identifier for this toolview
* @param pos position for the toolview, if we are in session restore, this is only a preference
* @param icon icon to use for the toolview
* @param text text to use in addition to icon
* @return created toolview on success or 0
*/
ToolView *createToolView (const TQString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const TQPixmap &icon, const TQString &text);
/**
* give you handle to toolview for the given name, 0 if no toolview around
* @param identifier toolview name
* @return toolview if existing, else 0
*/
ToolView *toolView (const TQString &identifier) const;
/**
* set the toolview's tabbar style.
* @param style the tabbar style.
*/
void setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style);
/**
* get the toolview's tabbar style. Call this before @p startRestore(),
* otherwise you overwrite the usersettings.
* @return toolview's tabbar style
*/
KMultiTabBar::KMultiTabBarStyle toolViewStyle () const;
protected:
/**
* called by toolview destructor
* @param widget toolview which is destroyed
*/
void toolViewDeleted (ToolView *widget);
/**
* modifiers for existing toolviews
*/
public:
/**
* move a toolview around
* @param widget toolview to move
* @param pos position to move too, during session restore, only preference
* @return success
*/
bool moveToolView (ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos);
/**
* show given toolview, discarded while session restore
* @param widget toolview to show
* @return success
*/
bool showToolView (ToolView *widget);
/**
* hide given toolview, discarded while session restore
* @param widget toolview to hide
* @return success
*/
bool hideToolView (ToolView *widget);
/**
* session saving and restore stuff
*/
public:
/**
* start the restore
* @param config config object to use
* @param group config group to use
*/
void startRestore (TDEConfig *config, const TQString &group);
/**
* finish the restore
*/
void finishRestore ();
/**
* save the current session config to given object and group
* @param config config object to use
* @param group config group to use
*/
void saveSession (TDEConfig *config, const TQString &group);
/**
* internal data ;)
*/
private:
/**
* map identifiers to widgets
*/
TQDict<ToolView> m_idToWidget;
/**
* list of all toolviews around
*/
TQValueList<ToolView*> m_toolviews;
/**
* widget, which is the central part of the
* main window ;)
*/
TQWidget *m_centralWidget;
/**
* horizontal splitter
*/
Splitter *m_hSplitter;
/**
* vertical splitter
*/
Splitter *m_vSplitter;
/**
* sidebars for the four sides
*/
Sidebar *m_sidebars[4];
/**
* config object for session restore, only valid between
* start and finish restore calls
*/
TDEConfig *m_restoreConfig;
/**
* restore group
*/
TQString m_restoreGroup;
/**
* out guiclient
*/
GUIClient *m_guiClient;
};
}
#endif
|