Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / apps / lib / konq / konq_fileundomanager_p.h
blobaae821e37e80854895713186b13525a7c36ee844
1 /* This file is part of the KDE project
2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
3 Copyright (C) 2006 David Faure <faure@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef KONQ_UNDO_P_H
22 #define KONQ_UNDO_P_H
24 #include <QtCore/QStack>
25 #include <QUndoCommand>
27 struct KonqBasicOperation
29 typedef QStack<KonqBasicOperation> Stack;
31 KonqBasicOperation()
32 { m_valid = false; }
34 bool m_valid;
35 bool m_renamed;
37 enum Type { File, Link, Directory };
38 Type m_type:2;
40 KUrl m_src;
41 KUrl m_dst;
42 QString m_target;
43 time_t m_mtime;
46 // ### I considered inheriting this from QUndoCommand.
47 // ### but since it is being copied by value in the code, we can't use that.
48 // Alternatively the data here should be contained into the QUndoCommand-subclass.
49 // This way we could copy the data in the manager code.
51 // ### also it would need to implement undo() itself (well, it can call the undomanager for it)
52 class KonqCommand
54 public:
55 typedef QStack<KonqCommand> Stack;
57 KonqCommand()
59 m_valid = false;
62 // TODO
63 //KonqCommand( Type type, KonqBasicOperation::Stack& opStack, const KUrl::List& src, const KUrl& dest )
64 // : m_type( type ), m_opStack( opStack ), m_src( src ), m_dest( dest )
65 // {
66 // // if using QUndoCommand: setText(...); // see code in KonqFileUndoManager::undoText()
67 // }
69 //virtual void undo() {} // TODO
70 //virtual void redo() {} // TODO
72 // TODO: is ::TRASH missing?
73 bool isMoveCommand() const { return m_type == KonqFileUndoManager::MOVE || m_type == KonqFileUndoManager::RENAME; }
75 bool m_valid;
77 KonqFileUndoManager::CommandType m_type;
78 KonqBasicOperation::Stack m_opStack;
79 KUrl::List m_src;
80 KUrl m_dst;
81 quint64 m_serialNumber;
84 // This class listens to a job, collects info while it's running (for copyjobs)
85 // and when the job terminates, on success, it calls addCommand in the undomanager.
86 class KonqCommandRecorder : public QObject
88 Q_OBJECT
89 public:
90 KonqCommandRecorder( KonqFileUndoManager::CommandType op, const KUrl::List &src, const KUrl &dst, KIO::Job *job );
91 virtual ~KonqCommandRecorder();
93 private Q_SLOTS:
94 void slotResult( KJob *job );
96 void slotCopyingDone( KIO::Job *, const KUrl &from, const KUrl &to, time_t, bool directory, bool renamed );
97 void slotCopyingLinkDone( KIO::Job *, const KUrl &from, const QString &target, const KUrl &to );
99 private:
100 KonqCommand m_cmd;
103 QDataStream &operator<<( QDataStream &stream, const KonqBasicOperation &op )
105 stream << op.m_valid << (qint8)op.m_type << op.m_renamed
106 << op.m_src << op.m_dst << op.m_target << (qint64)op.m_mtime;
107 return stream;
109 QDataStream &operator>>( QDataStream &stream, KonqBasicOperation &op )
111 qint8 type;
112 qint64 mtime;
113 stream >> op.m_valid >> type >> op.m_renamed
114 >> op.m_src >> op.m_dst >> op.m_target >> mtime;
115 op.m_type = static_cast<KonqBasicOperation::Type>(type);
116 op.m_mtime = mtime;
117 return stream;
120 QDataStream &operator<<( QDataStream &stream, const KonqCommand &cmd )
122 stream << cmd.m_valid << (qint8)cmd.m_type << cmd.m_opStack << cmd.m_src << cmd.m_dst;
123 return stream;
126 QDataStream &operator>>( QDataStream &stream, KonqCommand &cmd )
128 qint8 type;
129 stream >> cmd.m_valid >> type >> cmd.m_opStack >> cmd.m_src >> cmd.m_dst;
130 cmd.m_type = static_cast<KonqFileUndoManager::CommandType>( type );
131 return stream;
134 #endif /* KONQ_UNDO_P_H */