summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp3
-rw-r--r--noncore/graphics/opie-eye/phunk_view.pro2
2 files changed, 3 insertions, 2 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index aeaa3c6..74a8d0f 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -1,318 +1,319 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#include "iconview.h" 6#include "iconview.h"
7 7
8#include <lib/imagecache.h> 8#include <lib/imagecache.h>
9 9
10#include <iface/dirview.h> 10#include <iface/dirview.h>
11#include <iface/dirlister.h> 11#include <iface/dirlister.h>
12 12
13#include <qpe/config.h> 13#include <qpe/config.h>
14#include <qpe/resource.h> 14#include <qpe/resource.h>
15#include <qpe/qpemessagebox.h> 15#include <qpe/qpemessagebox.h>
16#include <qpe/ir.h> 16#include <qpe/ir.h>
17#include <qpe/qcopenvelope_qws.h> 17#include <qpe/qcopenvelope_qws.h>
18 18
19#include <qiconview.h> 19#include <qiconview.h>
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qhbox.h> 21#include <qhbox.h>
22#include <qcombobox.h> 22#include <qcombobox.h>
23#include <qdir.h> 23#include <qdir.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qstyle.h> 27#include <qstyle.h>
28 28
29 29
30 30
31namespace { 31namespace {
32 QPixmap* _dirPix = 0; 32 QPixmap* _dirPix = 0;
33 QPixmap* _unkPix = 0; 33 QPixmap* _unkPix = 0;
34 class IconViewItem : public QIconViewItem { 34 class IconViewItem : public QIconViewItem {
35 public: 35 public:
36 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); 36 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
37 QPixmap* pixmap()const; 37 QPixmap* pixmap()const;
38 QString path()const { return m_path; } 38 QString path()const { return m_path; }
39 bool isDir()const { return m_isDir; } 39 bool isDir()const { return m_isDir; }
40 void setText( const QString& ); 40 void setText( const QString& );
41 void reCalc(); 41 void reCalc();
42 private: 42 private:
43 mutable QPixmap* m_pix; 43 mutable QPixmap* m_pix;
44 QString m_path; 44 QString m_path;
45 bool m_isDir : 1; 45 bool m_isDir : 1;
46 bool m_noInfo :1; 46 bool m_noInfo :1;
47 }; 47 };
48 48
49 49
50/* 50/*
51 * If we request an Image or String 51 * If we request an Image or String
52 * we add it to the map 52 * we add it to the map
53 */ 53 */
54 QMap<QString, IconViewItem*> g_stringInf; 54 QMap<QString, IconViewItem*> g_stringInf;
55 QMap<QString, IconViewItem*> g_stringPix; 55 QMap<QString, IconViewItem*> g_stringPix;
56 56
57 IconViewItem::IconViewItem( QIconView* view,const QString& path, 57 IconViewItem::IconViewItem( QIconView* view,const QString& path,
58 const QString& name, bool isDir ) 58 const QString& name, bool isDir )
59 : QIconViewItem( view ), m_path( path ), m_isDir( isDir ), 59 : QIconViewItem( view ), m_path( path ), m_isDir( isDir ),
60 m_noInfo( false ) 60 m_noInfo( false )
61 { 61 {
62 QIconViewItem::setText( name ); 62 QIconViewItem::setText( name );
63 if ( isDir && !_dirPix ) 63 if ( isDir && !_dirPix )
64 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 64 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
65 else if ( !isDir && !_unkPix ) 65 else if ( !isDir && !_unkPix )
66 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 66 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
67 } 67 }
68 inline QPixmap* IconViewItem::pixmap()const { 68 inline QPixmap* IconViewItem::pixmap()const {
69 if ( m_isDir ) 69 if ( m_isDir )
70 return _dirPix; 70 return _dirPix;
71 else{ 71 else{
72 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 72 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
73 currentView()->dirLister()->imageInfo( m_path ); 73 currentView()->dirLister()->imageInfo( m_path );
74 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 74 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
75 } 75 }
76 76
77 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); 77 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
78 if ( !m_pix && !g_stringPix.contains( m_path )) { 78 if ( !m_pix && !g_stringPix.contains( m_path )) {
79 currentView()->dirLister()->thumbNail( m_path, 64, 64 ); 79 currentView()->dirLister()->thumbNail( m_path, 64, 64 );
80 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 80 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
81 } 81 }
82 return m_pix ? m_pix : _unkPix; 82 return m_pix ? m_pix : _unkPix;
83 } 83 }
84 } 84 }
85 inline void IconViewItem::setText( const QString& str ) { 85 inline void IconViewItem::setText( const QString& str ) {
86 QString text = QIconViewItem::text()+"\n"+str; 86 QString text = QIconViewItem::text()+"\n"+str;
87 m_noInfo = true; 87 m_noInfo = true;
88 QIconViewItem::setText( text ); 88 QIconViewItem::setText( text );
89 reCalc();
89 } 90 }
90 91
91 inline void IconViewItem::reCalc() 92 inline void IconViewItem::reCalc()
92 { 93 {
93 calcRect(); 94 calcRect();
94 } 95 }
95} 96}
96 97
97 98
98PIconView::PIconView( QWidget* wid, Config* cfg ) 99PIconView::PIconView( QWidget* wid, Config* cfg )
99 : QVBox( wid ), m_cfg( cfg ) 100 : QVBox( wid ), m_cfg( cfg )
100{ 101{
101 { 102 {
102 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 103 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
103 } 104 }
104 m_path = QDir::homeDirPath(); 105 m_path = QDir::homeDirPath();
105 106
106 QHBox *hbox = new QHBox( this ); 107 QHBox *hbox = new QHBox( this );
107 QLabel* lbl = new QLabel( hbox ); 108 QLabel* lbl = new QLabel( hbox );
108 lbl->setText( tr("View as" ) ); 109 lbl->setText( tr("View as" ) );
109 110
110 m_views = new QComboBox( hbox, "View As" ); 111 m_views = new QComboBox( hbox, "View As" );
111 connect( m_views, SIGNAL(activated(int)), 112 connect( m_views, SIGNAL(activated(int)),
112 this, SLOT(slotViewChanged(int)) ); 113 this, SLOT(slotViewChanged(int)) );
113 114
114 m_view= new QIconView( this ); 115 m_view= new QIconView( this );
115 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 116 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
116 this, SLOT(slotClicked(QIconViewItem*)) ); 117 this, SLOT(slotClicked(QIconViewItem*)) );
117 118
118 m_view->setArrangement( QIconView::LeftToRight ); 119 m_view->setArrangement( QIconView::LeftToRight );
119 m_view->setItemTextPos( QIconView::Right ); 120 m_view->setItemTextPos( QIconView::Right );
120 m_view->setResizeMode(QIconView::Adjust); 121 m_view->setResizeMode(QIconView::Adjust);
121 122
122 int dw = QApplication::desktop()->width(); 123 int dw = QApplication::desktop()->width();
123 int viewerWidth = dw-style().scrollBarExtent().width(); 124 int viewerWidth = dw-style().scrollBarExtent().width();
124 m_view->setGridX( viewerWidth-2*m_view->spacing() ); 125 m_view->setGridX( viewerWidth-2*m_view->spacing() );
125 m_view->setGridY( fontMetrics().height()*2+40 ); 126 m_view->setGridY( fontMetrics().height()*2+40 );
126 loadViews(); 127 loadViews();
127 slotViewChanged( m_views->currentItem() ); 128 slotViewChanged( m_views->currentItem() );
128} 129}
129 130
130PIconView::~PIconView() { 131PIconView::~PIconView() {
131 { 132 {
132 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 133 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
133 } 134 }
134} 135}
135 136
136void PIconView::slotDirUp() { 137void PIconView::slotDirUp() {
137 QDir dir( m_path ); 138 QDir dir( m_path );
138 dir.cdUp(); 139 dir.cdUp();
139 slotChangeDir( dir.absPath() ); 140 slotChangeDir( dir.absPath() );
140 141
141} 142}
142 143
143void PIconView::slotChangeDir(const QString& path) { 144void PIconView::slotChangeDir(const QString& path) {
144 if ( !currentView() ) 145 if ( !currentView() )
145 return; 146 return;
146 147
147 PDirLister *lister = currentView()->dirLister(); 148 PDirLister *lister = currentView()->dirLister();
148 if (!lister ) 149 if (!lister )
149 return; 150 return;
150 151
151 lister->setStartPath( path ); 152 lister->setStartPath( path );
152 m_path = lister->currentPath(); 153 m_path = lister->currentPath();
153 154
154 m_view->clear(); 155 m_view->clear();
155 addFolders( lister->folders() ); 156 addFolders( lister->folders() );
156 addFiles( lister->files() ); 157 addFiles( lister->files() );
157 158
158 // Also invalidate the cache. We can't cancel the operations anyway 159 // Also invalidate the cache. We can't cancel the operations anyway
159 g_stringPix.clear(); 160 g_stringPix.clear();
160 g_stringInf.clear(); 161 g_stringInf.clear();
161 162
162 // looks ugly 163 // looks ugly
163 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 164 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
164} 165}
165 166
166QString PIconView::currentFileName(bool &isDir)const { 167QString PIconView::currentFileName(bool &isDir)const {
167 isDir = false; 168 isDir = false;
168 QIconViewItem* _it = m_view->currentItem(); 169 QIconViewItem* _it = m_view->currentItem();
169 if ( !_it ) 170 if ( !_it )
170 return QString::null; 171 return QString::null;
171 172
172 IconViewItem* it = static_cast<IconViewItem*>( _it ); 173 IconViewItem* it = static_cast<IconViewItem*>( _it );
173 isDir = it->isDir(); 174 isDir = it->isDir();
174 return it->path(); 175 return it->path();
175} 176}
176 177
177void PIconView::slotTrash() { 178void PIconView::slotTrash() {
178 bool isDir; 179 bool isDir;
179 QString pa = currentFileName( isDir ); 180 QString pa = currentFileName( isDir );
180 if ( isDir && pa.isEmpty() ) 181 if ( isDir && pa.isEmpty() )
181 return; 182 return;
182 183
183 if (!QPEMessageBox::confirmDelete( this, 184 if (!QPEMessageBox::confirmDelete( this,
184 tr("Delete Image" ), 185 tr("Delete Image" ),
185 tr("the Image %1" ).arg(pa))) 186 tr("the Image %1" ).arg(pa)))
186 return 187 return
187 188
188 189
189 currentView()->dirLister()->deleteImage( pa ); 190 currentView()->dirLister()->deleteImage( pa );
190 delete m_view->currentItem(); 191 delete m_view->currentItem();
191} 192}
192void PIconView::loadViews() { 193void PIconView::loadViews() {
193 ViewMap::Iterator it; 194 ViewMap::Iterator it;
194 ViewMap* map = viewMap(); 195 ViewMap* map = viewMap();
195 for ( it = map->begin(); it != map->end(); ++it ) 196 for ( it = map->begin(); it != map->end(); ++it )
196 m_views->insertItem( QObject::tr(it.key() ) ); 197 m_views->insertItem( QObject::tr(it.key() ) );
197} 198}
198 199
199void PIconView::resetView() { 200void PIconView::resetView() {
200 slotViewChanged(m_views->currentItem()); 201 slotViewChanged(m_views->currentItem());
201} 202}
202 203
203void PIconView::slotViewChanged( int i) { 204void PIconView::slotViewChanged( int i) {
204 if (!m_views->count() ) { 205 if (!m_views->count() ) {
205 setCurrentView( 0l); 206 setCurrentView( 0l);
206 return; 207 return;
207 } 208 }
208 209
209 PDirView* cur = currentView(); 210 PDirView* cur = currentView();
210 delete cur; 211 delete cur;
211 QString str = m_views->text(i); 212 QString str = m_views->text(i);
212 cur = (*(*viewMap())[str])(*m_cfg); 213 cur = (*(*viewMap())[str])(*m_cfg);
213 setCurrentView( cur ); 214 setCurrentView( cur );
214 215
215 /* connect to the signals of the lister */ 216 /* connect to the signals of the lister */
216 PDirLister* lis = cur->dirLister(); 217 PDirLister* lis = cur->dirLister();
217 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 218 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
218 this, SLOT( slotThumbInfo(const QString&, const QString&))); 219 this, SLOT( slotThumbInfo(const QString&, const QString&)));
219 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 220 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
220 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 221 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
221 connect(lis, SIGNAL(sig_start()), 222 connect(lis, SIGNAL(sig_start()),
222 this, SLOT(slotStart())); 223 this, SLOT(slotStart()));
223 connect(lis, SIGNAL(sig_end()) , 224 connect(lis, SIGNAL(sig_end()) ,
224 this, SLOT(slotEnd()) ); 225 this, SLOT(slotEnd()) );
225 226
226 227
227 /* reload now */ 228 /* reload now */
228 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 229 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
229} 230}
230 231
231 232
232void PIconView::slotReloadDir() { 233void PIconView::slotReloadDir() {
233 slotChangeDir( m_path ); 234 slotChangeDir( m_path );
234} 235}
235 236
236 237
237void PIconView::addFolders( const QStringList& lst) { 238void PIconView::addFolders( const QStringList& lst) {
238 QStringList::ConstIterator it; 239 QStringList::ConstIterator it;
239 240
240 for(it=lst.begin(); it != lst.end(); ++it ) { 241 for(it=lst.begin(); it != lst.end(); ++it ) {
241 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); 242 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
242 } 243 }
243 244
244} 245}
245 246
246void PIconView::addFiles( const QStringList& lst) { 247void PIconView::addFiles( const QStringList& lst) {
247 QStringList::ConstIterator it; 248 QStringList::ConstIterator it;
248 for (it=lst.begin(); it!= lst.end(); ++it ) 249 for (it=lst.begin(); it!= lst.end(); ++it )
249 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); 250 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
250 251
251} 252}
252 253
253void PIconView::slotClicked(QIconViewItem* _it) { 254void PIconView::slotClicked(QIconViewItem* _it) {
254 if(!_it ) 255 if(!_it )
255 return; 256 return;
256 257
257 IconViewItem* it = static_cast<IconViewItem*>(_it); 258 IconViewItem* it = static_cast<IconViewItem*>(_it);
258 if( it->isDir() ) 259 if( it->isDir() )
259 slotChangeDir( it->path() ); 260 slotChangeDir( it->path() );
260 else // view image 261 else // view image
261 ; 262 ;
262} 263}
263 264
264void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 265void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
265 if ( g_stringInf.contains( _path ) ) { 266 if ( g_stringInf.contains( _path ) ) {
266 IconViewItem* item = g_stringInf[_path]; 267 IconViewItem* item = g_stringInf[_path];
267 /* if set the view shows nonsens! 268 /* if set the view shows nonsens!
268 I dont know how to fix the format of displayed text :(*/ 269 I dont know how to fix the format of displayed text :(*/
269 //item->setText( str ); 270 item->setText( str );
270 item->repaint(); 271 item->repaint();
271 g_stringInf.remove( _path ); 272 g_stringInf.remove( _path );
272 } 273 }
273} 274}
274void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 275void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
275 if ( g_stringPix.contains( _path ) ) { 276 if ( g_stringPix.contains( _path ) ) {
276 IconViewItem* item = g_stringPix[_path]; 277 IconViewItem* item = g_stringPix[_path];
277 278
278 if (pix.width()>0) { 279 if (pix.width()>0) {
279 PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); 280 PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
280 /* required for a recalculated rectangle. otherwise the view show nonsense! */ 281 /* required for a recalculated rectangle. otherwise the view show nonsense! */
281 item->reCalc(); 282 item->reCalc();
282 } else { 283 } else {
283 PPixmapCache::self()->insertImage(_path,Resource::loadPixmap( "UnknownDocument" ),64,64 ); 284 PPixmapCache::self()->insertImage(_path,Resource::loadPixmap( "UnknownDocument" ),64,64 );
284 } 285 }
285 item->repaint(); 286 item->repaint();
286 g_stringPix.remove( _path ); 287 g_stringPix.remove( _path );
287 } 288 }
288} 289}
289 290
290 291
291void PIconView::slotRename() { 292void PIconView::slotRename() {
292 293
293} 294}
294 295
295void PIconView::slotBeam() { 296void PIconView::slotBeam() {
296 bool isDir; 297 bool isDir;
297 QString pa = currentFileName( isDir ); 298 QString pa = currentFileName( isDir );
298 if ( isDir && pa.isEmpty() ) 299 if ( isDir && pa.isEmpty() )
299 return; 300 return;
300 301
301 Ir* ir = new Ir( this ); 302 Ir* ir = new Ir( this );
302 connect( ir, SIGNAL(done(Ir*)), 303 connect( ir, SIGNAL(done(Ir*)),
303 this, SLOT(slotBeamDone(Ir*))); 304 this, SLOT(slotBeamDone(Ir*)));
304 ir->send(pa, tr( "Image" ) ); 305 ir->send(pa, tr( "Image" ) );
305 306
306} 307}
307 308
308void PIconView::slotBeamDone( Ir* ir) { 309void PIconView::slotBeamDone( Ir* ir) {
309 delete ir; 310 delete ir;
310} 311}
311 312
312void PIconView::slotStart() { 313void PIconView::slotStart() {
313 m_view->setUpdatesEnabled( false ); 314 m_view->setUpdatesEnabled( false );
314} 315}
315 316
316void PIconView::slotEnd() { 317void PIconView::slotEnd() {
317 m_view->setUpdatesEnabled( true ); 318 m_view->setUpdatesEnabled( true );
318} 319}
diff --git a/noncore/graphics/opie-eye/phunk_view.pro b/noncore/graphics/opie-eye/phunk_view.pro
index 0bb5679..3547af0 100644
--- a/noncore/graphics/opie-eye/phunk_view.pro
+++ b/noncore/graphics/opie-eye/phunk_view.pro
@@ -1,34 +1,34 @@
1CONFIG += qt warn_on #quick-app 1CONFIG += qt warn_on quick-app
2DESTDIR = $(OPIEDIR)/bin 2DESTDIR = $(OPIEDIR)/bin
3TEMPLATE = app 3TEMPLATE = app
4TARGET = opie-eye 4TARGET = opie-eye
5# the name of the resulting object 5# the name of the resulting object
6 6
7HEADERS = gui/iconview.h gui/filesystem.h gui/mainwindow.h \ 7HEADERS = gui/iconview.h gui/filesystem.h gui/mainwindow.h \
8 lib/imagecache.h impl/dir/dir_dirview.h \ 8 lib/imagecache.h impl/dir/dir_dirview.h \
9 iface/dirview.h iface/dirlister.h iface/ifaceinfo.h \ 9 iface/dirview.h iface/dirlister.h iface/ifaceinfo.h \
10 impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \ 10 impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \
11 lib/slavemaster.h \ 11 lib/slavemaster.h \
12 iface/slaveiface.h 12 iface/slaveiface.h
13 13
14# A list header files 14# A list header files
15 15
16 16
17SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \ 17SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \
18 lib/imagecache.cpp lib/viewmap.cpp \ 18 lib/imagecache.cpp lib/viewmap.cpp \
19 impl/dir/dir_dirview.cpp iface/dirlister.cpp \ 19 impl/dir/dir_dirview.cpp iface/dirlister.cpp \
20 iface/dirview.cpp impl/dir/dir_lister.cpp \ 20 iface/dirview.cpp impl/dir/dir_lister.cpp \
21 impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp 21 impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp
22# A list of source files 22# A list of source files
23 23
24INTERFACES = 24INTERFACES =
25# list of ui files 25# list of ui files
26 26
27INCLUDEPATH += . $(OPIEDIR)/include 27INCLUDEPATH += . $(OPIEDIR)/include
28DEPENDPATH += $(OPIEDIR)/include 28DEPENDPATH += $(OPIEDIR)/include
29 29
30 30
31 31
32LIBS += -lqpe -lopieui2 32LIBS += -lqpe -lopieui2
33 33
34include ( $(OPIEDIR)/include.pro ) 34include ( $(OPIEDIR)/include.pro )