OSDN Git Service

4c6471b0d5785c6ea41ed795a6a6397dc0e25767
[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 <QtCore/QEvent>
15
16 #include <ktabwidget.h>
17 #include <kxmlguiclient.h>
18 #include <kparts/part.h>
19 #include <kparts/partmanager.h>
20
21 class QIcon;
22
23 class KMenu;
24 class KUrl;
25
26 namespace KParts
27 {
28     class DockMainWindow3;
29 }
30
31 /* ID of user defined event */
32 const int EVENT_CloseTab = QEvent::User + 100;
33 const int EVENT_ShowDock = QEvent::User + 101;
34 const int EVENT_FitImageToWinEvent = QEvent::User + 102;
35 const int EVENT_CancelMoszicEvent = QEvent::User + 103;
36
37 namespace Kita
38 {
39     class KDE_EXPORT TabWidgetBase : public KTabWidget, public KXMLGUIClient
40     {
41         Q_OBJECT
42
43     protected:
44         KParts::PartManager* m_manager;
45
46
47     public:
48         explicit TabWidgetBase(QWidget* parent = 0);
49         virtual ~TabWidgetBase();
50
51     public slots:
52         void slotCurrentChanged(QWidget* w);
53         void slotCloseTab(int num);
54
55
56     protected:
57         virtual void customEvent(QEvent * e);
58         virtual void deleteWidget(QWidget* w);
59         KParts::Part* findPartFromWidget(QWidget* w);
60
61         /*------------------------------------*/
62         /* common tab actions */
63
64     private:
65         void setupActions();
66         TabWidgetBase(const TabWidgetBase&);
67         TabWidgetBase& operator=(const TabWidgetBase&);
68
69     public slots:
70         void slotConfigureKeys();
71         void slotPrevTab();
72         void slotNextTab();
73         void slotCloseCurrentTab();
74         void slotCloseOtherTab(int idx = -1);
75         void slotCloseRightTab(int idx = -1);
76         void slotCloseLeftTab(int idx = -1);
77         void slotCloseAllTab();
78     };
79
80     /* user defined events */
81     class CloseTabEvent : public QEvent
82     {
83         int m_pageindex;
84
85     public:
86
87         CloseTabEvent(int idx)
88                 : QEvent(QEvent::Type(EVENT_CloseTab)), m_pageindex(idx) {}
89
90         int getIndex() const { return m_pageindex; }
91     };
92
93
94     class ShowDockEvent : public QEvent
95     {
96         bool m_activate;
97         bool m_force;
98
99     public:
100         ShowDockEvent(bool activate, bool force) : QEvent(QEvent::Type(EVENT_ShowDock))
101         , m_activate(activate), m_force(force) {}
102
103         bool getActivate() const { return m_activate; }
104         bool getForce() const { return m_force; }
105     };
106 }
107
108 #endif