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