]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincontroller.cpp
fixed most regressions due to the previous column-view refactoring
[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::triggerContextMenuRequest(const QPoint& pos)
48 {
49 emit activated();
50 emit requestContextMenu(pos);
51 }
52
53 void DolphinController::triggerActivation()
54 {
55 emit activated();
56 }
57
58 void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
59 const KUrl& destPath,
60 const QModelIndex& destIndex,
61 QWidget* source)
62 {
63 emit urlsDropped(urls, destPath, destIndex, source);
64 }
65
66
67 void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
68 {
69 emit sortingChanged(sorting);
70 }
71
72 void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
73 {
74 emit sortOrderChanged(order);
75 }
76
77 void DolphinController::setShowHiddenFiles(bool show)
78 {
79 if (m_showHiddenFiles != show) {
80 m_showHiddenFiles = show;
81 emit showHiddenFilesChanged(show);
82 }
83 }
84
85 void DolphinController::setShowPreview(bool show)
86 {
87 if (m_showPreview != show) {
88 m_showPreview = show;
89 emit showPreviewChanged(show);
90 }
91 }
92
93 void DolphinController::setAdditionalInfoCount(int count)
94 {
95 if (m_additionalInfoCount != count) {
96 m_additionalInfoCount = count;
97 emit additionalInfoCountChanged(count);
98 }
99 }
100
101 void DolphinController::triggerZoomIn()
102 {
103 emit zoomIn();
104 }
105
106 void DolphinController::triggerZoomOut()
107 {
108 emit zoomOut();
109 }
110
111 void DolphinController::drawHoverIndication(QWidget* widget,
112 const QRect& bounds,
113 const QBrush& brush)
114 {
115 QPainter painter(widget);
116 painter.save();
117 QBrush blendedBrush(brush);
118 QColor color = blendedBrush.color();
119 color.setAlpha(64);
120 blendedBrush.setColor(color);
121
122 const int radius = 10;
123 QPainterPath path(QPointF(bounds.left(), bounds.top() + radius));
124 path.quadTo(bounds.left(), bounds.top(), bounds.left() + radius, bounds.top());
125 path.lineTo(bounds.right() - radius, bounds.top());
126 path.quadTo(bounds.right(), bounds.top(), bounds.right(), bounds.top() + radius);
127 path.lineTo(bounds.right(), bounds.bottom() - radius);
128 path.quadTo(bounds.right(), bounds.bottom(), bounds.right() - radius, bounds.bottom());
129 path.lineTo(bounds.left() + radius, bounds.bottom());
130 path.quadTo(bounds.left(), bounds.bottom(), bounds.left(), bounds.bottom() - radius);
131 path.closeSubpath();
132
133 painter.setRenderHint(QPainter::Antialiasing);
134 painter.fillPath(path, blendedBrush);
135 painter.restore();
136 }
137
138 void DolphinController::triggerItem(const KFileItem& item)
139 {
140 emit itemTriggered(item);
141 }
142
143 void DolphinController::emitItemEntered(const KFileItem& item)
144 {
145 emit itemEntered(item);
146 }
147
148 void DolphinController::emitViewportEntered()
149 {
150 emit viewportEntered();
151 }
152
153 #include "dolphincontroller.moc"