summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index dbba4b9..2746732 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -209,284 +209,291 @@ void ODocumentFileView::reread()
209 m_selector->setNewVisible( showNew() ); 209 m_selector->setNewVisible( showNew() );
210 m_selector->setCloseVisible( showClose() ); 210 m_selector->setCloseVisible( showClose() );
211 m_selector->filter = currentMimeType().join(";"); 211 m_selector->filter = currentMimeType().join(";");
212 m_selector->reread(); 212 m_selector->reread();
213} 213}
214 214
215int ODocumentFileView::fileCount()const 215int ODocumentFileView::fileCount()const
216{ 216{
217 if (!m_selector) 217 if (!m_selector)
218 return -1; 218 return -1;
219 219
220 return m_selector->fileCount(); 220 return m_selector->fileCount();
221} 221}
222 222
223DocLnk ODocumentFileView::selectedDocument()const 223DocLnk ODocumentFileView::selectedDocument()const
224{ 224{
225 if (!m_selector) 225 if (!m_selector)
226 return DocLnk(); 226 return DocLnk();
227 227
228 return m_selector->selectedDocument(); 228 return m_selector->selectedDocument();
229} 229}
230 230
231QWidget* ODocumentFileView::widget( QWidget* parent ) 231QWidget* ODocumentFileView::widget( QWidget* parent )
232{ 232{
233 if (!m_selector ) 233 if (!m_selector )
234 { 234 {
235 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 235 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
236 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), 236 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ),
237 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 237 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
238 QObject::connect(m_selector, SIGNAL(closeMe() ), 238 QObject::connect(m_selector, SIGNAL(closeMe() ),
239 selector(), SIGNAL(closeMe() ) ); 239 selector(), SIGNAL(closeMe() ) );
240 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), 240 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ),
241 selector(), SIGNAL(newSelected(const DocLnk&) ) ); 241 selector(), SIGNAL(newSelected(const DocLnk&) ) );
242 } 242 }
243 243
244 return m_selector; 244 return m_selector;
245} 245}
246 246
247/* 247/*
248 * This is the file system view used 248 * This is the file system view used
249 * we use a QListView + QListViewItems for it 249 * we use a QListView + QListViewItems for it
250 */ 250 */
251 251
252OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 252OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
253 const QString& path, const QString& date, 253 const QString& path, const QString& date,
254 const QString& size, const QString& dir, 254 const QString& size, const QString& dir,
255 bool isLocked, bool isDir ) 255 bool isLocked, bool isDir )
256 : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) 256 : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked)
257{ 257{
258 setPixmap(0, pixmap ); 258 setPixmap(0, pixmap );
259 setText(1, path ); 259 setText(1, path );
260 setText(2, size ); 260 setText(2, size );
261 setText(3, date ); 261 setText(3, date );
262} 262}
263 263
264OFileSelectorItem::~OFileSelectorItem() 264OFileSelectorItem::~OFileSelectorItem()
265{ 265{
266} 266}
267 267
268bool OFileSelectorItem::isLocked()const 268bool OFileSelectorItem::isLocked()const
269{ 269{
270 return m_locked; 270 return m_locked;
271} 271}
272 272
273QString OFileSelectorItem::directory()const 273QString OFileSelectorItem::directory()const
274{ 274{
275 return m_dir; 275 return m_dir;
276} 276}
277 277
278bool OFileSelectorItem::isDir()const 278bool OFileSelectorItem::isDir()const
279{ 279{
280 return m_isDir; 280 return m_isDir;
281} 281}
282 282
283QString OFileSelectorItem::path()const 283QString OFileSelectorItem::path()const
284{ 284{
285 return text( 1 ); 285 return text( 1 );
286} 286}
287 287
288QString OFileSelectorItem::key( int id, bool )const 288QString OFileSelectorItem::key( int id, bool )const
289{ 289{
290 QString ke; 290 QString ke;
291 291
292 /* 292 /*
293 * id = 0 ||id == 1 : Sort By Name but Directories at Top 293 * id = 0 ||id == 1 : Sort By Name but Directories at Top
294 * id = 2 : Sort By Size: Prepend '0' to the key 294 * id = 2 : Sort By Size: Prepend '0' to the key
295 */ 295 */
296 if( id == 0 || id == 1 ) 296 if( id == 0 || id == 1 )
297 { // name 297 { // name
298 if( m_isDir ) 298 if( m_isDir )
299 { 299 {
300 ke.append("0" ); 300 ke.append("0" );
301 ke.append( text(1) ); 301 ke.append( text(1) );
302 } 302 }
303 else 303 else
304 { 304 {
305 ke.append("1" ); 305 ke.append("1" );
306 ke.append( text(1) ); 306 ke.append( text(1) );
307 } 307 }
308 return ke; 308 return ke;
309 }else if(id == 2) { 309 }else if(id == 2) {
310 return text(2).rightJustify(20, '0'); 310 return text(2).rightJustify(20, '0');
311 }else 311 }else
312 return text( id ); 312 return text( id );
313 313
314} 314}
315 315
316OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) 316OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel)
317 :QWidget( parent ), m_sel( sel ) 317 :QWidget( parent ), m_sel( sel )
318{ 318{
319 m_all = false; 319 m_all = false;
320 QVBoxLayout* lay = new QVBoxLayout( this ); 320 QVBoxLayout* lay = new QVBoxLayout( this );
321 m_currentDir = startDir; 321 m_currentDir = startDir;
322 322
323 /* 323 /*
324 * now we add a special bar 324 * now we add a special bar
325 * One Button For Up 325 * One Button For Up
326 * Home 326 * Home
327 * Doc 327 * Doc
328 * And a dropdown menu with FileSystems 328 * And a dropdown menu with FileSystems
329 * FUTURE: one to change dir with lineedit 329 * FUTURE: one to change dir with lineedit
330 * Bookmarks 330 * Bookmarks
331 * Create Dir 331 * Create Dir
332 */ 332 */
333 QHBox* box = new QHBox(this ); 333 QHBox* box = new QHBox(this );
334 box->setBackgroundMode( PaletteButton ); 334 box->setBackgroundMode( PaletteButton );
335 box->setSpacing( 0 ); 335 box->setSpacing( 0 );
336 336
337 QPixmap pic;
337 QToolButton *btn = new QToolButton( box ); 338 QToolButton *btn = new QToolButton( box );
338 btn->setIconSet( Resource::loadIconSet("up") ); 339 pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
340 btn->setPixmap( pic );
339 connect(btn, SIGNAL(clicked() ), 341 connect(btn, SIGNAL(clicked() ),
340 this, SLOT( cdUP() ) ); 342 this, SLOT( cdUP() ) );
341 343
342 btn = new QToolButton( box ); 344 btn = new QToolButton( box );
343 btn->setIconSet( Resource::loadIconSet("home") ); 345 pic.convertFromImage( Resource::loadImage( "home" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
346 btn->setPixmap( pic );
344 connect(btn, SIGNAL(clicked() ), 347 connect(btn, SIGNAL(clicked() ),
345 this, SLOT( cdHome() ) ); 348 this, SLOT( cdHome() ) );
346 349
347 btn = new QToolButton( box ); 350 btn = new QToolButton( box );
348 btn->setIconSet( Resource::loadIconSet("DocsIcon") ); 351 pic.convertFromImage( Resource::loadImage( "DocsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
352 btn->setPixmap( pic );
349 connect(btn, SIGNAL(clicked() ), 353 connect(btn, SIGNAL(clicked() ),
350 this, SLOT(cdDoc() ) ); 354 this, SLOT(cdDoc() ) );
351 355
352 m_btnNew = new QToolButton( box ); 356 m_btnNew = new QToolButton( box );
353 m_btnNew->setIconSet( Resource::loadIconSet("new") ); 357 pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
358 btn->setPixmap( pic );
354 connect(m_btnNew, SIGNAL(clicked() ), 359 connect(m_btnNew, SIGNAL(clicked() ),
355 this, SLOT(slotNew() ) ); 360 this, SLOT(slotNew() ) );
356 361
357 362
358 m_btnClose = new QToolButton( box ); 363 m_btnClose = new QToolButton( box );
359 m_btnClose->setIconSet( Resource::loadIconSet("close") ); 364 pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
365 btn->setPixmap( pic );
360 connect(m_btnClose, SIGNAL(clicked() ), 366 connect(m_btnClose, SIGNAL(clicked() ),
361 selector(), SIGNAL(closeMe() ) ); 367 selector(), SIGNAL(closeMe() ) );
362 368
363 btn = new QToolButton( box ); 369 btn = new QToolButton( box );
364 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); 370 pic.convertFromImage( Resource::loadImage( "cardmon/pcmcia" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
371 btn->setPixmap( pic );
365 372
366 m_fsButton = btn; 373 m_fsButton = btn;
367 /* let's fill device parts */ 374 /* let's fill device parts */
368 QPopupMenu* pop = new QPopupMenu(this); 375 QPopupMenu* pop = new QPopupMenu(this);
369 connect(pop, SIGNAL( activated(int) ), 376 connect(pop, SIGNAL( activated(int) ),
370 this, SLOT(slotFSActivated(int) ) ); 377 this, SLOT(slotFSActivated(int) ) );
371 378
372 StorageInfo storage; 379 StorageInfo storage;
373 const QList<FileSystem> &fs = storage.fileSystems(); 380 const QList<FileSystem> &fs = storage.fileSystems();
374 QListIterator<FileSystem> it(fs); 381 QListIterator<FileSystem> it(fs);
375 for ( ; it.current(); ++it ) 382 for ( ; it.current(); ++it )
376 { 383 {
377 const QString disk = (*it)->name(); 384 const QString disk = (*it)->name();
378 const QString path = (*it)->path(); 385 const QString path = (*it)->path();
379 m_dev.insert( disk, path ); 386 m_dev.insert( disk, path );
380 pop->insertItem( disk ); 387 pop->insertItem( disk );
381 } 388 }
382 m_fsPop = pop; 389 m_fsPop = pop;
383 390
384 connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed())); 391 connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed()));
385 392
386 lay->addWidget( box ); 393 lay->addWidget( box );
387 394
388 m_view = new QListView( this ); 395 m_view = new QListView( this );
389 396
390 m_view->installEventFilter(this); 397 m_view->installEventFilter(this);
391 398
392 QPEApplication::setStylusOperation( m_view->viewport(), 399 QPEApplication::setStylusOperation( m_view->viewport(),
393 QPEApplication::RightOnHold); 400 QPEApplication::RightOnHold);
394 m_view->addColumn(" " ); 401 m_view->addColumn(" " );
395 m_view->addColumn(tr("Name"), 135 ); 402 m_view->addColumn(tr("Name"), 135 );
396 m_view->addColumn(tr("Size"), -1 ); 403 m_view->addColumn(tr("Size"), -1 );
397 m_view->addColumn(tr("Date"), 60 ); 404 m_view->addColumn(tr("Date"), 60 );
398 m_view->addColumn(tr("Mime Type"), -1 ); 405 m_view->addColumn(tr("Mime Type"), -1 );
399 406
400 407
401 m_view->setSorting( 1 ); 408 m_view->setSorting( 1 );
402 m_view->setAllColumnsShowFocus( TRUE ); 409 m_view->setAllColumnsShowFocus( TRUE );
403 410
404 lay->addWidget( m_view, 1000 ); 411 lay->addWidget( m_view, 1000 );
405 connectSlots(); 412 connectSlots();
406} 413}
407 414
408void OFileViewFileListView::slotFSpressed() 415void OFileViewFileListView::slotFSpressed()
409{ 416{
410 m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y())); 417 m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y()));
411 m_fsButton->setDown(false); 418 m_fsButton->setDown(false);
412} 419}
413 420
414OFileViewFileListView::~OFileViewFileListView() 421OFileViewFileListView::~OFileViewFileListView()
415{ 422{
416} 423}
417 424
418void OFileViewFileListView::slotNew() 425void OFileViewFileListView::slotNew()
419{ 426{
420 DocLnk lnk; 427 DocLnk lnk;
421 emit selector()->newSelected( lnk ); 428 emit selector()->newSelected( lnk );
422} 429}
423 430
424OFileSelectorItem* OFileViewFileListView::currentItem()const 431OFileSelectorItem* OFileViewFileListView::currentItem()const
425{ 432{
426 QListViewItem* item = m_view->currentItem(); 433 QListViewItem* item = m_view->currentItem();
427 if (!item ) 434 if (!item )
428 return 0l; 435 return 0l;
429 436
430 return static_cast<OFileSelectorItem*>(item); 437 return static_cast<OFileSelectorItem*>(item);
431} 438}
432 439
433void OFileViewFileListView::reread( bool all ) 440void OFileViewFileListView::reread( bool all )
434{ 441{
435 m_view->clear(); 442 m_view->clear();
436 443
437 if (selector()->showClose() ) 444 if (selector()->showClose() )
438 m_btnClose->show(); 445 m_btnClose->show();
439 else 446 else
440 m_btnClose->hide(); 447 m_btnClose->hide();
441 448
442 if (selector()->showNew() ) 449 if (selector()->showNew() )
443 m_btnNew->show(); 450 m_btnNew->show();
444 else 451 else
445 m_btnNew->hide(); 452 m_btnNew->hide();
446 453
447 m_mimes = selector()->currentMimeType(); 454 m_mimes = selector()->currentMimeType();
448 m_all = all; 455 m_all = all;
449 456
450 QDir dir( m_currentDir ); 457 QDir dir( m_currentDir );
451 if (!dir.exists() ) 458 if (!dir.exists() )
452 return; 459 return;
453 460
454 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 461 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
455 int filter; 462 int filter;
456 filter = QDir::Dirs; 463 filter = QDir::Dirs;
457 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) 464 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR )
458 filter = filter | QDir::Files | QDir::All; 465 filter = filter | QDir::Files | QDir::All;
459 466
460 if ( m_all ) 467 if ( m_all )
461 filter = filter | QDir::Hidden; 468 filter = filter | QDir::Hidden;
462 469
463 dir.setFilter( filter ); 470 dir.setFilter( filter );
464 471
465 // now go through all files 472 // now go through all files
466 const QFileInfoList *list = dir.entryInfoList(); 473 const QFileInfoList *list = dir.entryInfoList();
467 if (!list) 474 if (!list)
468 { 475 {
469 cdUP(); 476 cdUP();
470 return; 477 return;
471 } 478 }
472 479
473 QFileInfoListIterator it( *list ); 480 QFileInfoListIterator it( *list );
474 QFileInfo *fi; 481 QFileInfo *fi;
475 while( (fi=it.current() ) ) 482 while( (fi=it.current() ) )
476 { 483 {
477 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) 484 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") )
478 { 485 {
479 ++it; 486 ++it;
480 continue; 487 continue;
481 } 488 }
482 489
483 /* 490 /*
484 * It is a symlink we try to resolve it now but don't let us attack by DOS 491 * It is a symlink we try to resolve it now but don't let us attack by DOS
485 * 492 *
486 */ 493 */
487 if( fi->isSymLink() ) 494 if( fi->isSymLink() )
488 { 495 {
489 QString file = createNewPath(fi->dirPath( true ),fi->readLink()); 496 QString file = createNewPath(fi->dirPath( true ),fi->readLink());
490 for( int i = 0; i<=4; i++) 497 for( int i = 0; i<=4; i++)
491 { // 5 tries to prevent dos 498 { // 5 tries to prevent dos
492 QFileInfo info( file ); 499 QFileInfo info( file );