-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 1 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 10 |
4 files changed, 15 insertions, 7 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 7fba0af..d7bad51 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,794 +1,793 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #define DEVELOPERS_VERSION | 12 | #define DEVELOPERS_VERSION |
13 | |||
14 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
15 | 14 | ||
16 | // #include <opie/ofileselector.h> | 15 | // #include <opie/ofileselector.h> |
17 | // #include <opie/ofiledialog.h> | 16 | // #include <opie/ofiledialog.h> |
18 | 17 | ||
19 | #include <qpe/filemanager.h> | 18 | #include <qpe/filemanager.h> |
20 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
21 | #include <qpe/qpemenubar.h> | 20 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 21 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
26 | #include <qpe/mimetype.h> | 25 | #include <qpe/mimetype.h> |
27 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
28 | #include <qpe/ir.h> | 27 | #include <qpe/ir.h> |
29 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
30 | 29 | ||
31 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
32 | #include <qtextstream.h> | 31 | #include <qtextstream.h> |
33 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
34 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
35 | #include <qdir.h> | 34 | #include <qdir.h> |
36 | #include <qfile.h> | 35 | #include <qfile.h> |
37 | #include <qstring.h> | 36 | #include <qstring.h> |
38 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
39 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
40 | #include <qlistview.h> | 39 | #include <qlistview.h> |
41 | #include <qmainwindow.h> | 40 | #include <qmainwindow.h> |
42 | #include <qlabel.h> | 41 | #include <qlabel.h> |
43 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
44 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
45 | #include <qwidget.h> | 44 | #include <qwidget.h> |
46 | #include <qlayout.h> | 45 | #include <qlayout.h> |
47 | #include <qimage.h> | 46 | #include <qimage.h> |
48 | #include <qpixmap.h> | 47 | #include <qpixmap.h> |
49 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
50 | #include <qlineedit.h> | 49 | #include <qlineedit.h> |
51 | #include <qregexp.h> | 50 | #include <qregexp.h> |
52 | 51 | ||
53 | #include <unistd.h> | 52 | #include <unistd.h> |
54 | #include <stdlib.h> | 53 | #include <stdlib.h> |
55 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
56 | #include <dirent.h> | 55 | #include <dirent.h> |
57 | #include <stdio.h> | 56 | #include <stdio.h> |
58 | #include <time.h> | 57 | #include <time.h> |
59 | #include <fcntl.h> | 58 | #include <fcntl.h> |
60 | #include <mntent.h> | 59 | #include <mntent.h> |
61 | #include <string.h> | 60 | #include <string.h> |
62 | #include <errno.h> | 61 | #include <errno.h> |
63 | #include <sys/vfs.h> | 62 | #include <sys/vfs.h> |
64 | #include <mntent.h> | 63 | #include <mntent.h> |
65 | #include <sys/utsname.h> | 64 | #include <sys/utsname.h> |
66 | 65 | ||
67 | AdvancedFm::AdvancedFm( ) | 66 | AdvancedFm::AdvancedFm( ) |
68 | : QMainWindow( ) { | 67 | : QMainWindow( ) { |
69 | init(); | 68 | init(); |
70 | initConnections(); | 69 | initConnections(); |
71 | populateLocalView(); | 70 | populateLocalView(); |
72 | populateRemoteView(); | 71 | populateRemoteView(); |
73 | currentPathCombo->setFocus(); | 72 | currentPathCombo->setFocus(); |
74 | } | 73 | } |
75 | 74 | ||
76 | AdvancedFm::~AdvancedFm() { | 75 | AdvancedFm::~AdvancedFm() { |
77 | } | 76 | } |
78 | 77 | ||
79 | void AdvancedFm::cleanUp() { | 78 | void AdvancedFm::cleanUp() { |
80 | QString sfile=QDir::homeDirPath(); | 79 | QString sfile=QDir::homeDirPath(); |
81 | if(sfile.right(1) != "/") | 80 | if(sfile.right(1) != "/") |
82 | sfile+="/._temp"; | 81 | sfile+="/._temp"; |
83 | else | 82 | else |
84 | sfile+="._temp"; | 83 | sfile+="._temp"; |
85 | QFile file( sfile); | 84 | QFile file( sfile); |
86 | if(file.exists()) | 85 | if(file.exists()) |
87 | file.remove(); | 86 | file.remove(); |
88 | } | 87 | } |
89 | 88 | ||
90 | void AdvancedFm::tabChanged(QWidget *) { | 89 | void AdvancedFm::tabChanged(QWidget *) { |
91 | if (TabWidget->currentPageIndex() == 0) { | 90 | if (TabWidget->currentPageIndex() == 0) { |
92 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 91 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
93 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 92 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
94 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 93 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
95 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 94 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
96 | setCaption("AdvancedFm :: "+fs+" :: " | 95 | setCaption("AdvancedFm :: "+fs+" :: " |
97 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 96 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
98 | 97 | ||
99 | } | 98 | } |
100 | if (TabWidget->currentPageIndex() == 1) { | 99 | if (TabWidget->currentPageIndex() == 1) { |
101 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 100 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
102 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 101 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
103 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 102 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
104 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 103 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
105 | setCaption("AdvancedFm :: "+fs+" :: " | 104 | setCaption("AdvancedFm :: "+fs+" :: " |
106 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 105 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
107 | } | 106 | } |
108 | } | 107 | } |
109 | 108 | ||
110 | 109 | ||
111 | void AdvancedFm::populateLocalView() { | 110 | void AdvancedFm::populateLocalView() { |
112 | QPixmap pm; | 111 | QPixmap pm; |
113 | Local_View->clear(); | 112 | Local_View->clear(); |
114 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 113 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
115 | currentDir.setMatchAllDirs(TRUE); | 114 | currentDir.setMatchAllDirs(TRUE); |
116 | currentDir.setNameFilter(filterStr); | 115 | currentDir.setNameFilter(filterStr); |
117 | QString fileL, fileS, fileDate; | 116 | QString fileL, fileS, fileDate; |
118 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 117 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
119 | setCaption("AdvancedFm :: "+fs+" :: " | 118 | setCaption("AdvancedFm :: "+fs+" :: " |
120 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 119 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
121 | bool isDir=FALSE; | 120 | bool isDir=FALSE; |
122 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 121 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
123 | QFileInfoListIterator it(*list); | 122 | QFileInfoListIterator it(*list); |
124 | QFileInfo *fi; | 123 | QFileInfo *fi; |
125 | while ( (fi=it.current()) ) { | 124 | while ( (fi=it.current()) ) { |
126 | if (fi->isSymLink() ) { | 125 | if (fi->isSymLink() ) { |
127 | QString symLink=fi->readLink(); | 126 | QString symLink=fi->readLink(); |
128 | QFileInfo sym( symLink); | 127 | QFileInfo sym( symLink); |
129 | fileS.sprintf( "%10i", sym.size() ); | 128 | fileS.sprintf( "%10i", sym.size() ); |
130 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 129 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
131 | fileDate = sym.lastModified().toString(); | 130 | fileDate = sym.lastModified().toString(); |
132 | } else { | 131 | } else { |
133 | fileS.sprintf( "%10i", fi->size() ); | 132 | fileS.sprintf( "%10i", fi->size() ); |
134 | fileL.sprintf( "%s",fi->fileName().data() ); | 133 | fileL.sprintf( "%s",fi->fileName().data() ); |
135 | fileDate= fi->lastModified().toString(); | 134 | fileDate= fi->lastModified().toString(); |
136 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 135 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
137 | fileL+="/"; | 136 | fileL+="/"; |
138 | isDir=TRUE; | 137 | isDir=TRUE; |
139 | } | 138 | } |
140 | } | 139 | } |
141 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 140 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
142 | if(fileL !="./" && fi->exists()) { | 141 | if(fileL !="./" && fi->exists()) { |
143 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 142 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
144 | 143 | ||
145 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 144 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
146 | 145 | ||
147 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 146 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
148 | pm = Resource::loadPixmap( "lockedfolder" ); | 147 | pm = Resource::loadPixmap( "lockedfolder" ); |
149 | else | 148 | else |
150 | pm= Resource::loadPixmap( "folder" ); | 149 | pm= Resource::loadPixmap( "folder" ); |
151 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 150 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
152 | pm = Resource::loadPixmap( "exec"); | 151 | pm = Resource::loadPixmap( "exec"); |
153 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 152 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
154 | | fileInfo.permission( QFileInfo::ExeGroup) | 153 | | fileInfo.permission( QFileInfo::ExeGroup) |
155 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 154 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
156 | pm = Resource::loadPixmap( "exec"); | 155 | pm = Resource::loadPixmap( "exec"); |
157 | } else if( !fi->isReadable() ) { | 156 | } else if( !fi->isReadable() ) { |
158 | pm = Resource::loadPixmap( "locked" ); | 157 | pm = Resource::loadPixmap( "locked" ); |
159 | } else { //everything else goes by mimetype | 158 | } else { //everything else goes by mimetype |
160 | MimeType mt(fi->filePath()); | 159 | MimeType mt(fi->filePath()); |
161 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 160 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
162 | if(pm.isNull()) | 161 | if(pm.isNull()) |
163 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 162 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
164 | } | 163 | } |
165 | item->setPixmap( 0,pm); | 164 | item->setPixmap( 0,pm); |
166 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 165 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
167 | // overlay link image | 166 | // overlay link image |
168 | pm= Resource::loadPixmap( "folder" ); | 167 | pm= Resource::loadPixmap( "folder" ); |
169 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 168 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
170 | QPainter painter( &pm ); | 169 | QPainter painter( &pm ); |
171 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 170 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
172 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 171 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
173 | item->setPixmap( 0, pm); | 172 | item->setPixmap( 0, pm); |
174 | } | 173 | } |
175 | } | 174 | } |
176 | isDir=FALSE; | 175 | isDir=FALSE; |
177 | ++it; | 176 | ++it; |
178 | } | 177 | } |
179 | 178 | ||
180 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 179 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
181 | struct stat buf; | 180 | struct stat buf; |
182 | dev_t devT; | 181 | dev_t devT; |
183 | DIR *dir; | 182 | DIR *dir; |
184 | struct dirent *mydirent; | 183 | struct dirent *mydirent; |
185 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 184 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
186 | while ((mydirent = readdir(dir)) != NULL) { | 185 | while ((mydirent = readdir(dir)) != NULL) { |
187 | lstat( mydirent->d_name, &buf); | 186 | lstat( mydirent->d_name, &buf); |
188 | qDebug(mydirent->d_name); | 187 | qDebug(mydirent->d_name); |
189 | fileL.sprintf("%s", mydirent->d_name); | 188 | fileL.sprintf("%s", mydirent->d_name); |
190 | devT = buf.st_dev; | 189 | devT = buf.st_dev; |
191 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 190 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
192 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 191 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
193 | if( fileL.find(".") == -1 ){ | 192 | if( fileL.find(".") == -1 ){ |
194 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 193 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
195 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 194 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
196 | item->setPixmap( 0,pm); | 195 | item->setPixmap( 0,pm); |
197 | } | 196 | } |
198 | } | 197 | } |
199 | 198 | ||
200 | closedir(dir); | 199 | closedir(dir); |
201 | } | 200 | } |
202 | 201 | ||
203 | Local_View->setSorting( 3,FALSE); | 202 | Local_View->setSorting( 3,FALSE); |
204 | fillCombo( (const QString &) currentDir.canonicalPath()); | 203 | fillCombo( (const QString &) currentDir.canonicalPath()); |
205 | } | 204 | } |
206 | 205 | ||
207 | 206 | ||
208 | void AdvancedFm::populateRemoteView() { | 207 | void AdvancedFm::populateRemoteView() { |
209 | QPixmap pm; | 208 | QPixmap pm; |
210 | Remote_View->clear(); | 209 | Remote_View->clear(); |
211 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 210 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
212 | currentRemoteDir.setMatchAllDirs(TRUE); | 211 | currentRemoteDir.setMatchAllDirs(TRUE); |
213 | currentRemoteDir.setNameFilter(filterStr); | 212 | currentRemoteDir.setNameFilter(filterStr); |
214 | QString fileL, fileS, fileDate; | 213 | QString fileL, fileS, fileDate; |
215 | 214 | ||
216 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 215 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
217 | setCaption("AdvancedFm :: "+fs+" :: " | 216 | setCaption("AdvancedFm :: "+fs+" :: " |
218 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 217 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
219 | bool isDir=FALSE; | 218 | bool isDir=FALSE; |
220 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 219 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
221 | QFileInfoListIterator it(*list); | 220 | QFileInfoListIterator it(*list); |
222 | QFileInfo *fi; | 221 | QFileInfo *fi; |
223 | while ( (fi=it.current()) ) { | 222 | while ( (fi=it.current()) ) { |
224 | if (fi->isSymLink() ){ | 223 | if (fi->isSymLink() ){ |
225 | QString symLink=fi->readLink(); | 224 | QString symLink=fi->readLink(); |
226 | // qDebug("Symlink detected "+symLink); | 225 | // qDebug("Symlink detected "+symLink); |
227 | QFileInfo sym( symLink); | 226 | QFileInfo sym( symLink); |
228 | fileS.sprintf( "%10i", sym.size() ); | 227 | fileS.sprintf( "%10i", sym.size() ); |
229 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 228 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
230 | fileDate = sym.lastModified().toString(); | 229 | fileDate = sym.lastModified().toString(); |
231 | } else { | 230 | } else { |
232 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 231 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
233 | fileS.sprintf( "%10i", fi->size() ); | 232 | fileS.sprintf( "%10i", fi->size() ); |
234 | fileL.sprintf( "%s",fi->fileName().data() ); | 233 | fileL.sprintf( "%s",fi->fileName().data() ); |
235 | fileDate= fi->lastModified().toString(); | 234 | fileDate= fi->lastModified().toString(); |
236 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 235 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
237 | fileL+="/"; | 236 | fileL+="/"; |
238 | isDir=TRUE; | 237 | isDir=TRUE; |
239 | // qDebug( fileL); | 238 | // qDebug( fileL); |
240 | } | 239 | } |
241 | } | 240 | } |
242 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); | 241 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); |
243 | if(fileL !="./" && fi->exists()) { | 242 | if(fileL !="./" && fi->exists()) { |
244 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 243 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
245 | QPixmap pm; | 244 | QPixmap pm; |
246 | 245 | ||
247 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 246 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
248 | if( !QDir( fi->filePath() ).isReadable()) | 247 | if( !QDir( fi->filePath() ).isReadable()) |
249 | pm = Resource::loadPixmap( "lockedfolder" ); | 248 | pm = Resource::loadPixmap( "lockedfolder" ); |
250 | else | 249 | else |
251 | pm= Resource::loadPixmap( "folder" ); | 250 | pm= Resource::loadPixmap( "folder" ); |
252 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 251 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
253 | pm = Resource::loadPixmap( "exec"); | 252 | pm = Resource::loadPixmap( "exec"); |
254 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 253 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
255 | | fileInfo.permission( QFileInfo::ExeGroup) | 254 | | fileInfo.permission( QFileInfo::ExeGroup) |
256 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 255 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
257 | pm = Resource::loadPixmap( "exec"); | 256 | pm = Resource::loadPixmap( "exec"); |
258 | } else if( !fi->isReadable() ) { | 257 | } else if( !fi->isReadable() ) { |
259 | pm = Resource::loadPixmap( "locked" ); | 258 | pm = Resource::loadPixmap( "locked" ); |
260 | } else { | 259 | } else { |
261 | MimeType mt(fi->filePath()); | 260 | MimeType mt(fi->filePath()); |
262 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 261 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
263 | if(pm.isNull()) | 262 | if(pm.isNull()) |
264 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 263 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
265 | } | 264 | } |
266 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 265 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
267 | // overlay link image | 266 | // overlay link image |
268 | pm= Resource::loadPixmap( "folder" ); | 267 | pm= Resource::loadPixmap( "folder" ); |
269 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 268 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
270 | QPainter painter( &pm ); | 269 | QPainter painter( &pm ); |
271 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 270 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
272 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 271 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
273 | } | 272 | } |
274 | item->setPixmap( 0, pm); | 273 | item->setPixmap( 0, pm); |
275 | } | 274 | } |
276 | isDir=FALSE; | 275 | isDir=FALSE; |
277 | ++it; | 276 | ++it; |
278 | } | 277 | } |
279 | 278 | ||
280 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 279 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
281 | struct stat buf; | 280 | struct stat buf; |
282 | DIR *dir; | 281 | DIR *dir; |
283 | struct dirent *mydirent; | 282 | struct dirent *mydirent; |
284 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 283 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
285 | while ((mydirent = readdir(dir)) != NULL) { | 284 | while ((mydirent = readdir(dir)) != NULL) { |
286 | lstat( mydirent->d_name, &buf); | 285 | lstat( mydirent->d_name, &buf); |
287 | qDebug(mydirent->d_name); | 286 | qDebug(mydirent->d_name); |
288 | fileL.sprintf("%s", mydirent->d_name); | 287 | fileL.sprintf("%s", mydirent->d_name); |
289 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 288 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
290 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 289 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
291 | if( fileL.find(".") == -1 ){ | 290 | if( fileL.find(".") == -1 ){ |
292 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 291 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
293 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 292 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
294 | item->setPixmap( 0,pm); | 293 | item->setPixmap( 0,pm); |
295 | } | 294 | } |
296 | } | 295 | } |
297 | 296 | ||
298 | closedir(dir); | 297 | closedir(dir); |
299 | } | 298 | } |
300 | 299 | ||
301 | Remote_View->setSorting( 3,FALSE); | 300 | Remote_View->setSorting( 3,FALSE); |
302 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 301 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
303 | } | 302 | } |
304 | 303 | ||
305 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) { | 304 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) { |
306 | if(selectedItem) { | 305 | if(selectedItem) { |
307 | QString strItem=selectedItem->text(0); | 306 | QString strItem=selectedItem->text(0); |
308 | QString strSize=selectedItem->text(1); | 307 | QString strSize=selectedItem->text(1); |
309 | strSize=strSize.stripWhiteSpace(); | 308 | strSize=strSize.stripWhiteSpace(); |
310 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 309 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
311 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 310 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
312 | if(QDir(strItem2).exists() ) { | 311 | if(QDir(strItem2).exists() ) { |
313 | currentDir.cd(strItem2, TRUE); | 312 | currentDir.cd(strItem2, TRUE); |
314 | populateLocalView(); | 313 | populateLocalView(); |
315 | 314 | ||
316 | } | 315 | } |
317 | } else { // not a symlink | 316 | } else { // not a symlink |
318 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 317 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
319 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 318 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
320 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 319 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
321 | currentDir.cd(strItem,FALSE); | 320 | currentDir.cd(strItem,FALSE); |
322 | populateLocalView(); | 321 | populateLocalView(); |
323 | Local_View->ensureItemVisible(Local_View->firstChild()); | 322 | Local_View->ensureItemVisible(Local_View->firstChild()); |
324 | 323 | ||
325 | } else { | 324 | } else { |
326 | currentDir.cdUp(); | 325 | currentDir.cdUp(); |
327 | populateLocalView(); | 326 | populateLocalView(); |
328 | Local_View->ensureItemVisible(Local_View->firstChild()); | 327 | Local_View->ensureItemVisible(Local_View->firstChild()); |
329 | } | 328 | } |
330 | if(QDir(strItem).exists()){ | 329 | if(QDir(strItem).exists()){ |
331 | currentDir.cd(strItem, TRUE); | 330 | currentDir.cd(strItem, TRUE); |
332 | Local_View->ensureItemVisible(Local_View->firstChild()); | 331 | Local_View->ensureItemVisible(Local_View->firstChild()); |
333 | populateLocalView(); | 332 | populateLocalView(); |
334 | } | 333 | } |
335 | } else { | 334 | } else { |
336 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 335 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
337 | if( QFile::exists(strItem ) ) { | 336 | if( QFile::exists(strItem ) ) { |
338 | // qDebug("clicked item "+strItem); | 337 | // qDebug("clicked item "+strItem); |
339 | // DocLnk doc( strItem, FALSE ); | 338 | // DocLnk doc( strItem, FALSE ); |
340 | // doc.execute(); | 339 | // doc.execute(); |
341 | // Local_View->clearSelection(); | 340 | // Local_View->clearSelection(); |
342 | } | 341 | } |
343 | } //end not symlink | 342 | } //end not symlink |
344 | chdir(strItem.latin1()); | 343 | chdir(strItem.latin1()); |
345 | } | 344 | } |
346 | 345 | ||
347 | } | 346 | } |
348 | } | 347 | } |
349 | 348 | ||
350 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { | 349 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { |
351 | 350 | ||
352 | if(selectedItem) { | 351 | if(selectedItem) { |
353 | QString strItem=selectedItem->text(0); | 352 | QString strItem=selectedItem->text(0); |
354 | QString strSize=selectedItem->text(1); | 353 | QString strSize=selectedItem->text(1); |
355 | strSize=strSize.stripWhiteSpace(); | 354 | strSize=strSize.stripWhiteSpace(); |
356 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 355 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
357 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 356 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
358 | currentRemoteDir.cd(strItem2, TRUE); | 357 | currentRemoteDir.cd(strItem2, TRUE); |
359 | populateRemoteView(); | 358 | populateRemoteView(); |
360 | } else { // not a symlink | 359 | } else { // not a symlink |
361 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 360 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
362 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 361 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
363 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 362 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
364 | currentRemoteDir.cd(strItem,FALSE); | 363 | currentRemoteDir.cd(strItem,FALSE); |
365 | populateRemoteView(); | 364 | populateRemoteView(); |
366 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 365 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
367 | } else { | 366 | } else { |
368 | currentRemoteDir.cdUp(); | 367 | currentRemoteDir.cdUp(); |
369 | populateRemoteView(); | 368 | populateRemoteView(); |
370 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 369 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
371 | } | 370 | } |
372 | if(QDir(strItem).exists()){ | 371 | if(QDir(strItem).exists()){ |
373 | currentRemoteDir.cd(strItem, TRUE); | 372 | currentRemoteDir.cd(strItem, TRUE); |
374 | populateRemoteView(); | 373 | populateRemoteView(); |
375 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 374 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
376 | } | 375 | } |
377 | } else { | 376 | } else { |
378 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 377 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
379 | if( QFile::exists(strItem ) ) { | 378 | if( QFile::exists(strItem ) ) { |
380 | // qDebug("clicked item "+strItem); | 379 | // qDebug("clicked item "+strItem); |
381 | // DocLnk doc( strItem, FALSE ); | 380 | // DocLnk doc( strItem, FALSE ); |
382 | // doc.execute(); | 381 | // doc.execute(); |
383 | // Remote_View->clearSelection(); | 382 | // Remote_View->clearSelection(); |
384 | } | 383 | } |
385 | } //end not symlink | 384 | } //end not symlink |
386 | chdir(strItem.latin1()); | 385 | chdir(strItem.latin1()); |
387 | } | 386 | } |
388 | } | 387 | } |
389 | } | 388 | } |
390 | 389 | ||
391 | 390 | ||
392 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 391 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
393 | // qDebug("list pressed"); | 392 | // qDebug("list pressed"); |
394 | switch (mouse) { | 393 | switch (mouse) { |
395 | case 1: | 394 | case 1: |
396 | break; | 395 | break; |
397 | case 2: | 396 | case 2: |
398 | menuTimer.start( 750, TRUE ); | 397 | menuTimer.start( 500, TRUE ); |
399 | qDebug("Start menu timer\n"); | 398 | qDebug("Start menu timer\n"); |
400 | break; | 399 | break; |
401 | }; | 400 | }; |
402 | } | 401 | } |
403 | 402 | ||
404 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { | 403 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { |
405 | 404 | ||
406 | switch (mouse) { | 405 | switch (mouse) { |
407 | case 1: | 406 | case 1: |
408 | break; | 407 | break; |
409 | case 2: | 408 | case 2: |
410 | menuTimer.start( 750, TRUE ); | 409 | menuTimer.start( 500, TRUE ); |
411 | qDebug("Start menu timer"); | 410 | qDebug("Start menu timer"); |
412 | break; | 411 | break; |
413 | }; | 412 | }; |
414 | } | 413 | } |
415 | 414 | ||
416 | 415 | ||
417 | void AdvancedFm::switchToLocalTab() { | 416 | void AdvancedFm::switchToLocalTab() { |
418 | TabWidget->setCurrentPage(0); | 417 | TabWidget->setCurrentPage(0); |
419 | Local_View->setFocus(); | 418 | Local_View->setFocus(); |
420 | } | 419 | } |
421 | 420 | ||
422 | void AdvancedFm::switchToRemoteTab() { | 421 | void AdvancedFm::switchToRemoteTab() { |
423 | TabWidget->setCurrentPage(1); | 422 | TabWidget->setCurrentPage(1); |
424 | Remote_View->setFocus(); | 423 | Remote_View->setFocus(); |
425 | } | 424 | } |
426 | 425 | ||
427 | void AdvancedFm::readConfig() { | 426 | void AdvancedFm::readConfig() { |
428 | Config cfg("AdvancedFm"); | 427 | Config cfg("AdvancedFm"); |
429 | } | 428 | } |
430 | 429 | ||
431 | void AdvancedFm::writeConfig() { | 430 | void AdvancedFm::writeConfig() { |
432 | Config cfg("AdvancedFm"); | 431 | Config cfg("AdvancedFm"); |
433 | } | 432 | } |
434 | 433 | ||
435 | void AdvancedFm::currentPathComboChanged() { | 434 | void AdvancedFm::currentPathComboChanged() { |
436 | if (TabWidget->currentPageIndex() == 0) { | 435 | if (TabWidget->currentPageIndex() == 0) { |
437 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 436 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
438 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 437 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
439 | populateLocalView(); | 438 | populateLocalView(); |
440 | } else { | 439 | } else { |
441 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 440 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
442 | } | 441 | } |
443 | } | 442 | } |
444 | if (TabWidget->currentPageIndex() == 0) { | 443 | if (TabWidget->currentPageIndex() == 0) { |
445 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 444 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
446 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 445 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
447 | populateRemoteView(); | 446 | populateRemoteView(); |
448 | } else { | 447 | } else { |
449 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 448 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
450 | } | 449 | } |
451 | } | 450 | } |
452 | } | 451 | } |
453 | 452 | ||
454 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 453 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
455 | 454 | ||
456 | if (TabWidget->currentPageIndex() == 0) { | 455 | if (TabWidget->currentPageIndex() == 0) { |
457 | currentPathCombo->lineEdit()->setText( currentPath); | 456 | currentPathCombo->lineEdit()->setText( currentPath); |
458 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 457 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
459 | currentPathCombo->clear(); | 458 | currentPathCombo->clear(); |
460 | localDirPathStringList.prepend( currentPath ); | 459 | localDirPathStringList.prepend( currentPath ); |
461 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 460 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
462 | } | 461 | } |
463 | } else { | 462 | } else { |
464 | currentPathCombo->lineEdit()->setText( currentPath); | 463 | currentPathCombo->lineEdit()->setText( currentPath); |
465 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 464 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
466 | currentPathCombo->clear(); | 465 | currentPathCombo->clear(); |
467 | remoteDirPathStringList.prepend( currentPath ); | 466 | remoteDirPathStringList.prepend( currentPath ); |
468 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 467 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
469 | } | 468 | } |
470 | } | 469 | } |
471 | } | 470 | } |
472 | 471 | ||
473 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 472 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
474 | if (TabWidget->currentPageIndex() == 0) { | 473 | if (TabWidget->currentPageIndex() == 0) { |
475 | chdir( currentPath.latin1() ); | 474 | chdir( currentPath.latin1() ); |
476 | currentDir.cd( currentPath, TRUE); | 475 | currentDir.cd( currentPath, TRUE); |
477 | populateLocalView(); | 476 | populateLocalView(); |
478 | update(); | 477 | update(); |
479 | } else { | 478 | } else { |
480 | chdir( currentPath.latin1() ); | 479 | chdir( currentPath.latin1() ); |
481 | currentRemoteDir.cd( currentPath, TRUE); | 480 | currentRemoteDir.cd( currentPath, TRUE); |
482 | populateRemoteView(); | 481 | populateRemoteView(); |
483 | update(); | 482 | update(); |
484 | } | 483 | } |
485 | } | 484 | } |
486 | 485 | ||
487 | QStringList AdvancedFm::getPath() { | 486 | QStringList AdvancedFm::getPath() { |
488 | QStringList strList; | 487 | QStringList strList; |
489 | if (TabWidget->currentPageIndex() == 0) { | 488 | if (TabWidget->currentPageIndex() == 0) { |
490 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 489 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
491 | QListViewItemIterator it( Local_View ); | 490 | QListViewItemIterator it( Local_View ); |
492 | for ( ; it.current(); ++it ) { | 491 | for ( ; it.current(); ++it ) { |
493 | if ( it.current()->isSelected() ) { | 492 | if ( it.current()->isSelected() ) { |
494 | strList << it.current()->text(0); | 493 | strList << it.current()->text(0); |
495 | qDebug(it.current()->text(0)); | 494 | qDebug(it.current()->text(0)); |
496 | } | 495 | } |
497 | } | 496 | } |
498 | return strList; | 497 | return strList; |
499 | } else { | 498 | } else { |
500 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 499 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
501 | QListViewItemIterator it( Remote_View ); | 500 | QListViewItemIterator it( Remote_View ); |
502 | for ( ; it.current(); ++it ) { | 501 | for ( ; it.current(); ++it ) { |
503 | if ( it.current()->isSelected() ) { | 502 | if ( it.current()->isSelected() ) { |
504 | strList << it.current()->text(0); | 503 | strList << it.current()->text(0); |
505 | qDebug(it.current()->text(0)); | 504 | qDebug(it.current()->text(0)); |
506 | } | 505 | } |
507 | } | 506 | } |
508 | return strList; | 507 | return strList; |
509 | } | 508 | } |
510 | return ""; | 509 | return ""; |
511 | } | 510 | } |
512 | 511 | ||
513 | void AdvancedFm::homeButtonPushed() { | 512 | void AdvancedFm::homeButtonPushed() { |
514 | QString current = QDir::homeDirPath(); | 513 | QString current = QDir::homeDirPath(); |
515 | chdir( current.latin1() ); | 514 | chdir( current.latin1() ); |
516 | if (TabWidget->currentPageIndex() == 0) { | 515 | if (TabWidget->currentPageIndex() == 0) { |
517 | currentDir.cd( current, TRUE); | 516 | currentDir.cd( current, TRUE); |
518 | populateLocalView(); | 517 | populateLocalView(); |
519 | } else { | 518 | } else { |
520 | currentRemoteDir.cd( current, TRUE); | 519 | currentRemoteDir.cd( current, TRUE); |
521 | populateRemoteView(); | 520 | populateRemoteView(); |
522 | } | 521 | } |
523 | update(); | 522 | update(); |
524 | } | 523 | } |
525 | 524 | ||
526 | void AdvancedFm::docButtonPushed() { | 525 | void AdvancedFm::docButtonPushed() { |
527 | QString current = QPEApplication::documentDir(); | 526 | QString current = QPEApplication::documentDir(); |
528 | chdir( current.latin1() ); | 527 | chdir( current.latin1() ); |
529 | if (TabWidget->currentPageIndex() == 0) { | 528 | if (TabWidget->currentPageIndex() == 0) { |
530 | currentDir.cd( current, TRUE); | 529 | currentDir.cd( current, TRUE); |
531 | populateLocalView(); | 530 | populateLocalView(); |
532 | } else { | 531 | } else { |
533 | currentRemoteDir.cd( current, TRUE); | 532 | currentRemoteDir.cd( current, TRUE); |
534 | populateRemoteView(); | 533 | populateRemoteView(); |
535 | } | 534 | } |
536 | update(); | 535 | update(); |
537 | } | 536 | } |
538 | 537 | ||
539 | void AdvancedFm::SDButtonPushed() { | 538 | void AdvancedFm::SDButtonPushed() { |
540 | QString current = "/mnt/card";// this can change so fix | 539 | QString current = "/mnt/card";// this can change so fix |
541 | chdir( current.latin1() ); | 540 | chdir( current.latin1() ); |
542 | if (TabWidget->currentPageIndex() == 0) { | 541 | if (TabWidget->currentPageIndex() == 0) { |
543 | currentDir.cd( current, TRUE); | 542 | currentDir.cd( current, TRUE); |
544 | populateLocalView(); | 543 | populateLocalView(); |
545 | } else { | 544 | } else { |
546 | currentRemoteDir.cd( current, TRUE); | 545 | currentRemoteDir.cd( current, TRUE); |
547 | populateRemoteView(); | 546 | populateRemoteView(); |
548 | } | 547 | } |
549 | update(); | 548 | update(); |
550 | 549 | ||
551 | } | 550 | } |
552 | 551 | ||
553 | void AdvancedFm::CFButtonPushed() { | 552 | void AdvancedFm::CFButtonPushed() { |
554 | QString current; | 553 | QString current; |
555 | if(zaurusDevice) | 554 | if(zaurusDevice) |
556 | current= "/mnt/cf"; //zaurus | 555 | current= "/mnt/cf"; //zaurus |
557 | else | 556 | else |
558 | current = "/mnt/hda"; //ipaq | 557 | current = "/mnt/hda"; //ipaq |
559 | 558 | ||
560 | chdir( current.latin1() ); | 559 | chdir( current.latin1() ); |
561 | if (TabWidget->currentPageIndex() == 0) { | 560 | if (TabWidget->currentPageIndex() == 0) { |
562 | currentDir.cd( current, TRUE); | 561 | currentDir.cd( current, TRUE); |
563 | populateLocalView(); | 562 | populateLocalView(); |
564 | } else { | 563 | } else { |
565 | currentRemoteDir.cd( current, TRUE); | 564 | currentRemoteDir.cd( current, TRUE); |
566 | populateRemoteView(); | 565 | populateRemoteView(); |
567 | } | 566 | } |
568 | update(); | 567 | update(); |
569 | } | 568 | } |
570 | 569 | ||
571 | 570 | ||
572 | 571 | ||
573 | void AdvancedFm::doAbout() { | 572 | void AdvancedFm::doAbout() { |
574 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 573 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
575 | "is copyright 2002 by\n" | 574 | "is copyright 2002 by\n" |
576 | "L.J.Potter<llornkcor@handhelds.org>\n" | 575 | "L.J.Potter<llornkcor@handhelds.org>\n" |
577 | "and is licensed by the GPL")); | 576 | "and is licensed by the GPL")); |
578 | } | 577 | } |
579 | 578 | ||
580 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 579 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
581 | if( TabWidget->hasFocus()) | 580 | if( TabWidget->hasFocus()) |
582 | switch ( e->key() ) { | 581 | switch ( e->key() ) { |
583 | case Key_Delete: | 582 | case Key_Delete: |
584 | del(); | 583 | del(); |
585 | break; | 584 | break; |
586 | case Key_H: | 585 | case Key_H: |
587 | showHidden(); | 586 | showHidden(); |
588 | break; | 587 | break; |
589 | case Key_E: | 588 | case Key_E: |
590 | runThis(); | 589 | runThis(); |
591 | break; | 590 | break; |
592 | case Key_C: | 591 | case Key_C: |
593 | copy(); | 592 | copy(); |
594 | break; | 593 | break; |
595 | case Key_A: | 594 | case Key_A: |
596 | copyAs(); | 595 | copyAs(); |
597 | break; | 596 | break; |
598 | case Key_M: | 597 | case Key_M: |
599 | move(); | 598 | move(); |
600 | break; | 599 | break; |
601 | case Key_R: | 600 | case Key_R: |
602 | rn(); | 601 | rn(); |
603 | break; | 602 | break; |
604 | case Key_I: | 603 | case Key_I: |
605 | fileStatus(); | 604 | fileStatus(); |
606 | break; | 605 | break; |
607 | case Key_U: | 606 | case Key_U: |
608 | upDir(); | 607 | upDir(); |
609 | break; | 608 | break; |
610 | case Key_P: | 609 | case Key_P: |
611 | filePerms(); | 610 | filePerms(); |
612 | break; | 611 | break; |
613 | case Key_N: | 612 | case Key_N: |
614 | mkDir(); | 613 | mkDir(); |
615 | break; | 614 | break; |
616 | case Key_1: | 615 | case Key_1: |
617 | switchToLocalTab(); | 616 | switchToLocalTab(); |
618 | break; | 617 | break; |
619 | case Key_2: | 618 | case Key_2: |
620 | switchToRemoteTab(); | 619 | switchToRemoteTab(); |
621 | break; | 620 | break; |
622 | case Key_3: | 621 | case Key_3: |
623 | CFButtonPushed(); | 622 | CFButtonPushed(); |
624 | break; | 623 | break; |
625 | case Key_4: | 624 | case Key_4: |
626 | SDButtonPushed(); | 625 | SDButtonPushed(); |
627 | break; | 626 | break; |
628 | case Key_5: | 627 | case Key_5: |
629 | homeButtonPushed(); | 628 | homeButtonPushed(); |
630 | break; | 629 | break; |
631 | case Key_6: | 630 | case Key_6: |
632 | docButtonPushed(); | 631 | docButtonPushed(); |
633 | break; | 632 | break; |
634 | case Key_7: | 633 | case Key_7: |
635 | break; | 634 | break; |
636 | case Key_8: | 635 | case Key_8: |
637 | break; | 636 | break; |
638 | case Key_9: | 637 | case Key_9: |
639 | break; | 638 | break; |
640 | case Key_0: | 639 | case Key_0: |
641 | break; | 640 | break; |
642 | } | 641 | } |
643 | } | 642 | } |
644 | 643 | ||
645 | 644 | ||
646 | void AdvancedFm::QPEButtonPushed() { | 645 | void AdvancedFm::QPEButtonPushed() { |
647 | QString current = QPEApplication::qpeDir(); | 646 | QString current = QPEApplication::qpeDir(); |
648 | chdir( current.latin1() ); | 647 | chdir( current.latin1() ); |
649 | if (TabWidget->currentPageIndex() == 0) { | 648 | if (TabWidget->currentPageIndex() == 0) { |
650 | currentDir.cd( current, TRUE); | 649 | currentDir.cd( current, TRUE); |
651 | populateLocalView(); | 650 | populateLocalView(); |
652 | } else { | 651 | } else { |
653 | currentRemoteDir.cd( current, TRUE); | 652 | currentRemoteDir.cd( current, TRUE); |
654 | populateRemoteView(); | 653 | populateRemoteView(); |
655 | } | 654 | } |
656 | update(); | 655 | update(); |
657 | } | 656 | } |
658 | 657 | ||
659 | void AdvancedFm::parsetab(const QString &fileName) { | 658 | void AdvancedFm::parsetab(const QString &fileName) { |
660 | 659 | ||
661 | fileSystemTypeList.clear(); | 660 | fileSystemTypeList.clear(); |
662 | fsList.clear(); | 661 | fsList.clear(); |
663 | struct mntent *me; | 662 | struct mntent *me; |
664 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 663 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
665 | if ( mntfp ) { | 664 | if ( mntfp ) { |
666 | while ( (me = getmntent( mntfp )) != 0 ) { | 665 | while ( (me = getmntent( mntfp )) != 0 ) { |
667 | QString deviceName = me->mnt_fsname; | 666 | QString deviceName = me->mnt_fsname; |
668 | QString filesystemType = me->mnt_type; | 667 | QString filesystemType = me->mnt_type; |
669 | QString mountDir = me->mnt_dir; | 668 | QString mountDir = me->mnt_dir; |
670 | if(deviceName != "none") { | 669 | if(deviceName != "none") { |
671 | if( fsList.contains(filesystemType) == 0 | 670 | if( fsList.contains(filesystemType) == 0 |
672 | & filesystemType.find("proc",0,TRUE) == -1 | 671 | & filesystemType.find("proc",0,TRUE) == -1 |
673 | & filesystemType.find("cramfs",0,TRUE) == -1 | 672 | & filesystemType.find("cramfs",0,TRUE) == -1 |
674 | & filesystemType.find("auto",0,TRUE) == -1) | 673 | & filesystemType.find("auto",0,TRUE) == -1) |
675 | fsList << filesystemType; | 674 | fsList << filesystemType; |
676 | fileSystemTypeList << mountDir+"::"+filesystemType; | 675 | fileSystemTypeList << mountDir+"::"+filesystemType; |
677 | } | 676 | } |
678 | } | 677 | } |
679 | } | 678 | } |
680 | endmntent( mntfp ); | 679 | endmntent( mntfp ); |
681 | } | 680 | } |
682 | 681 | ||
683 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 682 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
684 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 683 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
685 | QString current = currentText;//.right( currentText.length()-1); | 684 | QString current = currentText;//.right( currentText.length()-1); |
686 | QString baseFs; | 685 | QString baseFs; |
687 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 686 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
688 | QString temp = (*it); | 687 | QString temp = (*it); |
689 | QString path = temp.left(temp.find("::",0,TRUE) ); | 688 | QString path = temp.left(temp.find("::",0,TRUE) ); |
690 | path = path.right( path.length()-1); | 689 | path = path.right( path.length()-1); |
691 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 690 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
692 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 691 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
693 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 692 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
694 | } | 693 | } |
695 | } | 694 | } |
696 | return baseFs; | 695 | return baseFs; |
697 | } | 696 | } |
698 | 697 | ||
699 | QString AdvancedFm::getDiskSpace( const QString &path) { | 698 | QString AdvancedFm::getDiskSpace( const QString &path) { |
700 | struct statfs fss; | 699 | struct statfs fss; |
701 | if ( !statfs( path.latin1(), &fss ) ) { | 700 | if ( !statfs( path.latin1(), &fss ) ) { |
702 | int blkSize = fss.f_bsize; | 701 | int blkSize = fss.f_bsize; |
703 | // int totalBlks = fs.f_blocks; | 702 | // int totalBlks = fs.f_blocks; |
704 | int availBlks = fss.f_bavail; | 703 | int availBlks = fss.f_bavail; |
705 | 704 | ||
706 | long mult = blkSize / 1024; | 705 | long mult = blkSize / 1024; |
707 | long div = 1024 / blkSize; | 706 | long div = 1024 / blkSize; |
708 | if ( !mult ) mult = 1; | 707 | if ( !mult ) mult = 1; |
709 | if ( !div ) div = 1; | 708 | if ( !div ) div = 1; |
710 | 709 | ||
711 | return QString::number(availBlks * mult / div); | 710 | return QString::number(availBlks * mult / div); |
712 | } | 711 | } |
713 | return ""; | 712 | return ""; |
714 | } | 713 | } |
715 | 714 | ||
716 | 715 | ||
717 | void AdvancedFm::showFileMenu() { | 716 | void AdvancedFm::showFileMenu() { |
718 | 717 | ||
719 | QString curApp; | 718 | QString curApp; |
720 | bool isLocalView = false; | 719 | bool isLocalView = false; |
721 | if (TabWidget->currentPageIndex() == 0) { | 720 | if (TabWidget->currentPageIndex() == 0) { |
722 | isLocalView = TRUE; | 721 | isLocalView = TRUE; |
723 | curApp = Local_View->currentItem()->text(0); | 722 | curApp = Local_View->currentItem()->text(0); |
724 | } else { | 723 | } else { |
725 | curApp = Remote_View->currentItem()->text(0); | 724 | curApp = Remote_View->currentItem()->text(0); |
726 | } | 725 | } |
727 | 726 | ||
728 | MimeType mt( curApp ); | 727 | MimeType mt( curApp ); |
729 | const AppLnk* app = mt.application(); | 728 | const AppLnk* app = mt.application(); |
730 | QFile fi(curApp); | 729 | QFile fi(curApp); |
731 | 730 | ||
732 | QPopupMenu *m = new QPopupMenu(0); | 731 | QPopupMenu *m = new QPopupMenu(0); |
733 | QPopupMenu *n = new QPopupMenu(0); | 732 | QPopupMenu *n = new QPopupMenu(0); |
734 | // QPopupMenu *o = new QPopupMenu(0); | 733 | // QPopupMenu *o = new QPopupMenu(0); |
735 | 734 | ||
736 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 735 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
737 | if ( !QFileInfo(fi).isDir() ) { | 736 | if ( !QFileInfo(fi).isDir() ) { |
738 | // m->insertSeparator(); | 737 | // m->insertSeparator(); |
739 | // m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 738 | // m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
740 | // } else { | 739 | // } else { |
741 | 740 | ||
742 | if ( app ) | 741 | if ( app ) |
743 | m->insertItem( app->pixmap(), tr( "Open in " | 742 | m->insertItem( app->pixmap(), tr( "Open in " |
744 | + app->name() ), this, SLOT( runThis() ) ); | 743 | + app->name() ), this, SLOT( runThis() ) ); |
745 | else if( QFileInfo(fi).isExecutable() ) | 744 | else if( QFileInfo(fi).isExecutable() ) |
746 | m->insertItem( Resource::loadPixmap( app->name()), tr( "Execute" ), this, SLOT( runThis() ) ); | 745 | m->insertItem( Resource::loadPixmap( app->name()), tr( "Execute" ), this, SLOT( runThis() ) ); |
747 | 746 | ||
748 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 747 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
749 | } | 748 | } |
750 | 749 | ||
751 | m->insertItem(tr("Actions"),n); | 750 | m->insertItem(tr("Actions"),n); |
752 | if(isLocalView) | 751 | if(isLocalView) |
753 | n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 752 | n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
754 | else | 753 | else |
755 | n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 754 | n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
756 | 755 | ||
757 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 756 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
758 | 757 | ||
759 | n->insertSeparator(); | 758 | n->insertSeparator(); |
760 | 759 | ||
761 | 760 | ||
762 | if(isLocalView) | 761 | if(isLocalView) |
763 | n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 762 | n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
764 | else | 763 | else |
765 | n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 764 | n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
766 | 765 | ||
767 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 766 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
768 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 767 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
769 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 768 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
770 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 769 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
771 | 770 | ||
772 | n->insertSeparator(); | 771 | n->insertSeparator(); |
773 | 772 | ||
774 | if(isLocalView) | 773 | if(isLocalView) |
775 | n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 774 | n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
776 | else | 775 | else |
777 | n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 776 | n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
778 | 777 | ||
779 | 778 | ||
780 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 779 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
781 | 780 | ||
782 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 781 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
783 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 782 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
784 | 783 | ||
785 | m->insertSeparator(); | 784 | m->insertSeparator(); |
786 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 785 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
787 | 786 | ||
788 | #if defined(QT_QWS_OPIE) | 787 | #if defined(QT_QWS_OPIE) |
789 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 788 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
790 | #endif | 789 | #endif |
791 | m->setCheckable(TRUE); | 790 | m->setCheckable(TRUE); |
792 | if (!b) | 791 | if (!b) |
793 | m->setItemChecked(m->idAt(0),TRUE); | 792 | m->setItemChecked(m->idAt(0),TRUE); |
794 | else | 793 | else |
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 12ad474..f846c66 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -1,149 +1,150 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfm.h | 2 | advancedfm.h |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #ifndef ADVANCEDFM_H | 12 | #ifndef ADVANCEDFM_H |
13 | #define ADVANCEDFM_H | 13 | #define ADVANCEDFM_H |
14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | 14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties |
15 | #define QT_QWS_OPIE | ||
15 | 16 | ||
16 | #include <qpe/ir.h> | 17 | #include <qpe/ir.h> |
17 | 18 | ||
18 | #include <qvariant.h> | 19 | #include <qvariant.h> |
19 | #include <qdialog.h> | 20 | #include <qdialog.h> |
20 | #include <qmainwindow.h> | 21 | #include <qmainwindow.h> |
21 | #include <qstringlist.h> | 22 | #include <qstringlist.h> |
22 | #include <qdir.h> | 23 | #include <qdir.h> |
23 | #include <qstring.h> | 24 | #include <qstring.h> |
24 | #include <qpoint.h> | 25 | #include <qpoint.h> |
25 | #include <qtimer.h> | 26 | #include <qtimer.h> |
26 | 27 | ||
27 | class QVBoxLayout; | 28 | class QVBoxLayout; |
28 | class QHBoxLayout; | 29 | class QHBoxLayout; |
29 | class QGridLayout; | 30 | class QGridLayout; |
30 | class QComboBox; | 31 | class QComboBox; |
31 | class QListView; | 32 | class QListView; |
32 | class QListviewItem; | 33 | class QListviewItem; |
33 | class QLabel; | 34 | class QLabel; |
34 | class QProgressBar; | 35 | class QProgressBar; |
35 | class QSpinBox; | 36 | class QSpinBox; |
36 | class QTabWidget; | 37 | class QTabWidget; |
37 | class QWidget; | 38 | class QWidget; |
38 | class QPEToolBar; | 39 | class QPEToolBar; |
39 | class QPEMenuBar; | 40 | class QPEMenuBar; |
40 | class QPopupMenu; | 41 | class QPopupMenu; |
41 | class QFile; | 42 | class QFile; |
42 | class QListViewItem; | 43 | class QListViewItem; |
43 | class QLineEdit; | 44 | class QLineEdit; |
44 | //class QPushButton; | 45 | //class QPushButton; |
45 | class QToolButton; | 46 | class QToolButton; |
46 | class Ir; | 47 | class Ir; |
47 | 48 | ||
48 | class AdvancedFm : public QMainWindow | 49 | class AdvancedFm : public QMainWindow |
49 | { | 50 | { |
50 | Q_OBJECT | 51 | Q_OBJECT |
51 | public: | 52 | public: |
52 | AdvancedFm(); | 53 | AdvancedFm(); |
53 | ~AdvancedFm(); | 54 | ~AdvancedFm(); |
54 | 55 | ||
55 | QTabWidget *TabWidget; | 56 | QTabWidget *TabWidget; |
56 | QWidget *tab, *tab_2, *tab_3; | 57 | QWidget *tab, *tab_2, *tab_3; |
57 | QListView *Local_View, *Remote_View; | 58 | QListView *Local_View, *Remote_View; |
58 | 59 | ||
59 | QLineEdit *currentPathEdit; | 60 | QLineEdit *currentPathEdit; |
60 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; | 61 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; |
61 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 62 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
62 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 63 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
63 | QDir currentDir, currentRemoteDir; | 64 | QDir currentDir, currentRemoteDir; |
64 | QComboBox *currentPathCombo; | 65 | QComboBox *currentPathCombo; |
65 | QString filterStr; | 66 | QString filterStr; |
66 | QListViewItem * item; | 67 | QListViewItem * item; |
67 | bool b; | 68 | bool b; |
68 | QStringList fileSystemTypeList, fsList; | 69 | QStringList fileSystemTypeList, fsList; |
69 | int currentServerConfig; | 70 | int currentServerConfig; |
70 | protected slots: | 71 | protected slots: |
71 | void addToDocs(); | 72 | void addToDocs(); |
72 | void doLocalCd(); | 73 | void doLocalCd(); |
73 | void doRemoteCd(); | 74 | void doRemoteCd(); |
74 | // void copy(); | 75 | // void copy(); |
75 | void mkDir(); | 76 | void mkDir(); |
76 | void del(); | 77 | void del(); |
77 | void rn(); | 78 | void rn(); |
78 | void populateLocalView(); | 79 | void populateLocalView(); |
79 | void populateRemoteView(); | 80 | void populateRemoteView(); |
80 | void showHidden(); | 81 | void showHidden(); |
81 | void showMenuHidden(); | 82 | void showMenuHidden(); |
82 | void showRemoteHidden(); | 83 | void showRemoteHidden(); |
83 | void writeConfig(); | 84 | void writeConfig(); |
84 | void readConfig(); | 85 | void readConfig(); |
85 | void localListClicked(QListViewItem *); | 86 | void localListClicked(QListViewItem *); |
86 | void remoteListClicked(QListViewItem *); | 87 | void remoteListClicked(QListViewItem *); |
87 | void localListPressed( int, QListViewItem *, const QPoint&, int); | 88 | void localListPressed( int, QListViewItem *, const QPoint&, int); |
88 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); | 89 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); |
89 | void localMakDir(); | 90 | void localMakDir(); |
90 | void localDelete(); | 91 | void localDelete(); |
91 | void remoteMakDir(); | 92 | void remoteMakDir(); |
92 | void remoteDelete(); | 93 | void remoteDelete(); |
93 | /* bool remoteDirList(const QString &); */ | 94 | /* bool remoteDirList(const QString &); */ |
94 | /* bool remoteChDir(const QString &); */ | 95 | /* bool remoteChDir(const QString &); */ |
95 | void tabChanged(QWidget*); | 96 | void tabChanged(QWidget*); |
96 | void cleanUp(); | 97 | void cleanUp(); |
97 | void remoteRename(); | 98 | void remoteRename(); |
98 | void localRename(); | 99 | void localRename(); |
99 | void runThis(); | 100 | void runThis(); |
100 | void runText(); | 101 | void runText(); |
101 | void filePerms(); | 102 | void filePerms(); |
102 | void doProperties(); | 103 | void doProperties(); |
103 | void runCommand(); | 104 | void runCommand(); |
104 | void runCommandStd(); | 105 | void runCommandStd(); |
105 | QStringList getPath(); | 106 | QStringList getPath(); |
106 | void mkSym(); | 107 | void mkSym(); |
107 | void switchToLocalTab(); | 108 | void switchToLocalTab(); |
108 | void switchToRemoteTab(); | 109 | void switchToRemoteTab(); |
109 | 110 | ||
110 | protected: | 111 | protected: |
111 | bool zaurusDevice; | 112 | bool zaurusDevice; |
112 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; | 113 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; |
113 | QStringList remoteDirPathStringList, localDirPathStringList; | 114 | QStringList remoteDirPathStringList, localDirPathStringList; |
114 | 115 | ||
115 | void init(); | 116 | void init(); |
116 | void initConnections(); | 117 | void initConnections(); |
117 | void keyReleaseEvent( QKeyEvent *); | 118 | void keyReleaseEvent( QKeyEvent *); |
118 | QString getFileSystemType(const QString &); | 119 | QString getFileSystemType(const QString &); |
119 | QString getDiskSpace(const QString &); | 120 | QString getDiskSpace(const QString &); |
120 | void parsetab(const QString &fileName); | 121 | void parsetab(const QString &fileName); |
121 | QString checkDiskSpace(const QString &); | 122 | QString checkDiskSpace(const QString &); |
122 | 123 | ||
123 | protected slots: | 124 | protected slots: |
124 | void showFileMenu(); | 125 | void showFileMenu(); |
125 | void cancelMenuTimer(); | 126 | void cancelMenuTimer(); |
126 | void homeButtonPushed(); | 127 | void homeButtonPushed(); |
127 | void docButtonPushed(); | 128 | void docButtonPushed(); |
128 | void SDButtonPushed(); | 129 | void SDButtonPushed(); |
129 | void CFButtonPushed(); | 130 | void CFButtonPushed(); |
130 | void QPEButtonPushed(); | 131 | void QPEButtonPushed(); |
131 | void upDir(); | 132 | void upDir(); |
132 | void currentPathComboChanged(); | 133 | void currentPathComboChanged(); |
133 | void copy(); | 134 | void copy(); |
134 | void copyAs(); | 135 | void copyAs(); |
135 | void copySameDir(); | 136 | void copySameDir(); |
136 | void currentPathComboActivated(const QString &); | 137 | void currentPathComboActivated(const QString &); |
137 | void fillCombo(const QString &); | 138 | void fillCombo(const QString &); |
138 | bool copyFile( const QString & , const QString & ); | 139 | bool copyFile( const QString & , const QString & ); |
139 | void move(); | 140 | void move(); |
140 | void fileStatus(); | 141 | void fileStatus(); |
141 | void doAbout(); | 142 | void doAbout(); |
142 | void doBeam(); | 143 | void doBeam(); |
143 | void fileBeamFinished( Ir *); | 144 | void fileBeamFinished( Ir *); |
144 | 145 | ||
145 | private: | 146 | private: |
146 | QTimer menuTimer; | 147 | QTimer menuTimer; |
147 | }; | 148 | }; |
148 | 149 | ||
149 | #endif // ADVANCEDFM_H | 150 | #endif // ADVANCEDFM_H |
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index 4c24e83..619a7a9 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -1,235 +1,237 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfmData.cpp | 2 | advancedfmData.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Mon 09-23-2002 13:24:11 | 4 | ** Created: Mon 09-23-2002 13:24:11 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | 13 | ||
14 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
15 | #include <qpe/qpemenubar.h> | 15 | #include <qpe/qpemenubar.h> |
16 | #include <qpe/qpetoolbar.h> | 16 | #include <qpe/qpetoolbar.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | 18 | ||
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qpixmap.h> | 20 | #include <qpixmap.h> |
21 | #include <qcombobox.h> | 21 | #include <qcombobox.h> |
22 | #include <qpopupmenu.h> | 22 | #include <qpopupmenu.h> |
23 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | #include <qtabwidget.h> | 25 | #include <qtabwidget.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | 28 | ||
29 | #include <sys/utsname.h> | 29 | #include <sys/utsname.h> |
30 | 30 | ||
31 | 31 | ||
32 | void AdvancedFm::init() { | 32 | void AdvancedFm::init() { |
33 | 33 | #if defined(QT_QWS_OPIE) | |
34 | setCaption( tr( "AdvancedFm" ) ); | 34 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); |
35 | #endif | ||
36 | setCaption( tr( "AdvancedFm" ) ); | ||
35 | 37 | ||
36 | QGridLayout *layout = new QGridLayout( this ); | 38 | QGridLayout *layout = new QGridLayout( this ); |
37 | layout->setSpacing( 2); | 39 | layout->setSpacing( 2); |
38 | layout->setMargin( 2); | 40 | layout->setMargin( 2); |
39 | 41 | ||
40 | 42 | ||
41 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 43 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
42 | fileMenu = new QPopupMenu( this ); | 44 | fileMenu = new QPopupMenu( this ); |
43 | viewMenu = new QPopupMenu( this ); | 45 | viewMenu = new QPopupMenu( this ); |
44 | 46 | ||
45 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); | 47 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); |
46 | 48 | ||
47 | menuBar->insertItem( tr( "File" ), fileMenu); | 49 | menuBar->insertItem( tr( "File" ), fileMenu); |
48 | menuBar->insertItem( tr( "View" ), viewMenu); | 50 | menuBar->insertItem( tr( "View" ), viewMenu); |
49 | 51 | ||
50 | qpeDirButton= new QToolButton(this,"QPEButton"); | 52 | qpeDirButton= new QToolButton(this,"QPEButton"); |
51 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); | 53 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); |
52 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); | 54 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); |
53 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); | 55 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); |
54 | 56 | ||
55 | cfButton = new QToolButton( this,"CFButton"); | 57 | cfButton = new QToolButton( this,"CFButton"); |
56 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); | 58 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); |
57 | cfButton ->setFixedSize( QSize( 20, 20 ) ); | 59 | cfButton ->setFixedSize( QSize( 20, 20 ) ); |
58 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); | 60 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); |
59 | 61 | ||
60 | sdButton = new QToolButton( this,"SDButton"); | 62 | sdButton = new QToolButton( this,"SDButton"); |
61 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); | 63 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); |
62 | sdButton->setFixedSize( QSize( 20, 20 ) ); | 64 | sdButton->setFixedSize( QSize( 20, 20 ) ); |
63 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); | 65 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); |
64 | 66 | ||
65 | cdUpButton = new QToolButton( this,"cdUpButton"); | 67 | cdUpButton = new QToolButton( this,"cdUpButton"); |
66 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 68 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
67 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 69 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
68 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); | 70 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); |
69 | 71 | ||
70 | docButton = new QToolButton( this,"docsButton"); | 72 | docButton = new QToolButton( this,"docsButton"); |
71 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); | 73 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); |
72 | docButton->setFixedSize( QSize( 20, 20 ) ); | 74 | docButton->setFixedSize( QSize( 20, 20 ) ); |
73 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); | 75 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); |
74 | 76 | ||
75 | homeButton = new QToolButton( this,"homeButton"); | 77 | homeButton = new QToolButton( this,"homeButton"); |
76 | homeButton->setPixmap(Resource::loadPixmap("home")); | 78 | homeButton->setPixmap(Resource::loadPixmap("home")); |
77 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 79 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
78 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); | 80 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); |
79 | 81 | ||
80 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); | 82 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); |
81 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 83 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
82 | fileMenu->insertSeparator(); | 84 | fileMenu->insertSeparator(); |
83 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 85 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
84 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 86 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
85 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 87 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
86 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 88 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
87 | fileMenu->insertSeparator(); | 89 | fileMenu->insertSeparator(); |
88 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 90 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
89 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 91 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
90 | fileMenu->setCheckable(TRUE); | 92 | fileMenu->setCheckable(TRUE); |
91 | 93 | ||
92 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 94 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
93 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 95 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
94 | viewMenu->insertSeparator(); | 96 | viewMenu->insertSeparator(); |
95 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 97 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
96 | viewMenu->setCheckable(TRUE); | 98 | viewMenu->setCheckable(TRUE); |
97 | 99 | ||
98 | 100 | ||
99 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 101 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
100 | currentPathCombo->setEditable(TRUE); | 102 | currentPathCombo->setEditable(TRUE); |
101 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); | 103 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); |
102 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 104 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
103 | 105 | ||
104 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 106 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
105 | 107 | ||
106 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); | 108 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); |
107 | 109 | ||
108 | 110 | ||
109 | TabWidget = new QTabWidget( this, "TabWidget" ); | 111 | TabWidget = new QTabWidget( this, "TabWidget" ); |
110 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); | 112 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); |
111 | 113 | ||
112 | tab = new QWidget( TabWidget, "tab" ); | 114 | tab = new QWidget( TabWidget, "tab" ); |
113 | tabLayout = new QGridLayout( tab ); | 115 | tabLayout = new QGridLayout( tab ); |
114 | tabLayout->setSpacing( 2); | 116 | tabLayout->setSpacing( 2); |
115 | tabLayout->setMargin( 2); | 117 | tabLayout->setMargin( 2); |
116 | 118 | ||
117 | Local_View = new QListView( tab, "Local_View" ); | 119 | Local_View = new QListView( tab, "Local_View" ); |
118 | Local_View->addColumn( tr("File"),130); | 120 | Local_View->addColumn( tr("File"),130); |
119 | Local_View->addColumn( tr("Size"),-1); | 121 | Local_View->addColumn( tr("Size"),-1); |
120 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 122 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
121 | Local_View->addColumn( tr("Date"),-1); | 123 | Local_View->addColumn( tr("Date"),-1); |
122 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 124 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
123 | Local_View->setAllColumnsShowFocus(TRUE); | 125 | Local_View->setAllColumnsShowFocus(TRUE); |
124 | Local_View->setMultiSelection( TRUE ); | 126 | Local_View->setMultiSelection( TRUE ); |
125 | Local_View->setSelectionMode(QListView::Extended); | 127 | Local_View->setSelectionMode(QListView::Extended); |
126 | 128 | ||
127 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 129 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
128 | 130 | ||
129 | tabLayout->addWidget( Local_View, 0, 0 ); | 131 | tabLayout->addWidget( Local_View, 0, 0 ); |
130 | 132 | ||
131 | TabWidget->insertTab( tab, tr("1")); | 133 | TabWidget->insertTab( tab, tr("1")); |
132 | 134 | ||
133 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 135 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
134 | tabLayout_2 = new QGridLayout( tab_2 ); | 136 | tabLayout_2 = new QGridLayout( tab_2 ); |
135 | tabLayout_2->setSpacing( 2); | 137 | tabLayout_2->setSpacing( 2); |
136 | tabLayout_2->setMargin( 2); | 138 | tabLayout_2->setMargin( 2); |
137 | 139 | ||
138 | Remote_View = new QListView( tab_2, "Remote_View" ); | 140 | Remote_View = new QListView( tab_2, "Remote_View" ); |
139 | Remote_View->addColumn( tr("File"),130); | 141 | Remote_View->addColumn( tr("File"),130); |
140 | Remote_View->addColumn( tr("Size"),-1); | 142 | Remote_View->addColumn( tr("Size"),-1); |
141 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 143 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
142 | Remote_View->addColumn( tr("Date"),-1); | 144 | Remote_View->addColumn( tr("Date"),-1); |
143 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 145 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
144 | Remote_View->setAllColumnsShowFocus(TRUE); | 146 | Remote_View->setAllColumnsShowFocus(TRUE); |
145 | Remote_View->setMultiSelection( TRUE ); | 147 | Remote_View->setMultiSelection( TRUE ); |
146 | Remote_View->setSelectionMode(QListView::Extended); | 148 | Remote_View->setSelectionMode(QListView::Extended); |
147 | 149 | ||
148 | 150 | ||
149 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 151 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
150 | 152 | ||
151 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 153 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
152 | 154 | ||
153 | 155 | ||
154 | TabWidget->insertTab( tab_2, tr( "2")); | 156 | TabWidget->insertTab( tab_2, tr( "2")); |
155 | 157 | ||
156 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 158 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
157 | tabLayout_3 = new QGridLayout( tab_3 ); | 159 | tabLayout_3 = new QGridLayout( tab_3 ); |
158 | tabLayout_3->setSpacing( 2); | 160 | tabLayout_3->setSpacing( 2); |
159 | tabLayout_3->setMargin( 2); | 161 | tabLayout_3->setMargin( 2); |
160 | 162 | ||
161 | 163 | ||
162 | // OFileDialog fileDialog; | 164 | // OFileDialog fileDialog; |
163 | // fileDialog; | 165 | // fileDialog; |
164 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 166 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
165 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 167 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
166 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 168 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
167 | 169 | ||
168 | QListView *fileTree; | 170 | QListView *fileTree; |
169 | fileTree = new QListView( tab_3, "tree" ); | 171 | fileTree = new QListView( tab_3, "tree" ); |
170 | 172 | ||
171 | 173 | ||
172 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 174 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
173 | 175 | ||
174 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 176 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
175 | */ | 177 | */ |
176 | 178 | ||
177 | /////////////// | 179 | /////////////// |
178 | 180 | ||
179 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 181 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
180 | if (uname(&name) != -1) { | 182 | if (uname(&name) != -1) { |
181 | QString release=name.release; | 183 | QString release=name.release; |
182 | if(release.find("embedix",0,TRUE) !=-1) { | 184 | if(release.find("embedix",0,TRUE) !=-1) { |
183 | zaurusDevice=TRUE; | 185 | zaurusDevice=TRUE; |
184 | } else { | 186 | } else { |
185 | zaurusDevice=FALSE; | 187 | zaurusDevice=FALSE; |
186 | sdButton->hide(); | 188 | sdButton->hide(); |
187 | } | 189 | } |
188 | } | 190 | } |
189 | 191 | ||
190 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 192 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
191 | currentDir.setPath( QDir::currentDirPath()); | 193 | currentDir.setPath( QDir::currentDirPath()); |
192 | 194 | ||
193 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 195 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
194 | currentRemoteDir.setPath( QDir::currentDirPath()); | 196 | currentRemoteDir.setPath( QDir::currentDirPath()); |
195 | 197 | ||
196 | b = TRUE; | 198 | b = TRUE; |
197 | 199 | ||
198 | filterStr="*"; | 200 | filterStr="*"; |
199 | b=FALSE; | 201 | b=FALSE; |
200 | 202 | ||
201 | 203 | ||
202 | } | 204 | } |
203 | 205 | ||
204 | void AdvancedFm::initConnections() { | 206 | void AdvancedFm::initConnections() { |
205 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 207 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
206 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); | 208 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); |
207 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); | 209 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); |
208 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); | 210 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); |
209 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 211 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
210 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 212 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
211 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 213 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
212 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 214 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
213 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 215 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
214 | 216 | ||
215 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 217 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
216 | this,SLOT(currentPathComboChanged())); | 218 | this,SLOT(currentPathComboChanged())); |
217 | 219 | ||
218 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 220 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
219 | this,SLOT( localListClicked(QListViewItem *)) ); | 221 | this,SLOT( localListClicked(QListViewItem *)) ); |
220 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 222 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
221 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); | 223 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); |
222 | 224 | ||
223 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 225 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
224 | 226 | ||
225 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 227 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
226 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 228 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
227 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 229 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
228 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 230 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
229 | 231 | ||
230 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 232 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
231 | this,SLOT(tabChanged(QWidget*))); | 233 | this,SLOT(tabChanged(QWidget*))); |
232 | 234 | ||
233 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 235 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
234 | 236 | ||
235 | } | 237 | } |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 7ee5065..6d37904 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,744 +1,750 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "inputDialog.h" | 13 | #include "inputDialog.h" |
14 | #include "output.h" | 14 | #include "output.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | #include <qpe/lnkproperties.h> | 17 | #include <qpe/lnkproperties.h> |
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | #include <qpe/qpemenubar.h> | 19 | #include <qpe/qpemenubar.h> |
20 | #include <qpe/qpetoolbar.h> | 20 | #include <qpe/qpetoolbar.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | 28 | ||
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | 30 | ||
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
36 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qlistview.h> | 39 | #include <qlistview.h> |
40 | 40 | ||
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
44 | #include <dirent.h> | 44 | #include <dirent.h> |
45 | 45 | ||
46 | 46 | ||
47 | void AdvancedFm::doLocalCd() { | 47 | void AdvancedFm::doLocalCd() { |
48 | localListClicked( Local_View->currentItem()); | 48 | localListClicked( Local_View->currentItem()); |
49 | } | 49 | } |
50 | 50 | ||
51 | void AdvancedFm::doRemoteCd() { | 51 | void AdvancedFm::doRemoteCd() { |
52 | localListClicked( Remote_View->currentItem()); | 52 | localListClicked( Remote_View->currentItem()); |
53 | } | 53 | } |
54 | 54 | ||
55 | void AdvancedFm::showMenuHidden() { | 55 | void AdvancedFm::showMenuHidden() { |
56 | showHidden(); | 56 | showHidden(); |
57 | if(b) b= false; else b=true; | 57 | if(b) b= false; else b=true; |
58 | showRemoteHidden(); | 58 | showRemoteHidden(); |
59 | } | 59 | } |
60 | 60 | ||
61 | void AdvancedFm::showHidden() { | 61 | void AdvancedFm::showHidden() { |
62 | if (b) { | 62 | if (b) { |
63 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 63 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
64 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 64 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
65 | b=FALSE; | 65 | b=FALSE; |
66 | 66 | ||
67 | } else { | 67 | } else { |
68 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 68 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
70 | b=TRUE; | 70 | b=TRUE; |
71 | } | 71 | } |
72 | populateLocalView(); | 72 | populateLocalView(); |
73 | 73 | ||
74 | } | 74 | } |
75 | 75 | ||
76 | void AdvancedFm::showRemoteHidden() { | 76 | void AdvancedFm::showRemoteHidden() { |
77 | if (b) { | 77 | if (b) { |
78 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 78 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
79 | b=TRUE; | 79 | b=TRUE; |
80 | 80 | ||
81 | } else { | 81 | } else { |
82 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 82 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
83 | b=FALSE; | 83 | b=FALSE; |
84 | } | 84 | } |
85 | populateRemoteView(); | 85 | populateRemoteView(); |
86 | } | 86 | } |
87 | 87 | ||
88 | void AdvancedFm::runThis() { | 88 | void AdvancedFm::runThis() { |
89 | QString fs; | 89 | QString fs; |
90 | if (TabWidget->currentPageIndex() == 0) { | 90 | if (TabWidget->currentPageIndex() == 0) { |
91 | QString curFile = Local_View->currentItem()->text(0); | 91 | QString curFile = Local_View->currentItem()->text(0); |
92 | if(curFile != "../") { | 92 | if(curFile != "../") { |
93 | 93 | ||
94 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 94 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
95 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | 95 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); |
96 | qDebug( fileInfo.owner()); | 96 | qDebug( fileInfo.owner()); |
97 | if( (fileInfo.permission( QFileInfo::ExeUser) | 97 | if( (fileInfo.permission( QFileInfo::ExeUser) |
98 | | fileInfo.permission( QFileInfo::ExeGroup) | 98 | | fileInfo.permission( QFileInfo::ExeGroup) |
99 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 99 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
100 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 100 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
101 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 101 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
102 | e << curFile; | 102 | e << curFile; |
103 | } else { | 103 | } else { |
104 | curFile = currentDir.canonicalPath()+"/"+curFile; | 104 | curFile = currentDir.canonicalPath()+"/"+curFile; |
105 | DocLnk nf(curFile); | 105 | DocLnk nf(curFile); |
106 | QString execStr = nf.exec(); | 106 | QString execStr = nf.exec(); |
107 | qDebug( execStr); | 107 | qDebug( execStr); |
108 | if( execStr.isEmpty() ) { | 108 | if( execStr.isEmpty() ) { |
109 | } else { | 109 | } else { |
110 | nf.execute(); | 110 | nf.execute(); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | } | 113 | } |
114 | } else { | 114 | } else { |
115 | QString curFile = Remote_View->currentItem()->text(0); | 115 | QString curFile = Remote_View->currentItem()->text(0); |
116 | if(curFile != "../") { | 116 | if(curFile != "../") { |
117 | 117 | ||
118 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 118 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
119 | qDebug("Filesystemtype is "+fs); | 119 | qDebug("Filesystemtype is "+fs); |
120 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | 120 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); |
121 | if( (fileInfo.permission( QFileInfo::ExeUser) | 121 | if( (fileInfo.permission( QFileInfo::ExeUser) |
122 | | fileInfo.permission( QFileInfo::ExeGroup) | 122 | | fileInfo.permission( QFileInfo::ExeGroup) |
123 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 123 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
124 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 124 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
125 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 125 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
126 | e << curFile; | 126 | e << curFile; |
127 | } else { | 127 | } else { |
128 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 128 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
129 | DocLnk nf(curFile); | 129 | DocLnk nf(curFile); |
130 | QString execStr = nf.exec(); | 130 | QString execStr = nf.exec(); |
131 | qDebug(execStr); | 131 | qDebug(execStr); |
132 | if( execStr.isEmpty() ) { | 132 | if( execStr.isEmpty() ) { |
133 | } else { | 133 | } else { |
134 | nf.execute(); | 134 | nf.execute(); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | void AdvancedFm::runText() { | 141 | void AdvancedFm::runText() { |
142 | if (TabWidget->currentPageIndex() == 0) { | 142 | if (TabWidget->currentPageIndex() == 0) { |
143 | QString curFile = Local_View->currentItem()->text(0); | 143 | QString curFile = Local_View->currentItem()->text(0); |
144 | if(curFile != "../") { | 144 | if(curFile != "../") { |
145 | curFile = currentDir.canonicalPath()+"/"+curFile; | 145 | curFile = currentDir.canonicalPath()+"/"+curFile; |
146 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 146 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
147 | e << curFile; | 147 | e << curFile; |
148 | } | 148 | } |
149 | } else { | 149 | } else { |
150 | QString curFile = Remote_View->currentItem()->text(0); | 150 | QString curFile = Remote_View->currentItem()->text(0); |
151 | if(curFile != "../") { | 151 | if(curFile != "../") { |
152 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 152 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
153 | DocLnk nf(curFile); | 153 | DocLnk nf(curFile); |
154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
155 | e << curFile; | 155 | e << curFile; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | void AdvancedFm::localMakDir() { | 160 | void AdvancedFm::localMakDir() { |
161 | InputDialog *fileDlg; | 161 | InputDialog *fileDlg; |
162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
163 | fileDlg->exec(); | 163 | fileDlg->exec(); |
164 | if( fileDlg->result() == 1 ) { | 164 | if( fileDlg->result() == 1 ) { |
165 | QString filename = fileDlg->LineEdit1->text(); | 165 | QString filename = fileDlg->LineEdit1->text(); |
166 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 166 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
167 | } | 167 | } |
168 | populateLocalView(); | 168 | populateLocalView(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void AdvancedFm::remoteMakDir() { | 171 | void AdvancedFm::remoteMakDir() { |
172 | InputDialog *fileDlg; | 172 | InputDialog *fileDlg; |
173 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 173 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
174 | fileDlg->exec(); | 174 | fileDlg->exec(); |
175 | if( fileDlg->result() == 1 ) { | 175 | if( fileDlg->result() == 1 ) { |
176 | QString filename = fileDlg->LineEdit1->text(); | 176 | QString filename = fileDlg->LineEdit1->text(); |
177 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | 177 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); |
178 | } | 178 | } |
179 | populateRemoteView(); | 179 | populateRemoteView(); |
180 | } | 180 | } |
181 | 181 | ||
182 | void AdvancedFm::localDelete() { | 182 | void AdvancedFm::localDelete() { |
183 | QStringList curFileList = getPath(); | 183 | QStringList curFileList = getPath(); |
184 | if(curFileList.count() > 0) { | 184 | if(curFileList.count() > 0) { |
185 | QString myFile; | 185 | QString myFile; |
186 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 186 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
187 | myFile = (*it); | 187 | myFile = (*it); |
188 | if( myFile.find(" -> ",0,TRUE) != -1) | 188 | if( myFile.find(" -> ",0,TRUE) != -1) |
189 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 189 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
190 | 190 | ||
191 | QString f = currentDir.canonicalPath(); | 191 | QString f = currentDir.canonicalPath(); |
192 | if(f.right(1).find("/",0,TRUE) == -1) | 192 | if(f.right(1).find("/",0,TRUE) == -1) |
193 | f+="/"; | 193 | f+="/"; |
194 | f+=myFile; | 194 | f+=myFile; |
195 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 195 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
196 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 196 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
197 | "\nand all it's contents ?" | 197 | "\nand all it's contents ?" |
198 | ,tr("Yes"),tr("No"),0,0,1) ) { | 198 | ,tr("Yes"),tr("No"),0,0,1) ) { |
199 | case 0: { | 199 | case 0: { |
200 | f=f.left(f.length()-1); | 200 | f=f.left(f.length()-1); |
201 | QString cmd="rm -rf "+f; | 201 | QString cmd="rm -rf "+f; |
202 | system( cmd.latin1()); | 202 | system( cmd.latin1()); |
203 | populateLocalView(); | 203 | populateLocalView(); |
204 | } | 204 | } |
205 | break; | 205 | break; |
206 | case 1: | 206 | case 1: |
207 | // exit | 207 | // exit |
208 | break; | 208 | break; |
209 | }; | 209 | }; |
210 | 210 | ||
211 | } else { | 211 | } else { |
212 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 212 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
213 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 213 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
214 | case 0: { | 214 | case 0: { |
215 | QString cmd="rm "+f; | 215 | QString cmd="rm "+f; |
216 | QFile file(f); | 216 | QFile file(f); |
217 | file.remove(); | 217 | file.remove(); |
218 | // system( cmd.latin1()); | 218 | // system( cmd.latin1()); |
219 | populateLocalView(); | 219 | populateLocalView(); |
220 | } | 220 | } |
221 | break; | 221 | break; |
222 | case 1: | 222 | case 1: |
223 | // exit | 223 | // exit |
224 | break; | 224 | break; |
225 | }; | 225 | }; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | void AdvancedFm::remoteDelete() { | 231 | void AdvancedFm::remoteDelete() { |
232 | QStringList curFileList = getPath(); | 232 | QStringList curFileList = getPath(); |
233 | if( curFileList.count() > 0) { | 233 | if( curFileList.count() > 0) { |
234 | QString myFile; | 234 | QString myFile; |
235 | 235 | ||
236 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 236 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
237 | myFile = (*it); | 237 | myFile = (*it); |
238 | if(myFile.find(" -> ",0,TRUE) != -1) | 238 | if(myFile.find(" -> ",0,TRUE) != -1) |
239 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 239 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
240 | QString f = currentRemoteDir.canonicalPath(); | 240 | QString f = currentRemoteDir.canonicalPath(); |
241 | if(f.right(1).find("/",0,TRUE) == -1) | 241 | if(f.right(1).find("/",0,TRUE) == -1) |
242 | f+="/"; | 242 | f+="/"; |
243 | f+=myFile; | 243 | f+=myFile; |
244 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 244 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
245 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 245 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
246 | "\nand all it's contents ?", | 246 | "\nand all it's contents ?", |
247 | tr("Yes"),tr("No"),0,0,1) ) { | 247 | tr("Yes"),tr("No"),0,0,1) ) { |
248 | case 0: { | 248 | case 0: { |
249 | f=f.left(f.length()-1); | 249 | f=f.left(f.length()-1); |
250 | QString cmd="rm -rf "+f; | 250 | QString cmd="rm -rf "+f; |
251 | system( cmd.latin1()); | 251 | system( cmd.latin1()); |
252 | populateRemoteView(); | 252 | populateRemoteView(); |
253 | } | 253 | } |
254 | break; | 254 | break; |
255 | case 1: | 255 | case 1: |
256 | // exit | 256 | // exit |
257 | break; | 257 | break; |
258 | }; | 258 | }; |
259 | 259 | ||
260 | } else { | 260 | } else { |
261 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 261 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
262 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 262 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
263 | case 0: { | 263 | case 0: { |
264 | QString cmd="rm "+f; | 264 | QString cmd="rm "+f; |
265 | QFile file(f); | 265 | QFile file(f); |
266 | file.remove(); | 266 | file.remove(); |
267 | // system( cmd.latin1()); | 267 | // system( cmd.latin1()); |
268 | populateRemoteView(); | 268 | populateRemoteView(); |
269 | } | 269 | } |
270 | break; | 270 | break; |
271 | case 1: | 271 | case 1: |
272 | // exit | 272 | // exit |
273 | break; | 273 | break; |
274 | }; | 274 | }; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | void AdvancedFm::localRename() { | 280 | void AdvancedFm::localRename() { |
281 | QString curFile = Local_View->currentItem()->text(0); | 281 | QString curFile = Local_View->currentItem()->text(0); |
282 | qDebug("currentItem "+curFile); | 282 | qDebug("currentItem "+curFile); |
283 | if( curFile !="../") { | 283 | if( curFile !="../") { |
284 | InputDialog *fileDlg; | 284 | InputDialog *fileDlg; |
285 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 285 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
286 | fileDlg->setInputText((const QString &)curFile); | 286 | fileDlg->setInputText((const QString &)curFile); |
287 | fileDlg->exec(); | 287 | fileDlg->exec(); |
288 | if( fileDlg->result() == 1 ) { | 288 | if( fileDlg->result() == 1 ) { |
289 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 289 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
290 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); | 290 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); |
291 | //+".playlist"; | 291 | //+".playlist"; |
292 | if( rename(oldname.latin1(), newName.latin1())== -1) | 292 | if( rename(oldname.latin1(), newName.latin1())== -1) |
293 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 293 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
294 | } | 294 | } |
295 | populateLocalView(); | 295 | populateLocalView(); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | void AdvancedFm::remoteRename() | 299 | void AdvancedFm::remoteRename() |
300 | { | 300 | { |
301 | QString curFile = Remote_View->currentItem()->text(0); | 301 | QString curFile = Remote_View->currentItem()->text(0); |
302 | if( curFile !="../") { | 302 | if( curFile !="../") { |
303 | InputDialog *fileDlg; | 303 | InputDialog *fileDlg; |
304 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 304 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
305 | fileDlg->setInputText((const QString &)curFile); | 305 | fileDlg->setInputText((const QString &)curFile); |
306 | fileDlg->exec(); | 306 | fileDlg->exec(); |
307 | if( fileDlg->result() == 1 ) { | 307 | if( fileDlg->result() == 1 ) { |
308 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | 308 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; |
309 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); | 309 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); |
310 | //+".playlist"; | 310 | //+".playlist"; |
311 | if( rename(oldname.latin1(), newName.latin1())== -1) | 311 | if( rename(oldname.latin1(), newName.latin1())== -1) |
312 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 312 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
313 | } | 313 | } |
314 | populateRemoteView(); | 314 | populateRemoteView(); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | void AdvancedFm::filePerms() { | 319 | void AdvancedFm::filePerms() { |
320 | 320 | ||
321 | QStringList curFileList = getPath(); | 321 | QStringList curFileList = getPath(); |
322 | QString filePath; | 322 | QString filePath; |
323 | 323 | ||
324 | if (TabWidget->currentPageIndex() == 0) { | 324 | if (TabWidget->currentPageIndex() == 0) { |
325 | filePath = currentDir.canonicalPath()+"/"; | 325 | filePath = currentDir.canonicalPath()+"/"; |
326 | } else { | 326 | } else { |
327 | filePath= currentRemoteDir.canonicalPath()+"/"; | 327 | filePath= currentRemoteDir.canonicalPath()+"/"; |
328 | } | 328 | } |
329 | 329 | ||
330 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 330 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
331 | filePermissions *filePerm; | 331 | filePermissions *filePerm; |
332 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 332 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
333 | filePerm->showMaximized(); | 333 | filePerm->showMaximized(); |
334 | filePerm->exec(); | 334 | filePerm->exec(); |
335 | if( filePerm) | 335 | if( filePerm) |
336 | delete filePerm; | 336 | delete filePerm; |
337 | } | 337 | } |
338 | if (TabWidget->currentPageIndex() == 0) { | 338 | if (TabWidget->currentPageIndex() == 0) { |
339 | populateLocalView(); | 339 | populateLocalView(); |
340 | } else { | 340 | } else { |
341 | populateRemoteView(); | 341 | populateRemoteView(); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | void AdvancedFm::doProperties() { | 345 | void AdvancedFm::doProperties() { |
346 | #if defined(QT_QWS_OPIE) | ||
347 | |||
346 | QStringList curFileList = getPath(); | 348 | QStringList curFileList = getPath(); |
349 | |||
347 | QString filePath; | 350 | QString filePath; |
348 | if (TabWidget->currentPageIndex() == 0) { | 351 | if (TabWidget->currentPageIndex() == 0) { |
349 | filePath = currentDir.canonicalPath()+"/"; | 352 | filePath = currentDir.canonicalPath()+"/"; |
350 | } else { | 353 | } else { |
351 | filePath= currentRemoteDir.canonicalPath()+"/"; | 354 | filePath= currentRemoteDir.canonicalPath()+"/"; |
352 | } | 355 | } |
353 | // qDebug("%d",curFileList.count()); | 356 | qDebug("%d",curFileList.count()); |
354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 357 | |
358 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
355 | qDebug((filePath+*it)); | 359 | qDebug((filePath+*it)); |
356 | DocLnk lnk( (filePath+*it)); | 360 | DocLnk lnk( (filePath+*it)); |
357 | LnkProperties prop( &lnk ); | 361 | LnkProperties prop( &lnk ); |
358 | prop.showMaximized(); | 362 | prop.showMaximized(); |
359 | prop.exec(); | 363 | prop.exec(); |
360 | } | 364 | } |
365 | #endif | ||
366 | |||
361 | } | 367 | } |
362 | 368 | ||
363 | void AdvancedFm::upDir() { | 369 | void AdvancedFm::upDir() { |
364 | if (TabWidget->currentPageIndex() == 0) { | 370 | if (TabWidget->currentPageIndex() == 0) { |
365 | QString current = currentDir.canonicalPath(); | 371 | QString current = currentDir.canonicalPath(); |
366 | QDir dir(current); | 372 | QDir dir(current); |
367 | dir.cdUp(); | 373 | dir.cdUp(); |
368 | current = dir.canonicalPath(); | 374 | current = dir.canonicalPath(); |
369 | chdir( current.latin1() ); | 375 | chdir( current.latin1() ); |
370 | currentDir.cd( current, TRUE); | 376 | currentDir.cd( current, TRUE); |
371 | populateLocalView(); | 377 | populateLocalView(); |
372 | update(); | 378 | update(); |
373 | } else { | 379 | } else { |
374 | QString current = currentRemoteDir.canonicalPath(); | 380 | QString current = currentRemoteDir.canonicalPath(); |
375 | QDir dir(current); | 381 | QDir dir(current); |
376 | dir.cdUp(); | 382 | dir.cdUp(); |
377 | current = dir.canonicalPath(); | 383 | current = dir.canonicalPath(); |
378 | chdir( current.latin1() ); | 384 | chdir( current.latin1() ); |
379 | currentRemoteDir.cd( current, TRUE); | 385 | currentRemoteDir.cd( current, TRUE); |
380 | populateRemoteView(); | 386 | populateRemoteView(); |
381 | update(); | 387 | update(); |
382 | } | 388 | } |
383 | } | 389 | } |
384 | 390 | ||
385 | void AdvancedFm::copy() { | 391 | void AdvancedFm::copy() { |
386 | qApp->processEvents(); | 392 | qApp->processEvents(); |
387 | QStringList curFileList = getPath(); | 393 | QStringList curFileList = getPath(); |
388 | if( curFileList.count() > 0) { | 394 | if( curFileList.count() > 0) { |
389 | QString curFile, item, destFile; | 395 | QString curFile, item, destFile; |
390 | if (TabWidget->currentPageIndex() == 0) { | 396 | if (TabWidget->currentPageIndex() == 0) { |
391 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 397 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
392 | item=(*it); | 398 | item=(*it); |
393 | 399 | ||
394 | if(item.find("->",0,TRUE)) //symlink | 400 | if(item.find("->",0,TRUE)) //symlink |
395 | item = item.left(item.find("->",0,TRUE)); | 401 | item = item.left(item.find("->",0,TRUE)); |
396 | 402 | ||
397 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; | 403 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; |
398 | qDebug("Destination file is "+destFile); | 404 | qDebug("Destination file is "+destFile); |
399 | 405 | ||
400 | curFile = currentDir.canonicalPath()+"/"+ item; | 406 | curFile = currentDir.canonicalPath()+"/"+ item; |
401 | qDebug("CurrentFile file is " + curFile); | 407 | qDebug("CurrentFile file is " + curFile); |
402 | 408 | ||
403 | QFile f(destFile); | 409 | QFile f(destFile); |
404 | if( f.exists()) { | 410 | if( f.exists()) { |
405 | switch ( QMessageBox::warning(this,tr("Delete"), | 411 | switch ( QMessageBox::warning(this,tr("Delete"), |
406 | destFile+tr(" already exists\nDo you really want to delete it?"), | 412 | destFile+tr(" already exists\nDo you really want to delete it?"), |
407 | tr("Yes"),tr("No"),0,0,1) ) { | 413 | tr("Yes"),tr("No"),0,0,1) ) { |
408 | case 0: | 414 | case 0: |
409 | f.remove(); | 415 | f.remove(); |
410 | break; | 416 | break; |
411 | case 1: | 417 | case 1: |
412 | return; | 418 | return; |
413 | break; | 419 | break; |
414 | }; | 420 | }; |
415 | } | 421 | } |
416 | if(!copyFile(destFile, curFile) ) { | 422 | if(!copyFile(destFile, curFile) ) { |
417 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 423 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
418 | return; | 424 | return; |
419 | } | 425 | } |
420 | } | 426 | } |
421 | populateRemoteView(); | 427 | populateRemoteView(); |
422 | TabWidget->setCurrentPage(1); | 428 | TabWidget->setCurrentPage(1); |
423 | 429 | ||
424 | } else { | 430 | } else { |
425 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 431 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
426 | item= (*it); | 432 | item= (*it); |
427 | 433 | ||
428 | if(item.find("->",0,TRUE)) //symlink | 434 | if(item.find("->",0,TRUE)) //symlink |
429 | item = item.left(item.find("->",0,TRUE)); | 435 | item = item.left(item.find("->",0,TRUE)); |
430 | 436 | ||
431 | destFile = currentDir.canonicalPath()+"/"+ item; | 437 | destFile = currentDir.canonicalPath()+"/"+ item; |
432 | qDebug("Destination file is "+destFile); | 438 | qDebug("Destination file is "+destFile); |
433 | 439 | ||
434 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; | 440 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; |
435 | qDebug("CurrentFile file is " + curFile); | 441 | qDebug("CurrentFile file is " + curFile); |
436 | 442 | ||
437 | QFile f(destFile); | 443 | QFile f(destFile); |
438 | if( f.exists()) { | 444 | if( f.exists()) { |
439 | switch ( QMessageBox::warning(this,tr("Delete"), | 445 | switch ( QMessageBox::warning(this,tr("Delete"), |
440 | destFile+tr(" already exists\nDo you really want to delete it?"), | 446 | destFile+tr(" already exists\nDo you really want to delete it?"), |
441 | tr("Yes"),tr("No"),0,0,1) ) { | 447 | tr("Yes"),tr("No"),0,0,1) ) { |
442 | case 0: | 448 | case 0: |
443 | f.remove(); | 449 | f.remove(); |
444 | break; | 450 | break; |
445 | case 1: | 451 | case 1: |
446 | return; | 452 | return; |
447 | break; | 453 | break; |
448 | }; | 454 | }; |
449 | } | 455 | } |
450 | if(!copyFile(destFile, curFile) ) { | 456 | if(!copyFile(destFile, curFile) ) { |
451 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 457 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
452 | +curFile +tr("to\n")+destFile); | 458 | +curFile +tr("to\n")+destFile); |
453 | return; | 459 | return; |
454 | 460 | ||
455 | } | 461 | } |
456 | } | 462 | } |
457 | populateLocalView(); | 463 | populateLocalView(); |
458 | TabWidget->setCurrentPage(0); | 464 | TabWidget->setCurrentPage(0); |
459 | } | 465 | } |
460 | 466 | ||
461 | } | 467 | } |
462 | } | 468 | } |
463 | 469 | ||
464 | void AdvancedFm::copyAs() { | 470 | void AdvancedFm::copyAs() { |
465 | qApp->processEvents(); | 471 | qApp->processEvents(); |
466 | 472 | ||
467 | QStringList curFileList = getPath(); | 473 | QStringList curFileList = getPath(); |
468 | QString curFile; | 474 | QString curFile; |
469 | InputDialog *fileDlg; | 475 | InputDialog *fileDlg; |
470 | if (TabWidget->currentPageIndex() == 0) { | 476 | if (TabWidget->currentPageIndex() == 0) { |
471 | qDebug("tab 1"); | 477 | qDebug("tab 1"); |
472 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 478 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
473 | QString destFile; | 479 | QString destFile; |
474 | curFile = currentDir.canonicalPath()+"/"+(*it); | 480 | curFile = currentDir.canonicalPath()+"/"+(*it); |
475 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 481 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
476 | 482 | ||
477 | fileDlg->setInputText((const QString &) destFile ); | 483 | fileDlg->setInputText((const QString &) destFile ); |
478 | fileDlg->exec(); | 484 | fileDlg->exec(); |
479 | 485 | ||
480 | if( fileDlg->result() == 1 ) { | 486 | if( fileDlg->result() == 1 ) { |
481 | QString filename = fileDlg->LineEdit1->text(); | 487 | QString filename = fileDlg->LineEdit1->text(); |
482 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 488 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
483 | 489 | ||
484 | QFile f(destFile); | 490 | QFile f(destFile); |
485 | if( f.exists()) { | 491 | if( f.exists()) { |
486 | switch (QMessageBox::warning(this,tr("Delete"), | 492 | switch (QMessageBox::warning(this,tr("Delete"), |
487 | destFile+tr(" already exists\nDo you really want to delete it?"), | 493 | destFile+tr(" already exists\nDo you really want to delete it?"), |
488 | tr("Yes"),tr("No"),0,0,1) ) { | 494 | tr("Yes"),tr("No"),0,0,1) ) { |
489 | case 0: | 495 | case 0: |
490 | f.remove(); | 496 | f.remove(); |
491 | break; | 497 | break; |
492 | case 1: | 498 | case 1: |
493 | return; | 499 | return; |
494 | break; | 500 | break; |
495 | }; | 501 | }; |
496 | } | 502 | } |
497 | if(!copyFile(destFile, curFile) ) { | 503 | if(!copyFile(destFile, curFile) ) { |
498 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 504 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
499 | +curFile +tr("to\n")+destFile); | 505 | +curFile +tr("to\n")+destFile); |
500 | return; | 506 | return; |
501 | } | 507 | } |
502 | } | 508 | } |
503 | delete fileDlg; | 509 | delete fileDlg; |
504 | 510 | ||
505 | } | 511 | } |
506 | populateRemoteView(); | 512 | populateRemoteView(); |
507 | TabWidget->setCurrentPage(1); | 513 | TabWidget->setCurrentPage(1); |
508 | 514 | ||
509 | } else { | 515 | } else { |
510 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 516 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
511 | 517 | ||
512 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 518 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
513 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 519 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
514 | 520 | ||
515 | QString destFile; | 521 | QString destFile; |
516 | fileDlg->setInputText((const QString &) destFile); | 522 | fileDlg->setInputText((const QString &) destFile); |
517 | fileDlg->exec(); | 523 | fileDlg->exec(); |
518 | 524 | ||
519 | if( fileDlg->result() == 1 ) { | 525 | if( fileDlg->result() == 1 ) { |
520 | QString filename = fileDlg->LineEdit1->text(); | 526 | QString filename = fileDlg->LineEdit1->text(); |
521 | destFile = currentDir.canonicalPath()+"/"+filename; | 527 | destFile = currentDir.canonicalPath()+"/"+filename; |
522 | 528 | ||
523 | QFile f( destFile); | 529 | QFile f( destFile); |
524 | if( f.exists()) { | 530 | if( f.exists()) { |
525 | switch ( QMessageBox::warning(this,tr("Delete"), | 531 | switch ( QMessageBox::warning(this,tr("Delete"), |
526 | destFile+tr(" already exists\nDo you really want to delete it?"), | 532 | destFile+tr(" already exists\nDo you really want to delete it?"), |
527 | tr("Yes"),tr("No"),0,0,1) ) { | 533 | tr("Yes"),tr("No"),0,0,1) ) { |
528 | case 0: | 534 | case 0: |
529 | f.remove(); | 535 | f.remove(); |
530 | break; | 536 | break; |
531 | case 1: | 537 | case 1: |
532 | return; | 538 | return; |
533 | break; | 539 | break; |
534 | }; | 540 | }; |
535 | } | 541 | } |
536 | if(!copyFile(destFile, curFile) ) { | 542 | if(!copyFile(destFile, curFile) ) { |
537 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 543 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
538 | +curFile +tr("to\n")+destFile); | 544 | +curFile +tr("to\n")+destFile); |
539 | return; | 545 | return; |
540 | } | 546 | } |
541 | 547 | ||
542 | } | 548 | } |
543 | delete fileDlg; | 549 | delete fileDlg; |
544 | 550 | ||
545 | } | 551 | } |
546 | populateLocalView(); | 552 | populateLocalView(); |
547 | TabWidget->setCurrentPage(0); | 553 | TabWidget->setCurrentPage(0); |
548 | } | 554 | } |
549 | } | 555 | } |
550 | 556 | ||
551 | void AdvancedFm::copySameDir() { | 557 | void AdvancedFm::copySameDir() { |
552 | qApp->processEvents(); | 558 | qApp->processEvents(); |
553 | QStringList curFileList = getPath(); | 559 | QStringList curFileList = getPath(); |
554 | QString curFile, item, destFile; | 560 | QString curFile, item, destFile; |
555 | InputDialog *fileDlg; | 561 | InputDialog *fileDlg; |
556 | 562 | ||
557 | if (TabWidget->currentPageIndex() == 0) { | 563 | if (TabWidget->currentPageIndex() == 0) { |
558 | 564 | ||
559 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 565 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
560 | item=(*it); | 566 | item=(*it); |
561 | curFile = currentDir.canonicalPath()+"/"+ item; | 567 | curFile = currentDir.canonicalPath()+"/"+ item; |
562 | 568 | ||
563 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 569 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
564 | fileDlg->setInputText((const QString &) destFile ); | 570 | fileDlg->setInputText((const QString &) destFile ); |
565 | fileDlg->exec(); | 571 | fileDlg->exec(); |
566 | 572 | ||
567 | if( fileDlg->result() == 1 ) { | 573 | if( fileDlg->result() == 1 ) { |
568 | 574 | ||
569 | QString filename = fileDlg->LineEdit1->text(); | 575 | QString filename = fileDlg->LineEdit1->text(); |
570 | destFile = currentDir.canonicalPath()+"/"+filename; | 576 | destFile = currentDir.canonicalPath()+"/"+filename; |
571 | 577 | ||
572 | QFile f(destFile); | 578 | QFile f(destFile); |
573 | if( f.exists()) { | 579 | if( f.exists()) { |
574 | switch (QMessageBox::warning(this,tr("Delete"), | 580 | switch (QMessageBox::warning(this,tr("Delete"), |
575 | destFile+tr(" already exists\nDo you really want to delete it?"), | 581 | destFile+tr(" already exists\nDo you really want to delete it?"), |
576 | tr("Yes"),tr("No"),0,0,1) ) { | 582 | tr("Yes"),tr("No"),0,0,1) ) { |
577 | case 0: | 583 | case 0: |
578 | 584 | ||
579 | f.remove(); | 585 | f.remove(); |
580 | break; | 586 | break; |
581 | case 1: | 587 | case 1: |
582 | return; | 588 | return; |
583 | break; | 589 | break; |
584 | }; | 590 | }; |
585 | } | 591 | } |
586 | if(!copyFile(destFile, curFile) ) { | 592 | if(!copyFile(destFile, curFile) ) { |
587 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 593 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
588 | +curFile +tr("to\n")+destFile); | 594 | +curFile +tr("to\n")+destFile); |
589 | return; | 595 | return; |
590 | } | 596 | } |
591 | 597 | ||
592 | qDebug("copy "+curFile+" as "+destFile); | 598 | qDebug("copy "+curFile+" as "+destFile); |
593 | } | 599 | } |
594 | delete fileDlg; | 600 | delete fileDlg; |
595 | } | 601 | } |
596 | populateLocalView(); | 602 | populateLocalView(); |
597 | 603 | ||
598 | } else { | 604 | } else { |
599 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 605 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
600 | item=(*it); | 606 | item=(*it); |
601 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; | 607 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; |
602 | 608 | ||
603 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 609 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
604 | fileDlg->setInputText((const QString &) destFile); | 610 | fileDlg->setInputText((const QString &) destFile); |
605 | fileDlg->exec(); | 611 | fileDlg->exec(); |
606 | if( fileDlg->result() == 1 ) { | 612 | if( fileDlg->result() == 1 ) { |
607 | QString filename = fileDlg->LineEdit1->text(); | 613 | QString filename = fileDlg->LineEdit1->text(); |
608 | 614 | ||
609 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 615 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
610 | 616 | ||
611 | QFile f(destFile); | 617 | QFile f(destFile); |
612 | if( f.exists()) { | 618 | if( f.exists()) { |
613 | switch ( QMessageBox::warning(this,tr("Delete"), | 619 | switch ( QMessageBox::warning(this,tr("Delete"), |
614 | destFile+tr(" already exists\nDo you really want to delete it?"), | 620 | destFile+tr(" already exists\nDo you really want to delete it?"), |
615 | tr("Yes"),tr("No"),0,0,1) ) { | 621 | tr("Yes"),tr("No"),0,0,1) ) { |
616 | case 0: | 622 | case 0: |
617 | f.remove(); | 623 | f.remove(); |
618 | break; | 624 | break; |
619 | case 1: | 625 | case 1: |
620 | return; | 626 | return; |
621 | break; | 627 | break; |
622 | }; | 628 | }; |
623 | } | 629 | } |
624 | if(!copyFile(destFile, curFile) ) { | 630 | if(!copyFile(destFile, curFile) ) { |
625 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 631 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
626 | +curFile +tr("to\n")+destFile); | 632 | +curFile +tr("to\n")+destFile); |
627 | return; | 633 | return; |
628 | } | 634 | } |
629 | qDebug("copy "+curFile+" as "+destFile); | 635 | qDebug("copy "+curFile+" as "+destFile); |
630 | } | 636 | } |
631 | delete fileDlg; | 637 | delete fileDlg; |
632 | } | 638 | } |
633 | populateRemoteView(); | 639 | populateRemoteView(); |
634 | } | 640 | } |
635 | } | 641 | } |
636 | 642 | ||
637 | void AdvancedFm::move() { | 643 | void AdvancedFm::move() { |
638 | qApp->processEvents(); | 644 | qApp->processEvents(); |
639 | 645 | ||
640 | QStringList curFileList = getPath(); | 646 | QStringList curFileList = getPath(); |
641 | if( curFileList.count() > 0) { | 647 | if( curFileList.count() > 0) { |
642 | QString curFile, destFile, item; | 648 | QString curFile, destFile, item; |
643 | 649 | ||
644 | if (TabWidget->currentPageIndex() == 0) { | 650 | if (TabWidget->currentPageIndex() == 0) { |
645 | 651 | ||
646 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 652 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
647 | item=(*it); | 653 | item=(*it); |
648 | QString destFile = currentRemoteDir.canonicalPath(); | 654 | QString destFile = currentRemoteDir.canonicalPath(); |
649 | 655 | ||
650 | if(destFile.right(1).find("/",0,TRUE) == -1) | 656 | if(destFile.right(1).find("/",0,TRUE) == -1) |
651 | destFile+="/"; | 657 | destFile+="/"; |
652 | destFile += item; | 658 | destFile += item; |
653 | curFile = currentDir.canonicalPath(); | 659 | curFile = currentDir.canonicalPath(); |
654 | 660 | ||
655 | qDebug("Destination file is "+destFile); | 661 | qDebug("Destination file is "+destFile); |
656 | 662 | ||
657 | if(curFile.right(1).find("/",0,TRUE) == -1) | 663 | if(curFile.right(1).find("/",0,TRUE) == -1) |
658 | curFile +="/"; | 664 | curFile +="/"; |
659 | 665 | ||
660 | curFile+= item; | 666 | curFile+= item; |
661 | qDebug("CurrentFile file is " + curFile); | 667 | qDebug("CurrentFile file is " + curFile); |
662 | 668 | ||
663 | QFile f( curFile); | 669 | QFile f( curFile); |
664 | if( f.exists()) { | 670 | if( f.exists()) { |
665 | if(!copyFile( destFile, curFile) ) { | 671 | if(!copyFile( destFile, curFile) ) { |
666 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 672 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
667 | return; | 673 | return; |
668 | } else | 674 | } else |
669 | QFile::remove(curFile); | 675 | QFile::remove(curFile); |
670 | } | 676 | } |
671 | } | 677 | } |
672 | 678 | ||
673 | TabWidget->setCurrentPage(1); | 679 | TabWidget->setCurrentPage(1); |
674 | 680 | ||
675 | } else { //view 2 | 681 | } else { //view 2 |
676 | 682 | ||
677 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 683 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
678 | item = (*it); | 684 | item = (*it); |
679 | QString destFile = currentDir.canonicalPath(); | 685 | QString destFile = currentDir.canonicalPath(); |
680 | 686 | ||
681 | if(destFile.right(1).find("/",0,TRUE) == -1) | 687 | if(destFile.right(1).find("/",0,TRUE) == -1) |
682 | destFile+="/"; | 688 | destFile+="/"; |
683 | 689 | ||
684 | destFile += item; | 690 | destFile += item; |
685 | 691 | ||
686 | qDebug("Destination file is "+destFile); | 692 | qDebug("Destination file is "+destFile); |
687 | 693 | ||
688 | curFile = currentRemoteDir.canonicalPath(); | 694 | curFile = currentRemoteDir.canonicalPath(); |
689 | 695 | ||
690 | if(curFile.right(1).find("/",0,TRUE) == -1) | 696 | if(curFile.right(1).find("/",0,TRUE) == -1) |
691 | curFile +="/"; | 697 | curFile +="/"; |
692 | curFile+= item; | 698 | curFile+= item; |
693 | qDebug("CurrentFile file is " + curFile); | 699 | qDebug("CurrentFile file is " + curFile); |
694 | 700 | ||
695 | QFile f( curFile); | 701 | QFile f( curFile); |
696 | if( f.exists()) { | 702 | if( f.exists()) { |
697 | if(!copyFile( destFile, curFile) ) { | 703 | if(!copyFile( destFile, curFile) ) { |
698 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | 704 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); |
699 | return; | 705 | return; |
700 | } else | 706 | } else |
701 | QFile::remove( curFile); | 707 | QFile::remove( curFile); |
702 | } | 708 | } |
703 | TabWidget->setCurrentPage(0); | 709 | TabWidget->setCurrentPage(0); |
704 | } | 710 | } |
705 | } | 711 | } |
706 | populateRemoteView(); | 712 | populateRemoteView(); |
707 | populateLocalView(); | 713 | populateLocalView(); |
708 | } | 714 | } |
709 | } | 715 | } |
710 | 716 | ||
711 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { | 717 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { |
712 | char bf[ 50000 ]; | 718 | char bf[ 50000 ]; |
713 | int bytesRead; | 719 | int bytesRead; |
714 | bool success = TRUE; | 720 | bool success = TRUE; |
715 | struct stat status; | 721 | struct stat status; |
716 | 722 | ||
717 | QFile s( src ); | 723 | QFile s( src ); |
718 | QFile d( dest ); | 724 | QFile d( dest ); |
719 | 725 | ||
720 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 726 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
721 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 727 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
722 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 728 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
723 | success = FALSE; | 729 | success = FALSE; |
724 | break; | 730 | break; |
725 | } | 731 | } |
726 | } | 732 | } |
727 | if( success && (bytesRead > 0) ){ | 733 | if( success && (bytesRead > 0) ){ |
728 | d.writeBlock( bf, bytesRead ); | 734 | d.writeBlock( bf, bytesRead ); |
729 | } | 735 | } |
730 | } else { | 736 | } else { |
731 | success = FALSE; | 737 | success = FALSE; |
732 | } | 738 | } |
733 | 739 | ||
734 | // Set file permissions | 740 | // Set file permissions |
735 | if( stat( (const char *) src, &status ) == 0 ){ | 741 | if( stat( (const char *) src, &status ) == 0 ){ |
736 | chmod( (const char *) dest, status.st_mode ); | 742 | chmod( (const char *) dest, status.st_mode ); |
737 | } | 743 | } |
738 | 744 | ||
739 | return success; | 745 | return success; |
740 | } | 746 | } |
741 | 747 | ||
742 | void AdvancedFm::runCommand() { | 748 | void AdvancedFm::runCommand() { |
743 | QString curFile; | 749 | QString curFile; |
744 | if (TabWidget->currentPageIndex() == 0) { | 750 | if (TabWidget->currentPageIndex() == 0) { |