X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/0a6257bce3de877e4ae869f974df645c428d32c9..fa988586bc923b33497cbc97aaac07fc93a4ca83:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 4ed32ed43..b330e5f5c 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -57,7 +57,7 @@ #include #include #include -#include +#include #include "dolphinnewfilemenuobserver.h" #include "dolphin_detailsmodesettings.h" @@ -80,7 +80,7 @@ namespace { const int MaxModeEnum = DolphinView::CompactView; }; -DolphinView::DolphinView(const KUrl& url, QWidget* parent) : +DolphinView::DolphinView(const QUrl& url, QWidget* parent) : QWidget(parent), m_active(true), m_tabsForFiles(false), @@ -203,7 +203,7 @@ DolphinView::~DolphinView() { } -KUrl DolphinView::url() const +QUrl DolphinView::url() const { return m_url; } @@ -293,7 +293,7 @@ void DolphinView::setHiddenFilesShown(bool show) const KFileItemList itemList = selectedItems(); m_selectedUrls.clear(); - m_selectedUrls = KUrl::List(itemList.urlList()); + m_selectedUrls = itemList.urlList(); ViewProperties props(viewPropertiesUrl()); props.setHiddenFilesShown(show); @@ -362,12 +362,12 @@ int DolphinView::selectedItemsCount() const return selectionManager->selectedItems().count(); } -void DolphinView::markUrlsAsSelected(const QList& urls) +void DolphinView::markUrlsAsSelected(const QList& urls) { m_selectedUrls = urls; } -void DolphinView::markUrlAsCurrent(const KUrl& url) +void DolphinView::markUrlAsCurrent(const QUrl &url) { m_currentItemUrl = url; m_scrollToCurrentItem = true; @@ -470,7 +470,7 @@ void DolphinView::reload() const KFileItemList itemList = selectedItems(); m_selectedUrls.clear(); - m_selectedUrls = KUrl::List(itemList.urlList()); + m_selectedUrls = itemList.urlList(); setUrl(url()); loadDirectory(url(), true); @@ -591,7 +591,7 @@ QList DolphinView::versionControlActions(const KFileItemList& items) c return actions; } -void DolphinView::setUrl(const KUrl& url) +void DolphinView::setUrl(const QUrl& url) { if (url == m_url) { return; @@ -667,12 +667,12 @@ void DolphinView::renameSelectedItems() void DolphinView::trashSelectedItems() { - const KUrl::List list = simplifiedSelectedUrls(); + const QList list = simplifiedSelectedUrls(); KIO::JobUiDelegate uiDelegate; uiDelegate.setWindow(window()); if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) { KIO::Job* job = KIO::trash(list); - KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, KUrl("trash:/"), job); + KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, QUrl("trash:/"), job); KJobWidgets::setWindow(job, this); connect(job, &KIO::Job::result, this, &DolphinView::slotTrashFileFinished); @@ -681,7 +681,7 @@ void DolphinView::trashSelectedItems() void DolphinView::deleteSelectedItems() { - const KUrl::List list = simplifiedSelectedUrls(); + const QList list = simplifiedSelectedUrls(); KIO::JobUiDelegate uiDelegate; uiDelegate.setWindow(window()); @@ -819,7 +819,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes) foreach (int index, indexes) { KFileItem item = m_model->fileItem(index); - const KUrl& url = openItemAsFolderUrl(item); + const QUrl& url = openItemAsFolderUrl(item); if (!url.isEmpty()) { // Open folders in new tabs emit tabRequested(url); @@ -838,7 +838,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes) void DolphinView::slotItemMiddleClicked(int index) { const KFileItem& item = m_model->fileItem(index); - const KUrl& url = openItemAsFolderUrl(item); + const QUrl& url = openItemAsFolderUrl(item); if (!url.isEmpty()) { emit tabRequested(url); } else if (isTabsForFilesEnabled()) { @@ -1021,7 +1021,7 @@ void DolphinView::slotItemUnhovered(int index) void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) { - KUrl destUrl; + QUrl destUrl; KFileItem destItem = m_model->fileItem(index); if (destItem.isNull() || (!destItem.isDir() && !destItem.isDesktopFile())) { // Use the URL of the view as drop target if the item is no directory @@ -1049,7 +1049,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even // Mark the dropped urls as selected. m_clearSelectionBeforeSelectingNewItems = true; m_markFirstNewlySelectedItemAsCurrent = true; - connect(op, static_cast(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate); + connect(op, static_cast&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate); } setActive(true); @@ -1085,14 +1085,14 @@ void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons } } -void DolphinView::slotAboutToCreate(const KUrl::List& urls) +void DolphinView::slotAboutToCreate(const QList& urls) { if (!urls.isEmpty()) { if (m_markFirstNewlySelectedItemAsCurrent) { markUrlAsCurrent(urls.first()); m_markFirstNewlySelectedItemAsCurrent = false; } - m_selectedUrls << KUrl::List(KDirModel::simplifiedUrlList(urls)); + m_selectedUrls << KDirModel::simplifiedUrlList(urls); } } @@ -1149,7 +1149,10 @@ void DolphinView::updateSortFoldersFirst(bool foldersFirst) QPair DolphinView::pasteInfo() const { - return KonqOperations::pasteInfo(url()); + const QMimeData *mimeData = QApplication::clipboard()->mimeData(); + QPair info; + info.second = KIO::pasteActionText(mimeData, &info.first, rootItem()); + return info; } void DolphinView::setTabsForFilesEnabled(bool tabsForFiles) @@ -1184,7 +1187,7 @@ void DolphinView::restoreState(QDataStream& stream) stream >> m_restoredContentsPosition; // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes) - QSet urls; + QSet urls; stream >> urls; m_model->restoreExpandedDirectories(urls); } @@ -1198,10 +1201,10 @@ void DolphinView::saveState(QDataStream& stream) if (currentIndex != -1) { KFileItem item = m_model->fileItem(currentIndex); Q_ASSERT(!item.isNull()); // If the current index is valid a item must exist - KUrl currentItemUrl = item.url(); + QUrl currentItemUrl = item.url(); stream << currentItemUrl; } else { - stream << KUrl(); + stream << QUrl(); } // Save view position @@ -1228,13 +1231,13 @@ QString DolphinView::viewPropertiesContext() const return m_viewPropertiesContext; } -KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives) +QUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives) { if (item.isNull()) { - return KUrl(); + return QUrl(); } - KUrl url = item.targetUrl(); + QUrl url = item.targetUrl(); if (item.isDir()) { return url; @@ -1251,7 +1254,7 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh // open OpenDocument files as zip folders... const QString& protocol = KProtocolManager::protocolForArchiveMimetype(mimetype); if (!protocol.isEmpty()) { - url.setProtocol(protocol); + url.setScheme(protocol); return url; } } @@ -1268,21 +1271,21 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh } } - return KUrl(); + return QUrl(); } -void DolphinView::observeCreatedItem(const KUrl& url) +void DolphinView::observeCreatedItem(const QUrl& url) { if (m_active) { clearSelection(); markUrlAsCurrent(url); - markUrlsAsSelected(QList() << url); + markUrlsAsSelected(QList() << url); } } -void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl) +void DolphinView::slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl) { - if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) { + if (oldUrl.matches(url(), QUrl::StripTrailingSlash)) { emit redirection(oldUrl, newUrl); m_url = newUrl; // #186947 } @@ -1290,7 +1293,7 @@ void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUr void DolphinView::updateViewState() { - if (m_currentItemUrl != KUrl()) { + if (m_currentItemUrl != QUrl()) { KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); const int currentIndex = m_model->index(m_currentItemUrl); if (currentIndex != -1) { @@ -1305,7 +1308,7 @@ void DolphinView::updateViewState() selectionManager->setCurrentItem(0); } - m_currentItemUrl = KUrl(); + m_currentItemUrl = QUrl(); } if (!m_restoredContentsPosition.isNull()) { @@ -1327,7 +1330,7 @@ void DolphinView::updateViewState() KItemSet selectedItems = selectionManager->selectedItems(); - QList::iterator it = m_selectedUrls.begin(); + QList::iterator it = m_selectedUrls.begin(); while (it != m_selectedUrls.end()) { const int index = m_model->index(*it); if (index >= 0) { @@ -1389,7 +1392,7 @@ void DolphinView::slotRenamingResult(KJob* job) KIO::CopyJob *copyJob = qobject_cast(job); Q_ASSERT(copyJob); const QUrl newUrl = copyJob->destUrl(); - const int index = m_model->index(KUrl(newUrl)); + const int index = m_model->index(newUrl); if (index >= 0) { QHash data; const QUrl oldUrl = copyJob->srcUrls().first(); @@ -1484,12 +1487,12 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con const KFileItem oldItem = m_model->fileItem(index); const QString newName = value.toString(); if (!newName.isEmpty() && newName != oldItem.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) { - const KUrl oldUrl = oldItem.url(); + const QUrl oldUrl = oldItem.url(); QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename); newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName)); - const bool newNameExistsAlready = (m_model->index(KUrl(newUrl)) >= 0); + 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 @@ -1515,10 +1518,10 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con } } -void DolphinView::loadDirectory(const KUrl& url, bool reload) +void DolphinView::loadDirectory(const QUrl& url, bool reload) { if (!url.isValid()) { - const QString location(url.pathOrUrl()); + const QString location(url.toDisplayString(QUrl::PreferLocalFile)); if (location.isEmpty()) { emit errorMessage(i18nc("@info:status", "The location is empty.")); } else { @@ -1644,19 +1647,19 @@ void DolphinView::applyModeToView() } } -void DolphinView::pasteToUrl(const KUrl& url) +void DolphinView::pasteToUrl(const QUrl& url) { - KonqOperations* op = KonqOperations::doPasteV2(this, url); + KonqOperations* op = KonqOperations::doPaste(this, url); if (op) { m_clearSelectionBeforeSelectingNewItems = true; m_markFirstNewlySelectedItemAsCurrent = true; - connect(op, static_cast(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate); + connect(op, static_cast&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate); } } -KUrl::List DolphinView::simplifiedSelectedUrls() const +QList DolphinView::simplifiedSelectedUrls() const { - KUrl::List urls; + QList urls; const KFileItemList items = selectedItems(); foreach (const KFileItem& item, items) { @@ -1699,15 +1702,14 @@ void DolphinView::updateWritableState() } } -KUrl DolphinView::viewPropertiesUrl() const +QUrl DolphinView::viewPropertiesUrl() const { if (m_viewPropertiesContext.isEmpty()) { return m_url; } - KUrl url; - url.setProtocol(m_url.protocol()); + QUrl url; + url.setScheme(m_url.scheme()); url.setPath(m_viewPropertiesContext); return url; } -