2 * SPDX-FileCopyrightText: 2014 Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef DOLPHIN_TAB_PAGE_H
8 #define DOLPHIN_TAB_PAGE_H
14 class DolphinNavigatorsWidgetAction
;
15 class DolphinViewContainer
;
19 class DolphinTabPage
: public QWidget
24 explicit DolphinTabPage(const QUrl
& primaryUrl
, const QUrl
& secondaryUrl
= QUrl(), QWidget
* parent
= nullptr);
27 * @return True if primary view is the active view in this tab.
29 bool primaryViewActive() const;
32 * @return True if split view is enabled.
34 bool splitViewEnabled() const;
37 * Enables or disables the split view mode.
39 * If \a enabled is true, it creates a secondary view with the url of the primary view.
41 void setSplitViewEnabled(bool enabled
, const QUrl
&secondaryUrl
= QUrl());
44 * @return The primary view container.
46 DolphinViewContainer
* primaryViewContainer() const;
49 * @return The secondary view container, can be 0 if split view is disabled.
51 DolphinViewContainer
* secondaryViewContainer() const;
54 * @return DolphinViewContainer of the active view
56 DolphinViewContainer
* activeViewContainer() const;
59 * Returns the selected items. The list is empty if no item has been
62 KFileItemList
selectedItems() const;
65 * Returns the number of selected items (this is faster than
66 * invoking selectedItems().count()).
68 int selectedItemsCount() const;
71 * Connects a navigatorsWidget to this. It will be connected to the DolphinViewContainers
72 * managed by this tab. For alignment purposes this will from now on notify the
73 * navigatorsWidget when this tab or its viewContainers are resized.
75 void connectNavigators(DolphinNavigatorsWidgetAction
*navigatorsWidget
);
78 * Makes it so this tab and its DolphinViewContainers aren't controlled by any
79 * UrlNavigators anymore.
81 void disconnectNavigators();
84 * Calls resizeNavigators() when a watched object is resized.
86 bool eventFilter(QObject
*watched
, QEvent
*event
) override
;
89 * Notify the connected DolphinNavigatorsWidgetAction of geometry changes which it
90 * needs for visual alignment.
92 void resizeNavigators() const;
95 * Marks the items indicated by \p urls to get selected after the
96 * directory DolphinView::url() has been loaded. Note that nothing
97 * gets selected if no loading of a directory has been triggered
98 * by DolphinView::setUrl() or DolphinView::reload().
100 void markUrlsAsSelected(const QList
<QUrl
> &urls
);
103 * Marks the item indicated by \p url to be scrolled to and as the
104 * current item after directory DolphinView::url() has been loaded.
106 void markUrlAsCurrent(const QUrl
& url
);
109 * Refreshes the views of the main window by recreating them according to
110 * the given Dolphin settings.
115 * Saves all tab related properties (urls, splitter layout, ...).
117 * @return A byte-array which contains all properties.
119 QByteArray
saveState() const;
122 * Restores all tab related properties (urls, splitter layout, ...) from
123 * the given \a state.
125 void restoreState(const QByteArray
& state
);
128 * Restores all tab related properties (urls, splitter layout, ...) from
129 * the given \a state.
131 * @deprecated The first tab state version has no version number, we keep
132 * this method to restore old states (<= Dolphin 4.14.x).
134 Q_DECL_DEPRECATED
void restoreStateV1(const QByteArray
& state
);
137 * Set whether the tab page is active
140 void setActive(bool active
);
143 void activeViewChanged(DolphinViewContainer
* viewContainer
);
144 void activeViewUrlChanged(const QUrl
& url
);
145 void splitterMoved(int pos
, int index
);
149 * Handles the view activated event.
151 * It sets the previous active view to inactive, updates the current
152 * active view type and triggers the activeViewChanged event.
154 void slotViewActivated();
157 * Handles the view url redirection event.
159 * It emits the activeViewUrlChanged signal with the url \a newUrl.
161 void slotViewUrlRedirection(const QUrl
& oldUrl
, const QUrl
& newUrl
);
163 void switchActiveView();
167 * Creates a new view container and does the default initialization.
169 DolphinViewContainer
* createViewContainer(const QUrl
& url
) const;
172 QSplitter
* m_splitter
;
174 QPointer
<DolphinNavigatorsWidgetAction
> m_navigatorsWidget
;
175 QPointer
<DolphinViewContainer
> m_primaryViewContainer
;
176 QPointer
<DolphinViewContainer
> m_secondaryViewContainer
;
178 bool m_primaryViewActive
;
179 bool m_splitViewEnabled
;
183 #endif // DOLPHIN_TAB_PAGE_H