libkonq Library API Documentation

konq_undo.h

00001 /* This file is part of the KDE project 00002 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library 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 GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 #ifndef __konq_undo_h__ 00020 #define __konq_undo_h__ 00021 00022 #include <qobject.h> 00023 #include <qstring.h> 00024 #include <qvaluestack.h> 00025 00026 #include <dcopobject.h> 00027 00028 #include <kurl.h> 00029 00030 namespace KIO 00031 { 00032 class Job; 00033 } 00034 00035 class KonqUndoJob; 00036 00037 struct KonqBasicOperation 00038 { 00039 typedef QValueStack<KonqBasicOperation> Stack; 00040 00041 KonqBasicOperation() 00042 { m_valid = false; } 00043 00044 bool m_valid; 00045 bool m_directory; 00046 bool m_renamed; 00047 bool m_link; 00048 KURL m_src; 00049 KURL m_dst; 00050 QString m_target; 00051 }; 00052 00053 struct KonqCommand 00054 { 00055 typedef QValueStack<KonqCommand> Stack; 00056 00057 enum Type { COPY, MOVE, LINK, MKDIR }; 00058 00059 KonqCommand() 00060 { m_valid = false; } 00061 00062 bool m_valid; 00063 00064 Type m_type; 00065 KonqBasicOperation::Stack m_opStack; 00066 KURL::List m_src; 00067 KURL m_dst; 00068 }; 00069 00070 class KonqCommandRecorder : public QObject 00071 { 00072 Q_OBJECT 00073 public: 00074 KonqCommandRecorder( KonqCommand::Type op, const KURL::List &src, const KURL &dst, KIO::Job *job ); 00075 virtual ~KonqCommandRecorder(); 00076 00077 private slots: 00078 void slotResult( KIO::Job *job ); 00079 00080 void slotCopyingDone( KIO::Job *, const KURL &from, const KURL &to, bool directory, bool renamed ); 00081 void slotCopyingLinkDone( KIO::Job *, const KURL &from, const QString &target, const KURL &to ); 00082 00083 private: 00084 class KonqCommandRecorderPrivate; 00085 KonqCommandRecorderPrivate *d; 00086 }; 00087 00088 class KonqUndoManager : public QObject, public DCOPObject 00089 { 00090 Q_OBJECT 00091 K_DCOP 00092 friend class KonqUndoJob; 00093 public: 00094 enum UndoState { MAKINGDIRS, MOVINGFILES, REMOVINGDIRS, REMOVINGFILES }; 00095 00096 KonqUndoManager(); 00097 virtual ~KonqUndoManager(); 00098 00099 static void incRef(); 00100 static void decRef(); 00101 static KonqUndoManager *self(); 00102 00103 void addCommand( const KonqCommand &cmd ); 00104 00105 bool undoAvailable() const; 00106 QString undoText() const; 00107 00108 public slots: 00109 void undo(); 00110 00111 signals: 00112 void undoAvailable( bool avail ); 00113 void undoTextChanged( const QString &text ); 00114 00115 protected: 00119 void stopUndo( bool step ); 00120 00121 private: 00122 k_dcop: 00123 virtual ASYNC push( const KonqCommand &cmd ); 00124 virtual ASYNC pop(); 00125 virtual ASYNC lock(); 00126 virtual ASYNC unlock(); 00127 00128 virtual KonqCommand::Stack get() const; 00129 00130 private slots: 00131 void slotResult( KIO::Job *job ); 00132 00133 private: 00134 void undoStep(); 00135 00136 void undoMakingDirectories(); 00137 void undoMovingFiles(); 00138 void undoRemovingFiles(); 00139 void undoRemovingDirectories(); 00140 00141 void broadcastPush( const KonqCommand &cmd ); 00142 void broadcastPop(); 00143 void broadcastLock(); 00144 void broadcastUnlock(); 00145 00146 bool initializeFromKDesky(); 00147 00148 class KonqUndoManagerPrivate; 00149 KonqUndoManagerPrivate *d; 00150 static KonqUndoManager *s_self; 00151 static unsigned long s_refCnt; 00152 }; 00153 00154 QDataStream &operator<<( QDataStream &stream, const KonqBasicOperation &op ); 00155 QDataStream &operator>>( QDataStream &stream, KonqBasicOperation &op ); 00156 00157 QDataStream &operator<<( QDataStream &stream, const KonqCommand &cmd ); 00158 QDataStream &operator>>( QDataStream &stream, KonqCommand &cmd ); 00159 00160 #endif
KDE Logo
This file is part of the documentation for libkonq Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 13 21:46:59 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003