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_PAGE_H |
21 | #define DOLPHIN_TAB_PAGE_H |
22 | |
23 | #include <QWidget> |
24 | #include <QPointer> |
25 | #include <KUrl> |
26 | |
27 | class QSplitter; |
28 | class DolphinViewContainer; |
29 | class KFileItemList; |
30 | |
31 | class DolphinTabPage : public QWidget |
32 | { |
33 | Q_OBJECT |
34 | |
35 | public: |
36 | explicit DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl(), QWidget* parent = 0); |
37 | |
38 | /** |
39 | * @return True if primary view is the active view in this tab. |
40 | */ |
41 | bool primaryViewActive() const; |
42 | |
43 | /** |
44 | * @return True if split view is enabled. |
45 | */ |
46 | bool splitViewEnabled() const; |
47 | |
48 | /** |
49 | * Enables or disables the split view mode. |
50 | * |
51 | * If \a enabled is true, it creates a secondary view with the url of the primary view. |
52 | */ |
53 | void setSplitViewEnabled(bool enabled); |
54 | |
55 | /** |
56 | * @return The primary view containter. |
57 | */ |
58 | DolphinViewContainer* primaryViewContainer() const; |
59 | |
60 | /** |
61 | * @return The secondary view containter, can be 0 if split view is disabled. |
62 | */ |
63 | DolphinViewContainer* secondaryViewContainer() const; |
64 | |
65 | /** |
66 | * @return DolphinViewContainer of the active view |
67 | */ |
68 | DolphinViewContainer* activeViewContainer() const; |
69 | |
70 | /** |
71 | * Returns the selected items. The list is empty if no item has been |
72 | * selected. |
73 | */ |
74 | KFileItemList selectedItems() const; |
75 | |
76 | /** |
77 | * Returns the number of selected items (this is faster than |
78 | * invoking selectedItems().count()). |
79 | */ |
80 | int selectedItemsCount() const; |
81 | |
82 | /** |
83 | * Marks the items indicated by \p urls to get selected after the |
84 | * directory DolphinView::url() has been loaded. Note that nothing |
85 | * gets selected if no loading of a directory has been triggered |
86 | * by DolphinView::setUrl() or DolphinView::reload(). |
87 | */ |
88 | void markUrlsAsSelected(const QList<KUrl>& urls); |
89 | |
90 | /** |
91 | * Marks the item indicated by \p url to be scrolled to and as the |
92 | * current item after directory DolphinView::url() has been loaded. |
93 | */ |
94 | void markUrlAsCurrent(const KUrl& url); |
95 | |
96 | /** |
97 | * Sets the places selector visible, if \a visible is true. |
98 | * The places selector allows to select the places provided |
99 | * by the places model passed in the constructor. Per default |
100 | * the places selector is visible. |
101 | */ |
102 | void setPlacesSelectorVisible(bool visible); |
103 | |
104 | /** |
105 | * Refreshes the views of the main window by recreating them according to |
106 | * the given Dolphin settings. |
107 | */ |
108 | void refreshViews(); |
109 | |
110 | /** |
111 | * Saves all tab related properties (urls, splitter layout, ...). |
112 | * |
113 | * @return A byte-array which contains all properties. |
114 | */ |
115 | QByteArray saveState() const; |
116 | |
117 | /** |
118 | * Restores all tab related properties (urls, splitter layout, ...) from |
119 | * the given \a state. |
120 | */ |
121 | void restoreState(const QByteArray& state); |
122 | |
123 | signals: |
124 | void activeViewChanged(); |
125 | void activeViewUrlChanged(const KUrl& url); |
126 | |
127 | private slots: |
128 | /** |
129 | * Handles the view activated event. |
130 | * |
131 | * It sets the previous active view to inactive, updates the current |
132 | * active view type and triggers the activeViewChanged event. |
133 | */ |
134 | void slotViewActivated(); |
135 | |
136 | private: |
137 | /** |
138 | * Creates a new view container and does the default initialization. |
139 | */ |
140 | DolphinViewContainer* createViewContainer(const KUrl& url) const; |
141 | |
142 | private: |
143 | QSplitter* m_splitter; |
144 | |
145 | QPointer<DolphinViewContainer> m_primaryViewContainer; |
146 | QPointer<DolphinViewContainer> m_secondaryViewContainer; |
147 | |
148 | bool m_primaryViewActive; |
149 | bool m_splitViewEnabled; |
150 | }; |
151 | |
152 | #endif // DOLPHIN_TAB_PAGE_H |
153 | |