OSDN Git Service

e9e45c68b72458720d0c7b54df134f3e56ce3694
[kita/kita.git] / kita / src / kitaui / tabwidgetbase.h
1 /***************************************************************************
2 *   Copyright (C) 2003 by Hideki Ikemoto, 2004 by 421                     *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10
11 #ifndef KITATABWIDGETBASE_H
12 #define KITATABWIDGETBASE_H
13
14 #include <ktabwidget.h>
15 #include <kxmlguiclient.h>
16 #include <kparts/partmanager.h>
17 #include <kparts/browserextension.h>
18
19 #include <ktabbar.h>
20
21 #include <kdockwidget.h>
22
23 #include <qevent.h>
24 #include <qdict.h>
25
26 class KLibFactory;
27 class KURL;
28 class QIconSet;
29 class KPopupMenu;
30
31 namespace KParts
32 {
33     class DockMainWindow;
34 }
35
36 /* ID of user defined event */
37 #define EVENT_CloseTab ( QEvent::User + 100 )
38 #define EVENT_ShowDock ( QEvent::User + 101 )
39 #define EVENT_FitImageToWinEvent ( QEvent::User + 102 )
40 #define EVENT_CancelMoszicEvent ( QEvent::User + 103 )
41
42
43
44 /*-----------------------------------------------*/
45
46
47 class KitaTabWidgetBase : public KTabWidget, public KXMLGUIClient
48 {
49     Q_OBJECT
50
51 protected:
52     KParts::PartManager* m_manager;
53
54
55 public:
56     KitaTabWidgetBase( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
57     virtual ~KitaTabWidgetBase();
58
59 public slots:
60     void slotCurrentChanged( QWidget* w );
61     void slotShowPart( const KURL&, const QString&, const QString& );
62     void slotCloseTab( int num );
63
64
65 protected:
66     virtual void customEvent( QCustomEvent * e );
67     virtual void deleteWidget( QWidget* w );
68     KParts::Part* findPartFromWidget( QWidget* w );
69
70
71 private:
72     void connectSignals();
73
74
75
76     /*------------------------------------*/
77     /* common tab actions */
78
79 private:
80     void setupActions();
81
82 public slots:
83     void slotConfigureKeys();
84     void slotPrevTab();
85     void slotNextTab();
86     void slotCloseCurrentTab();
87     void slotCloseOtherTab( int idx = -1 );
88     void slotCloseRightTab( int idx = -1 );
89     void slotCloseLeftTab( int idx = -1 );
90     void slotCloseAllTab();
91
92 signals:
93     void openURLRequestExt( const KURL& url, const QString mimetype = QString::null );
94 };
95
96
97 /*-------------------------------------------------*/
98
99 class KitaDockWidgetBase : public KDockWidget
100 {
101
102     Q_OBJECT
103
104     bool m_docked;
105     bool m_tabbed;
106     bool m_closeButtonClicked;
107     KParts::DockMainWindow* m_parentDock;
108     QDict<KDockWidget>* m_dockDict;
109
110 public:
111     KitaDockWidgetBase( KDockManager* dockManager,
112                         const char* name,
113                         const QPixmap &pixmap,
114                         QWidget* parent = 0L,
115                         const QString& strCaption = QString::null,
116                         const QString& strTabPageLabel = QString::fromLatin1( " " ),
117                         WFlags f = 0 );
118     ~KitaDockWidgetBase();
119
120     void showDock( bool active = TRUE, bool force = TRUE );
121     void loadSession();
122     void saveSession();
123     void setSession( bool docked, bool tabbed );
124
125
126 public slots:
127     void slotShowPart( const KURL&, const QString&, const QString& );
128     void slotShowDock( bool activate = TRUE , bool force = TRUE );
129     void slotHideDock();
130     void slotToggleShowHide();
131
132
133 protected:
134     void windowActivationChange( bool );
135     virtual void closeEvent( QCloseEvent* e );
136     virtual void customEvent( QCustomEvent * e );
137
138
139 private slots:
140     void slotSaveDocStatus();
141     void slotHeaderCloseButtonClicked();
142
143 signals:
144     void windowDeactivated();
145     void checkToggleAction( bool );
146 };
147
148
149
150 /*------------------------------------------------------------------*/
151
152 /* user defined events */
153
154 class CloseTabEvent : public QCustomEvent
155 {
156     int m_pageindex;
157
158 public:
159
160     CloseTabEvent( int idx )
161             : QCustomEvent( EVENT_CloseTab ), m_pageindex( idx ) {}
162
163     const int getIndex() const { return m_pageindex; }
164 };
165
166
167 class ShowDockEvent : public QCustomEvent
168 {
169     bool m_activate;
170     bool m_force;
171
172 public:
173     ShowDockEvent( bool activate, bool force ) : QCustomEvent( EVENT_ShowDock )
174     , m_activate( activate ), m_force( force ) {}
175
176     const bool getActivate() const { return m_activate; }
177     const bool getForce() const { return m_force; }
178 };
179
180 #endif