X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e46003aca365ca66ce7c7cccd47fb52d1da2fb91..fc9a6701da13b1d4527b36f19860b34762cd4b3c:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 3fd1e9468..68b288b0b 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -44,6 +44,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) : QTreeView(parent), m_controller(controller), + m_font(), + m_decorationSize(), m_clearAdditionalInfo(false), m_dragging(false), m_showElasticBand(false), @@ -60,6 +62,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr setDragDropMode(QAbstractItemView::DragDrop); setDropIndicatorShown(false); setAlternatingRowColors(true); + setItemsExpandable(false); setMouseTracking(true); viewport()->setAttribute(Qt::WA_Hover); @@ -106,13 +109,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); Q_ASSERT(settings != 0); - m_viewOptions = QTreeView::viewOptions(); - - QFont font(settings->fontFamily(), settings->fontSize()); - font.setItalic(settings->italicFont()); - font.setBold(settings->boldFont()); - m_viewOptions.font = font; - m_viewOptions.showDecorationSelected = true; + m_font = QFont(settings->fontFamily(), settings->fontSize()); // TODO: Remove this check when 4.3.2 is released and KDE requires it... this // check avoids a division by zero happening on versions before 4.3.1. @@ -136,7 +133,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(); @@ -162,7 +159,11 @@ bool DolphinDetailsView::event(QEvent* event) QStyleOptionViewItem DolphinDetailsView::viewOptions() const { - return m_viewOptions; + QStyleOptionViewItem viewOptions = QTreeView::viewOptions(); + viewOptions.font = m_font; + viewOptions.showDecorationSelected = true; + viewOptions.decorationSize = m_decorationSize; + return viewOptions; } void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event) @@ -251,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 @@ -299,7 +301,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); + const QBrush& brush = viewOptions().palette.brush(QPalette::Normal, QPalette::Highlight); DragAndDropHelper::drawHoverIndication(viewport(), m_dropRect, brush); } } @@ -321,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) @@ -506,7 +516,7 @@ void DolphinDetailsView::updateDecorationSize() { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); const int iconSize = settings->iconSize(); - m_viewOptions.decorationSize = QSize(iconSize, iconSize); + m_decorationSize = QSize(iconSize, iconSize); m_controller->setZoomInPossible(isZoomInPossible()); m_controller->setZoomOutPossible(isZoomOutPossible());