// the blank portion of the name column counts as empty space
const QModelIndex index = QTreeView::indexAt(point);
const bool isAboveEmptySpace = !m_useDefaultIndexAt &&
- (index.column() == KDirModel::Name) && !nameColumnRect(index).contains(point);
+ (index.column() == KDirModel::Name) && !visualRect(index).contains(point);
return isAboveEmptySpace ? QModelIndex() : index;
}
+QRect DolphinDetailsView::visualRect(const QModelIndex& index) const
+{
+ QRect rect = QTreeView::visualRect(index);
+ const KFileItem item = m_controller->itemForIndex(index);
+ if (!item.isNull()) {
+ const int width = DolphinFileItemDelegate::nameColumnWidth(item.text(), viewOptions());
+ rect.setWidth(width);
+ }
+
+ return rect;
+}
+
void DolphinDetailsView::setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command)
{
// We must override setSelection() as Qt calls it internally and when this happens
QModelIndex toggleIndexRangeBegin = QModelIndex();
do {
- QRect currIndexRect = nameColumnRect(currIndex);
+ QRect currIndexRect = visualRect(currIndex);
// Update some optimization info as we go.
const int cr = currIndexRect.right();
headerView->resizeSection(KDirModel::Name, columnWidth[KDirModel::Name]);
}
-QRect DolphinDetailsView::nameColumnRect(const QModelIndex& index) const
-{
- QRect rect = visualRect(index);
- const KFileItem item = m_controller->itemForIndex(index);
- if (!item.isNull()) {
- const int width = DolphinFileItemDelegate::nameColumnWidth(item.text(), viewOptions());
- rect.setWidth(width);
- }
-
- return rect;
-}
-
bool DolphinDetailsView::isAboveExpandingToggle(const QPoint& pos) const
{
// QTreeView offers no public API to get the information whether an index has an
if (itemsExpandable()) {
const QModelIndex index = QTreeView::indexAt(pos);
if (index.isValid() && (index.column() == KDirModel::Name)) {
- QRect rect = nameColumnRect(index);
+ QRect rect = visualRect(index);
const int toggleSize = rect.height();
if (isRightToLeft()) {
rect.moveRight(rect.right());
virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
virtual bool eventFilter(QObject* watched, QEvent* event);
virtual QModelIndex indexAt (const QPoint& point) const;
+ virtual QRect visualRect(const QModelIndex& index) const;
virtual void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command);
virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
*/
void resizeColumns();
- QRect nameColumnRect(const QModelIndex& index) const;
-
/**
* Returns true, if \a pos is within the expanding toggle of a tree.
*/