author | alwin <alwin> | 2004-04-21 23:15:47 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-21 23:15:47 (UTC) |
commit | 9230c9dd6bef33603cef1727be95dafc8065f66c (patch) (side-by-side diff) | |
tree | 076da2786297367a15e8929784933d8e9bd02576 | |
parent | 15abdc3ac4e7406d15a8a59f43b3ae669099074a (diff) | |
download | opie-9230c9dd6bef33603cef1727be95dafc8065f66c.zip opie-9230c9dd6bef33603cef1727be95dafc8065f66c.tar.gz opie-9230c9dd6bef33603cef1727be95dafc8065f66c.tar.bz2 |
saves the last view used.
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 77597d2..6c5f5ea 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp @@ -139,71 +139,83 @@ namespace { m_noInfo = true; QIconViewItem::setText( text ); } } /* * Set up the GUI.. initialize the slave set up gui * and also load a dir */ PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); } m_path = QDir::homeDirPath(); m_mode = 0; QHBox *hbox = new QHBox( this ); QLabel* lbl = new QLabel( hbox ); lbl->setText( tr("View as" ) ); m_views = new QComboBox( hbox, "View As" ); - connect( m_views, SIGNAL(activated(int)), - this, SLOT(slotViewChanged(int)) ); m_view= new QIconView( this ); connect(m_view, SIGNAL(clicked(QIconViewItem*) ), this, SLOT(slotClicked(QIconViewItem*)) ); connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), this, SLOT(slotClicked(QIconViewItem*)) ); m_view->setArrangement( QIconView::LeftToRight ); - m_mode = cfg->readNumEntry("ListViewMode", 1); + m_mode = m_cfg->readNumEntry("ListViewMode", 1); + QString lastView = m_cfg->readEntry("LastView",""); if (m_mode < 1 || m_mode>3) m_mode = 1; m_view->setItemTextPos( QIconView::Right ); calculateGrid(); initKeys(); loadViews(); - slotViewChanged( m_views->currentItem() ); + int cc=0; + for (; cc<m_views->count();++cc) { + if (m_views->text(cc)==lastView) { + break; + } + } + if (cc<m_views->count()) { + m_views->setCurrentItem(cc); + slotViewChanged(cc); + } else { + slotViewChanged(m_views->currentItem()); + } + connect( m_views, SIGNAL(activated(int)), + this, SLOT(slotViewChanged(int)) ); } /* * Unref the slave and save the keyboard manager */ PIconView::~PIconView() { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); } m_viewManager->save(); delete m_viewManager; } Opie::Core::OKeyConfigManager* PIconView::manager() { return m_viewManager; } /* * init the KeyBoard Shortcuts * called from the c'tor */ void PIconView::initKeys() { Opie::Core::OKeyPair::List lst; @@ -351,48 +363,50 @@ void PIconView::loadViews() { } void PIconView::resetView() { slotViewChanged(m_views->currentItem()); } /* *swicth view reloadDir and connect signals */ void PIconView::slotViewChanged( int i) { if (!m_views->count() ) { setCurrentView( 0l); return; } PDirView* cur = currentView(); if (cur) delete cur; QString str = m_views->text(i); ViewMap* map = viewMap(); if (!map) {setCurrentView(0l); return;} if (map->find(str) == map->end()) { owarn << "Key not found" << oendl; setCurrentView(0l); return; } + m_cfg->writeEntry("LastView",str); + m_cfg->write(); cur = (*(*map)[str])(*m_cfg); setCurrentView( cur ); /* connect to the signals of the lister */ PDirLister* lis = cur->dirLister(); connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), this, SLOT( slotThumbInfo(const QString&, const QString&))); connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), this, SLOT(slotThumbNail(const QString&, const QPixmap&))); connect(lis, SIGNAL(sig_start()), this, SLOT(slotStart())); connect(lis, SIGNAL(sig_end()) , this, SLOT(slotEnd()) ); /* reload now */ QTimer::singleShot( 0, this, SLOT(slotReloadDir())); } void PIconView::slotReloadDir() { slotChangeDir( m_path ); } |