X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e46003aca365ca66ce7c7cccd47fb52d1da2fb91..70e938b23ef3238bc69ad01ac85cd9262229ea82:/src/dolphiniconsview.cpp diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index c04a70fab..2bb21cb79 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -142,8 +142,12 @@ QRect DolphinIconsView::visualRect(const QModelIndex& index) const itemRect.setHeight(maxHeight); } - if (leftToRightFlow && bypassVisualRectIssue()) { - // TODO: check inline comment inside bypassVisualRectIssue() for details + KCategorizedSortFilterProxyModel* proxyModel = dynamic_cast(model()); + if (leftToRightFlow && !proxyModel->isCategorizedModel()) { + // TODO: QListView::visualRect() calculates a wrong position of the items under + // certain circumstances (e. g. if the text is too long). This issue is bypassed + // by the following code (I'll try create a patch for Qt but as Dolphin must also work with + // Qt 4.3.0 this workaround must get applied at least for KDE 4.0). const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); const int margin = settings->gridSpacing(); const int gridWidth = gridSize().width(); @@ -180,12 +184,10 @@ void DolphinIconsView::mousePressEvent(QMouseEvent* event) void DolphinIconsView::startDrag(Qt::DropActions supportedActions) { - if (bypassVisualRectIssue()) { - // TODO: check inline comment inside bypassVisualRectIssue() for details - DragAndDropHelper::startDrag(this, supportedActions); - } else { - KCategorizedView::startDrag(supportedActions); - } + // TODO: invoking KCategorizedView::startDrag() should not be necessary, we'll + // fix this in KDE 4.1 + KCategorizedView::startDrag(supportedActions); + DragAndDropHelper::startDrag(this, supportedActions); } void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event) @@ -198,12 +200,7 @@ void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event) void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event) { - if (bypassVisualRectIssue()) { - // TODO: check inline comment inside bypassVisualRectIssue() for details - QAbstractItemView::dragLeaveEvent(event); - } else { - KCategorizedView::dragLeaveEvent(event); - } + KCategorizedView::dragLeaveEvent(event); // TODO: remove this code when the issue #160611 is solved in Qt 4.4 m_dragging = false; @@ -212,20 +209,18 @@ void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event) void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event) { - if (bypassVisualRectIssue()) { - // TODO: check inline comment inside bypassVisualRectIssue() for details - QAbstractItemView::dragMoveEvent(event); - } else { - KCategorizedView::dragMoveEvent(event); - } + KCategorizedView::dragMoveEvent(event); // TODO: remove this code when the issue #160611 is solved in Qt 4.4 const QModelIndex index = indexAt(event->pos()); setDirtyRegion(m_dropRect); - if (itemForIndex(index).isDir()) { - m_dropRect = visualRect(index); - } else { - m_dropRect.setSize(QSize()); // set as invalid + + m_dropRect.setSize(QSize()); // set as invalid + if (index.isValid()) { + const KFileItem item = itemForIndex(index); + if (!item.isNull() && item.isDir()) { + m_dropRect = visualRect(index); + } } setDirtyRegion(m_dropRect); } @@ -244,12 +239,7 @@ void DolphinIconsView::dropEvent(QDropEvent* event) } } - if (bypassVisualRectIssue()) { - // TODO: check inline comment inside bypassVisualRectIssue() for details - QAbstractItemView::dropEvent(event); - } else { - KCategorizedView::dropEvent(event); - } + KCategorizedView::dropEvent(event); m_dragging = false; } @@ -292,12 +282,16 @@ void DolphinIconsView::slotEntered(const QModelIndex& index) void DolphinIconsView::slotShowPreviewChanged() { const DolphinView* view = m_controller->dolphinView(); - const int infoCount = view->additionalInfo().count(); - updateGridSize(view->showPreview(), infoCount); + updateGridSize(view->showPreview(), additionalInfoCount()); } void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info) { + const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); + if (!settings->showAdditionalInfo()) { + return; + } + const bool showPreview = m_controller->dolphinView()->showPreview(); updateGridSize(showPreview, info.count()); } @@ -328,8 +322,7 @@ void DolphinIconsView::zoomIn() settings->setItemWidth(settings->itemWidth() + diff); settings->setItemHeight(settings->itemHeight() + diff); - const int infoCount = m_controller->dolphinView()->additionalInfo().count(); - updateGridSize(showPreview, infoCount); + updateGridSize(showPreview, additionalInfoCount()); } } @@ -360,8 +353,7 @@ void DolphinIconsView::zoomOut() settings->setItemWidth(settings->itemWidth() - diff); settings->setItemHeight(settings->itemHeight() - diff); - const int infoCount = m_controller->dolphinView()->additionalInfo().count(); - updateGridSize(showPreview, infoCount); + updateGridSize(showPreview, additionalInfoCount()); } } @@ -457,21 +449,11 @@ KFileItem DolphinIconsView::itemForIndex(const QModelIndex& index) const return dirModel->itemForIndex(dirIndex); } -bool DolphinIconsView::bypassVisualRectIssue() const +int DolphinIconsView::additionalInfoCount() const { - // TODO: QListView::visualRect() calculates a wrong position of the items under - // certain circumstances (e. g. if the text is too long). This issue is bypassed - // inside DolphinIconsView::visualRect(), but internally QListView does not use - // visualRect() but the (non-virtual) QListView::rectForIndex(). This leads - // to problems in combination with drag & drop operations: visual fragments get - // created. To bypass the drag & drop issue the calls for QListView::dragMoveEvent(), - // QListView::dropEvent() are replaced by the QAbstractItemView counterparts and - // QAbstractItemView::startDrag() has been reimplemented. - // - // I'll try create a patch for Qt but as Dolphin must also work with - // Qt 4.3.0 this workaround must get applied at least for KDE 4.0. - KCategorizedSortFilterProxyModel* proxyModel = dynamic_cast(model()); - return !proxyModel->isCategorizedModel(); + const DolphinView* view = m_controller->dolphinView(); + const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); + return settings->showAdditionalInfo() ? view->additionalInfo().count() : 0; } #include "dolphiniconsview.moc"