X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/362817d1834f2ada3ea4552a25fa39bbbb540f8c..b358e9928049575cf3118f3950caf52bfa003404:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 379cd9f90..873074653 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -135,8 +135,11 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : KItemListController* controller = m_container->controller(); controller->setSelectionBehavior(KItemListController::MultiSelection); - connect(controller, SIGNAL(itemActivated(int)), - this, SLOT(slotItemActivated(int))); + if (GeneralSettings::autoExpandFolders()) { + controller->setAutoActivationDelay(750); + } + connect(controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int))); + connect(controller, SIGNAL(itemsActivated(QSet)), this, SLOT(slotItemsActivated(QSet))); connect(controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int))); connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF))); connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF))); @@ -456,13 +459,12 @@ void DolphinView::refresh() void DolphinView::setNameFilter(const QString& nameFilter) { - Q_UNUSED(nameFilter); - //m_viewModeController->setNameFilter(nameFilter); + fileItemModel()->setNameFilter(nameFilter); } QString DolphinView::nameFilter() const { - return QString(); //m_viewModeController->nameFilter(); + return fileItemModel()->nameFilter(); } void DolphinView::calculateItemCount(int& fileCount, @@ -692,22 +694,30 @@ void DolphinView::activate() void DolphinView::slotItemActivated(int index) { - Q_UNUSED(index); + const KFileItem item = fileItemModel()->fileItem(index); + if (!item.isNull()) { + emit itemActivated(item); + } +} - const KFileItemList items = selectedItems(); - if (items.isEmpty()) { - return; +void DolphinView::slotItemsActivated(const QSet& indexes) +{ + Q_ASSERT(indexes.count() >= 2); + + KFileItemList items; + + KFileItemModel* model = fileItemModel(); + QSetIterator it(indexes); + while (it.hasNext()) { + const int index = it.next(); + items.append(model->fileItem(index)); } - if (items.count() == 1) { - emit itemActivated(items.at(0)); // caught by DolphinViewContainer or DolphinPart - } else { - foreach (const KFileItem& item, items) { - if (item.isDir()) { - emit tabRequested(item.url()); - } else { - emit itemActivated(item); - } + foreach (const KFileItem& item, items) { + if (item.isDir()) { + emit tabRequested(item.url()); + } else { + emit itemActivated(item); } } } @@ -792,7 +802,7 @@ void DolphinView::slotItemHovered(int index) const KFileItem item = fileItemModel()->fileItem(index); if (GeneralSettings::showToolTips()) { - QRectF itemRect = m_container->controller()->view()->itemRect(index); + QRectF itemRect = m_container->controller()->view()->itemContextRect(index); const QPoint pos = m_container->mapToGlobal(itemRect.topLeft().toPoint()); itemRect.moveTo(pos); @@ -821,7 +831,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even event->buttons(), event->modifiers()); - DragAndDropHelper::dropUrls(destItem, url(), &dropEvent, this); + DragAndDropHelper::dropUrls(destItem, url(), &dropEvent); } void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous) @@ -940,6 +950,7 @@ void DolphinView::saveState(QDataStream& stream) const int currentIndex = m_container->controller()->selectionManager()->currentItem(); if (currentIndex != -1) { KFileItem item = fileItemModel()->fileItem(currentIndex); + Q_ASSERT(!item.isNull()); // If the current index is valid a item must exist KUrl currentItemUrl = item.url(); stream << currentItemUrl; } else { @@ -1115,9 +1126,23 @@ void DolphinView::applyViewProperties() m_container->beginTransaction(); const ViewProperties props(url()); + KFileItemModel* model = fileItemModel(); const Mode mode = props.viewMode(); if (m_mode != mode) { + // Prevent an animated transition of the position and size of the items when switching + // the view-mode by temporary clearing the model and updating it again after the view mode + // has been modified. + const bool restoreModel = (model->count() > 0); + if (restoreModel) { + const int currentItemIndex = m_container->controller()->selectionManager()->currentItem(); + if (currentItemIndex >= 0) { + m_currentItemUrl = model->fileItem(currentItemIndex).url(); + } + m_selectedUrls = selectedItems().urlList(); + model->clear(); + } + const Mode previousMode = m_mode; m_mode = mode; @@ -1138,6 +1163,10 @@ void DolphinView::applyViewProperties() if (m_container->zoomLevel() != oldZoomLevel) { emit zoomLevelChanged(m_container->zoomLevel(), oldZoomLevel); } + + if (restoreModel) { + loadDirectory(url()); + } } const bool hiddenFilesShown = props.hiddenFilesShown(); @@ -1147,8 +1176,6 @@ void DolphinView::applyViewProperties() emit hiddenFilesShownChanged(hiddenFilesShown); } - KFileItemModel* model = fileItemModel(); - const bool groupedSorting = props.groupedSorting(); if (groupedSorting != model->groupedSorting()) { model->setGroupedSorting(groupedSorting);