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