Diffstat (limited to 'noncore/graphics/opie-eye/gui/iconview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 7c8c88d..eafff1d 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -108,96 +108,97 @@ namespace { | |||
108 | calcRect(text()); | 108 | calcRect(text()); |
109 | } | 109 | } |
110 | 110 | ||
111 | inline QPixmap* IconViewItem::pixmap()const { | 111 | inline QPixmap* IconViewItem::pixmap()const { |
112 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() | 112 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() |
113 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() | 113 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() |
114 | // << " " << iconView()->contentsY() << oendl; | 114 | // << " " << iconView()->contentsY() << oendl; |
115 | 115 | ||
116 | if (textOnly()&&!m_isDir) { | 116 | if (textOnly()&&!m_isDir) { |
117 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); | 117 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); |
118 | return _emptyPix; | 118 | return _emptyPix; |
119 | } | 119 | } |
120 | if ( m_isDir ) | 120 | if ( m_isDir ) |
121 | return _dirPix; | 121 | return _dirPix; |
122 | else{ | 122 | else{ |
123 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 123 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
124 | currentView()->dirLister()->imageInfo( m_path ); | 124 | currentView()->dirLister()->imageInfo( m_path ); |
125 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 125 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
126 | } | 126 | } |
127 | 127 | ||
128 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 128 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
129 | if (!m_pix && !g_stringPix.contains( m_path )) { | 129 | if (!m_pix && !g_stringPix.contains( m_path )) { |
130 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 130 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
131 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 131 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
132 | } | 132 | } |
133 | return m_pix ? m_pix : _unkPix; | 133 | return m_pix ? m_pix : _unkPix; |
134 | } | 134 | } |
135 | } | 135 | } |
136 | inline void IconViewItem::setText( const QString& str ) { | 136 | inline void IconViewItem::setText( const QString& str ) { |
137 | QString text = QIconViewItem::text()+"\n"+str; | 137 | QString text = QIconViewItem::text()+"\n"+str; |
138 | m_noInfo = true; | 138 | m_noInfo = true; |
139 | QIconViewItem::setText( text ); | 139 | QIconViewItem::setText( text ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | /* | 144 | /* |
145 | * Set up the GUI.. initialize the slave set up gui | 145 | * Set up the GUI.. initialize the slave set up gui |
146 | * and also load a dir | 146 | * and also load a dir |
147 | */ | 147 | */ |
148 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 148 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
149 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 149 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
150 | { | 150 | { |
151 | { | 151 | { |
152 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 152 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
153 | } | 153 | } |
154 | m_path = QDir::homeDirPath(); | 154 | m_path = QDir::homeDirPath(); |
155 | m_mode = 0; | 155 | m_mode = 0; |
156 | m_internalReset = false; | ||
156 | 157 | ||
157 | QHBox *hbox = new QHBox( this ); | 158 | QHBox *hbox = new QHBox( this ); |
158 | QLabel* lbl = new QLabel( hbox ); | 159 | QLabel* lbl = new QLabel( hbox ); |
159 | lbl->setText( tr("View as" ) ); | 160 | lbl->setText( tr("View as" ) ); |
160 | 161 | ||
161 | m_views = new QComboBox( hbox, "View As" ); | 162 | m_views = new QComboBox( hbox, "View As" ); |
162 | 163 | ||
163 | m_view= new QIconView( this ); | 164 | m_view= new QIconView( this ); |
164 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 165 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
165 | this, SLOT(slotClicked(QIconViewItem*)) ); | 166 | this, SLOT(slotClicked(QIconViewItem*)) ); |
166 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 167 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
167 | this, SLOT(slotClicked(QIconViewItem*)) ); | 168 | this, SLOT(slotClicked(QIconViewItem*)) ); |
168 | 169 | ||
169 | m_view->setArrangement( QIconView::LeftToRight ); | 170 | m_view->setArrangement( QIconView::LeftToRight ); |
170 | 171 | ||
171 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); | 172 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); |
172 | QString lastView = m_cfg->readEntry("LastView",""); | 173 | QString lastView = m_cfg->readEntry("LastView",""); |
173 | 174 | ||
174 | if (m_mode < 1 || m_mode>3) m_mode = 1; | 175 | if (m_mode < 1 || m_mode>3) m_mode = 1; |
175 | 176 | ||
176 | m_view->setItemTextPos( QIconView::Right ); | 177 | m_view->setItemTextPos( QIconView::Right ); |
177 | 178 | ||
178 | calculateGrid(); | 179 | calculateGrid(); |
179 | 180 | ||
180 | initKeys(); | 181 | initKeys(); |
181 | 182 | ||
182 | loadViews(); | 183 | loadViews(); |
183 | int cc=0; | 184 | int cc=0; |
184 | for (; cc<m_views->count();++cc) { | 185 | for (; cc<m_views->count();++cc) { |
185 | if (m_views->text(cc)==lastView) { | 186 | if (m_views->text(cc)==lastView) { |
186 | break; | 187 | break; |
187 | } | 188 | } |
188 | } | 189 | } |
189 | if (cc<m_views->count()) { | 190 | if (cc<m_views->count()) { |
190 | m_views->setCurrentItem(cc); | 191 | m_views->setCurrentItem(cc); |
191 | slotViewChanged(cc); | 192 | slotViewChanged(cc); |
192 | } else { | 193 | } else { |
193 | slotViewChanged(m_views->currentItem()); | 194 | slotViewChanged(m_views->currentItem()); |
194 | } | 195 | } |
195 | connect( m_views, SIGNAL(activated(int)), | 196 | connect( m_views, SIGNAL(activated(int)), |
196 | this, SLOT(slotViewChanged(int)) ); | 197 | this, SLOT(slotViewChanged(int)) ); |
197 | } | 198 | } |
198 | 199 | ||
199 | /* | 200 | /* |
200 | * Unref the slave and save the keyboard manager | 201 | * Unref the slave and save the keyboard manager |
201 | */ | 202 | */ |
202 | PIconView::~PIconView() { | 203 | PIconView::~PIconView() { |
203 | { | 204 | { |
@@ -318,142 +319,147 @@ QString PIconView::nextFileName(bool &isDir)const | |||
318 | QIconViewItem* _it = _it1->nextItem(); | 319 | QIconViewItem* _it = _it1->nextItem(); |
319 | if ( !_it ) | 320 | if ( !_it ) |
320 | return QString::null; | 321 | return QString::null; |
321 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 322 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
322 | isDir = it->isDir(); | 323 | isDir = it->isDir(); |
323 | return it->path(); | 324 | return it->path(); |
324 | } | 325 | } |
325 | 326 | ||
326 | QString PIconView::prevFileName(bool &isDir)const{ | 327 | QString PIconView::prevFileName(bool &isDir)const{ |
327 | isDir = false; | 328 | isDir = false; |
328 | QIconViewItem* _it = m_view->currentItem(); | 329 | QIconViewItem* _it = m_view->currentItem(); |
329 | if ( !_it ) | 330 | if ( !_it ) |
330 | return QString::null; | 331 | return QString::null; |
331 | _it = _it->prevItem(); | 332 | _it = _it->prevItem(); |
332 | if ( !_it ) | 333 | if ( !_it ) |
333 | return QString::null; | 334 | return QString::null; |
334 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 335 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
335 | isDir = it->isDir(); | 336 | isDir = it->isDir(); |
336 | return it->path(); | 337 | return it->path(); |
337 | } | 338 | } |
338 | 339 | ||
339 | void PIconView::slotTrash() { | 340 | void PIconView::slotTrash() { |
340 | bool isDir; | 341 | bool isDir; |
341 | QString pa = currentFileName( isDir ); | 342 | QString pa = currentFileName( isDir ); |
342 | if ( isDir && pa.isEmpty() ) | 343 | if ( isDir && pa.isEmpty() ) |
343 | return; | 344 | return; |
344 | 345 | ||
345 | if (!QPEMessageBox::confirmDelete( this, | 346 | if (!QPEMessageBox::confirmDelete( this, |
346 | tr("Delete Image" ), | 347 | tr("Delete Image" ), |
347 | tr("the Image %1" ).arg(pa))) | 348 | tr("the Image %1" ).arg(pa))) |
348 | return | 349 | return |
349 | 350 | ||
350 | 351 | ||
351 | currentView()->dirLister()->deleteImage( pa ); | 352 | currentView()->dirLister()->deleteImage( pa ); |
352 | delete m_view->currentItem(); | 353 | delete m_view->currentItem(); |
353 | } | 354 | } |
354 | 355 | ||
355 | /* | 356 | /* |
356 | * see what views are available | 357 | * see what views are available |
357 | */ | 358 | */ |
358 | void PIconView::loadViews() { | 359 | void PIconView::loadViews() { |
359 | ViewMap::Iterator it; | 360 | ViewMap::Iterator it; |
360 | ViewMap* map = viewMap(); | 361 | ViewMap* map = viewMap(); |
361 | for ( it = map->begin(); it != map->end(); ++it ) | 362 | for ( it = map->begin(); it != map->end(); ++it ) |
362 | m_views->insertItem( it.key() ); | 363 | m_views->insertItem( it.key() ); |
363 | } | 364 | } |
364 | 365 | ||
365 | void PIconView::resetView() { | 366 | void PIconView::resetView() { |
367 | m_internalReset = true; | ||
366 | slotViewChanged(m_views->currentItem()); | 368 | slotViewChanged(m_views->currentItem()); |
369 | m_internalReset = false; | ||
367 | } | 370 | } |
368 | 371 | ||
369 | /* | 372 | /* |
370 | *swicth view reloadDir and connect signals | 373 | *swicth view reloadDir and connect signals |
371 | */ | 374 | */ |
372 | void PIconView::slotViewChanged( int i) { | 375 | void PIconView::slotViewChanged( int i) { |
373 | if (!m_views->count() ) { | 376 | if (!m_views->count() ) { |
374 | setCurrentView( 0l); | 377 | setCurrentView( 0l); |
375 | return; | 378 | return; |
376 | } | 379 | } |
377 | 380 | ||
378 | PDirView* cur = currentView(); | 381 | PDirView* cur = currentView(); |
379 | if (cur) delete cur; | 382 | if (cur) delete cur; |
380 | QString str = m_views->text(i); | 383 | QString str = m_views->text(i); |
381 | ViewMap* map = viewMap(); | 384 | ViewMap* map = viewMap(); |
382 | if (!map) { | 385 | if (!map) { |
383 | setCurrentView(0l); | 386 | setCurrentView(0l); |
384 | return; | 387 | return; |
385 | } | 388 | } |
386 | 389 | ||
387 | if (map->find(str) == map->end()) { | 390 | if (map->find(str) == map->end()) { |
388 | owarn << "Key not found" << oendl; | 391 | owarn << "Key not found" << oendl; |
389 | setCurrentView(0l); | 392 | setCurrentView(0l); |
390 | return; | 393 | return; |
391 | } | 394 | } |
392 | 395 | ||
393 | m_cfg->writeEntry("LastView",str); | 396 | m_cfg->writeEntry("LastView",str); |
394 | m_cfg->write(); | 397 | m_cfg->write(); |
395 | cur = (*(*map)[str])(*m_cfg); | 398 | cur = (*(*map)[str])(*m_cfg); |
396 | setCurrentView( cur ); | 399 | setCurrentView( cur ); |
397 | 400 | ||
398 | /* connect to the signals of the lister */ | 401 | /* connect to the signals of the lister */ |
399 | PDirLister* lis = cur->dirLister(); | 402 | PDirLister* lis = cur->dirLister(); |
400 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 403 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
401 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 404 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
402 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 405 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
403 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 406 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
404 | connect(lis, SIGNAL(sig_start()), | 407 | connect(lis, SIGNAL(sig_start()), |
405 | this, SLOT(slotStart())); | 408 | this, SLOT(slotStart())); |
406 | connect(lis, SIGNAL(sig_end()) , | 409 | connect(lis, SIGNAL(sig_end()) , |
407 | this, SLOT(slotEnd()) ); | 410 | this, SLOT(slotEnd()) ); |
408 | 411 | ||
409 | 412 | ||
410 | /* reload now with default Path*/ | 413 | /* reload now with default Path |
411 | m_path = lis->defaultPath(); | 414 | * but only if it isn't a reset like from setupdlg |
415 | */ | ||
416 | if (!m_internalReset) | ||
417 | m_path = lis->defaultPath(); | ||
412 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 418 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
413 | } | 419 | } |
414 | 420 | ||
415 | 421 | ||
416 | void PIconView::slotReloadDir() { | 422 | void PIconView::slotReloadDir() { |
417 | slotChangeDir( m_path ); | 423 | slotChangeDir( m_path ); |
418 | } | 424 | } |
419 | 425 | ||
420 | 426 | ||
421 | /* | 427 | /* |
422 | * add files and folders | 428 | * add files and folders |
423 | */ | 429 | */ |
424 | void PIconView::addFolders( const QStringList& lst) { | 430 | void PIconView::addFolders( const QStringList& lst) { |
425 | QStringList::ConstIterator it; | 431 | QStringList::ConstIterator it; |
426 | IconViewItem * _iv; | 432 | IconViewItem * _iv; |
427 | 433 | ||
428 | for(it=lst.begin(); it != lst.end(); ++it ) { | 434 | for(it=lst.begin(); it != lst.end(); ++it ) { |
429 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 435 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
430 | if (m_mode==3) _iv->setTextOnly(true); | 436 | if (m_mode==3) _iv->setTextOnly(true); |
431 | } | 437 | } |
432 | } | 438 | } |
433 | 439 | ||
434 | void PIconView::addFiles( const QStringList& lst) { | 440 | void PIconView::addFiles( const QStringList& lst) { |
435 | QStringList::ConstIterator it; | 441 | QStringList::ConstIterator it; |
436 | IconViewItem * _iv; | 442 | IconViewItem * _iv; |
437 | QPixmap*m_pix = 0; | 443 | QPixmap*m_pix = 0; |
438 | QString pre = ""; | 444 | QString pre = ""; |
439 | if (!m_path.isEmpty()) { | 445 | if (!m_path.isEmpty()) { |
440 | pre = m_path+"/"; | 446 | pre = m_path+"/"; |
441 | } | 447 | } |
442 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 448 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
443 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); | 449 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); |
444 | _iv = new IconViewItem( m_view, pre+(*it), (*it) ); | 450 | _iv = new IconViewItem( m_view, pre+(*it), (*it) ); |
445 | if (m_mode==3) { | 451 | if (m_mode==3) { |
446 | _iv->setTextOnly(true); | 452 | _iv->setTextOnly(true); |
447 | _iv->setPixmap(QPixmap()); | 453 | _iv->setPixmap(QPixmap()); |
448 | 454 | ||
449 | 455 | ||
450 | 456 | ||
451 | } else { | 457 | } else { |
452 | if (m_pix) _iv->setPixmap(*m_pix); | 458 | if (m_pix) _iv->setPixmap(*m_pix); |
453 | } | 459 | } |
454 | } | 460 | } |
455 | 461 | ||
456 | } | 462 | } |
457 | 463 | ||
458 | /* | 464 | /* |
459 | * user clicked on the item. Change dir or view | 465 | * user clicked on the item. Change dir or view |