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.

threadedlister.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /***************************************************************************
  2. threadedlister.h - description
  3. -------------------
  4. begin : Tue Feb 01 2005
  5. copyright : (C) 2005 by Dominik Seichter
  6. email : domseichter@web.de
  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 THREADEDLISTER_H
  17. #define THREADEDLISTER_H
  18. #include <tqobject.h>
  19. #include <tqthread.h>
  20. #include <tdefileitem.h>
  21. class KDirLister;
  22. class KRecursiveLister;
  23. class KMyListBox;
  24. class TQMutex;
  25. class FileList : public TQPtrList<KFileItem> {
  26. public:
  27. FileList() : TQPtrList<KFileItem>() {}
  28. FileList( KFileItemList list )
  29. : TQPtrList<KFileItem>() {
  30. KFileItem* it;
  31. for( it = list.first(); it; it = list.next() )
  32. this->append( it );
  33. }
  34. protected:
  35. int compareItems( TQPtrCollection::Item item1, TQPtrCollection::Item item2 ) {
  36. return static_cast<KFileItem*>(item1)->url().url().compare( static_cast<KFileItem*>(item2)->url().url() );
  37. }
  38. };
  39. class ThreadedLister : public TQObject, public TQThread
  40. {
  41. Q_OBJECT
  42. public:
  43. ThreadedLister( TQMutex* mutex, unsigned int* counter, KMyListBox* list );
  44. ~ThreadedLister();
  45. static int TYPE() { return 51984; }
  46. inline FileList* items();
  47. inline const KURL & dirname();
  48. inline bool dirnames();
  49. inline const TQString & filter();
  50. inline bool hidden();
  51. inline void setDirname( const KURL & dirname );
  52. inline void setDirnames( bool names );
  53. inline void setFilter( const TQString & filter );
  54. inline void setHidden( bool h );
  55. inline void setRecursive( bool r );
  56. inline void setRecursiveDirOnlyMode( bool m );
  57. signals:
  58. void listerDone( ThreadedLister* );
  59. protected:
  60. void run();
  61. private slots:
  62. void reclisterFinished();
  63. void listerFinished();
  64. private:
  65. TQMutex* m_mutex;
  66. TQMutex* m_internal;
  67. unsigned int* m_counter;
  68. FileList m_files;
  69. KURL m_dirname;
  70. TQString m_filter;
  71. bool m_hidden;
  72. bool m_recursive;
  73. bool m_dirnames;
  74. bool m_dironly;
  75. KDirLister* m_lister;
  76. KRecursiveLister* m_reclister;
  77. KMyListBox* m_list;
  78. };
  79. void ThreadedLister::setDirname( const KURL & dirname )
  80. {
  81. m_dirname = dirname;
  82. }
  83. void ThreadedLister::setDirnames( bool names )
  84. {
  85. m_dirnames = names;
  86. }
  87. void ThreadedLister::setFilter( const TQString & filter )
  88. {
  89. m_filter = filter;
  90. }
  91. void ThreadedLister::setHidden( bool h )
  92. {
  93. m_hidden = h;
  94. }
  95. void ThreadedLister::setRecursive( bool r )
  96. {
  97. m_recursive = r;
  98. }
  99. void ThreadedLister::setRecursiveDirOnlyMode( bool m )
  100. {
  101. m_dironly = m;
  102. }
  103. FileList* ThreadedLister::items()
  104. {
  105. return &m_files;
  106. }
  107. const KURL & ThreadedLister::dirname()
  108. {
  109. return m_dirname;
  110. }
  111. bool ThreadedLister::dirnames()
  112. {
  113. return m_dirnames;
  114. }
  115. const TQString & ThreadedLister::filter()
  116. {
  117. return m_filter;
  118. }
  119. bool ThreadedLister::hidden()
  120. {
  121. return m_hidden;
  122. }
  123. #endif