]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnview.cpp
Initial version for a column view support (thanks a lot to Benjamin Meyer for QColumn...
[dolphin.git] / src / dolphincolumnview.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 "dolphincolumnview.h"
21
22 #include "dolphincontroller.h"
23 #include "dolphinsettings.h"
24
25 //#include "dolphin_iconsmodesettings.h"
26
27 #include <kdirmodel.h>
28 #include <kfileitem.h>
29 #include <kfileitemdelegate.h>
30
31 #include <QAbstractProxyModel>
32 #include <QPoint>
33
34 DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* controller) :
35 QColumnView(parent),
36 m_controller(controller)
37 {
38 Q_ASSERT(controller != 0);
39
40 viewport()->setAttribute(Qt::WA_Hover);
41
42 connect(this, SIGNAL(clicked(const QModelIndex&)),
43 controller, SLOT(triggerItem(const QModelIndex&)));
44 connect(this, SIGNAL(activated(const QModelIndex&)),
45 controller, SLOT(triggerItem(const QModelIndex&)));
46 connect(controller, SIGNAL(showPreviewChanged(bool)),
47 this, SLOT(updateGridSize(bool)));
48 connect(controller, SIGNAL(zoomIn()),
49 this, SLOT(zoomIn()));
50 connect(controller, SIGNAL(zoomOut()),
51 this, SLOT(zoomOut()));
52
53 // apply the icons mode settings to the widget
54 //const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
55 //Q_ASSERT(settings != 0);
56
57 m_viewOptions = QColumnView::viewOptions();
58
59 /*QFont font(settings->fontFamily(), settings->fontSize());
60 font.setItalic(settings->italicFont());
61 font.setBold(settings->boldFont());
62 m_viewOptions.font = font;
63
64 updateGridSize(controller->showPreview());
65
66 if (settings->arrangement() == QColumnView::TopToBottom) {
67 setFlow(QColumnView::LeftToRight);
68 m_viewOptions.decorationPosition = QStyleOptionViewItem::Top;
69 }
70 else {
71 setFlow(QColumnView::TopToBottom);
72 m_viewOptions.decorationPosition = QStyleOptionViewItem::Left;
73 }*/
74 }
75
76 DolphinColumnView::~DolphinColumnView()
77 {
78 }
79
80 QStyleOptionViewItem DolphinColumnView::viewOptions() const
81 {
82 return m_viewOptions;
83 }
84
85 void DolphinColumnView::contextMenuEvent(QContextMenuEvent* event)
86 {
87 QColumnView::contextMenuEvent(event);
88 m_controller->triggerContextMenuRequest(event->pos());
89 }
90
91 void DolphinColumnView::mouseReleaseEvent(QMouseEvent* event)
92 {
93 QColumnView::mouseReleaseEvent(event);
94 m_controller->triggerActivation();
95 }
96
97 void DolphinColumnView::dragEnterEvent(QDragEnterEvent* event)
98 {
99 if (event->mimeData()->hasUrls()) {
100 event->acceptProposedAction();
101 }
102 }
103
104 void DolphinColumnView::dropEvent(QDropEvent* event)
105 {
106 const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
107 if (!urls.isEmpty()) {
108 m_controller->indicateDroppedUrls(urls,
109 indexAt(event->pos()),
110 event->source());
111 event->acceptProposedAction();
112 }
113 QColumnView::dropEvent(event);
114 }
115
116 void DolphinColumnView::zoomIn()
117 {
118 }
119
120 void DolphinColumnView::zoomOut()
121 {
122 }
123
124 bool DolphinColumnView::isZoomInPossible() const
125 {
126 return false;
127 }
128
129 bool DolphinColumnView::isZoomOutPossible() const
130 {
131 return false;
132 }
133
134 #include "dolphincolumnview.moc"