author | zautrix <zautrix> | 2005-07-06 11:17:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-06 11:17:00 (UTC) |
commit | 7e22293b1ec1ee190ca8db6c8ecd079bafdae520 (patch) (unidiff) | |
tree | aed67fbbd844480e3dc0a7b5587edca766b51a5f /microkde | |
parent | 3b77a857e17e04e47d22ba6017dd723ed922e3fc (diff) | |
download | kdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.zip kdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.tar.gz kdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.tar.bz2 |
fixes
-rw-r--r-- | microkde/ofileselector_p.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp index 488dee2..f4f112e 100644 --- a/microkde/ofileselector_p.cpp +++ b/microkde/ofileselector_p.cpp | |||
@@ -271,197 +271,197 @@ OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& st | |||
271 | 271 | ||
272 | StorageInfo storage; | 272 | StorageInfo storage; |
273 | const QList<FileSystem> &fs = storage.fileSystems(); | 273 | const QList<FileSystem> &fs = storage.fileSystems(); |
274 | QListIterator<FileSystem> it(fs); | 274 | QListIterator<FileSystem> it(fs); |
275 | for ( ; it.current(); ++it ) { | 275 | for ( ; it.current(); ++it ) { |
276 | const QString disk = (*it)->name(); | 276 | const QString disk = (*it)->name(); |
277 | const QString path = (*it)->path(); | 277 | const QString path = (*it)->path(); |
278 | m_dev.insert( disk, path ); | 278 | m_dev.insert( disk, path ); |
279 | pop->insertItem( disk ); | 279 | pop->insertItem( disk ); |
280 | } | 280 | } |
281 | m_fsPop = pop; | 281 | m_fsPop = pop; |
282 | 282 | ||
283 | 283 | ||
284 | btn->setPopup( pop ); | 284 | btn->setPopup( pop ); |
285 | btn->setPopupDelay ( 0 ); | 285 | btn->setPopupDelay ( 0 ); |
286 | lay->addWidget( box ); | 286 | lay->addWidget( box ); |
287 | 287 | ||
288 | m_view = new QListView( this ); | 288 | m_view = new QListView( this ); |
289 | 289 | ||
290 | m_view->installEventFilter(this); | 290 | m_view->installEventFilter(this); |
291 | 291 | ||
292 | QPEApplication::setStylusOperation( m_view->viewport(), | 292 | QPEApplication::setStylusOperation( m_view->viewport(), |
293 | QPEApplication::RightOnHold); | 293 | QPEApplication::RightOnHold); |
294 | m_view->addColumn(" " ); | 294 | m_view->addColumn(" " ); |
295 | m_view->addColumn(i18n("Name"), 150 ); | 295 | m_view->addColumn(i18n("Name"), 150 ); |
296 | m_view->addColumn(i18n("Size"), -1 ); | 296 | m_view->addColumn(i18n("Size"), -1 ); |
297 | m_view->addColumn(i18n("Date"), -1 ); | 297 | m_view->addColumn(i18n("Date"), -1 ); |
298 | m_view->addColumn(i18n("Mime Type"), -1 ); | 298 | m_view->addColumn(i18n("Mime Type"), -1 ); |
299 | 299 | ||
300 | 300 | ||
301 | m_view->setSorting( 1 ); | 301 | m_view->setSorting( 1 ); |
302 | m_view->setAllColumnsShowFocus( TRUE ); | 302 | m_view->setAllColumnsShowFocus( TRUE ); |
303 | 303 | ||
304 | lay->addWidget( m_view, 1000 ); | 304 | lay->addWidget( m_view, 1000 ); |
305 | connectSlots(); | 305 | connectSlots(); |
306 | } | 306 | } |
307 | OFileViewFileListView::~OFileViewFileListView() { | 307 | OFileViewFileListView::~OFileViewFileListView() { |
308 | } | 308 | } |
309 | void OFileViewFileListView::slotNew() { | 309 | void OFileViewFileListView::slotNew() { |
310 | DocLnk lnk; | 310 | DocLnk lnk; |
311 | emit selector()->newSelected( lnk ); | 311 | emit selector()->newSelected( lnk ); |
312 | } | 312 | } |
313 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ | 313 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ |
314 | QListViewItem* item = m_view->currentItem(); | 314 | QListViewItem* item = m_view->currentItem(); |
315 | if (!item ) | 315 | if (!item ) |
316 | return 0l; | 316 | return 0l; |
317 | 317 | ||
318 | return static_cast<OFileSelectorItem*>(item); | 318 | return static_cast<OFileSelectorItem*>(item); |
319 | } | 319 | } |
320 | void OFileViewFileListView::reread( bool all ) { | 320 | void OFileViewFileListView::reread( bool all ) { |
321 | m_view->clear(); | 321 | m_view->clear(); |
322 | 322 | ||
323 | if (selector()->showClose() ) | 323 | if (selector()->showClose() ) |
324 | m_btnClose->show(); | 324 | m_btnClose->show(); |
325 | else | 325 | else |
326 | m_btnClose->hide(); | 326 | m_btnClose->hide(); |
327 | 327 | ||
328 | if (selector()->showNew() ) | 328 | if (selector()->showNew() ) |
329 | m_btnNew->show(); | 329 | m_btnNew->show(); |
330 | else | 330 | else |
331 | m_btnNew->hide(); | 331 | m_btnNew->hide(); |
332 | 332 | ||
333 | m_mimes = selector()->currentMimeType(); | 333 | m_mimes = selector()->currentMimeType(); |
334 | m_all = all; | 334 | m_all = all; |
335 | 335 | ||
336 | QDir dir( m_currentDir ); | 336 | QDir dir( m_currentDir ); |
337 | if (!dir.exists() ) | 337 | if (!dir.exists() ) |
338 | return; | 338 | return; |
339 | topLevelWidget()->setCaption( dir.path() ); | 339 | topLevelWidget()->setCaption( dir.path() ); |
340 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 340 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
341 | int filter; | 341 | int filter; |
342 | if (m_all ) | 342 | if (m_all ) |
343 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 343 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
344 | else | 344 | else |
345 | filter = QDir::Files | QDir::Dirs | QDir::All; | 345 | filter = QDir::Files | QDir::Dirs | QDir::All; |
346 | dir.setFilter( filter ); | 346 | dir.setFilter( filter ); |
347 | 347 | ||
348 | // now go through all files | 348 | // now go through all files |
349 | const QFileInfoList *list = dir.entryInfoList(); | 349 | const QFileInfoList *list = dir.entryInfoList(); |
350 | if (!list) { | 350 | if (!list) { |
351 | cdUP(); | 351 | cdUP(); |
352 | return; | 352 | return; |
353 | } | 353 | } |
354 | QFileInfoListIterator it( *list ); | 354 | QFileInfoListIterator it( *list ); |
355 | QFileInfo *fi; | 355 | QFileInfo *fi; |
356 | while( (fi=it.current() ) ){ | 356 | while( (fi=it.current() ) ){ |
357 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 357 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
358 | ++it; | 358 | ++it; |
359 | continue; | 359 | continue; |
360 | } | 360 | } |
361 | 361 | ||
362 | /* | 362 | /* |
363 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 363 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
364 | * | 364 | * |
365 | */ | 365 | */ |
366 | if( fi->isSymLink() ){ | 366 | if( fi->isSymLink() ){ |
367 | qDebug("SYMLINK "); | 367 | //qDebug("SYMLINK "); |
368 | QString file = fi->readLink(); | 368 | QString file = fi->readLink(); |
369 | for( int i = 0; i<=5; i++) { // 5 tries to prevent dos | 369 | for( int i = 0; i<=5; i++) { // 5 tries to prevent dos |
370 | QFileInfo info( file ); | 370 | QFileInfo info( file ); |
371 | qDebug("FILE %s ", file.latin1()); | 371 | //qDebug("FILE %s ", file.latin1()); |
372 | if( !info.exists() ){ | 372 | if( !info.exists() ){ |
373 | addSymlink( fi, TRUE ); | 373 | addSymlink( fi, TRUE ); |
374 | break; | 374 | break; |
375 | }else if( info.isDir() ){ | 375 | }else if( info.isDir() ){ |
376 | addDir( fi, TRUE ); | 376 | addDir( fi, TRUE ); |
377 | break; | 377 | break; |
378 | }else if( info.isFile() ){ | 378 | }else if( info.isFile() ){ |
379 | addFile( fi, TRUE ); | 379 | addFile( fi, TRUE ); |
380 | break; | 380 | break; |
381 | }else if( info.isSymLink() ){ | 381 | }else if( info.isSymLink() ){ |
382 | file = info.readLink() ; | 382 | file = info.readLink() ; |
383 | break; | 383 | break; |
384 | }else if( i == 4){ // couldn't resolve symlink add it as symlink | 384 | }else if( i == 4){ // couldn't resolve symlink add it as symlink |
385 | addSymlink( fi ); | 385 | addSymlink( fi ); |
386 | } | 386 | } |
387 | } // off for loop for symlink resolving | 387 | } // off for loop for symlink resolving |
388 | }else if( fi->isDir() ) | 388 | }else if( fi->isDir() ) |
389 | addDir( fi ); | 389 | addDir( fi ); |
390 | else if( fi->isFile() ) | 390 | else if( fi->isFile() ) |
391 | addFile( fi ); | 391 | addFile( fi ); |
392 | 392 | ||
393 | ++it; | 393 | ++it; |
394 | } // of while loop | 394 | } // of while loop |
395 | m_view->sort(); | 395 | m_view->sort(); |
396 | 396 | ||
397 | } | 397 | } |
398 | int OFileViewFileListView::fileCount()const{ | 398 | int OFileViewFileListView::fileCount()const{ |
399 | return m_view->childCount(); | 399 | return m_view->childCount(); |
400 | } | 400 | } |
401 | QString OFileViewFileListView::currentDir()const{ | 401 | QString OFileViewFileListView::currentDir()const{ |
402 | return m_currentDir; | 402 | return m_currentDir; |
403 | } | 403 | } |
404 | OFileSelector* OFileViewFileListView::selector() { | 404 | OFileSelector* OFileViewFileListView::selector() { |
405 | return m_sel; | 405 | return m_sel; |
406 | } | 406 | } |
407 | 407 | ||
408 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { | 408 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { |
409 | #if 0 | 409 | #if 0 |
410 | if ( e->type() == QEvent::KeyPress ) { | 410 | if ( e->type() == QEvent::KeyPress ) { |
411 | QKeyEvent *k = (QKeyEvent *)e; | 411 | QKeyEvent *k = (QKeyEvent *)e; |
412 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | 412 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { |
413 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 413 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
414 | return true; | 414 | return true; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | #endif | 417 | #endif |
418 | return false; | 418 | return false; |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void OFileViewFileListView::connectSlots() { | 422 | void OFileViewFileListView::connectSlots() { |
423 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 423 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
424 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 424 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
425 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), | 425 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), |
426 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); | 426 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); |
427 | connect(m_view, SIGNAL(doubleClicked( QListViewItem* )), | 427 | connect(m_view, SIGNAL(doubleClicked( QListViewItem* )), |
428 | this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); | 428 | this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); |
429 | connect(m_view, SIGNAL(returnPressed( QListViewItem* )), | 429 | connect(m_view, SIGNAL(returnPressed( QListViewItem* )), |
430 | this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); | 430 | this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); |
431 | } | 431 | } |
432 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { | 432 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { |
433 | if (!item) | 433 | if (!item) |
434 | return; | 434 | return; |
435 | #if 0 | 435 | #if 0 |
436 | 436 | ||
437 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 437 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
438 | 438 | ||
439 | if (!sel->isDir() ) { | 439 | if (!sel->isDir() ) { |
440 | selector()->m_lneEdit->setText( sel->text(1) ); | 440 | selector()->m_lneEdit->setText( sel->text(1) ); |
441 | // if in fileselector mode we will emit selected | 441 | // if in fileselector mode we will emit selected |
442 | if ( selector()->mode() == OFileSelector::FileSelector ) { | 442 | if ( selector()->mode() == OFileSelector::FileSelector ) { |
443 | qWarning("slot Current Changed"); | 443 | qWarning("slot Current Changed"); |
444 | QStringList str = QStringList::split("->", sel->text(1) ); | 444 | QStringList str = QStringList::split("->", sel->text(1) ); |
445 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 445 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
446 | emit selector()->fileSelected( path ); | 446 | emit selector()->fileSelected( path ); |
447 | DocLnk lnk( path ); | 447 | DocLnk lnk( path ); |
448 | emit selector()->fileSelected( lnk ); | 448 | emit selector()->fileSelected( lnk ); |
449 | } | 449 | } |
450 | } | 450 | } |
451 | #endif | 451 | #endif |
452 | } | 452 | } |
453 | void OFileViewFileListView::slotDoubleClicked(QListViewItem* item ) { | 453 | void OFileViewFileListView::slotDoubleClicked(QListViewItem* item ) { |
454 | if (!item ) return; | 454 | if (!item ) return; |
455 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 455 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
456 | if (!sel->isLocked() ) { | 456 | if (!sel->isLocked() ) { |
457 | QStringList str = QStringList::split("->", sel->text(1) ); | 457 | QStringList str = QStringList::split("->", sel->text(1) ); |
458 | if (sel->isDir() ) { | 458 | if (sel->isDir() ) { |
459 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 459 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
460 | emit selector()->dirSelected( m_currentDir ); | 460 | emit selector()->dirSelected( m_currentDir ); |
461 | reread( m_all ); | 461 | reread( m_all ); |
462 | }else { // file | 462 | }else { // file |
463 | //qWarning("slot Clicked"); | 463 | //qWarning("slot Clicked"); |
464 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 464 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
465 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 465 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
466 | emit selector()->fileSelected( path ); | 466 | emit selector()->fileSelected( path ); |
467 | DocLnk lnk( path ); | 467 | DocLnk lnk( path ); |