X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/8bbddb3b6324dfa22d0a57805d387d19db9a3afe..f3537f5b5fb0fd107a2e299aaeca3524cf1dd792:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index c1d245301..1416bb6df 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -145,7 +145,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : controller->setSelectionBehavior(KItemListController::MultiSelection); connect(controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int))); - connect(controller, SIGNAL(itemsActivated(QSet)), this, SLOT(slotItemsActivated(QSet))); + connect(controller, SIGNAL(itemsActivated(KItemSet)), this, SLOT(slotItemsActivated(KItemSet))); 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))); @@ -154,6 +154,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int))); connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int))); connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*))); + connect(controller, SIGNAL(escapePressed()), this, SLOT(stopLoading())); connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*))); connect(m_model, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted())); @@ -183,8 +184,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal))); KItemListSelectionManager* selectionManager = controller->selectionManager(); - connect(selectionManager, SIGNAL(selectionChanged(QSet,QSet)), - this, SLOT(slotSelectionChanged(QSet,QSet))); + connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), + this, SLOT(slotSelectionChanged(KItemSet,KItemSet))); m_toolTipManager = new ToolTipManager(this); @@ -349,14 +350,9 @@ int DolphinView::itemsCount() const KFileItemList DolphinView::selectedItems() const { const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); - QList selectedIndexes = selectionManager->selectedItems().toList(); - - qSort(selectedIndexes); KFileItemList selectedItems; - QListIterator it(selectedIndexes); - while (it.hasNext()) { - const int index = it.next(); + foreach (int index, selectionManager->selectedItems()) { selectedItems.append(m_model->fileItem(index)); } return selectedItems; @@ -389,9 +385,9 @@ void DolphinView::selectItems(const QRegExp& pattern, bool enabled) for (int index = 0; index < m_model->count(); index++) { const KFileItem item = m_model->fileItem(index); if (pattern.exactMatch(item.text())) { - // An alternative approach would be to store the matching items in a QSet and + // An alternative approach would be to store the matching items in a KItemSet and // select them in one go after the loop, but we'd need a new function - // KItemListSelectionManager::setSelected(QSet, SelectionMode mode) + // KItemListSelectionManager::setSelected(KItemSet, SelectionMode mode) // for that. selectionManager->setSelected(index, 1, mode); } @@ -485,11 +481,6 @@ void DolphinView::reload() restoreState(restoreStream); } -void DolphinView::stopLoading() -{ - m_model->cancelDirectoryLoading(); -} - void DolphinView::readSettings() { const int oldZoomLevel = m_view->zoomLevel(); @@ -724,6 +715,11 @@ void DolphinView::pasteIntoFolder() } } +void DolphinView::stopLoading() +{ + m_model->cancelDirectoryLoading(); +} + bool DolphinView::eventFilter(QObject* watched, QEvent* event) { switch (event->type()) { @@ -802,7 +798,7 @@ void DolphinView::slotItemActivated(int index) } } -void DolphinView::slotItemsActivated(const QSet& indexes) +void DolphinView::slotItemsActivated(const KItemSet& indexes) { Q_ASSERT(indexes.count() >= 2); @@ -817,9 +813,7 @@ void DolphinView::slotItemsActivated(const QSet& indexes) KFileItemList items; items.reserve(indexes.count()); - QSetIterator it(indexes); - while (it.hasNext()) { - const int index = it.next(); + foreach (int index, indexes) { KFileItem item = m_model->fileItem(index); const KUrl& url = openItemAsFolderUrl(item); @@ -1103,7 +1097,7 @@ void DolphinView::slotAboutToCreate(const KUrl::List& urls) } } -void DolphinView::slotSelectionChanged(const QSet& current, const QSet& previous) +void DolphinView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous) { const int currentCount = current.count(); const int previousCount = previous.count(); @@ -1322,7 +1316,7 @@ void DolphinView::updateViewState() m_clearSelectionBeforeSelectingNewItems = false; } - QSet selectedItems = selectionManager->selectedItems(); + KItemSet selectedItems = selectionManager->selectedItems(); QList::iterator it = m_selectedUrls.begin(); while (it != m_selectedUrls.end()) { @@ -1492,7 +1486,9 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con } KonqOperations* op = KonqOperations::renameV2(this, oldUrl, newName); - if (op) { + if (op && !newNameExistsAlready) { + // Only connect the renamingFailed signal if there is no item with the new name + // in the model yet, see bug 328262. connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl))); } } @@ -1658,7 +1654,7 @@ KUrl::List DolphinView::simplifiedSelectedUrls() const QMimeData* DolphinView::selectionMimeData() const { const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); - const QSet selectedIndexes = selectionManager->selectedItems(); + const KItemSet selectedIndexes = selectionManager->selectedItems(); return m_model->createMimeData(selectedIndexes); }