]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincontroller.cpp
* fixed drag & drop issue in column view (dropping on files was not possible -> handl...
[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(DolphinView* dolphinView) :
25 QObject(dolphinView),
26 m_zoomInPossible(false),
27 m_zoomOutPossible(false),
28 m_url(),
29 m_dolphinView(dolphinView)
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::triggerUrlChangeRequest(const KUrl& url)
46 {
47 if (m_url != url) {
48 emit requestUrlChange(url);
49 }
50 }
51
52 void DolphinController::triggerContextMenuRequest(const QPoint& pos)
53 {
54 emit activated();
55 emit requestContextMenu(pos);
56 }
57
58 void DolphinController::requestActivation()
59 {
60 emit activated();
61 }
62
63 void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
64 const KUrl& destPath,
65 const KFileItem& destItem)
66 {
67 emit urlsDropped(urls, destPath, destItem);
68 }
69
70
71 void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
72 {
73 emit sortingChanged(sorting);
74 }
75
76 void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
77 {
78 emit sortOrderChanged(order);
79 }
80
81 void DolphinController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info)
82 {
83 emit additionalInfoChanged(info);
84 }
85
86 void DolphinController::indicateActivationChange(bool active)
87 {
88 emit activationChanged(active);
89 }
90
91 void DolphinController::triggerZoomIn()
92 {
93 emit zoomIn();
94 }
95
96 void DolphinController::triggerZoomOut()
97 {
98 emit zoomOut();
99 }
100
101 void DolphinController::drawHoverIndication(QWidget* widget,
102 const QRect& bounds,
103 const QBrush& brush)
104 {
105 QPainter painter(widget);
106 painter.save();
107 QBrush blendedBrush(brush);
108 QColor color = blendedBrush.color();
109 color.setAlpha(64);
110 blendedBrush.setColor(color);
111
112 const int radius = 10;
113 QPainterPath path(QPointF(bounds.left(), bounds.top() + radius));
114 path.quadTo(bounds.left(), bounds.top(), bounds.left() + radius, bounds.top());
115 path.lineTo(bounds.right() - radius, bounds.top());
116 path.quadTo(bounds.right(), bounds.top(), bounds.right(), bounds.top() + radius);
117 path.lineTo(bounds.right(), bounds.bottom() - radius);
118 path.quadTo(bounds.right(), bounds.bottom(), bounds.right() - radius, bounds.bottom());
119 path.lineTo(bounds.left() + radius, bounds.bottom());
120 path.quadTo(bounds.left(), bounds.bottom(), bounds.left(), bounds.bottom() - radius);
121 path.closeSubpath();
122
123 painter.setRenderHint(QPainter::Antialiasing);
124 painter.fillPath(path, blendedBrush);
125 painter.restore();
126 }
127
128 void DolphinController::triggerItem(const KFileItem& item)
129 {
130 emit itemTriggered(item);
131 }
132
133 void DolphinController::emitItemEntered(const KFileItem& item)
134 {
135 emit itemEntered(item);
136 }
137
138 void DolphinController::emitViewportEntered()
139 {
140 emit viewportEntered();
141 }
142
143 #include "dolphincontroller.moc"