X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/85aec92f819eae5a6189bd3ec25cff44dce3ae19..d2fbbd44b422cc64ad184886670ca22df9dced5b:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index f4b8cd162..1b651456a 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -55,6 +55,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr m_ignoreScrollTo(false), m_controller(controller), m_selectionManager(0), + m_autoScroller(0), m_font(), m_decorationSize(), m_band() @@ -76,7 +77,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr setEditTriggers(QAbstractItemView::NoEditTriggers); setMouseTracking(true); - new DolphinViewAutoScroller(this); + m_autoScroller = new DolphinViewAutoScroller(this); const ViewProperties props(controller->url()); setSortIndicatorSection(props.sorting()); @@ -424,6 +425,9 @@ void DolphinDetailsView::wheelEvent(QWheelEvent* event) void DolphinDetailsView::currentChanged(const QModelIndex& current, const QModelIndex& previous) { QTreeView::currentChanged(current, previous); + if (current.isValid() && !m_autoScroller->isActive()) { + scrollTo(current); + } // Stay consistent with QListView: When changing the current index by key presses, // also change the selection. @@ -907,9 +911,26 @@ void DolphinDetailsView::resizeColumns() // resize the name column in a way that the whole available width is used columnWidth[KDirModel::Name] = viewport()->width() - requiredWidth; - if (columnWidth[KDirModel::Name] < 120) { - columnWidth[KDirModel::Name] = 120; + + const int minNameWidth = 300; + if (columnWidth[KDirModel::Name] < minNameWidth) { + columnWidth[KDirModel::Name] = minNameWidth; + + // It might be possible that the name column width can be + // decreased without clipping any text. For performance + // reasons the exact necessary width for full visible names is + // only checked for up to 200 items: + const int rowCount = model()->rowCount(); + if (rowCount < 200) { + const int nameWidth = sizeHintForColumn(DolphinModel::Name); + if (nameWidth + requiredWidth <= viewport()->width()) { + columnWidth[KDirModel::Name] = viewport()->width() - requiredWidth; + } else if (nameWidth < minNameWidth) { + columnWidth[KDirModel::Name] = nameWidth; + } + } } + headerView->resizeSection(KDirModel::Name, columnWidth[KDirModel::Name]); }