summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector/ofileselector.cpp
authorzecke <zecke>2005-02-07 22:41:59 (UTC)
committer zecke <zecke>2005-02-07 22:41:59 (UTC)
commitf112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24 (patch) (unidiff)
tree95f03410ad60ed5d04486821e9bc76cf1e3664ec /libopie2/opieui/fileselector/ofileselector.cpp
parent2e4fd59ce900490ccbbb6c0f7b2fcd4811ac8a07 (diff)
downloadopie-f112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24.zip
opie-f112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24.tar.gz
opie-f112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24.tar.bz2
Fix for #1482, do not start a path with "//". We do that by having
a method to assemble paths to avoid adding a second "/"
Diffstat (limited to 'libopie2/opieui/fileselector/ofileselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 718f743..74aca96 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -17,96 +17,106 @@
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30/* hacky but we need to get FileSelector::filter */ 30/* hacky but we need to get FileSelector::filter */
31#define private public 31#define private public
32#include <qpe/fileselector.h> 32#include <qpe/fileselector.h>
33#undef private 33#undef private
34 34
35#include "ofileselector_p.h" 35#include "ofileselector_p.h"
36 36
37/* OPIE */ 37/* OPIE */
38#include <opie2/ofileselector.h> 38#include <opie2/ofileselector.h>
39#include <opie2/odebug.h> 39#include <opie2/odebug.h>
40 40
41#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
42#include <qpe/mimetype.h> 42#include <qpe/mimetype.h>
43#include <qpe/resource.h> 43#include <qpe/resource.h>
44#include <qpe/storage.h> 44#include <qpe/storage.h>
45 45
46/* QT */ 46/* QT */
47#include <qcombobox.h> 47#include <qcombobox.h>
48#include <qdir.h> 48#include <qdir.h>
49#include <qhbox.h> 49#include <qhbox.h>
50#include <qheader.h> 50#include <qheader.h>
51#include <qlabel.h> 51#include <qlabel.h>
52#include <qlayout.h> 52#include <qlayout.h>
53#include <qlineedit.h> 53#include <qlineedit.h>
54#include <qlistview.h> 54#include <qlistview.h>
55#include <qpopupmenu.h> 55#include <qpopupmenu.h>
56#include <qwidgetstack.h> 56#include <qwidgetstack.h>
57#include <qregexp.h> 57#include <qregexp.h>
58#include <qobjectlist.h> 58#include <qobjectlist.h>
59 59
60using namespace Opie::Ui::Internal; 60using namespace Opie::Ui::Internal;
61 61
62namespace Opie { 62namespace Opie {
63namespace Ui { 63namespace Ui {
64namespace Internal { 64namespace Internal {
65/*
66 * Create a path by adding a '/'/QDir::seperator in between
67 * base and ending, but only if base is not empty
68 */
69static inline QString createNewPath(const QString& base, const QString &ending) {
70 return base == QString::fromLatin1("/") ?
71 base + ending : base + "/" + ending;
72}
73
74
65OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) 75OFileViewInterface::OFileViewInterface( OFileSelector* _selector )
66 : m_selector( _selector ) 76 : m_selector( _selector )
67{ 77{
68 selector()->registerView( this ); 78 selector()->registerView( this );
69} 79}
70 80
71OFileViewInterface::~OFileViewInterface() 81OFileViewInterface::~OFileViewInterface()
72{} 82{}
73 83
74QString OFileViewInterface::name()const 84QString OFileViewInterface::name()const
75{ 85{
76 return m_name; 86 return m_name;
77} 87}
78 88
79void OFileViewInterface::setName( const QString& name ) 89void OFileViewInterface::setName( const QString& name )
80{ 90{
81 m_name = name; 91 m_name = name;
82} 92}
83 93
84OFileSelector* OFileViewInterface::selector()const 94OFileSelector* OFileViewInterface::selector()const
85{ 95{
86 return m_selector; 96 return m_selector;
87} 97}
88 98
89DocLnk OFileViewInterface::selectedDocument()const 99DocLnk OFileViewInterface::selectedDocument()const
90{ 100{
91 return DocLnk( selectedName() ); 101 return DocLnk( selectedName() );
92} 102}
93 103
94bool OFileViewInterface::showNew()const 104bool OFileViewInterface::showNew()const
95{ 105{
96 return selector()->showNew(); 106 return selector()->showNew();
97} 107}
98 108
99bool OFileViewInterface::showClose()const 109bool OFileViewInterface::showClose()const
100{ 110{
101 return selector()->showClose(); 111 return selector()->showClose();
102} 112}
103 113
104MimeTypes OFileViewInterface::mimeTypes()const 114MimeTypes OFileViewInterface::mimeTypes()const
105{ 115{
106 return selector()->mimeTypes(); 116 return selector()->mimeTypes();
107} 117}
108 118
109QStringList OFileViewInterface::currentMimeType()const 119QStringList OFileViewInterface::currentMimeType()const
110{ 120{
111 return selector()->currentMimeType(); 121 return selector()->currentMimeType();
112} 122}
@@ -425,275 +435,275 @@ void OFileViewFileListView::reread( bool all )
425 435
426 if (selector()->showNew() ) 436 if (selector()->showNew() )
427 m_btnNew->show(); 437 m_btnNew->show();
428 else 438 else
429 m_btnNew->hide(); 439 m_btnNew->hide();
430 440
431 m_mimes = selector()->currentMimeType(); 441 m_mimes = selector()->currentMimeType();
432 m_all = all; 442 m_all = all;
433 443
434 QDir dir( m_currentDir ); 444 QDir dir( m_currentDir );
435 if (!dir.exists() ) 445 if (!dir.exists() )
436 return; 446 return;
437 447
438 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 448 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
439 int filter; 449 int filter;
440 filter = QDir::Dirs; 450 filter = QDir::Dirs;
441 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) 451 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR )
442 filter = filter | QDir::Files | QDir::All; 452 filter = filter | QDir::Files | QDir::All;
443 453
444 if ( m_all ) 454 if ( m_all )
445 filter = filter | QDir::Hidden; 455 filter = filter | QDir::Hidden;
446 456
447 dir.setFilter( filter ); 457 dir.setFilter( filter );
448 458
449 // now go through all files 459 // now go through all files
450 const QFileInfoList *list = dir.entryInfoList(); 460 const QFileInfoList *list = dir.entryInfoList();
451 if (!list) 461 if (!list)
452 { 462 {
453 cdUP(); 463 cdUP();
454 return; 464 return;
455 } 465 }
456 466
457 QFileInfoListIterator it( *list ); 467 QFileInfoListIterator it( *list );
458 QFileInfo *fi; 468 QFileInfo *fi;
459 while( (fi=it.current() ) ) 469 while( (fi=it.current() ) )
460 { 470 {
461 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) 471 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") )
462 { 472 {
463 ++it; 473 ++it;
464 continue; 474 continue;
465 } 475 }
466 476
467 /* 477 /*
468 * It is a symlink we try to resolve it now but don't let us attack by DOS 478 * It is a symlink we try to resolve it now but don't let us attack by DOS
469 * 479 *
470 */ 480 */
471 if( fi->isSymLink() ) 481 if( fi->isSymLink() )
472 { 482 {
473 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 483 QString file = createNewPath(fi->dirPath( true ),fi->readLink());
474 for( int i = 0; i<=4; i++) 484 for( int i = 0; i<=4; i++)
475 { // 5 tries to prevent dos 485 { // 5 tries to prevent dos
476 QFileInfo info( file ); 486 QFileInfo info( file );
477 if( !info.exists() ) 487 if( !info.exists() )
478 { 488 {
479 addSymlink( fi, TRUE ); 489 addSymlink( fi, TRUE );
480 break; 490 break;
481 } 491 }
482 else if( info.isDir() ) 492 else if( info.isDir() )
483 { 493 {
484 addDir( fi, TRUE ); 494 addDir( fi, TRUE );
485 break; 495 break;
486 } 496 }
487 else if( info.isFile() ) 497 else if( info.isFile() )
488 { 498 {
489 addFile( fi, TRUE ); 499 addFile( fi, TRUE );
490 break; 500 break;
491 } 501 }
492 else if( info.isSymLink() ) 502 else if( info.isSymLink() )
493 { 503 {
494 file = info.dirPath(true ) + "/" + info.readLink() ; 504 file = createNewPath(info.dirPath(true ),info.readLink());
495 break; 505 break;
496 } 506 }
497 else if( i == 4) 507 else if( i == 4)
498 { // couldn't resolve symlink add it as symlink 508 { // couldn't resolve symlink add it as symlink
499 addSymlink( fi ); 509 addSymlink( fi );
500 } 510 }
501 } // off for loop for symlink resolving 511 } // off for loop for symlink resolving
502 } 512 }
503 else if( fi->isDir() ) 513 else if( fi->isDir() )
504 addDir( fi ); 514 addDir( fi );
505 else if( fi->isFile() ) 515 else if( fi->isFile() )
506 addFile( fi ); 516 addFile( fi );
507 517
508 ++it; 518 ++it;
509 } // of while loop 519 } // of while loop
510 m_view->sort(); 520 m_view->sort();
511 521
512} 522}
513int OFileViewFileListView::fileCount()const 523int OFileViewFileListView::fileCount()const
514{ 524{
515 return m_view->childCount(); 525 return m_view->childCount();
516} 526}
517 527
518QString OFileViewFileListView::currentDir()const 528QString OFileViewFileListView::currentDir()const
519{ 529{
520 return m_currentDir; 530 return m_currentDir;
521} 531}
522 532
523OFileSelector* OFileViewFileListView::selector() 533OFileSelector* OFileViewFileListView::selector()
524{ 534{
525 return m_sel; 535 return m_sel;
526} 536}
527 537
528bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) 538bool OFileViewFileListView::eventFilter (QObject *, QEvent *e)
529{ 539{
530 if ( e->type() == QEvent::KeyPress ) 540 if ( e->type() == QEvent::KeyPress )
531 { 541 {
532 QKeyEvent *k = (QKeyEvent *)e; 542 QKeyEvent *k = (QKeyEvent *)e;
533 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 543 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
534 { 544 {
535 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 545 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
536 return true; 546 return true;
537 } 547 }
538 } 548 }
539 return false; 549 return false;
540} 550}
541 551
542void OFileViewFileListView::connectSlots() 552void OFileViewFileListView::connectSlots()
543{ 553{
544 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 554 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
545 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 555 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
546 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), 556 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
547 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); 557 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
548} 558}
549 559
550void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 560void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
551{ 561{
552 if (!item) 562 if (!item)
553 return; 563 return;
554#if 0 564#if 0
555 565
556 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 566 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
557 567
558 if (!sel->isDir() ) 568 if (!sel->isDir() )
559 { 569 {
560 selector()->m_lneEdit->setText( sel->text(1) ); 570 selector()->m_lneEdit->setText( sel->text(1) );
561 // if in fileselector mode we will emit selected 571 // if in fileselector mode we will emit selected
562 if ( selector()->mode() == OFileSelector::FileSelector ) 572 if ( selector()->mode() == OFileSelector::FileSelector )
563 { 573 {
564 odebug << "slot Current Changed" << oendl; 574 odebug << "slot Current Changed" << oendl;
565 QStringList str = QStringList::split("->", sel->text(1) ); 575 QStringList str = QStringList::split("->", sel->text(1) );
566 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 576 QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace());
567 emit selector()->fileSelected( path ); 577 emit selector()->fileSelected( path );
568 DocLnk lnk( path ); 578 DocLnk lnk( path );
569 emit selector()->fileSelected( lnk ); 579 emit selector()->fileSelected( lnk );
570 } 580 }
571 } 581 }
572#endif 582#endif
573} 583}
574 584
575void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) 585void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
576{ 586{
577 if (!item || ( button != Qt::LeftButton) ) 587 if (!item || ( button != Qt::LeftButton) )
578 return; 588 return;
579 589
580 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 590 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
581 if (!sel->isLocked() ) 591 if (!sel->isLocked() )
582 { 592 {
583 QStringList str = QStringList::split("->", sel->text(1) ); 593 QStringList str = QStringList::split("->", sel->text(1) );
584 if (sel->isDir() ) 594 if (sel->isDir() )
585 { 595 {
586 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 596 m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace());
587 emit selector()->dirSelected( m_currentDir ); 597 emit selector()->dirSelected( m_currentDir );
588 reread( m_all ); 598 reread( m_all );
589 } 599 }
590 else 600 else
591 { // file 601 { // file
592 odebug << "slot Clicked" << oendl; 602 odebug << "slot Clicked" << oendl;
593 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 603 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
594 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 604 QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace());
595 emit selector()->fileSelected( path ); 605 emit selector()->fileSelected( path );
596 DocLnk lnk( path ); 606 DocLnk lnk( path );
597 emit selector()->fileSelected( lnk ); 607 emit selector()->fileSelected( lnk );
598 } 608 }
599 } // not locked 609 } // not locked
600} 610}
601 611
602void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) 612void OFileViewFileListView::addFile( QFileInfo* info, bool symlink )
603{ 613{
604 MimeType type( info->absFilePath() ); 614 MimeType type( info->absFilePath() );
605 if (!compliesMime( type.id() ) ) 615 if (!compliesMime( type.id() ) )
606 return; 616 return;
607 617
608 QPixmap pix = type.pixmap(); 618 QPixmap pix = type.pixmap();
609 QString dir, name; bool locked; 619 QString dir, name; bool locked;
610 if ( pix.isNull() ) 620 if ( pix.isNull() )
611 { 621 {
612 QWMatrix matrix; 622 QWMatrix matrix;
613 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 623 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
614 matrix.scale( .4, .4 ); 624 matrix.scale( .4, .4 );
615 pix = pixer.xForm( matrix ); 625 pix = pixer.xForm( matrix );
616 } 626 }
617 dir = info->dirPath( true ); 627 dir = info->dirPath( true );
618 locked = false; 628 locked = false;
619 if ( symlink ) 629 if ( symlink )
620 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 630 name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink());
621 else 631 else
622 { 632 {
623 name = info->fileName(); 633 name = info->fileName();
624 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 634 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
625 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) 635 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) )
626 { 636 {
627 locked = true; pix = Resource::loadPixmap("locked"); 637 locked = true; pix = Resource::loadPixmap("locked");
628 } 638 }
629 } 639 }
630 (void)new OFileSelectorItem( m_view, pix, name, 640 (void)new OFileSelectorItem( m_view, pix, name,
631 info->lastModified().toString(), QString::number( info->size() ), 641 info->lastModified().toString(), QString::number( info->size() ),
632 dir, locked ); 642 dir, locked );
633} 643}
634 644
635void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) 645void OFileViewFileListView::addDir( QFileInfo* info, bool symlink )
636{ 646{
637 bool locked = false; QString name; QPixmap pix; 647 bool locked = false; QString name; QPixmap pix;
638 648
639 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 649 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
640 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) 650 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) )
641 { 651 {
642 locked = true; 652 locked = true;
643 if ( symlink ) 653 if ( symlink )
644 pix = Resource::loadPixmap( "opie/symlink" ); 654 pix = Resource::loadPixmap( "opie/symlink" );
645 else 655 else
646 pix = Resource::loadPixmap( "lockedfolder" ); 656 pix = Resource::loadPixmap( "lockedfolder" );
647 } 657 }
648 else 658 else
649 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); 659 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder");
650 660
651 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : 661 name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) :
652 info->fileName(); 662 info->fileName();
653 663
654 (void)new OFileSelectorItem( m_view, pix, name, 664 (void)new OFileSelectorItem( m_view, pix, name,
655 info->lastModified().toString(), 665 info->lastModified().toString(),
656 QString::number( info->size() ), 666 QString::number( info->size() ),
657 info->dirPath( true ), locked, true ); 667 info->dirPath( true ), locked, true );
658 668
659 669
660} 670}
661 671
662void OFileViewFileListView::addSymlink( QFileInfo* , bool ) 672void OFileViewFileListView::addSymlink( QFileInfo* , bool )
663{ 673{
664} 674}
665 675
666void OFileViewFileListView::cdUP() 676void OFileViewFileListView::cdUP()
667{ 677{
668 QDir dir( m_currentDir ); 678 QDir dir( m_currentDir );
669 dir.cdUp(); 679 dir.cdUp();
670 680
671 if (!dir.exists() ) 681 if (!dir.exists() )
672 m_currentDir = "/"; 682 m_currentDir = "/";
673 else 683 else
674 m_currentDir = dir.absPath(); 684 m_currentDir = dir.absPath();
675 685
676 emit selector()->dirSelected( m_currentDir ); 686 emit selector()->dirSelected( m_currentDir );
677 reread( m_all ); 687 reread( m_all );
678} 688}
679 689
680void OFileViewFileListView::cdHome() 690void OFileViewFileListView::cdHome()
681{ 691{
682 m_currentDir = QDir::homeDirPath(); 692 m_currentDir = QDir::homeDirPath();
683 emit selector()->dirSelected( m_currentDir ); 693 emit selector()->dirSelected( m_currentDir );
684 reread( m_all ); 694 reread( m_all );
685} 695}
686 696
687void OFileViewFileListView::cdDoc() 697void OFileViewFileListView::cdDoc()
688{ 698{
689 m_currentDir = QPEApplication::documentDir(); 699 m_currentDir = QPEApplication::documentDir();
690 emit selector()->dirSelected( m_currentDir ); 700 emit selector()->dirSelected( m_currentDir );
691 reread( m_all ); 701 reread( m_all );
692} 702}
693 703
694void OFileViewFileListView::changeDir( const QString& dir ) 704void OFileViewFileListView::changeDir( const QString& dir )
695{ 705{
696 m_currentDir = dir; 706 m_currentDir = dir;
697 emit selector()->dirSelected( m_currentDir ); 707 emit selector()->dirSelected( m_currentDir );
698 reread( m_all ); 708 reread( m_all );
699} 709}
@@ -735,97 +745,97 @@ bool OFileViewFileListView::compliesMime( const QString& str)
735 if ( str.find( reg ) != -1 ) 745 if ( str.find( reg ) != -1 )
736 return true; 746 return true;
737 747
738 } 748 }
739 return false; 749 return false;
740} 750}
741/* 751/*
742 * The listView giving access to the file system! 752 * The listView giving access to the file system!
743 */ 753 */
744 754
745class OFileViewFileSystem : public OFileViewInterface 755class OFileViewFileSystem : public OFileViewInterface
746{ 756{
747public: 757public:
748 OFileViewFileSystem( OFileSelector* ); 758 OFileViewFileSystem( OFileSelector* );
749 ~OFileViewFileSystem(); 759 ~OFileViewFileSystem();
750 760
751 QString selectedName() const; 761 QString selectedName() const;
752 QString selectedPath() const; 762 QString selectedPath() const;
753 763
754 QString directory()const; 764 QString directory()const;
755 void reread(); 765 void reread();
756 int fileCount()const; 766 int fileCount()const;
757 767
758 QWidget* widget( QWidget* parent ); 768 QWidget* widget( QWidget* parent );
759 void activate( const QString& ); 769 void activate( const QString& );
760private: 770private:
761 OFileViewFileListView* m_view; 771 OFileViewFileListView* m_view;
762 bool m_all : 1; 772 bool m_all : 1;
763}; 773};
764 774
765OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) 775OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel)
766 : OFileViewInterface( sel ) 776 : OFileViewInterface( sel )
767{ 777{
768 m_view = 0; 778 m_view = 0;
769 m_all = false; 779 m_all = false;
770} 780}
771 781
772OFileViewFileSystem::~OFileViewFileSystem() 782OFileViewFileSystem::~OFileViewFileSystem()
773{ 783{
774} 784}
775 785
776QString OFileViewFileSystem::selectedName()const 786QString OFileViewFileSystem::selectedName()const
777{ 787{
778 if (!m_view ) 788 if (!m_view )
779 return QString::null; 789 return QString::null;
780 790
781 QString cFN=currentFileName(); 791 QString cFN=currentFileName();
782 if (cFN.startsWith("/")) return cFN; 792 if (cFN.startsWith("/")) return cFN;
783 return m_view->currentDir() + "/" + cFN; 793 return createNewPath(m_view->currentDir(),cFN);
784} 794}
785 795
786QString OFileViewFileSystem::selectedPath()const 796QString OFileViewFileSystem::selectedPath()const
787{ 797{
788 return QString::null; 798 return QString::null;
789} 799}
790 800
791QString OFileViewFileSystem::directory()const 801QString OFileViewFileSystem::directory()const
792{ 802{
793 if (!m_view) 803 if (!m_view)
794 return QString::null; 804 return QString::null;
795 805
796 OFileSelectorItem* item = m_view->currentItem(); 806 OFileSelectorItem* item = m_view->currentItem();
797 if (!item ) 807 if (!item )
798 return QString::null; 808 return QString::null;
799 809
800 return QDir(item->directory() ).absPath(); 810 return QDir(item->directory() ).absPath();
801} 811}
802 812
803void OFileViewFileSystem::reread() 813void OFileViewFileSystem::reread()
804{ 814{
805 if (!m_view) 815 if (!m_view)
806 return; 816 return;
807 817
808 m_view->reread( m_all ); 818 m_view->reread( m_all );
809} 819}
810 820
811int OFileViewFileSystem::fileCount()const 821int OFileViewFileSystem::fileCount()const
812{ 822{
813 if (!m_view ) 823 if (!m_view )
814 return -1; 824 return -1;
815 return m_view->fileCount(); 825 return m_view->fileCount();
816} 826}
817 827
818QWidget* OFileViewFileSystem::widget( QWidget* parent ) 828QWidget* OFileViewFileSystem::widget( QWidget* parent )
819{ 829{
820 if (!m_view ) 830 if (!m_view )
821 { 831 {
822 m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); 832 m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
823 } 833 }
824 return m_view; 834 return m_view;
825} 835}
826 836
827void OFileViewFileSystem::activate( const QString& str ) 837void OFileViewFileSystem::activate( const QString& str )
828{ 838{
829 m_all = allItem( str ); 839 m_all = allItem( str );
830} 840}
831 841