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 <qobject.h>
00026 #include <qevent.h>
00027 
00028 namespace KIO { class Job; class CopyInfo; }
00029 class QWidget;
00030 class KFileItem;
00031 class KonqMainWindow;
00032 
00037 class LIBKONQ_EXPORT KonqOperations : public QObject
00038 {
00039     Q_OBJECT
00040 protected:
00041     KonqOperations( QWidget * parent );
00042     virtual ~KonqOperations();
00043 
00044 public:
00048     static void editMimeType( const QString & mimeType );
00049 
00050     enum { TRASH, DEL, SHRED, COPY, MOVE, LINK, EMPTYTRASH, STAT, MKDIR, RESTORE, UNKNOWN };
00058     static void del( QWidget * parent, int method, const KURL::List & selectedURLs );
00059 
00070     static void copy( QWidget * parent, int method, const KURL::List & selectedURLs, const KURL& destURL );
00080     static void doDrop( const KFileItem * destItem, const KURL & destURL, QDropEvent * ev, QWidget * parent );
00081 
00085     static void doPaste( QWidget * parent, const KURL & destURL, const QPoint &pos );
00086     static void doPaste( QWidget * parent, const KURL & destURL );
00087 
00088     static void emptyTrash();
00089     static void restoreTrashedItems( const KURL::List& urls );
00090 
00094     static void mkdir( QWidget *parent, const KURL & url );
00095 
00102     static void statURL( const KURL & url, const QObject *receiver, const char *member );
00103 
00110     static void rename( QWidget * parent, const KURL & oldurl, const QString & name );
00111 
00120     static void rename( QWidget * parent, const KURL & oldurl, const KURL & newurl );
00121 
00127     static void newDir( QWidget * parent, const KURL & baseURL );
00128 
00129 signals:
00130     void statFinished( const KFileItem * item );
00131     void aboutToCreate(const QPoint &pos, const QValueList<KIO::CopyInfo> &files);
00132 
00133 protected:
00134     enum { DEFAULT_CONFIRMATION, SKIP_CONFIRMATION, FORCE_CONFIRMATION };
00135     bool askDeleteConfirmation( const KURL::List & selectedURLs, int confirmation );
00136     void _del( int method, const KURL::List & selectedURLs, int confirmation );
00137     void _restoreTrashedItems( const KURL::List& urls );
00138     void _statURL( const KURL & url, const QObject *receiver, const char *member );
00139 
00140     // internal, for COPY/MOVE/LINK/MKDIR
00141     void setOperation( KIO::Job * job, int method, const KURL::List & src, const KURL & dest );
00142 
00143     struct DropInfo
00144     {
00145         DropInfo( uint k, KURL::List & l, const QMap<QString,QString> &m,
00146                   int x, int y, QDropEvent::Action a ) :
00147             keybstate(k), lst(l), metaData(m), mousePos(x,y), action(a) {}
00148         uint keybstate;
00149         KURL::List lst;
00150         QMap<QString,QString> metaData;
00151         QPoint mousePos;
00152         QDropEvent::Action action;
00153     };
00154     // internal, for doDrop
00155     void setDropInfo( DropInfo * info ) { m_info = info; }
00156 
00157     struct KIOPasteInfo // KDE4: remove and use DropInfo instead or a QPoint member
00158     {
00159         QByteArray data;  // unused
00160         KURL destURL;     // unused
00161         QPoint mousePos;
00162         QString dialogText; // unused
00163     };
00164     void setPasteInfo( KIOPasteInfo * info ) { m_pasteInfo = info; }
00165 
00166 protected slots:
00167 
00168     void slotAboutToCreate(KIO::Job *job, const QValueList<KIO::CopyInfo> &files);
00169     void slotResult( KIO::Job * job );
00170     void slotStatResult( KIO::Job * job );
00171     void asyncDrop( const KFileItem * item );
00172     void doFileCopy();
00173 
00174 private:
00175     int m_method;
00176     //KURL::List m_srcURLs;
00177     KURL m_destURL;
00178     // for doDrop
00179     DropInfo * m_info;
00180     KIOPasteInfo * m_pasteInfo;
00181 };
00182 
00183 #include <kio/job.h>
00184 
00186 class KonqMultiRestoreJob : public KIO::Job
00187 {
00188     Q_OBJECT
00189 
00190 public:
00191     KonqMultiRestoreJob( const KURL::List& urls, bool showProgressInfo );
00192 
00193 protected slots:
00194     virtual void slotStart();
00195     virtual void slotResult( KIO::Job *job );
00196 
00197 private:
00198     const KURL::List m_urls;
00199     KURL::List::const_iterator m_urlsIterator;
00200     int m_progress;
00201 };
00202 
00203 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys