summaryrefslogtreecommitdiff
authorzecke <zecke>2004-04-06 10:37:23 (UTC)
committer zecke <zecke>2004-04-06 10:37:23 (UTC)
commit8981e35697647315d88cdf95e912b0fe2f9d5375 (patch) (unidiff)
tree4631dc800cb6d45d38d69d43f14e305ce0123d10
parent2a4ec8132bea9c4c8308038d555755eabc1eee46 (diff)
downloadopie-8981e35697647315d88cdf95e912b0fe2f9d5375.zip
opie-8981e35697647315d88cdf95e912b0fe2f9d5375.tar.gz
opie-8981e35697647315d88cdf95e912b0fe2f9d5375.tar.bz2
Add some documentation and remove qWarnings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 4ced52d..c07a1e5 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -156,262 +156,301 @@ PIconView::~PIconView() {
156 156
157Opie::Ui::OKeyConfigManager* PIconView::manager() { 157Opie::Ui::OKeyConfigManager* PIconView::manager() {
158 return m_viewManager; 158 return m_viewManager;
159} 159}
160 160
161 161
162/* 162/*
163 * init the KeyBoard Shortcuts 163 * init the KeyBoard Shortcuts
164 * called from the c'tor 164 * called from the c'tor
165 */ 165 */
166void PIconView::initKeys() { 166void PIconView::initKeys() {
167 Opie::Ui::OKeyPair::List lst; 167 Opie::Ui::OKeyPair::List lst;
168 lst.append( Opie::Ui::OKeyPair::upArrowKey() ); 168 lst.append( Opie::Ui::OKeyPair::upArrowKey() );
169 lst.append( Opie::Ui::OKeyPair::downArrowKey() ); 169 lst.append( Opie::Ui::OKeyPair::downArrowKey() );
170 lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); 170 lst.append( Opie::Ui::OKeyPair::leftArrowKey() );
171 lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); 171 lst.append( Opie::Ui::OKeyPair::rightArrowKey() );
172 lst.append( Opie::Ui::OKeyPair::returnKey() ); 172 lst.append( Opie::Ui::OKeyPair::returnKey() );
173 173
174 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 174 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
175 lst, false,this, "keyconfig name" ); 175 lst, false,this, "keyconfig name" );
176 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 176 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
177 Resource::loadPixmap("beam"), BeamItem, 177 Resource::loadPixmap("beam"), BeamItem,
178 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton), 178 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton),
179 this, SLOT(slotBeam())) ); 179 this, SLOT(slotBeam())) );
180 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 180 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
181 Resource::loadPixmap("trash"), DeleteItem, 181 Resource::loadPixmap("trash"), DeleteItem,
182 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton), 182 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton),
183 this, SLOT(slotTrash())) ); 183 this, SLOT(slotTrash())) );
184 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 184 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
185 Resource::loadPixmap("1to1"), ViewItem, 185 Resource::loadPixmap("1to1"), ViewItem,
186 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), 186 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton),
187 this, SLOT(slotShowImage()))); 187 this, SLOT(slotShowImage())));
188 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 188 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
189 Resource::loadPixmap("DocumentTypeWord"), InfoItem, 189 Resource::loadPixmap("DocumentTypeWord"), InfoItem,
190 Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 190 Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
191 this, SLOT(slotImageInfo()) ) ); 191 this, SLOT(slotImageInfo()) ) );
192 m_viewManager->load(); 192 m_viewManager->load();
193 m_viewManager->handleWidget( m_view ); 193 m_viewManager->handleWidget( m_view );
194} 194}
195 195
196 196
197/* 197/*
198 * change one dir up 198 * change one dir up
199 */ 199 */
200void PIconView::slotDirUp() { 200void PIconView::slotDirUp() {
201 QDir dir( m_path ); 201 QDir dir( m_path );
202 dir.cdUp(); 202 dir.cdUp();
203 slotChangeDir( dir.absPath() ); 203 slotChangeDir( dir.absPath() );
204
205} 204}
206 205
207/* 206/*
208 * change the dir 207 * change the dir
209 */ 208 */
210void PIconView::slotChangeDir(const QString& path) { 209void PIconView::slotChangeDir(const QString& path) {
211 if ( !currentView() ) 210 if ( !currentView() )
212 return; 211 return;
213 212
214 PDirLister *lister = currentView()->dirLister(); 213 PDirLister *lister = currentView()->dirLister();
215 if (!lister ) 214 if (!lister )
216 return; 215 return;
217 216
217 /*
218 * Say what we want and take what we get
219 */
218 lister->setStartPath( path ); 220 lister->setStartPath( path );
219 m_path = lister->currentPath(); 221 m_path = lister->currentPath();
220 222
221 m_view->viewport()->setUpdatesEnabled( false ); 223 m_view->viewport()->setUpdatesEnabled( false );
222 m_view->clear(); 224 m_view->clear();
225
226 /*
227 * add files and folders
228 */
223 addFolders( lister->folders() ); 229 addFolders( lister->folders() );
224 addFiles( lister->files() ); 230 addFiles( lister->files() );
225 m_view->viewport()->setUpdatesEnabled( true ); 231 m_view->viewport()->setUpdatesEnabled( true );
226 232
227 // Also invalidate the cache. We can't cancel the operations anyway 233 // Also invalidate the cache. We can't cancel the operations anyway
228 g_stringPix.clear(); 234 g_stringPix.clear();
229 g_stringInf.clear(); 235 g_stringInf.clear();
230 236
231 // looks ugly 237 // looks ugly
232 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 238 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
233} 239}
234 240
241/**
242 * get the current file name
243 * @param isDir see if this is a dir or real file
244 */
235QString PIconView::currentFileName(bool &isDir)const { 245QString PIconView::currentFileName(bool &isDir)const {
236 isDir = false; 246 isDir = false;
237 QIconViewItem* _it = m_view->currentItem(); 247 QIconViewItem* _it = m_view->currentItem();
238 if ( !_it ) 248 if ( !_it )
239 return QString::null; 249 return QString::null;
240 250
241 IconViewItem* it = static_cast<IconViewItem*>( _it ); 251 IconViewItem* it = static_cast<IconViewItem*>( _it );
242 isDir = it->isDir(); 252 isDir = it->isDir();
243 return it->path(); 253 return it->path();
244} 254}
245 255
246void PIconView::slotTrash() { 256void PIconView::slotTrash() {
247 bool isDir; 257 bool isDir;
248 QString pa = currentFileName( isDir ); 258 QString pa = currentFileName( isDir );
249 if ( isDir && pa.isEmpty() ) 259 if ( isDir && pa.isEmpty() )
250 return; 260 return;
251 261
252 if (!QPEMessageBox::confirmDelete( this, 262 if (!QPEMessageBox::confirmDelete( this,
253 tr("Delete Image" ), 263 tr("Delete Image" ),
254 tr("the Image %1" ).arg(pa))) 264 tr("the Image %1" ).arg(pa)))
255 return 265 return
256 266
257 267
258 currentView()->dirLister()->deleteImage( pa ); 268 currentView()->dirLister()->deleteImage( pa );
259 delete m_view->currentItem(); 269 delete m_view->currentItem();
260} 270}
271
272/*
273 * see what views are available
274 */
261void PIconView::loadViews() { 275void PIconView::loadViews() {
262 ViewMap::Iterator it; 276 ViewMap::Iterator it;
263 ViewMap* map = viewMap(); 277 ViewMap* map = viewMap();
264 for ( it = map->begin(); it != map->end(); ++it ) 278 for ( it = map->begin(); it != map->end(); ++it )
265 m_views->insertItem( QObject::tr(it.key() ) ); 279 m_views->insertItem( QObject::tr(it.key() ) );
266} 280}
267 281
268void PIconView::resetView() { 282void PIconView::resetView() {
269 slotViewChanged(m_views->currentItem()); 283 slotViewChanged(m_views->currentItem());
270} 284}
271 285
286/*
287 *swicth view reloadDir and connect signals
288 */
272void PIconView::slotViewChanged( int i) { 289void PIconView::slotViewChanged( int i) {
273 if (!m_views->count() ) { 290 if (!m_views->count() ) {
274 setCurrentView( 0l); 291 setCurrentView( 0l);
275 return; 292 return;
276 } 293 }
277 294
278 PDirView* cur = currentView(); 295 PDirView* cur = currentView();
279 delete cur; 296 delete cur;
280 QString str = m_views->text(i); 297 QString str = m_views->text(i);
281 cur = (*(*viewMap())[str])(*m_cfg); 298 cur = (*(*viewMap())[str])(*m_cfg);
282 setCurrentView( cur ); 299 setCurrentView( cur );
283 300
284 /* connect to the signals of the lister */ 301 /* connect to the signals of the lister */
285 PDirLister* lis = cur->dirLister(); 302 PDirLister* lis = cur->dirLister();
286 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 303 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
287 this, SLOT( slotThumbInfo(const QString&, const QString&))); 304 this, SLOT( slotThumbInfo(const QString&, const QString&)));
288 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 305 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
289 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 306 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
290 connect(lis, SIGNAL(sig_start()), 307 connect(lis, SIGNAL(sig_start()),
291 this, SLOT(slotStart())); 308 this, SLOT(slotStart()));
292 connect(lis, SIGNAL(sig_end()) , 309 connect(lis, SIGNAL(sig_end()) ,
293 this, SLOT(slotEnd()) ); 310 this, SLOT(slotEnd()) );
294 311
295 312
296 /* reload now */ 313 /* reload now */
297 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 314 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
298} 315}
299 316
300 317
301void PIconView::slotReloadDir() { 318void PIconView::slotReloadDir() {
302 slotChangeDir( m_path ); 319 slotChangeDir( m_path );
303} 320}
304 321
305 322
323/*
324 * add files and folders
325 */
306void PIconView::addFolders( const QStringList& lst) { 326void PIconView::addFolders( const QStringList& lst) {
307 QStringList::ConstIterator it; 327 QStringList::ConstIterator it;
308 328
309 for(it=lst.begin(); it != lst.end(); ++it ) 329 for(it=lst.begin(); it != lst.end(); ++it )
310 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); 330 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
311 331
312 332
313} 333}
314 334
315void PIconView::addFiles( const QStringList& lst) { 335void PIconView::addFiles( const QStringList& lst) {
316 QStringList::ConstIterator it; 336 QStringList::ConstIterator it;
317 for (it=lst.begin(); it!= lst.end(); ++it ) 337 for (it=lst.begin(); it!= lst.end(); ++it )
318 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); 338 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
319 339
320} 340}
321 341
342/*
343 * user clicked on the item. Change dir or view
344 */
322void PIconView::slotClicked(QIconViewItem* _it) { 345void PIconView::slotClicked(QIconViewItem* _it) {
323 if(!_it ) 346 if(!_it )
324 return; 347 return;
325 348
326 IconViewItem* it = static_cast<IconViewItem*>(_it); 349 IconViewItem* it = static_cast<IconViewItem*>(_it);
327 if( it->isDir() ) 350 if( it->isDir() )
328 slotChangeDir( it->path() ); 351 slotChangeDir( it->path() );
329 else // view image 352 else // view image
330 slotShowImage(); 353 slotShowImage();
331} 354}
332 355
356/*
357 * got thumb info add to the cache if items is visible
358 * we later need update after processing of slave is done
359 */
333void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 360void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
334 IconViewItem* item = g_stringInf[_path]; 361 IconViewItem* item = g_stringInf[_path];
335 if (!item ) 362 if (!item )
336 return; 363 return;
337 364
338 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 365 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
339 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 366 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
340 m_updatet = true; 367 m_updatet = true;
341 368
342 item->setText( str ); 369 item->setText( str );
343 g_stringInf.remove( _path ); 370 g_stringInf.remove( _path );
344} 371}
372
373/*
374 * got thumbnail and see if it is visible so we need to update later
375 */
345void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 376void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
346 IconViewItem* item = g_stringPix[_path]; 377 IconViewItem* item = g_stringPix[_path];
347 if (!item ) 378 if (!item )
348 return; 379 return;
349 380
350 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 381 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
351 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 382 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
352 m_updatet = true; 383 m_updatet = true;
353 384
354 if (pix.width()>0) 385 if (pix.width()>0)
355 PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); 386 PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
356 387
357 388
358 g_stringPix.remove( _path ); 389 g_stringPix.remove( _path );
359} 390}
360 391
361 392
393/*
394 * FIXME rename
395 */
362void PIconView::slotRename() { 396void PIconView::slotRename() {
363 397
364} 398}
365 399
400
401/*
402 * BEAM the current file
403 */
366void PIconView::slotBeam() { 404void PIconView::slotBeam() {
367 bool isDir; 405 bool isDir;
368 QString pa = currentFileName( isDir ); 406 QString pa = currentFileName( isDir );
369 if ( isDir && pa.isEmpty() ) 407 if ( isDir && pa.isEmpty() )
370 return; 408 return;
371 409
372 Ir* ir = new Ir( this ); 410 Ir* ir = new Ir( this );
373 connect( ir, SIGNAL(done(Ir*)), 411 connect( ir, SIGNAL(done(Ir*)),
374 this, SLOT(slotBeamDone(Ir*))); 412 this, SLOT(slotBeamDone(Ir*)));
375 ir->send(pa, tr( "Image" ) ); 413 ir->send(pa, tr( "Image" ) );
376 414
377} 415}
378 416
417/*
418 * BEAM done clean up
419 */
379void PIconView::slotBeamDone( Ir* ir) { 420void PIconView::slotBeamDone( Ir* ir) {
380 delete ir; 421 delete ir;
381} 422}
382 423
383void PIconView::slotStart() { 424void PIconView::slotStart() {
384 m_view->viewport()->setUpdatesEnabled( false ); 425 m_view->viewport()->setUpdatesEnabled( false );
385} 426}
386 427
387void PIconView::slotEnd() { 428void PIconView::slotEnd() {
388 if ( m_updatet ) 429 if ( m_updatet )
389 m_view->arrangeItemsInGrid( ); 430 m_view->arrangeItemsInGrid( );
390 m_view->viewport()->setUpdatesEnabled( true ); 431 m_view->viewport()->setUpdatesEnabled( true );
391 m_updatet = false; 432 m_updatet = false;
392} 433}
393 434
394void PIconView::slotShowImage() 435void PIconView::slotShowImage()
395{ 436{
396 qWarning( "SLotShowImage" );
397 bool isDir = false; 437 bool isDir = false;
398 QString name = currentFileName(isDir); 438 QString name = currentFileName(isDir);
399 if (isDir) return; 439 if (isDir) return;
400 440
401 slotShowImage( name ); 441 slotShowImage( name );
402} 442}
403void PIconView::slotShowImage( const QString& name) { 443void PIconView::slotShowImage( const QString& name) {
404 emit sig_display( name ); 444 emit sig_display( name );
405} 445}
406void PIconView::slotImageInfo() { 446void PIconView::slotImageInfo() {
407 qWarning( "SlotImageInfo" );
408 bool isDir = false; 447 bool isDir = false;
409 QString name = currentFileName(isDir); 448 QString name = currentFileName(isDir);
410 if (isDir) return; 449 if (isDir) return;
411 450
412 slotImageInfo( name ); 451 slotImageInfo( name );
413} 452}
414 453
415void PIconView::slotImageInfo( const QString& name) { 454void PIconView::slotImageInfo( const QString& name) {
416 emit sig_showInfo( name ); 455 emit sig_showInfo( name );
417} 456}