~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to src/tabs/tabdlg.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * tabdlg.h - dialog for handling tabbed chats
 
3
 * Copyright (C) 2005 Kevin Smith
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program 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
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
 
20
 
 
21
#ifndef TABDLG_H
 
22
#define TABDLG_H
 
23
 
 
24
#include <QWidget>
 
25
#include <QSize>
 
26
#include <QMap>
 
27
#include <QPointer>
 
28
 
 
29
#include "advwidget.h"
 
30
 
 
31
#include "tabbablewidget.h"
 
32
 
 
33
class PsiCon;
 
34
class ChatTabs;
 
35
class ChatDlg;
 
36
class QPushButton;
 
37
class QMenu;
 
38
class QString;
 
39
class Q3DragObject;
 
40
class QContextMenuEvent;
 
41
class PsiTabWidget;
 
42
class TabManager;
 
43
 
 
44
class TabDlg;
 
45
 
 
46
class TabDlgDelegate : public QObject
 
47
{
 
48
        Q_OBJECT
 
49
public:
 
50
        TabDlgDelegate(QObject *parent = 0);
 
51
        ~TabDlgDelegate();
 
52
 
 
53
        virtual Qt::WindowFlags initWindowFlags() const;
 
54
        virtual void create(QWidget *widget);
 
55
        virtual void destroy(QWidget *widget);
 
56
        virtual void tabWidgetCreated(QWidget *widget, PsiTabWidget *tabWidget);
 
57
        virtual bool paintEvent(QWidget *widget, QPaintEvent *event);
 
58
        virtual bool resizeEvent(QWidget *widget, QResizeEvent *event);
 
59
        virtual bool mousePressEvent(QWidget *widget, QMouseEvent *event);
 
60
        virtual bool mouseMoveEvent(QWidget *widget, QMouseEvent *event);
 
61
        virtual bool mouseReleaseEvent(QWidget *widget, QMouseEvent *event);
 
62
        virtual bool changeEvent(QWidget *widget, QEvent *event);
 
63
        virtual bool event(QWidget *widget, QEvent *event);
 
64
        virtual bool eventFilter(QWidget *widget, QObject *obj, QEvent *event);
 
65
};
 
66
 
 
67
class TabDlg : public AdvancedWidget<QWidget>
 
68
{
 
69
        Q_OBJECT
 
70
public:
 
71
        TabDlg(TabManager* tabManager, QSize size, TabDlgDelegate *delegate = 0);
 
72
        ~TabDlg();
 
73
        bool managesTab(const TabbableWidget*) const;
 
74
        bool tabOnTop(const TabbableWidget*) const;
 
75
        TabbableWidget *getTab(int i) const;
 
76
        void removeTabWithNoChecks(TabbableWidget *tab);
 
77
 
 
78
        TabbableWidget* getTabPointer(QString fullJid);
 
79
 
 
80
        virtual QString desiredCaption() const;
 
81
        QString captionForTab(TabbableWidget* tab) const;
 
82
 
 
83
        int tabCount() const;
 
84
        void setUserManagementEnabled(bool enabled); // default enabled
 
85
        void setTabBarShownForSingles(bool enabled); // default enabled
 
86
        void setSimplifiedCaptionEnabled(bool enabled); // default disabled
 
87
 
 
88
protected:
 
89
        void setShortcuts();
 
90
 
 
91
        // reimplemented
 
92
        void closeEvent(QCloseEvent*);
 
93
        void changeEvent(QEvent *event);
 
94
        void resizeEvent(QResizeEvent *);
 
95
        void dragEnterEvent(QDragEnterEvent *event);
 
96
        void dropEvent(QDropEvent *event);
 
97
 
 
98
        // delegate-only
 
99
        virtual void paintEvent(QPaintEvent *event);
 
100
        virtual void mousePressEvent(QMouseEvent *event);
 
101
        virtual void mouseMoveEvent(QMouseEvent *event);
 
102
        virtual void mouseReleaseEvent(QMouseEvent *event);
 
103
        virtual bool event(QEvent *event);
 
104
        virtual bool eventFilter(QObject *obj, QEvent *event);
 
105
 
 
106
protected slots:
 
107
        void detachCurrentTab();
 
108
        void mouseDoubleClickTab(QWidget*);
 
109
 
 
110
public slots:
 
111
        void addTab(TabbableWidget *tab);
 
112
        void setLooks();
 
113
        void closeCurrentTab();
 
114
        void closeTab(TabbableWidget*, bool doclose = true);
 
115
        void selectTab(TabbableWidget*);
 
116
        void activated();
 
117
        void optionsUpdate();
 
118
        void detachTab(TabbableWidget*);
 
119
        void sendTabTo(TabbableWidget*, TabDlg *);
 
120
 
 
121
signals:
 
122
        void resized(QSize size);
 
123
        
 
124
private slots:
 
125
        void updateFlashState();
 
126
        void tabSelected(QWidget* selected);
 
127
        void checkHasChats();
 
128
        void updateTab();
 
129
        void updateTab(TabbableWidget*);
 
130
        void nextTab();
 
131
        void previousTab();
 
132
        void tab_aboutToShowMenu(QMenu *menu);
 
133
        void setAsDefaultForChat();
 
134
        void setAsDefaultForMuc();
 
135
        void menu_sendTabTo(QAction *act);
 
136
        void queuedSendTabTo(TabbableWidget* chat, TabDlg *dest);
 
137
        void showTabMenu(int tab, QPoint pos, QContextMenuEvent * event);
 
138
 
 
139
private:
 
140
        TabDlgDelegate *delegate_;
 
141
        QList<TabbableWidget*> tabs_;
 
142
        PsiTabWidget *tabWidget_;
 
143
        QPushButton *detachButton_;
 
144
        QPushButton *closeButton_;
 
145
        QPushButton *closeCross_;
 
146
        QMenu *tabMenu_;
 
147
        QAction *act_close_;
 
148
        QAction *act_next_;
 
149
        QAction *act_prev_;
 
150
        TabManager *tabManager_;
 
151
        QPointer<TabbableWidget> selectedTab_;
 
152
        bool userManagement_;
 
153
        bool tabBarSingles_;
 
154
        bool simplifiedCaption_;
 
155
 
 
156
        QSize chatSize_;
 
157
 
 
158
        void extinguishFlashingTabs();
 
159
        void updateCaption();
 
160
        void updateTabBar();
 
161
};
 
162
 
 
163
#endif