X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/98363db9134fc42e67f6aa2434dc5a03516ad1a6..60d555fa55f025f3ecaa82cf95f012cbbbeb8ddc:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index e59f9b282..f18f6b391 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -67,8 +67,6 @@ #include "viewproperties.h" #include "zoomlevelinfo.h" -#include - /** * Helper function for sorting items with qSort() in * DolphinView::renameSelectedItems(). @@ -106,7 +104,7 @@ DolphinView::DolphinView(QWidget* parent, m_previewGenerator(0), m_toolTipManager(0), m_rootUrl(), - m_currentItemUrl(), + m_activeItemUrl(), m_createdItemUrl(), m_selectedItems(), m_newFileNames(), @@ -331,6 +329,7 @@ void DolphinView::clearSelection() const QModelIndex currentIndex = selModel->currentIndex(); selModel->setCurrentIndex(currentIndex, QItemSelectionModel::Current | QItemSelectionModel::Clear); + m_selectedItems.clear(); } KFileItemList DolphinView::selectedItems() const @@ -377,7 +376,7 @@ int DolphinView::selectedItemsCount() const return m_columnView->selectedItems().count(); } - return itemView()->selectionModel()->selection().count(); + return itemView()->selectionModel()->selectedIndexes().count(); } void DolphinView::setContentsPosition(int x, int y) @@ -610,9 +609,6 @@ QString DolphinView::statusBarText() const void DolphinView::setUrl(const KUrl& url) { m_newFileNames.clear(); - - // remember current item candidate (see slotDirListerCompleted()) - m_currentItemUrl = url; updateView(url, KUrl()); } @@ -648,16 +644,23 @@ void DolphinView::renameSelectedItems() if (itemCount > 1) { // More than one item has been selected for renaming. Open // a rename dialog and rename all items afterwards. - RenameDialog dialog(this, items); - if (dialog.exec() == QDialog::Rejected) { + QPointer dialog = new RenameDialog(this, items); + if (dialog->exec() == QDialog::Rejected) { + delete dialog; return; } - const QString newName = dialog.newName(); + const QString newName = dialog->newName(); if (newName.isEmpty()) { - emit errorMessage(dialog.errorString()); + emit errorMessage(dialog->errorString()); + delete dialog; return; } + delete dialog; + + // the selection would be invalid after renaming the items, so just clear + // it before + clearSelection(); // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations // as one operation instead of n rename operations like it is done now... @@ -696,16 +699,19 @@ void DolphinView::renameSelectedItems() } else { Q_ASSERT(itemCount == 1); - RenameDialog dialog(this, items); - if (dialog.exec() == QDialog::Rejected) { + QPointer dialog = new RenameDialog(this, items); + if (dialog->exec() == QDialog::Rejected) { + delete dialog; return; } - const QString& newName = dialog.newName(); + const QString newName = dialog->newName(); if (newName.isEmpty()) { - emit errorMessage(dialog.errorString()); + emit errorMessage(dialog->errorString()); + delete dialog; return; } + delete dialog; const KUrl& oldUrl = items.first().url(); KUrl newUrl = oldUrl; @@ -1096,6 +1102,11 @@ bool DolphinView::isTabsForFilesEnabled() const return m_tabsForFiles; } +void DolphinView::activateItem(const KUrl& url) +{ + m_activeItemUrl = url; +} + bool DolphinView::itemsExpandable() const { return (m_detailsView != 0) && m_detailsView->itemsExpandable(); @@ -1187,9 +1198,9 @@ void DolphinView::slotRequestUrlChange(const KUrl& url) void DolphinView::slotDirListerCompleted() { - if (!m_currentItemUrl.isEmpty()) { + if (!m_activeItemUrl.isEmpty()) { // assure that the current item remains visible - const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl); + const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_activeItemUrl); if (dirIndex.isValid()) { const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex); QAbstractItemView* view = itemView(); @@ -1198,8 +1209,8 @@ void DolphinView::slotDirListerCompleted() if (clearSelection) { view->clearSelection(); } + m_activeItemUrl.clear(); } - m_currentItemUrl.clear(); } if (!m_newFileNames.isEmpty()) {