1
/* This file is part of the KDE libraries
2
Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
3
Copyright (C) 2002, 2003 Joseph Wenninger <jowenn@kde.org>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
Boston, MA 02110-1301, USA.
21
#ifndef __KATE_MDI_H__
22
#define __KATE_MDI_H__
24
#include <kparts/mainwindow.h>
26
#include <kmultitabbar.h>
27
#include <kxmlguiclient.h>
33
#include <qsplitter.h>
40
/** This class is needed because QSplitter cant return an index for a widget. */
41
class Splitter : public QSplitter
46
Splitter(Orientation o, QWidget* parent=0, const char* name=0);
49
/** Since there is supposed to be only 2 childs of a katesplitter,
50
* any child other than the last is the first.
51
* This method uses QSplitter::idAfter(widget) which
52
* returns 0 if there is no widget after this one.
53
* This results in an error if widget is not a child
55
bool isLastChild(QWidget* w) const;
57
int idAfter ( QWidget * w ) const;
60
class ToggleToolViewAction : public KToggleAction
65
ToggleToolViewAction ( const QString& text, const KShortcut& cut,
66
class ToolView *tv, QObject* parent = 0, const char* name = 0 );
68
virtual ~ToggleToolViewAction();
71
void slotToggled(bool);
72
void visibleChanged(bool);
78
class GUIClient : public QObject, public KXMLGUIClient
83
GUIClient ( class MainWindow *mw );
86
void registerToolView (ToolView *tv);
87
void unregisterToolView (ToolView *tv);
88
void updateSidebarsVisibleAction();
91
void clientAdded( KXMLGUIClient *client );
96
KToggleAction *m_showSidebarsAction;
97
QPtrList<KAction> m_toolViewActions;
98
QMap<ToolView*, KAction*> m_toolToAction;
99
KActionMenu *m_toolMenu;
102
class ToolView : public QVBox
106
friend class Sidebar;
107
friend class MainWindow;
108
friend class GUIClient;
109
friend class ToggleToolViewAction;
114
* Objects of this clas represent a toolview in the mainwindow
115
* you should only add one widget as child to this toolview, it will
116
* be automatically set to be the focus proxy of the toolview
117
* @param mainwin main window for this toolview
118
* @param sidebar sidebar of this toolview
119
* @param parent parent widget, e.g. the splitter of one of the sidebars
121
ToolView (class MainWindow *mainwin, class Sidebar *sidebar, QWidget *parent);
125
* destuct me, this is allowed for all, will care itself that the toolview is removed
126
* from the mainwindow and sidebar
128
virtual ~ToolView ();
132
* toolview hidden or shown
133
* @param bool is this toolview made visible?
135
void visibleChanged (bool visible);
138
* some internal methodes needed by the main window and the sidebars
141
MainWindow *mainWindow () { return m_mainWin; }
143
Sidebar *sidebar () { return m_sidebar; }
145
void setVisible (bool vis);
148
bool visible () const;
151
void childEvent ( QChildEvent *ev );
154
MainWindow *m_mainWin;
163
* is visible in sidebar
168
* is this view persistent?
176
class Sidebar : public KMultiTabBar
181
Sidebar (KMultiTabBar::KMultiTabBarPosition pos, class MainWindow *mainwin, QWidget *parent);
184
void setSplitter (Splitter *sp);
187
ToolView *addWidget (const QPixmap &icon, const QString &text, ToolView *widget);
188
bool removeWidget (ToolView *widget);
190
bool showWidget (ToolView *widget);
191
bool hideWidget (ToolView *widget);
193
void setLastSize (int s) { m_lastSize = s; }
194
int lastSize () const { return m_lastSize; }
195
void updateLastSize ();
197
bool splitterVisible () const { return m_ownSplit->isVisible(); }
199
void restoreSession ();
202
* restore the current session config from given object, use current group
203
* @param config config object to use
205
void restoreSession (KConfig *config);
208
* save the current session config to given object, use current group
209
* @param config config object to use
211
void saveSession (KConfig *config);
214
// reimplemented, to block a show() call if we have no children or if
215
// all sidebars are forced hidden.
219
void tabClicked(int);
222
bool eventFilter(QObject *obj, QEvent *ev);
225
void buttonPopupActivate (int id);
228
MainWindow *m_mainWin;
230
KMultiTabBar::KMultiTabBarPosition m_pos;
231
Splitter *m_splitter;
232
KMultiTabBar *m_tabBar;
233
Splitter *m_ownSplit;
235
QIntDict<ToolView> m_idToWidget;
236
QMap<ToolView*, int> m_widgetToId;
239
* list of all toolviews around in this sidebar
241
QValueList<ToolView*> m_toolviews;
248
class MainWindow : public KParts::MainWindow
252
friend class ToolView;
261
MainWindow (QWidget* parentWidget = 0, const char* name = 0);
266
virtual ~MainWindow ();
274
* use this as parent for your content
275
* this widget will get focus if a toolview is hidden
276
* @return central widget
278
QWidget *centralWidget () const;
281
* add a given widget to the given sidebar if possible, name is very important
282
* @param identifier unique identifier for this toolview
283
* @param pos position for the toolview, if we are in session restore, this is only a preference
284
* @param icon icon to use for the toolview
285
* @param text text to use in addition to icon
286
* @return created toolview on success or 0
288
ToolView *createToolView (const QString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const QPixmap &icon, const QString &text);
291
* give you handle to toolview for the given name, 0 if no toolview around
292
* @param identifier toolview name
293
* @return toolview if existing, else 0
295
ToolView *toolView (const QString &identifier) const;
298
* set the toolview's tabbar style.
299
* @param style the tabbar style.
301
void setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style);
304
* get the toolview's tabbar style. Call this before @p startRestore(),
305
* otherwise you overwrite the usersettings.
306
* @return toolview's tabbar style
308
KMultiTabBar::KMultiTabBarStyle toolViewStyle () const;
311
* get the sidebars' visibility.
312
* @return false, if the sidebars' visibility is forced hidden, otherwise true
314
bool sidebarsVisible() const;
318
* set the sidebars' visibility to @p visible. If false, the sidebars
319
* are @e always hidden. Usually you do not have to call this because
320
* the user can set this in the menu.
321
* @param visible sidebars visibility
323
void setSidebarsVisible( bool visible );
327
* called by toolview destructor
328
* @param widget toolview which is destroyed
330
void toolViewDeleted (ToolView *widget);
333
* modifiers for existing toolviews
337
* move a toolview around
338
* @param widget toolview to move
339
* @param pos position to move too, during session restore, only preference
342
bool moveToolView (ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos);
345
* show given toolview, discarded while session restore
346
* @param widget toolview to show
349
bool showToolView (ToolView *widget);
352
* hide given toolview, discarded while session restore
353
* @param widget toolview to hide
356
bool hideToolView (ToolView *widget);
359
* session saving and restore stuff
364
* @param config config object to use
365
* @param group config group to use
367
void startRestore (KConfig *config, const QString &group);
372
void finishRestore ();
375
* save the current session config to given object and group
376
* @param config config object to use
377
* @param group config group to use
379
void saveSession (KConfig *config, const QString &group);
386
* map identifiers to widgets
388
QDict<ToolView> m_idToWidget;
391
* list of all toolviews around
393
QValueList<ToolView*> m_toolviews;
396
* widget, which is the central part of the
399
QWidget *m_centralWidget;
402
* horizontal splitter
404
Splitter *m_hSplitter;
409
Splitter *m_vSplitter;
412
* sidebars for the four sides
414
Sidebar *m_sidebars[4];
419
bool m_sidebarsVisible;
422
* config object for session restore, only valid between
423
* start and finish restore calls
425
KConfig *m_restoreConfig;
430
QString m_restoreGroup;
435
GUIClient *m_guiClient;
442
// kate: space-indent on; indent-width 2;