port Konqueror from KUrl to QUrl

REVIEW: 120650
This commit is contained in:
Lukáš Tinkl 2014-10-21 00:27:42 +02:00
parent 3c74d908de
commit d9d7926c49
15 changed files with 129 additions and 122 deletions

View file

@ -138,7 +138,7 @@ target_link_libraries(dolphinpart
install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR}) install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES dolphinpart.rc DESTINATION ${DATA_INSTALL_DIR}/dolphinpart) install(FILES dolphinpart.rc DESTINATION ${CMAKE_INSTALL_KXMLGUI5DIR}/dolphinpart)
install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR}) install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})

View file

@ -39,7 +39,7 @@ DolphinApplication::DolphinApplication() :
const int argsCount = args->count(); const int argsCount = args->count();
QList<KUrl> urls; QList<QUrl> urls;
for (int i = 0; i < argsCount; ++i) { for (int i = 0; i < argsCount; ++i) {
const KUrl url = args->url(i); const KUrl url = args->url(i);
if (url.isValid()) { if (url.isValid()) {

View file

@ -172,12 +172,12 @@ DolphinMainWindow::~DolphinMainWindow()
{ {
} }
void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs) void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs)
{ {
m_tabWidget->openDirectories(dirs); m_tabWidget->openDirectories(dirs);
} }
void DolphinMainWindow::openFiles(const QList<KUrl>& files) void DolphinMainWindow::openFiles(const QList<QUrl>& files)
{ {
m_tabWidget->openFiles(files); m_tabWidget->openFiles(files);
} }

View file

@ -76,14 +76,14 @@ public:
* Opens each directory in \p dirs in a separate tab. If the "split view" * Opens each directory in \p dirs in a separate tab. If the "split view"
* option is enabled, 2 directories are collected within one tab. * option is enabled, 2 directories are collected within one tab.
*/ */
void openDirectories(const QList<KUrl>& dirs); void openDirectories(const QList<QUrl> &dirs);
/** /**
* Opens the directory which contains the files \p files * Opens the directory which contains the files \p files
* and selects all files (implements the --select option * and selects all files (implements the --select option
* of Dolphin). * of Dolphin).
*/ */
void openFiles(const QList<KUrl>& files); void openFiles(const QList<QUrl>& files);
/** /**
* Returns the 'Create New...' sub menu which also can be shared * Returns the 'Create New...' sub menu which also can be shared

View file

@ -39,6 +39,7 @@
#include <kdeversion.h> #include <kdeversion.h>
#include <KSharedConfig> #include <KSharedConfig>
#include <KConfigGroup> #include <KConfigGroup>
#include <KComponentData>
#include "dolphinpart_ext.h" #include "dolphinpart_ext.h"
#include "dolphinnewfilemenu.h" #include "dolphinnewfilemenu.h"
@ -66,8 +67,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
,m_removeAction(0) ,m_removeAction(0)
{ {
Q_UNUSED(args) Q_UNUSED(args)
#pragma message("TODO: port to KF5") setComponentData(*createAboutData(), false);
//setComponentData(DolphinPartFactory::componentData(), false);
m_extension = new DolphinPartBrowserExtension(this); m_extension = new DolphinPartBrowserExtension(this);
// make sure that other apps using this part find Dolphin's view-file-columns icons // make sure that other apps using this part find Dolphin's view-file-columns icons
@ -381,7 +381,7 @@ void DolphinPart::slotItemsActivated(const KFileItemList& items)
} }
} }
void DolphinPart::createNewWindow(const KUrl& url) void DolphinPart::createNewWindow(const QUrl& url)
{ {
// TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
// should be moved into DolphinPart::slotItemActivated() // should be moved into DolphinPart::slotItemActivated()
@ -390,7 +390,7 @@ void DolphinPart::createNewWindow(const KUrl& url)
void DolphinPart::slotOpenContextMenu(const QPoint& pos, void DolphinPart::slotOpenContextMenu(const QPoint& pos,
const KFileItem& _item, const KFileItem& _item,
const KUrl&, const QUrl &,
const QList<QAction*>& customActions) const QList<QAction*>& customActions)
{ {
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
@ -471,12 +471,12 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
actionGroups); actionGroups);
} }
void DolphinPart::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl) void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
{ {
//kDebug() << oldUrl << newUrl << "currentUrl=" << url(); //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) { if (oldUrl.matches(url(), QUrl::StripTrailingSlash /* #207572 */)) {
KParts::ReadOnlyPart::setUrl(newUrl); KParts::ReadOnlyPart::setUrl(newUrl);
const QString prettyUrl = newUrl.pathOrUrl(); const QString prettyUrl = newUrl.toDisplayString(QUrl::PreferLocalFile);
emit m_extension->setLocationBarUrl(prettyUrl); emit m_extension->setLocationBarUrl(prettyUrl);
} }
} }
@ -585,7 +585,7 @@ void DolphinPart::createDirectory()
m_newFileMenu->createDirectory(); m_newFileMenu->createDirectory();
} }
void DolphinPart::setFilesToSelect(const KUrl::List& files) void DolphinPart::setFilesToSelect(const QList<QUrl>& files)
{ {
if (files.isEmpty()) { if (files.isEmpty()) {
return; return;

View file

@ -50,7 +50,7 @@ class DolphinPart : public KParts::ReadOnlyPart
Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter ) Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
// Used by konqueror to implement the --select command-line option // Used by konqueror to implement the --select command-line option
Q_PROPERTY( KUrl::List filesToSelect READ filesToSelect WRITE setFilesToSelect ) Q_PROPERTY( QList<QUrl> filesToSelect READ filesToSelect WRITE setFilesToSelect )
public: public:
explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args); explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
@ -131,7 +131,7 @@ private Q_SLOTS:
/** /**
* Creates a new window showing the content of \a url. * Creates a new window showing the content of \a url.
*/ */
void createNewWindow(const KUrl& url); void createNewWindow(const QUrl &url);
/** /**
* Opens the context menu on the current mouse position. * Opens the context menu on the current mouse position.
* @pos Position in screen coordinates. * @pos Position in screen coordinates.
@ -143,7 +143,7 @@ private Q_SLOTS:
*/ */
void slotOpenContextMenu(const QPoint& pos, void slotOpenContextMenu(const QPoint& pos,
const KFileItem& item, const KFileItem& item,
const KUrl& url, const QUrl& url,
const QList<QAction*>& customActions); const QList<QAction*>& customActions);
/** /**
@ -152,7 +152,7 @@ private Q_SLOTS:
* Testcase 1: fish://localhost * Testcase 1: fish://localhost
* Testcase 2: showing a directory that is being renamed by another window (#180156) * Testcase 2: showing a directory that is being renamed by another window (#180156)
*/ */
void slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl); void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/** /**
* Updates the state of the 'Edit' menu actions and emits * Updates the state of the 'Edit' menu actions and emits
@ -220,8 +220,8 @@ private Q_SLOTS:
/** /**
* Called by konqueror --select * Called by konqueror --select
*/ */
void setFilesToSelect(const KUrl::List& files); void setFilesToSelect(const QList<QUrl> &files);
KUrl::List filesToSelect() const { return KUrl::List(); } // silence moc QList<QUrl> filesToSelect() const { return QList<QUrl>(); } // silence moc
virtual bool eventFilter(QObject*, QEvent*); virtual bool eventFilter(QObject*, QEvent*);

View file

@ -25,7 +25,7 @@
#include <QSplitter> #include <QSplitter>
#include <QVBoxLayout> #include <QVBoxLayout>
DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl, QWidget* parent) : DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) :
QWidget(parent), QWidget(parent),
m_primaryViewActive(true), m_primaryViewActive(true),
m_splitViewEnabled(false) m_splitViewEnabled(false)
@ -135,7 +135,7 @@ int DolphinTabPage::selectedItemsCount() const
return selectedItemsCount; return selectedItemsCount;
} }
void DolphinTabPage::markUrlsAsSelected(const QList<KUrl>& urls) void DolphinTabPage::markUrlsAsSelected(const QList<QUrl>& urls)
{ {
m_primaryViewContainer->view()->markUrlsAsSelected(urls); m_primaryViewContainer->view()->markUrlsAsSelected(urls);
if (m_splitViewEnabled) { if (m_splitViewEnabled) {
@ -143,7 +143,7 @@ void DolphinTabPage::markUrlsAsSelected(const QList<KUrl>& urls)
} }
} }
void DolphinTabPage::markUrlAsCurrent(const KUrl& url) void DolphinTabPage::markUrlAsCurrent(const QUrl& url)
{ {
m_primaryViewContainer->view()->markUrlAsCurrent(url); m_primaryViewContainer->view()->markUrlAsCurrent(url);
if (m_splitViewEnabled) { if (m_splitViewEnabled) {

View file

@ -33,7 +33,7 @@ class DolphinTabPage : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl(), QWidget* parent = 0); explicit DolphinTabPage(const QUrl& primaryUrl, const QUrl& secondaryUrl = KUrl(), QWidget* parent = 0);
/** /**
* @return True if primary view is the active view in this tab. * @return True if primary view is the active view in this tab.
@ -85,13 +85,13 @@ public:
* gets selected if no loading of a directory has been triggered * gets selected if no loading of a directory has been triggered
* by DolphinView::setUrl() or DolphinView::reload(). * by DolphinView::setUrl() or DolphinView::reload().
*/ */
void markUrlsAsSelected(const QList<KUrl>& urls); void markUrlsAsSelected(const QList<QUrl> &urls);
/** /**
* Marks the item indicated by \p url to be scrolled to and as the * Marks the item indicated by \p url to be scrolled to and as the
* current item after directory DolphinView::url() has been loaded. * current item after directory DolphinView::url() has been loaded.
*/ */
void markUrlAsCurrent(const KUrl& url); void markUrlAsCurrent(const QUrl& url);
/** /**
* Sets the places selector visible, if \a visible is true. * Sets the places selector visible, if \a visible is true.

View file

@ -136,7 +136,7 @@ void DolphinTabWidget::openNewActivatedTab(const KUrl& primaryUrl, const KUrl& s
setCurrentIndex(count() - 1); setCurrentIndex(count() - 1);
} }
void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl) void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
{ {
QWidget* focusWidget = QApplication::focusWidget(); QWidget* focusWidget = QApplication::focusWidget();
@ -155,17 +155,17 @@ void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryU
} }
} }
void DolphinTabWidget::openDirectories(const QList<KUrl>& dirs) void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs)
{ {
const bool hasSplitView = GeneralSettings::splitView(); const bool hasSplitView = GeneralSettings::splitView();
// Open each directory inside a new tab. If the "split view" option has been enabled, // Open each directory inside a new tab. If the "split view" option has been enabled,
// always show two directories within one tab. // always show two directories within one tab.
QList<KUrl>::const_iterator it = dirs.constBegin(); QList<QUrl>::const_iterator it = dirs.constBegin();
while (it != dirs.constEnd()) { while (it != dirs.constEnd()) {
const KUrl& primaryUrl = *(it++); const QUrl& primaryUrl = *(it++);
if (hasSplitView && (it != dirs.constEnd())) { if (hasSplitView && (it != dirs.constEnd())) {
const KUrl& secondaryUrl = *(it++); const QUrl& secondaryUrl = *(it++);
openNewTab(primaryUrl, secondaryUrl); openNewTab(primaryUrl, secondaryUrl);
} else { } else {
openNewTab(primaryUrl); openNewTab(primaryUrl);
@ -173,7 +173,7 @@ void DolphinTabWidget::openDirectories(const QList<KUrl>& dirs)
} }
} }
void DolphinTabWidget::openFiles(const QList<KUrl>& files) void DolphinTabWidget::openFiles(const QList<QUrl>& files)
{ {
if (files.isEmpty()) { if (files.isEmpty()) {
return; return;
@ -182,7 +182,7 @@ void DolphinTabWidget::openFiles(const QList<KUrl>& files)
// Get all distinct directories from 'files' and open a tab // Get all distinct directories from 'files' and open a tab
// for each directory. If the "split view" option is enabled, two // for each directory. If the "split view" option is enabled, two
// directories are shown inside one tab (see openDirectories()). // directories are shown inside one tab (see openDirectories()).
QList<KUrl> dirs; QList<QUrl> dirs;
foreach (const KUrl& url, files) { foreach (const KUrl& url, files) {
const KUrl dir(url.directory()); const KUrl dir(url.directory());
if (!dirs.contains(dir)) { if (!dirs.contains(dir)) {

View file

@ -95,20 +95,20 @@ public slots:
* Opens a new tab in the background showing the URL \a primaryUrl and the * Opens a new tab in the background showing the URL \a primaryUrl and the
* optional URL \a secondaryUrl. * optional URL \a secondaryUrl.
*/ */
void openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl()); void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = KUrl());
/** /**
* Opens each directory in \p dirs in a separate tab. If the "split view" * Opens each directory in \p dirs in a separate tab. If the "split view"
* option is enabled, 2 directories are collected within one tab. * option is enabled, 2 directories are collected within one tab.
*/ */
void openDirectories(const QList<KUrl>& dirs); void openDirectories(const QList<QUrl>& dirs);
/** /**
* Opens the directory which contains the files \p files * Opens the directory which contains the files \p files
* and selects all files (implements the --select option * and selects all files (implements the --select option
* of Dolphin). * of Dolphin).
*/ */
void openFiles(const QList<KUrl>& files); void openFiles(const QList<QUrl> &files);
/** /**
* Closes the currently active tab. * Closes the currently active tab.
@ -187,4 +187,4 @@ private:
bool m_placesSelectorVisible; bool m_placesSelectorVisible;
}; };
#endif #endif

View file

@ -116,15 +116,15 @@ KFileItemModel::~KFileItemModel()
qDeleteAll(m_pendingItemsToInsert); qDeleteAll(m_pendingItemsToInsert);
} }
void KFileItemModel::loadDirectory(const KUrl& url) void KFileItemModel::loadDirectory(const QUrl &url)
{ {
m_dirLister->openUrl(url); m_dirLister->openUrl(url);
} }
void KFileItemModel::refreshDirectory(const KUrl& url) void KFileItemModel::refreshDirectory(const QUrl &url)
{ {
// Refresh all expanded directories first (Bug 295300) // Refresh all expanded directories first (Bug 295300)
QHashIterator<KUrl, KUrl> expandedDirs(m_expandedDirs); QHashIterator<QUrl, QUrl> expandedDirs(m_expandedDirs);
while (expandedDirs.hasNext()) { while (expandedDirs.hasNext()) {
expandedDirs.next(); expandedDirs.next();
m_dirLister->openUrl(expandedDirs.value(), KDirLister::Reload); m_dirLister->openUrl(expandedDirs.value(), KDirLister::Reload);
@ -133,7 +133,7 @@ void KFileItemModel::refreshDirectory(const KUrl& url)
m_dirLister->openUrl(url, KDirLister::Reload); m_dirLister->openUrl(url, KDirLister::Reload);
} }
KUrl KFileItemModel::directory() const QUrl KFileItemModel::directory() const
{ {
return m_dirLister->url(); return m_dirLister->url();
} }
@ -353,7 +353,7 @@ KFileItem KFileItemModel::fileItem(int index) const
return KFileItem(); return KFileItem();
} }
KFileItem KFileItemModel::fileItem(const KUrl& url) const KFileItem KFileItemModel::fileItem(const QUrl &url) const
{ {
const int indexForUrl = index(url); const int indexForUrl = index(url);
if (indexForUrl >= 0) { if (indexForUrl >= 0) {
@ -364,10 +364,10 @@ KFileItem KFileItemModel::fileItem(const KUrl& url) const
int KFileItemModel::index(const KFileItem& item) const int KFileItemModel::index(const KFileItem& item) const
{ {
return index(KUrl(item.url())); return index(item.url());
} }
int KFileItemModel::index(const KUrl& url) const int KFileItemModel::index(const QUrl& url) const
{ {
KUrl urlToFind = url; KUrl urlToFind = url;
urlToFind.adjustPath(KUrl::RemoveTrailingSlash); urlToFind.adjustPath(KUrl::RemoveTrailingSlash);
@ -592,17 +592,17 @@ int KFileItemModel::expandedParentsCount(int index) const
return 0; return 0;
} }
QSet<KUrl> KFileItemModel::expandedDirectories() const QSet<QUrl> KFileItemModel::expandedDirectories() const
{ {
return m_expandedDirs.values().toSet(); return m_expandedDirs.values().toSet();
} }
void KFileItemModel::restoreExpandedDirectories(const QSet<KUrl>& urls) void KFileItemModel::restoreExpandedDirectories(const QSet<QUrl> &urls)
{ {
m_urlsToExpand = urls; m_urlsToExpand = urls;
} }
void KFileItemModel::expandParentDirectories(const KUrl& url) void KFileItemModel::expandParentDirectories(const QUrl &url)
{ {
const int pos = m_dirLister->url().path().length(); const int pos = m_dirLister->url().path().length();
@ -620,7 +620,7 @@ void KFileItemModel::expandParentDirectories(const KUrl& url)
// KDirLister::open() must called at least once to trigger an initial // KDirLister::open() must called at least once to trigger an initial
// loading. The pending URLs that must be restored are handled // loading. The pending URLs that must be restored are handled
// in slotCompleted(). // in slotCompleted().
QSetIterator<KUrl> it2(m_urlsToExpand); QSetIterator<QUrl> it2(m_urlsToExpand);
while (it2.hasNext()) { while (it2.hasNext()) {
const int idx = index(it2.next()); const int idx = index(it2.next());
if (idx >= 0 && !isExpanded(idx)) { if (idx >= 0 && !isExpanded(idx)) {
@ -898,7 +898,7 @@ void KFileItemModel::slotCanceled()
emit directoryLoadingCanceled(); emit directoryLoadingCanceled();
} }
void KFileItemModel::slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items) void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemList& items)
{ {
Q_ASSERT(!items.isEmpty()); Q_ASSERT(!items.isEmpty());

View file

@ -56,13 +56,13 @@ public:
* indicate the current state of the loading process. The items * indicate the current state of the loading process. The items
* of the directory are added after the loading has been completed. * of the directory are added after the loading has been completed.
*/ */
void loadDirectory(const KUrl& url); void loadDirectory(const QUrl& url);
/** /**
* Throws away all currently loaded items and refreshes the directory * Throws away all currently loaded items and refreshes the directory
* by reloading all items again. * by reloading all items again.
*/ */
void refreshDirectory(const KUrl& url); void refreshDirectory(const QUrl& url);
/** /**
* @return Parent directory of the items that are shown. In case * @return Parent directory of the items that are shown. In case
@ -70,7 +70,7 @@ public:
* the root-parent of all items. * the root-parent of all items.
* @see rootItem() * @see rootItem()
*/ */
KUrl directory() const; QUrl directory() const;
/** /**
* Cancels the loading of a directory which has been started by either * Cancels the loading of a directory which has been started by either
@ -126,7 +126,7 @@ public:
* URL is found KFileItem::isNull() will be true for the returned * URL is found KFileItem::isNull() will be true for the returned
* file-item. The runtime complexity of this call is O(1). * file-item. The runtime complexity of this call is O(1).
*/ */
KFileItem fileItem(const KUrl& url) const; KFileItem fileItem(const QUrl& url) const;
/** /**
* @return The index for the file-item \a item. -1 is returned if no file-item * @return The index for the file-item \a item. -1 is returned if no file-item
@ -139,7 +139,7 @@ public:
* @return The index for the URL \a url. -1 is returned if no file-item * @return The index for the URL \a url. -1 is returned if no file-item
* is found. The amortized runtime complexity of this call is O(1). * is found. The amortized runtime complexity of this call is O(1).
*/ */
int index(const KUrl& url) const; int index(const QUrl &url) const;
/** /**
* @return Root item of all items representing the item * @return Root item of all items representing the item
@ -163,19 +163,19 @@ public:
virtual bool isExpandable(int index) const; virtual bool isExpandable(int index) const;
virtual int expandedParentsCount(int index) const; virtual int expandedParentsCount(int index) const;
QSet<KUrl> expandedDirectories() const; QSet<QUrl> expandedDirectories() const;
/** /**
* Marks the URLs in \a urls as sub-directories which were expanded previously. * Marks the URLs in \a urls as sub-directories which were expanded previously.
* After calling loadDirectory() or refreshDirectory() the marked sub-directories * After calling loadDirectory() or refreshDirectory() the marked sub-directories
* will be expanded step-by-step. * will be expanded step-by-step.
*/ */
void restoreExpandedDirectories(const QSet<KUrl>& urls); void restoreExpandedDirectories(const QSet<QUrl>& urls);
/** /**
* Expands all parent-directories of the item \a url. * Expands all parent-directories of the item \a url.
*/ */
void expandParentDirectories(const KUrl& url); void expandParentDirectories(const QUrl& url);
void setNameFilter(const QString& nameFilter); void setNameFilter(const QString& nameFilter);
QString nameFilter() const; QString nameFilter() const;
@ -251,13 +251,13 @@ signals:
* Is emitted if a redirection from the current URL \a oldUrl * Is emitted if a redirection from the current URL \a oldUrl
* to the new URL \a newUrl has been done. * to the new URL \a newUrl has been done.
*/ */
void directoryRedirection(const KUrl& oldUrl, const KUrl& newUrl); void directoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/** /**
* Is emitted when the URL passed by KFileItemModel::setUrl() represents a file. * Is emitted when the URL passed by KFileItemModel::setUrl() represents a file.
* In this case no signal errorMessage() will be emitted. * In this case no signal errorMessage() will be emitted.
*/ */
void urlIsFileError(const KUrl& url); void urlIsFileError(const QUrl& url);
protected: protected:
virtual void onGroupedSortingChanged(bool current); virtual void onGroupedSortingChanged(bool current);
@ -273,7 +273,7 @@ private slots:
void slotCompleted(); void slotCompleted();
void slotCanceled(); void slotCanceled();
void slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items); void slotItemsAdded(const QUrl& directoryUrl, const KFileItemList& items);
void slotItemsDeleted(const KFileItemList& items); void slotItemsDeleted(const KFileItemList& items);
void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items); void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items);
void slotClear(); void slotClear();
@ -489,11 +489,11 @@ private:
mutable QList<QPair<int, QVariant> > m_groups; mutable QList<QPair<int, QVariant> > m_groups;
// Stores the URLs (key: target url, value: url) of the expanded directories. // Stores the URLs (key: target url, value: url) of the expanded directories.
QHash<KUrl, KUrl> m_expandedDirs; QHash<QUrl, QUrl> m_expandedDirs;
// URLs that must be expanded. The expanding is initially triggered in setExpanded() // URLs that must be expanded. The expanding is initially triggered in setExpanded()
// and done step after step in slotCompleted(). // and done step after step in slotCompleted().
QSet<KUrl> m_urlsToExpand; QSet<QUrl> m_urlsToExpand;
friend class KFileItemModelLessThan; // Accesses lessThan() method friend class KFileItemModelLessThan; // Accesses lessThan() method
friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method

