summaryrefslogtreecommitdiff
authorzecke <zecke>2004-04-02 19:28:09 (UTC)
committer zecke <zecke>2004-04-02 19:28:09 (UTC)
commit97bdc55663590ba430a4f322ad97aab9f4c02bf3 (patch) (unidiff)
tree8d340684ac97907b73d6b8abf995116f58680cdd
parent09d1ebb55ab44ebd129ff44b83b6b20054df77aa (diff)
downloadopie-97bdc55663590ba430a4f322ad97aab9f4c02bf3.zip
opie-97bdc55663590ba430a4f322ad97aab9f4c02bf3.tar.gz
opie-97bdc55663590ba430a4f322ad97aab9f4c02bf3.tar.bz2
-Fix realignment of the items but now it updates too often
-Fix slave not to include <qt></qt> for iconViewName
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp29
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp2
-rw-r--r--noncore/graphics/opie-eye/slave/gif_slave.cpp3
-rw-r--r--noncore/graphics/opie-eye/slave/jpeg_slave.cpp5
-rw-r--r--noncore/graphics/opie-eye/slave/png_slave.cpp3
5 files changed, 20 insertions, 22 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index b3f0006..ed9fc9c 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -1,378 +1,375 @@
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 <opie2/oconfig.h> 13#include <opie2/oconfig.h>
14#include <opie2/okeyconfigwidget.h> 14#include <opie2/okeyconfigwidget.h>
15#include <opie2/odebug.h>
15 16
16#include <qpe/resource.h> 17#include <qpe/resource.h>
17#include <qpe/qpemessagebox.h> 18#include <qpe/qpemessagebox.h>
18#include <qpe/ir.h> 19#include <qpe/ir.h>
19#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
20 21
21 22
22#include <qiconview.h> 23#include <qiconview.h>
23#include <qlabel.h> 24#include <qlabel.h>
24#include <qhbox.h> 25#include <qhbox.h>
25#include <qcombobox.h> 26#include <qcombobox.h>
26#include <qdir.h> 27#include <qdir.h>
27#include <qapplication.h> 28#include <qapplication.h>
28#include <qmainwindow.h> 29#include <qmainwindow.h>
29#include <qtimer.h> 30#include <qtimer.h>
30#include <qstyle.h> 31#include <qstyle.h>
31 32
32 33
33using Opie::Ui::OKeyConfigItem; 34using Opie::Ui::OKeyConfigItem;
34 35
35namespace { 36namespace {
36 QPixmap* _dirPix = 0; 37 QPixmap* _dirPix = 0;
37 QPixmap* _unkPix = 0; 38 QPixmap* _unkPix = 0;
38 class IconViewItem : public QIconViewItem { 39 class IconViewItem : public QIconViewItem {
39 public: 40 public:
40 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); 41 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
41 QPixmap* pixmap()const; 42 QPixmap* pixmap()const;
42 QString path()const { return m_path; } 43 QString path()const { return m_path; }
43 bool isDir()const { return m_isDir; } 44 bool isDir()const { return m_isDir; }
44 void setText( const QString& ); 45 void setText( const QString& );
45 void reCalc(); 46
47
46 private: 48 private:
47 mutable QPixmap* m_pix; 49 mutable QPixmap* m_pix;
48 QString m_path; 50 QString m_path;
49 bool m_isDir : 1; 51 bool m_isDir : 1;
50 bool m_noInfo :1; 52 bool m_noInfo :1;
51 }; 53 };
52 54
53 55
54/* 56/*
55 * If we request an Image or String 57 * If we request an Image or String
56 * we add it to the map 58 * we add it to the map
57 */ 59 */
58 QMap<QString, IconViewItem*> g_stringInf; 60 QMap<QString, IconViewItem*> g_stringInf;
59 QMap<QString, IconViewItem*> g_stringPix; 61 QMap<QString, IconViewItem*> g_stringPix;
60 62
61 IconViewItem::IconViewItem( QIconView* view,const QString& path, 63 IconViewItem::IconViewItem( QIconView* view,const QString& path,
62 const QString& name, bool isDir ) 64 const QString& name, bool isDir )
63 : QIconViewItem( view ), m_path( path ), m_isDir( isDir ), 65 : QIconViewItem( view ), m_path( path ), m_isDir( isDir ),
64 m_noInfo( false ) 66 m_noInfo( false )
65 { 67 {
66 QIconViewItem::setText( name ); 68 QIconViewItem::setText( name );
67 if ( isDir && !_dirPix ) 69 if ( isDir && !_dirPix )
68 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 70 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
69 else if ( !isDir && !_unkPix ) 71 else if ( !isDir && !_unkPix )
70 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 72 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
71 } 73 }
72 inline QPixmap* IconViewItem::pixmap()const { 74 inline QPixmap* IconViewItem::pixmap()const {
75 qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d",
76 rect().x(),rect().y(),rect().width(),rect().height(),
77 iconView()->contentsX(), iconView()->contentsY());
78
73 if ( m_isDir ) 79 if ( m_isDir )
74 return _dirPix; 80 return _dirPix;
75 else{ 81 else{
76 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 82 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
77 currentView()->dirLister()->imageInfo( m_path ); 83 currentView()->dirLister()->imageInfo( m_path );
78 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 84 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
79 } 85 }
80 86
81 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); 87 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
82 if ( !m_pix && !g_stringPix.contains( m_path )) { 88 if ( !m_pix && !g_stringPix.contains( m_path )) {
83 currentView()->dirLister()->thumbNail( m_path, 64, 64 ); 89 currentView()->dirLister()->thumbNail( m_path, 64, 64 );
84 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 90 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
85 } 91 }
86 return m_pix ? m_pix : _unkPix; 92 return m_pix ? m_pix : _unkPix;
87 } 93 }
88 } 94 }
89 inline void IconViewItem::setText( const QString& str ) { 95 inline void IconViewItem::setText( const QString& str ) {
90 QString text = QIconViewItem::text()+"\n"+str; 96 QString text = QIconViewItem::text()+"\n"+str;
91 m_noInfo = true; 97 m_noInfo = true;
92 QIconViewItem::setText( text ); 98 QIconViewItem::setText( text );
93 reCalc();
94 }
95
96 inline void IconViewItem::reCalc()
97 {
98 calcRect();
99 } 99 }
100} 100}
101 101
102 102
103PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 103PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
104 : QVBox( wid ), m_cfg( cfg ) 104 : QVBox( wid ), m_cfg( cfg )
105{ 105{
106 { 106 {
107 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 107 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
108 } 108 }
109 m_path = QDir::homeDirPath(); 109 m_path = QDir::homeDirPath();
110 110
111 QHBox *hbox = new QHBox( this ); 111 QHBox *hbox = new QHBox( this );
112 QLabel* lbl = new QLabel( hbox ); 112 QLabel* lbl = new QLabel( hbox );
113 lbl->setText( tr("View as" ) ); 113 lbl->setText( tr("View as" ) );
114 114
115 m_views = new QComboBox( hbox, "View As" ); 115 m_views = new QComboBox( hbox, "View As" );
116 connect( m_views, SIGNAL(activated(int)), 116 connect( m_views, SIGNAL(activated(int)),
117 this, SLOT(slotViewChanged(int)) ); 117 this, SLOT(slotViewChanged(int)) );
118 118
119 m_view= new QIconView( this ); 119 m_view= new QIconView( this );
120 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 120 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
121 this, SLOT(slotClicked(QIconViewItem*)) ); 121 this, SLOT(slotClicked(QIconViewItem*)) );
122 122
123 m_view->setArrangement( QIconView::LeftToRight ); 123 m_view->setArrangement( QIconView::LeftToRight );
124 m_view->setItemTextPos( QIconView::Right ); 124 m_view->setItemTextPos( QIconView::Right );
125 m_view->setResizeMode(QIconView::Adjust);
126 125
127 int dw = QApplication::desktop()->width(); 126 int dw = QApplication::desktop()->width();
128 int viewerWidth = dw-style().scrollBarExtent().width(); 127 int viewerWidth = dw-style().scrollBarExtent().width();
129 m_view->setGridX( viewerWidth-2*m_view->spacing() ); 128 m_view->setGridX( viewerWidth-3*m_view->spacing());
130 m_view->setGridY( fontMetrics().height()*2+40 ); 129 m_view->setGridY( fontMetrics().height()*2+40 );
131 130
132 131
133 initKeys(); 132 initKeys();
134 133
135 loadViews(); 134 loadViews();
136 slotViewChanged( m_views->currentItem() ); 135 slotViewChanged( m_views->currentItem() );
137} 136}
138 137
139PIconView::~PIconView() { 138PIconView::~PIconView() {
140 { 139 {
141 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 140 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
142 } 141 }
143 m_viewManager->save(); 142 m_viewManager->save();
144 delete m_viewManager; 143 delete m_viewManager;
145} 144}
146 145
147Opie::Ui::OKeyConfigManager* PIconView::manager() { 146Opie::Ui::OKeyConfigManager* PIconView::manager() {
148 return m_viewManager; 147 return m_viewManager;
149} 148}
150 149
151void PIconView::initKeys() { 150void PIconView::initKeys() {
152 Opie::Ui::OKeyPair::List lst; 151 Opie::Ui::OKeyPair::List lst;
153 lst.append( Opie::Ui::OKeyPair::upArrowKey() ); 152 lst.append( Opie::Ui::OKeyPair::upArrowKey() );
154 lst.append( Opie::Ui::OKeyPair::downArrowKey() ); 153 lst.append( Opie::Ui::OKeyPair::downArrowKey() );
155 lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); 154 lst.append( Opie::Ui::OKeyPair::leftArrowKey() );
156 lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); 155 lst.append( Opie::Ui::OKeyPair::rightArrowKey() );
157 lst.append( Opie::Ui::OKeyPair::returnKey() ); 156 lst.append( Opie::Ui::OKeyPair::returnKey() );
158 157
159 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 158 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
160 lst, false,this, "keyconfig name" ); 159 lst, false,this, "keyconfig name" );
161 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 160 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
162 QString::fromLatin1("beam"), BeamItem, 161 QString::fromLatin1("beam"), BeamItem,
163 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton), 162 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton),
164 this, SLOT(slotBeam())) ); 163 this, SLOT(slotBeam())) );
165 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 164 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
166 QString::fromLatin1("trash"), DeleteItem, 165 QString::fromLatin1("trash"), DeleteItem,
167 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton), 166 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton),
168 this, SLOT(slotTrash())) ); 167 this, SLOT(slotTrash())) );
169 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 168 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
170 QString::fromLatin1("1to1"), ViewItem, 169 QString::fromLatin1("1to1"), ViewItem,
171 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), 170 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton),
172 this, SLOT(slotShowImage()))); 171 this, SLOT(slotShowImage())));
173 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 172 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
174 QString::fromLatin1("DocumentTypeWord"), InfoItem, 173 QString::fromLatin1("DocumentTypeWord"), InfoItem,
175 Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 174 Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
176 this, SLOT(slotImageInfo()) ) ); 175 this, SLOT(slotImageInfo()) ) );
177 m_viewManager->load(); 176 m_viewManager->load();
178 m_viewManager->handleWidget( m_view ); 177 m_viewManager->handleWidget( m_view );
179} 178}
180 179
181void PIconView::slotDirUp() { 180void PIconView::slotDirUp() {
182 QDir dir( m_path ); 181 QDir dir( m_path );
183 dir.cdUp(); 182 dir.cdUp();
184 slotChangeDir( dir.absPath() ); 183 slotChangeDir( dir.absPath() );
185 184
186} 185}
187 186
188void PIconView::slotChangeDir(const QString& path) { 187void PIconView::slotChangeDir(const QString& path) {
189 if ( !currentView() ) 188 if ( !currentView() )
190 return; 189 return;
191 190
192 PDirLister *lister = currentView()->dirLister(); 191 PDirLister *lister = currentView()->dirLister();
193 if (!lister ) 192 if (!lister )
194 return; 193 return;
195 194
196 lister->setStartPath( path ); 195 lister->setStartPath( path );
197 m_path = lister->currentPath(); 196 m_path = lister->currentPath();
198 197
199 m_view->setUpdatesEnabled( false ); 198 m_view->viewport()->setUpdatesEnabled( false );
200 m_view->clear(); 199 m_view->clear();
201 addFolders( lister->folders() ); 200 addFolders( lister->folders() );
202 addFiles( lister->files() ); 201 addFiles( lister->files() );
203 m_view->setUpdatesEnabled( true ); 202 m_view->viewport()->setUpdatesEnabled( true );
204 203
205 // Also invalidate the cache. We can't cancel the operations anyway 204 // Also invalidate the cache. We can't cancel the operations anyway
206 g_stringPix.clear(); 205 g_stringPix.clear();
207 g_stringInf.clear(); 206 g_stringInf.clear();
208 207
209 // looks ugly 208 // looks ugly
210 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 209 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
211} 210}
212 211
213QString PIconView::currentFileName(bool &isDir)const { 212QString PIconView::currentFileName(bool &isDir)const {
214 isDir = false; 213 isDir = false;
215 QIconViewItem* _it = m_view->currentItem(); 214 QIconViewItem* _it = m_view->currentItem();
216 if ( !_it ) 215 if ( !_it )
217 return QString::null; 216 return QString::null;
218 217
219 IconViewItem* it = static_cast<IconViewItem*>( _it ); 218 IconViewItem* it = static_cast<IconViewItem*>( _it );
220 isDir = it->isDir(); 219 isDir = it->isDir();
221 return it->path(); 220 return it->path();
222} 221}
223 222
224void PIconView::slotTrash() { 223void PIconView::slotTrash() {
225 bool isDir; 224 bool isDir;
226 QString pa = currentFileName( isDir ); 225 QString pa = currentFileName( isDir );
227 if ( isDir && pa.isEmpty() ) 226 if ( isDir && pa.isEmpty() )
228 return; 227 return;
229 228
230 if (!QPEMessageBox::confirmDelete( this, 229 if (!QPEMessageBox::confirmDelete( this,
231 tr("Delete Image" ), 230 tr("Delete Image" ),
232 tr("the Image %1" ).arg(pa))) 231 tr("the Image %1" ).arg(pa)))
233 return 232 return
234 233
235 234
236 currentView()->dirLister()->deleteImage( pa ); 235 currentView()->dirLister()->deleteImage( pa );
237 delete m_view->currentItem(); 236 delete m_view->currentItem();
238} 237}
239void PIconView::loadViews() { 238void PIconView::loadViews() {
240 ViewMap::Iterator it; 239 ViewMap::Iterator it;
241 ViewMap* map = viewMap(); 240 ViewMap* map = viewMap();
242 for ( it = map->begin(); it != map->end(); ++it ) 241 for ( it = map->begin(); it != map->end(); ++it )
243 m_views->insertItem( QObject::tr(it.key() ) ); 242 m_views->insertItem( QObject::tr(it.key() ) );
244} 243}
245 244
246void PIconView::resetView() { 245void PIconView::resetView() {
247 slotViewChanged(m_views->currentItem()); 246 slotViewChanged(m_views->currentItem());
248} 247}
249 248
250void PIconView::slotViewChanged( int i) { 249void PIconView::slotViewChanged( int i) {
251 if (!m_views->count() ) { 250 if (!m_views->count() ) {
252 setCurrentView( 0l); 251 setCurrentView( 0l);
253 return; 252 return;
254 } 253 }
255 254
256 PDirView* cur = currentView(); 255 PDirView* cur = currentView();
257 delete cur; 256 delete cur;
258 QString str = m_views->text(i); 257 QString str = m_views->text(i);
259 cur = (*(*viewMap())[str])(*m_cfg); 258 cur = (*(*viewMap())[str])(*m_cfg);
260 setCurrentView( cur ); 259 setCurrentView( cur );
261 260
262 /* connect to the signals of the lister */ 261 /* connect to the signals of the lister */
263 PDirLister* lis = cur->dirLister(); 262 PDirLister* lis = cur->dirLister();
264 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 263 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
265 this, SLOT( slotThumbInfo(const QString&, const QString&))); 264 this, SLOT( slotThumbInfo(const QString&, const QString&)));
266 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 265 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
267 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 266 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
268 connect(lis, SIGNAL(sig_start()), 267 connect(lis, SIGNAL(sig_start()),
269 this, SLOT(slotStart())); 268 this, SLOT(slotStart()));
270 connect(lis, SIGNAL(sig_end()) , 269 connect(lis, SIGNAL(sig_end()) ,
271 this, SLOT(slotEnd()) ); 270 this, SLOT(slotEnd()) );
272 271
273 272
274 /* reload now */ 273 /* reload now */
275 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 274 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
276} 275}
277 276
278 277
279void PIconView::slotReloadDir() { 278void PIconView::slotReloadDir() {
280 slotChangeDir( m_path ); 279 slotChangeDir( m_path );
281} 280}
282 281
283 282
284void PIconView::addFolders( const QStringList& lst) { 283void PIconView::addFolders( const QStringList& lst) {
285 QStringList::ConstIterator it; 284 QStringList::ConstIterator it;
286 285
287 for(it=lst.begin(); it != lst.end(); ++it ) { 286 for(it=lst.begin(); it != lst.end(); ++it ) {
288 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); 287 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
289 } 288 }
290 289
291} 290}
292 291
293void PIconView::addFiles( const QStringList& lst) { 292void PIconView::addFiles( const QStringList& lst) {
294 QStringList::ConstIterator it; 293 QStringList::ConstIterator it;
295 for (it=lst.begin(); it!= lst.end(); ++it ) 294 for (it=lst.begin(); it!= lst.end(); ++it )
296 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); 295 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
297 296
298} 297}
299 298
300void PIconView::slotClicked(QIconViewItem* _it) { 299void PIconView::slotClicked(QIconViewItem* _it) {
301 if(!_it ) 300 if(!_it )
302 return; 301 return;
303 302
304 IconViewItem* it = static_cast<IconViewItem*>(_it); 303 IconViewItem* it = static_cast<IconViewItem*>(_it);
305 if( it->isDir() ) 304 if( it->isDir() )
306 slotChangeDir( it->path() ); 305 slotChangeDir( it->path() );
307 else // view image 306 else // view image
308 ; 307 ;
309} 308}
310 309
311void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 310void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
312 if ( g_stringInf.contains( _path ) ) { 311 if ( g_stringInf.contains( _path ) ) {
313 IconViewItem* item = g_stringInf[_path]; 312 IconViewItem* item = g_stringInf[_path];
314 /* if set the view shows nonsens! 313 /* if set the view shows nonsens!
315 I dont know how to fix the format of displayed text :(*/ 314 I dont know how to fix the format of displayed text :(*/
316 item->setText( str ); 315 item->setText( str );
317 item->repaint();
318 g_stringInf.remove( _path ); 316 g_stringInf.remove( _path );
319 } 317 }
320} 318}
321void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 319void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
322 if ( g_stringPix.contains( _path ) ) { 320 if ( g_stringPix.contains( _path ) ) {
323 IconViewItem* item = g_stringPix[_path]; 321 IconViewItem* item = g_stringPix[_path];
324 322
325 if (pix.width()>0) { 323 if (pix.width()>0) {
326 PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); 324 PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
327 /* required for a recalculated rectangle. otherwise the view show nonsense! */ 325 /* required for a recalculated rectangle. otherwise the view show nonsense! */
328 item->reCalc();
329 } else { 326 } else {
330 PPixmapCache::self()->insertImage(_path,Resource::loadPixmap( "UnknownDocument" ),64,64 ); 327 PPixmapCache::self()->insertImage(_path,Resource::loadPixmap( "UnknownDocument" ),64,64 );
331 } 328 }
332 item->repaint();
333 g_stringPix.remove( _path ); 329 g_stringPix.remove( _path );
334 } 330 }
335} 331}
336 332
337 333
338void PIconView::slotRename() { 334void PIconView::slotRename() {
339 335
340} 336}
341 337
342void PIconView::slotBeam() { 338void PIconView::slotBeam() {
343 bool isDir; 339 bool isDir;
344 QString pa = currentFileName( isDir ); 340 QString pa = currentFileName( isDir );
345 if ( isDir && pa.isEmpty() ) 341 if ( isDir && pa.isEmpty() )
346 return; 342 return;
347 343
348 Ir* ir = new Ir( this ); 344 Ir* ir = new Ir( this );
349 connect( ir, SIGNAL(done(Ir*)), 345 connect( ir, SIGNAL(done(Ir*)),
350 this, SLOT(slotBeamDone(Ir*))); 346 this, SLOT(slotBeamDone(Ir*)));
351 ir->send(pa, tr( "Image" ) ); 347 ir->send(pa, tr( "Image" ) );
352 348
353} 349}
354 350
355void PIconView::slotBeamDone( Ir* ir) { 351void PIconView::slotBeamDone( Ir* ir) {
356 delete ir; 352 delete ir;
357} 353}
358 354
359void PIconView::slotStart() { 355void PIconView::slotStart() {
360 m_view->setUpdatesEnabled( false ); 356 m_view->viewport()->setUpdatesEnabled( false );
361} 357}
362 358
363void PIconView::slotEnd() { 359void PIconView::slotEnd() {
364 m_view->setUpdatesEnabled( true ); 360 m_view->arrangeItemsInGrid( );
361 m_view->viewport()->setUpdatesEnabled( true );
365} 362}
366 363
367void PIconView::slotShowImage() { 364void PIconView::slotShowImage() {
368 365
369} 366}
370void PIconView::slotShowImage( const QString& ) { 367void PIconView::slotShowImage( const QString& ) {
371 368
372} 369}
373void PIconView::slotImageInfo() { 370void PIconView::slotImageInfo() {
374 371
375} 372}
376void PIconView::slotImageInfo( const QString& ) { 373void PIconView::slotImageInfo( const QString& ) {
377 374
378} 375}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 0314659..83ff4f1 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -16,123 +16,123 @@
16 16
17 17
18#include <qpe/resource.h> 18#include <qpe/resource.h>
19#include <qpe/config.h> 19#include <qpe/config.h>
20#include <qpe/ir.h> 20#include <qpe/ir.h>
21 21
22#include <qtoolbar.h> 22#include <qtoolbar.h>
23#include <qtoolbutton.h> 23#include <qtoolbutton.h>
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qdialog.h> 25#include <qdialog.h>
26#include <qmap.h> 26#include <qmap.h>
27 27
28 28
29 29
30 30
31 31
32OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) 32OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> )
33 33
34PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 34PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
35 : QMainWindow( wid, name, style ) 35 : QMainWindow( wid, name, style )
36{ 36{
37 setCaption( QObject::tr("Opie Eye Caramba" ) ); 37 setCaption( QObject::tr("Opie Eye Caramba" ) );
38 m_cfg = new Opie::Core::OConfig("phunkview"); 38 m_cfg = new Opie::Core::OConfig("phunkview");
39 m_cfg->setGroup("Zecke_view" ); 39 m_cfg->setGroup("Zecke_view" );
40 40
41 41
42 /* 42 /*
43 * Initialize ToolBar and IconView 43 * Initialize ToolBar and IconView
44 * And Connect Them 44 * And Connect Them
45 */ 45 */
46 QToolBar *bar = new QToolBar( this ); 46 QToolBar *bar = new QToolBar( this );
47 bar->setHorizontalStretchable( true ); 47 bar->setHorizontalStretchable( true );
48 setToolBarsMovable( false ); 48 setToolBarsMovable( false );
49 49
50 m_view = new PIconView( this, m_cfg ); 50 m_view = new PIconView( this, m_cfg );
51 setCentralWidget( m_view ); 51 setCentralWidget( m_view );
52 52
53 QToolButton *btn = new QToolButton( bar ); 53 QToolButton *btn = new QToolButton( bar );
54 btn->setIconSet( Resource::loadIconSet( "up" ) ); 54 btn->setIconSet( Resource::loadIconSet( "up" ) );
55 connect( btn, SIGNAL(clicked()), 55 connect( btn, SIGNAL(clicked()),
56 m_view, SLOT(slotDirUp()) ); 56 m_view, SLOT(slotDirUp()) );
57 57
58 btn = new PFileSystem( bar ); 58 btn = new PFileSystem( bar );
59 connect( btn, SIGNAL( changeDir( const QString& ) ), 59 connect( btn, SIGNAL( changeDir( const QString& ) ),
60 m_view, SLOT(slotChangeDir( const QString& ) ) ); 60 m_view, SLOT(slotChangeDir( const QString& ) ) );
61 61
62 btn = new QToolButton( bar ); 62 btn = new QToolButton( bar );
63 btn->setIconSet( Resource::loadIconSet( "edit" ) ); 63 btn->setIconSet( Resource::loadIconSet( "edit" ) );
64 connect( btn, SIGNAL(clicked()), 64 connect( btn, SIGNAL(clicked()),
65 m_view, SLOT(slotRename()) ); 65 m_view, SLOT(slotRename()) );
66 66
67 if ( Ir::supported() ) { 67 if ( Ir::supported() ) {
68 btn = new QToolButton( bar ); 68 btn = new QToolButton( bar );
69 btn->setIconSet( Resource::loadIconSet( "beam" ) ); 69 btn->setIconSet( Resource::loadIconSet( "beam" ) );
70 connect( btn, SIGNAL(clicked()), 70 connect( btn, SIGNAL(clicked()),
71 m_view, SLOT(slotBeam()) ); 71 m_view, SLOT(slotBeam()) );
72 } 72 }
73 73
74 btn = new QToolButton( bar ); 74 btn = new QToolButton( bar );
75 btn->setIconSet( Resource::loadIconSet( "trash" ) ); 75 btn->setIconSet( Resource::loadIconSet( "trash" ) );
76 connect( btn, SIGNAL(clicked() ), 76 connect( btn, SIGNAL(clicked() ),
77 m_view, SLOT(slotTrash() ) ); 77 m_view, SLOT(slotTrash() ) );
78 78
79 btn = new QToolButton( bar ); 79 btn = new QToolButton( bar );
80 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); 80 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
81 connect( btn, SIGNAL(clicked() ), 81 connect( btn, SIGNAL(clicked() ),
82 this, SLOT(slotConfig() ) ); 82 this, SLOT(slotConfig() ) );
83 83
84} 84}
85 85
86PMainWindow::~PMainWindow() { 86PMainWindow::~PMainWindow() {
87} 87}
88 88
89 89
90void PMainWindow::slotConfig() { 90void PMainWindow::slotConfig() {
91/* 91/*
92 * have a tab with the possible views 92 * have a tab with the possible views
93 * a tab for globals image cache size.. scaled loading 93 * a tab for globals image cache size.. scaled loading
94 * and one tab for the KeyConfigs 94 * and one tab for the KeyConfigs
95 */ 95 */
96 QDialog dlg(this, 0, true); 96 QDialog dlg(this, 0, true);
97 dlg.setCaption( tr("Phunk View - Config" ) ); 97 dlg.setCaption( tr("Phunk View - Config" ) );
98 98
99 QHBoxLayout *lay = new QHBoxLayout(&dlg); 99 QHBoxLayout *lay = new QHBoxLayout(&dlg);
100 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 100 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
101 lay->addWidget( wid ); 101 lay->addWidget( wid );
102 ViewMap *vM = viewMap(); 102 ViewMap *vM = viewMap();
103 ViewMap::Iterator _it = vM->begin(); 103 ViewMap::Iterator _it = vM->begin();
104 QMap<PDirView*, QWidget*> lst; 104 QMap<PDirView*, QWidget*> lst;
105 105
106 for( ; _it != vM->end(); ++_it ) { 106 for( ; _it != vM->end(); ++_it ) {
107 PDirView *view = (_it.data())(*m_cfg); 107 PDirView *view = (_it.data())(*m_cfg);
108 PInterfaceInfo *inf = view->interfaceInfo(); 108 PInterfaceInfo *inf = view->interfaceInfo();
109 QWidget *_wid = inf->configWidget( *m_cfg ); 109 QWidget *_wid = inf->configWidget( *m_cfg );
110 _wid->reparent(wid, QPoint() ); 110 _wid->reparent(wid, QPoint() );
111 lst.insert( view, _wid ); 111 lst.insert( view, _wid );
112 wid->addTab( _wid, QString::null, inf->name() ); 112 wid->addTab( _wid, "fileopen", inf->name() );
113 } 113 }
114 114
115/* 115/*
116 * Add the KeyConfigWidget 116 * Add the KeyConfigWidget
117 */ 117 */
118 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 118 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
119 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 119 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
120 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 120 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
121 keyWid->load(); 121 keyWid->load();
122 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 122 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
123 123
124 124
125 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 125 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
126 126
127 QMap<PDirView*, QWidget*>::Iterator it; 127 QMap<PDirView*, QWidget*>::Iterator it;
128 for ( it = lst.begin(); it != lst.end(); ++it ) { 128 for ( it = lst.begin(); it != lst.end(); ++it ) {
129 if ( act ) 129 if ( act )
130 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 130 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
131 delete it.key(); 131 delete it.key();
132 } 132 }
133 133
134 if ( act ) { 134 if ( act ) {
135 m_view->resetView(); 135 m_view->resetView();
136 keyWid->save(); 136 keyWid->save();
137 } 137 }
138} 138}
diff --git a/noncore/graphics/opie-eye/slave/gif_slave.cpp b/noncore/graphics/opie-eye/slave/gif_slave.cpp
index feb69b6..f0dc86e 100644
--- a/noncore/graphics/opie-eye/slave/gif_slave.cpp
+++ b/noncore/graphics/opie-eye/slave/gif_slave.cpp
@@ -193,113 +193,114 @@ int giftrans(FILE *src, FILE* dest, QString& str, bool full)
193 if (lsd[4]&0x80) { 193 if (lsd[4]&0x80) {
194 gct_size=2<<(lsd[4]&0x7); 194 gct_size=2<<(lsd[4]&0x7);
195 pos=ftell(src); 195 pos=ftell(src);
196 (void)fread((void *)gct,gct_size,3,src); 196 (void)fread((void *)gct,gct_size,3,src);
197 } 197 }
198 198
199 do { 199 do {
200 pos=ftell(src); 200 pos=ftell(src);
201 (void)fread((void *)buffer,1,1,src); 201 (void)fread((void *)buffer,1,1,src);
202 switch (buffer[0]) { 202 switch (buffer[0]) {
203 case 0x2c: /* Image Descriptor */ 203 case 0x2c: /* Image Descriptor */
204 (void)fread((void *)(buffer+1),9,1,src); 204 (void)fread((void *)(buffer+1),9,1,src);
205 /* Local Color Table */ 205 /* Local Color Table */
206 if (buffer[8]&0x80) { 206 if (buffer[8]&0x80) {
207 size=2<<(buffer[8]&0x7); 207 size=2<<(buffer[8]&0x7);
208 pos=ftell(src); 208 pos=ftell(src);
209 (void)fread((void *)buffer,size,3,src); 209 (void)fread((void *)buffer,size,3,src);
210 } 210 }
211 /* Table Based Image Data */ 211 /* Table Based Image Data */
212 pos=ftell(src); 212 pos=ftell(src);
213 (void)fread((void *)buffer,1,1,src); 213 (void)fread((void *)buffer,1,1,src);
214 transdata(src,dest); 214 transdata(src,dest);
215 break; 215 break;
216 case 0x21: /* Extension */ 216 case 0x21: /* Extension */
217 (void)fread((void *)(buffer+1),1,1,src); 217 (void)fread((void *)(buffer+1),1,1,src);
218 switch (buffer[1]) { 218 switch (buffer[1]) {
219 case 0xfe: /* Comment Extension */ 219 case 0xfe: /* Comment Extension */
220 if (true) 220 if (true)
221 { 221 {
222 QCString st; 222 QCString st;
223 dumpcomment(src, st); 223 dumpcomment(src, st);
224 str += QObject::tr("Comment: %1\n" ).arg( st ); 224 str += QObject::tr("Comment: %1\n" ).arg( st );
225 } 225 }
226 if (skipcomment) 226 if (skipcomment)
227 skipdata(src); 227 skipdata(src);
228 else { 228 else {
229 transdata(src,dest); 229 transdata(src,dest);
230 } 230 }
231 break; 231 break;
232 case 0x01: /* Plain Text Extension */ 232 case 0x01: /* Plain Text Extension */
233 case 0xf9: /* Graphic Control Extension */ 233 case 0xf9: /* Graphic Control Extension */
234 case 0xff: /* Application Extension */ 234 case 0xff: /* Application Extension */
235 default: 235 default:
236 transblock(src,dest); 236 transblock(src,dest);
237 transdata(src,dest); 237 transdata(src,dest);
238 break; 238 break;
239 } 239 }
240 break; 240 break;
241 case 0x3b: /* Trailer (write comment just before here) */ 241 case 0x3b: /* Trailer (write comment just before here) */
242 break; 242 break;
243 default: 243 default:
244 (void)fprintf(stderr,"0x%08lx: Error, unknown block 0x%02x!\n",ftell(src)-1,buffer[0]); 244 (void)fprintf(stderr,"0x%08lx: Error, unknown block 0x%02x!\n",ftell(src)-1,buffer[0]);
245 return(1); 245 return(1);
246 } 246 }
247 } while (buffer[0]!=0x3b&&!feof(src)); 247 } while (buffer[0]!=0x3b&&!feof(src));
248 return(buffer[0]==0x3b?SUCCESS:FAILURE); 248 return(buffer[0]==0x3b?SUCCESS:FAILURE);
249} 249}
250 250
251 251
252/****************************************************************************/ 252/****************************************************************************/
253extern void get_gif_info( const char * original_filename, QString& str, 253extern void get_gif_info( const char * original_filename, QString& str,
254 bool full =false) 254 bool full =false)
255{ 255{
256FILE * infile; 256FILE * infile;
257 257
258 if ((infile = fopen(original_filename, READ_BINARY)) == NULL) { 258 if ((infile = fopen(original_filename, READ_BINARY)) == NULL) {
259 fprintf(stderr, "can't open gif image '%s'\n", original_filename); 259 fprintf(stderr, "can't open gif image '%s'\n", original_filename);
260 return ; 260 return ;
261 } 261 }
262 262
263 output = FALSE; 263 output = FALSE;
264 verbose = TRUE; 264 verbose = TRUE;
265 debug = FALSE; 265 debug = FALSE;
266 skipcomment = FALSE; 266 skipcomment = FALSE;
267 giftrans( infile, NULL, str, full ); 267 giftrans( infile, NULL, str, full );
268 fclose( infile ); 268 fclose( infile );
269} 269}
270 270
271} 271}
272 272
273 273
274GifSlave::GifSlave() 274GifSlave::GifSlave()
275 : SlaveInterface(QStringList("gif")) 275 : SlaveInterface(QStringList("gif"))
276{} 276{}
277 277
278GifSlave::~GifSlave() { 278GifSlave::~GifSlave() {
279 279
280} 280}
281 281
282QString GifSlave::iconViewName(const QString& str) { 282QString GifSlave::iconViewName(const QString& str) {
283 QString st; 283 QString st;
284 get_gif_info(QFile::encodeName( str ).data(), st ); 284 get_gif_info(QFile::encodeName( str ).data(), st );
285 return st; 285 return st;
286} 286}
287 287
288QString GifSlave::fullImageInfo( const QString& str) { 288QString GifSlave::fullImageInfo( const QString& str) {
289 QString st; 289 QString st = "<qt>";
290 get_gif_info(QFile::encodeName( str ).data(), st, true ); 290 get_gif_info(QFile::encodeName( str ).data(), st, true );
291 st.append( "</qt>" );
291 return st; 292 return st;
292} 293}
293 294
294QPixmap GifSlave::pixmap(const QString& path, int width, int height ) { 295QPixmap GifSlave::pixmap(const QString& path, int width, int height ) {
295 static QImage img; 296 static QImage img;
296 img.load( path ); 297 img.load( path );
297 if ( img.isNull() ) { 298 if ( img.isNull() ) {
298 QPixmap pix; 299 QPixmap pix;
299 return pix; 300 return pix;
300 } 301 }
301 302
302 return ThumbNailTool::scaleImage( img, width,height ); 303 return ThumbNailTool::scaleImage( img, width,height );
303} 304}
304 305
305 306
diff --git a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
index 95055fd..086b47f 100644
--- a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
+++ b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
@@ -1207,220 +1207,219 @@ static QString white_balance_string( int i ) {
1207 break; 1207 break;
1208 case 255: 1208 case 255:
1209 balance = QObject::tr( "Other" ); 1209 balance = QObject::tr( "Other" );
1210 break; 1210 break;
1211 default: 1211 default:
1212 balance = QObject::tr( "Unknown" ); 1212 balance = QObject::tr( "Unknown" );
1213 } 1213 }
1214 return QObject::tr( "White Balance: %1\n" ).arg( balance ); 1214 return QObject::tr( "White Balance: %1\n" ).arg( balance );
1215 1215
1216} 1216}
1217 1217
1218 1218
1219static QString metering_mode( int i) { 1219static QString metering_mode( int i) {
1220 QString meter; 1220 QString meter;
1221 switch( i ) { 1221 switch( i ) {
1222 case 0: 1222 case 0:
1223 meter = QObject::tr( "Unknown" ); 1223 meter = QObject::tr( "Unknown" );
1224 break; 1224 break;
1225 case 1: 1225 case 1:
1226 meter = QObject::tr( "Average" ); 1226 meter = QObject::tr( "Average" );
1227 break; 1227 break;
1228 case 2: 1228 case 2:
1229 meter = QObject::tr( "Center weighted average" ); 1229 meter = QObject::tr( "Center weighted average" );
1230 break; 1230 break;
1231 case 3: 1231 case 3:
1232 meter = QObject::tr( "Spot" ); 1232 meter = QObject::tr( "Spot" );
1233 break; 1233 break;
1234 case 4: 1234 case 4:
1235 meter = QObject::tr( "MultiSpot" ); 1235 meter = QObject::tr( "MultiSpot" );
1236 break; 1236 break;
1237 case 5: 1237 case 5:
1238 meter = QObject::tr( "Pattern" ); 1238 meter = QObject::tr( "Pattern" );
1239 break; 1239 break;
1240 case 6: 1240 case 6:
1241 meter = QObject::tr( "Partial" ); 1241 meter = QObject::tr( "Partial" );
1242 break; 1242 break;
1243 case 255: 1243 case 255:
1244 meter = QObject::tr( "Other" ); 1244 meter = QObject::tr( "Other" );
1245 break; 1245 break;
1246 default: 1246 default:
1247 meter = QObject::tr( "Unknown" ); 1247 meter = QObject::tr( "Unknown" );
1248 } 1248 }
1249 1249
1250 return QObject::tr( "Metering Mode: %1\n" ).arg( meter ); 1250 return QObject::tr( "Metering Mode: %1\n" ).arg( meter );
1251} 1251}
1252 1252
1253 1253
1254static QString exposure_program( int i ) { 1254static QString exposure_program( int i ) {
1255 QString exp; 1255 QString exp;
1256 switch( i ) { 1256 switch( i ) {
1257 case 0: 1257 case 0:
1258 exp = QObject::tr( "Not defined" ); 1258 exp = QObject::tr( "Not defined" );
1259 break; 1259 break;
1260 case 1: 1260 case 1:
1261 exp = QObject::tr( "Manual" ); 1261 exp = QObject::tr( "Manual" );
1262 break; 1262 break;
1263 case 2: 1263 case 2:
1264 exp = QObject::tr( "Normal progam" ); 1264 exp = QObject::tr( "Normal progam" );
1265 break; 1265 break;
1266 case 3: 1266 case 3:
1267 exp = QObject::tr( "Aperture priority" ); 1267 exp = QObject::tr( "Aperture priority" );
1268 break; 1268 break;
1269 case 4: 1269 case 4:
1270 exp = QObject::tr( "Shutter priority" ); 1270 exp = QObject::tr( "Shutter priority" );
1271 break; 1271 break;
1272 case 5: 1272 case 5:
1273 exp = QObject::tr( "Creative progam\n(biased toward fast shutter speed" ); 1273 exp = QObject::tr( "Creative progam\n(biased toward fast shutter speed" );
1274 break; 1274 break;
1275 case 6: 1275 case 6:
1276 exp = QObject::tr( "Action progam\n(biased toward fast shutter speed)" ); 1276 exp = QObject::tr( "Action progam\n(biased toward fast shutter speed)" );
1277 break; 1277 break;
1278 case 7: 1278 case 7:
1279 exp = QObject::tr( "Portrait mode\n(for closeup photos with the background out of focus)" ); 1279 exp = QObject::tr( "Portrait mode\n(for closeup photos with the background out of focus)" );
1280 break; 1280 break;
1281 case 8: 1281 case 8:
1282 exp = QObject::tr( "Landscape mode\n(for landscape photos with the background in focus)" ); 1282 exp = QObject::tr( "Landscape mode\n(for landscape photos with the background in focus)" );
1283 break; 1283 break;
1284 default: 1284 default:
1285 exp = QObject::tr( "Unknown" ); 1285 exp = QObject::tr( "Unknown" );
1286 } 1286 }
1287 1287
1288 return QObject::tr( "Exposure Program: %1\n" ).arg( exp ); 1288 return QObject::tr( "Exposure Program: %1\n" ).arg( exp );
1289} 1289}
1290 1290
1291JpegSlave::JpegSlave() 1291JpegSlave::JpegSlave()
1292 : SlaveInterface( QStringList::split( " ", "jpeg jpg" ) ) 1292 : SlaveInterface( QStringList::split( " ", "jpeg jpg" ) )
1293{} 1293{}
1294 1294
1295JpegSlave::~JpegSlave() {} 1295JpegSlave::~JpegSlave() {}
1296 1296
1297QString JpegSlave::iconViewName( const QString& path) { 1297QString JpegSlave::iconViewName( const QString& path) {
1298 ExifData ImageInfo; 1298 ExifData ImageInfo;
1299 if ( !ImageInfo.scan( path ) ) 1299 if ( !ImageInfo.scan( path ) )
1300 return QString::null; 1300 return QString::null;
1301 1301
1302 QString tag; 1302 QString tag;
1303 tag = QObject::tr( "<qt>Comment: %1\n" ).arg( ImageInfo.getComment() ); 1303 tag = QObject::tr( "Comment: %1\n" ).arg( ImageInfo.getComment() );
1304 { 1304 {
1305// ODP fixme 1305// ODP fixme
1306 QString timestring = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE ); 1306 QString timestring = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE );
1307 tag += QObject::tr( "Date/Time: %1\n" ).arg( timestring ); 1307 tag += QObject::tr( "Date/Time: %1\n" ).arg( timestring );
1308 } 1308 }
1309 tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth()) 1309 tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth())
1310 .arg(ImageInfo.getHeight() ); 1310 .arg(ImageInfo.getHeight() );
1311 1311
1312 tag += color_mode_to_string( ImageInfo.getIsColor() ); 1312 tag += color_mode_to_string( ImageInfo.getIsColor() );
1313 1313
1314 tag += compression_to_string( ImageInfo.getCompressionLevel() ); 1314 tag += compression_to_string( ImageInfo.getCompressionLevel() );
1315 tag += QObject::tr( "</qt>" );
1316 1315
1317 return tag; 1316 return tag;
1318} 1317}
1319 1318
1320 1319
1321/* 1320/*
1322 * messy messy string creation 1321 * messy messy string creation
1323 */ 1322 */
1324QString JpegSlave::fullImageInfo( const QString& path) { 1323QString JpegSlave::fullImageInfo( const QString& path) {
1325 ExifData ImageInfo; 1324 ExifData ImageInfo;
1326 if ( !ImageInfo.scan( path ) ) 1325 if ( !ImageInfo.scan( path ) )
1327 return QString::null; 1326 return QString::null;
1328 1327
1329 QString tag, tmp; 1328 QString tag, tmp;
1330 tag = QObject::tr( "Comment: %1\n" ).arg( ImageInfo.getComment() ); 1329 tag = QObject::tr( "<qt>Comment: %1\n" ).arg( ImageInfo.getComment() );
1331 1330
1332 tmp = ImageInfo.getCameraMake(); 1331 tmp = ImageInfo.getCameraMake();
1333 if ( tmp.length() ) 1332 if ( tmp.length() )
1334 tag += QObject::tr( "Manufacturer: %1\n" ).arg( tmp ); 1333 tag += QObject::tr( "Manufacturer: %1\n" ).arg( tmp );
1335 tmp = ImageInfo.getCameraModel(); 1334 tmp = ImageInfo.getCameraModel();
1336 if ( tmp.length() ) 1335 if ( tmp.length() )
1337 tag += QObject::tr( "Model: %1\n" ).arg( tmp ); 1336 tag += QObject::tr( "Model: %1\n" ).arg( tmp );
1338 { 1337 {
1339// ODP fixme 1338// ODP fixme
1340 tmp = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE ); 1339 tmp = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE );
1341 tag += QObject::tr( "Date/Time: %1\n" ).arg( tmp ); 1340 tag += QObject::tr( "Date/Time: %1\n" ).arg( tmp );
1342 } 1341 }
1343 tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth()) 1342 tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth())
1344 .arg(ImageInfo.getHeight() ); 1343 .arg(ImageInfo.getHeight() );
1345 1344
1346 tag += color_mode_to_string( ImageInfo.getIsColor() ); 1345 tag += color_mode_to_string( ImageInfo.getIsColor() );
1347 1346
1348 tag += compression_to_string( ImageInfo.getCompressionLevel() ); 1347 tag += compression_to_string( ImageInfo.getCompressionLevel() );
1349 if ( ImageInfo.getOrientation() ) 1348 if ( ImageInfo.getOrientation() )
1350 tag += QObject::tr( "Orientation: %1\n" ).arg(ImageInfo.getOrientation() ); 1349 tag += QObject::tr( "Orientation: %1\n" ).arg(ImageInfo.getOrientation() );
1351 1350
1352 1351
1353 { 1352 {
1354 int flash_used = ImageInfo.getFlashUsed(); 1353 int flash_used = ImageInfo.getFlashUsed();
1355 if ( flash_used >= 0 ) 1354 if ( flash_used >= 0 )
1356 tag += QObject::tr( "Flash used\n" ); 1355 tag += QObject::tr( "Flash used\n" );
1357 } 1356 }
1358 1357
1359 if ( ImageInfo.getFocalLength() ) { 1358 if ( ImageInfo.getFocalLength() ) {
1360 tag += QObject::tr( "Focal length: %1\n" ).arg( QString().sprintf( "%4.1f", ImageInfo.getFocalLength() ) ); 1359 tag += QObject::tr( "Focal length: %1\n" ).arg( QString().sprintf( "%4.1f", ImageInfo.getFocalLength() ) );
1361 if ( ImageInfo.getCCDWidth() ) 1360 if ( ImageInfo.getCCDWidth() )
1362 tag += QObject::tr( "35mm equivalent: %1\n" ).arg( (int)(ImageInfo.getFocalLength()/ImageInfo.getCCDWidth()*35 + 0.5) ); 1361 tag += QObject::tr( "35mm equivalent: %1\n" ).arg( (int)(ImageInfo.getFocalLength()/ImageInfo.getCCDWidth()*35 + 0.5) );
1363 1362
1364 } 1363 }
1365 1364
1366 if ( ImageInfo.getCCDWidth() ) 1365 if ( ImageInfo.getCCDWidth() )
1367 tag += QObject::tr( "CCD width: %1" ).arg( ImageInfo.getCCDWidth() ); 1366 tag += QObject::tr( "CCD width: %1" ).arg( ImageInfo.getCCDWidth() );
1368 if ( ImageInfo.getExposureTime() ) { 1367 if ( ImageInfo.getExposureTime() ) {
1369 tmp = QString().sprintf("%4.2f", ImageInfo.getExposureTime() ); 1368 tmp = QString().sprintf("%4.2f", ImageInfo.getExposureTime() );
1370 float exposureTime = ImageInfo.getExposureTime(); 1369 float exposureTime = ImageInfo.getExposureTime();
1371 if ( exposureTime > 0 && exposureTime <= 0.5 ) 1370 if ( exposureTime > 0 && exposureTime <= 0.5 )
1372 tmp += QString().sprintf(" (1/%d)", (int)(0.5 +1/exposureTime) ); 1371 tmp += QString().sprintf(" (1/%d)", (int)(0.5 +1/exposureTime) );
1373 tag += QObject::tr( "Exposure time: %1\n" ).arg( tmp ); 1372 tag += QObject::tr( "Exposure time: %1\n" ).arg( tmp );
1374 } 1373 }
1375 1374
1376 if ( ImageInfo.getApertureFNumber() ) 1375 if ( ImageInfo.getApertureFNumber() )
1377 tag += QObject::tr( "Aperture: %1\n" ).arg( QString().sprintf("f/%3.1f", (double)ImageInfo.getApertureFNumber() ) ); 1376 tag += QObject::tr( "Aperture: %1\n" ).arg( QString().sprintf("f/%3.1f", (double)ImageInfo.getApertureFNumber() ) );
1378 1377
1379 if ( ImageInfo.getDistance() ) { 1378 if ( ImageInfo.getDistance() ) {
1380 if ( ImageInfo.getDistance() < 0 ) 1379 if ( ImageInfo.getDistance() < 0 )
1381 tag += QObject::tr( "Distance: %1\n" ).arg( QObject::tr( "Infinite" ) ); 1380 tag += QObject::tr( "Distance: %1\n" ).arg( QObject::tr( "Infinite" ) );
1382 else 1381 else
1383 tag += QObject::tr( "Distance: %1\n" ).arg( QString().sprintf( "%5.2fm", (double)ImageInfo.getDistance() ) ); 1382 tag += QObject::tr( "Distance: %1\n" ).arg( QString().sprintf( "%5.2fm", (double)ImageInfo.getDistance() ) );
1384 } 1383 }
1385 1384
1386 if ( ImageInfo.getExposureBias() ) { 1385 if ( ImageInfo.getExposureBias() ) {
1387 tag += QObject::tr( "Exposure bias: %1\n", QString().sprintf("%4.2f", (double)ImageInfo.getExposureBias() ) ); 1386 tag += QObject::tr( "Exposure bias: %1\n", QString().sprintf("%4.2f", (double)ImageInfo.getExposureBias() ) );
1388 } 1387 }
1389 1388
1390 if ( ImageInfo.getWhitebalance() != -1 ) 1389 if ( ImageInfo.getWhitebalance() != -1 )
1391 tag += white_balance_string( ImageInfo.getWhitebalance() ); 1390 tag += white_balance_string( ImageInfo.getWhitebalance() );
1392 1391
1393 1392
1394 if( ImageInfo.getMeteringMode() != -1 ) 1393 if( ImageInfo.getMeteringMode() != -1 )
1395 tag += metering_mode( ImageInfo.getMeteringMode() ); 1394 tag += metering_mode( ImageInfo.getMeteringMode() );
1396 1395
1397 if ( ImageInfo.getExposureProgram() ) 1396 if ( ImageInfo.getExposureProgram() )
1398 tag += exposure_program( ImageInfo.getExposureProgram() ); 1397 tag += exposure_program( ImageInfo.getExposureProgram() );
1399 if ( ImageInfo.getISOequivalent() ) 1398 if ( ImageInfo.getISOequivalent() )
1400 tag += QObject::tr( "ISO equivalent: %1\n" ).arg( QString().sprintf("%2d", ImageInfo.getISOequivalent() ) ); 1399 tag += QObject::tr( "ISO equivalent: %1\n" ).arg( QString().sprintf("%2d", ImageInfo.getISOequivalent() ) );
1401 1400
1402 tmp = ImageInfo.getUserComment(); 1401 tmp = ImageInfo.getUserComment();
1403 if ( tmp.length() ) 1402 if ( tmp.length() )
1404 tag += QObject::tr( "EXIF comment: %1" ).arg( tmp ); 1403 tag += QObject::tr( "EXIF comment: %1" ).arg( tmp );
1405 1404
1406 tag += QObject::tr( "</qt>" ); 1405 tag += QObject::tr( "</qt>" );
1407 1406
1408 1407
1409 1408
1410 return tag; 1409 return tag;
1411} 1410}
1412 1411
1413QPixmap JpegSlave::pixmap( const QString& path, int wid, int hei) { 1412QPixmap JpegSlave::pixmap( const QString& path, int wid, int hei) {
1414 ExifData ImageInfo; 1413 ExifData ImageInfo;
1415 if ( !ImageInfo.scan( path ) || ImageInfo.isNullThumbnail() ) { 1414 if ( !ImageInfo.scan( path ) || ImageInfo.isNullThumbnail() ) {
1416 QImage img; 1415 QImage img;
1417 QImageIO iio( path, 0l ); 1416 QImageIO iio( path, 0l );
1418 QString str = QString( "Fast Shrink( 4 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); 1417 QString str = QString( "Fast Shrink( 4 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei );
1419 iio.setParameters( str.latin1() );// will be strdupped anyway 1418 iio.setParameters( str.latin1() );// will be strdupped anyway
1420 img = iio.read() ? iio.image() : QImage(); 1419 img = iio.read() ? iio.image() : QImage();
1421 return ThumbNailTool::scaleImage( img, wid,hei ); 1420 return ThumbNailTool::scaleImage( img, wid,hei );
1422 }else{ 1421 }else{
1423 QImage img = ImageInfo.getThumbnail(); 1422 QImage img = ImageInfo.getThumbnail();
1424 return ThumbNailTool::scaleImage( img, wid,hei ); 1423 return ThumbNailTool::scaleImage( img, wid,hei );
1425 } 1424 }
1426} 1425}
diff --git a/noncore/graphics/opie-eye/slave/png_slave.cpp b/noncore/graphics/opie-eye/slave/png_slave.cpp
index 72b93cc..86e1cdc 100644
--- a/noncore/graphics/opie-eye/slave/png_slave.cpp
+++ b/noncore/graphics/opie-eye/slave/png_slave.cpp
@@ -102,109 +102,110 @@ static void read_comment( const QString& inf,
102 case 4: bpp *= 2; break; // grayscale w. alpha 102 case 4: bpp *= 2; break; // grayscale w. alpha
103 case 6: bpp *= 4; break; // RGBA 103 case 6: bpp *= 4; break; // RGBA
104 104
105 default: // we don't get any sensible value here 105 default: // we don't get any sensible value here
106 bpp = 0; 106 bpp = 0;
107 } 107 }
108 108
109 109
110 str = QObject::tr("Dimensions: %1x%2\n" ).arg(x).arg(y); 110 str = QObject::tr("Dimensions: %1x%2\n" ).arg(x).arg(y);
111 str += QObject::tr("Depth: %1\n" ).arg(bpp); 111 str += QObject::tr("Depth: %1\n" ).arg(bpp);
112 str += QObject::tr("ColorMode: %1\n").arg( 112 str += QObject::tr("ColorMode: %1\n").arg(
113 (type < sizeof(colors)/sizeof(colors[0])) 113 (type < sizeof(colors)/sizeof(colors[0]))
114 ? QObject::tr(colors[data[25]]) : QObject::tr("Unknown") ); 114 ? QObject::tr(colors[data[25]]) : QObject::tr("Unknown") );
115 115
116 str += QObject::tr("Compression: %1\n").arg( 116 str += QObject::tr("Compression: %1\n").arg(
117 (data[26] < sizeof(compressions)/sizeof(compressions[0])) 117 (data[26] < sizeof(compressions)/sizeof(compressions[0]))
118 ? QObject::tr(compressions[data[26]]) : QObject::tr("Unknown") ); 118 ? QObject::tr(compressions[data[26]]) : QObject::tr("Unknown") );
119 119
120 str += QObject::tr("InterlaceMode: %1\n" ).arg( 120 str += QObject::tr("InterlaceMode: %1\n" ).arg(
121 (data[28] < sizeof(interlaceModes)/sizeof(interlaceModes[0])) 121 (data[28] < sizeof(interlaceModes)/sizeof(interlaceModes[0]))
122 ? QObject::tr(interlaceModes[data[28]]) : QObject::tr("Unknown")); 122 ? QObject::tr(interlaceModes[data[28]]) : QObject::tr("Unknown"));
123 } 123 }
124 124
125 if ( readComments ) { 125 if ( readComments ) {
126 uint index = 8; 126 uint index = 8;
127 index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE; 127 index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE;
128 128
129 while(index<f.size()-12) 129 while(index<f.size()-12)
130 { 130 {
131 while (index < f.size() - 12 && 131 while (index < f.size() - 12 &&
132 strncmp((char*)CHUNK_TYPE(data,index), "tEXt", 4)) 132 strncmp((char*)CHUNK_TYPE(data,index), "tEXt", 4))
133 { 133 {
134 if (!strncmp((char*)CHUNK_TYPE(data,index), "IEND", 4)) 134 if (!strncmp((char*)CHUNK_TYPE(data,index), "IEND", 4))
135 goto end; 135 goto end;
136 136
137 index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE; 137 index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE;
138 } 138 }
139 139
140 if (index < f.size() - 12) 140 if (index < f.size() - 12)
141 { 141 {
142 // we found a tEXt field 142 // we found a tEXt field
143 // get the key, it's a null terminated string at the 143 // get the key, it's a null terminated string at the
144 // chunk start 144 // chunk start
145 145
146 uchar* key = &CHUNK_DATA(data,index,0); 146 uchar* key = &CHUNK_DATA(data,index,0);
147 147
148 int keysize=0; 148 int keysize=0;
149 for (;key[keysize]!=0; keysize++) 149 for (;key[keysize]!=0; keysize++)
150 // look if we reached the end of the file 150 // look if we reached the end of the file
151 // (it might be corrupted) 151 // (it might be corrupted)
152 if (8+index+keysize>=f.size()) 152 if (8+index+keysize>=f.size())
153 goto end; 153 goto end;
154 154
155 // the text comes after the key, but isn't null terminated 155 // the text comes after the key, but isn't null terminated
156 uchar* text = &CHUNK_DATA(data,index, keysize+1); 156 uchar* text = &CHUNK_DATA(data,index, keysize+1);
157 uint textsize = CHUNK_SIZE(data, index)-keysize-1; 157 uint textsize = CHUNK_SIZE(data, index)-keysize-1;
158 158
159 // security check, also considering overflow wraparound from the addition -- 159 // security check, also considering overflow wraparound from the addition --
160 // we may endup with a /smaller/ index if we wrap all the way around 160 // we may endup with a /smaller/ index if we wrap all the way around
161 uint firstIndex = (uint)(text - data); 161 uint firstIndex = (uint)(text - data);
162 uint onePastLastIndex = firstIndex + textsize; 162 uint onePastLastIndex = firstIndex + textsize;
163 163
164 if ( onePastLastIndex > f.size() || onePastLastIndex <= firstIndex) 164 if ( onePastLastIndex > f.size() || onePastLastIndex <= firstIndex)
165 goto end; 165 goto end;
166 166
167 QByteArray arr(textsize); 167 QByteArray arr(textsize);
168 arr = QByteArray(textsize).duplicate((const char*)text, 168 arr = QByteArray(textsize).duplicate((const char*)text,
169 textsize); 169 textsize);
170 str += QObject::tr( 170 str += QObject::tr(
171 QString(reinterpret_cast<char*>(key)), 171 QString(reinterpret_cast<char*>(key)),
172 QString(arr) ); 172 QString(arr) );
173 173
174 index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE; 174 index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE;
175 } 175 }
176 } 176 }
177 } 177 }
178 } 178 }
179end: 179end:
180 delete[] data; 180 delete[] data;
181 181
182} 182}
183 183
184 184
185PNGSlave::PNGSlave() 185PNGSlave::PNGSlave()
186 : SlaveInterface("png") 186 : SlaveInterface("png")
187{ 187{
188} 188}
189PNGSlave::~PNGSlave() { 189PNGSlave::~PNGSlave() {
190} 190}
191QString PNGSlave::iconViewName( const QString& path) { 191QString PNGSlave::iconViewName( const QString& path) {
192 QString str; 192 QString str;
193 read_comment( path, false, str ); 193 read_comment( path, false, str );
194 return str; 194 return str;
195} 195}
196 196
197QString PNGSlave::fullImageInfo( const QString& path) { 197QString PNGSlave::fullImageInfo( const QString& path) {
198 QString str; 198 QString str = "<qt>";
199 read_comment( path, true, str ); 199 read_comment( path, true, str );
200 str += "</qt>";
200 return str; 201 return str;
201} 202}
202 203
203 204
204QPixmap PNGSlave::pixmap( const QString& path, int width, int height) { 205QPixmap PNGSlave::pixmap( const QString& path, int width, int height) {
205 QImage img; img.load( path ); 206 QImage img; img.load( path );
206 if ( img.isNull() ) 207 if ( img.isNull() )
207 return QPixmap(); 208 return QPixmap();
208 else 209 else
209 return ThumbNailTool::scaleImage( img, width,height ); 210 return ThumbNailTool::scaleImage( img, width,height );
210} 211}