]>
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"
25 #include <kdirmodel.h>
26 #include <kfileitem.h>
28 #include <QAbstractProxyModel>
30 DolphinIconsView::DolphinIconsView(QWidget
* parent
, DolphinController
* controller
) :
32 m_controller(controller
)
34 assert(controller
!= 0);
36 setResizeMode(QListView::Adjust
);
38 // TODO: read out settings
39 setViewMode(QListView::IconMode
);
40 setGridSize(QSize(128, 96));
42 connect(this, SIGNAL(clicked(const QModelIndex
&)),
43 controller
, SLOT(triggerItem(const QModelIndex
&)));
46 DolphinIconsView::~DolphinIconsView()
50 QStyleOptionViewItem
DolphinIconsView::viewOptions() const
52 return QListView::viewOptions();
54 // TODO: the view options should been read from the settings;
55 // the following code is just for testing...
56 //QStyleOptionViewItem options = QListView::viewOptions();
57 //options.decorationAlignment = Qt::AlignRight;
58 //options.decorationPosition = QStyleOptionViewItem::Right;
59 //options.decorationSize = QSize(100, 100);
60 //options.showDecorationSelected = true;
61 //options.state = QStyle::State_MouseOver;
65 void DolphinIconsView::contextMenuEvent(QContextMenuEvent
* event
)
67 QListView::contextMenuEvent(event
);
68 m_controller
->triggerContextMenuRequest(event
->pos());
71 void DolphinIconsView::mouseReleaseEvent(QMouseEvent
* event
)
73 QListView::mouseReleaseEvent(event
);
74 m_controller
->triggerActivation();
77 void DolphinIconsView::dragEnterEvent(QDragEnterEvent
* event
)
79 if (event
->mimeData()->hasUrls()) {
80 event
->acceptProposedAction();
84 void DolphinIconsView::dropEvent(QDropEvent
* event
)
86 const KUrl::List urls
= KUrl::List::fromMimeData(event
->mimeData());
87 if (urls
.isEmpty() || (event
->source() == this)) {
88 QListView::dropEvent(event
);
91 event
->acceptProposedAction();
92 m_controller
->indicateDroppedUrls(urls
, event
->pos());
96 #include "dolphiniconsview.moc"