X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/1353c92cce7ebc805b51d90f0bbb0c95dca0f2cb..99f2840038976111475cb90e3865edb11d04db61:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 5b3d074c9..ea64a04dc 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -101,6 +101,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : m_scrollToCurrentItem(false), m_restoredContentsPosition(), m_selectedUrls(), + m_clearSelectionBeforeSelectingNewItems(false), m_versionControlObserver(0) { m_topLayout = new QVBoxLayout(this); @@ -599,6 +600,8 @@ void DolphinView::setUrl(const KUrl& url) return; } + clearSelection(); + emit urlAboutToBeChanged(url); m_url = url; @@ -629,6 +632,7 @@ void DolphinView::invertSelection() void DolphinView::clearSelection() { + m_selectedUrls.clear(); m_container->controller()->selectionManager()->clearSelection(); } @@ -847,7 +851,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); if (nepomukRunning) { KConfig config("nepomukserverrc"); - indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false); + indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true); } #endif @@ -1179,8 +1183,11 @@ QString DolphinView::viewPropertiesContext() const void DolphinView::observeCreatedItem(const KUrl& url) { - markUrlAsCurrent(url); - markUrlsAsSelected(QList() << url); + if (m_active) { + clearSelection(); + markUrlAsCurrent(url); + markUrlsAsSelected(QList() << url); + } } void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl) @@ -1220,20 +1227,27 @@ void DolphinView::updateViewState() } if (!m_selectedUrls.isEmpty()) { - clearSelection(); - KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); + + if (m_clearSelectionBeforeSelectingNewItems) { + selectionManager->clearSelection(); + m_clearSelectionBeforeSelectingNewItems = false; + } + QSet selectedItems = selectionManager->selectedItems(); - foreach (const KUrl& url, m_selectedUrls) { - const int index = m_model->index(url); + QList::iterator it = m_selectedUrls.begin(); + while (it != m_selectedUrls.end()) { + const int index = m_model->index(*it); if (index >= 0) { selectedItems.insert(index); + it = m_selectedUrls.erase(it); + } else { + ++it; } } selectionManager->setSelectedItems(selectedItems); - m_selectedUrls.clear(); } } @@ -1357,9 +1371,18 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con if (!newName.isEmpty() && newName != oldItem.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) { const KUrl oldUrl = oldItem.url(); - QHash data; - data.insert(role, value); - m_model->setData(index, data); + const KUrl newUrl(url().path(KUrl::AddTrailingSlash) + newName); + const bool newNameExistsAlready = (m_model->index(newUrl) >= 0); + if (!newNameExistsAlready) { + // Only change the data in the model if no item with the new name + // is in the model yet. If there is an item with the new name + // already, calling KonqOperations::rename() will open a dialog + // asking for a new name, and KFileItemModel will update the + // data when the dir lister signals that the file name has changed. + QHash data; + data.insert(role, value); + m_model->setData(index, data); + } KonqOperations::rename(this, oldUrl, newName); } @@ -1531,6 +1554,7 @@ void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData) destUrls << destination; } markUrlsAsSelected(destUrls); + m_clearSelectionBeforeSelectingNewItems = true; } void DolphinView::updateWritableState()