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

dcim_lister.cpp

Go to the documentation of this file.
00001 /*
00002  * GPLv2 zecke@handhelds.org
00003  */
00004 
00005 #include "dcim_lister.h"
00006 #include <lib/slavemaster.h>
00007 
00008 #include <opie2/odebug.h>
00009 #include <qpe/storage.h>
00010 
00011 #include <qdir.h>
00012 #include <qfileinfo.h>
00013 #include <qimage.h>
00014 
00015 DCIM_DirLister::DCIM_DirLister()
00016     : PDirLister( "dcim_dirlister" )
00017 {
00018 
00019     /*
00020      * create a SlaveMaster and lets connect the signal of
00021      * it to our interface
00022      */
00023     SlaveHelper::slaveConnectSignals( this );
00024     m_mode = ListingUnknown;
00025 }
00026 
00027 DCIM_DirLister::~DCIM_DirLister() {}
00028 
00029 QString DCIM_DirLister::defaultPath()const {
00030     m_mode = ListingStart;
00031     return QString::null;
00032 }
00033 
00034 QString DCIM_DirLister::setStartPath( const QString& str) {
00039     QString st = str.mid( 1 );
00040     if ( ListingStart == m_mode && m_map.contains( st ) ) {
00041         m_path = m_map[st]+ "/dcim";
00042         m_mode = ListingFolder;
00043     }else if ( m_mode == ListingFolder ) {
00044         m_mode = ListingFiles;
00045         m_path = str;
00046     }else if ( m_mode == ListingReFolder ) {
00047         m_mode = ListingFolder;
00048     }
00049 
00050     owarn << " StartPath2 " << str << " " << m_path << oendl;
00051 
00052     return m_path;
00053 }
00054 
00055 
00056 QString DCIM_DirLister::currentPath()const {
00057     return m_path;
00058 }
00059 
00060 /*
00061  * depending on the mode we will either
00062  * Find Digital Cameras
00063  */
00064 QStringList DCIM_DirLister::folders()const {
00065     QStringList lst;
00066 
00067     switch( m_mode ) {
00068     case ListingUnknown:
00069     case ListingStart:
00070         lst = findCameras();
00071         break;
00072     case ListingFolder:
00073         lst = findAlbums();
00074         break;
00075     case ListingFiles:
00076     default:
00077         break;
00078     }
00079 
00080     return lst;
00081 }
00082 
00083 QStringList DCIM_DirLister::files()const {
00084     if ( m_mode != ListingFiles )
00085         return QStringList();
00086     else
00087         return findImages();
00088 }
00089 
00090 QString DCIM_DirLister::dirUp( const QString& p )const {
00091     QString str;
00092 
00093     switch( m_mode ) {
00094     case ListingFiles:
00095         m_mode = ListingReFolder;
00096         str = PDirLister::dirUp( p );
00097         break;
00098     case ListingFolder:
00099         m_mode = ListingStart;
00100         break;
00101     case ListingUnknown:
00102     case ListingStart:
00103     default:
00104         break;
00105     }
00106 
00107     /* down cases */
00108     owarn << " New String " << str << " old path " << m_mode << oendl;
00109     m_path = str;
00110     return str;
00111 }
00112 
00113 
00114 QStringList DCIM_DirLister::findCameras()const {
00115     QStringList lst;
00116     StorageInfo inf;
00117 
00118     m_map.clear();
00119 
00120     const QList<FileSystem> &list = inf.fileSystems();
00121     QListIterator<FileSystem> it( list );
00122 
00123 
00124     FileSystem *sys;
00125     for ( sys = it.current(); (sys=it.current())!=0  ; ++it )
00126         if ( QFileInfo( sys->path() + "/dcim/" ).exists() ) {
00127             lst << sys->name();
00128             m_map.insert( sys->name(), sys->path() );
00129         }
00130 
00131     if ( lst.isEmpty() ) {
00132         m_mode = ListingUnknown;
00133         lst << QObject::tr("Error no Camera Dir found");
00134     }else
00135         m_mode = ListingStart;
00136 
00137     return lst;
00138 }
00139 
00140 QStringList DCIM_DirLister::findAlbums()const {
00141     QStringList lst = QDir( m_path ).entryList( QDir::Dirs );
00142     lst.remove( "."  );
00143     lst.remove( ".." );
00144 
00145     return lst;
00146 }
00147 
00148 QStringList DCIM_DirLister::findImages()const {
00149     return QDir( m_path ).entryList("*.jpg *.jpeg *.png", QDir::Files );
00150 }
00151 
00152 void DCIM_DirLister::deleteImage( const QString& fl ) {
00153     QFileInfo inf( fl );
00154     QFile::remove( fl );
00155     QFile::remove( inf.dirPath ()+"/preview/"+
00156                    inf.fileName() );
00157 }
00158 
00159 void DCIM_DirLister::thumbNail( const QString& _str, int w, int h ) {
00160     QFileInfo inf( _str );
00161     QString str = QFileInfo( inf.dirPath()+"/preview"+ inf.fileName() ).exists() ?
00162                   inf.dirPath()+"/preview"+ inf.fileName() : _str;
00163 
00164     SlaveMaster::self()->thumbNail( str, w, h );
00165 }
00166 
00167 QImage DCIM_DirLister::image( const QString& str,  Factor f,  int m ) {
00168     return SlaveMaster::self()->image( str, f, m );
00169 }
00170 
00171 void DCIM_DirLister::imageInfo( const QString& str ) {
00172     SlaveMaster::self()->thumbInfo( str );
00173 }
00174 
00175 void DCIM_DirLister::fullImageInfo( const QString& str ) {
00176     SlaveMaster::self()->imageInfo( str );
00177 }
00178 
00179 QString DCIM_DirLister::nameToFname( const QString& name )const {
00180     return name;
00181 }

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