Version: (using KDE KDE 3.3.0) Installed from: I Don't Know OS: Linux ISSUE: In repsonse to this lovely piece of fan mail: http://article.gmane.org/gmane.comp.kde.digikam.devel/1093 SOLUTION: It appears that KIO::del() should respect the Trash can. Adding in support in such a global manner should avoid that mishap from occuring in the future and it will provide Trash support transparently as well for other apps. RISKS: 1) too much is moved to trash, rather than deleted. While this may make a for a busy trash can, saving stuff in the trash is much more safe than not. Authors are free to use unlink() or other means to bypass this mechanism.
KIO::del() has to remain doing what it always did - after all Konqueror offers both "Move to Trash" and "Delete", so for the latter we need del(). Many other apps use del() to really delete (backup files etc.) However, given that I'm working on a new trash system, I am planning to provide an API for it, e.g. a KIO::trash( url list ). It will basically be a move( urls, "trash:/" ). Thanks for the BR, it confirms the need for an easy API for this. Will close when done.
CVS commit by faure: Added convenience method KIO::trash( url or url list ), to encapsulate the trash implementation (it now moves to "trash:/"). Should also make it easy for apps to use it instead of del(). CCMAIL: 88615-done@bugs.kde.org M +12 -0 job.cpp 1.407 M +21 -0 job.h 1.101 M +1 -0 jobclasses.h 1.147 --- kdelibs/kio/kio/job.cpp #1.406:1.407 @@ -3593,4 +3593,16 @@ CopyJob *KIO::linkAs(const KURL& src, co } +CopyJob *KIO::trash(const KURL& src, bool showProgressInfo ) +{ + KURL::List srcList; + srcList.append( src ); + return new CopyJob( srcList, KURL( "trash:/" ), CopyJob::Move, false, showProgressInfo ); +} + +CopyJob *KIO::trash(const KURL::List& srcList, bool showProgressInfo ) +{ + return new CopyJob( srcList, KURL( "trash:/" ), CopyJob::Move, false, showProgressInfo ); +} + ////////// --- kdelibs/kio/kio/job.h #1.100:1.101 @@ -477,4 +477,25 @@ namespace KIO { /** + * Trash a file or directory. + * This is currently only supported for local files and directories. + * Use "KURL src; src.setPath( path );" to create a URL from a path. + * + * @param src file to delete + * @param showProgressInfo true to show progress information + * @return the job handling the operation + */ + CopyJob *trash( const KURL& src, bool showProgressInfo = true ); + + /** + * Trash a list of files or directories. + * This is currently only supported for local files and directories. + * + * @param src the files to delete + * @param showProgressInfo true to show progress information + * @return the job handling the operation + */ + CopyJob *trash( const KURL::List& src, bool showProgressInfo = true ); + + /** * Delete a file or directory. * --- kdelibs/kio/kio/jobclasses.h #1.146:1.147 @@ -1384,4 +1384,5 @@ namespace KIO { }; + /// @internal struct CopyInfo {