]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dolphiniconsview.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 "dolphiniconsview.h"
22 #include "dolphincontroller.h"
23 #include "dolphinsettings.h"
25 #include "dolphin_iconsmodesettings.h"
28 #include <kdirmodel.h>
29 #include <kfileitem.h>
31 #include <QAbstractProxyModel>
33 DolphinIconsView::DolphinIconsView(QWidget
* parent
, DolphinController
* controller
) :
35 m_controller(controller
)
37 assert(controller
!= 0);
38 setResizeMode(QListView::Adjust
);
40 connect(this, SIGNAL(clicked(const QModelIndex
&)),
41 controller
, SLOT(triggerItem(const QModelIndex
&)));
43 // apply the icons mode settings to the widget
44 const IconsModeSettings
* settings
= DolphinSettings::instance().iconsModeSettings();
45 assert(settings
!= 0);
47 if (settings
->arrangement() == QListView::TopToBottom
) {
48 setViewMode(QListView::IconMode
);
51 setViewMode(QListView::ListMode
);
54 setGridSize(QSize(settings
->gridWidth(), settings
->gridHeight()));
55 setSpacing(settings
->gridSpacing());
57 m_viewOptions
= QListView::viewOptions();
58 m_viewOptions
.font
= QFont(settings
->fontFamily(), settings
->fontSize());
59 const int iconSize
= settings
->iconSize();
60 m_viewOptions
.decorationSize
= QSize(iconSize
, iconSize
);
63 DolphinIconsView::~DolphinIconsView()
67 QStyleOptionViewItem
DolphinIconsView::viewOptions() const
72 void DolphinIconsView::contextMenuEvent(QContextMenuEvent
* event
)
74 QListView::contextMenuEvent(event
);
75 m_controller
->triggerContextMenuRequest(event
->pos());
78 void DolphinIconsView::mouseReleaseEvent(QMouseEvent
* event
)
80 QListView::mouseReleaseEvent(event
);
81 m_controller
->triggerActivation();
84 void DolphinIconsView::dragEnterEvent(QDragEnterEvent
* event
)
86 if (event
->mimeData()->hasUrls()) {
87 event
->acceptProposedAction();
91 void DolphinIconsView::dropEvent(QDropEvent
* event
)
93 const KUrl::List urls
= KUrl::List::fromMimeData(event
->mimeData());
94 if (urls
.isEmpty() || (event
->source() == this)) {
95 QListView::dropEvent(event
);
98 event
->acceptProposedAction();
99 m_controller
->indicateDroppedUrls(urls
, event
->pos());
103 #include "dolphiniconsview.moc"