]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnview.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
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. *
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. *
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 ***************************************************************************/
20 #include "dolphincolumnview.h"
22 #include "dolphincontroller.h"
23 #include "dolphinsettings.h"
25 //#include "dolphin_iconsmodesettings.h"
27 #include <kdirmodel.h>
28 #include <kfileitem.h>
29 #include <kfileitemdelegate.h>
31 #include <QAbstractProxyModel>
34 DolphinColumnView::DolphinColumnView(QWidget
* parent
, DolphinController
* controller
) :
36 m_controller(controller
)
38 Q_ASSERT(controller
!= 0);
40 viewport()->setAttribute(Qt::WA_Hover
);
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(zoomIn()),
47 this, SLOT(zoomIn()));
48 connect(controller
, SIGNAL(zoomOut()),
49 this, SLOT(zoomOut()));
51 // apply the icons mode settings to the widget
52 //const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
53 //Q_ASSERT(settings != 0);
55 m_viewOptions
= QColumnView::viewOptions();
57 /*QFont font(settings->fontFamily(), settings->fontSize());
58 font.setItalic(settings->italicFont());
59 font.setBold(settings->boldFont());
60 m_viewOptions.font = font;
62 updateGridSize(controller->showPreview());
64 if (settings->arrangement() == QColumnView::TopToBottom) {
65 setFlow(QColumnView::LeftToRight);
66 m_viewOptions.decorationPosition = QStyleOptionViewItem::Top;
69 setFlow(QColumnView::TopToBottom);
70 m_viewOptions.decorationPosition = QStyleOptionViewItem::Left;
74 DolphinColumnView::~DolphinColumnView()
78 QStyleOptionViewItem
DolphinColumnView::viewOptions() const
83 void DolphinColumnView::contextMenuEvent(QContextMenuEvent
* event
)
85 QColumnView::contextMenuEvent(event
);
86 m_controller
->triggerContextMenuRequest(event
->pos());
89 void DolphinColumnView::mouseReleaseEvent(QMouseEvent
* event
)
91 QColumnView::mouseReleaseEvent(event
);
92 m_controller
->triggerActivation();
95 void DolphinColumnView::dragEnterEvent(QDragEnterEvent
* event
)
97 if (event
->mimeData()->hasUrls()) {
98 event
->acceptProposedAction();
102 void DolphinColumnView::dropEvent(QDropEvent
* event
)
104 const KUrl::List urls
= KUrl::List::fromMimeData(event
->mimeData());
105 if (!urls
.isEmpty()) {
106 m_controller
->indicateDroppedUrls(urls
,
107 indexAt(event
->pos()),
109 event
->acceptProposedAction();
111 QColumnView::dropEvent(event
);
114 void DolphinColumnView::zoomIn()
118 void DolphinColumnView::zoomOut()
122 bool DolphinColumnView::isZoomInPossible() const
127 bool DolphinColumnView::isZoomOutPossible() const
132 #include "dolphincolumnview.moc"