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.

160 lines
3.9KB

  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 <kfileitem.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. TQ_OBJECT
  43. public:
  44. ThreadedLister( TQMutex* mutex, unsigned int* counter, KMyListBox* list );
  45. ~ThreadedLister();
  46. static int TYPE() { return 51984; }
  47. inline FileList* items();
  48. inline const KURL & dirname();
  49. inline bool dirnames();
  50. inline const TQString & filter();
  51. inline bool hidden();
  52. inline void setDirname( const KURL & dirname );
  53. inline void setDirnames( bool names );
  54. inline void setFilter( const TQString & filter );
  55. inline void setHidden( bool h );
  56. inline void setRecursive( bool r );
  57. inline void setRecursiveDirOnlyMode( bool m );
  58. signals:
  59. void listerDone( ThreadedLister* );
  60. protected:
  61. void run();
  62. private slots:
  63. void reclisterFinished();
  64. void listerFinished();
  65. private:
  66. TQMutex* m_mutex;
  67. TQMutex* m_internal;
  68. unsigned int* m_counter;
  69. FileList m_files;
  70. KURL m_dirname;
  71. TQString m_filter;
  72. bool m_hidden;
  73. bool m_recursive;
  74. bool m_dirnames;
  75. bool m_dironly;
  76. KDirLister* m_lister;
  77. KRecursiveLister* m_reclister;
  78. KMyListBox* m_list;
  79. };
  80. void ThreadedLister::setDirname( const KURL & dirname )
  81. {
  82. m_dirname = dirname;
  83. }
  84. void ThreadedLister::setDirnames( bool names )
  85. {
  86. m_dirnames = names;
  87. }
  88. void ThreadedLister::setFilter( const TQString & filter )
  89. {
  90. m_filter = filter;
  91. }
  92. void ThreadedLister::setHidden( bool h )
  93. {
  94. m_hidden = h;
  95. }
  96. void ThreadedLister::setRecursive( bool r )
  97. {
  98. m_recursive = r;
  99. }
  100. void ThreadedLister::setRecursiveDirOnlyMode( bool m )
  101. {
  102. m_dironly = m;
  103. }
  104. FileList* ThreadedLister::items()
  105. {
  106. return &m_files;
  107. }
  108. const KURL & ThreadedLister::dirname()
  109. {
  110. return m_dirname;
  111. }
  112. bool ThreadedLister::dirnames()
  113. {
  114. return m_dirnames;
  115. }
  116. const TQString & ThreadedLister::filter()
  117. {
  118. return m_filter;
  119. }
  120. bool ThreadedLister::hidden()
  121. {
  122. return m_hidden;
  123. }
  124. #endif