summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/iconview.cpp
Unidiff
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.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index d546b64..660c4fa 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -149,55 +149,56 @@ namespace {
149PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 149PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
150 : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) 150 : QVBox( wid ), m_cfg( cfg ), m_updatet( false )
151{ 151{
152 { 152 {
153 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 153 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
154 } 154 }
155 m_path = QDir::homeDirPath(); 155 m_path = QDir::homeDirPath();
156 m_mode = 0; 156 m_mode = 0;
157 157
158 QHBox *hbox = new QHBox( this ); 158 QHBox *hbox = new QHBox( this );
159 QLabel* lbl = new QLabel( hbox ); 159 QLabel* lbl = new QLabel( hbox );
160 lbl->setText( tr("View as" ) ); 160 lbl->setText( tr("View as" ) );
161 161
162 m_views = new QComboBox( hbox, "View As" ); 162 m_views = new QComboBox( hbox, "View As" );
163 connect( m_views, SIGNAL(activated(int)), 163 connect( m_views, SIGNAL(activated(int)),
164 this, SLOT(slotViewChanged(int)) ); 164 this, SLOT(slotViewChanged(int)) );
165 165
166 m_view= new QIconView( this ); 166 m_view= new QIconView( this );
167 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 167 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
168 this, SLOT(slotClicked(QIconViewItem*)) ); 168 this, SLOT(slotClicked(QIconViewItem*)) );
169 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), 169 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
170 this, SLOT(slotClicked(QIconViewItem*)) ); 170 this, SLOT(slotClicked(QIconViewItem*)) );
171 171
172 m_view->setArrangement( QIconView::LeftToRight ); 172 m_view->setArrangement( QIconView::LeftToRight );
173 m_view->setItemTextPos( QIconView::Right );
174 173
175 int dw = QApplication::desktop()->width(); 174 m_mode = cfg->readNumEntry("ListViewMode", 1);
176 int viewerWidth = dw-style().scrollBarExtent().width();
177 m_view->setGridX( viewerWidth-3*m_view->spacing());
178 m_view->setGridY( fontMetrics().height()*2+40 );
179 175
176 if (m_mode < 1 || m_mode>3) m_mode = 1;
177
178 m_view->setItemTextPos( QIconView::Right );
179
180 calculateGrid();
180 181
181 initKeys(); 182 initKeys();
182 183
183 loadViews(); 184 loadViews();
184 slotViewChanged( m_views->currentItem() ); 185 slotViewChanged( m_views->currentItem() );
185} 186}
186 187
187/* 188/*
188 * Unref the slave and save the keyboard manager 189 * Unref the slave and save the keyboard manager
189 */ 190 */
190PIconView::~PIconView() { 191PIconView::~PIconView() {
191 { 192 {
192 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 193 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
193 } 194 }
194 m_viewManager->save(); 195 m_viewManager->save();
195 delete m_viewManager; 196 delete m_viewManager;
196} 197}
197 198
198Opie::Core::OKeyConfigManager* PIconView::manager() { 199Opie::Core::OKeyConfigManager* PIconView::manager() {
199 return m_viewManager; 200 return m_viewManager;
200} 201}
201 202
202 203
203/* 204/*
@@ -544,71 +545,73 @@ void PIconView::slotShowImage()
544 if (isDir) return; 545 if (isDir) return;
545 546
546 slotShowImage( name ); 547 slotShowImage( name );
547} 548}
548void PIconView::slotShowImage( const QString& name) { 549void PIconView::slotShowImage( const QString& name) {
549 emit sig_display( name ); 550 emit sig_display( name );
550} 551}
551void PIconView::slotImageInfo() { 552void PIconView::slotImageInfo() {
552 bool isDir = false; 553 bool isDir = false;
553 QString name = currentFileName(isDir); 554 QString name = currentFileName(isDir);
554 if (isDir) return; 555 if (isDir) return;
555 556
556 slotImageInfo( name ); 557 slotImageInfo( name );
557} 558}
558 559
559void PIconView::slotImageInfo( const QString& name) { 560void PIconView::slotImageInfo( const QString& name) {
560 emit sig_showInfo( name ); 561 emit sig_showInfo( name );
561} 562}
562 563
563 564
564void PIconView::slotChangeMode( int mode ) { 565void PIconView::slotChangeMode( int mode ) {
565 if ( mode >= 1 && mode <= 3 ) 566 if ( mode >= 1 && mode <= 3 )
566 m_mode = mode; 567 m_mode = mode;
567 568
568 QIconView::ItemTextPos pos; 569 m_cfg->writeEntry("ListViewMode", m_mode);
569 switch( m_mode ) {
570 case 2:
571 pos = QIconView::Bottom;
572 break;
573 case 3:
574 case 1:
575 default:
576 pos = QIconView::Right;
577 break;
578 }
579 m_view->setItemTextPos( pos );
580
581 calculateGrid(); 570 calculateGrid();
582 slotReloadDir(); 571 slotReloadDir();
583} 572}
584 573
585 574
586void PIconView::resizeEvent( QResizeEvent* re ) { 575void PIconView::resizeEvent( QResizeEvent* re ) {
587 QVBox::resizeEvent( re ); 576 QVBox::resizeEvent( re );
588 calculateGrid(); 577 calculateGrid();
589} 578}
590 579
591 580
592void PIconView::calculateGrid() { 581void PIconView::calculateGrid() {
593 odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl; 582 odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl;
594 odebug << "Size of view: " << m_view->size() << oendl; 583 odebug << "Size of view: " << m_view->size() << oendl;
584 int dw = QApplication::desktop()->width();
585 int viewerWidth = dw-style().scrollBarExtent().width();
595 586
587 QIconView::ItemTextPos pos;
588 switch( m_mode ) {
589 case 2:
590 pos = QIconView::Bottom;
591 break;
592 case 3:
593 case 1:
594 default:
595 pos = QIconView::Right;
596 break;
597 }
598 m_view->setItemTextPos( pos );
596 switch (m_mode) { 599 switch (m_mode) {
597 case 2: 600 case 2:
598 m_view->setGridX(50); 601 m_view->setGridX(50);
599 m_view->setGridY(20); 602 m_view->setGridY(20);
600 PPixmapCache::self()->setMaxImages(40); 603 PPixmapCache::self()->setMaxImages(40);
601 break; 604 break;
602 case 3: 605 case 3:
603 m_view->setGridX(m_view->width()); 606 m_view->setGridX( fontMetrics().width("testimage.jpg")+20);
604 m_view->setGridY(8); 607 m_view->setGridY(8);
605 PPixmapCache::self()->setMaxImages(2); 608 PPixmapCache::self()->setMaxImages(2);
606 break; 609 break;
607 case 1: 610 case 1:
608 default: 611 default:
609 m_view->setGridX(m_view->width()); 612 m_view->setGridX( viewerWidth-3*m_view->spacing());
610 m_view->setGridY(80); 613 m_view->setGridY( fontMetrics().height()*2+40 );
611 PPixmapCache::self()->setMaxImages(20); 614 PPixmapCache::self()->setMaxImages(20);
612 break; 615 break;
613 } 616 }
614} 617}