View file

@ -404,8 +404,9 @@ void KFileItemModelTest::testResortAfterChangingName()
// We rename d.txt back to a.txt using the dir lister's refreshItems() signal. // We rename d.txt back to a.txt using the dir lister's refreshItems() signal.
const KFileItem fileItemD = m_model->fileItem(2); const KFileItem fileItemD = m_model->fileItem(2);
KFileItem fileItemA = fileItemD; KFileItem fileItemA = fileItemD;
KUrl urlA = fileItemA.url(); QUrl urlA = fileItemA.url();
urlA.setFileName("a.txt"); urlA.adjusted(QUrl::RemoveFilename);
urlA.setPath(urlA.path() + "a.txt");
fileItemA.setUrl(urlA); fileItemA.setUrl(urlA);
m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemD, fileItemA)); m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemD, fileItemA));
@ -516,8 +517,10 @@ void KFileItemModelTest::testExpandItems()
m_testDir->createFiles(files); m_testDir->createFiles(files);
// Store the URLs of all folders in a set. // Store the URLs of all folders in a set.
QSet<KUrl> allFolders; QSet<QUrl> allFolders;
allFolders << KUrl(m_testDir->name() + 'a') << KUrl(m_testDir->name() + "a/a") << KUrl(m_testDir->name() + "a/a-1"); allFolders << QUrl::fromLocalFile(m_testDir->name() + 'a')
<< QUrl::fromLocalFile(m_testDir->name() + "a/a")
<< QUrl::fromLocalFile(m_testDir->name() + "a/a-1");
m_model->loadDirectory(m_testDir->url()); m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
@ -535,7 +538,7 @@ void KFileItemModelTest::testExpandItems()
QVERIFY(m_model->isExpanded(0)); QVERIFY(m_model->isExpanded(0));
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/a/", "a/a-1/" QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/a/", "a/a-1/"
QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + 'a')); QCOMPARE(m_model->expandedDirectories(), QSet<QUrl>() << QUrl(m_testDir->name() + 'a'));
QCOMPARE(spyInserted.count(), 1); QCOMPARE(spyInserted.count(), 1);
KItemRangeList itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>(); KItemRangeList itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
@ -551,7 +554,7 @@ void KFileItemModelTest::testExpandItems()
QVERIFY(m_model->isExpanded(1)); QVERIFY(m_model->isExpanded(1));
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 4); // 4 items: "a/", "a/a/", "a/a/1", "a/a-1/" QCOMPARE(m_model->count(), 4); // 4 items: "a/", "a/a/", "a/a/1", "a/a-1/"
QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + 'a') << KUrl(m_testDir->name() + "a/a")); QCOMPARE(m_model->expandedDirectories(), QSet<QUrl>() << QUrl(m_testDir->name() + 'a') << QUrl(m_testDir->name() + "a/a"));
QCOMPARE(spyInserted.count(), 1); QCOMPARE(spyInserted.count(), 1);
itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>(); itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
@ -580,7 +583,7 @@ void KFileItemModelTest::testExpandItems()
m_model->setExpanded(0, false); m_model->setExpanded(0, false);
QVERIFY(!m_model->isExpanded(0)); QVERIFY(!m_model->isExpanded(0));
QCOMPARE(m_model->count(), 1); QCOMPARE(m_model->count(), 1);
QVERIFY(!m_model->expandedDirectories().contains(KUrl(m_testDir->name() + 'a'))); // TODO: Make sure that child URLs are also removed QVERIFY(!m_model->expandedDirectories().contains(QUrl(m_testDir->name() + 'a'))); // TODO: Make sure that child URLs are also removed
QCOMPARE(spyRemoved.count(), 1); QCOMPARE(spyRemoved.count(), 1);
itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>(); itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>();
@ -606,7 +609,7 @@ void KFileItemModelTest::testExpandItems()
// Move to a sub folder, then call restoreExpandedFolders() *before* going back. // Move to a sub folder, then call restoreExpandedFolders() *before* going back.
// This is how DolphinView restores the expanded folders when navigating in history. // This is how DolphinView restores the expanded folders when navigating in history.
m_model->loadDirectory(KUrl(m_testDir->name() + "a/a/")); m_model->loadDirectory(QUrl(m_testDir->name() + "a/a/"));
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
QCOMPARE(m_model->count(), 1); // 1 item: "1" QCOMPARE(m_model->count(), 1); // 1 item: "1"
m_model->restoreExpandedDirectories(allFolders); m_model->restoreExpandedDirectories(allFolders);
@ -620,7 +623,7 @@ void KFileItemModelTest::testExpandItems()
m_model->setRoles(originalModelRoles); m_model->setRoles(originalModelRoles);
QVERIFY(!m_model->isExpanded(0)); QVERIFY(!m_model->isExpanded(0));
QCOMPARE(m_model->count(), 1); QCOMPARE(m_model->count(), 1);
QVERIFY(!m_model->expandedDirectories().contains(KUrl(m_testDir->name() + 'a'))); QVERIFY(!m_model->expandedDirectories().contains(QUrl(m_testDir->name() + 'a')));
QCOMPARE(spyRemoved.count(), 1); QCOMPARE(spyRemoved.count(), 1);
itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>(); itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>();
@ -654,7 +657,7 @@ void KFileItemModelTest::testExpandParentItems()
QVERIFY(m_model->expandedDirectories().empty()); QVERIFY(m_model->expandedDirectories().empty());
// Expand the parents of "a2/b2/c2". // Expand the parents of "a2/b2/c2".
m_model->expandParentDirectories(KUrl(m_testDir->name() + "a2/b2/c2")); m_model->expandParentDirectories(QUrl(m_testDir->name() + "a2/b2/c2"));
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
// The model should now contain "a 1/", "a2/", "a2/b2/", and "a2/b2/c2/". // The model should now contain "a 1/", "a2/", "a2/b2/", and "a2/b2/c2/".
@ -666,7 +669,7 @@ void KFileItemModelTest::testExpandParentItems()
QVERIFY(!m_model->isExpanded(3)); QVERIFY(!m_model->isExpanded(3));
// Expand the parents of "a 1/b1". // Expand the parents of "a 1/b1".
m_model->expandParentDirectories(KUrl(m_testDir->name() + "a 1/b1")); m_model->expandParentDirectories(QUrl(m_testDir->name() + "a 1/b1"));
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
// The model should now contain "a 1/", "a 1/b1/", "a2/", "a2/b2", and "a2/b2/c2/". // The model should now contain "a 1/", "a 1/b1/", "a2/", "a2/b2", and "a2/b2/c2/".
@ -822,11 +825,11 @@ void KFileItemModelTest::testSorting()
m_model->loadDirectory(m_testDir->url()); m_model->loadDirectory(m_testDir->url());
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
int index = m_model->index(KUrl(m_testDir->url().url() + 'c')); int index = m_model->index(QUrl(m_testDir->url().url() + 'c'));
m_model->setExpanded(index, true); m_model->setExpanded(index, true);
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
index = m_model->index(KUrl(m_testDir->url().url() + "c/c-2")); index = m_model->index(QUrl(m_testDir->url().url() + "c/c-2"));
m_model->setExpanded(index, true); m_model->setExpanded(index, true);
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
@ -1021,10 +1024,10 @@ void KFileItemModelTest::testEmptyPath()
roles.insert("expandedParentsCount"); roles.insert("expandedParentsCount");
m_model->setRoles(roles); m_model->setRoles(roles);
const KUrl emptyUrl; const QUrl emptyUrl;
QVERIFY(emptyUrl.path().isEmpty()); QVERIFY(emptyUrl.path().isEmpty());
const KUrl url("file:///test/"); const QUrl url("file:///test/");
KFileItemList items; KFileItemList items;
items << KFileItem(emptyUrl, QString(), KFileItem::Unknown) << KFileItem(url, QString(), KFileItem::Unknown); items << KFileItem(emptyUrl, QString(), KFileItem::Unknown) << KFileItem(url, QString(), KFileItem::Unknown);
@ -1251,28 +1254,28 @@ void KFileItemModelTest::testGeneralParentChildRelationships()
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "parent2" << "realChild2" << "realGrandChild2"); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "parent2" << "realChild2" << "realGrandChild2");
// Add some more children and grand-children. // Add some more children and grand-children.
const KUrl parent1 = m_model->fileItem(0).url(); const QUrl parent1 = m_model->fileItem(0).url();
const KUrl parent2 = m_model->fileItem(3).url(); const QUrl parent2 = m_model->fileItem(3).url();
const KUrl realChild1 = m_model->fileItem(1).url(); const QUrl realChild1 = m_model->fileItem(1).url();
const KUrl realChild2 = m_model->fileItem(4).url(); const QUrl realChild2 = m_model->fileItem(4).url();
m_model->slotItemsAdded(parent1, KFileItemList() << KFileItem(KUrl("child1"), QString(), KFileItem::Unknown)); m_model->slotItemsAdded(parent1, KFileItemList() << KFileItem(QUrl("child1"), QString(), KFileItem::Unknown));
m_model->slotCompleted(); m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2"); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2");
m_model->slotItemsAdded(parent2, KFileItemList() << KFileItem(KUrl("child2"), QString(), KFileItem::Unknown)); m_model->slotItemsAdded(parent2, KFileItemList() << KFileItem(QUrl("child2"), QString(), KFileItem::Unknown));
m_model->slotCompleted(); m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2"); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2");
m_model->slotItemsAdded(realChild1, KFileItemList() << KFileItem(KUrl("grandChild1"), QString(), KFileItem::Unknown)); m_model->slotItemsAdded(realChild1, KFileItemList() << KFileItem(QUrl("grandChild1"), QString(), KFileItem::Unknown));
m_model->slotCompleted(); m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2"); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2");
m_model->slotItemsAdded(realChild1, KFileItemList() << KFileItem(KUrl("grandChild1"), QString(), KFileItem::Unknown)); m_model->slotItemsAdded(realChild1, KFileItemList() << KFileItem(QUrl("grandChild1"), QString(), KFileItem::Unknown));
m_model->slotCompleted(); m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2"); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2");
m_model->slotItemsAdded(realChild2, KFileItemList() << KFileItem(KUrl("grandChild2"), QString(), KFileItem::Unknown)); m_model->slotItemsAdded(realChild2, KFileItemList() << KFileItem(QUrl("grandChild2"), QString(), KFileItem::Unknown));
m_model->slotCompleted(); m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "grandChild2" << "realGrandChild2" << "child2"); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "grandChild2" << "realGrandChild2" << "child2");
@ -1355,8 +1358,9 @@ void KFileItemModelTest::testNameRoleGroups()
// Change d.txt back to c.txt, but this time using the dir lister's refreshItems() signal. // Change d.txt back to c.txt, but this time using the dir lister's refreshItems() signal.
const KFileItem fileItemD = m_model->fileItem(2); const KFileItem fileItemD = m_model->fileItem(2);
KFileItem fileItemC = fileItemD; KFileItem fileItemC = fileItemD;
KUrl urlC = fileItemC.url(); QUrl urlC = fileItemC.url();
urlC.setFileName("c.txt"); urlC.adjusted(QUrl::RemoveFilename);
urlC.setPath(urlC.path() + "c.txt");
fileItemC.setUrl(urlC); fileItemC.setUrl(urlC);
m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemD, fileItemC)); m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemD, fileItemC));
@ -1445,7 +1449,7 @@ void KFileItemModelTest::testInconsistentModel()
// Note that the first item in the list of added items must be new (i.e., not // Note that the first item in the list of added items must be new (i.e., not
// in the model yet). Otherwise, KFileItemModel::slotItemsAdded() will see that // in the model yet). Otherwise, KFileItemModel::slotItemsAdded() will see that
// it receives items that are in the model already and ignore them. // it receives items that are in the model already and ignore them.
KUrl url(m_model->directory().url() + "/a2"); QUrl url(m_model->directory().url() + "/a2");
KFileItem newItem(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem newItem(KFileItem::Unknown, KFileItem::Unknown, url);
KFileItemList items; KFileItemList items;
@ -1582,8 +1586,9 @@ void KFileItemModelTest::testRefreshFilteredItems()
// Rename one of the .jpg files. // Rename one of the .jpg files.
KFileItem fileItemE = fileItemC; KFileItem fileItemE = fileItemC;
KUrl urlE = fileItemE.url(); QUrl urlE = fileItemE.url();
urlE.setFileName("e.jpg"); urlE.adjusted(QUrl::RemoveFilename);
urlE.setPath(urlE.path() + "e.jpg");
fileItemE.setUrl(urlE); fileItemE.setUrl(urlE);
m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemC, fileItemE)); m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemC, fileItemE));
@ -1650,11 +1655,12 @@ void KFileItemModelTest::testCollapseFolderWhileLoading()
// signal is not emitted yet. // signal is not emitted yet.
const KFileItem fileItemC1 = m_model->fileItem(2); const KFileItem fileItemC1 = m_model->fileItem(2);
KFileItem fileItemC2 = fileItemC1; KFileItem fileItemC2 = fileItemC1;
KUrl urlC2 = fileItemC2.url(); QUrl urlC2 = fileItemC2.url();
urlC2.setFileName("c2.txt"); urlC2.adjusted(QUrl::RemoveFilename);
urlC2.setPath(urlC2.path() + "c2.txt");
fileItemC2.setUrl(urlC2); fileItemC2.setUrl(urlC2);
const KUrl urlB = m_model->fileItem(1).url(); const QUrl urlB = m_model->fileItem(1).url();
m_model->slotItemsAdded(urlB, KFileItemList() << fileItemC2); m_model->slotItemsAdded(urlB, KFileItemList() << fileItemC2);
QCOMPARE(itemsInModel(), QStringList() << "a2" << "b" << "c1.txt"); QCOMPARE(itemsInModel(), QStringList() << "a2" << "b" << "c1.txt");
@ -1681,8 +1687,9 @@ void KFileItemModelTest::testCollapseFolderWhileLoading()
// completed() signal is not emitted yet. // completed() signal is not emitted yet.
const KFileItem fileItemA2 = m_model->fileItem(0); const KFileItem fileItemA2 = m_model->fileItem(0);
KFileItem fileItemA1 = fileItemA2; KFileItem fileItemA1 = fileItemA2;
KUrl urlA1 = fileItemA1.url(); QUrl urlA1 = fileItemA1.url();
urlA1.setFileName("a1"); urlA1.adjusted(QUrl::RemoveFilename);
urlA1.setPath(urlA1.path() + "a1");
fileItemA1.setUrl(urlA1); fileItemA1.setUrl(urlA1);
m_model->slotItemsAdded(m_model->directory(), KFileItemList() << fileItemA1); m_model->slotItemsAdded(m_model->directory(), KFileItemList() << fileItemA1);

