author | zecke <zecke> | 2005-02-07 22:41:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-07 22:41:59 (UTC) |
commit | f112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24 (patch) (unidiff) | |
tree | 95f03410ad60ed5d04486821e9bc76cf1e3664ec /libopie2 | |
parent | 2e4fd59ce900490ccbbb6c0f7b2fcd4811ac8a07 (diff) | |
download | opie-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 "/"
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 26 |
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 | |||
@@ -62,6 +62,16 @@ using namespace Opie::Ui::Internal; | |||
62 | namespace Opie { | 62 | namespace Opie { |
63 | namespace Ui { | 63 | namespace Ui { |
64 | namespace Internal { | 64 | namespace 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 | */ | ||
69 | static inline QString createNewPath(const QString& base, const QString &ending) { | ||
70 | return base == QString::fromLatin1("/") ? | ||
71 | base + ending : base + "/" + ending; | ||
72 | } | ||
73 | |||
74 | |||
65 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) | 75 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) |
66 | : m_selector( _selector ) | 76 | : m_selector( _selector ) |
67 | { | 77 | { |
@@ -470,7 +480,7 @@ void OFileViewFileListView::reread( bool all ) | |||
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 ); |
@@ -491,7 +501,7 @@ void OFileViewFileListView::reread( bool all ) | |||
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) |
@@ -563,7 +573,7 @@ void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) | |||
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 ); |
@@ -583,7 +593,7 @@ void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const | |||
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 | } |
@@ -591,7 +601,7 @@ void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const | |||
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 ); |
@@ -617,7 +627,7 @@ void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) | |||
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(); |
@@ -648,7 +658,7 @@ void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) | |||
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, |
@@ -780,7 +790,7 @@ QString OFileViewFileSystem::selectedName()const | |||
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 | ||
786 | QString OFileViewFileSystem::selectedPath()const | 796 | QString OFileViewFileSystem::selectedPath()const |