- // TODO: remove this code when the issue #160611 is solved in Qt 4.4
- QPainter painter(viewport());
- painter.save();
- QBrush brush(m_viewOptions.palette.brush(QPalette::Normal, QPalette::Highlight));
- QColor color = brush.color();
- color.setAlpha(64);
- brush.setColor(color);
- painter.fillRect(m_dropRect, brush);
- painter.restore();
+ const QBrush& brush = m_viewOptions.palette.brush(QPalette::Normal, QPalette::Highlight);
+ DolphinController::drawHoverIndication(viewport(), m_dropRect, brush);
+ }
+}
+
+void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
+{
+ QTreeView::keyPressEvent(event);
+
+ const QItemSelectionModel* selModel = selectionModel();
+ const QModelIndex currentIndex = selModel->currentIndex();
+ const bool triggerItem = currentIndex.isValid()
+ && (event->key() == Qt::Key_Return)
+ && (selModel->selectedIndexes().count() <= 1);
+ if (triggerItem) {
+ m_controller->triggerItem(currentIndex);
+ }
+}
+
+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);
+ }