File indexing completed on 2024-04-21 05:51:48
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 // SPDX-FileCopyrightText: 2005 Dominik Seichter <domseichter@web.de> 0003 0004 #ifndef THREADEDLISTER_H 0005 #define THREADEDLISTER_H 0006 0007 #include <QThread> 0008 #include <QMutex> 0009 0010 #include <kfileitem.h> 0011 0012 #include "krenamefile.h" 0013 0014 class KRenameModel; 0015 class QMutex; 0016 class QWidget; 0017 0018 namespace KIO 0019 { 0020 class Job; 0021 }; 0022 0023 class ThreadedLister : public QObject 0024 { 0025 Q_OBJECT 0026 public: 0027 ThreadedLister(const QUrl &dirname, QWidget *cache, KRenameModel *model); 0028 ~ThreadedLister() override; 0029 0030 inline void start() 0031 { 0032 this->run(); 0033 } 0034 0035 /** Sets if dirnames should listed along with the filenames. 0036 * This is disabled by default. 0037 * 0038 * \param names if true dirnames are listed along with the filenames. 0039 */ 0040 inline void setListDirnames(bool names); 0041 0042 /** Sets if only dirnames should listed. 0043 * This is disabled by default. 0044 * 0045 * \param names if true only dirnames are listed. 0046 */ 0047 inline void setListDirnamesOnly(bool names); 0048 0049 inline void setFilter(const QString &filter); 0050 inline void setListHidden(bool h); 0051 inline void setListRecursively(bool r); 0052 0053 Q_SIGNALS: 0054 void listerDone(ThreadedLister *); 0055 0056 protected: 0057 void run(); 0058 0059 private Q_SLOTS: 0060 void completed(); 0061 0062 void foundItem(KIO::Job *, const KIO::UDSEntryList &list); 0063 0064 private: 0065 static QMutex s_mutex; ///< Mutex assuring that only one thread at a time will work on m_model 0066 0067 QUrl m_dirname; 0068 QString m_filter; 0069 bool m_listHiddenFiles; 0070 bool m_listRecursive; 0071 bool m_listDirnamesOnly; 0072 bool m_listDirnames; 0073 0074 QWidget *m_cache; 0075 KRenameModel *m_model; 0076 KRenameFile::List m_files; 0077 0078 ESplitMode m_eSplitMode; 0079 unsigned int m_dot; 0080 }; 0081 0082 void ThreadedLister::setListDirnames(bool names) 0083 { 0084 m_listDirnames = names; 0085 } 0086 0087 void ThreadedLister::setListDirnamesOnly(bool names) 0088 { 0089 m_listDirnamesOnly = names; 0090 } 0091 0092 void ThreadedLister::setFilter(const QString &filter) 0093 { 0094 m_filter = filter; 0095 } 0096 0097 void ThreadedLister::setListHidden(bool h) 0098 { 0099 m_listHiddenFiles = h; 0100 } 0101 0102 void ThreadedLister::setListRecursively(bool r) 0103 { 0104 m_listRecursive = r; 0105 } 0106 0107 #endif