]>
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"
26 #include <kdirmodel.h>
27 #include <kfileitem.h>
29 #include <QAbstractProxyModel>
31 DolphinIconsView::DolphinIconsView(DolphinView
* parent
) :
35 setResizeMode(QListView::Adjust
);
38 DolphinIconsView::~DolphinIconsView()
42 QStyleOptionViewItem
DolphinIconsView::viewOptions() const
44 return QListView::viewOptions();
46 // TODO: the view options should been read from the settings;
47 // the following code is just for testing...
48 //QStyleOptionViewItem options = QListView::viewOptions();
49 //options.decorationAlignment = Qt::AlignRight;
50 //options.decorationPosition = QStyleOptionViewItem::Right;
51 //options.decorationSize = QSize(100, 100);
52 //options.showDecorationSelected = true;
53 //options.state = QStyle::State_MouseOver;
57 void DolphinIconsView::contextMenuEvent(QContextMenuEvent
* event
)
59 QListView::contextMenuEvent(event
);
63 const QModelIndex index
= indexAt(event
->pos());
64 if (index
.isValid()) {
65 item
= m_dolphinView
->fileItem(index
);
68 m_dolphinView
->openContextMenu(item
, event
->globalPos());
71 void DolphinIconsView::mouseReleaseEvent(QMouseEvent
* event
)
73 QListView::mouseReleaseEvent(event
);
74 m_dolphinView
->declareViewActive();
77 void DolphinIconsView::dragEnterEvent(QDragEnterEvent
* event
)
79 if (event
->mimeData()->hasUrls()) {
80 event
->acceptProposedAction();
84 void DolphinIconsView::dropEvent(QDropEvent
* event
)
86 KFileItem
* directory
= 0;
87 bool dropIntoDirectory
= false;
88 const QModelIndex index
= indexAt(event
->pos());
89 if (index
.isValid()) {
90 KFileItem
* item
= m_dolphinView
->fileItem(index
);
92 dropIntoDirectory
= item
->isDir();
93 if (dropIntoDirectory
) {
98 const KUrl::List urls
= KUrl::List::fromMimeData(event
->mimeData());
99 if (urls
.isEmpty() || (event
->source() == this) && !dropIntoDirectory
) {
100 QListView::dropEvent(event
);
103 event
->acceptProposedAction();
104 const KUrl
& destination
= (directory
== 0) ? m_dolphinView
->url() :
106 m_dolphinView
->mainWindow()->dropUrls(urls
, destination
);
110 #include "dolphiniconsview.moc"