]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/viewmodecontroller.h
dolphinui: Set view_mode action to low priority
[dolphin.git] / src / views / viewmodecontroller.h
1 /*
2 * SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef VIEWMODECONTROLLER_H
8 #define VIEWMODECONTROLLER_H
9
10 #include "dolphin_export.h"
11 #include "views/dolphinview.h"
12
13 #include <QObject>
14 #include <QUrl>
15
16 /**
17 * @brief Allows the DolphinView to control the view implementations for the
18 * different view modes.
19 *
20 * The view implementations (DolphinIconsView, DolphinDetailsView, DolphinColumnView)
21 * connect to signals of the ViewModeController to react on changes. The view
22 * implementations get only read-access to the ViewModeController.
23 */
24 class DOLPHIN_EXPORT ViewModeController : public QObject
25 {
26 Q_OBJECT
27
28 public:
29 explicit ViewModeController(QObject *parent = nullptr);
30 ~ViewModeController() override;
31
32 /**
33 * @return URL that is shown by the view mode implementation.
34 */
35 QUrl url() const;
36
37 /**
38 * Sets the URL to \a url and does nothing else. Called when
39 * a redirection happens. See ViewModeController::setUrl()
40 */
41 void redirectToUrl(const QUrl &url);
42
43 /**
44 * Informs the view mode implementation about a change of the activation
45 * state by emitting the signal activationChanged().
46 */
47 void indicateActivationChange(bool active);
48
49 /**
50 * Sets the zoom level to \a level and emits the signal zoomLevelChanged().
51 * It must be assured that the used level is inside the range
52 * ViewModeController::zoomLevelMinimum() and
53 * ViewModeController::zoomLevelMaximum().
54 */
55 void setZoomLevel(int level);
56 int zoomLevel() const;
57
58 /**
59 * Sets the name filter to \a and emits the signal nameFilterChanged().
60 */
61 void setNameFilter(const QString &nameFilter);
62 QString nameFilter() const;
63
64 public Q_SLOTS:
65 /**
66 * Sets the URL to \a url and emits the signals cancelPreviews() and
67 * urlChanged() if \a url is different for the current URL.
68 */
69 void setUrl(const QUrl &url);
70
71 Q_SIGNALS:
72 /**
73 * Is emitted if the URL has been changed by ViewModeController::setUrl().
74 */
75 void urlChanged(const QUrl &url);
76
77 /**
78 * Is emitted, if ViewModeController::indicateActivationChange() has been
79 * invoked. The view mode implementation may update its visual state
80 * to represent the activation state.
81 */
82 void activationChanged(bool active);
83
84 /**
85 * Is emitted if the name filter has been changed by
86 * ViewModeController::setNameFilter().
87 */
88 void nameFilterChanged(const QString &nameFilter);
89
90 /**
91 * Is emitted if the zoom level has been changed by
92 * ViewModeController::setZoomLevel().
93 */
94 void zoomLevelChanged(int level);
95
96 /**
97 * Is emitted if pending previews should be canceled (e. g. because of an URL change).
98 */
99 void cancelPreviews();
100
101 private:
102 int m_zoomLevel;
103 QString m_nameFilter;
104 QUrl m_url;
105 };
106
107 #endif