View file

@ -80,7 +80,7 @@ namespace {
const int MaxModeEnum = DolphinView::CompactView; const int MaxModeEnum = DolphinView::CompactView;
}; };
DolphinView::DolphinView(const KUrl& url, QWidget* parent) : DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
QWidget(parent), QWidget(parent),
m_active(true), m_active(true),
m_tabsForFiles(false), m_tabsForFiles(false),
@ -203,7 +203,7 @@ DolphinView::~DolphinView()
{ {
} }
KUrl DolphinView::url() const QUrl DolphinView::url() const
{ {
return m_url; return m_url;
} }
@ -362,12 +362,12 @@ int DolphinView::selectedItemsCount() const
return selectionManager->selectedItems().count(); return selectionManager->selectedItems().count();
} }
void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls) void DolphinView::markUrlsAsSelected(const QList<QUrl>& urls)
{ {
m_selectedUrls = urls; m_selectedUrls = urls;
} }
void DolphinView::markUrlAsCurrent(const KUrl& url) void DolphinView::markUrlAsCurrent(const QUrl &url)
{ {
m_currentItemUrl = url; m_currentItemUrl = url;
m_scrollToCurrentItem = true; m_scrollToCurrentItem = true;
@ -1049,7 +1049,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
// Mark the dropped urls as selected. // Mark the dropped urls as selected.
m_clearSelectionBeforeSelectingNewItems = true; m_clearSelectionBeforeSelectingNewItems = true;
m_markFirstNewlySelectedItemAsCurrent = true; m_markFirstNewlySelectedItemAsCurrent = true;
connect(op, static_cast<void(KonqOperations::*)(const KUrl::List&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate); connect(op, static_cast<void(KonqOperations::*)(const QList<QUrl>&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate);
} }
setActive(true); 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<QUrl>& urls)
{ {
if (!urls.isEmpty()) { if (!urls.isEmpty()) {
if (m_markFirstNewlySelectedItemAsCurrent) { if (m_markFirstNewlySelectedItemAsCurrent) {
markUrlAsCurrent(urls.first()); markUrlAsCurrent(urls.first());
m_markFirstNewlySelectedItemAsCurrent = false; m_markFirstNewlySelectedItemAsCurrent = false;
} }
m_selectedUrls << KUrl::List(KDirModel::simplifiedUrlList(urls)); m_selectedUrls << KDirModel::simplifiedUrlList(urls);
} }
} }
@ -1184,7 +1184,7 @@ void DolphinView::restoreState(QDataStream& stream)
stream >> m_restoredContentsPosition; stream >> m_restoredContentsPosition;
// Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes) // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
QSet<KUrl> urls; QSet<QUrl> urls;
stream >> urls; stream >> urls;
m_model->restoreExpandedDirectories(urls); m_model->restoreExpandedDirectories(urls);
} }
@ -1271,18 +1271,18 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh
return KUrl(); return KUrl();
} }
void DolphinView::observeCreatedItem(const KUrl& url) void DolphinView::observeCreatedItem(const QUrl& url)
{ {
if (m_active) { if (m_active) {
clearSelection(); clearSelection();
markUrlAsCurrent(url); markUrlAsCurrent(url);
markUrlsAsSelected(QList<KUrl>() << url); markUrlsAsSelected(QList<QUrl>() << 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); emit redirection(oldUrl, newUrl);
m_url = newUrl; // #186947 m_url = newUrl; // #186947
} }
@ -1290,7 +1290,7 @@ void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUr
void DolphinView::updateViewState() void DolphinView::updateViewState()
{ {
if (m_currentItemUrl != KUrl()) { if (m_currentItemUrl != QUrl()) {
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
const int currentIndex = m_model->index(m_currentItemUrl); const int currentIndex = m_model->index(m_currentItemUrl);
if (currentIndex != -1) { if (currentIndex != -1) {
@ -1305,7 +1305,7 @@ void DolphinView::updateViewState()
selectionManager->setCurrentItem(0); selectionManager->setCurrentItem(0);
} }
m_currentItemUrl = KUrl(); m_currentItemUrl = QUrl();
} }
if (!m_restoredContentsPosition.isNull()) { if (!m_restoredContentsPosition.isNull()) {
@ -1327,7 +1327,7 @@ void DolphinView::updateViewState()
KItemSet selectedItems = selectionManager->selectedItems(); KItemSet selectedItems = selectionManager->selectedItems();
QList<KUrl>::iterator it = m_selectedUrls.begin(); QList<QUrl>::iterator it = m_selectedUrls.begin();
while (it != m_selectedUrls.end()) { while (it != m_selectedUrls.end()) {
const int index = m_model->index(*it); const int index = m_model->index(*it);
if (index >= 0) { if (index >= 0) {
@ -1389,7 +1389,7 @@ void DolphinView::slotRenamingResult(KJob* job)
KIO::CopyJob *copyJob = qobject_cast<KIO::CopyJob *>(job); KIO::CopyJob *copyJob = qobject_cast<KIO::CopyJob *>(job);
Q_ASSERT(copyJob); Q_ASSERT(copyJob);
const QUrl newUrl = copyJob->destUrl(); const QUrl newUrl = copyJob->destUrl();
const int index = m_model->index(KUrl(newUrl)); const int index = m_model->index(newUrl);
if (index >= 0) { if (index >= 0) {
QHash<QByteArray, QVariant> data; QHash<QByteArray, QVariant> data;
const QUrl oldUrl = copyJob->srcUrls().first(); const QUrl oldUrl = copyJob->srcUrls().first();
@ -1650,7 +1650,7 @@ void DolphinView::pasteToUrl(const KUrl& url)
if (op) { if (op) {
m_clearSelectionBeforeSelectingNewItems = true; m_clearSelectionBeforeSelectingNewItems = true;
m_markFirstNewlySelectedItemAsCurrent = true; m_markFirstNewlySelectedItemAsCurrent = true;
connect(op, static_cast<void(KonqOperations::*)(const KUrl::List&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate); connect(op, static_cast<void(KonqOperations::*)(const QList<QUrl>&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate);
} }
} }

View file

@ -92,7 +92,7 @@ public:
* @param url Specifies the content which should be shown. * @param url Specifies the content which should be shown.
* @param parent Parent widget of the view. * @param parent Parent widget of the view.
*/ */
DolphinView(const KUrl& url, QWidget* parent); DolphinView(const QUrl& url, QWidget* parent);
virtual ~DolphinView(); virtual ~DolphinView();
@ -100,7 +100,7 @@ public:
* Returns the current active URL, where all actions are applied. * Returns the current active URL, where all actions are applied.
* The URL navigator is synchronized with this URL. * The URL navigator is synchronized with this URL.
*/ */
KUrl url() const; QUrl url() const;
/** /**
* If \a active is true, the view will marked as active. The active * If \a active is true, the view will marked as active. The active
@ -173,13 +173,13 @@ public:
* gets selected if no loading of a directory has been triggered * gets selected if no loading of a directory has been triggered
* by DolphinView::setUrl() or DolphinView::reload(). * by DolphinView::setUrl() or DolphinView::reload().
*/ */
void markUrlsAsSelected(const QList<KUrl>& urls); void markUrlsAsSelected(const QList<QUrl> &urls);
/** /**
* Marks the item indicated by \p url to be scrolled to and as the * Marks the item indicated by \p url to be scrolled to and as the
* current item after directory DolphinView::url() has been loaded. * current item after directory DolphinView::url() has been loaded.
*/ */
void markUrlAsCurrent(const KUrl& url); void markUrlAsCurrent(const QUrl& url);
/** /**
* All items that match to the pattern \a pattern will get selected * All items that match to the pattern \a pattern will get selected
@ -573,7 +573,7 @@ private slots:
/* /*
* Is called when new items get pasted or dropped. * Is called when new items get pasted or dropped.
*/ */
void slotAboutToCreate(const KUrl::List& urls); void slotAboutToCreate(const QList<QUrl> &urls);
/** /**
* Emits the signal \a selectionChanged() with a small delay. This is * Emits the signal \a selectionChanged() with a small delay. This is
@ -669,13 +669,13 @@ private slots:
* model indicates that the item is available, the item will * model indicates that the item is available, the item will
* get selected and it is assured that the item stays visible. * get selected and it is assured that the item stays visible.
*/ */
void observeCreatedItem(const KUrl& url); void observeCreatedItem(const QUrl &url);
/** /**
* Called when a redirection happens. * Called when a redirection happens.
* Testcase: fish://localhost * Testcase: fish://localhost
*/ */
void slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl); void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/** /**
* Applies the state that has been restored by restoreViewState() * Applies the state that has been restored by restoreViewState()
@ -772,11 +772,11 @@ private:
QTimer* m_selectionChangedTimer; QTimer* m_selectionChangedTimer;
KUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5 QUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5
bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not
QPoint m_restoredContentsPosition; QPoint m_restoredContentsPosition;
QList<KUrl> m_selectedUrls; // Used for making the view to remember selections after F5 QList<QUrl> m_selectedUrls; // Used for making the view to remember selections after F5
bool m_clearSelectionBeforeSelectingNewItems; bool m_clearSelectionBeforeSelectingNewItems;
bool m_markFirstNewlySelectedItemAsCurrent; bool m_markFirstNewlySelectedItemAsCurrent;