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