From kde-commits Mon Apr 30 22:49:29 2012 From: David Faure Date: Mon, 30 Apr 2012 22:49:29 +0000 To: kde-commits Subject: [kdelibs/frameworks] /: Port KDirNotify to QList instead of QStringList Message-Id: <20120430224929.7E518A60A9 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=133582630610517 Git commit 6d3ebee139d27dac30762ad4cab9227c7e3ba625 by David Faure. Committed on 01/05/2012 at 00:26. Pushed by dfaure into branch 'frameworks'. Port KDirNotify to QList instead of QStringList (so that the calling code can be ported away from KUrl::List::toStringList) M +1 -1 kfile/kdiroperator.cpp M +1 -1 kio/kfile/kpropertiesdialog.cpp M +1 -1 kio/kio/copyjob.cpp M +6 -6 kio/kio/davjob.cpp M +4 -4 kio/kio/davjob.h M +13 -13 kio/kio/deletejob.cpp M +2 -2 kio/kio/deletejob.h M +2 -6 kio/kio/kautomount.cpp M +1 -1 kio/kio/kdesktopfileactions.cpp M +31 -14 kio/kio/kdirnotify.cpp M +21 -13 kio/kio/kdirnotify.h M +6 -6 kio/tests/jobtest.cpp M +3 -3 kio/tests/kdirlistertest.cpp M +3 -3 kio/tests/kdirmodeltest.cpp http://commits.kde.org/kdelibs/6d3ebee139d27dac30762ad4cab9227c7e3ba625 diff --git a/kfile/kdiroperator.cpp b/kfile/kdiroperator.cpp index 004f21c..480d722 100644 --- a/kfile/kdiroperator.cpp +++ b/kfile/kdiroperator.cpp @@ -787,7 +787,7 @@ KIO::DeleteJob * KDirOperator::del(const KFileItemList&= items, parent =3D this; } = - QList urls; + QList urls; QStringList files; foreach (const KFileItem &item, items) { const KUrl url =3D item.url(); diff --git a/kio/kfile/kpropertiesdialog.cpp b/kio/kfile/kpropertiesdialog.= cpp index 2347eff..95f5647 100644 --- a/kio/kfile/kpropertiesdialog.cpp +++ b/kio/kfile/kpropertiesdialog.cpp @@ -1509,7 +1509,7 @@ void KFilePropsPlugin::postApplyChanges() = const KFileItemList items =3D properties->items(); const QList lst =3D items.urlList(); - org::kde::KDirNotify::emitFilesChanged( KUrl::List(lst).toStringList()= ); + org::kde::KDirNotify::emitFilesChanged(KUrl::List(lst)); } = class KFilePermissionsPropsPlugin::KFilePermissionsPropsPluginPrivate diff --git a/kio/kio/copyjob.cpp b/kio/kio/copyjob.cpp index e654f36..8ce2461 100644 --- a/kio/kio/copyjob.cpp +++ b/kio/kio/copyjob.cpp @@ -1744,7 +1744,7 @@ void CopyJob::emitResult() = if (d->m_mode =3D=3D CopyJob::Move && !d->m_successSrcList.isEmpty= ()) { kDebug(7007) << "KDirNotify'ing FilesRemoved" << d->m_successS= rcList.toStringList(); - org::kde::KDirNotify::emitFilesRemoved(d->m_successSrcList.toS= tringList()); + org::kde::KDirNotify::emitFilesRemoved(d->m_successSrcList); } = // Re-enable watching on the dirs that held the deleted files diff --git a/kio/kio/davjob.cpp b/kio/kio/davjob.cpp index 7a4dea6..7feaf35 100644 --- a/kio/kio/davjob.cpp +++ b/kio/kio/davjob.cpp @@ -47,7 +47,7 @@ using namespace KIO; class KIO::DavJobPrivate: public KIO::TransferJobPrivate { public: - DavJobPrivate(const KUrl& url) + DavJobPrivate(const QUrl& url) : TransferJobPrivate(url, KIO::CMD_SPECIAL, QByteArray(), QByteArr= ay()) {} QByteArray savedStaticData; @@ -58,7 +58,7 @@ public: = Q_DECLARE_PUBLIC(DavJob) = - static inline DavJob *newJob(const KUrl &url, int method, const QStrin= g &request, + static inline DavJob *newJob(const QUrl &url, int method, const QStrin= g &request, JobFlags flags) { DavJob *job =3D new DavJob(*new DavJobPrivate(url), method, reques= t); @@ -141,7 +141,7 @@ void DavJob::slotFinished() = /* Convenience methods */ = -DavJob* KIO::davPropFind( const KUrl& url, const QDomDocument& properties,= const QString &depth, JobFlags flags ) +DavJob* KIO::davPropFind( const QUrl& url, const QDomDocument& properties,= const QString &depth, JobFlags flags ) { DavJob *job =3D DavJobPrivate::newJob(url, (int) KIO::DAV_PROPFIND, pr= operties.toString(), flags); job->addMetaData( "davDepth", depth ); @@ -149,13 +149,13 @@ DavJob* KIO::davPropFind( const KUrl& url, const QDom= Document& properties, const } = = -DavJob* KIO::davPropPatch( const KUrl& url, const QDomDocument& properties= , JobFlags flags ) +DavJob* KIO::davPropPatch( const QUrl& url, const QDomDocument& properties= , JobFlags flags ) { return DavJobPrivate::newJob(url, (int) KIO::DAV_PROPPATCH, properties= .toString(), flags); } = -DavJob* KIO::davSearch( const KUrl& url, const QString& nsURI, const QStri= ng& qName, const QString& query, JobFlags flags ) +DavJob* KIO::davSearch( const QUrl& url, const QString& nsURI, const QStri= ng& qName, const QString& query, JobFlags flags ) { QDomDocument doc; QDomElement searchrequest =3D doc.createElementNS( "DAV:", "searchreques= t" ); @@ -167,7 +167,7 @@ DavJob* KIO::davSearch( const KUrl& url, const QString&= nsURI, const QString& qN return DavJobPrivate::newJob(url, KIO::DAV_SEARCH, doc.toString(), flags= ); } = -DavJob* KIO::davReport( const KUrl& url, const QString& report, const QStr= ing &depth, JobFlags flags ) +DavJob* KIO::davReport( const QUrl& url, const QString& report, const QStr= ing &depth, JobFlags flags ) { DavJob *job =3D DavJobPrivate::newJob(url, (int) KIO::DAV_REPORT, repo= rt, flags); job->addMetaData( "davDepth", depth ); diff --git a/kio/kio/davjob.h b/kio/kio/davjob.h index 0b141be..bd4742e 100644 --- a/kio/kio/davjob.h +++ b/kio/kio/davjob.h @@ -81,7 +81,7 @@ namespace KIO { * @param flags: We support HideProgressInfo here * @return the new DavJob */ - KIO_EXPORT DavJob* davPropFind( const KUrl& url, const QDomDocument& pr= operties, const QString &depth, JobFlags flags =3D DefaultFlags ); + KIO_EXPORT DavJob* davPropFind( const QUrl& url, const QDomDocument& pr= operties, const QString &depth, JobFlags flags =3D DefaultFlags ); = /** * Creates a new DavJob that issues a PROPPATCH command. PROPPATCH sets @@ -93,7 +93,7 @@ namespace KIO { * @param flags: We support HideProgressInfo here * @return the new DavJob */ - KIO_EXPORT DavJob* davPropPatch( const KUrl& url, const QDomDocument& p= roperties, JobFlags flags =3D DefaultFlags ); + KIO_EXPORT DavJob* davPropPatch( const QUrl& url, const QDomDocument& p= roperties, JobFlags flags =3D DefaultFlags ); = /** * Creates a new DavJob that issues a SEARCH command. @@ -105,7 +105,7 @@ namespace KIO { * @param flags: We support HideProgressInfo here * @return the new DavJob */ - KIO_EXPORT DavJob* davSearch( const KUrl &url, const QString& nsURI, co= nst QString& qName, const QString& query, JobFlags flags =3D DefaultFlags ); + KIO_EXPORT DavJob* davSearch( const QUrl &url, const QString& nsURI, co= nst QString& qName, const QString& query, JobFlags flags =3D DefaultFlags ); = /** * Creates a new DavJob that issues a REPORT command. @@ -117,7 +117,7 @@ namespace KIO { * @return the new DavJob * @since 4.4 */ - KIO_EXPORT DavJob* davReport( const KUrl& url, const QString& report, c= onst QString &depth, JobFlags flags =3D DefaultFlags ); + KIO_EXPORT DavJob* davReport( const QUrl& url, const QString& report, c= onst QString &depth, JobFlags flags =3D DefaultFlags ); = } = diff --git a/kio/kio/deletejob.cpp b/kio/kio/deletejob.cpp index 03586ef..679803e 100644 --- a/kio/kio/deletejob.cpp +++ b/kio/kio/deletejob.cpp @@ -65,7 +65,7 @@ namespace KIO class DeleteJobPrivate: public KIO::JobPrivate { public: - DeleteJobPrivate(const KUrl::List& src) + DeleteJobPrivate(const QList& src) : state( DELETEJOB_STATE_STATING ) , m_processedFiles( 0 ) , m_processedDirs( 0 ) @@ -80,11 +80,11 @@ namespace KIO int m_processedDirs; int m_totalFilesDirs; KUrl m_currentURL; - KUrl::List files; - KUrl::List symlinks; - KUrl::List dirs; - KUrl::List m_srcList; - KUrl::List::iterator m_currentStat; + QList files; + QList symlinks; + QList dirs; + QList m_srcList; + QList::iterator m_currentStat; QSet m_parentDirs; QTimer *m_reportTimer; = @@ -99,7 +99,7 @@ namespace KIO = Q_DECLARE_PUBLIC(DeleteJob) = - static inline DeleteJob *newJob(const KUrl::List &src, JobFlags fl= ags) + static inline DeleteJob *newJob(const QList &src, JobFlags f= lags) { DeleteJob *job =3D new DeleteJob(*new DeleteJobPrivate(src)); job->setUiDelegate(new JobUiDelegate); @@ -128,7 +128,7 @@ DeleteJob::~DeleteJob() { } = -KUrl::List DeleteJob::urls() const +QList DeleteJob::urls() const { return d_func()->m_srcList; } @@ -277,7 +277,7 @@ void DeleteJobPrivate::deleteNextFile() SimpleJob *job; do { // Take first file to delete out of list - KUrl::List::iterator it =3D files.begin(); + QList::iterator it =3D files.begin(); bool isLink =3D false; if ( it =3D=3D files.end() ) // No more files { @@ -330,7 +330,7 @@ void DeleteJobPrivate::deleteNextDir() { do { // Take first dir to delete out of list - last ones first ! - KUrl::List::iterator it =3D --dirs.end(); + QList::iterator it =3D --dirs.end(); // If local dir, try to rmdir it directly #ifdef Q_WS_WIN if ( (*it).isLocalFile() && RemoveDirectoryW( (LPCWSTR)(*it).t= oLocalFile().utf16() ) !=3D 0 ) { @@ -366,7 +366,7 @@ void DeleteJobPrivate::deleteNextDir() if ( !m_srcList.isEmpty() ) { //kDebug(7007) << "KDirNotify'ing FilesRemoved " << m_srcList.toSt= ringList(); - org::kde::KDirNotify::emitFilesRemoved( m_srcList.toStringList() ); + org::kde::KDirNotify::emitFilesRemoved(m_srcList); } if (m_reportTimer!=3D0) m_reportTimer->stop(); @@ -483,12 +483,12 @@ void DeleteJob::slotResult( KJob *job ) = DeleteJob *KIO::del( const KUrl& src, JobFlags flags ) { - KUrl::List srcList; + QList srcList; srcList.append( src ); return DeleteJobPrivate::newJob(srcList, flags); } = -DeleteJob *KIO::del( const KUrl::List& src, JobFlags flags ) +DeleteJob *KIO::del( const QList& src, JobFlags flags ) { return DeleteJobPrivate::newJob(src, flags); } diff --git a/kio/kio/deletejob.h b/kio/kio/deletejob.h index eaba4be..6212c03 100644 --- a/kio/kio/deletejob.h +++ b/kio/kio/deletejob.h @@ -50,7 +50,7 @@ namespace KIO { * Returns the list of URLs. * @return the list of URLs. */ - KUrl::List urls() const; + QList urls() const; = Q_SIGNALS: = @@ -117,7 +117,7 @@ namespace KIO { * @param flags: We support HideProgressInfo here * @return the job handling the operation */ - KIO_EXPORT DeleteJob *del( const KUrl::List& src, JobFlags flags =3D D= efaultFlags ); + KIO_EXPORT DeleteJob *del( const QList& src, JobFlags flags =3D = DefaultFlags ); } = #endif diff --git a/kio/kio/kautomount.cpp b/kio/kio/kautomount.cpp index 872a025..5768940 100644 --- a/kio/kio/kautomount.cpp +++ b/kio/kio/kautomount.cpp @@ -84,9 +84,7 @@ void KAutoMountPrivate::slotResult( KJob * job ) = // Update the desktop file which is used for mount/unmount (icon c= hange) kDebug(7015) << " mount finished : updating " << m_desktopFile; - KUrl dfURL; - dfURL.setPath( m_desktopFile ); - org::kde::KDirNotify::emitFilesChanged( QStringList() << dfURL.url= () ); + org::kde::KDirNotify::emitFilesChanged(QList() << QUrl::from= LocalFile(m_desktopFile)); //KDirWatch::self()->setFileDirty( m_desktopFile ); = emit q->finished(); @@ -124,9 +122,7 @@ void KAutoUnmountPrivate::slotResult( KJob * job ) { // Update the desktop file which is used for mount/unmount (icon c= hange) kDebug(7015) << "unmount finished : updating " << m_desktopFile; - KUrl dfURL; - dfURL.setPath( m_desktopFile ); - org::kde::KDirNotify::emitFilesChanged( QStringList() << dfURL.url= () ); + org::kde::KDirNotify::emitFilesChanged(QList() << QUrl::from= LocalFile(m_desktopFile)); //KDirWatch::self()->setFileDirty( m_desktopFile ); = // Notify about the new stuff in that dir, in case of opened windo= ws showing it diff --git a/kio/kio/kdesktopfileactions.cpp b/kio/kio/kdesktopfileactions.= cpp index 3262abe..2a9f300 100644 --- a/kio/kio/kdesktopfileactions.cpp +++ b/kio/kio/kdesktopfileactions.cpp @@ -367,7 +367,7 @@ void KDesktopFileActions::executeService( const KUrl::L= ist& urls, const KService kDebug() << action.name() << "first url's path=3D" << urls.first()= .path() << "exec=3D" << action.exec(); KRun::run( action.exec(), urls, 0, action.text(), action.icon()); // The action may update the desktop file. Example: eject unmounts= (#5129). - org::kde::KDirNotify::emitFilesChanged( urls.toStringList() ); + org::kde::KDirNotify::emitFilesChanged(urls); } } = diff --git a/kio/kio/kdirnotify.cpp b/kio/kio/kdirnotify.cpp index 5f06b38..c10bcfb 100644 --- a/kio/kio/kdirnotify.cpp +++ b/kio/kio/kdirnotify.cpp @@ -1,13 +1,20 @@ -/* - * This file was generated by dbusxml2cpp version 0.6 - * Command line was: dbusxml2cpp -m -p kdirnotify -- org.kde.KDirNotify.xml - * - * dbusxml2cpp is Copyright (C) 2006 Trolltech AS. All rights reserved. - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ +/* This file is part of the KDE libraries + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public Lice= nse + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ = #include "kdirnotify.h" = @@ -47,14 +54,24 @@ void OrgKdeKDirNotifyInterface::emitFilesAdded(const QS= tring &directory) emitSignal(QLatin1String("FilesAdded"), QVariantList() << directory); } = -void OrgKdeKDirNotifyInterface::emitFilesChanged(const QStringList &fileLi= st) +static QStringList urlListToStringList(const QList &urls) +{ + QStringList lst; + for(QList::const_iterator it =3D urls.constBegin(); + it !=3D urls.constEnd(); ++it) { + lst.append(it->toString()); + } + return lst; +} + +void OrgKdeKDirNotifyInterface::emitFilesChanged(const QList &fileLi= st) { - emitSignal(QLatin1String("FilesChanged"), QVariantList() << QVariant(f= ileList)); + emitSignal(QLatin1String("FilesChanged"), QVariantList() << QVariant(u= rlListToStringList(fileList))); } = -void OrgKdeKDirNotifyInterface::emitFilesRemoved(const QStringList &fileLi= st) +void OrgKdeKDirNotifyInterface::emitFilesRemoved(const QList &fileLi= st) { - emitSignal(QLatin1String("FilesRemoved"), QVariantList() << QVariant(f= ileList)); + emitSignal(QLatin1String("FilesRemoved"), QVariantList() << QVariant(u= rlListToStringList(fileList))); } = void OrgKdeKDirNotifyInterface::emitEnteredDirectory(const QString &url) diff --git a/kio/kio/kdirnotify.h b/kio/kio/kdirnotify.h index 52f344e..17ed777 100644 --- a/kio/kio/kdirnotify.h +++ b/kio/kio/kdirnotify.h @@ -1,15 +1,23 @@ -/* - * This file was generated by dbusxml2cpp version 0.6 - * Command line was: dbusxml2cpp -m -p kdirnotify -- org.kde.KDirNotify.xml - * - * dbusxml2cpp is Copyright (C) 2006 Trolltech AS. All rights reserved. - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ +/* This file is part of the KDE libraries + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public Lice= nse + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ = -#ifndef KDIRNOTIFY_H_268161151672021 -#define KDIRNOTIFY_H_268161151672021 +#ifndef KDIRNOTIFY_H +#define KDIRNOTIFY_H = #include #include @@ -83,8 +91,8 @@ public: static void emitFileRenamed(const QString &src, const QString &dst); static void emitFileMoved(const QString &src, const QString &dst); static void emitFilesAdded(const QString &directory); - static void emitFilesChanged(const QStringList &fileList); - static void emitFilesRemoved(const QStringList &fileList); + static void emitFilesChanged(const QList &fileList); + static void emitFilesRemoved(const QList &fileList); static void emitEnteredDirectory(const QString &url); static void emitLeftDirectory(const QString &url); }; diff --git a/kio/tests/jobtest.cpp b/kio/tests/jobtest.cpp index 5946751..befe241 100644 --- a/kio/tests/jobtest.cpp +++ b/kio/tests/jobtest.cpp @@ -1226,11 +1226,11 @@ void JobTest::deleteManyDirs(bool using_fast_path) kio_resolve_local_urls =3D !using_fast_path; = const int numDirs =3D 50; - QList dirs; + QList dirs; for (int i =3D 0; i < numDirs; ++i) { const QString dir =3D homeTmpDir() + "dir" + QString::number(i); createTestDirectory(dir); - dirs << KUrl(dir); + dirs << QUrl::fromLocalFile(dir); } QTime dt; dt.start(); @@ -1238,8 +1238,8 @@ void JobTest::deleteManyDirs(bool using_fast_path) job->setUiDelegate(0); bool ok =3D KIO::NetAccess::synchronousRun(job, 0); QVERIFY(ok); - Q_FOREACH(const KUrl& dir, dirs) { - QVERIFY(!QFile::exists(dir.path())); + Q_FOREACH(const QUrl& dir, dirs) { + QVERIFY(!QFile::exists(dir.toLocalFile())); } = kDebug() << "Deleted" << numDirs << "dirs in" << dt.elapsed() << "mill= iseconds"; @@ -1292,11 +1292,11 @@ void JobTest::deleteManyFilesTogether(bool using_fa= st_path) const int numFiles =3D 100; // Use 1000 for performance testing const QString baseDir =3D homeTmpDir(); createManyFiles(baseDir, numFiles); - QList urls; + QList urls; for (int i =3D 0; i < numFiles; ++i) { const QString file =3D baseDir + QString::number(i); QVERIFY(QFile::exists(file)); - urls.append(KUrl(file)); + urls.append(QUrl::fromLocalFile(file)); } = //kDebug() << file; diff --git a/kio/tests/kdirlistertest.cpp b/kio/tests/kdirlistertest.cpp index 6362baf..741f636 100644 --- a/kio/tests/kdirlistertest.cpp +++ b/kio/tests/kdirlistertest.cpp @@ -385,7 +385,7 @@ void KDirListerTest::testRefreshRootItem() connect(&m_dirLister, SIGNAL(refreshItems(QList >)), this, SLOT(slotRefreshItems(QList >= ))); = - org::kde::KDirNotify::emitFilesChanged(QStringList() << KUrl(path).url= ()); + org::kde::KDirNotify::emitFilesChanged(QList() << QUrl::fromLoca= lFile(path)); waitForRefreshedItems(); = QCOMPARE(m_dirLister.spyStarted.count(), 0); @@ -416,10 +416,10 @@ void KDirListerTest::testRefreshRootItem() = org::kde::KDirNotify::emitFilesAdded(KUrl(path).url()); QTest::qWait(200); - org::kde::KDirNotify::emitFilesChanged(QStringList() << KUrl(directory= File).url()); + org::kde::KDirNotify::emitFilesChanged(QList() << QUrl::fromLoca= lFile(directoryFile)); QCOMPARE(m_refreshedItems.count(), 0); = - org::kde::KDirNotify::emitFilesChanged(QStringList() << KUrl(path).url= ()); + org::kde::KDirNotify::emitFilesChanged(QList() << QUrl::fromLoca= lFile(path)); waitForRefreshedItems(); QCOMPARE(m_refreshedItems.count(), 1); entry =3D m_refreshedItems.first(); diff --git a/kio/tests/kdirmodeltest.cpp b/kio/tests/kdirmodeltest.cpp index b0c9477..a5a0528 100644 --- a/kio/tests/kdirmodeltest.cpp +++ b/kio/tests/kdirmodeltest.cpp @@ -649,7 +649,7 @@ void KDirModelTest::testChmodDirectory() // #53397 QVERIFY(KIO::NetAccess::synchronousRun(job, 0)); // ChmodJob doesn't talk to KDirNotify, kpropertiesdialog does. // [this allows to group notifications after all the changes one can m= ake in the dialog] - org::kde::KDirNotify::emitFilesChanged( QStringList() << path ); + org::kde::KDirNotify::emitFilesChanged(QList() << QUrl::fromLoca= lFile(path)); // Wait for the DBUS signal from KDirNotify, it's the one the triggers= rowsRemoved enterLoop(); = @@ -1216,8 +1216,8 @@ void KDirModelTest::testDeleteFiles() { const int oldTopLevelRowCount =3D m_dirModel->rowCount(); const QString file =3D m_tempDir->path() + "/toplevelfile_"; - QList urls; - urls << KUrl(file + '1') << KUrl(file + '2') << KUrl(file + '3'); + QList urls; + urls << QUrl::fromLocalFile(file + '1') << QUrl::fromLocalFile(file + = '2') << QUrl::fromLocalFile(file + '3'); = QSignalSpy spyRowsRemoved(m_dirModel, SIGNAL(rowsRemoved(QModelIndex,i= nt,int))); =