X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/8ee3363dbcc4d2e9e9f89b2737d26fcea55653a7..70e938b23ef3238bc69ad01ac85cd9262229ea82:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 9dd91b308..f3d55a8c3 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -24,6 +24,7 @@ #include "dolphincontroller.h" #include "dolphinsettings.h" #include "dolphinsortfilterproxymodel.h" +#include "draganddrophelper.h" #include "viewproperties.h" #include "dolphin_detailsmodesettings.h" @@ -59,6 +60,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr setDragDropMode(QAbstractItemView::DragDrop); setDropIndicatorShown(false); setAlternatingRowColors(true); + setItemsExpandable(false); setMouseTracking(true); viewport()->setAttribute(Qt::WA_Hover); @@ -135,7 +137,7 @@ bool DolphinDetailsView::event(QEvent* event) { if (event->type() == QEvent::Polish) { QHeaderView* headerView = header(); - headerView->setResizeMode(QHeaderView::Fixed); + headerView->setResizeMode(QHeaderView::Interactive); headerView->setMovable(false); updateColumnVisibility(); @@ -167,9 +169,7 @@ QStyleOptionViewItem DolphinDetailsView::viewOptions() const void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event) { QTreeView::contextMenuEvent(event); - if (selectionModel()->hasSelection()) { - m_controller->triggerContextMenuRequest(event->pos()); - } + m_controller->triggerContextMenuRequest(event->pos()); } void DolphinDetailsView::mousePressEvent(QMouseEvent* event) @@ -214,6 +214,11 @@ void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event) } } +void DolphinDetailsView::startDrag(Qt::DropActions supportedActions) +{ + DragAndDropHelper::startDrag(this, supportedActions); +} + void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event) { if (event->mimeData()->hasUrls()) { @@ -247,7 +252,8 @@ void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event) m_dragging = false; } else { m_dragging = true; - if (itemForIndex(index).isDir()) { + const KFileItem item = itemForIndex(index); + if (!item.isNull() && item.isDir()) { m_dropRect = visualRect(index); } else { m_dropRect.setSize(QSize()); // set as invalid @@ -296,7 +302,7 @@ void DolphinDetailsView::paintEvent(QPaintEvent* event) // TODO: remove this code when the issue #160611 is solved in Qt 4.4 if (m_dragging) { const QBrush& brush = m_viewOptions.palette.brush(QPalette::Normal, QPalette::Highlight); - DolphinController::drawHoverIndication(viewport(), m_dropRect, brush); + DragAndDropHelper::drawHoverIndication(viewport(), m_dropRect, brush); } } @@ -317,7 +323,15 @@ void DolphinDetailsView::keyPressEvent(QKeyEvent* event) void DolphinDetailsView::resizeEvent(QResizeEvent* event) { QTreeView::resizeEvent(event); - resizeColumns(); + + // TODO: There seems to be no easy way to find out whether the resize event + // has been triggered because of resizing the window or by adjusting the column-width + // by a left mouse-click (the columns should only be resized automatically when the window + // size is adjusted). The following workaround works well, but it should be + // considered solving this in a more transparent way. + if (!(QApplication::mouseButtons() & Qt::LeftButton)) { + resizeColumns(); + } } void DolphinDetailsView::closeEvent(QCloseEvent* event)