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
;
88 void insertNavigatorsWidget(DolphinNavigatorsWidgetAction
*navigatorsWidget
);
91 * Notify the connected DolphinNavigatorsWidgetAction of geometry changes which it
92 * needs for visual alignment.
94 void resizeNavigators() const;
97 * Marks the items indicated by \p urls to get selected after the
98 * directory DolphinView::url() has been loaded. Note that nothing
99 * gets selected if no loading of a directory has been triggered
100 * by DolphinView::setUrl() or DolphinView::reload().
102 void markUrlsAsSelected(const QList
<QUrl
> &urls
);
105 * Marks the item indicated by \p url to be scrolled to and as the
106 * current item after directory DolphinView::url() has been loaded.
108 void markUrlAsCurrent(const QUrl
& url
);
111 * Refreshes the views of the main window by recreating them according to
112 * the given Dolphin settings.
117 * Saves all tab related properties (urls, splitter layout, ...).
119 * @return A byte-array which contains all properties.
121 QByteArray
saveState() const;
124 * Restores all tab related properties (urls, splitter layout, ...) from
125 * the given \a state.
127 void restoreState(const QByteArray
& state
);
130 * Restores all tab related properties (urls, splitter layout, ...) from
131 * the given \a state.
133 * @deprecated The first tab state version has no version number, we keep
134 * this method to restore old states (<= Dolphin 4.14.x).
136 Q_DECL_DEPRECATED
void restoreStateV1(const QByteArray
& state
);
139 * Set whether the tab page is active
142 void setActive(bool active
);
145 void activeViewChanged(DolphinViewContainer
* viewContainer
);
146 void activeViewUrlChanged(const QUrl
& url
);
147 void splitterMoved(int pos
, int index
);
151 * Handles the view activated event.
153 * It sets the previous active view to inactive, updates the current
154 * active view type and triggers the activeViewChanged event.
156 void slotViewActivated();
159 * Handles the view url redirection event.
161 * It emits the activeViewUrlChanged signal with the url \a newUrl.
163 void slotViewUrlRedirection(const QUrl
& oldUrl
, const QUrl
& newUrl
);
165 void switchActiveView();
169 * Creates a new view container and does the default initialization.
171 DolphinViewContainer
* createViewContainer(const QUrl
& url
) const;
174 QSplitter
* m_splitter
;
176 QPointer
<DolphinNavigatorsWidgetAction
> m_navigatorsWidget
;
177 QPointer
<DolphinViewContainer
> m_primaryViewContainer
;
178 QPointer
<DolphinViewContainer
> m_secondaryViewContainer
;
180 bool m_primaryViewActive
;
181 bool m_splitViewEnabled
;
185 #endif // DOLPHIN_TAB_PAGE_H