]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincontroller.cpp
7723fd8ef693582e40d8d906ceeee86b96df051b
[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_zoomInPossible(false),
28 m_zoomOutPossible(false),
29 m_additionalInfoCount(0),
30 m_url()
31 {
32 }
33
34 DolphinController::~DolphinController()
35 {
36 }
37
38 void DolphinController::setUrl(const KUrl& url)
39 {
40 if (m_url != url) {
41 m_url = url;
42 emit urlChanged(url);
43 }
44 }
45
46 void DolphinController::triggerContextMenuRequest(const QPoint& pos)
47 {
48 emit activated();
49 emit requestContextMenu(pos);
50 }
51
52 void DolphinController::triggerActivation()
53 {
54 emit activated();
55 }
56
57 void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
58 const KUrl& destPath,
59 const QModelIndex& destIndex,
60 QWidget* source)
61 {
62 emit urlsDropped(urls, destPath, destIndex, source);
63 }
64
65
66 void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
67 {
68 emit sortingChanged(sorting);
69 }
70
71 void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
72 {
73 emit sortOrderChanged(order);
74 }
75
76 void DolphinController::setShowPreview(bool show)
77 {
78 if (m_showPreview != show) {
79 m_showPreview = show;
80 emit showPreviewChanged(show);
81 }
82 }
83
84 void DolphinController::setAdditionalInfoCount(int count)
85 {
86 if (m_additionalInfoCount != count) {
87 m_additionalInfoCount = count;
88 emit additionalInfoCountChanged(count);
89 }
90 }
91
92 void DolphinController::triggerZoomIn()
93 {
94 emit zoomIn();
95 }
96
97 void DolphinController::triggerZoomOut()
98 {
99 emit zoomOut();
100 }
101
102 void DolphinController::drawHoverIndication(QWidget* widget,
103 const QRect& bounds,
104 const QBrush& brush)
105 {
106 QPainter painter(widget);
107 painter.save();
108 QBrush blendedBrush(brush);
109 QColor color = blendedBrush.color();
110 color.setAlpha(64);
111 blendedBrush.setColor(color);
112
113 const int radius = 10;
114 QPainterPath path(QPointF(bounds.left(), bounds.top() + radius));
115 path.quadTo(bounds.left(), bounds.top(), bounds.left() + radius, bounds.top());
116 path.lineTo(bounds.right() - radius, bounds.top());
117 path.quadTo(bounds.right(), bounds.top(), bounds.right(), bounds.top() + radius);
118 path.lineTo(bounds.right(), bounds.bottom() - radius);
119 path.quadTo(bounds.right(), bounds.bottom(), bounds.right() - radius, bounds.bottom());
120 path.lineTo(bounds.left() + radius, bounds.bottom());
121 path.quadTo(bounds.left(), bounds.bottom(), bounds.left(), bounds.bottom() - radius);
122 path.closeSubpath();
123
124 painter.setRenderHint(QPainter::Antialiasing);
125 painter.fillPath(path, blendedBrush);
126 painter.restore();
127 }
128
129 void DolphinController::triggerItem(const QModelIndex& index)
130 {
131 emit itemTriggered(index);
132 }
133
134 void DolphinController::emitItemEntered(const QModelIndex& index)
135 {
136 emit itemEntered(index);
137 }
138
139 void DolphinController::emitViewportEntered()
140 {
141 emit viewportEntered();
142 }
143
144 #include "dolphincontroller.moc"