1 /*
2  * tabmanager.h - Controller for tab dialogs.
3  * Copyright (C) 2007  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  */
20 #ifndef _TABMANAGER_H_
21 #define _TABMANAGER_H_
22 
23 #include <QObject>
24 #include <QList>
25 #include "psicon.h"
26 
27 class TabbableWidget;
28 class TabDlg;
29 class TabDlgDelegate;
30 
31 class TabManager : public QObject
32 {
33 	Q_OBJECT
34 public:
35 	TabManager(PsiCon *psiCon, QObject *parent = 0);
36 	~TabManager();
37 
38 	PsiCon* psiCon() const;
39 
40 	/**
41 	 * Get the default tabset for this widget (created if needed).
42 	 */
43 	TabDlg* getTabs(QWidget *widget);
44 
45 	/**
46 	 * Return a new tabset (for this widget).
47 	 */
48 	TabDlg*	newTabs(QWidget *widget=0);
49 
50 	/**
51 	 * Checks if a tabset manages this widget.
52 	 */
53 	bool isChatTabbed(const TabbableWidget*) const;
54 
55 	/**
56 	 * Returns the tab dialog that owns the supplied widget.
57 	 */
58 	TabDlg* getManagingTabs(const TabbableWidget*) const;
59 
60 	/**
61 	 * Returns all active tabsets (could be empty).
62 	 */
63 	const QList<TabDlg*>& tabSets();
64 
65 	/**
66 	 * Checks if a given widget should be in a tabset
67 	 * (depends on set options and widget type).
68 	 */
69 	bool shouldBeTabbed(QWidget *widget);
70 
71 	/**
72 	 * removes and deletes all tabsets
73 	 */
74 	void deleteAll();
75 
76 
77 	/**
78 	 * Returns the Kind of the given widget.
79 	 */
80 	QChar tabKind(QWidget *widget);
81 
82 	/**
83 	 * return the preferred tabset for a given kind of tabs(0 for none).
84 	 */
85 	TabDlg *preferredTabsForKind(QChar kind);
86 
87 	/**
88 	 * set the preferred tabset for a given kind of tabs
89 	 */
90 	void setPreferredTabsForKind(QChar kind, TabDlg *tabs);
91 
92 	/**
93 	 * set the delegate to be used for all created TabDlgs
94 	 */
95 	void setTabDlgDelegate(TabDlgDelegate *delegate);
96 
97 	/**
98 	 * enable/disable user dragging/detach/assignment of tabs
99 	 *
100 	 * the default is enabled
101 	 */
102 	void setUserManagementEnabled(bool enabled);
103 
104 	/**
105 	 * enable/disable display of PsiTabBar when there is only one tab
106 	 *
107 	 * the default is enabled
108 	 */
109 	void setTabBarShownForSingles(bool enabled);
110 
111 	/**
112 	 * enable/disable simplified caption mode
113 	 *
114 	 * the default is disabled
115 	 */
116 	void setSimplifiedCaptionEnabled(bool enabled);
117 
118 public slots:
119 	void tabDestroyed(QObject*);
120 
121 private:
122 	QMap<QChar, TabDlg*> preferedTabsetForKind_;
123 	QMap<TabDlg*, QString> tabsetToKinds_;
124  	QList<TabDlg*> tabs_;
125 	QList<TabbableWidget*> tabControlledChats_;
126 	PsiCon *psiCon_;
127 	TabDlgDelegate *tabDlgDelegate_;
128 	bool userManagement_;
129 	bool tabSingles_;
130 	bool simplifiedCaption_;
131 };
132 
133 #endif /* _TABMANAGER_H_ */
134