-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 3 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index bb420e6..2275388 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -1,137 +1,138 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 | 3 | ** Created: Fri Dec 14 08:16:46 2001 |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "fileBrowser.h" | 14 | #include "fileBrowser.h" |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | 16 | ||
17 | #include <qlistview.h> | 17 | #include <qlistview.h> |
18 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
19 | #include <qfile.h> | 19 | #include <qfile.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | 22 | ||
23 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) | 23 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) |
24 | : QDialog( parent, name, modal, fl ) | 24 | : QDialog( parent, name, modal, fl ) |
25 | { | 25 | { |
26 | if ( !name ) | 26 | if ( !name ) |
27 | setName( "fileBrowser" ); | 27 | setName( "fileBrowser" ); |
28 | resize( 236, 280 ); | 28 | resize( 236, 280 ); |
29 | setCaption(tr( "Browse for file" ) ); | 29 | setCaption(tr( "Browse for file" ) ); |
30 | filterStr=filter; | 30 | filterStr=filter; |
31 | dirLabel = new QLabel(this, "DirLabel"); | 31 | dirLabel = new QLabel(this, "DirLabel"); |
32 | dirLabel->setText(currentDir.canonicalPath()); | 32 | dirLabel->setText(currentDir.canonicalPath()); |
33 | dirLabel->setGeometry(10,4,230,30); | 33 | dirLabel->setGeometry(10,4,230,30); |
34 | ListView = new QListView( this, "ListView" ); | 34 | ListView = new QListView( this, "ListView" ); |
35 | ListView->addColumn( tr( "Name" ) ); | 35 | ListView->addColumn( tr( "Name" ) ); |
36 | ListView->setColumnWidth(0,140); | 36 | ListView->setColumnWidth(0,140); |
37 | ListView->setSorting( 2, FALSE); | 37 | ListView->setSorting( 2, FALSE); |
38 | ListView->addColumn( tr( "Size" ) ); | 38 | ListView->addColumn( tr( "Size" ) ); |
39 | ListView->setColumnWidth(1,59); | 39 | ListView->setColumnWidth(1,59); |
40 | // ListView->addColumn( tr( "" ) ); | 40 | // ListView->addColumn( tr( "" ) ); |
41 | // ListView->setColumnWidth(1,59); | 41 | ListView->setColumnWidthMode(0,QListView::Manual); |
42 | ListView->setColumnAlignment(1,QListView::AlignRight); | ||
42 | // ListView->setMultiSelection(true); | 43 | // ListView->setMultiSelection(true); |
43 | // ListView->setSelectionMode(QListView::Extended); | 44 | // ListView->setSelectionMode(QListView::Extended); |
44 | 45 | ||
45 | ListView->setAllColumnsShowFocus( TRUE ); | 46 | ListView->setAllColumnsShowFocus( TRUE ); |
46 | ListView->setGeometry( QRect( 10, 35, 220, 240 ) ); | 47 | ListView->setGeometry( QRect( 10, 35, 220, 240 ) ); |
47 | 48 | ||
48 | // signals and slots connections | 49 | // signals and slots connections |
49 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 50 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
50 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 51 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
51 | currentDir.setPath(QDir::currentDirPath()); | 52 | currentDir.setPath(QDir::currentDirPath()); |
52 | populateList(); | 53 | populateList(); |
53 | } | 54 | } |
54 | 55 | ||
55 | fileBrowser::~fileBrowser() | 56 | fileBrowser::~fileBrowser() |
56 | { | 57 | { |
57 | } | 58 | } |
58 | 59 | ||
59 | 60 | ||
60 | void fileBrowser::populateList() | 61 | void fileBrowser::populateList() |
61 | { | 62 | { |
62 | ListView->clear(); | 63 | ListView->clear(); |
63 | //qDebug(currentDir.canonicalPath()); | 64 | //qDebug(currentDir.canonicalPath()); |
64 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); | 65 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); |
65 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 66 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
66 | currentDir.setMatchAllDirs(TRUE); | 67 | currentDir.setMatchAllDirs(TRUE); |
67 | 68 | ||
68 | currentDir.setNameFilter(filterStr); | 69 | currentDir.setNameFilter(filterStr); |
69 | // currentDir.setNameFilter("*.txt;*.etx"); | 70 | // currentDir.setNameFilter("*.txt;*.etx"); |
70 | QString fileL, fileS; | 71 | QString fileL, fileS; |
71 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); | 72 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); |
72 | QFileInfoListIterator it(*list); | 73 | QFileInfoListIterator it(*list); |
73 | QFileInfo *fi; | 74 | QFileInfo *fi; |
74 | while ( (fi=it.current()) ) { | 75 | while ( (fi=it.current()) ) { |
75 | 76 | ||
76 | if (fi->isSymLink() ){ | 77 | if (fi->isSymLink() ){ |
77 | QString symLink=fi->readLink(); | 78 | QString symLink=fi->readLink(); |
78 | // qDebug("Symlink detected "+symLink); | 79 | // qDebug("Symlink detected "+symLink); |
79 | QFileInfo sym( symLink); | 80 | QFileInfo sym( symLink); |
80 | fileS.sprintf( "%10li", sym.size() ); | 81 | fileS.sprintf( "%10li", sym.size() ); |
81 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 82 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
82 | 83 | ||
83 | } else { | 84 | } else { |
84 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 85 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
85 | fileS.sprintf( "%10li", fi->size() ); | 86 | fileS.sprintf( "%10li", fi->size() ); |
86 | fileL.sprintf( "%s",fi->fileName().data() ); | 87 | fileL.sprintf( "%s",fi->fileName().data() ); |
87 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 88 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
88 | fileL+="/"; | 89 | fileL+="/"; |
89 | // qDebug(currentDir.canonicalPath()+fileL); | 90 | // qDebug(currentDir.canonicalPath()+fileL); |
90 | } | 91 | } |
91 | } | 92 | } |
92 | item= new QListViewItem( ListView,fileL,fileS ); | 93 | item= new QListViewItem( ListView,fileL,fileS ); |
93 | ++it; | 94 | ++it; |
94 | } | 95 | } |
95 | ListView->setSorting( 2, FALSE); | 96 | ListView->setSorting( 2, FALSE); |
96 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 97 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); |
97 | } | 98 | } |
98 | 99 | ||
99 | void fileBrowser::upDir() | 100 | void fileBrowser::upDir() |
100 | { | 101 | { |
101 | // qDebug(currentDir.canonicalPath()); | 102 | // qDebug(currentDir.canonicalPath()); |
102 | } | 103 | } |
103 | 104 | ||
104 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) | 105 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) |
105 | { | 106 | { |
106 | } | 107 | } |
107 | 108 | ||
108 | // you may want to switch these 2 functions. I like single clicks | 109 | // you may want to switch these 2 functions. I like single clicks |
109 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 110 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
110 | { | 111 | { |
111 | QString strItem=selectedItem->text(0); | 112 | QString strItem=selectedItem->text(0); |
112 | QString strSize=selectedItem->text(1); | 113 | QString strSize=selectedItem->text(1); |
113 | // qDebug("strItem is "+strItem); | 114 | // qDebug("strItem is "+strItem); |
114 | strSize.stripWhiteSpace(); | 115 | strSize.stripWhiteSpace(); |
115 | // qDebug(strSize); | 116 | // qDebug(strSize); |
116 | 117 | ||
117 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 118 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
118 | // is symlink | 119 | // is symlink |
119 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 120 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
120 | // qDebug("strItem symlink is "+strItem2); | 121 | // qDebug("strItem symlink is "+strItem2); |
121 | if(QDir(strItem2).exists() ) { | 122 | if(QDir(strItem2).exists() ) { |
122 | currentDir.cd(strItem2, TRUE); | 123 | currentDir.cd(strItem2, TRUE); |
123 | populateList(); | 124 | populateList(); |
124 | } | 125 | } |
125 | } else { // not a symlink | 126 | } else { // not a symlink |
126 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 127 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
127 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 128 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
128 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 129 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
129 | currentDir.cd(strItem,FALSE); | 130 | currentDir.cd(strItem,FALSE); |
130 | // qDebug("Path is "+strItem); | 131 | // qDebug("Path is "+strItem); |
131 | populateList(); | 132 | populateList(); |
132 | } else { | 133 | } else { |
133 | currentDir.cdUp(); | 134 | currentDir.cdUp(); |
134 | populateList(); | 135 | populateList(); |
135 | } | 136 | } |
136 | if(QDir(strItem).exists()){ | 137 | if(QDir(strItem).exists()){ |
137 | currentDir.cd(strItem, TRUE); | 138 | currentDir.cd(strItem, TRUE); |
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index af51fc3..b813ed3 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -1,182 +1,184 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp | 3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "fileSaver.h" | 14 | #include "fileSaver.h" |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | 17 | ||
18 | #include <qlistview.h> | 18 | #include <qlistview.h> |
19 | #include <qpushbutton.h> | 19 | #include <qpushbutton.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <qlineedit.h> | 23 | #include <qlineedit.h> |
24 | 24 | ||
25 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) | 25 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) |
26 | : QDialog( parent, name, modal, fl ) | 26 | : QDialog( parent, name, modal, fl ) |
27 | { | 27 | { |
28 | if ( !name ) | 28 | if ( !name ) |
29 | setName( "fileSaver" ); | 29 | setName( "fileSaver" ); |
30 | resize( 236, 280 ); | 30 | resize( 236, 280 ); |
31 | setCaption(tr( "Save file" ) ); | 31 | setCaption(tr( "Save file" ) ); |
32 | QFileInfo fi(currentFileName); | 32 | QFileInfo fi(currentFileName); |
33 | QString tmpFileName=fi.fileName(); | 33 | QString tmpFileName=fi.fileName(); |
34 | // qDebug( tmpFileName); | 34 | // qDebug( tmpFileName); |
35 | 35 | ||
36 | dirLabel = new QLabel(this, "DirLabel"); | 36 | dirLabel = new QLabel(this, "DirLabel"); |
37 | dirLabel->setText(currentDir.canonicalPath()); | 37 | dirLabel->setText(currentDir.canonicalPath()); |
38 | dirLabel->setGeometry(10,4,230,30); | 38 | dirLabel->setGeometry(10,4,230,30); |
39 | 39 | ||
40 | ListView = new QListView( this, "ListView" ); | 40 | ListView = new QListView( this, "ListView" ); |
41 | ListView->addColumn( tr( "Name" ) ); | 41 | ListView->addColumn( tr( "Name" ) ); |
42 | ListView->setColumnWidth(0,140); | 42 | ListView->setColumnWidth(0,140); |
43 | ListView->setSorting( 2, FALSE); | 43 | ListView->setSorting( 2, FALSE); |
44 | ListView->addColumn( tr( "Size" ) ); | 44 | ListView->addColumn( tr( "Size" ) ); |
45 | ListView->setColumnWidth(1,59); | 45 | ListView->setColumnWidth(1,59); |
46 | ListView->setColumnWidthMode(0,QListView::Manual); | ||
47 | ListView->setColumnAlignment(1,QListView::AlignRight); | ||
46 | // ListView->setMultiSelection(true); | 48 | // ListView->setMultiSelection(true); |
47 | // ListView->setSelectionMode(QListView::Extended); | 49 | // ListView->setSelectionMode(QListView::Extended); |
48 | 50 | ||
49 | ListView->setAllColumnsShowFocus( TRUE ); | 51 | ListView->setAllColumnsShowFocus( TRUE ); |
50 | ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); | 52 | ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); |
51 | 53 | ||
52 | fileEdit= new QLineEdit(this); | 54 | fileEdit= new QLineEdit(this); |
53 | fileEdit->setGeometry( QRect( 10, 200, 200, 22)); | 55 | fileEdit->setGeometry( QRect( 10, 200, 200, 22)); |
54 | 56 | ||
55 | fileEdit->setText( tmpFileName); | 57 | fileEdit->setText( tmpFileName); |
56 | 58 | ||
57 | // signals and slots connections | 59 | // signals and slots connections |
58 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 60 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
59 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 61 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
60 | 62 | ||
61 | // tmpFileName=fi.FilePath(); | 63 | // tmpFileName=fi.FilePath(); |
62 | // qDebug( tmpFileName); | 64 | // qDebug( tmpFileName); |
63 | currentDir.setPath( QDir::currentDirPath() ); | 65 | currentDir.setPath( QDir::currentDirPath() ); |
64 | populateList(); | 66 | populateList(); |
65 | } | 67 | } |
66 | 68 | ||
67 | fileSaver::~fileSaver() | 69 | fileSaver::~fileSaver() |
68 | { | 70 | { |
69 | } | 71 | } |
70 | 72 | ||
71 | 73 | ||
72 | void fileSaver::populateList() | 74 | void fileSaver::populateList() |
73 | { | 75 | { |
74 | ListView->clear(); | 76 | ListView->clear(); |
75 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); | 77 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); |
76 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 78 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
77 | currentDir.setMatchAllDirs(TRUE); | 79 | currentDir.setMatchAllDirs(TRUE); |
78 | 80 | ||
79 | currentDir.setNameFilter("*"); | 81 | currentDir.setNameFilter("*"); |
80 | QString fileL, fileS; | 82 | QString fileL, fileS; |
81 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); | 83 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); |
82 | QFileInfoListIterator it(*list); | 84 | QFileInfoListIterator it(*list); |
83 | QFileInfo *fi; | 85 | QFileInfo *fi; |
84 | while ( (fi=it.current()) ) { | 86 | while ( (fi=it.current()) ) { |
85 | 87 | ||
86 | if (fi->isSymLink() ){ | 88 | if (fi->isSymLink() ){ |
87 | QString symLink=fi->readLink(); | 89 | QString symLink=fi->readLink(); |
88 | // qDebug("Symlink detected "+symLink); | 90 | // qDebug("Symlink detected "+symLink); |
89 | QFileInfo sym( symLink); | 91 | QFileInfo sym( symLink); |
90 | fileS.sprintf( "%10li", sym.size() ); | 92 | fileS.sprintf( "%10li", sym.size() ); |
91 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 93 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
92 | 94 | ||
93 | } else { | 95 | } else { |
94 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 96 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
95 | fileS.sprintf( "%10li", fi->size() ); | 97 | fileS.sprintf( "%10li", fi->size() ); |
96 | fileL.sprintf( "%s",fi->fileName().data() ); | 98 | fileL.sprintf( "%s",fi->fileName().data() ); |
97 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 99 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
98 | fileL+="/"; | 100 | fileL+="/"; |
99 | // qDebug(currentDir.canonicalPath()+fileL); | 101 | // qDebug(currentDir.canonicalPath()+fileL); |
100 | } | 102 | } |
101 | } | 103 | } |
102 | item= new QListViewItem( ListView,fileL,fileS ); | 104 | item= new QListViewItem( ListView,fileL,fileS ); |
103 | ++it; | 105 | ++it; |
104 | } | 106 | } |
105 | ListView->setSorting( 2, FALSE); | 107 | ListView->setSorting( 2, FALSE); |
106 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 108 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); |
107 | 109 | ||
108 | 110 | ||
109 | } | 111 | } |
110 | 112 | ||
111 | void fileSaver::upDir() | 113 | void fileSaver::upDir() |
112 | { | 114 | { |
113 | // qDebug(currentDir.canonicalPath()); | 115 | // qDebug(currentDir.canonicalPath()); |
114 | } | 116 | } |
115 | 117 | ||
116 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) | 118 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) |
117 | { | 119 | { |
118 | } | 120 | } |
119 | 121 | ||
120 | void fileSaver::listClicked(QListViewItem *selectedItem) | 122 | void fileSaver::listClicked(QListViewItem *selectedItem) |
121 | { | 123 | { |
122 | QString strItem=selectedItem->text(0); | 124 | QString strItem=selectedItem->text(0); |
123 | QString strSize=selectedItem->text(1); | 125 | QString strSize=selectedItem->text(1); |
124 | // qDebug("strItem is "+strItem); | 126 | // qDebug("strItem is "+strItem); |
125 | strSize.stripWhiteSpace(); | 127 | strSize.stripWhiteSpace(); |
126 | // qDebug(strSize); | 128 | // qDebug(strSize); |
127 | 129 | ||
128 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 130 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
129 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 131 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
130 | // qDebug("strItem symlink is "+strItem2); | 132 | // qDebug("strItem symlink is "+strItem2); |
131 | if(QDir(strItem2).exists() ) { | 133 | if(QDir(strItem2).exists() ) { |
132 | currentDir.cd(strItem2, TRUE); | 134 | currentDir.cd(strItem2, TRUE); |
133 | populateList(); | 135 | populateList(); |
134 | } | 136 | } |
135 | } else { // not a symlink | 137 | } else { // not a symlink |
136 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 138 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
137 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 139 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
138 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 140 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
139 | currentDir.cd(strItem,FALSE); | 141 | currentDir.cd(strItem,FALSE); |
140 | // qDebug("Path is "+strItem); | 142 | // qDebug("Path is "+strItem); |
141 | populateList(); | 143 | populateList(); |
142 | } else { | 144 | } else { |
143 | currentDir.cdUp(); | 145 | currentDir.cdUp(); |
144 | populateList(); | 146 | populateList(); |
145 | } | 147 | } |
146 | if(QDir(strItem).exists()){ | 148 | if(QDir(strItem).exists()){ |
147 | currentDir.cd(strItem, TRUE); | 149 | currentDir.cd(strItem, TRUE); |
148 | populateList(); | 150 | populateList(); |
149 | } | 151 | } |
150 | } // else | 152 | } // else |
151 | // if( QFile::exists(strItem ) ) { | 153 | // if( QFile::exists(strItem ) ) { |
152 | // qDebug("We found our files!!"); | 154 | // qDebug("We found our files!!"); |
153 | 155 | ||
154 | // OnOK(); | 156 | // OnOK(); |
155 | } //end not symlink | 157 | } //end not symlink |
156 | chdir(strItem.latin1()); | 158 | chdir(strItem.latin1()); |
157 | 159 | ||
158 | 160 | ||
159 | } | 161 | } |
160 | 162 | ||
161 | 163 | ||
162 | void fileSaver::closeEvent( QCloseEvent *e ) | 164 | void fileSaver::closeEvent( QCloseEvent *e ) |
163 | { | 165 | { |
164 | if(e->isAccepted()) { | 166 | if(e->isAccepted()) { |
165 | e->accept(); | 167 | e->accept(); |
166 | } else { | 168 | } else { |
167 | qDebug("not accepted"); | 169 | qDebug("not accepted"); |
168 | done(-1); | 170 | done(-1); |
169 | } | 171 | } |
170 | } | 172 | } |
171 | 173 | ||
172 | void fileSaver::accept() { | 174 | void fileSaver::accept() { |
173 | selectedFileName = fileEdit->text(); | 175 | selectedFileName = fileEdit->text(); |
174 | QString path = currentDir.canonicalPath()+"/" + selectedFileName; | 176 | QString path = currentDir.canonicalPath()+"/" + selectedFileName; |
175 | if( path.find("//",0,TRUE) ==-1 ) { | 177 | if( path.find("//",0,TRUE) ==-1 ) { |
176 | selectedFileName = path; | 178 | selectedFileName = path; |
177 | } else { | 179 | } else { |
178 | selectedFileName = currentDir.canonicalPath()+selectedFileName; | 180 | selectedFileName = currentDir.canonicalPath()+selectedFileName; |
179 | } | 181 | } |
180 | qDebug("going to save "+selectedFileName); | 182 | qDebug("going to save "+selectedFileName); |
181 | done(1); | 183 | done(1); |
182 | } | 184 | } |