]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/viewmodecontroller.h
Fix crash at shutdown after showing a tooltip
[dolphin.git] / src / views / viewmodecontroller.h
1 /***************************************************************************
2 * Copyright (C) 2010 by Peter Penz <peter.penz19@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 VIEWMODECONTROLLER_H
21 #define VIEWMODECONTROLLER_H
22
23 #include "dolphin_export.h"
24 #include "views/dolphinview.h"
25
26 #include <QObject>
27 #include <QUrl>
28
29 /**
30 * @brief Allows the DolphinView to control the view implementations for the
31 * different view modes.
32 *
33 * The view implementations (DolphinIconsView, DolphinDetailsView, DolphinColumnView)
34 * connect to signals of the ViewModeController to react on changes. The view
35 * implementations get only read-access to the ViewModeController.
36 */
37 class DOLPHIN_EXPORT ViewModeController : public QObject
38 {
39 Q_OBJECT
40
41 public:
42 explicit ViewModeController(QObject* parent = nullptr);
43 ~ViewModeController() override;
44
45 /**
46 * @return URL that is shown by the view mode implementation.
47 */
48 QUrl url() const;
49
50 /**
51 * Sets the URL to \a url and does nothing else. Called when
52 * a redirection happens. See ViewModeController::setUrl()
53 */
54 void redirectToUrl(const QUrl& url);
55
56 /**
57 * Informs the view mode implementation about a change of the activation
58 * state by emitting the signal activationChanged().
59 */
60 void indicateActivationChange(bool active);
61
62 /**
63 * Sets the zoom level to \a level and emits the signal zoomLevelChanged().
64 * It must be assured that the used level is inside the range
65 * ViewModeController::zoomLevelMinimum() and
66 * ViewModeController::zoomLevelMaximum().
67 */
68 void setZoomLevel(int level);
69 int zoomLevel() const;
70
71 /**
72 * Sets the name filter to \a and emits the signal nameFilterChanged().
73 */
74 void setNameFilter(const QString& nameFilter);
75 QString nameFilter() const;
76
77 /**
78 * Requests the view mode implementation to hide tooltips.
79 */
80 void requestToolTipHiding();
81
82 public slots:
83 /**
84 * Sets the URL to \a url and emits the signals cancelPreviews() and
85 * urlChanged() if \a url is different for the current URL.
86 */
87 void setUrl(const QUrl& url);
88
89 signals:
90 /**
91 * Is emitted if the URL has been changed by ViewModeController::setUrl().
92 */
93 void urlChanged(const QUrl& url);
94
95 /**
96 * Is emitted, if ViewModeController::indicateActivationChange() has been
97 * invoked. The view mode implementation may update its visual state
98 * to represent the activation state.
99 */
100 void activationChanged(bool active);
101
102 /**
103 * Is emitted if the name filter has been changed by
104 * ViewModeController::setNameFilter().
105 */
106 void nameFilterChanged(const QString& nameFilter);
107
108 /**
109 * Is emitted if the zoom level has been changed by
110 * ViewModeController::setZoomLevel().
111 */
112 void zoomLevelChanged(int level);
113
114 /**
115 * Is emitted if pending previews should be canceled (e. g. because of an URL change).
116 */
117 void cancelPreviews();
118
119 private:
120 int m_zoomLevel;
121 QString m_nameFilter;
122 QUrl m_url;
123 };
124
125 #endif