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