1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
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. *
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. *
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 ***************************************************************************/
20 #ifndef DOLPHINCONTROLLER_H
21 #define DOLPHINCONTROLLER_H
23 #include <dolphinview.h>
26 #include <libdolphin_export.h>
33 * @brief Allows to control Dolphin views and to react on state changes.
35 * One instance of a DolphinController can be assigned to a variable number of
36 * Dolphin views (DolphinIconsView, DolphinDetailsView) by passing it in
40 * DolphinController* controller = new DolphinController(parent);
41 * DolphinDetailsView* detailsView = new DolphinDetailsView(parent, controller);
42 * DolphinIconsView* iconsView = new DolphinIconsView(parent, controller);
45 * The Dolphin view assures that the controller gets informed about selection changes,
46 * when an item should be triggered and a lot more. The controller emits the corresponding signals
47 * so that the receiver may react on those changes.
49 class LIBDOLPHIN_EXPORT DolphinController
: public QObject
54 explicit DolphinController(QObject
* parent
);
55 virtual ~DolphinController();
57 void setUrl(const KUrl
& url
) { m_url
= url
; }
58 const KUrl
& url() const { return m_url
; }
60 void triggerContextMenuRequest(const QPoint
& pos
);
62 void triggerActivation();
64 void indicateDroppedUrls(const KUrl::List
& urls
,
65 const QModelIndex
& index
,
68 void indicateSortingChange(DolphinView::Sorting sorting
);
70 void indicateSortOrderChange(Qt::SortOrder order
);
72 void setShowPreview(bool showPreview
);
73 bool showPreview() const { return m_showPreview
; }
76 void setZoomInPossible(bool possible
) { m_zoomInPossible
= possible
; }
77 bool isZoomInPossible() const { return m_zoomInPossible
; }
79 void triggerZoomOut();
80 void setZoomOutPossible(bool possible
) { m_zoomOutPossible
= possible
; }
81 bool isZoomOutPossible() const { return m_zoomOutPossible
; }
84 void triggerItem(const QModelIndex
& index
);
85 void indicateSelectionChange();
89 * Is emitted if a context menu should be opened.
90 * @param pos Position relative to the view widget where the
91 * context menu should be opened. It is recommended
92 * to get the corresponding model index from
95 void requestContextMenu(const QPoint
& pos
);
98 * Is emitted if the view has been activated by e. g. a mouse click.
103 * Is emitted if the URLs \a urls have been dropped to the index
104 * \a index. \a source indicates the widget where the dragging has
107 void urlsDropped(const KUrl::List
& urls
,
108 const QModelIndex
& index
,
111 /** Is emitted if the sorting has been changed to \a sorting. */
112 void sortingChanged(DolphinView::Sorting sorting
);
114 /** Is emitted if the sort order has been changed to \a sort order. */
115 void sortOrderChanged(Qt::SortOrder order
);
118 * Is emitted if the state for showing previews has been
119 * changed to \a showPreview.
121 void showPreviewChanged(bool showPreview
);
124 * Is emitted if the item with the index \a index should be triggered.
125 * Usually triggering on a directory opens the directory, triggering
126 * on a file opens the corresponding application.
128 void itemTriggered(const QModelIndex
& index
);
130 /** Is emitted if the selection has been changed by the user. */
131 void selectionChanged();
133 /** Is emitted if the view should zoom in. */
136 /** Is emitted if the view should zoom out. */
141 bool m_zoomInPossible
;
142 bool m_zoomOutPossible
;