]>
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
);
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(),
72 void DolphinIconsView::mouseReleaseEvent(QMouseEvent
* event
)
74 QListView::mouseReleaseEvent(event
);
75 m_controller
->triggerActivation();
78 void DolphinIconsView::dragEnterEvent(QDragEnterEvent
* event
)
80 if (event
->mimeData()->hasUrls()) {
81 event
->acceptProposedAction();
85 void DolphinIconsView::dropEvent(QDropEvent
* event
)
87 QListView::dropEvent(event
);
88 // TODO: temporary deactivated until DolphinController will support this
90 /* KFileItem* directory = 0;
91 bool dropIntoDirectory = false;
92 const QModelIndex index = indexAt(event->pos());
93 if (index.isValid()) {
94 KFileItem* item = m_dolphinView->fileItem(index);
96 dropIntoDirectory = item->isDir();
97 if (dropIntoDirectory) {
102 const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
103 if (urls.isEmpty() || (event->source() == this) && !dropIntoDirectory) {
104 QListView::dropEvent(event);
107 event->acceptProposedAction();
108 const KUrl& destination = (directory == 0) ? m_dolphinView->url() :
110 m_dolphinView->mainWindow()->dropUrls(urls, destination);
114 #include "dolphiniconsview.moc"