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 | |||
@@ -15,14 +15,19 @@ using namespace Opie::Core; | |||
15 | /* QT */ | 15 | /* QT */ |
16 | #include <qdir.h> | 16 | #include <qdir.h> |
17 | #include <qfileinfo.h> | 17 | #include <qfileinfo.h> |
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" ) |
21 | { | 21 | { |
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 | } |
26 | 31 | ||
27 | QString Dir_DirLister::defaultPath()const { | 32 | QString Dir_DirLister::defaultPath()const { |
28 | return QPEApplication::documentDir(); | 33 | return QPEApplication::documentDir(); |
@@ -45,26 +50,40 @@ QString Dir_DirLister::currentPath()const { | |||
45 | QStringList Dir_DirLister::folders()const { | 50 | QStringList Dir_DirLister::folders()const { |
46 | return m_currentDir.entryList( QDir::Dirs ); | 51 | return m_currentDir.entryList( QDir::Dirs ); |
47 | } | 52 | } |
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 | } |
68 | 87 | ||
69 | void Dir_DirLister::deleteImage( const QString& fl) { | 88 | void Dir_DirLister::deleteImage( const QString& fl) { |
70 | QFile::remove( fl ); | 89 | QFile::remove( fl ); |