author | alwin <alwin> | 2004-04-21 23:15:47 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-21 23:15:47 (UTC) |
commit | 9230c9dd6bef33603cef1727be95dafc8065f66c (patch) (unidiff) | |
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 | |||
@@ -131,87 +131,99 @@ namespace { | |||
131 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 131 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
132 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 132 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
133 | } | 133 | } |
134 | return m_pix ? m_pix : _unkPix; | 134 | return m_pix ? m_pix : _unkPix; |
135 | } | 135 | } |
136 | } | 136 | } |
137 | inline void IconViewItem::setText( const QString& str ) { | 137 | inline void IconViewItem::setText( const QString& str ) { |
138 | QString text = QIconViewItem::text()+"\n"+str; | 138 | QString text = QIconViewItem::text()+"\n"+str; |
139 | m_noInfo = true; | 139 | m_noInfo = true; |
140 | QIconViewItem::setText( text ); | 140 | QIconViewItem::setText( text ); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | /* | 145 | /* |
146 | * Set up the GUI.. initialize the slave set up gui | 146 | * Set up the GUI.. initialize the slave set up gui |
147 | * and also load a dir | 147 | * and also load a dir |
148 | */ | 148 | */ |
149 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 149 | PIconView::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)), | ||
164 | this, SLOT(slotViewChanged(int)) ); | ||
165 | 163 | ||
166 | m_view= new QIconView( this ); | 164 | m_view= new QIconView( this ); |
167 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 165 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
168 | this, SLOT(slotClicked(QIconViewItem*)) ); | 166 | this, SLOT(slotClicked(QIconViewItem*)) ); |
169 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 167 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
170 | this, SLOT(slotClicked(QIconViewItem*)) ); | 168 | this, SLOT(slotClicked(QIconViewItem*)) ); |
171 | 169 | ||
172 | m_view->setArrangement( QIconView::LeftToRight ); | 170 | m_view->setArrangement( QIconView::LeftToRight ); |
173 | 171 | ||
174 | m_mode = cfg->readNumEntry("ListViewMode", 1); | 172 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); |
173 | QString lastView = m_cfg->readEntry("LastView",""); | ||
175 | 174 | ||
176 | if (m_mode < 1 || m_mode>3) m_mode = 1; | 175 | if (m_mode < 1 || m_mode>3) m_mode = 1; |
177 | 176 | ||
178 | m_view->setItemTextPos( QIconView::Right ); | 177 | m_view->setItemTextPos( QIconView::Right ); |
179 | 178 | ||
180 | calculateGrid(); | 179 | calculateGrid(); |
181 | 180 | ||
182 | initKeys(); | 181 | initKeys(); |
183 | 182 | ||
184 | loadViews(); | 183 | loadViews(); |
185 | slotViewChanged( m_views->currentItem() ); | 184 | int cc=0; |
185 | for (; cc<m_views->count();++cc) { | ||
186 | if (m_views->text(cc)==lastView) { | ||
187 | break; | ||
188 | } | ||
189 | } | ||
190 | if (cc<m_views->count()) { | ||
191 | m_views->setCurrentItem(cc); | ||
192 | slotViewChanged(cc); | ||
193 | } else { | ||
194 | slotViewChanged(m_views->currentItem()); | ||
195 | } | ||
196 | connect( m_views, SIGNAL(activated(int)), | ||
197 | this, SLOT(slotViewChanged(int)) ); | ||
186 | } | 198 | } |
187 | 199 | ||
188 | /* | 200 | /* |
189 | * Unref the slave and save the keyboard manager | 201 | * Unref the slave and save the keyboard manager |
190 | */ | 202 | */ |
191 | PIconView::~PIconView() { | 203 | PIconView::~PIconView() { |
192 | { | 204 | { |
193 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 205 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
194 | } | 206 | } |
195 | m_viewManager->save(); | 207 | m_viewManager->save(); |
196 | delete m_viewManager; | 208 | delete m_viewManager; |
197 | } | 209 | } |
198 | 210 | ||
199 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 211 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
200 | return m_viewManager; | 212 | return m_viewManager; |
201 | } | 213 | } |
202 | 214 | ||
203 | 215 | ||
204 | /* | 216 | /* |
205 | * init the KeyBoard Shortcuts | 217 | * init the KeyBoard Shortcuts |
206 | * called from the c'tor | 218 | * called from the c'tor |
207 | */ | 219 | */ |
208 | void PIconView::initKeys() { | 220 | void PIconView::initKeys() { |
209 | Opie::Core::OKeyPair::List lst; | 221 | Opie::Core::OKeyPair::List lst; |
210 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 222 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
211 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 223 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
212 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 224 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
213 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 225 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
214 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 226 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
215 | 227 | ||
216 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 228 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
217 | lst, false,this, "keyconfig name" ); | 229 | lst, false,this, "keyconfig name" ); |
@@ -343,64 +355,66 @@ void PIconView::slotTrash() { | |||
343 | /* | 355 | /* |
344 | * see what views are available | 356 | * see what views are available |
345 | */ | 357 | */ |
346 | void PIconView::loadViews() { | 358 | void PIconView::loadViews() { |
347 | ViewMap::Iterator it; | 359 | ViewMap::Iterator it; |
348 | ViewMap* map = viewMap(); | 360 | ViewMap* map = viewMap(); |
349 | for ( it = map->begin(); it != map->end(); ++it ) | 361 | for ( it = map->begin(); it != map->end(); ++it ) |
350 | m_views->insertItem( it.key() ); | 362 | m_views->insertItem( it.key() ); |
351 | } | 363 | } |
352 | 364 | ||
353 | void PIconView::resetView() { | 365 | void PIconView::resetView() { |
354 | slotViewChanged(m_views->currentItem()); | 366 | slotViewChanged(m_views->currentItem()); |
355 | } | 367 | } |
356 | 368 | ||
357 | /* | 369 | /* |
358 | *swicth view reloadDir and connect signals | 370 | *swicth view reloadDir and connect signals |
359 | */ | 371 | */ |
360 | void PIconView::slotViewChanged( int i) { | 372 | void PIconView::slotViewChanged( int i) { |
361 | if (!m_views->count() ) { | 373 | if (!m_views->count() ) { |
362 | setCurrentView( 0l); | 374 | setCurrentView( 0l); |
363 | return; | 375 | return; |
364 | } | 376 | } |
365 | 377 | ||
366 | PDirView* cur = currentView(); | 378 | PDirView* cur = currentView(); |
367 | if (cur) delete cur; | 379 | if (cur) delete cur; |
368 | QString str = m_views->text(i); | 380 | QString str = m_views->text(i); |
369 | ViewMap* map = viewMap(); | 381 | ViewMap* map = viewMap(); |
370 | if (!map) {setCurrentView(0l); return;} | 382 | if (!map) {setCurrentView(0l); return;} |
371 | if (map->find(str) == map->end()) { | 383 | if (map->find(str) == map->end()) { |
372 | owarn << "Key not found" << oendl; | 384 | owarn << "Key not found" << oendl; |
373 | setCurrentView(0l); return; | 385 | setCurrentView(0l); return; |
374 | } | 386 | } |
387 | m_cfg->writeEntry("LastView",str); | ||
388 | m_cfg->write(); | ||
375 | cur = (*(*map)[str])(*m_cfg); | 389 | cur = (*(*map)[str])(*m_cfg); |
376 | setCurrentView( cur ); | 390 | setCurrentView( cur ); |
377 | 391 | ||
378 | /* connect to the signals of the lister */ | 392 | /* connect to the signals of the lister */ |
379 | PDirLister* lis = cur->dirLister(); | 393 | PDirLister* lis = cur->dirLister(); |
380 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 394 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
381 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 395 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
382 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 396 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
383 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 397 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
384 | connect(lis, SIGNAL(sig_start()), | 398 | connect(lis, SIGNAL(sig_start()), |
385 | this, SLOT(slotStart())); | 399 | this, SLOT(slotStart())); |
386 | connect(lis, SIGNAL(sig_end()) , | 400 | connect(lis, SIGNAL(sig_end()) , |
387 | this, SLOT(slotEnd()) ); | 401 | this, SLOT(slotEnd()) ); |
388 | 402 | ||
389 | 403 | ||
390 | /* reload now */ | 404 | /* reload now */ |
391 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 405 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
392 | } | 406 | } |
393 | 407 | ||
394 | 408 | ||
395 | void PIconView::slotReloadDir() { | 409 | void PIconView::slotReloadDir() { |
396 | slotChangeDir( m_path ); | 410 | slotChangeDir( m_path ); |
397 | } | 411 | } |
398 | 412 | ||
399 | 413 | ||
400 | /* | 414 | /* |
401 | * add files and folders | 415 | * add files and folders |
402 | */ | 416 | */ |
403 | void PIconView::addFolders( const QStringList& lst) { | 417 | void PIconView::addFolders( const QStringList& lst) { |
404 | QStringList::ConstIterator it; | 418 | QStringList::ConstIterator it; |
405 | IconViewItem * _iv; | 419 | IconViewItem * _iv; |
406 | 420 | ||