summaryrefslogtreecommitdiff
authorzecke <zecke>2004-04-02 23:46:47 (UTC)
committer zecke <zecke>2004-04-02 23:46:47 (UTC)
commit02bb854283a7b0abecf3d3e9dd4c9ece0c5ef6a9 (patch) (unidiff)
treef0ff26b90aefd930c18735cf49b2a9e2c7c6ba9a
parentcc94df750d5e0c016fad2dc12bbbf7cd8592e7c8 (diff)
downloadopie-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...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp58
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h1
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
@@ -1,375 +1,383 @@
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#include <opie2/odebug.h>
16 16
17#include <qpe/resource.h> 17#include <qpe/resource.h>
18#include <qpe/qpemessagebox.h> 18#include <qpe/qpemessagebox.h>
19#include <qpe/ir.h> 19#include <qpe/ir.h>
20#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
21 21
22 22
23#include <qiconview.h> 23#include <qiconview.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qhbox.h> 25#include <qhbox.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qapplication.h> 28#include <qapplication.h>
29#include <qmainwindow.h> 29#include <qmainwindow.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qstyle.h> 31#include <qstyle.h>
32 32
33 33
34using Opie::Ui::OKeyConfigItem; 34using Opie::Ui::OKeyConfigItem;
35 35
36namespace { 36namespace {
37 QPixmap* _dirPix = 0; 37 QPixmap* _dirPix = 0;
38 QPixmap* _unkPix = 0; 38 QPixmap* _unkPix = 0;
39 class IconViewItem : public QIconViewItem { 39 class IconViewItem : public QIconViewItem {
40 public: 40 public:
41 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); 41 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
42 QPixmap* pixmap()const; 42 QPixmap* pixmap()const;
43 QString path()const { return m_path; } 43 QString path()const { return m_path; }
44 bool isDir()const { return m_isDir; } 44 bool isDir()const { return m_isDir; }
45 void setText( const QString& ); 45 void setText( const QString& );
46 46
47 47
48 private: 48 private:
49 mutable QPixmap* m_pix; 49 mutable QPixmap* m_pix;
50 QString m_path; 50 QString m_path;
51 bool m_isDir : 1; 51 bool m_isDir : 1;
52 bool m_noInfo :1; 52 bool m_noInfo :1;
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 );
90 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 89 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
91 } 90 }
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
103PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 102PIconView::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)),
117 this, SLOT(slotViewChanged(int)) ); 116 this, SLOT(slotViewChanged(int)) );
118 117
119 m_view= new QIconView( this ); 118 m_view= new QIconView( this );
120 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 119 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
121 this, SLOT(slotClicked(QIconViewItem*)) ); 120 this, SLOT(slotClicked(QIconViewItem*)) );
122 121
123 m_view->setArrangement( QIconView::LeftToRight ); 122 m_view->setArrangement( QIconView::LeftToRight );
124 m_view->setItemTextPos( QIconView::Right ); 123 m_view->setItemTextPos( QIconView::Right );
125 124
126 int dw = QApplication::desktop()->width(); 125 int dw = QApplication::desktop()->width();
127 int viewerWidth = dw-style().scrollBarExtent().width(); 126 int viewerWidth = dw-style().scrollBarExtent().width();
128 m_view->setGridX( viewerWidth-3*m_view->spacing()); 127 m_view->setGridX( viewerWidth-3*m_view->spacing());
129 m_view->setGridY( fontMetrics().height()*2+40 ); 128 m_view->setGridY( fontMetrics().height()*2+40 );
130 129
131 130
132 initKeys(); 131 initKeys();
133 132
134 loadViews(); 133 loadViews();
135 slotViewChanged( m_views->currentItem() ); 134 slotViewChanged( m_views->currentItem() );
136} 135}
137 136
138PIconView::~PIconView() { 137PIconView::~PIconView() {
139 { 138 {
140 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 139 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
141 } 140 }
142 m_viewManager->save(); 141 m_viewManager->save();
143 delete m_viewManager; 142 delete m_viewManager;
144} 143}
145 144
146Opie::Ui::OKeyConfigManager* PIconView::manager() { 145Opie::Ui::OKeyConfigManager* PIconView::manager() {
147 return m_viewManager; 146 return m_viewManager;
148} 147}
149 148
150void PIconView::initKeys() { 149void PIconView::initKeys() {
151 Opie::Ui::OKeyPair::List lst; 150 Opie::Ui::OKeyPair::List lst;
152 lst.append( Opie::Ui::OKeyPair::upArrowKey() ); 151 lst.append( Opie::Ui::OKeyPair::upArrowKey() );
153 lst.append( Opie::Ui::OKeyPair::downArrowKey() ); 152 lst.append( Opie::Ui::OKeyPair::downArrowKey() );
154 lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); 153 lst.append( Opie::Ui::OKeyPair::leftArrowKey() );
155 lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); 154 lst.append( Opie::Ui::OKeyPair::rightArrowKey() );
156 lst.append( Opie::Ui::OKeyPair::returnKey() ); 155 lst.append( Opie::Ui::OKeyPair::returnKey() );
157 156
158 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 157 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
159 lst, false,this, "keyconfig name" ); 158 lst, false,this, "keyconfig name" );
160 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 159 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
161 QString::fromLatin1("beam"), BeamItem, 160 QString::fromLatin1("beam"), BeamItem,
162 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton), 161 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton),
163 this, SLOT(slotBeam())) ); 162 this, SLOT(slotBeam())) );
164 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 163 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
165 QString::fromLatin1("trash"), DeleteItem, 164 QString::fromLatin1("trash"), DeleteItem,
166 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton), 165 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton),
167 this, SLOT(slotTrash())) ); 166 this, SLOT(slotTrash())) );
168 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 167 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
169 QString::fromLatin1("1to1"), ViewItem, 168 QString::fromLatin1("1to1"), ViewItem,
170 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), 169 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton),
171 this, SLOT(slotShowImage()))); 170 this, SLOT(slotShowImage())));
172 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 171 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
173 QString::fromLatin1("DocumentTypeWord"), InfoItem, 172 QString::fromLatin1("DocumentTypeWord"), InfoItem,
174 Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 173 Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
175 this, SLOT(slotImageInfo()) ) ); 174 this, SLOT(slotImageInfo()) ) );
176 m_viewManager->load(); 175 m_viewManager->load();
177 m_viewManager->handleWidget( m_view ); 176 m_viewManager->handleWidget( m_view );
178} 177}
179 178
180void PIconView::slotDirUp() { 179void PIconView::slotDirUp() {
181 QDir dir( m_path ); 180 QDir dir( m_path );
182 dir.cdUp(); 181 dir.cdUp();
183 slotChangeDir( dir.absPath() ); 182 slotChangeDir( dir.absPath() );
184 183
185} 184}
186 185
187void PIconView::slotChangeDir(const QString& path) { 186void PIconView::slotChangeDir(const QString& path) {
188 if ( !currentView() ) 187 if ( !currentView() )
189 return; 188 return;
190 189
191 PDirLister *lister = currentView()->dirLister(); 190 PDirLister *lister = currentView()->dirLister();
192 if (!lister ) 191 if (!lister )
193 return; 192 return;
194 193
195 lister->setStartPath( path ); 194 lister->setStartPath( path );
196 m_path = lister->currentPath(); 195 m_path = lister->currentPath();
197 196
198 m_view->viewport()->setUpdatesEnabled( false ); 197 m_view->viewport()->setUpdatesEnabled( false );
199 m_view->clear(); 198 m_view->clear();
200 addFolders( lister->folders() ); 199 addFolders( lister->folders() );
201 addFiles( lister->files() ); 200 addFiles( lister->files() );
202 m_view->viewport()->setUpdatesEnabled( true ); 201 m_view->viewport()->setUpdatesEnabled( true );
203 202
204 // Also invalidate the cache. We can't cancel the operations anyway 203 // Also invalidate the cache. We can't cancel the operations anyway
205 g_stringPix.clear(); 204 g_stringPix.clear();
206 g_stringInf.clear(); 205 g_stringInf.clear();
207 206
208 // looks ugly 207 // looks ugly
209 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 208 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
210} 209}
211 210
212QString PIconView::currentFileName(bool &isDir)const { 211QString PIconView::currentFileName(bool &isDir)const {
213 isDir = false; 212 isDir = false;
214 QIconViewItem* _it = m_view->currentItem(); 213 QIconViewItem* _it = m_view->currentItem();
215 if ( !_it ) 214 if ( !_it )
216 return QString::null; 215 return QString::null;
217 216
218 IconViewItem* it = static_cast<IconViewItem*>( _it ); 217 IconViewItem* it = static_cast<IconViewItem*>( _it );
219 isDir = it->isDir(); 218 isDir = it->isDir();
220 return it->path(); 219 return it->path();
221} 220}
222 221
223void PIconView::slotTrash() { 222void PIconView::slotTrash() {
224 bool isDir; 223 bool isDir;
225 QString pa = currentFileName( isDir ); 224 QString pa = currentFileName( isDir );
226 if ( isDir && pa.isEmpty() ) 225 if ( isDir && pa.isEmpty() )
227 return; 226 return;
228 227
229 if (!QPEMessageBox::confirmDelete( this, 228 if (!QPEMessageBox::confirmDelete( this,
230 tr("Delete Image" ), 229 tr("Delete Image" ),
231 tr("the Image %1" ).arg(pa))) 230 tr("the Image %1" ).arg(pa)))
232 return 231 return
233 232
234 233
235 currentView()->dirLister()->deleteImage( pa ); 234 currentView()->dirLister()->deleteImage( pa );
236 delete m_view->currentItem(); 235 delete m_view->currentItem();
237} 236}
238void PIconView::loadViews() { 237void PIconView::loadViews() {
239 ViewMap::Iterator it; 238 ViewMap::Iterator it;
240 ViewMap* map = viewMap(); 239 ViewMap* map = viewMap();
241 for ( it = map->begin(); it != map->end(); ++it ) 240 for ( it = map->begin(); it != map->end(); ++it )
242 m_views->insertItem( QObject::tr(it.key() ) ); 241 m_views->insertItem( QObject::tr(it.key() ) );
243} 242}
244 243
245void PIconView::resetView() { 244void PIconView::resetView() {
246 slotViewChanged(m_views->currentItem()); 245 slotViewChanged(m_views->currentItem());
247} 246}
248 247
249void PIconView::slotViewChanged( int i) { 248void PIconView::slotViewChanged( int i) {
250 if (!m_views->count() ) { 249 if (!m_views->count() ) {
251 setCurrentView( 0l); 250 setCurrentView( 0l);
252 return; 251 return;
253 } 252 }
254 253
255 PDirView* cur = currentView(); 254 PDirView* cur = currentView();
256 delete cur; 255 delete cur;
257 QString str = m_views->text(i); 256 QString str = m_views->text(i);
258 cur = (*(*viewMap())[str])(*m_cfg); 257 cur = (*(*viewMap())[str])(*m_cfg);
259 setCurrentView( cur ); 258 setCurrentView( cur );
260 259
261 /* connect to the signals of the lister */ 260 /* connect to the signals of the lister */
262 PDirLister* lis = cur->dirLister(); 261 PDirLister* lis = cur->dirLister();
263 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 262 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
264 this, SLOT( slotThumbInfo(const QString&, const QString&))); 263 this, SLOT( slotThumbInfo(const QString&, const QString&)));
265 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 264 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
266 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 265 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
267 connect(lis, SIGNAL(sig_start()), 266 connect(lis, SIGNAL(sig_start()),
268 this, SLOT(slotStart())); 267 this, SLOT(slotStart()));
269 connect(lis, SIGNAL(sig_end()) , 268 connect(lis, SIGNAL(sig_end()) ,
270 this, SLOT(slotEnd()) ); 269 this, SLOT(slotEnd()) );
271 270
272 271
273 /* reload now */ 272 /* reload now */
274 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 273 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
275} 274}
276 275
277 276
278void PIconView::slotReloadDir() { 277void PIconView::slotReloadDir() {
279 slotChangeDir( m_path ); 278 slotChangeDir( m_path );
280} 279}
281 280
282 281
283void PIconView::addFolders( const QStringList& lst) { 282void PIconView::addFolders( const QStringList& lst) {
284 QStringList::ConstIterator it; 283 QStringList::ConstIterator it;
285 284
286 for(it=lst.begin(); it != lst.end(); ++it ) { 285 for(it=lst.begin(); it != lst.end(); ++it ) {
287 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); 286 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
288 } 287 }
289 288
290} 289}
291 290
292void PIconView::addFiles( const QStringList& lst) { 291void PIconView::addFiles( const QStringList& lst) {
293 QStringList::ConstIterator it; 292 QStringList::ConstIterator it;
294 for (it=lst.begin(); it!= lst.end(); ++it ) 293 for (it=lst.begin(); it!= lst.end(); ++it )
295 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); 294 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
296 295
297} 296}
298 297
299void PIconView::slotClicked(QIconViewItem* _it) { 298void 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
310void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 309void 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}
319void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 321void 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
334void PIconView::slotRename() { 338void PIconView::slotRename() {
335 339
336} 340}
337 341
338void PIconView::slotBeam() { 342void 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;
343 347
344 Ir* ir = new Ir( this ); 348 Ir* ir = new Ir( this );
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
351void PIconView::slotBeamDone( Ir* ir) { 355void PIconView::slotBeamDone( Ir* ir) {
352 delete ir; 356 delete ir;
353} 357}
354 358
355void PIconView::slotStart() { 359void PIconView::slotStart() {
356 m_view->viewport()->setUpdatesEnabled( false ); 360 m_view->viewport()->setUpdatesEnabled( false );
361 qWarning( "Sig Start" );
357} 362}
358 363
359void PIconView::slotEnd() { 364void 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
364void PIconView::slotShowImage() { 372void PIconView::slotShowImage() {
365 373
366} 374}
367void PIconView::slotShowImage( const QString& ) { 375void PIconView::slotShowImage( const QString& ) {
368 376
369} 377}
370void PIconView::slotImageInfo() { 378void PIconView::slotImageInfo() {
371 379
372} 380}
373void PIconView::slotImageInfo( const QString& ) { 381void PIconView::slotImageInfo( const QString& ) {
374 382
375} 383}
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
@@ -1,79 +1,80 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#ifndef PHUNK_ICON_VIEW_H 6#ifndef PHUNK_ICON_VIEW_H
7#define PHUNK_ICON_VIEW_H 7#define PHUNK_ICON_VIEW_H
8 8
9#include <qvbox.h> 9#include <qvbox.h>
10 10
11 11
12class QIconView; 12class QIconView;
13class QIconViewItem; 13class QIconViewItem;
14class QComboBox; 14class QComboBox;
15class PIconViewItem; 15class PIconViewItem;
16class PDirLister; 16class PDirLister;
17class Ir; 17class Ir;
18 18
19namespace Opie { 19namespace Opie {
20namespace Core{ 20namespace Core{
21 class OConfig; 21 class OConfig;
22} 22}
23namespace Ui { 23namespace Ui {
24 class OKeyConfigManager; 24 class OKeyConfigManager;
25} 25}
26} 26}
27 27
28class PIconView : public QVBox { 28class PIconView : public QVBox {
29 Q_OBJECT 29 Q_OBJECT
30 friend class PIconViewItem; 30 friend class PIconViewItem;
31 enum ActionIds { 31 enum ActionIds {
32 BeamItem, DeleteItem, ViewItem, InfoItem 32 BeamItem, DeleteItem, ViewItem, InfoItem
33 }; 33 };
34public: 34public:
35 PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); 35 PIconView( QWidget* wid, Opie::Core::OConfig *cfg );
36 ~PIconView(); 36 ~PIconView();
37 void resetView(); 37 void resetView();
38 Opie::Ui::OKeyConfigManager* manager(); 38 Opie::Ui::OKeyConfigManager* manager();
39 39
40private: 40private:
41 void initKeys(); 41 void initKeys();
42 QString currentFileName(bool &isDir)const; 42 QString currentFileName(bool &isDir)const;
43 void loadViews(); 43 void loadViews();
44 44
45private slots: 45private slots:
46 void slotDirUp(); 46 void slotDirUp();
47 void slotChangeDir(const QString&); 47 void slotChangeDir(const QString&);
48 void slotTrash(); 48 void slotTrash();
49 void slotViewChanged( int ); 49 void slotViewChanged( int );
50 void slotReloadDir(); 50 void slotReloadDir();
51 void slotRename(); 51 void slotRename();
52 void slotBeam(); 52 void slotBeam();
53 void slotBeamDone( Ir* ); 53 void slotBeamDone( Ir* );
54 54
55 void slotShowImage(); 55 void slotShowImage();
56 void slotShowImage( const QString& ); 56 void slotShowImage( const QString& );
57 void slotImageInfo(); 57 void slotImageInfo();
58 void slotImageInfo( const QString& ); 58 void slotImageInfo( const QString& );
59 59
60 void slotStart(); 60 void slotStart();
61 void slotEnd(); 61 void slotEnd();
62 62
63/* for performance reasons make it inline in the future */ 63/* for performance reasons make it inline in the future */
64 void addFolders( const QStringList& ); 64 void addFolders( const QStringList& );
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&);
71private: 71private:
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