Diffstat (limited to 'noncore/graphics/opie-eye/gui/iconview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 948477c..138e661 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -187,73 +187,60 @@ namespace { | |||
187 | */ | 187 | */ |
188 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 188 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
189 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 189 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
190 | { | 190 | { |
191 | { | 191 | { |
192 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 192 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
193 | } | 193 | } |
194 | m_path = QDir::homeDirPath(); | 194 | m_path = QDir::homeDirPath(); |
195 | m_mode = 0; | 195 | m_mode = 0; |
196 | m_iconsize = 32; | 196 | m_iconsize = 32; |
197 | m_internalReset = false; | 197 | m_internalReset = false; |
198 | m_customWidget = 0; | 198 | m_customWidget = 0; |
199 | m_setDocCalled = false; | ||
199 | 200 | ||
200 | m_hbox = new QHBox( this ); | 201 | m_hbox = new QHBox( this ); |
201 | QLabel* lbl = new QLabel( m_hbox ); | 202 | QLabel* lbl = new QLabel( m_hbox ); |
202 | lbl->setText( tr("View as" ) ); | 203 | lbl->setText( tr("View as" ) ); |
203 | 204 | ||
204 | m_views = new QComboBox( m_hbox, "View As" ); | 205 | m_views = new QComboBox( m_hbox, "View As" ); |
205 | 206 | ||
206 | m_view= new QIconView( this ); | 207 | m_view= new QIconView( this ); |
207 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 208 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
208 | this, SLOT(slotClicked(QIconViewItem*)) ); | 209 | this, SLOT(slotClicked(QIconViewItem*)) ); |
209 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 210 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
210 | this, SLOT(slotClicked(QIconViewItem*)) ); | 211 | this, SLOT(slotClicked(QIconViewItem*)) ); |
211 | 212 | ||
212 | m_view->setArrangement( QIconView::LeftToRight ); | 213 | m_view->setArrangement( QIconView::LeftToRight ); |
213 | 214 | ||
214 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); | 215 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); |
215 | QString lastView = m_cfg->readEntry("LastView",""); | ||
216 | |||
217 | if (m_mode < 1 || m_mode>3) m_mode = 1; | 216 | if (m_mode < 1 || m_mode>3) m_mode = 1; |
218 | |||
219 | m_view->setItemTextPos( QIconView::Right ); | 217 | m_view->setItemTextPos( QIconView::Right ); |
220 | if (m_mode >1) { | 218 | if (m_mode >1) { |
221 | m_view->setResizeMode(QIconView::Adjust); | 219 | m_view->setResizeMode(QIconView::Adjust); |
222 | } else { | 220 | } else { |
223 | m_view->setResizeMode(QIconView::Fixed); | 221 | m_view->setResizeMode(QIconView::Fixed); |
224 | } | 222 | } |
225 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | 223 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); |
226 | if (m_iconsize<12)m_iconsize = 12; | 224 | if (m_iconsize<12)m_iconsize = 12; |
227 | if (m_iconsize>64)m_iconsize = 64; | 225 | if (m_iconsize>64)m_iconsize = 64; |
228 | 226 | ||
229 | calculateGrid(); | 227 | calculateGrid(); |
230 | |||
231 | initKeys(); | 228 | initKeys(); |
232 | |||
233 | loadViews(); | 229 | loadViews(); |
234 | int cc=0; | ||
235 | for (; cc<m_views->count();++cc) { | ||
236 | if (m_views->text(cc)==lastView) { | ||
237 | break; | ||
238 | } | ||
239 | } | ||
240 | if (cc<m_views->count()) { | ||
241 | m_views->setCurrentItem(cc); | ||
242 | slotViewChanged(cc); | ||
243 | } else { | ||
244 | slotViewChanged(m_views->currentItem()); | ||
245 | } | 230 | } |
246 | connect( m_views, SIGNAL(activated(int)), | 231 | |
247 | this, SLOT(slotViewChanged(int)) ); | 232 | void PIconView::setDoccalled(bool how) |
233 | { | ||
234 | m_setDocCalled = how; | ||
248 | } | 235 | } |
249 | 236 | ||
250 | /* | 237 | /* |
251 | * Unref the slave and save the keyboard manager | 238 | * Unref the slave and save the keyboard manager |
252 | */ | 239 | */ |
253 | PIconView::~PIconView() { | 240 | PIconView::~PIconView() { |
254 | { | 241 | { |
255 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 242 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
256 | } | 243 | } |
257 | m_viewManager->save(); | 244 | m_viewManager->save(); |
258 | delete m_viewManager; | 245 | delete m_viewManager; |
259 | } | 246 | } |
@@ -432,24 +419,48 @@ void PIconView::resetView() { | |||
432 | delete _cpyPix; | 419 | delete _cpyPix; |
433 | _cpyPix = 0; | 420 | _cpyPix = 0; |
434 | } | 421 | } |
435 | calculateGrid(); | 422 | calculateGrid(); |
436 | } | 423 | } |
437 | } else { | 424 | } else { |
438 | m_iconsize = 64; | 425 | m_iconsize = 64; |
439 | } | 426 | } |
440 | slotViewChanged(m_views->currentItem()); | 427 | slotViewChanged(m_views->currentItem()); |
441 | m_internalReset = false; | 428 | m_internalReset = false; |
442 | } | 429 | } |
443 | 430 | ||
431 | void PIconView::polish() | ||
432 | { | ||
433 | odebug << "===\n" | ||
434 | << "PIconView::polish()\n" | ||
435 | << "====" << oendl; | ||
436 | QVBox::polish(); | ||
437 | |||
438 | QString lastView = m_cfg->readEntry("LastView",""); | ||
439 | int cc=0; | ||
440 | for (; cc<m_views->count();++cc) { | ||
441 | if (m_views->text(cc)==lastView) { | ||
442 | break; | ||
443 | } | ||
444 | } | ||
445 | if (cc<m_views->count()) { | ||
446 | m_views->setCurrentItem(cc); | ||
447 | slotViewChanged(cc); | ||
448 | } else { | ||
449 | slotViewChanged(m_views->currentItem()); | ||
450 | } | ||
451 | connect( m_views, SIGNAL(activated(int)), | ||
452 | this, SLOT(slotViewChanged(int)) ); | ||
453 | } | ||
454 | |||
444 | /* | 455 | /* |
445 | *swicth view reloadDir and connect signals | 456 | *swicth view reloadDir and connect signals |
446 | */ | 457 | */ |
447 | void PIconView::slotViewChanged( int i) { | 458 | void PIconView::slotViewChanged( int i) { |
448 | if (!m_views->count() ) { | 459 | if (!m_views->count() ) { |
449 | setCurrentView( 0l); | 460 | setCurrentView( 0l); |
450 | return; | 461 | return; |
451 | } | 462 | } |
452 | 463 | ||
453 | if (m_customWidget) { | 464 | if (m_customWidget) { |
454 | delete m_customWidget; | 465 | delete m_customWidget; |
455 | m_customWidget = 0; | 466 | m_customWidget = 0; |
@@ -520,33 +531,38 @@ void PIconView::addFolders( const QStringList& lst) { | |||
520 | if (m_mode==3) _iv->setTextOnly(true); | 531 | if (m_mode==3) _iv->setTextOnly(true); |
521 | } | 532 | } |
522 | } | 533 | } |
523 | 534 | ||
524 | void PIconView::addFiles( const QStringList& lst) { | 535 | void PIconView::addFiles( const QStringList& lst) { |
525 | QStringList::ConstIterator it; | 536 | QStringList::ConstIterator it; |
526 | IconViewItem * _iv; | 537 | IconViewItem * _iv; |
527 | QPixmap*m_pix = 0; | 538 | QPixmap*m_pix = 0; |
528 | QString pre = ""; | 539 | QString pre = ""; |
529 | if (!m_path.isEmpty()) { | 540 | if (!m_path.isEmpty()) { |
530 | pre = m_path+"/"; | 541 | pre = m_path+"/"; |
531 | } | 542 | } |
543 | QString s = ""; | ||
544 | int pos; | ||
532 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 545 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
546 | s = (*it); | ||
547 | pos = s.find(char(0)); | ||
533 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); | 548 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); |
549 | if (pos>-1) { | ||
550 | _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize ); | ||
551 | } else { | ||
534 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); | 552 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); |
553 | } | ||
535 | if (m_mode==3) { | 554 | if (m_mode==3) { |
536 | _iv->setTextOnly(true); | 555 | _iv->setTextOnly(true); |
537 | _iv->setPixmap(QPixmap()); | 556 | _iv->setPixmap(QPixmap()); |
538 | |||
539 | |||
540 | |||
541 | } else { | 557 | } else { |
542 | if (m_pix) _iv->setPixmap(*m_pix); | 558 | if (m_pix) _iv->setPixmap(*m_pix); |
543 | } | 559 | } |
544 | } | 560 | } |
545 | 561 | ||
546 | } | 562 | } |
547 | 563 | ||
548 | /* | 564 | /* |
549 | * user clicked on the item. Change dir or view | 565 | * user clicked on the item. Change dir or view |
550 | */ | 566 | */ |
551 | void PIconView::slotClicked(QIconViewItem* _it) { | 567 | void PIconView::slotClicked(QIconViewItem* _it) { |
552 | if(!_it ) | 568 | if(!_it ) |