konq_operations.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2000 David Faure <faure@kde.org> 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef __konq_operations_h__ 00020 #define __konq_operations_h__ 00021 00022 #include <kurl.h> 00023 #include <libkonq_export.h> 00024 00025 #include <tqobject.h> 00026 #include <tqevent.h> 00027 00028 namespace KIO { class Job; class CopyInfo; } 00029 class TQWidget; 00030 class KFileItem; 00031 class KonqMainWindow; 00032 00037 class LIBKONQ_EXPORT KonqOperations : public TQObject 00038 { 00039 Q_OBJECT 00040 protected: 00041 KonqOperations( TQWidget * parent ); 00042 virtual ~KonqOperations(); 00043 00044 public: 00048 static void editMimeType( const TQString & mimeType ); 00049 00050 enum { TRASH, DEL, SHRED, COPY, MOVE, LINK, EMPTYTRASH, STAT, MKDIR, RESTORE, UNKNOWN }; 00058 static void del( TQWidget * parent, int method, const KURL::List & selectedURLs ); 00059 00070 static void copy( TQWidget * parent, int method, const KURL::List & selectedURLs, const KURL& destURL ); 00080 static void doDrop( const KFileItem * destItem, const KURL & destURL, TQDropEvent * ev, TQWidget * parent ); 00081 00085 static void doPaste( TQWidget * parent, const KURL & destURL, const TQPoint &pos ); 00086 static void doPaste( TQWidget * parent, const KURL & destURL ); 00087 00088 static void emptyTrash(); 00089 static void restoreTrashedItems( const KURL::List& urls ); 00090 00094 static void mkdir( TQWidget *parent, const KURL & url ); 00095 00102 static void statURL( const KURL & url, const TQObject *receiver, const char *member ); 00103 00110 static void rename( TQWidget * parent, const KURL & oldurl, const TQString & name ); 00111 00120 static void rename( TQWidget * parent, const KURL & oldurl, const KURL & newurl ); 00121 00127 static void newDir( TQWidget * parent, const KURL & baseURL ); 00128 00129 enum ConfirmationType { DEFAULT_CONFIRMATION, SKIP_CONFIRMATION, FORCE_CONFIRMATION }; 00138 static bool askDeleteConfirmation( const KURL::List & selectedURLs, int method, ConfirmationType confirmation, TQWidget* widget ); 00139 00140 signals: 00141 void statFinished( const KFileItem * item ); 00142 void aboutToCreate(const TQPoint &pos, const TQValueList<KIO::CopyInfo> &files); 00143 00144 protected: 00145 void _del( int method, const KURL::List & selectedURLs, ConfirmationType confirmation ); 00146 void _restoreTrashedItems( const KURL::List& urls ); 00147 void _statURL( const KURL & url, const TQObject *receiver, const char *member ); 00148 00149 // internal, for COPY/MOVE/LINK/MKDIR 00150 void setOperation( KIO::Job * job, int method, const KURL::List & src, const KURL & dest ); 00151 00152 struct DropInfo 00153 { 00154 DropInfo( uint k, KURL::List & l, const TQMap<TQString,TQString> &m, 00155 int x, int y, TQDropEvent::Action a ) : 00156 keybstate(k), lst(l), metaData(m), mousePos(x,y), action(a) {} 00157 uint keybstate; 00158 KURL::List lst; 00159 TQMap<TQString,TQString> metaData; 00160 TQPoint mousePos; 00161 TQDropEvent::Action action; 00162 }; 00163 // internal, for doDrop 00164 void setDropInfo( DropInfo * info ) { m_info = info; } 00165 00166 struct KIOPasteInfo // KDE4: remove and use DropInfo instead or a TQPoint member 00167 { 00168 TQByteArray data; // unused 00169 KURL destURL; // unused 00170 TQPoint mousePos; 00171 TQString dialogText; // unused 00172 }; 00173 void setPasteInfo( KIOPasteInfo * info ) { m_pasteInfo = info; } 00174 00175 private: 00176 TQWidget* parentWidget() const; 00177 00178 protected slots: 00179 00180 void slotAboutToCreate(KIO::Job *job, const TQValueList<KIO::CopyInfo> &files); 00181 void slotResult( KIO::Job * job ); 00182 void slotStatResult( KIO::Job * job ); 00183 void asyncDrop( const KFileItem * item ); 00184 void doFileCopy(); 00185 00186 private: 00187 int m_method; 00188 //KURL::List m_srcURLs; 00189 KURL m_destURL; 00190 // for doDrop 00191 DropInfo * m_info; 00192 KIOPasteInfo * m_pasteInfo; 00193 }; 00194 00195 #include <kio/job.h> 00196 00198 class KonqMultiRestoreJob : public KIO::Job 00199 { 00200 Q_OBJECT 00201 00202 public: 00203 KonqMultiRestoreJob( const KURL::List& urls, bool showProgressInfo ); 00204 00205 protected slots: 00206 virtual void slotStart(); 00207 virtual void slotResult( KIO::Job *job ); 00208 00209 private: 00210 const KURL::List m_urls; 00211 KURL::List::const_iterator m_urlsIterator; 00212 int m_progress; 00213 }; 00214 00215 #endif