author | alwin <alwin> | 2004-11-02 17:52:41 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-02 17:52:41 (UTC) |
commit | ebdc2d346272bae27c867b855207993985df4450 (patch) (unidiff) | |
tree | 37b4710141434e33df3873c16937a6ad6a015eb4 /noncore/graphics/opie-eye/impl/dir/dir_lister.cpp | |
parent | e246d0590286f6b9b0d5d40f1a17caa78c015b21 (diff) | |
download | opie-ebdc2d346272bae27c867b855207993985df4450.zip opie-ebdc2d346272bae27c867b855207993985df4450.tar.gz opie-ebdc2d346272bae27c867b855207993985df4450.tar.bz2 |
if wanted the user may search directories recursiv
Diffstat (limited to 'noncore/graphics/opie-eye/impl/dir/dir_lister.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/impl/dir/dir_lister.cpp | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp index d8b332a..ff33cf2 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp +++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp | |||
@@ -18,3 +18,3 @@ using namespace Opie::Core; | |||
18 | 18 | ||
19 | Dir_DirLister::Dir_DirLister( bool list ) | 19 | Dir_DirLister::Dir_DirLister( bool list,bool rec,int recdepth ) |
20 | : PDirLister( "dir_dir_lister" ) | 20 | : PDirLister( "dir_dir_lister" ) |
@@ -22,4 +22,9 @@ Dir_DirLister::Dir_DirLister( bool list ) | |||
22 | m_allFiles = list; | 22 | m_allFiles = list; |
23 | m_recursive = rec; | ||
24 | m_recDepth = recdepth; | ||
25 | if (m_recDepth<1) m_recDepth = 1; | ||
26 | if (m_recDepth>10) m_recDepth = 10; | ||
23 | owarn << "All Files " << m_allFiles << "" << oendl; | 27 | owarn << "All Files " << m_allFiles << "" << oendl; |
24 | SlaveHelper::slaveConnectSignals( this ); | 28 | SlaveHelper::slaveConnectSignals( this ); |
29 | m_Filter = (m_allFiles?"*":"*.jpg;*.jpeg;*.JPG;*.PNG;*.GIF;*.BMP;*.png;*.bmp;*.gif"); | ||
25 | } | 30 | } |
@@ -48,20 +53,34 @@ QStringList Dir_DirLister::folders()const { | |||
48 | 53 | ||
49 | QStringList Dir_DirLister::files()const { | 54 | QStringList Dir_DirLister::recFiles(const QString&aPath,int currentDepth)const |
50 | if ( m_allFiles ) | 55 | { |
51 | return m_currentDir.entryList( QDir::Files ); | 56 | QStringList all; |
52 | else { | 57 | if (currentDepth>m_recDepth) return all; |
53 | QStringList out; | 58 | |
54 | QStringList list = m_currentDir.entryList( QDir::Files | QDir::Readable ); | 59 | QString subPath; |
55 | for (QStringList::Iterator it = list.begin(); it != list.end();++it ) { | 60 | subPath = aPath; |
56 | QFileInfo inf( *it ); | 61 | if (subPath.length()==0) { |
57 | QString ext = inf.extension(false).lower(); | 62 | subPath="."; |
58 | if( ext == QString::fromLatin1("jpg") || | 63 | } |
59 | ext == QString::fromLatin1("jpeg" ) || | 64 | QDir checkDir(currentPath()+"/"+aPath); |
60 | ext == QString::fromLatin1("png" ) || | 65 | |
61 | ext == QString::fromLatin1("bmp" ) || | 66 | QStringList p = checkDir.entryList( QDir::Dirs ); |
62 | ext == QString::fromLatin1("gif" ) ) | 67 | all+=checkDir.entryList(m_Filter,QDir::Files|QDir::Readable); |
63 | out.append( *it ); | 68 | QStringList tmp; |
69 | for (unsigned i = 0; i < p.count();++i) { | ||
70 | if (p[i]=="." || p[i]=="..") continue; | ||
71 | tmp =recFiles(subPath+"/"+p[i],currentDepth+1); | ||
72 | for (unsigned j = 0; j < tmp.count();++j) { | ||
73 | all.append(p[i]+"/"+tmp[j]); | ||
64 | } | 74 | } |
65 | return out; | ||
66 | } | 75 | } |
76 | return all; | ||
77 | } | ||
78 | |||
79 | QStringList Dir_DirLister::files()const | ||
80 | { | ||
81 | if (m_recursive) { | ||
82 | odebug << "Startpfad: "<<m_currentDir.absPath()<<oendl; | ||
83 | return recFiles("",0); | ||
84 | } | ||
85 | return m_currentDir.entryList(m_Filter,QDir::Files|QDir::Readable); | ||
67 | } | 86 | } |