]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincontroller.cpp
Make use of the error messages coming from the places model.
[dolphin.git] / src / dolphincontroller.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
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 #include "dolphincontroller.h"
21
22 #include <QPainter>
23
24 DolphinController::DolphinController(QObject* parent) :
25 QObject(parent),
26 m_showPreview(false),
27 m_showAdditionalInfo(false),
28 m_zoomInPossible(false),
29 m_zoomOutPossible(false)
30 {
31 }
32
33 DolphinController::~DolphinController()
34 {
35 }
36
37 void DolphinController::triggerContextMenuRequest(const QPoint& pos)
38 {
39 emit activated();
40 emit requestContextMenu(pos);
41 }
42
43 void DolphinController::triggerActivation()
44 {
45 emit activated();
46 }
47
48 void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
49 const QModelIndex& index,
50 QWidget* source)
51 {
52 emit urlsDropped(urls, index, source);
53 }
54
55
56 void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
57 {
58 emit sortingChanged(sorting);
59 }
60
61 void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
62 {
63 emit sortOrderChanged(order);
64 }
65
66 void DolphinController::setShowPreview(bool show)
67 {
68 if (m_showPreview != show) {
69 m_showPreview = show;
70 emit showPreviewChanged(show);
71 }
72 }
73
74 void DolphinController::setShowAdditionalInfo(bool show)
75 {
76 if (m_showAdditionalInfo != show) {
77 m_showAdditionalInfo = show;
78 emit showAdditionalInfoChanged(show);
79 }
80 }
81
82 void DolphinController::triggerZoomIn()
83 {
84 emit zoomIn();
85 }
86
87 void DolphinController::triggerZoomOut()
88 {
89 emit zoomOut();
90 }
91
92 void DolphinController::drawHoverIndication(QWidget* widget,
93 const QRect& bounds,
94 const QBrush& brush)
95 {
96 QPainter painter(widget);
97 painter.save();
98 QBrush blendedBrush(brush);
99 QColor color = blendedBrush.color();
100 color.setAlpha(64);
101 blendedBrush.setColor(color);
102
103 const int radius = 10;
104 QPainterPath path(QPointF(bounds.left(), bounds.top() + radius));
105 path.quadTo(bounds.left(), bounds.top(), bounds.left() + radius, bounds.top());
106 path.lineTo(bounds.right() - radius, bounds.top());
107 path.quadTo(bounds.right(), bounds.top(), bounds.right(), bounds.top() + radius);
108 path.lineTo(bounds.right(), bounds.bottom() - radius);
109 path.quadTo(bounds.right(), bounds.bottom(), bounds.right() - radius, bounds.bottom());
110 path.lineTo(bounds.left() + radius, bounds.bottom());
111 path.quadTo(bounds.left(), bounds.bottom(), bounds.left(), bounds.bottom() - radius);
112 path.closeSubpath();
113
114 painter.setRenderHint(QPainter::Antialiasing);
115 painter.fillPath(path, blendedBrush);
116 painter.restore();
117 }
118
119 void DolphinController::triggerItem(const QModelIndex& index)
120 {
121 emit itemTriggered(index);
122 }
123
124 void DolphinController::emitItemEntered(const QModelIndex& index)
125 {
126 emit itemEntered(index);
127 }
128
129 void DolphinController::emitViewportEntered()
130 {
131 emit viewportEntered();
132 }
133
134 #include "dolphincontroller.moc"