]>
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(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()));
53 // apply the icons mode settings to the widget
54 //const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
55 //Q_ASSERT(settings != 0);
57 m_viewOptions
= QColumnView::viewOptions();
59 /*QFont font(settings->fontFamily(), settings->fontSize());
60 font.setItalic(settings->italicFont());
61 font.setBold(settings->boldFont());
62 m_viewOptions.font = font;
64 updateGridSize(controller->showPreview());
66 if (settings->arrangement() == QColumnView::TopToBottom) {
67 setFlow(QColumnView::LeftToRight);
68 m_viewOptions.decorationPosition = QStyleOptionViewItem::Top;
71 setFlow(QColumnView::TopToBottom);
72 m_viewOptions.decorationPosition = QStyleOptionViewItem::Left;
76 DolphinColumnView::~DolphinColumnView()
80 QStyleOptionViewItem
DolphinColumnView::viewOptions() const
85 void DolphinColumnView::contextMenuEvent(QContextMenuEvent
* event
)
87 QColumnView::contextMenuEvent(event
);
88 m_controller
->triggerContextMenuRequest(event
->pos());
91 void DolphinColumnView::mouseReleaseEvent(QMouseEvent
* event
)
93 QColumnView::mouseReleaseEvent(event
);
94 m_controller
->triggerActivation();
97 void DolphinColumnView::dragEnterEvent(QDragEnterEvent
* event
)
99 if (event
->mimeData()->hasUrls()) {
100 event
->acceptProposedAction();
104 void DolphinColumnView::dropEvent(QDropEvent
* event
)
106 const KUrl::List urls
= KUrl::List::fromMimeData(event
->mimeData());
107 if (!urls
.isEmpty()) {
108 m_controller
->indicateDroppedUrls(urls
,
109 indexAt(event
->pos()),
111 event
->acceptProposedAction();
113 QColumnView::dropEvent(event
);
116 void DolphinColumnView::zoomIn()
120 void DolphinColumnView::zoomOut()
124 bool DolphinColumnView::isZoomInPossible() const
129 bool DolphinColumnView::isZoomOutPossible() const
134 #include "dolphincolumnview.moc"