Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

dir_lister.cpp

Go to the documentation of this file.
00001 /*
00002  * GPLv2 zecke@handhelds.org
00003  */
00004 
00005 #include "dir_lister.h"
00006 
00007 #include <lib/slavemaster.h>
00008 
00009 /* OPIE */
00010 #include <opie2/odebug.h>
00011 #include <qpe/config.h>
00012 #include <qpe/qpeapplication.h>
00013 using namespace Opie::Core;
00014 
00015 /* QT */
00016 #include <qdir.h>
00017 #include <qfileinfo.h>
00018 
00019 Dir_DirLister::Dir_DirLister( bool list,bool rec,int recdepth )
00020     : PDirLister( "dir_dir_lister" )
00021 {
00022     m_allFiles = list;
00023     m_recursive = rec;
00024     m_recDepth = recdepth;
00025     if (m_recDepth<1) m_recDepth = 1;
00026     if (m_recDepth>10) m_recDepth = 10;
00027     owarn << "All Files " << m_allFiles << "" << oendl;
00028     SlaveHelper::slaveConnectSignals( this );
00029     m_Filter = (m_allFiles?"*":"*.jpg;*.jpeg;*.JPG;*.PNG;*.GIF;*.BMP;*.png;*.bmp;*.gif");
00030 }
00031 
00032 QString Dir_DirLister::defaultPath()const {
00033     return QPEApplication::documentDir();
00034 }
00035 
00036 QString Dir_DirLister::setStartPath( const QString& path ) {
00037     m_currentDir.cd( path );
00038     if (!m_currentDir.exists() )
00039         m_currentDir.cd(defaultPath());
00040 
00041 
00042     return m_currentDir.absPath();
00043 }
00044 
00045 QString Dir_DirLister::currentPath()const {
00046     return m_currentDir.absPath();
00047 }
00048 
00049 
00050 QStringList Dir_DirLister::folders()const {
00051     QStringList dirs = m_currentDir.entryList( QDir::Dirs );
00052     dirs.remove(".");
00053     
00054     return dirs;
00055 }
00056 
00057 QStringList Dir_DirLister::recFiles(const QString&aPath,int currentDepth)const
00058 {
00059     QStringList all;
00060     if (currentDepth>m_recDepth) return all;
00061 
00062     QString subPath;
00063     subPath = aPath;
00064     if (subPath.length()==0) {
00065         subPath=".";
00066     }
00067     QDir checkDir(currentPath()+"/"+aPath);
00068 
00069     QStringList p = checkDir.entryList( QDir::Dirs );
00070     all+=checkDir.entryList(m_Filter,QDir::Files|QDir::Readable);
00071     QStringList tmp;
00072     for (unsigned i = 0; i < p.count();++i) {
00073         if (p[i]=="." || p[i]=="..") continue;
00074         tmp =recFiles(subPath+"/"+p[i],currentDepth+1);
00075         for (unsigned j = 0; j < tmp.count();++j) {
00076             all.append(p[i]+"/"+tmp[j]);
00077         }
00078     }
00079     return all;
00080 }
00081 
00082 QStringList Dir_DirLister::files()const
00083 {
00084     if (m_recursive) {
00085         odebug << "Startpfad: "<<m_currentDir.absPath()<<oendl;
00086         return recFiles("",0);
00087     }
00088     return m_currentDir.entryList(m_Filter,QDir::Files|QDir::Readable);
00089 }
00090 
00091 void Dir_DirLister::deleteImage( const QString& fl) {
00092     QFile::remove( fl );
00093 }
00094 
00095 void Dir_DirLister::thumbNail( const QString& str, int w, int h) {
00096     SlaveMaster::self()->thumbNail( str, w, h );
00097 }
00098 
00099 QImage Dir_DirLister::image( const QString& str, Factor f, int m) {
00100     return SlaveMaster::self()->image( str, f, m );
00101 }
00102 
00103 void Dir_DirLister::imageInfo( const QString& str) {
00104     SlaveMaster::self()->thumbInfo( str );
00105 }
00106 
00107 void Dir_DirLister::fullImageInfo( const QString& str) {
00108     SlaveMaster::self()->imageInfo( str );
00109 }
00110 
00111 QString Dir_DirLister::nameToFname(const QString&name)const
00112 {
00113     return name;
00114 }

Generated on Sat Nov 5 16:17:30 2005 for OPIE by  doxygen 1.4.2