kdirstat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kcleanupcollection.h 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * File name: kcleanupcollection.h
  3. * Summary: Support classes for KDirStat
  4. * License: LGPL - See file COPYING.LIB for details.
  5. * Author: Stefan Hundhammer <sh@suse.de>
  6. *
  7. * Updated: 2003-01-07
  8. */
  9. #ifndef KCleanupCollection_h
  10. #define KCleanupCollection_h
  11. #ifdef HAVE_CONFIG_H
  12. # include <config.h>
  13. #endif
  14. #include "kcleanup.h"
  15. // Forward declarations
  16. class TDEActionCollection;
  17. namespace KDirStat
  18. {
  19. typedef TQDict<KCleanup> KCleanupDict;
  20. typedef TQDictIterator<KCleanup> KCleanupDictIterator;
  21. typedef TQPtrList<KCleanup> KCleanupList;
  22. typedef TQPtrListIterator<KCleanup> KCleanupListIterator;
  23. /**
  24. * Set of @ref KCleanup actions to be performed for @ref KDirTree items,
  25. * consisting of a number of predefined and a number of user-defined
  26. * cleanups. The prime purpose of this is to make save/restore operations
  27. * with a number of cleanups easier. Thus, it provides a copy constructor,
  28. * an assignment operator and various methods to directly access individual
  29. * cleanups.
  30. *
  31. * @short KDirStat cleanup action collection
  32. **/
  33. class KCleanupCollection: public TQObject
  34. {
  35. Q_OBJECT
  36. public:
  37. /**
  38. * Constructor.
  39. *
  40. * Most applications will want to pass TDEMainWindow::actionCollection()
  41. * for 'actionCollection' so the menus and toolbars can be created
  42. * using the XML UI description ('kdirstatui.rc' for KDirStat).
  43. *
  44. * All @ref KCleanup actions ever added to this collection will get
  45. * this as their parent.
  46. **/
  47. KCleanupCollection( TDEActionCollection * actionCollection = 0 );
  48. /**
  49. * Copy Constructor.
  50. *
  51. * Makes a deep copy of this collection with 'actionCollection' set to
  52. * 0 for all copied cleanups. Please note that since there is no
  53. * complete copy constructor for @ref KCleanup, all restrictions to the
  54. * @ref KCleanup copy constructor apply to the KCleanupCollection, too:
  55. * This copy constructor is intended for save/restore operations only,
  56. * not for general use. In particular, DO NOT connect an object thus
  57. * constructed with signals. The results will be undefined (at best).
  58. **/
  59. KCleanupCollection( const KCleanupCollection &src );
  60. /**
  61. * Assignment operator.
  62. *
  63. * This operator has the same restrictions as the copy constructor:
  64. * Just like the copy constructor, this is intended for save/restore
  65. * operations, not for general use.
  66. *
  67. * For details, see the extensive comments in the source file.
  68. **/
  69. KCleanupCollection & operator= ( const KCleanupCollection &src );
  70. /**
  71. * Destructor
  72. **/
  73. virtual ~KCleanupCollection();
  74. /**
  75. * Add the standard cleanups to this collection.
  76. **/
  77. void addStdCleanups();
  78. /**
  79. * Add 'number' user-defined cleanups to this collection.
  80. **/
  81. void addUserCleanups( int number );
  82. /**
  83. * Add one single cleanup to this collection. The collection assumes
  84. * ownerwhip of this cleanup - don't delete it!
  85. **/
  86. void add( KCleanup *cleanup );
  87. /**
  88. * Retrieve a cleanup by its ID (internal name).
  89. * Returns 0 if there is no such cleanup.
  90. **/
  91. KCleanup * cleanup( const TQString & id );
  92. /**
  93. * An alias to @ref cleanup() for convenience: Thus, you can use
  94. * collection[ "cleanup_id" ] to access any particular cleanup.
  95. **/
  96. KCleanup * operator[] ( const TQString & id )
  97. { return cleanup( id ); }
  98. /**
  99. * Remove all cleanups from this collection.
  100. **/
  101. void clear();
  102. /**
  103. * Return (a shallow copy of) the internal cleanup list.
  104. *
  105. * Use this and a KCleanupListIterator to iterate over all cleanups in
  106. * this collection. Remember to keep the list until you no longer need
  107. * the iterator!
  108. *
  109. * KCleanupCollection *coll = ...
  110. * KCleanupList cleanup_list = coll->cleanupList();
  111. * KCleanupListIterator it( cleanup_list );
  112. *
  113. * while ( *it )
  114. * {
  115. * kdDebug() << "Found cleanup " << *it << endl;
  116. * ++it;
  117. * }
  118. **/
  119. KCleanupList cleanupList() const { return _cleanupList; }
  120. /**
  121. * Return the number of cleanup actions in this collection.
  122. **/
  123. int size() const { return _cleanupList.count(); }
  124. /**
  125. * For internal use only: Returns the number to be assigned to the next
  126. * user cleanup that may be added.
  127. **/
  128. int nextUserCleanupNo() const { return _nextUserCleanupNo; }
  129. public slots:
  130. /**
  131. * Emit the readConfig() signal for all cleanups.
  132. **/
  133. void slotReadConfig();
  134. signals:
  135. /**
  136. * Emitted when the currently selected item changes.
  137. * 'item' may be 0 when the selection is cleared.
  138. *
  139. * Connect a view's selectionChanged() signal to this
  140. * selectionChanged() signal to have the cleanup collection pass this
  141. * signal to its cleanups.
  142. **/
  143. void selectionChanged( KFileInfo *item );
  144. /**
  145. * Read collection for all cleanups.
  146. **/
  147. void readConfig();
  148. /**
  149. * Save configuration for all cleanups.
  150. **/
  151. void saveConfig();
  152. /**
  153. * Emitted at user activity, i.e. when the user executes a cleanup.
  154. * This is intended for use together with a @ref KActivityTracker.
  155. **/
  156. void userActivity( int points );
  157. protected slots:
  158. /**
  159. * Connected to each cleanup's @ref executed() signal to track user
  160. * activity.
  161. **/
  162. void cleanupExecuted();
  163. protected:
  164. /**
  165. * Internal implementation of copy constructor and assignment operator:
  166. * Make a deep copy of the collection.
  167. **/
  168. void deepCopy( const KCleanupCollection &src );
  169. // Data members
  170. TDEActionCollection * _actionCollection;
  171. int _nextUserCleanupNo;
  172. KCleanupList _cleanupList;
  173. KCleanupDict _cleanupDict;
  174. };
  175. } // namespace KDirStat
  176. #endif // ifndef KCleanupCollection_h
  177. // EOF