X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/96d892bc47c652676f380193a3bc298c3a62c2ea..093efca22dfd247f06e2a669ad968300e71ef08d:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 2eca0860c..39783c9a9 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -52,11 +52,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr setDragDropMode(QAbstractItemView::DragDrop); setDropIndicatorShown(false); setAlternatingRowColors(true); - // TODO: enable ScrollPerPixel again as soon as a Qt-patch - // is supplied which fixes a possible crash - // (see http://lists.kde.org/?l=kde-core-devel&m=119077433611662&w=2) - //setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); - //setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); + setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setMouseTracking(true); viewport()->setAttribute(Qt::WA_Hover); @@ -297,6 +294,39 @@ void DolphinDetailsView::keyPressEvent(QKeyEvent* event) } } +void DolphinDetailsView::resizeEvent(QResizeEvent* event) +{ + QTreeView::resizeEvent(event); + + // assure that the width of the name-column does not get too small + const int minWidth = 120; + QHeaderView* headerView = header(); + bool useFixedWidth = (headerView->sectionSize(KDirModel::Name) <= minWidth) + && (headerView->resizeMode(0) != QHeaderView::Fixed); + if (useFixedWidth) { + // the current width of the name-column is too small, hence + // use a fixed size + headerView->setResizeMode(QHeaderView::Fixed); + headerView->setResizeMode(0, QHeaderView::Fixed); + headerView->resizeSection(KDirModel::Name, minWidth); + } else if (headerView->resizeMode(0) != QHeaderView::Stretch) { + // check whether there is enough available viewport width + // to automatically resize the columns + const int availableWidth = viewport()->width(); + + int headerWidth = 0; + const int count = headerView->count(); + for (int i = 0; i < count; ++i) { + headerWidth += headerView->sectionSize(i); + } + + if (headerWidth < availableWidth) { + headerView->setResizeMode(QHeaderView::ResizeToContents); + headerView->setResizeMode(0, QHeaderView::Stretch); + } + } +} + void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting) { QHeaderView* headerView = header(); @@ -368,6 +398,16 @@ void DolphinDetailsView::zoomOut() } } +void DolphinDetailsView::slotItemActivated(const QModelIndex& index) +{ + if (index.isValid() && (index.column() == KDirModel::Name)) { + m_controller->triggerItem(index); + } else { + clearSelection(); + m_controller->emitItemEntered(index); + } +} + bool DolphinDetailsView::isZoomInPossible() const { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); @@ -422,14 +462,4 @@ static bool isValidNameIndex(const QModelIndex& index) return index.isValid() && (index.column() == KDirModel::Name); } -void DolphinDetailsView::slotItemActivated(const QModelIndex& index) -{ - if (!isValidNameIndex(index)) { - clearSelection(); - m_controller->emitItemEntered(index); - } else { - m_controller->triggerItem(index); - } -} - #include "dolphindetailsview.moc"