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