KDirStat – a graphical disk usage utility
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 KActionCollection;
  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. TQ_OBJECT
  37. public:
  38. /**
  39. * Constructor.
  40. *
  41. * Most applications will want to pass KMainWindow::actionCollection()
  42. * for 'actionCollection' so the menus and toolbars can be created
  43. * using the XML UI description ('kdirstatui.rc' for KDirStat).
  44. *
  45. * All @ref KCleanup actions ever added to this collection will get
  46. * this as their tqparent.
  47. **/
  48. KCleanupCollection( KActionCollection * actionCollection = 0 );
  49. /**
  50. * Copy Constructor.
  51. *
  52. * Makes a deep copy of this collection with 'actionCollection' set to
  53. * 0 for all copied cleanups. Please note that since there is no
  54. * complete copy constructor for @ref KCleanup, all restrictions to the
  55. * @ref KCleanup copy constructor apply to the KCleanupCollection, too:
  56. * This copy constructor is intended for save/restore operations only,
  57. * not for general use. In particular, DO NOT connect an object thus
  58. * constructed with signals. The results will be undefined (at best).
  59. **/
  60. KCleanupCollection( const KCleanupCollection &src );
  61. /**
  62. * Assignment operator.
  63. *
  64. * This operator has the same restrictions as the copy constructor:
  65. * Just like the copy constructor, this is intended for save/restore
  66. * operations, not for general use.
  67. *
  68. * For details, see the extensive comments in the source file.
  69. **/
  70. KCleanupCollection & operator= ( const KCleanupCollection &src );
  71. /**
  72. * Destructor
  73. **/
  74. virtual ~KCleanupCollection();
  75. /**
  76. * Add the standard cleanups to this collection.
  77. **/
  78. void addStdCleanups();
  79. /**
  80. * Add 'number' user-defined cleanups to this collection.
  81. **/
  82. void addUserCleanups( int number );
  83. /**
  84. * Add one single cleanup to this collection. The collection assumes
  85. * ownerwhip of this cleanup - don't delete it!
  86. **/
  87. void add( KCleanup *cleanup );
  88. /**
  89. * Retrieve a cleanup by its ID (internal name).
  90. * Returns 0 if there is no such cleanup.
  91. **/
  92. KCleanup * cleanup( const TQString & id );
  93. /**
  94. * An alias to @ref cleanup() for convenience: Thus, you can use
  95. * collection[ "cleanup_id" ] to access any particular cleanup.
  96. **/
  97. KCleanup * operator[] ( const TQString & id )
  98. { return cleanup( id ); }
  99. /**
  100. * Remove all cleanups from this collection.
  101. **/
  102. void clear();
  103. /**
  104. * Return (a shallow copy of) the internal cleanup list.
  105. *
  106. * Use this and a KCleanupListIterator to iterate over all cleanups in
  107. * this collection. Remember to keep the list until you no longer need
  108. * the iterator!
  109. *
  110. * KCleanupCollection *coll = ...
  111. * KCleanupList cleanup_list = coll->cleanupList();
  112. * KCleanupListIterator it( cleanup_list );
  113. *
  114. * while ( *it )
  115. * {
  116. * kdDebug() << "Found cleanup " << *it << endl;
  117. * ++it;
  118. * }
  119. **/
  120. KCleanupList cleanupList() const { return _cleanupList; }
  121. /**
  122. * Return the number of cleanup actions in this collection.
  123. **/
  124. int size() const { return _cleanupList.count(); }
  125. /**
  126. * For internal use only: Returns the number to be assigned to the next
  127. * user cleanup that may be added.
  128. **/
  129. int nextUserCleanupNo() const { return _nextUserCleanupNo; }
  130. public slots:
  131. /**
  132. * Emit the readConfig() signal for all cleanups.
  133. **/
  134. void slotReadConfig();
  135. signals:
  136. /**
  137. * Emitted when the currently selected item changes.
  138. * 'item' may be 0 when the selection is cleared.
  139. *
  140. * Connect a view's selectionChanged() signal to this
  141. * selectionChanged() signal to have the cleanup collection pass this
  142. * signal to its cleanups.
  143. **/
  144. void selectionChanged( KFileInfo *item );
  145. /**
  146. * Read collection for all cleanups.
  147. **/
  148. void readConfig();
  149. /**
  150. * Save configuration for all cleanups.
  151. **/
  152. void saveConfig();
  153. /**
  154. * Emitted at user activity, i.e. when the user executes a cleanup.
  155. * This is intended for use together with a @ref KActivityTracker.
  156. **/
  157. void userActivity( int points );
  158. protected slots:
  159. /**
  160. * Connected to each cleanup's @ref executed() signal to track user
  161. * activity.
  162. **/
  163. void cleanupExecuted();
  164. protected:
  165. /**
  166. * Internal implementation of copy constructor and assignment operator:
  167. * Make a deep copy of the collection.
  168. **/
  169. void deepCopy( const KCleanupCollection &src );
  170. // Data members
  171. KActionCollection * _actionCollection;
  172. int _nextUserCleanupNo;
  173. KCleanupList _cleanupList;
  174. KCleanupDict _cleanupDict;
  175. };
  176. } // namespace KDirStat
  177. #endif // ifndef KCleanupCollection_h
  178. // EOF