KRename – powerful batch renamer
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.

109 lines
3.1KB

  1. /***************************************************************************
  2. krecursivelister.h - description
  3. -------------------
  4. begin : Fri Aug 31 2001
  5. copyright : (C) 2001 by Jonathon Sim
  6. email : jonathonsim@iname.com
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #ifndef KRECURSIVELISTER_H
  17. #define KRECURSIVELISTER_H
  18. #include <tqwidget.h>
  19. #include <tqobject.h>
  20. #include <kdirlister.h>
  21. #include <kfileitem.h>
  22. #include <tqguardedptr.h>
  23. /**A convienience class that recursively lists a directory
  24. *@author Jonathon Sim
  25. *
  26. * Modified by Dominik Seichter to support a name filter,
  27. * dir only mode, support for showing hidden files on demand
  28. * and support for listing directories along with files.
  29. */
  30. class KRecursiveLister : public TQObject {
  31. Q_OBJECT
  32. TQ_OBJECT
  33. public:
  34. KRecursiveLister(TQObject *parent=0, const char *name=0);
  35. ~KRecursiveLister();
  36. /** Returns the list of fileitems found. */
  37. const KFileItemList & items();
  38. /** sets wether hidden files shall be listed */
  39. inline void setShowingDotFiles( bool dotfiles );
  40. /** filter to be used */
  41. inline void setNameFilter( const TQString & filter );
  42. /** list only directories */
  43. inline void setDirOnlyMode( bool dirsOnly );
  44. /** Starts listing the specified url */
  45. void openURL(const KURL& url);
  46. /** Stops the listing */
  47. void stop();
  48. /** Returns the subdirectories found by the listing */
  49. const KFileItemList& dirs();
  50. void cleanUp();
  51. signals: // Signals
  52. /** Listing is complete */
  53. void completed();
  54. protected slots: // Protected slots
  55. /** handles completion of a listing. */
  56. void slotListingComplete();
  57. void listNextDirectory();
  58. protected: // Protected methods
  59. /** Starts listing the specified url */
  60. void startListing(const KURL& url);
  61. //Protected variables
  62. KFileItemList filelist; //Files found at url
  63. KFileItemList dirlist; //Dirs remaining to list
  64. KFileItemList dirtree;
  65. KFileItemList allItems;
  66. TQGuardedPtr<KDirLister> lister; //The current KDirLister
  67. bool m_hidden;
  68. bool m_dirs;
  69. TQString m_filter;
  70. };
  71. void KRecursiveLister::setShowingDotFiles( bool dotfiles )
  72. {
  73. m_hidden = dotfiles;
  74. }
  75. void KRecursiveLister::setNameFilter( const TQString & filter )
  76. {
  77. m_filter = filter;
  78. }
  79. void KRecursiveLister::setDirOnlyMode( bool dirsOnly )
  80. {
  81. m_dirs = dirsOnly;
  82. }
  83. #endif