]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphintabpage.h
Output of licensedigger + manual cleanup afterwards.
[dolphin.git] / src / dolphintabpage.h
1 /*
2 * SPDX-FileCopyrightText: 2014 Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef DOLPHIN_TAB_PAGE_H
8 #define DOLPHIN_TAB_PAGE_H
9
10 #include <QPointer>
11 #include <QUrl>
12 #include <QWidget>
13
14 class QSplitter;
15 class DolphinViewContainer;
16 class KFileItemList;
17
18 class DolphinTabPage : public QWidget
19 {
20 Q_OBJECT
21
22 public:
23 explicit DolphinTabPage(const QUrl& primaryUrl, const QUrl& secondaryUrl = QUrl(), QWidget* parent = nullptr);
24
25 /**
26 * @return True if primary view is the active view in this tab.
27 */
28 bool primaryViewActive() const;
29
30 /**
31 * @return True if split view is enabled.
32 */
33 bool splitViewEnabled() const;
34
35 /**
36 * Enables or disables the split view mode.
37 *
38 * If \a enabled is true, it creates a secondary view with the url of the primary view.
39 */
40 void setSplitViewEnabled(bool enabled, const QUrl &secondaryUrl = QUrl());
41
42 /**
43 * @return The primary view container.
44 */
45 DolphinViewContainer* primaryViewContainer() const;
46
47 /**
48 * @return The secondary view container, can be 0 if split view is disabled.
49 */
50 DolphinViewContainer* secondaryViewContainer() const;
51
52 /**
53 * @return DolphinViewContainer of the active view
54 */
55 DolphinViewContainer* activeViewContainer() const;
56
57 /**
58 * Returns the selected items. The list is empty if no item has been
59 * selected.
60 */
61 KFileItemList selectedItems() const;
62
63 /**
64 * Returns the number of selected items (this is faster than
65 * invoking selectedItems().count()).
66 */
67 int selectedItemsCount() const;
68
69 /**
70 * Marks the items indicated by \p urls to get selected after the
71 * directory DolphinView::url() has been loaded. Note that nothing
72 * gets selected if no loading of a directory has been triggered
73 * by DolphinView::setUrl() or DolphinView::reload().
74 */
75 void markUrlsAsSelected(const QList<QUrl> &urls);
76
77 /**
78 * Marks the item indicated by \p url to be scrolled to and as the
79 * current item after directory DolphinView::url() has been loaded.
80 */
81 void markUrlAsCurrent(const QUrl& url);
82
83 /**
84 * Sets the places selector visible, if \a visible is true.
85 * The places selector allows to select the places provided
86 * by the places model passed in the constructor. Per default
87 * the places selector is visible.
88 */
89 void setPlacesSelectorVisible(bool visible);
90
91 /**
92 * Refreshes the views of the main window by recreating them according to
93 * the given Dolphin settings.
94 */
95 void refreshViews();
96
97 /**
98 * Saves all tab related properties (urls, splitter layout, ...).
99 *
100 * @return A byte-array which contains all properties.
101 */
102 QByteArray saveState() const;
103
104 /**
105 * Restores all tab related properties (urls, splitter layout, ...) from
106 * the given \a state.
107 */
108 void restoreState(const QByteArray& state);
109
110 /**
111 * Restores all tab related properties (urls, splitter layout, ...) from
112 * the given \a state.
113 *
114 * @deprecated The first tab state version has no version number, we keep
115 * this method to restore old states (<= Dolphin 4.14.x).
116 */
117 Q_DECL_DEPRECATED void restoreStateV1(const QByteArray& state);
118
119 /**
120 * Set whether the tab page is active
121 *
122 */
123 void setActive(bool active);
124
125 signals:
126 void activeViewChanged(DolphinViewContainer* viewContainer);
127 void activeViewUrlChanged(const QUrl& url);
128
129 private slots:
130 /**
131 * Handles the view activated event.
132 *
133 * It sets the previous active view to inactive, updates the current
134 * active view type and triggers the activeViewChanged event.
135 */
136 void slotViewActivated();
137
138 /**
139 * Handles the view url redirection event.
140 *
141 * It emits the activeViewUrlChanged signal with the url \a newUrl.
142 */
143 void slotViewUrlRedirection(const QUrl& oldUrl, const QUrl& newUrl);
144
145 void switchActiveView();
146
147 private:
148 /**
149 * Creates a new view container and does the default initialization.
150 */
151 DolphinViewContainer* createViewContainer(const QUrl& url) const;
152
153 private:
154 QSplitter* m_splitter;
155
156 QPointer<DolphinViewContainer> m_primaryViewContainer;
157 QPointer<DolphinViewContainer> m_secondaryViewContainer;
158
159 bool m_primaryViewActive;
160 bool m_splitViewEnabled;
161 bool m_active;
162 };
163
164 #endif // DOLPHIN_TAB_PAGE_H