]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphintabwidget.h
Merge branch 'KDE/4.14'
[dolphin.git] / src / dolphintabwidget.h
1 /***************************************************************************
2 * Copyright (C) 2014 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef DOLPHIN_TAB_WIDGET_H
21 #define DOLPHIN_TAB_WIDGET_H
22
23 #include <QTabWidget>
24 #include <KUrl>
25
26 class DolphinViewContainer;
27 class DolphinTabPage;
28 class KConfigGroup;
29
30 class DolphinTabWidget : public QTabWidget
31 {
32 Q_OBJECT
33
34 public:
35 explicit DolphinTabWidget(QWidget* parent);
36
37 /**
38 * @return Tab page at the current index (can be 0 if tabs count is smaller than 1)
39 */
40 DolphinTabPage* currentTabPage() const;
41
42 /**
43 * @return Tab page at the given \a index (can be 0 if the index is out-of-range)
44 */
45 DolphinTabPage* tabPageAt(const int index) const;
46
47 void saveProperties(KConfigGroup& group) const;
48 void readProperties(const KConfigGroup& group);
49
50 /**
51 * Refreshes the views of the main window by recreating them according to
52 * the given Dolphin settings.
53 */
54 void refreshViews();
55
56 signals:
57 /**
58 * Is emitted when the active view has been changed, by changing the current
59 * tab or by activating another view when split view is enabled in the current
60 * tab.
61 */
62 void activeViewChanged(DolphinViewContainer* viewContainer);
63
64 /**
65 * Is emitted when the number of open tabs has changed (e.g. by opening or
66 * closing a tab)
67 */
68 void tabCountChanged(int count);
69
70 /**
71 * Is emitted when a tab has been closed.
72 */
73 void rememberClosedTab(const KUrl& url, const QByteArray& state);
74
75 /**
76 * Is emitted when the url of the current tab has been changed. This signal
77 * is also emitted when the active view has been changed.
78 */
79 void currentUrlChanged(const KUrl& url);
80
81 public slots:
82 /**
83 * Opens a new view with the current URL that is part of a tab and activates
84 * the tab.
85 */
86 void openNewActivatedTab();
87
88 /**
89 * Opens a new tab showing the URL \a primaryUrl and the optional URL
90 * \a secondaryUrl and activates the tab.
91 */
92 void openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
93
94 /**
95 * Opens a new tab in the background showing the URL \a primaryUrl and the
96 * optional URL \a secondaryUrl.
97 */
98 void openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
99
100 /**
101 * Opens each directory in \p dirs in a separate tab. If the "split view"
102 * option is enabled, 2 directories are collected within one tab.
103 */
104 void openDirectories(const QList<KUrl>& dirs);
105
106 /**
107 * Opens the directory which contains the files \p files
108 * and selects all files (implements the --select option
109 * of Dolphin).
110 */
111 void openFiles(const QList<KUrl>& files);
112
113 /**
114 * Closes the currently active tab.
115 */
116 void closeTab();
117
118 /**
119 * Closes the tab with the index \a index and activates the tab with index - 1.
120 */
121 void closeTab(const int index);
122
123 /**
124 * Activates the next tab in the tab bar.
125 * If the current active tab is the last tab, it activates the first tab.
126 */
127 void activateNextTab();
128
129 /**
130 * Activates the previous tab in the tab bar.
131 * If the current active tab is the first tab, it activates the last tab.
132 */
133 void activatePrevTab();
134
135 /**
136 * Is invoked if the Places panel got visible/invisible and takes care
137 * that the places-selector of all views is only shown if the Places panel
138 * is invisible.
139 */
140 void slotPlacesPanelVisibilityChanged(bool visible);
141
142 /**
143 * Is called when the user wants to reopen a previously closed tab from
144 * the recent tabs menu.
145 */
146 void restoreClosedTab(const QByteArray& state);
147
148 private slots:
149 /**
150 * Opens the tab with the index \a index in a new Dolphin instance and closes
151 * this tab.
152 */
153 void detachTab(int index);
154
155 /**
156 * Opens a new tab showing the url from tab at the given \a index and
157 * activates the tab.
158 */
159 void openNewActivatedTab(int index);
160
161 /**
162 * Is connected to the KTabBar signal receivedDropEvent.
163 * Allows dragging and dropping files onto tabs.
164 */
165 void tabDropEvent(int tab, QDropEvent* event);
166
167 /**
168 * The active view url of a tab has been changed so update the text and the
169 * icon of the corresponding tab.
170 */
171 void tabUrlChanged(const KUrl& url);
172
173 void currentTabChanged(int index);
174
175 protected:
176 virtual void tabInserted(int index);
177 virtual void tabRemoved(int index);
178
179 private:
180 /**
181 * Returns the name of the tab for the URL \a url.
182 */
183 QString tabName(const KUrl& url) const;
184
185 private:
186 /** Caches the (negated) places panel visibility */
187 bool m_placesSelectorVisible;
188 };
189
190 #endif