author | zecke <zecke> | 2004-04-02 23:46:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-02 23:46:47 (UTC) |
commit | 02bb854283a7b0abecf3d3e9dd4c9ece0c5ef6a9 (patch) (unidiff) | |
tree | f0ff26b90aefd930c18735cf49b2a9e2c7c6ba9a | |
parent | cc94df750d5e0c016fad2dc12bbbf7cd8592e7c8 (diff) | |
download | opie-02bb854283a7b0abecf3d3e9dd4c9ece0c5ef6a9.zip opie-02bb854283a7b0abecf3d3e9dd4c9ece0c5ef6a9.tar.gz opie-02bb854283a7b0abecf3d3e9dd4c9ece0c5ef6a9.tar.bz2 |
Ah finally the IconView is a bit faster... Still needs a Qt patch
But hey previewing is really useful now. I think it is one of the fastest
Image Viewer available for Unix/Windoze...
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 58 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 1 |
2 files changed, 34 insertions, 25 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index ed9fc9c..4a20648 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -53,37 +53,36 @@ namespace { | |||
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
56 | /* | 56 | /* |
57 | * If we request an Image or String | 57 | * If we request an Image or String |
58 | * we add it to the map | 58 | * we add it to the map |
59 | */ | 59 | */ |
60 | QMap<QString, IconViewItem*> g_stringInf; | 60 | QMap<QString, IconViewItem*> g_stringInf; |
61 | QMap<QString, IconViewItem*> g_stringPix; | 61 | QMap<QString, IconViewItem*> g_stringPix; |
62 | 62 | ||
63 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 63 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
64 | const QString& name, bool isDir ) | 64 | const QString& name, bool isDir ) |
65 | : QIconViewItem( view ), m_path( path ), m_isDir( isDir ), | 65 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
66 | m_noInfo( false ) | 66 | m_noInfo( false ) |
67 | { | 67 | { |
68 | QIconViewItem::setText( name ); | ||
69 | if ( isDir && !_dirPix ) | 68 | if ( isDir && !_dirPix ) |
70 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 69 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
71 | else if ( !isDir && !_unkPix ) | 70 | else if ( !isDir && !_unkPix ) |
72 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 71 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
73 | } | 72 | } |
74 | inline QPixmap* IconViewItem::pixmap()const { | 73 | inline QPixmap* IconViewItem::pixmap()const { |
75 | qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", | 74 | qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", |
76 | rect().x(),rect().y(),rect().width(),rect().height(), | 75 | rect().x(),rect().y(),rect().width(),rect().height(), |
77 | iconView()->contentsX(), iconView()->contentsY()); | 76 | iconView()->contentsX(), iconView()->contentsY()); |
78 | 77 | ||
79 | if ( m_isDir ) | 78 | if ( m_isDir ) |
80 | return _dirPix; | 79 | return _dirPix; |
81 | else{ | 80 | else{ |
82 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 81 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
83 | currentView()->dirLister()->imageInfo( m_path ); | 82 | currentView()->dirLister()->imageInfo( m_path ); |
84 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 83 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
85 | } | 84 | } |
86 | 85 | ||
87 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 86 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
88 | if ( !m_pix && !g_stringPix.contains( m_path )) { | 87 | if ( !m_pix && !g_stringPix.contains( m_path )) { |
89 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 88 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
@@ -92,25 +91,25 @@ namespace { | |||
92 | return m_pix ? m_pix : _unkPix; | 91 | return m_pix ? m_pix : _unkPix; |
93 | } | 92 | } |
94 | } | 93 | } |
95 | inline void IconViewItem::setText( const QString& str ) { | 94 | inline void IconViewItem::setText( const QString& str ) { |
96 | QString text = QIconViewItem::text()+"\n"+str; | 95 | QString text = QIconViewItem::text()+"\n"+str; |
97 | m_noInfo = true; | 96 | m_noInfo = true; |
98 | QIconViewItem::setText( text ); | 97 | QIconViewItem::setText( text ); |
99 | } | 98 | } |
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 102 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
104 | : QVBox( wid ), m_cfg( cfg ) | 103 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
105 | { | 104 | { |
106 | { | 105 | { |
107 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 106 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
108 | } | 107 | } |
109 | m_path = QDir::homeDirPath(); | 108 | m_path = QDir::homeDirPath(); |
110 | 109 | ||
111 | QHBox *hbox = new QHBox( this ); | 110 | QHBox *hbox = new QHBox( this ); |
112 | QLabel* lbl = new QLabel( hbox ); | 111 | QLabel* lbl = new QLabel( hbox ); |
113 | lbl->setText( tr("View as" ) ); | 112 | lbl->setText( tr("View as" ) ); |
114 | 113 | ||
115 | m_views = new QComboBox( hbox, "View As" ); | 114 | m_views = new QComboBox( hbox, "View As" ); |
116 | connect( m_views, SIGNAL(activated(int)), | 115 | connect( m_views, SIGNAL(activated(int)), |
@@ -299,44 +298,49 @@ void PIconView::addFiles( const QStringList& lst) { | |||
299 | void PIconView::slotClicked(QIconViewItem* _it) { | 298 | void PIconView::slotClicked(QIconViewItem* _it) { |
300 | if(!_it ) | 299 | if(!_it ) |
301 | return; | 300 | return; |
302 | 301 | ||
303 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 302 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
304 | if( it->isDir() ) | 303 | if( it->isDir() ) |
305 | slotChangeDir( it->path() ); | 304 | slotChangeDir( it->path() ); |
306 | else // view image | 305 | else // view image |
307 | ; | 306 | ; |
308 | } | 307 | } |
309 | 308 | ||
310 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 309 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
311 | if ( g_stringInf.contains( _path ) ) { | 310 | IconViewItem* item = g_stringInf[_path]; |
312 | IconViewItem* item = g_stringInf[_path]; | 311 | if (!item ) |
313 | /* if set the view shows nonsens! | 312 | return; |
314 | I dont know how to fix the format of displayed text :(*/ | 313 | |
315 | item->setText( str ); | 314 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
316 | g_stringInf.remove( _path ); | 315 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
317 | } | 316 | m_updatet = true; |
317 | |||
318 | item->setText( str ); | ||
319 | g_stringInf.remove( _path ); | ||
318 | } | 320 | } |
319 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 321 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
320 | if ( g_stringPix.contains( _path ) ) { | 322 | IconViewItem* item = g_stringPix[_path]; |
321 | IconViewItem* item = g_stringPix[_path]; | 323 | if (!item ) |
322 | 324 | return; | |
323 | if (pix.width()>0) { | 325 | |
324 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 326 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
325 | /* required for a recalculated rectangle. otherwise the view show nonsense! */ | 327 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
326 | } else { | 328 | m_updatet = true; |
327 | PPixmapCache::self()->insertImage(_path,Resource::loadPixmap( "UnknownDocument" ),64,64 ); | 329 | |
328 | } | 330 | if (pix.width()>0) |
329 | g_stringPix.remove( _path ); | 331 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
330 | } | 332 | |
333 | |||
334 | g_stringPix.remove( _path ); | ||
331 | } | 335 | } |
332 | 336 | ||
333 | 337 | ||
334 | void PIconView::slotRename() { | 338 | void PIconView::slotRename() { |
335 | 339 | ||
336 | } | 340 | } |
337 | 341 | ||
338 | void PIconView::slotBeam() { | 342 | void PIconView::slotBeam() { |
339 | bool isDir; | 343 | bool isDir; |
340 | QString pa = currentFileName( isDir ); | 344 | QString pa = currentFileName( isDir ); |
341 | if ( isDir && pa.isEmpty() ) | 345 | if ( isDir && pa.isEmpty() ) |
342 | return; | 346 | return; |
@@ -345,29 +349,33 @@ void PIconView::slotBeam() { | |||
345 | connect( ir, SIGNAL(done(Ir*)), | 349 | connect( ir, SIGNAL(done(Ir*)), |
346 | this, SLOT(slotBeamDone(Ir*))); | 350 | this, SLOT(slotBeamDone(Ir*))); |
347 | ir->send(pa, tr( "Image" ) ); | 351 | ir->send(pa, tr( "Image" ) ); |
348 | 352 | ||
349 | } | 353 | } |
350 | 354 | ||
351 | void PIconView::slotBeamDone( Ir* ir) { | 355 | void PIconView::slotBeamDone( Ir* ir) { |
352 | delete ir; | 356 | delete ir; |
353 | } | 357 | } |
354 | 358 | ||
355 | void PIconView::slotStart() { | 359 | void PIconView::slotStart() { |
356 | m_view->viewport()->setUpdatesEnabled( false ); | 360 | m_view->viewport()->setUpdatesEnabled( false ); |
361 | qWarning( "Sig Start" ); | ||
357 | } | 362 | } |
358 | 363 | ||
359 | void PIconView::slotEnd() { | 364 | void PIconView::slotEnd() { |
360 | m_view->arrangeItemsInGrid( ); | 365 | qWarning( "SLot End" ); |
366 | if ( m_updatet ) | ||
367 | m_view->arrangeItemsInGrid( ); | ||
361 | m_view->viewport()->setUpdatesEnabled( true ); | 368 | m_view->viewport()->setUpdatesEnabled( true ); |
369 | m_updatet = false; | ||
362 | } | 370 | } |
363 | 371 | ||
364 | void PIconView::slotShowImage() { | 372 | void PIconView::slotShowImage() { |
365 | 373 | ||
366 | } | 374 | } |
367 | void PIconView::slotShowImage( const QString& ) { | 375 | void PIconView::slotShowImage( const QString& ) { |
368 | 376 | ||
369 | } | 377 | } |
370 | void PIconView::slotImageInfo() { | 378 | void PIconView::slotImageInfo() { |
371 | 379 | ||
372 | } | 380 | } |
373 | void PIconView::slotImageInfo( const QString& ) { | 381 | void PIconView::slotImageInfo( const QString& ) { |
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index 0fba327..7ddb023 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -65,15 +65,16 @@ private slots: | |||
65 | void addFiles( const QStringList& ); | 65 | void addFiles( const QStringList& ); |
66 | void slotClicked(QIconViewItem* ); | 66 | void slotClicked(QIconViewItem* ); |
67 | 67 | ||
68 | /**/ | 68 | /**/ |
69 | void slotThumbInfo(const QString&, const QString&); | 69 | void slotThumbInfo(const QString&, const QString&); |
70 | void slotThumbNail(const QString&, const QPixmap&); | 70 | void slotThumbNail(const QString&, const QPixmap&); |
71 | private: | 71 | private: |
72 | Opie::Ui::OKeyConfigManager *m_viewManager; | 72 | Opie::Ui::OKeyConfigManager *m_viewManager; |
73 | Opie::Core::OConfig *m_cfg; | 73 | Opie::Core::OConfig *m_cfg; |
74 | QComboBox* m_views; | 74 | QComboBox* m_views; |
75 | QIconView* m_view; | 75 | QIconView* m_view; |
76 | QString m_path; | 76 | QString m_path; |
77 | bool m_updatet : 1; | ||
77 | }; | 78 | }; |
78 | 79 | ||
79 | #endif | 80 | #endif |