File indexing completed on 2024-04-28 05:45:25
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz19@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef VIEWMODECONTROLLER_H 0008 #define VIEWMODECONTROLLER_H 0009 0010 #include "dolphin_export.h" 0011 #include "views/dolphinview.h" 0012 0013 #include <QObject> 0014 #include <QUrl> 0015 0016 /** 0017 * @brief Allows the DolphinView to control the view implementations for the 0018 * different view modes. 0019 * 0020 * The view implementations (DolphinIconsView, DolphinDetailsView, DolphinColumnView) 0021 * connect to signals of the ViewModeController to react on changes. The view 0022 * implementations get only read-access to the ViewModeController. 0023 */ 0024 class DOLPHIN_EXPORT ViewModeController : public QObject 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 explicit ViewModeController(QObject *parent = nullptr); 0030 ~ViewModeController() override; 0031 0032 /** 0033 * @return URL that is shown by the view mode implementation. 0034 */ 0035 QUrl url() const; 0036 0037 /** 0038 * Sets the URL to \a url and does nothing else. Called when 0039 * a redirection happens. See ViewModeController::setUrl() 0040 */ 0041 void redirectToUrl(const QUrl &url); 0042 0043 /** 0044 * Informs the view mode implementation about a change of the activation 0045 * state by emitting the signal activationChanged(). 0046 */ 0047 void indicateActivationChange(bool active); 0048 0049 /** 0050 * Sets the zoom level to \a level and emits the signal zoomLevelChanged(). 0051 * It must be assured that the used level is inside the range 0052 * ViewModeController::zoomLevelMinimum() and 0053 * ViewModeController::zoomLevelMaximum(). 0054 */ 0055 void setZoomLevel(int level); 0056 int zoomLevel() const; 0057 0058 /** 0059 * Sets the name filter to \a and emits the signal nameFilterChanged(). 0060 */ 0061 void setNameFilter(const QString &nameFilter); 0062 QString nameFilter() const; 0063 0064 public Q_SLOTS: 0065 /** 0066 * Sets the URL to \a url and emits the signals cancelPreviews() and 0067 * urlChanged() if \a url is different for the current URL. 0068 */ 0069 void setUrl(const QUrl &url); 0070 0071 Q_SIGNALS: 0072 /** 0073 * Is emitted if the URL has been changed by ViewModeController::setUrl(). 0074 */ 0075 void urlChanged(const QUrl &url); 0076 0077 /** 0078 * Is emitted, if ViewModeController::indicateActivationChange() has been 0079 * invoked. The view mode implementation may update its visual state 0080 * to represent the activation state. 0081 */ 0082 void activationChanged(bool active); 0083 0084 /** 0085 * Is emitted if the name filter has been changed by 0086 * ViewModeController::setNameFilter(). 0087 */ 0088 void nameFilterChanged(const QString &nameFilter); 0089 0090 /** 0091 * Is emitted if the zoom level has been changed by 0092 * ViewModeController::setZoomLevel(). 0093 */ 0094 void zoomLevelChanged(int level); 0095 0096 /** 0097 * Is emitted if pending previews should be canceled (e. g. because of an URL change). 0098 */ 0099 void cancelPreviews(); 0100 0101 private: 0102 int m_zoomLevel; 0103 QString m_nameFilter; 0104 QUrl m_url; 0105 }; 0106 0107 #endif