summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp
Unidiff
Diffstat (limited to 'noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp181
1 files changed, 181 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp b/noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp
new file mode 100644
index 0000000..3c3d702
--- a/dev/null
+++ b/noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp
@@ -0,0 +1,181 @@
1/*
2 * GPLv2 zecke@handhelds.org
3 */
4
5#include "dcim_lister.h"
6#include <lib/slavemaster.h>
7
8#include <opie2/odebug.h>
9#include <qpe/storage.h>
10
11#include <qdir.h>
12#include <qfileinfo.h>
13#include <qimage.h>
14
15DCIM_DirLister::DCIM_DirLister()
16 : PDirLister( "dcim_dirlister" )
17{
18
19 /*
20 * create a SlaveMaster and lets connect the signal of
21 * it to our interface
22 */
23 SlaveHelper::slaveConnectSignals( this );
24 m_mode = ListingUnknown;
25}
26
27DCIM_DirLister::~DCIM_DirLister() {}
28
29QString DCIM_DirLister::defaultPath()const {
30 m_mode = ListingStart;
31 return QString::null;
32}
33
34QString DCIM_DirLister::setStartPath( const QString& str) {
35 /**
36 * IconView adds a '/' to path. Lets strip
37 * that.
38 */
39 QString st = str.mid( 1 );
40 if ( ListingStart == m_mode && m_map.contains( st ) ) {
41 m_path = m_map[st]+ "/dcim";
42 m_mode = ListingFolder;
43 }else if ( m_mode == ListingFolder ) {
44 m_mode = ListingFiles;
45 m_path = str;
46 }else if ( m_mode == ListingReFolder ) {
47 m_mode = ListingFolder;
48 }
49
50 owarn << " StartPath2 " << str << " " << m_path << oendl;
51
52 return m_path;
53}
54
55
56QString DCIM_DirLister::currentPath()const {
57 return m_path;
58}
59
60/*
61 * depending on the mode we will either
62 * Find Digital Cameras
63 */
64QStringList DCIM_DirLister::folders()const {
65 QStringList lst;
66
67 switch( m_mode ) {
68 case ListingUnknown:
69 case ListingStart:
70 lst = findCameras();
71 break;
72 case ListingFolder:
73 lst = findAlbums();
74 break;
75 case ListingFiles:
76 default:
77 break;
78 }
79
80 return lst;
81}
82
83QStringList DCIM_DirLister::files()const {
84 if ( m_mode != ListingFiles )
85 return QStringList();
86 else
87 return findImages();
88}
89
90QString DCIM_DirLister::dirUp( const QString& p )const {
91 QString str;
92
93 switch( m_mode ) {
94 case ListingFiles:
95 m_mode = ListingReFolder;
96 str = PDirLister::dirUp( p );
97 break;
98 case ListingFolder:
99 m_mode = ListingStart;
100 break;
101 case ListingUnknown:
102 case ListingStart:
103 default:
104 break;
105 }
106
107 /* down cases */
108 owarn << " New String " << str << " old path " << m_mode << oendl;
109 m_path = str;
110 return str;
111}
112
113
114QStringList DCIM_DirLister::findCameras()const {
115 QStringList lst;
116 StorageInfo inf;
117
118 m_map.clear();
119
120 const QList<FileSystem> &list = inf.fileSystems();
121 QListIterator<FileSystem> it( list );
122
123
124 FileSystem *sys;
125 for ( sys = it.current(); (sys=it.current())!=0 ; ++it )
126 if ( QFileInfo( sys->path() + "/dcim/" ).exists() ) {
127 lst << sys->name();
128 m_map.insert( sys->name(), sys->path() );
129 }
130
131 if ( lst.isEmpty() ) {
132 m_mode = ListingUnknown;
133 lst << QObject::tr("Error no Camera Dir found");
134 }else
135 m_mode = ListingStart;
136
137 return lst;
138}
139
140QStringList DCIM_DirLister::findAlbums()const {
141 QStringList lst = QDir( m_path ).entryList( QDir::Dirs );
142 lst.remove( "." );
143 lst.remove( ".." );
144
145 return lst;
146}
147
148QStringList DCIM_DirLister::findImages()const {
149 return QDir( m_path ).entryList("*.jpg *.jpeg *.png", QDir::Files );
150}
151
152void DCIM_DirLister::deleteImage( const QString& fl ) {
153 QFileInfo inf( fl );
154 QFile::remove( fl );
155 QFile::remove( inf.dirPath ()+"/preview"+
156 inf.fileName() );
157}
158
159void DCIM_DirLister::thumbNail( const QString& _str, int w, int h ) {
160 QFileInfo inf( _str );
161 QString str = QFileInfo( inf.dirPath()+"/preview"+ inf.fileName() ).exists() ?
162 inf.dirPath()+"/preview"+ inf.fileName() : _str;
163
164 SlaveMaster::self()->thumbNail( str, w, h );
165}
166
167QImage DCIM_DirLister::image( const QString& str, Factor f, int m ) {
168 return SlaveMaster::self()->image( str, f, m );
169}
170
171void DCIM_DirLister::imageInfo( const QString& str ) {
172 SlaveMaster::self()->thumbInfo( str );
173}
174
175void DCIM_DirLister::fullImageInfo( const QString& str ) {
176 SlaveMaster::self()->imageInfo( str );
177}
178
179QString DCIM_DirLister::nameToFname( const QString& name )const {
180 return name;
181}