diff options
Diffstat (limited to 'src/kitemviews')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 61 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemmodel.h | 8 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemmodelrolesupdater.cpp | 2 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.cpp | 6 | ||||
| -rw-r--r-- | src/kitemviews/private/kdirectorycontentscounter.cpp | 6 | ||||
| -rw-r--r-- | src/kitemviews/private/kfileitemclipboard.cpp | 11 | ||||
| -rw-r--r-- | src/kitemviews/private/kfileitemclipboard.h | 8 | ||||
| -rw-r--r-- | src/kitemviews/private/kfileitemmodeldirlister.h | 4 |
8 files changed, 52 insertions, 54 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 524b4f59a..711b0797b 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -189,8 +189,9 @@ bool KFileItemModel::setData(int index, const QHash<QByteArray, QVariant>& value m_itemData[index]->values = currentValues; if (changedRoles.contains("text")) { - KUrl url = m_itemData[index]->item.url(); - url.setFileName(currentValues["text"].toString()); + QUrl url = m_itemData[index]->item.url(); + url = url.adjusted(QUrl::RemoveFilename); + url.setPath(url.path() + currentValues["text"].toString()); m_itemData[index]->item.setUrl(url); } @@ -243,8 +244,8 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const // The following code has been taken from KDirModel::mimeData() // (kdelibs/kio/kio/kdirmodel.cpp) // Copyright (C) 2006 David Faure <[email protected]> - KUrl::List urls; - KUrl::List mostLocalUrls; + QList<QUrl> urls; + QList<QUrl> mostLocalUrls; bool canUseMostLocalUrls = true; const ItemData* lastAddedItem = 0; @@ -276,9 +277,9 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const const bool different = canUseMostLocalUrls && mostLocalUrls != urls; if (different) { - urls.populateMimeData(mostLocalUrls, data); + data->setUrls(mostLocalUrls); } else { - urls.populateMimeData(data); + data->setUrls(urls); } return data; @@ -369,8 +370,7 @@ int KFileItemModel::index(const KFileItem& item) const int KFileItemModel::index(const QUrl& url) const { - KUrl urlToFind = url; - urlToFind.adjustPath(KUrl::RemoveTrailingSlash); + const QUrl urlToFind = url.adjusted(QUrl::StripTrailingSlash); const int itemCount = m_itemData.count(); int itemsInHash = m_items.count(); @@ -388,7 +388,7 @@ int KFileItemModel::index(const QUrl& url) const const int blockSize = 1000; const int currentBlockEnd = qMin(itemsInHash + blockSize, itemCount); for (int i = itemsInHash; i < currentBlockEnd; ++i) { - const KUrl nextUrl = m_itemData.at(i)->item.url(); + const QUrl nextUrl = m_itemData.at(i)->item.url(); m_items.insert(nextUrl, i); } @@ -412,12 +412,12 @@ int KFileItemModel::index(const QUrl& url) const kWarning() << "m_itemData.count() ==" << m_itemData.count(); // Check if there are multiple items with the same URL. - QMultiHash<KUrl, int> indexesForUrl; + QMultiHash<QUrl, int> indexesForUrl; for (int i = 0; i < m_itemData.count(); ++i) { indexesForUrl.insert(m_itemData.at(i)->item.url(), i); } - foreach (const KUrl& url, indexesForUrl.uniqueKeys()) { + foreach (const QUrl& url, indexesForUrl.uniqueKeys()) { if (indexesForUrl.count(url) > 1) { kWarning() << "Multiple items found with the URL" << url; foreach (int index, indexesForUrl.values(url)) { @@ -511,15 +511,15 @@ bool KFileItemModel::setExpanded(int index, bool expanded) } const KFileItem item = m_itemData.at(index)->item; - const KUrl url = item.url(); - const KUrl targetUrl = item.targetUrl(); + const QUrl url = item.url(); + const QUrl targetUrl = item.targetUrl(); if (expanded) { m_expandedDirs.insert(targetUrl, url); m_dirLister->openUrl(url, KDirLister::Keep); - const KUrl::List previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<KUrl::List>(); - foreach (const KUrl& url, previouslyExpandedChildren) { - m_urlsToExpand.insert(url); + const QVariantList previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<QVariantList>(); + foreach (const QVariant& var, previouslyExpandedChildren) { + m_urlsToExpand.insert(var.toUrl()); } } else { // Note that there might be (indirect) children of the folder which is to be collapsed in @@ -541,14 +541,14 @@ bool KFileItemModel::setExpanded(int index, bool expanded) const int itemCount = m_itemData.count(); const int firstChildIndex = index + 1; - KUrl::List expandedChildren; + QVariantList expandedChildren; int childIndex = firstChildIndex; while (childIndex < itemCount && expandedParentsCount(childIndex) > parentLevel) { ItemData* itemData = m_itemData.at(childIndex); if (itemData->values.value("isExpanded").toBool()) { - const KUrl targetUrl = itemData->item.targetUrl(); - const KUrl url = itemData->item.url(); + const QUrl targetUrl = itemData->item.targetUrl(); + const QUrl url = itemData->item.url(); m_expandedDirs.remove(targetUrl); m_dirLister->stop(url); // TODO: try to unit-test this, see https://bugs.kde.org/show_bug.cgi?id=332102#c11 expandedChildren.append(targetUrl); @@ -610,10 +610,10 @@ void KFileItemModel::expandParentDirectories(const QUrl &url) // expanded is added to m_urlsToExpand. KDirLister // does not care whether the parent-URL has already been // expanded. - KUrl urlToExpand = m_dirLister->url(); + QUrl urlToExpand = m_dirLister->url(); const QStringList subDirs = url.path().mid(pos).split(QDir::separator()); for (int i = 0; i < subDirs.count() - 1; ++i) { - urlToExpand.addPath(subDirs.at(i)); + urlToExpand.setPath(urlToExpand.path() + '/' + subDirs.at(i)); m_urlsToExpand.insert(urlToExpand); } @@ -801,7 +801,7 @@ void KFileItemModel::resortAllItems() // Remember the order of the current URLs so // that it can be determined which indexes have // been moved because of the resorting. - QList<KUrl> oldUrls; + QList<QUrl> oldUrls; oldUrls.reserve(itemCount); foreach (const ItemData* itemData, m_itemData) { oldUrls.append(itemData->item.url()); @@ -870,7 +870,7 @@ void KFileItemModel::slotCompleted() // Note that the parent folder must be expanded before any of its subfolders become visible. // Therefore, some URLs in m_restoredExpandedUrls might not be visible yet // -> we expand the first visible URL we find in m_restoredExpandedUrls. - foreach (const KUrl& url, m_urlsToExpand) { + foreach (const QUrl& url, m_urlsToExpand) { const int indexForUrl = index(url); if (indexForUrl >= 0) { m_urlsToExpand.remove(url); @@ -902,12 +902,11 @@ void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemLis { Q_ASSERT(!items.isEmpty()); - KUrl parentUrl; + QUrl parentUrl; if (m_expandedDirs.contains(directoryUrl)) { parentUrl = m_expandedDirs.value(directoryUrl); } else { - parentUrl = directoryUrl; - parentUrl.adjustPath(KUrl::RemoveTrailingSlash); + parentUrl = directoryUrl.adjusted(QUrl::StripTrailingSlash); } if (m_requestRole[ExpandedParentsCountRole]) { @@ -916,7 +915,7 @@ void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemLis // might result in emitting the same items twice due to the Keep-parameter. // This case happens if an item gets expanded, collapsed and expanded again // before the items could be loaded for the first expansion. - if (index(KUrl(items.first().url())) >= 0) { + if (index(items.first().url()) >= 0) { // The items are already part of the model. return; } @@ -1202,7 +1201,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems) } // The indexes in m_items are not correct anymore. Therefore, we clear m_items. - // It will be re-populated with the updated indices if index(const KUrl&) is called. + // It will be re-populated with the updated indices if index(const QUrl&) is called. m_items.clear(); emit itemsInserted(itemRanges); @@ -1255,13 +1254,13 @@ void KFileItemModel::removeItems(const KItemRangeList& itemRanges, RemoveItemsBe m_itemData.erase(m_itemData.end() - removedItemsCount, m_itemData.end()); // The indexes in m_items are not correct anymore. Therefore, we clear m_items. - // It will be re-populated with the updated indices if index(const KUrl&) is called. + // It will be re-populated with the updated indices if index(const QUrl&) is called. m_items.clear(); emit itemsRemoved(itemRanges); } -QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const +QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const { if (m_sortRole == TypeRole) { // Try to resolve the MIME-types synchronously to prevent a reordering of @@ -2200,7 +2199,7 @@ QByteArray KFileItemModel::sharedValue(const QByteArray& value) bool KFileItemModel::isConsistent() const { // m_items may contain less items than m_itemData because m_items - // is populated lazily, see KFileItemModel::index(const KUrl& url). + // is populated lazily, see KFileItemModel::index(const QUrl& url). if (m_items.count() > m_itemData.count()) { return false; } diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index aea0341ea..1a4f6928e 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -22,7 +22,7 @@ #include <libdolphin_export.h> #include <KFileItemList> -#include <KUrl> +#include <QUrl> #include <kitemviews/kitemmodelbase.h> #include <kitemviews/private/kfileitemmodelfilter.h> @@ -317,7 +317,7 @@ private: * Note that the ItemData instances are created dynamically and * must be deleted by the caller. */ - QList<ItemData*> createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const; + QList<ItemData*> createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const; /** * Prepares the items for sorting. Normally, the hash 'values' in ItemData is filled @@ -470,11 +470,11 @@ private: QList<ItemData*> m_itemData; - // m_items is a cache for the method index(const KUrl&). If it contains N + // m_items is a cache for the method index(const QUrl&). If it contains N // entries, it is guaranteed that these correspond to the first N items in // the model, i.e., that (for every i between 0 and N - 1) // m_items.value(fileItem(i).url()) == i - mutable QHash<KUrl, int> m_items; + mutable QHash<QUrl, int> m_items; KFileItemModelFilter m_filter; QHash<KFileItem, ItemData*> m_filteredItems; // Items that got hidden by KFileItemModel::setNameFilter() diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index 8e9b9dd98..2353f106f 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -741,7 +741,7 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin const bool getIsExpandableRole = m_roles.contains("isExpandable"); if (getSizeRole || getIsExpandableRole) { - const int index = m_model->index(KUrl(path)); + const int index = m_model->index(QUrl::fromLocalFile(path)); if (index >= 0) { QHash<QByteArray, QVariant> data; diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 9a08a53db..ec48f19db 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -680,7 +680,7 @@ void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& cur // The URL might have changed (i.e., if the sort order of the items has // been changed). Therefore, the "is cut" state must be updated. KFileItemClipboard* clipboard = KFileItemClipboard::instance(); - const KUrl itemUrl = data().value("url").value<KUrl>(); + const QUrl itemUrl = data().value("url").value<QUrl>(); m_isCut = clipboard->isCut(itemUrl); // The icon-state might depend from other roles and hence is @@ -831,7 +831,7 @@ void KStandardItemListWidget::showEvent(QShowEvent* event) // Listen to changes of the clipboard to mark the item as cut/uncut KFileItemClipboard* clipboard = KFileItemClipboard::instance(); - const KUrl itemUrl = data().value("url").value<KUrl>(); + const QUrl itemUrl = data().value("url").value<QUrl>(); m_isCut = clipboard->isCut(itemUrl); connect(clipboard, &KFileItemClipboard::cutItemsChanged, @@ -848,7 +848,7 @@ void KStandardItemListWidget::hideEvent(QHideEvent* event) void KStandardItemListWidget::slotCutItemsChanged() { - const KUrl itemUrl = data().value("url").value<KUrl>(); + const QUrl itemUrl = data().value("url").value<QUrl>(); const bool isCut = KFileItemClipboard::instance()->isCut(itemUrl); if (m_isCut != isCut) { m_isCut = isCut; diff --git a/src/kitemviews/private/kdirectorycontentscounter.cpp b/src/kitemviews/private/kdirectorycontentscounter.cpp index cd448e233..af7312ad2 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.cpp +++ b/src/kitemviews/private/kdirectorycontentscounter.cpp @@ -122,7 +122,7 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count) void KDirectoryContentsCounter::slotDirWatchDirty(const QString& path) { - const int index = m_model->index(KUrl(path)); + const int index = m_model->index(QUrl::fromLocalFile(path)); if (index >= 0) { if (!m_model->fileItem(index).isDir()) { // If INotify is used, KDirWatch issues the dirty() signal @@ -151,7 +151,7 @@ void KDirectoryContentsCounter::slotItemsRemoved() QMutableSetIterator<QString> it(m_watchedDirs); while (it.hasNext()) { const QString& path = it.next(); - if (m_model->index(KUrl(path)) < 0) { + if (m_model->index(QUrl::fromLocalFile(path)) < 0) { m_dirWatcher->removeDir(path); it.remove(); } @@ -181,4 +181,4 @@ void KDirectoryContentsCounter::startWorker(const QString& path) } QThread* KDirectoryContentsCounter::m_workerThread = 0; -int KDirectoryContentsCounter::m_workersCount = 0;
\ No newline at end of file +int KDirectoryContentsCounter::m_workersCount = 0; diff --git a/src/kitemviews/private/kfileitemclipboard.cpp b/src/kitemviews/private/kfileitemclipboard.cpp index 1fb147716..e12767853 100644 --- a/src/kitemviews/private/kfileitemclipboard.cpp +++ b/src/kitemviews/private/kfileitemclipboard.cpp @@ -19,17 +19,17 @@ #include "kfileitemclipboard.h" -#include <KGlobal> #include <QApplication> #include <QClipboard> #include <QMimeData> +#include <KUrlMimeData> class KFileItemClipboardSingleton { public: KFileItemClipboard instance; }; -K_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard) +Q_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard) @@ -38,12 +38,12 @@ KFileItemClipboard* KFileItemClipboard::instance() return &s_KFileItemClipboard->instance; } -bool KFileItemClipboard::isCut(const KUrl& url) const +bool KFileItemClipboard::isCut(const QUrl& url) const { return m_cutItems.contains(url); } -QList<KUrl> KFileItemClipboard::cutItems() const +QList<QUrl> KFileItemClipboard::cutItems() const { return m_cutItems.toList(); } @@ -66,7 +66,7 @@ void KFileItemClipboard::updateCutItems() const QByteArray data = mimeData->data("application/x-kde-cutselection"); const bool isCutSelection = (!data.isEmpty() && data.at(0) == QLatin1Char('1')); if (isCutSelection) { - m_cutItems = KUrl::List::fromMimeData(mimeData).toSet(); + m_cutItems = KUrlMimeData::urlsFromMimeData(mimeData).toSet(); } else { m_cutItems.clear(); } @@ -82,4 +82,3 @@ KFileItemClipboard::KFileItemClipboard() : connect(QApplication::clipboard(), &QClipboard::dataChanged, this, &KFileItemClipboard::updateCutItems); } - diff --git a/src/kitemviews/private/kfileitemclipboard.h b/src/kitemviews/private/kfileitemclipboard.h index 86eb8e9fc..d02fc0d47 100644 --- a/src/kitemviews/private/kfileitemclipboard.h +++ b/src/kitemviews/private/kfileitemclipboard.h @@ -20,7 +20,7 @@ #ifndef KFILEITEMCLIPBOARD_H #define KFILEITEMCLIPBOARD_H -#include <KUrl> +#include <QUrl> #include <QList> #include <QSet> #include <QObject> @@ -38,9 +38,9 @@ class LIBDOLPHINPRIVATE_EXPORT KFileItemClipboard : public QObject public: static KFileItemClipboard* instance(); - bool isCut(const KUrl& url) const; + bool isCut(const QUrl& url) const; - QList<KUrl> cutItems() const; + QList<QUrl> cutItems() const; signals: void cutItemsChanged(); @@ -54,7 +54,7 @@ private slots: private: KFileItemClipboard(); - QSet<KUrl> m_cutItems; + QSet<QUrl> m_cutItems; friend class KFileItemClipboardSingleton; }; diff --git a/src/kitemviews/private/kfileitemmodeldirlister.h b/src/kitemviews/private/kfileitemmodeldirlister.h index da01d20bd..94a0e39fd 100644 --- a/src/kitemviews/private/kfileitemmodeldirlister.h +++ b/src/kitemviews/private/kfileitemmodeldirlister.h @@ -22,7 +22,7 @@ #include <libdolphin_export.h> #include <KDirLister> -#include <KUrl> +#include <QUrl> /** * @brief Extends the class KDirLister by emitting a signal when an @@ -45,7 +45,7 @@ signals: * Is emitted when the URL of the directory lister represents a file. * In this case no signal errorMessage() will be emitted. */ - void urlIsFileError(const KUrl& url); + void urlIsFileError(const QUrl& url); protected: virtual void handleError(KIO::Job* job); |
