-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | 40 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.h | 1 |
4 files changed, 28 insertions, 20 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 087db30..77597d2 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -194,97 +194,99 @@ PIconView::~PIconView() { | |||
194 | } | 194 | } |
195 | m_viewManager->save(); | 195 | m_viewManager->save(); |
196 | delete m_viewManager; | 196 | delete m_viewManager; |
197 | } | 197 | } |
198 | 198 | ||
199 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 199 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
200 | return m_viewManager; | 200 | return m_viewManager; |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | /* | 204 | /* |
205 | * init the KeyBoard Shortcuts | 205 | * init the KeyBoard Shortcuts |
206 | * called from the c'tor | 206 | * called from the c'tor |
207 | */ | 207 | */ |
208 | void PIconView::initKeys() { | 208 | void PIconView::initKeys() { |
209 | Opie::Core::OKeyPair::List lst; | 209 | Opie::Core::OKeyPair::List lst; |
210 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 210 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
211 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 211 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
212 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 212 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
213 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 213 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
214 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 214 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
215 | 215 | ||
216 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 216 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
217 | lst, false,this, "keyconfig name" ); | 217 | lst, false,this, "keyconfig name" ); |
218 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 218 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
219 | Resource::loadPixmap("beam"), BeamItem, | 219 | Resource::loadPixmap("beam"), BeamItem, |
220 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 220 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
221 | this, SLOT(slotBeam())) ); | 221 | this, SLOT(slotBeam())) ); |
222 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 222 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
223 | Resource::loadPixmap("trash"), DeleteItem, | 223 | Resource::loadPixmap("trash"), DeleteItem, |
224 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 224 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
225 | this, SLOT(slotTrash())) ); | 225 | this, SLOT(slotTrash())) ); |
226 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 226 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
227 | Resource::loadPixmap("1to1"), ViewItem, | 227 | Resource::loadPixmap("1to1"), ViewItem, |
228 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 228 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
229 | this, SLOT(slotShowImage()))); | 229 | this, SLOT(slotShowImage()))); |
230 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 230 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
231 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 231 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, |
232 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 232 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
233 | this, SLOT(slotImageInfo()) ) ); | 233 | this, SLOT(slotImageInfo()) ) ); |
234 | m_viewManager->load(); | 234 | m_viewManager->load(); |
235 | m_viewManager->handleWidget( m_view ); | 235 | m_viewManager->handleWidget( m_view ); |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | /* | 239 | /* |
240 | * change one dir up | 240 | * change one dir up |
241 | */ | 241 | */ |
242 | void PIconView::slotDirUp() { | 242 | void PIconView::slotDirUp() |
243 | { | ||
244 | if (m_path.isEmpty()) return; | ||
243 | QDir dir( m_path ); | 245 | QDir dir( m_path ); |
244 | dir.cdUp(); | 246 | dir.cdUp(); |
245 | slotChangeDir( dir.absPath() ); | 247 | slotChangeDir( dir.absPath() ); |
246 | } | 248 | } |
247 | 249 | ||
248 | /* | 250 | /* |
249 | * change the dir | 251 | * change the dir |
250 | */ | 252 | */ |
251 | void PIconView::slotChangeDir(const QString& path) { | 253 | void PIconView::slotChangeDir(const QString& path) { |
252 | if ( !currentView() ) | 254 | if ( !currentView() ) |
253 | return; | 255 | return; |
254 | 256 | ||
255 | PDirLister *lister = currentView()->dirLister(); | 257 | PDirLister *lister = currentView()->dirLister(); |
256 | if (!lister ) | 258 | if (!lister ) |
257 | return; | 259 | return; |
258 | 260 | ||
259 | /* | 261 | /* |
260 | * Say what we want and take what we get | 262 | * Say what we want and take what we get |
261 | */ | 263 | */ |
262 | lister->setStartPath( path ); | 264 | lister->setStartPath( path ); |
263 | m_path = lister->currentPath(); | 265 | m_path = lister->currentPath(); |
264 | 266 | ||
265 | m_view->viewport()->setUpdatesEnabled( false ); | 267 | m_view->viewport()->setUpdatesEnabled( false ); |
266 | m_view->clear(); | 268 | m_view->clear(); |
267 | 269 | ||
268 | /* | 270 | /* |
269 | * add files and folders | 271 | * add files and folders |
270 | */ | 272 | */ |
271 | addFolders( lister->folders() ); | 273 | addFolders( lister->folders() ); |
272 | addFiles( lister->files() ); | 274 | addFiles( lister->files() ); |
273 | m_view->viewport()->setUpdatesEnabled( true ); | 275 | m_view->viewport()->setUpdatesEnabled( true ); |
274 | 276 | ||
275 | // Also invalidate the cache. We can't cancel the operations anyway | 277 | // Also invalidate the cache. We can't cancel the operations anyway |
276 | g_stringPix.clear(); | 278 | g_stringPix.clear(); |
277 | g_stringInf.clear(); | 279 | g_stringInf.clear(); |
278 | 280 | ||
279 | // looks ugly | 281 | // looks ugly |
280 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 282 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
281 | } | 283 | } |
282 | 284 | ||
283 | /** | 285 | /** |
284 | * get the current file name | 286 | * get the current file name |
285 | * @param isDir see if this is a dir or real file | 287 | * @param isDir see if this is a dir or real file |
286 | */ | 288 | */ |
287 | QString PIconView::currentFileName(bool &isDir)const { | 289 | QString PIconView::currentFileName(bool &isDir)const { |
288 | isDir = false; | 290 | isDir = false; |
289 | QIconViewItem* _it = m_view->currentItem(); | 291 | QIconViewItem* _it = m_view->currentItem(); |
290 | if ( !_it ) | 292 | if ( !_it ) |
@@ -535,94 +537,96 @@ void PIconView::slotShowNext() | |||
535 | /* if we got a name we have a next item */ | 537 | /* if we got a name we have a next item */ |
536 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 538 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
537 | slotShowImage(name); | 539 | slotShowImage(name); |
538 | } | 540 | } |
539 | 541 | ||
540 | void PIconView::slotShowPrev() | 542 | void PIconView::slotShowPrev() |
541 | { | 543 | { |
542 | bool isDir = false; | 544 | bool isDir = false; |
543 | QString name = prevFileName(isDir); | 545 | QString name = prevFileName(isDir); |
544 | if (name.isEmpty()) return; | 546 | if (name.isEmpty()) return; |
545 | if (isDir) return; | 547 | if (isDir) return; |
546 | /* if we got a name we have a prev item */ | 548 | /* if we got a name we have a prev item */ |
547 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 549 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
548 | slotShowImage(name); | 550 | slotShowImage(name); |
549 | } | 551 | } |
550 | 552 | ||
551 | void PIconView::slotShowImage() | 553 | void PIconView::slotShowImage() |
552 | { | 554 | { |
553 | bool isDir = false; | 555 | bool isDir = false; |
554 | QString name = currentFileName(isDir); | 556 | QString name = currentFileName(isDir); |
555 | if (isDir) return; | 557 | if (isDir) return; |
556 | slotShowImage( name ); | 558 | slotShowImage( name ); |
557 | } | 559 | } |
558 | void PIconView::slotShowImage( const QString& name) { | 560 | void PIconView::slotShowImage( const QString& name) { |
559 | PDirLister *lister = currentView()->dirLister(); | 561 | PDirLister *lister = currentView()->dirLister(); |
560 | QString r_name = lister->nameToFname(name); | 562 | QString r_name = lister->nameToFname(name); |
561 | emit sig_display( r_name ); | 563 | emit sig_display( r_name ); |
562 | } | 564 | } |
563 | void PIconView::slotImageInfo() { | 565 | void PIconView::slotImageInfo() { |
564 | bool isDir = false; | 566 | bool isDir = false; |
565 | QString name = currentFileName(isDir); | 567 | QString name = currentFileName(isDir); |
566 | if (isDir) return; | 568 | if (isDir) return; |
567 | 569 | ||
568 | slotImageInfo( name ); | 570 | slotImageInfo( name ); |
569 | } | 571 | } |
570 | 572 | ||
571 | void PIconView::slotImageInfo( const QString& name) { | 573 | void PIconView::slotImageInfo( const QString& name) { |
572 | PDirLister *lister = currentView()->dirLister(); | 574 | PDirLister *lister = currentView()->dirLister(); |
573 | QString r_name = lister->nameToFname(name); | 575 | QString r_name = lister->nameToFname(name); |
574 | emit sig_showInfo(r_name ); | 576 | emit sig_showInfo(r_name ); |
575 | } | 577 | } |
576 | 578 | ||
577 | 579 | ||
578 | void PIconView::slotChangeMode( int mode ) { | 580 | void PIconView::slotChangeMode( int mode ) { |
579 | if ( mode >= 1 && mode <= 3 ) | 581 | if ( mode >= 1 && mode <= 3 ) |
580 | m_mode = mode; | 582 | m_mode = mode; |
581 | 583 | ||
582 | m_cfg->writeEntry("ListViewMode", m_mode); | 584 | m_cfg->writeEntry("ListViewMode", m_mode); |
585 | /* performance! */ | ||
586 | m_view->clear(); | ||
583 | calculateGrid(); | 587 | calculateGrid(); |
584 | slotReloadDir(); | 588 | slotReloadDir(); |
585 | } | 589 | } |
586 | 590 | ||
587 | 591 | ||
588 | void PIconView::resizeEvent( QResizeEvent* re ) { | 592 | void PIconView::resizeEvent( QResizeEvent* re ) { |
589 | QVBox::resizeEvent( re ); | 593 | QVBox::resizeEvent( re ); |
590 | calculateGrid(); | 594 | calculateGrid(); |
591 | } | 595 | } |
592 | 596 | ||
593 | 597 | ||
594 | void PIconView::calculateGrid() { | 598 | void PIconView::calculateGrid() { |
595 | int dw = QApplication::desktop()->width(); | 599 | int dw = QApplication::desktop()->width(); |
596 | int viewerWidth = dw-style().scrollBarExtent().width(); | 600 | int viewerWidth = dw-style().scrollBarExtent().width(); |
597 | 601 | ||
598 | QIconView::ItemTextPos pos; | 602 | QIconView::ItemTextPos pos; |
599 | switch( m_mode ) { | 603 | switch( m_mode ) { |
600 | case 2: | 604 | case 2: |
601 | pos = QIconView::Bottom; | 605 | pos = QIconView::Bottom; |
602 | break; | 606 | break; |
603 | case 3: | 607 | case 3: |
604 | case 1: | 608 | case 1: |
605 | default: | 609 | default: |
606 | pos = QIconView::Right; | 610 | pos = QIconView::Right; |
607 | break; | 611 | break; |
608 | } | 612 | } |
609 | m_view->setItemTextPos( pos ); | 613 | m_view->setItemTextPos( pos ); |
610 | switch (m_mode) { | 614 | switch (m_mode) { |
611 | case 2: | 615 | case 2: |
612 | m_view->setGridX(50); | 616 | m_view->setGridX(50); |
613 | m_view->setGridY(20); | 617 | m_view->setGridY(20); |
614 | PPixmapCache::self()->setMaxImages(40); | 618 | PPixmapCache::self()->setMaxImages(40); |
615 | break; | 619 | break; |
616 | case 3: | 620 | case 3: |
617 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); | 621 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); |
618 | m_view->setGridY(8); | 622 | m_view->setGridY(8); |
619 | PPixmapCache::self()->setMaxImages(2); | 623 | PPixmapCache::self()->setMaxImages(2); |
620 | break; | 624 | break; |
621 | case 1: | 625 | case 1: |
622 | default: | 626 | default: |
623 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 627 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
624 | m_view->setGridY( fontMetrics().height()*2+40 ); | 628 | m_view->setGridY( fontMetrics().height()*2+40 ); |
625 | PPixmapCache::self()->setMaxImages(20); | 629 | PPixmapCache::self()->setMaxImages(20); |
626 | break; | 630 | break; |
627 | } | 631 | } |
628 | } | 632 | } |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 058fca0..ec6b051 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -179,96 +179,97 @@ void PMainWindow::slotToggleAutoscale() | |||
179 | if (!m_disp) return; | 179 | if (!m_disp) return; |
180 | bool cur = scaleButton->isOn(); | 180 | bool cur = scaleButton->isOn(); |
181 | scaleButton->setOn(!cur); | 181 | scaleButton->setOn(!cur); |
182 | } | 182 | } |
183 | 183 | ||
184 | void PMainWindow::slotRotateToggled(bool how) | 184 | void PMainWindow::slotRotateToggled(bool how) |
185 | { | 185 | { |
186 | autoRotate = how; | 186 | autoRotate = how; |
187 | if (m_disp) { | 187 | if (m_disp) { |
188 | m_disp->setAutoRotate(how); | 188 | m_disp->setAutoRotate(how); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | void PMainWindow::slotScaleToggled(bool how) | 192 | void PMainWindow::slotScaleToggled(bool how) |
193 | { | 193 | { |
194 | autoScale = !how; | 194 | autoScale = !how; |
195 | if (!how) { | 195 | if (!how) { |
196 | autoRotate = how; | 196 | autoRotate = how; |
197 | } | 197 | } |
198 | if (m_disp) { | 198 | if (m_disp) { |
199 | m_disp->setAutoScaleRotate(autoScale,autoRotate); | 199 | m_disp->setAutoScaleRotate(autoScale,autoRotate); |
200 | } | 200 | } |
201 | if (!autoScale) { | 201 | if (!autoScale) { |
202 | rotateButton->setOn(false); | 202 | rotateButton->setOn(false); |
203 | } | 203 | } |
204 | rotateButton->setEnabled(!how); | 204 | rotateButton->setEnabled(!how); |
205 | } | 205 | } |
206 | 206 | ||
207 | void PMainWindow::slotConfig() { | 207 | void PMainWindow::slotConfig() { |
208 | /* | 208 | /* |
209 | * have a tab with the possible views | 209 | * have a tab with the possible views |
210 | * a tab for globals image cache size.. scaled loading | 210 | * a tab for globals image cache size.. scaled loading |
211 | * and one tab for the KeyConfigs | 211 | * and one tab for the KeyConfigs |
212 | */ | 212 | */ |
213 | QDialog dlg(this, 0, true); | 213 | QDialog dlg(this, 0, true); |
214 | dlg.setCaption( tr("Phunk View - Config" ) ); | 214 | dlg.setCaption( tr("Phunk View - Config" ) ); |
215 | 215 | ||
216 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 216 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
217 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 217 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
218 | lay->addWidget( wid ); | 218 | lay->addWidget( wid ); |
219 | ViewMap *vM = viewMap(); | 219 | ViewMap *vM = viewMap(); |
220 | ViewMap::Iterator _it = vM->begin(); | 220 | ViewMap::Iterator _it = vM->begin(); |
221 | QMap<PDirView*, QWidget*> lst; | 221 | QMap<PDirView*, QWidget*> lst; |
222 | 222 | ||
223 | for( ; _it != vM->end(); ++_it ) { | 223 | for( ; _it != vM->end(); ++_it ) { |
224 | PDirView *view = (_it.data())(*m_cfg); | 224 | PDirView *view = (_it.data())(*m_cfg); |
225 | PInterfaceInfo *inf = view->interfaceInfo(); | 225 | PInterfaceInfo *inf = view->interfaceInfo(); |
226 | QWidget *_wid = inf->configWidget( *m_cfg ); | 226 | QWidget *_wid = inf->configWidget( *m_cfg ); |
227 | if (!_wid) continue; | ||
227 | _wid->reparent(wid, QPoint() ); | 228 | _wid->reparent(wid, QPoint() ); |
228 | lst.insert( view, _wid ); | 229 | lst.insert( view, _wid ); |
229 | wid->addTab( _wid, "fileopen", inf->name() ); | 230 | wid->addTab( _wid, "fileopen", inf->name() ); |
230 | } | 231 | } |
231 | 232 | ||
232 | /* | 233 | /* |
233 | * Add the KeyConfigWidget | 234 | * Add the KeyConfigWidget |
234 | */ | 235 | */ |
235 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | 236 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); |
236 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 237 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
237 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | 238 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); |
238 | 239 | ||
239 | if ( !m_info ) { | 240 | if ( !m_info ) { |
240 | initInfo(); | 241 | initInfo(); |
241 | } | 242 | } |
242 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); | 243 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); |
243 | 244 | ||
244 | if ( !m_disp ) { | 245 | if ( !m_disp ) { |
245 | initDisp(); | 246 | initDisp(); |
246 | } | 247 | } |
247 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); | 248 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); |
248 | 249 | ||
249 | keyWid->load(); | 250 | keyWid->load(); |
250 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | 251 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); |
251 | 252 | ||
252 | 253 | ||
253 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 254 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
254 | 255 | ||
255 | /* | 256 | /* |
256 | * clean up | 257 | * clean up |
257 | *apply changes | 258 | *apply changes |
258 | */ | 259 | */ |
259 | 260 | ||
260 | QMap<PDirView*, QWidget*>::Iterator it; | 261 | QMap<PDirView*, QWidget*>::Iterator it; |
261 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 262 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
262 | if ( act ) | 263 | if ( act ) |
263 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 264 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
264 | delete it.key(); | 265 | delete it.key(); |
265 | } | 266 | } |
266 | 267 | ||
267 | 268 | ||
268 | if ( act ) { | 269 | if ( act ) { |
269 | m_view->resetView(); | 270 | m_view->resetView(); |
270 | keyWid->save(); | 271 | keyWid->save(); |
271 | m_disp->manager()->save(); | 272 | m_disp->manager()->save(); |
272 | m_info->manager()->save(); | 273 | m_info->manager()->save(); |
273 | m_view->manager()->save(); | 274 | m_view->manager()->save(); |
274 | } | 275 | } |
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp index f695a76..73b2863 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | |||
@@ -1,146 +1,150 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include "doc_lister.h" | 5 | #include "doc_lister.h" |
6 | 6 | ||
7 | #include <lib/slavemaster.h> | 7 | #include <lib/slavemaster.h> |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | #include <qpe/applnk.h> | 13 | #include <qpe/applnk.h> |
14 | 14 | ||
15 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
16 | 16 | ||
17 | /* QT */ | 17 | /* QT */ |
18 | #include <qdir.h> | 18 | #include <qdir.h> |
19 | #include <qfileinfo.h> | 19 | #include <qfileinfo.h> |
20 | 20 | ||
21 | Doc_DirLister::Doc_DirLister() | 21 | Doc_DirLister::Doc_DirLister() |
22 | : PDirLister( "doc_dir_lister" ) | 22 | : PDirLister( "doc_dir_lister" ) |
23 | { | 23 | { |
24 | SlaveMaster* master = SlaveMaster::self(); | 24 | SlaveMaster* master = SlaveMaster::self(); |
25 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); | 25 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); |
26 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); | 26 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); |
27 | connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), | 27 | connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), |
28 | this, SLOT(slotThumbInfo(const QString&, const QString&)) ); | 28 | this, SLOT(slotThumbInfo(const QString&, const QString&)) ); |
29 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), | 29 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), |
30 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); | 30 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); |
31 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), | 31 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), |
32 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); | 32 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); |
33 | 33 | ||
34 | m_namemap.clear(); | ||
35 | m_filemap.clear(); | ||
34 | } | 36 | } |
35 | 37 | ||
36 | QString Doc_DirLister::defaultPath()const { | 38 | QString Doc_DirLister::defaultPath()const { |
37 | return ""; QPEApplication::documentDir(); | 39 | return ""; QPEApplication::documentDir(); |
38 | } | 40 | } |
39 | 41 | ||
40 | QString Doc_DirLister::setStartPath( const QString& path ) { | 42 | QString Doc_DirLister::setStartPath(const QString&) { |
41 | m_namemap.clear(); | ||
42 | m_out.clear(); | ||
43 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); | 43 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); |
44 | owarn << "Set start path" << oendl; | 44 | if (m_namemap.isEmpty()) { |
45 | DocLnkSet ds; | 45 | DocLnkSet ds; |
46 | Global::findDocuments(&ds,Mtype_str); | 46 | Global::findDocuments(&ds,Mtype_str); |
47 | QListIterator<DocLnk> dit(ds.children()); | 47 | QListIterator<DocLnk> dit(ds.children()); |
48 | for( ; dit.current(); ++dit) { | 48 | for( ; dit.current(); ++dit) { |
49 | owarn << (*dit)->file() << oendl; | 49 | owarn << (*dit)->file() << oendl; |
50 | m_namemap[(*dit)->name()]=(*dit)->file(); | 50 | m_namemap[(*dit)->name()]=(*dit)->file(); |
51 | m_filemap[(*dit)->file()]=(*dit)->name(); | 51 | m_filemap[(*dit)->file()]=(*dit)->name(); |
52 | m_out.append((*dit)->name()); | 52 | } |
53 | } | 53 | } |
54 | owarn << "Set start path end" << oendl; | 54 | return QString::null; |
55 | return ""; | ||
56 | } | 55 | } |
57 | 56 | ||
58 | QString Doc_DirLister::currentPath()const { | 57 | QString Doc_DirLister::currentPath()const { |
59 | return ""; | 58 | return QString::null; |
60 | } | 59 | } |
61 | 60 | ||
62 | 61 | ||
63 | QStringList Doc_DirLister::folders()const { | 62 | QStringList Doc_DirLister::folders()const { |
64 | return QStringList(); | 63 | return QStringList(); |
65 | } | 64 | } |
66 | 65 | ||
67 | QStringList Doc_DirLister::files()const { | 66 | QStringList Doc_DirLister::files()const { |
68 | return m_out; | 67 | QStringList out; |
68 | QMap<QString,QString>::ConstIterator it; | ||
69 | for (it = m_namemap.begin();it != m_namemap.end();++it) { | ||
70 | out.append(it.key()); | ||
71 | } | ||
72 | return out; | ||
69 | } | 73 | } |
70 | 74 | ||
71 | void Doc_DirLister::deleteImage( const QString& ) { | 75 | void Doc_DirLister::deleteImage( const QString& ) |
76 | { | ||
72 | } | 77 | } |
73 | 78 | ||
74 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { | 79 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { |
75 | if (m_namemap.find(str)==m_namemap.end()) { | 80 | if (m_namemap.find(str)==m_namemap.end()) { |
76 | owarn << "Item " << str << " not found" << oendl; | 81 | owarn << "Item " << str << " not found" << oendl; |
77 | return; | 82 | return; |
78 | } | 83 | } |
79 | QString fname = m_namemap[str]; | 84 | QString fname = m_namemap[str]; |
80 | SlaveMaster::self()->thumbNail( fname, w, h ); | 85 | SlaveMaster::self()->thumbNail( fname, w, h ); |
81 | } | 86 | } |
82 | 87 | ||
83 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { | 88 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { |
84 | if (m_namemap.find(str)==m_namemap.end()) { | 89 | if (m_namemap.find(str)==m_namemap.end()) { |
85 | owarn << "Item " << str << " not found" << oendl; | 90 | owarn << "Item " << str << " not found" << oendl; |
86 | return QImage(); | 91 | return QImage(); |
87 | } | 92 | } |
88 | QString fname = m_namemap[str]; | 93 | QString fname = m_namemap[str]; |
89 | return SlaveMaster::self()->image( fname, f, m ); | 94 | return SlaveMaster::self()->image( fname, f, m ); |
90 | } | 95 | } |
91 | 96 | ||
92 | void Doc_DirLister::imageInfo( const QString& str) { | 97 | void Doc_DirLister::imageInfo( const QString& str) { |
93 | if (m_namemap.find(str)==m_namemap.end()) { | 98 | if (m_namemap.find(str)==m_namemap.end()) { |
94 | owarn << "Item " << str << " not found" << oendl; | 99 | owarn << "Item " << str << " not found" << oendl; |
95 | return; | 100 | return; |
96 | } | 101 | } |
97 | QString fname = m_namemap[str]; | 102 | QString fname = m_namemap[str]; |
98 | owarn << "Image info: " << fname << oendl; | ||
99 | SlaveMaster::self()->thumbInfo( fname ); | 103 | SlaveMaster::self()->thumbInfo( fname ); |
100 | } | 104 | } |
101 | 105 | ||
102 | void Doc_DirLister::fullImageInfo( const QString& str) { | 106 | void Doc_DirLister::fullImageInfo( const QString& str) { |
103 | if (m_namemap.find(str)==m_namemap.end()) { | 107 | if (m_namemap.find(str)==m_namemap.end()) { |
104 | owarn << "Item " << str << " not found" << oendl; | 108 | owarn << "Item " << str << " not found" << oendl; |
105 | return; | 109 | return; |
106 | } | 110 | } |
107 | QString fname = m_namemap[str]; | 111 | QString fname = m_namemap[str]; |
108 | SlaveMaster::self()->imageInfo( fname ); | 112 | SlaveMaster::self()->imageInfo( fname ); |
109 | } | 113 | } |
110 | 114 | ||
111 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) | 115 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) |
112 | { | 116 | { |
113 | if (m_filemap.find(f)==m_filemap.end()) { | 117 | if (m_filemap.find(f)==m_filemap.end()) { |
114 | owarn << "Item " << f << " not found" << oendl; | 118 | owarn << "Item " << f << " not found" << oendl; |
115 | return; | 119 | return; |
116 | } | 120 | } |
117 | QString name = m_filemap[f]; | 121 | QString name = m_filemap[f]; |
118 | emit sig_fullInfo(name, t); | 122 | emit sig_fullInfo(name, t); |
119 | } | 123 | } |
120 | 124 | ||
121 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) | 125 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) |
122 | { | 126 | { |
123 | if (m_filemap.find(f)==m_filemap.end()) { | 127 | if (m_filemap.find(f)==m_filemap.end()) { |
124 | owarn << "Item " << f << " not found" << oendl; | 128 | owarn << "Item " << f << " not found" << oendl; |
125 | return; | 129 | return; |
126 | } | 130 | } |
127 | QString name = m_filemap[f]; | 131 | QString name = m_filemap[f]; |
128 | emit sig_thumbInfo(name, t); | 132 | emit sig_thumbInfo(name, t); |
129 | } | 133 | } |
130 | 134 | ||
131 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) | 135 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) |
132 | { | 136 | { |
133 | if (m_filemap.find(f)==m_filemap.end()) { | 137 | if (m_filemap.find(f)==m_filemap.end()) { |
134 | owarn << "Item " << f << " not found" << oendl; | 138 | owarn << "Item " << f << " not found" << oendl; |
135 | return; | 139 | return; |
136 | } | 140 | } |
137 | QString name = m_filemap[f]; | 141 | QString name = m_filemap[f]; |
138 | emit sig_thumbNail(name, p); | 142 | emit sig_thumbNail(name, p); |
139 | } | 143 | } |
140 | 144 | ||
141 | QString Doc_DirLister::nameToFname(const QString&name)const | 145 | QString Doc_DirLister::nameToFname(const QString&name)const |
142 | { | 146 | { |
143 | if (m_namemap.find(name)==m_namemap.end()) { | 147 | if (m_namemap.find(name)==m_namemap.end()) { |
144 | owarn << "Item " << name << " not found" << oendl; | 148 | owarn << "Item " << name << " not found" << oendl; |
145 | return QString::null; | 149 | return QString::null; |
146 | } | 150 | } |
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h index d89b579..a65b616 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.h +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h | |||
@@ -1,42 +1,41 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef DOC_LISTER_INTERFACE_LISTER_H | 5 | #ifndef DOC_LISTER_INTERFACE_LISTER_H |
6 | #define DOC_LISTER_INTERFACE_LISTER_H | 6 | #define DOC_LISTER_INTERFACE_LISTER_H |
7 | 7 | ||
8 | #include <iface/dirlister.h> | 8 | #include <iface/dirlister.h> |
9 | 9 | ||
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qmap.h> | 11 | #include <qmap.h> |
12 | 12 | ||
13 | class Config; | 13 | class Config; |
14 | class Doc_DirLister : public PDirLister { | 14 | class Doc_DirLister : public PDirLister { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | Doc_DirLister(); | 17 | Doc_DirLister(); |
18 | virtual ~Doc_DirLister(){} | 18 | virtual ~Doc_DirLister(){} |
19 | 19 | ||
20 | QString defaultPath()const; | 20 | QString defaultPath()const; |
21 | QString setStartPath( const QString& ); | 21 | QString setStartPath( const QString& ); |
22 | QString currentPath()const; | 22 | QString currentPath()const; |
23 | QStringList folders()const; | 23 | QStringList folders()const; |
24 | QStringList files()const; | 24 | QStringList files()const; |
25 | 25 | ||
26 | void deleteImage( const QString& ); | 26 | void deleteImage( const QString& ); |
27 | void thumbNail( const QString&, int, int ); | 27 | void thumbNail( const QString&, int, int ); |
28 | QImage image( const QString&, Factor, int ); | 28 | QImage image( const QString&, Factor, int ); |
29 | void imageInfo( const QString& ); | 29 | void imageInfo( const QString& ); |
30 | void fullImageInfo( const QString& ); | 30 | void fullImageInfo( const QString& ); |
31 | virtual QString nameToFname(const QString&name)const; | 31 | virtual QString nameToFname(const QString&name)const; |
32 | 32 | ||
33 | private: | 33 | private: |
34 | QMap<QString,QString> m_namemap,m_filemap; | 34 | QMap<QString,QString> m_namemap,m_filemap; |
35 | QStringList m_out; | ||
36 | protected slots: | 35 | protected slots: |
37 | virtual void slotFullInfo(const QString&, const QString&); | 36 | virtual void slotFullInfo(const QString&, const QString&); |
38 | virtual void slotThumbInfo(const QString&, const QString&); | 37 | virtual void slotThumbInfo(const QString&, const QString&); |
39 | virtual void slotThumbNail(const QString&, const QPixmap&); | 38 | virtual void slotThumbNail(const QString&, const QPixmap&); |
40 | }; | 39 | }; |
41 | 40 | ||
42 | #endif | 41 | #endif |