]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindetailsview.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 "dolphindetailsview.h"
22 #include "dolphinmainwindow.h"
23 #include "dolphinview.h"
25 #include <QHeaderView>
27 DolphinDetailsView::DolphinDetailsView(DolphinView
* parent
) :
32 setRootIsDecorated(false);
33 setSortingEnabled(true);
34 setUniformRowHeights(true);
37 DolphinDetailsView::~DolphinDetailsView()
41 bool DolphinDetailsView::event(QEvent
* event
)
43 if (event
->type() == QEvent::Polish
) {
44 // Assure that by respecting the available width that:
45 // - the 'Name' column is stretched as large as possible
46 // - the remaining columns are as small as possible
47 QHeaderView
* headerView
= header();
48 headerView
->setStretchLastSection(false);
49 headerView
->setResizeMode(QHeaderView::ResizeToContents
);
50 headerView
->setResizeMode(0, QHeaderView::Stretch
);
53 return QTreeView::event(event
);
55 QStyleOptionViewItem
DolphinDetailsView::viewOptions() const
57 return QTreeView::viewOptions();
59 // TODO: the view options should been read from the settings;
60 // the following code is just for testing...
61 //QStyleOptionViewItem options = QTreeView::viewOptions();
62 //options.decorationAlignment = Qt::AlignRight;
63 //options.decorationPosition = QStyleOptionViewItem::Right;
64 //options.decorationSize = QSize(100, 100);
65 //options.showDecorationSelected = true;
66 //options.state = QStyle::State_MouseOver;
70 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent
* event
)
72 QTreeView::contextMenuEvent(event
);
76 const QModelIndex index
= indexAt(event
->pos());
77 if (index
.isValid()) {
78 item
= m_parentView
->fileItem(index
);
81 m_parentView
->openContextMenu(item
, event
->globalPos());
84 void DolphinDetailsView::mouseReleaseEvent(QMouseEvent
* event
)
86 QTreeView::mouseReleaseEvent(event
);
87 m_parentView
->declareViewActive();
90 void DolphinDetailsView::dragEnterEvent(QDragEnterEvent
* event
)
92 if (event
->mimeData()->hasUrls()) {
93 event
->acceptProposedAction();
97 void DolphinDetailsView::dropEvent(QDropEvent
* event
)
99 const KUrl::List urls
= KUrl::List::fromMimeData(event
->mimeData());
100 if (!urls
.isEmpty()) {
101 event
->acceptProposedAction();
103 // TODO: handle dropping above a directory
105 const KUrl
& destination
= m_parentView
->url();
106 m_parentView
->mainWindow()->dropUrls(urls
, destination
);
110 #include "dolphindetailsview.moc"