• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libkonq
 

libkonq

  • libkonq
konq_undo.h
1 /* This file is part of the KDE project
2  Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 #ifndef __konq_undo_h__
20 #define __konq_undo_h__
21 
22 #include <tqobject.h>
23 #include <tqstring.h>
24 #include <tqvaluestack.h>
25 
26 #include <dcopobject.h>
27 
28 #include <kurl.h>
29 #include <libkonq_export.h>
30 
31 namespace TDEIO
32 {
33  class Job;
34 }
35 
36 class KonqUndoJob;
37 
38 struct KonqBasicOperation
39 {
40  typedef TQValueStack<KonqBasicOperation> Stack;
41 
42  KonqBasicOperation()
43  { m_valid = false; }
44 
45  bool m_valid;
46  bool m_directory;
47  bool m_renamed;
48  bool m_link;
49  KURL m_src;
50  KURL m_dst;
51  TQString m_target;
52 };
53 
54 struct KonqCommand
55 {
56  typedef TQValueStack<KonqCommand> Stack;
57 
58  enum Type { COPY, MOVE, LINK, MKDIR, TRASH };
59 
60  KonqCommand()
61  { m_valid = false; }
62 
63  bool m_valid;
64 
65  Type m_type;
66  KonqBasicOperation::Stack m_opStack;
67  KURL::List m_src;
68  KURL m_dst;
69 };
70 
71 class KonqCommandRecorder : public TQObject
72 {
73  Q_OBJECT
74 public:
75  KonqCommandRecorder( KonqCommand::Type op, const KURL::List &src, const KURL &dst, TDEIO::Job *job );
76  virtual ~KonqCommandRecorder();
77 
78 private slots:
79  void slotResult( TDEIO::Job *job );
80 
81  void slotCopyingDone( TDEIO::Job *, const KURL &from, const KURL &to, bool directory, bool renamed );
82  void slotCopyingLinkDone( TDEIO::Job *, const KURL &from, const TQString &target, const KURL &to );
83 
84 private:
85  class KonqCommandRecorderPrivate;
86  KonqCommandRecorderPrivate *d;
87 };
88 
89 class LIBKONQ_EXPORT KonqUndoManager : public TQObject, public DCOPObject
90 {
91  Q_OBJECT
92  K_DCOP
93  friend class KonqUndoJob;
94 public:
95  enum UndoState { MAKINGDIRS, MOVINGFILES, REMOVINGDIRS, REMOVINGFILES };
96 
97  KonqUndoManager();
98  virtual ~KonqUndoManager();
99 
100  static void incRef();
101  static void decRef();
102  static KonqUndoManager *self();
103 
104  void addCommand( const KonqCommand &cmd );
105 
106  bool undoAvailable() const;
107  TQString undoText() const;
108 
109 public slots:
110  void undo();
111 
112 signals:
113  void undoAvailable( bool avail );
114  void undoTextChanged( const TQString &text );
115 
116 protected:
120  void stopUndo( bool step );
121 
122 private:
123 k_dcop:
124  virtual ASYNC push( const KonqCommand &cmd );
125  virtual ASYNC pop();
126  virtual ASYNC lock();
127  virtual ASYNC unlock();
128 
129  virtual KonqCommand::Stack get() const;
130 
131 private slots:
132  void slotResult( TDEIO::Job *job );
133 
134 private:
135  void undoStep();
136 
137  void undoMakingDirectories();
138  void undoMovingFiles();
139  void undoRemovingFiles();
140  void undoRemovingDirectories();
141 
142  void broadcastPush( const KonqCommand &cmd );
143  void broadcastPop();
144  void broadcastLock();
145  void broadcastUnlock();
146 
147  void addDirToUpdate( const KURL& url );
148  bool initializeFromKDesky();
149 
150  class KonqUndoManagerPrivate;
151  KonqUndoManagerPrivate *d;
152  static KonqUndoManager *s_self;
153  static unsigned long s_refCnt;
154 };
155 
156 TQDataStream &operator<<( TQDataStream &stream, const KonqBasicOperation &op );
157 TQDataStream &operator>>( TQDataStream &stream, KonqBasicOperation &op );
158 
159 TQDataStream &operator<<( TQDataStream &stream, const KonqCommand &cmd );
160 TQDataStream &operator>>( TQDataStream &stream, KonqCommand &cmd );
161 
162 #endif

libkonq

Skip menu "libkonq"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libkonq

Skip menu "libkonq"
  • kate
  • libkonq
  • twin
  •   lib
Generated for libkonq by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.