]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dolphiniconsview.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "dolphiniconsview.h"
22 #include "dolphinmainwindow.h"
23 #include "dolphinview.h"
25 #include <kdirmodel.h>
26 #include <kfileitem.h>
28 #include <QAbstractProxyModel>
30 DolphinIconsView::DolphinIconsView(DolphinView
* parent
) :
34 setResizeMode(QListView::Adjust
);
37 DolphinIconsView::~DolphinIconsView()
41 QStyleOptionViewItem
DolphinIconsView::viewOptions() const
43 return QListView::viewOptions();
45 // TODO: the view options should been read from the settings;
46 // the following code is just for testing...
47 //QStyleOptionViewItem options = QListView::viewOptions();
48 //options.decorationAlignment = Qt::AlignRight;
49 //options.decorationPosition = QStyleOptionViewItem::Right;
50 //options.decorationSize = QSize(100, 100);
51 //options.showDecorationSelected = true;
52 //options.state = QStyle::State_MouseOver;
56 void DolphinIconsView::contextMenuEvent(QContextMenuEvent
* event
)
58 QListView::contextMenuEvent(event
);
62 const QModelIndex index
= indexAt(event
->pos());
63 if (index
.isValid()) {
64 const QAbstractProxyModel
* proxyModel
= static_cast<const QAbstractProxyModel
*>(model());
65 const KDirModel
* dirModel
= static_cast<const KDirModel
*>(proxyModel
->sourceModel());
66 item
= dirModel
->itemForIndex(index
);
69 m_parentView
->openContextMenu(item
, event
->globalPos());
72 void DolphinIconsView::mouseReleaseEvent(QMouseEvent
* event
)
74 QListView::mouseReleaseEvent(event
);
75 m_parentView
->declareViewActive();
78 void DolphinIconsView::dragEnterEvent(QDragEnterEvent
* event
)
80 if (event
->mimeData()->hasUrls()) {
81 event
->acceptProposedAction();
85 void DolphinIconsView::dropEvent(QDropEvent
* event
)
87 const KUrl::List urls
= KUrl::List::fromMimeData(event
->mimeData());
88 if (!urls
.isEmpty()) {
89 event
->acceptProposedAction();
91 // TODO: handle dropping above a directory
93 const KUrl
& destination
= m_parentView
->url();
94 m_parentView
->mainWindow()->dropUrls(urls
, destination
);
98 #include "dolphiniconsview.moc"