author | llornkcor <llornkcor> | 2003-02-24 02:38:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-24 02:38:01 (UTC) |
commit | e144592570ddacf26d27f3e2759dbe7f2370d0a0 (patch) (unidiff) | |
tree | 054221a40b03bd91945161570a8996a5427e6456 | |
parent | 56b89312a374b62ee20f6ad2b62b6426183d4d26 (diff) | |
download | opie-e144592570ddacf26d27f3e2759dbe7f2370d0a0.zip opie-e144592570ddacf26d27f3e2759dbe7f2370d0a0.tar.gz opie-e144592570ddacf26d27f3e2759dbe7f2370d0a0.tar.bz2 |
cleanup
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 200 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 6 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 102 |
3 files changed, 87 insertions, 221 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 74654fc..fc6c3bf 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,1002 +1,890 @@ | |||
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 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
14 | 14 | ||
15 | #include <opie/otabwidget.h> | 15 | #include <opie/otabwidget.h> |
16 | // #include <opie/ofileselector.h> | 16 | // #include <opie/ofileselector.h> |
17 | // #include <opie/ofiledialog.h> | 17 | // #include <opie/ofiledialog.h> |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qpe/filemanager.h> | 20 | #include <qpe/filemanager.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/mimetype.h> | 27 | #include <qpe/mimetype.h> |
28 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
29 | #include <qpe/ir.h> | 29 | #include <qpe/ir.h> |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qpe/menubutton.h> | 31 | #include <qpe/menubutton.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
36 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qstring.h> | 41 | #include <qstring.h> |
42 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
43 | #include <qpopupmenu.h> | 43 | #include <qpopupmenu.h> |
44 | #include <qlistview.h> | 44 | #include <qlistview.h> |
45 | #include <qmainwindow.h> | 45 | #include <qmainwindow.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qprogressbar.h> | 47 | #include <qprogressbar.h> |
48 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
49 | #include <qwidget.h> | 49 | #include <qwidget.h> |
50 | #include <qlayout.h> | 50 | #include <qlayout.h> |
51 | #include <qimage.h> | 51 | #include <qimage.h> |
52 | #include <qpixmap.h> | 52 | #include <qpixmap.h> |
53 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
54 | #include <qlineedit.h> | 54 | #include <qlineedit.h> |
55 | #include <qregexp.h> | 55 | #include <qregexp.h> |
56 | 56 | ||
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | #include <stdlib.h> | 58 | #include <stdlib.h> |
59 | #include <sys/stat.h> | 59 | #include <sys/stat.h> |
60 | #include <dirent.h> | 60 | #include <dirent.h> |
61 | #include <stdio.h> | 61 | #include <stdio.h> |
62 | #include <time.h> | 62 | #include <time.h> |
63 | #include <fcntl.h> | 63 | #include <fcntl.h> |
64 | #include <mntent.h> | 64 | #include <mntent.h> |
65 | #include <string.h> | 65 | #include <string.h> |
66 | #include <errno.h> | 66 | #include <errno.h> |
67 | #include <sys/vfs.h> | 67 | #include <sys/vfs.h> |
68 | #include <mntent.h> | 68 | #include <mntent.h> |
69 | #include <sys/utsname.h> | 69 | #include <sys/utsname.h> |
70 | 70 | ||
71 | AdvancedFm::AdvancedFm( ) | 71 | AdvancedFm::AdvancedFm( ) |
72 | : QMainWindow( ) { | 72 | : QMainWindow( ) { |
73 | init(); | 73 | init(); |
74 | renameBox = 0; | 74 | renameBox = 0; |
75 | 75 | ||
76 | initConnections(); | 76 | initConnections(); |
77 | populateLocalView(); | 77 | TabWidget->setCurrentTab(1); |
78 | populateRemoteView(); | 78 | populateView(); |
79 | TabWidget->setCurrentTab(0); | ||
80 | populateView(); | ||
79 | currentPathCombo->setFocus(); | 81 | currentPathCombo->setFocus(); |
80 | } | 82 | } |
81 | 83 | ||
82 | AdvancedFm::~AdvancedFm() { | 84 | AdvancedFm::~AdvancedFm() { |
83 | } | 85 | } |
84 | 86 | ||
85 | 87 | ||
86 | void AdvancedFm::cleanUp() | 88 | void AdvancedFm::cleanUp() |
87 | { | 89 | { |
88 | QString sfile=QDir::homeDirPath(); | 90 | QString sfile=QDir::homeDirPath(); |
89 | if(sfile.right(1) != "/") | 91 | if(sfile.right(1) != "/") |
90 | sfile+="/._temp"; | 92 | sfile+="/._temp"; |
91 | else | 93 | else |
92 | sfile+="._temp"; | 94 | sfile+="._temp"; |
93 | QFile file( sfile); | 95 | QFile file( sfile); |
94 | if(file.exists()) | 96 | if(file.exists()) |
95 | file.remove(); | 97 | file.remove(); |
96 | } | 98 | } |
97 | 99 | ||
98 | void AdvancedFm::tabChanged(QWidget *w) | 100 | void AdvancedFm::tabChanged(QWidget *w) |
99 | { | 101 | { |
100 | if( w == tab) | 102 | if( w == tab) |
101 | whichTab = 1; | 103 | whichTab = 1; |
102 | else | 104 | else |
103 | whichTab = 2; | 105 | whichTab = 2; |
104 | 106 | ||
105 | //qDebug("tab changed %d", whichTab ); | 107 | //qDebug("tab changed %d", whichTab ); |
106 | 108 | ||
107 | QString path = CurrentDir()->canonicalPath(); | 109 | QString path = CurrentDir()->canonicalPath(); |
108 | currentPathCombo->lineEdit()->setText( path ); | 110 | currentPathCombo->lineEdit()->setText( path ); |
109 | 111 | ||
110 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 112 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
111 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 113 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
112 | 114 | ||
113 | QString fs= getFileSystemType( (const QString &) path); | 115 | QString fs= getFileSystemType( (const QString &) path); |
114 | 116 | ||
115 | setCaption("AdvancedFm :: "+fs+" :: " | 117 | setCaption("AdvancedFm :: "+fs+" :: " |
116 | +checkDiskSpace( (const QString &) path )+ " kB free" ); | 118 | +checkDiskSpace( (const QString &) path )+ " kB free" ); |
117 | chdir( path.latin1()); | 119 | chdir( path.latin1()); |
120 | //2populateView(); | ||
118 | } | 121 | } |
119 | 122 | ||
120 | 123 | ||
121 | void AdvancedFm::populateLocalView() | 124 | void AdvancedFm::populateView() |
122 | { | 125 | { |
123 | QPixmap pm; | 126 | QPixmap pm; |
124 | Local_View->clear(); | 127 | QListView *thisView = CurrentView(); |
125 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 128 | QDir *thisDir = CurrentDir(); |
126 | currentDir.setMatchAllDirs(TRUE); | 129 | QString path = thisDir->canonicalPath(); |
127 | currentDir.setNameFilter(filterStr); | 130 | |
131 | thisView->clear(); | ||
132 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | ||
133 | thisDir->setMatchAllDirs(TRUE); | ||
134 | thisDir->setNameFilter(filterStr); | ||
128 | QString fileL, fileS, fileDate; | 135 | QString fileL, fileS, fileDate; |
129 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 136 | QString fs= getFileSystemType((const QString &) path); |
130 | setCaption("AdvancedFm :: "+fs+" :: " | 137 | setCaption("AdvancedFm :: "+fs+" :: " |
131 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 138 | +checkDiskSpace((const QString &) path)+" kB free" ); |
132 | bool isDir=FALSE; | 139 | bool isDir=FALSE; |
133 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 140 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
134 | QFileInfoListIterator it(*list); | 141 | QFileInfoListIterator it(*list); |
135 | QFileInfo *fi; | 142 | QFileInfo *fi; |
136 | while ( (fi=it.current()) ) | 143 | while ( (fi=it.current()) ) |
137 | { | 144 | { |
138 | if (fi->isSymLink() ) | 145 | if (fi->isSymLink() ) |
139 | { | 146 | { |
140 | QString symLink=fi->readLink(); | 147 | QString symLink=fi->readLink(); |
141 | QFileInfo sym( symLink); | 148 | QFileInfo sym( symLink); |
142 | fileS.sprintf( "%10i", sym.size() ); | 149 | fileS.sprintf( "%10i", sym.size() ); |
143 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 150 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
144 | fileDate = sym.lastModified().toString(); | 151 | fileDate = sym.lastModified().toString(); |
145 | } | 152 | } |
146 | else | 153 | else |
147 | { | 154 | { |
148 | fileS.sprintf( "%10i", fi->size() ); | 155 | fileS.sprintf( "%10i", fi->size() ); |
149 | fileL.sprintf( "%s",fi->fileName().data() ); | 156 | fileL.sprintf( "%s",fi->fileName().data() ); |
150 | fileDate= fi->lastModified().toString(); | 157 | fileDate= fi->lastModified().toString(); |
151 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) | 158 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) |
152 | { | 159 | { |
153 | fileL+="/"; | 160 | fileL+="/"; |
154 | isDir=TRUE; | 161 | isDir=TRUE; |
155 | } | 162 | } |
156 | } | 163 | } |
157 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 164 | |
165 | QFileInfo fileInfo( path + "/" + fileL); | ||
166 | |||
158 | if(fileL !="./" && fi->exists()) | 167 | if(fileL !="./" && fi->exists()) |
159 | { | 168 | { |
160 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 169 | item= new QListViewItem( thisView, fileL, fileS , fileDate); |
161 | 170 | ||
162 | if(isDir || fileL.find("/",0,TRUE) != -1) | 171 | if(isDir || fileL.find("/",0,TRUE) != -1) |
163 | { | 172 | { |
164 | 173 | ||
165 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 174 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
166 | pm = Resource::loadPixmap( "lockedfolder" ); | 175 | pm = Resource::loadPixmap( "lockedfolder" ); |
167 | else | 176 | else |
168 | pm= Resource::loadPixmap( "folder" ); | 177 | pm= Resource::loadPixmap( "folder" ); |
169 | } | 178 | } |
170 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) | 179 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) |
171 | { | 180 | { |
172 | pm = Resource::loadPixmap( "exec"); | 181 | pm = Resource::loadPixmap( "exec"); |
173 | } | 182 | } |
174 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 183 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
175 | | fileInfo.permission( QFileInfo::ExeGroup) | 184 | | fileInfo.permission( QFileInfo::ExeGroup) |
176 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) | 185 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) |
177 | { | 186 | { |
178 | pm = Resource::loadPixmap( "exec"); | 187 | pm = Resource::loadPixmap( "exec"); |
179 | } | 188 | } |
180 | else if( !fi->isReadable() ) | 189 | else if( !fi->isReadable() ) |
181 | { | 190 | { |
182 | pm = Resource::loadPixmap( "locked" ); | 191 | pm = Resource::loadPixmap( "locked" ); |
183 | } | 192 | } |
184 | else { //everything else goes by mimetype | 193 | else { //everything else goes by mimetype |
185 | MimeType mt(fi->filePath()); | 194 | MimeType mt(fi->filePath()); |
186 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 195 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
187 | if(pm.isNull()) | 196 | if(pm.isNull()) |
188 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 197 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
189 | } | 198 | } |
190 | item->setPixmap( 0,pm); | 199 | item->setPixmap( 0,pm); |
191 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) | 200 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) |
192 | { | 201 | { |
193 | // overlay link image | 202 | // overlay link image |
194 | pm= Resource::loadPixmap( "folder" ); | 203 | pm= Resource::loadPixmap( "folder" ); |
195 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 204 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
196 | QPainter painter( &pm ); | 205 | QPainter painter( &pm ); |
197 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 206 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
198 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 207 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
199 | item->setPixmap( 0, pm); | 208 | item->setPixmap( 0, pm); |
200 | } | 209 | } |
201 | } | 210 | } |
202 | isDir=FALSE; | 211 | isDir=FALSE; |
203 | ++it; | 212 | ++it; |
204 | } | 213 | } |
205 | 214 | ||
206 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) | 215 | if( path.find("dev",0,TRUE) != -1) |
207 | { | 216 | { |
208 | struct stat buf; | 217 | struct stat buf; |
209 | dev_t devT; | 218 | dev_t devT; |
210 | DIR *dir; | 219 | DIR *dir; |
211 | struct dirent *mydirent; | 220 | struct dirent *mydirent; |
212 | 221 | ||
213 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 222 | if((dir = opendir( path.latin1())) != NULL) |
214 | while ((mydirent = readdir(dir)) != NULL) | 223 | while ((mydirent = readdir(dir)) != NULL) |
215 | { | 224 | { |
216 | lstat( mydirent->d_name, &buf); | 225 | lstat( mydirent->d_name, &buf); |
217 | // qDebug(mydirent->d_name); | 226 | // qDebug(mydirent->d_name); |
218 | fileL.sprintf("%s", mydirent->d_name); | 227 | fileL.sprintf("%s", mydirent->d_name); |
219 | devT = buf.st_dev; | 228 | devT = buf.st_dev; |
220 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 229 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
221 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 230 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
222 | if( fileL.find(".") == -1 ) | 231 | if( fileL.find(".") == -1 ) |
223 | { | 232 | { |
224 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 233 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
225 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 234 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
226 | item->setPixmap( 0,pm); | 235 | item->setPixmap( 0,pm); |
227 | } | 236 | } |
228 | } | 237 | } |
229 | 238 | ||
230 | closedir(dir); | 239 | closedir(dir); |
231 | } | 240 | } |
232 | 241 | ||
233 | Local_View->setSorting( 3,FALSE); | 242 | thisView->setSorting( 3,FALSE); |
234 | fillCombo( (const QString &) currentDir.canonicalPath()); | 243 | fillCombo( (const QString &) path ); |
235 | } | 244 | } |
236 | 245 | ||
237 | 246 | ||
238 | void AdvancedFm::populateRemoteView() | ||
239 | { | ||
240 | QPixmap pm; | ||
241 | Remote_View->clear(); | ||
242 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | ||
243 | currentRemoteDir.setMatchAllDirs(TRUE); | ||
244 | currentRemoteDir.setNameFilter(filterStr); | ||
245 | QString fileL, fileS, fileDate; | ||
246 | |||
247 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | ||
248 | setCaption("AdvancedFm :: "+fs+" :: " | ||
249 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | ||
250 | bool isDir=FALSE; | ||
251 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | ||
252 | QFileInfoListIterator it(*list); | ||
253 | QFileInfo *fi; | ||
254 | while ( (fi=it.current()) ) | ||
255 | { | ||
256 | if (fi->isSymLink() ) | ||
257 | { | ||
258 | QString symLink=fi->readLink(); | ||
259 | // qDebug("Symlink detected "+symLink); | ||
260 | QFileInfo sym( symLink); | ||
261 | fileS.sprintf( "%10i", sym.size() ); | ||
262 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | ||
263 | fileDate = sym.lastModified().toString(); | ||
264 | } | ||
265 | else | ||
266 | { | ||
267 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | ||
268 | fileS.sprintf( "%10i", fi->size() ); | ||
269 | fileL.sprintf( "%s",fi->fileName().data() ); | ||
270 | fileDate= fi->lastModified().toString(); | ||
271 | |||
272 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) | ||
273 | { | ||
274 | fileL+="/"; | ||
275 | isDir=TRUE; | ||
276 | // qDebug( fileL); | ||
277 | } | ||
278 | } | ||
279 | |||
280 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); | ||
281 | if(fileL !="./" && fi->exists()) | ||
282 | { | ||
283 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | ||
284 | QPixmap pm; | ||
285 | |||
286 | if(isDir || fileL.find("/",0,TRUE) != -1) | ||
287 | { | ||
288 | if( !QDir( fi->filePath() ).isReadable()) | ||
289 | pm = Resource::loadPixmap( "lockedfolder" ); | ||
290 | else | ||
291 | pm= Resource::loadPixmap( "folder" ); | ||
292 | } | ||
293 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) | ||
294 | { | ||
295 | pm = Resource::loadPixmap( "exec"); | ||
296 | } | ||
297 | else if( (fileInfo.permission( QFileInfo::ExeUser) | ||
298 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
299 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) | ||
300 | { | ||
301 | pm = Resource::loadPixmap( "exec"); | ||
302 | } | ||
303 | else if( !fi->isReadable() ) | ||
304 | { | ||
305 | pm = Resource::loadPixmap( "locked" ); | ||
306 | } | ||
307 | else | ||
308 | { | ||
309 | MimeType mt(fi->filePath()); | ||
310 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | ||
311 | if(pm.isNull()) | ||
312 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | ||
313 | } | ||
314 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) | ||
315 | { | ||
316 | // overlay link image | ||
317 | pm= Resource::loadPixmap( "folder" ); | ||
318 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | ||
319 | QPainter painter( &pm ); | ||
320 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
321 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
322 | } | ||
323 | item->setPixmap( 0, pm); | ||
324 | } | ||
325 | isDir=FALSE; | ||
326 | ++it; | ||
327 | } | ||
328 | |||
329 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) | ||
330 | { | ||
331 | struct stat buf; | ||
332 | DIR *dir; | ||
333 | struct dirent *mydirent; | ||
334 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | ||
335 | |||
336 | while ((mydirent = readdir(dir)) != NULL) | ||
337 | { | ||
338 | lstat( mydirent->d_name, &buf); | ||
339 | // qDebug(mydirent->d_name); | ||
340 | fileL.sprintf("%s", mydirent->d_name); | ||
341 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | ||
342 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | ||
343 | |||
344 | if( fileL.find(".") == -1 ) | ||
345 | { | ||
346 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | ||
347 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | ||
348 | item->setPixmap( 0,pm); | ||
349 | } | ||
350 | } | ||
351 | |||
352 | closedir(dir); | ||
353 | } | ||
354 | |||
355 | Remote_View->setSorting( 3,FALSE); | ||
356 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | ||
357 | } | ||
358 | |||
359 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) | 247 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) |
360 | { | 248 | { |
361 | if(selectedItem) | 249 | if(selectedItem) |
362 | { | 250 | { |
363 | QString strItem=selectedItem->text(0); | 251 | QString strItem=selectedItem->text(0); |
364 | QString strSize=selectedItem->text(1); | 252 | QString strSize=selectedItem->text(1); |
365 | strSize=strSize.stripWhiteSpace(); | 253 | strSize=strSize.stripWhiteSpace(); |
366 | bool isDirectory = false; | 254 | bool isDirectory = false; |
367 | QString strItem2; | 255 | QString strItem2; |
368 | 256 | ||
369 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink | 257 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink |
370 | { | 258 | { |
371 | strItem2 = dealWithSymName((const QString&)strItem); | 259 | strItem2 = dealWithSymName((const QString&)strItem); |
372 | if(QDir(strItem2).exists() ) | 260 | if(QDir(strItem2).exists() ) |
373 | strItem = strItem2; | 261 | strItem = strItem2; |
374 | } | 262 | } |
375 | 263 | ||
376 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) | 264 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) |
377 | { | 265 | { |
378 | 266 | ||
379 | if(QDir(strItem).exists()) | 267 | if(QDir(strItem).exists()) |
380 | isDirectory = true; | 268 | isDirectory = true; |
381 | } | 269 | } |
382 | 270 | ||
383 | if( isDirectory ) | 271 | if( isDirectory ) |
384 | { | 272 | { |
385 | CurrentDir()->cd( strItem, TRUE); | 273 | CurrentDir()->cd( strItem, TRUE); |
386 | PopulateView(); | 274 | populateView(); |
387 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 275 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
388 | } | 276 | } |
389 | chdir( strItem.latin1()); | 277 | chdir( strItem.latin1()); |
390 | } | 278 | } |
391 | } | 279 | } |
392 | 280 | ||
393 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 281 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
394 | switch (mouse) { | 282 | switch (mouse) { |
395 | case 1: | 283 | case 1: |
396 | { | 284 | { |
397 | if(renameBox != 0 ) | 285 | if(renameBox != 0 ) |
398 | { | 286 | { |
399 | cancelRename(); | 287 | cancelRename(); |
400 | } | 288 | } |
401 | 289 | ||
402 | } | 290 | } |
403 | break; | 291 | break; |
404 | case 2: | 292 | case 2: |
405 | menuTimer.start( 500, TRUE ); | 293 | menuTimer.start( 500, TRUE ); |
406 | break; | 294 | break; |
407 | }; | 295 | }; |
408 | } | 296 | } |
409 | 297 | ||
410 | void AdvancedFm::switchToLocalTab() | 298 | void AdvancedFm::switchToLocalTab() |
411 | { | 299 | { |
412 | TabWidget->setCurrentTab(0); | 300 | TabWidget->setCurrentTab(0); |
413 | Local_View->setFocus(); | 301 | Local_View->setFocus(); |
414 | } | 302 | } |
415 | 303 | ||
416 | void AdvancedFm::switchToRemoteTab() | 304 | void AdvancedFm::switchToRemoteTab() |
417 | { | 305 | { |
418 | TabWidget->setCurrentTab(1); | 306 | TabWidget->setCurrentTab(1); |
419 | Remote_View->setFocus(); | 307 | Remote_View->setFocus(); |
420 | } | 308 | } |
421 | 309 | ||
422 | void AdvancedFm::readConfig() | 310 | void AdvancedFm::readConfig() |
423 | { | 311 | { |
424 | Config cfg("AdvancedFm"); | 312 | Config cfg("AdvancedFm"); |
425 | } | 313 | } |
426 | 314 | ||
427 | void AdvancedFm::writeConfig() | 315 | void AdvancedFm::writeConfig() |
428 | { | 316 | { |
429 | Config cfg("AdvancedFm"); | 317 | Config cfg("AdvancedFm"); |
430 | } | 318 | } |
431 | 319 | ||
432 | void AdvancedFm::currentPathComboChanged() | 320 | void AdvancedFm::currentPathComboChanged() |
433 | { | 321 | { |
434 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) | 322 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) |
435 | { | 323 | { |
436 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 324 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
437 | PopulateView(); | 325 | populateView(); |
438 | } | 326 | } |
439 | else | 327 | else |
440 | { | 328 | { |
441 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 329 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
442 | } | 330 | } |
443 | } | 331 | } |
444 | 332 | ||
445 | void AdvancedFm::fillCombo(const QString ¤tPath) | 333 | void AdvancedFm::fillCombo(const QString ¤tPath) |
446 | { | 334 | { |
447 | // qDebug("%d",TabWidget->getCurrentTab()); | 335 | // qDebug("%d",TabWidget->getCurrentTab()); |
448 | if ( whichTab == 1) | 336 | if ( whichTab == 1) |
449 | { | 337 | { |
450 | currentPathCombo->lineEdit()->setText( currentPath); | 338 | currentPathCombo->lineEdit()->setText( currentPath); |
451 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 339 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) |
452 | { | 340 | { |
453 | currentPathCombo->clear(); | 341 | currentPathCombo->clear(); |
454 | localDirPathStringList.prepend( currentPath ); | 342 | localDirPathStringList.prepend( currentPath ); |
455 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 343 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
456 | } | 344 | } |
457 | } | 345 | } |
458 | else | 346 | else |
459 | { | 347 | { |
460 | currentPathCombo->lineEdit()->setText( currentPath); | 348 | currentPathCombo->lineEdit()->setText( currentPath); |
461 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 349 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) |
462 | { | 350 | { |
463 | currentPathCombo->clear(); | 351 | currentPathCombo->clear(); |
464 | remoteDirPathStringList.prepend( currentPath ); | 352 | remoteDirPathStringList.prepend( currentPath ); |
465 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 353 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
466 | } | 354 | } |
467 | } | 355 | } |
468 | } | 356 | } |
469 | 357 | ||
470 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) | 358 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) |
471 | { | 359 | { |
472 | chdir( currentPath.latin1() ); | 360 | chdir( currentPath.latin1() ); |
473 | CurrentDir()->cd( currentPath, TRUE); | 361 | CurrentDir()->cd( currentPath, TRUE); |
474 | PopulateView(); | 362 | populateView(); |
475 | update(); | 363 | update(); |
476 | } | 364 | } |
477 | 365 | ||
478 | QStringList AdvancedFm::getPath() | 366 | QStringList AdvancedFm::getPath() |
479 | { | 367 | { |
480 | QStringList strList; | 368 | QStringList strList; |
481 | QListView *thisView=CurrentView(); | 369 | QListView *thisView=CurrentView(); |
482 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 370 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
483 | QListViewItemIterator it( thisView ); | 371 | QListViewItemIterator it( thisView ); |
484 | for ( ; it.current(); ++it ) | 372 | for ( ; it.current(); ++it ) |
485 | { | 373 | { |
486 | if ( it.current()->isSelected() ) | 374 | if ( it.current()->isSelected() ) |
487 | { | 375 | { |
488 | strList << it.current()->text(0); | 376 | strList << it.current()->text(0); |
489 | // qDebug(it.current()->text(0)); | 377 | // qDebug(it.current()->text(0)); |
490 | } | 378 | } |
491 | } | 379 | } |
492 | return strList; | 380 | return strList; |
493 | } | 381 | } |
494 | 382 | ||
495 | void AdvancedFm::homeButtonPushed() | 383 | void AdvancedFm::homeButtonPushed() |
496 | { | 384 | { |
497 | QString current = QDir::homeDirPath(); | 385 | QString current = QDir::homeDirPath(); |
498 | chdir( current.latin1() ); | 386 | chdir( current.latin1() ); |
499 | CurrentDir()->cd( current, TRUE); | 387 | CurrentDir()->cd( current, TRUE); |
500 | PopulateView(); | 388 | populateView(); |
501 | update(); | 389 | update(); |
502 | } | 390 | } |
503 | 391 | ||
504 | void AdvancedFm::docButtonPushed() | 392 | void AdvancedFm::docButtonPushed() |
505 | { | 393 | { |
506 | QString current = QPEApplication::documentDir(); | 394 | QString current = QPEApplication::documentDir(); |
507 | chdir( current.latin1() ); | 395 | chdir( current.latin1() ); |
508 | 396 | ||
509 | CurrentDir()->cd( current, TRUE); | 397 | CurrentDir()->cd( current, TRUE); |
510 | PopulateView(); | 398 | populateView(); |
511 | update(); | 399 | update(); |
512 | } | 400 | } |
513 | 401 | ||
514 | void AdvancedFm::SDButtonPushed() | 402 | void AdvancedFm::SDButtonPushed() |
515 | { | 403 | { |
516 | QString current = "/mnt/card";// this can change so fix | 404 | QString current = "/mnt/card";// this can change so fix |
517 | chdir( current.latin1() ); | 405 | chdir( current.latin1() ); |
518 | CurrentDir()->cd( current, TRUE); | 406 | CurrentDir()->cd( current, TRUE); |
519 | PopulateView(); | 407 | populateView(); |
520 | update(); | 408 | update(); |
521 | } | 409 | } |
522 | 410 | ||
523 | void AdvancedFm::CFButtonPushed() | 411 | void AdvancedFm::CFButtonPushed() |
524 | { | 412 | { |
525 | QString current; | 413 | QString current; |
526 | if(zaurusDevice) | 414 | if(zaurusDevice) |
527 | current= "/mnt/cf"; //zaurus | 415 | current= "/mnt/cf"; //zaurus |
528 | else | 416 | else |
529 | current = "/mnt/hda"; //ipaq | 417 | current = "/mnt/hda"; //ipaq |
530 | 418 | ||
531 | chdir( current.latin1() ); | 419 | chdir( current.latin1() ); |
532 | CurrentDir()->cd( current, TRUE); | 420 | CurrentDir()->cd( current, TRUE); |
533 | PopulateView(); | 421 | populateView(); |
534 | update(); | 422 | update(); |
535 | } | 423 | } |
536 | 424 | ||
537 | 425 | ||
538 | void AdvancedFm::doAbout() | 426 | void AdvancedFm::doAbout() |
539 | { | 427 | { |
540 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 428 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
541 | "is copyright 2002-2003 by\n" | 429 | "is copyright 2002-2003 by\n" |
542 | "L.J.Potter<llornkcor@handhelds.org>\n" | 430 | "L.J.Potter<llornkcor@handhelds.org>\n" |
543 | "and is licensed by the GPL")); | 431 | "and is licensed by the GPL")); |
544 | } | 432 | } |
545 | 433 | ||
546 | void AdvancedFm::keyPressEvent( QKeyEvent *e) | 434 | void AdvancedFm::keyPressEvent( QKeyEvent *e) |
547 | { | 435 | { |
548 | // e->accept(); | 436 | // e->accept(); |
549 | if( CurrentView()->hasFocus() ) | 437 | if( CurrentView()->hasFocus() ) |
550 | { | 438 | { |
551 | switch ( e->key() ) { | 439 | switch ( e->key() ) { |
552 | case Key_Delete: | 440 | case Key_Delete: |
553 | del(); | 441 | del(); |
554 | break; | 442 | break; |
555 | case Key_A: | 443 | case Key_A: |
556 | copyAs(); | 444 | copyAs(); |
557 | break; | 445 | break; |
558 | case Key_C: | 446 | case Key_C: |
559 | copy(); | 447 | copy(); |
560 | break; | 448 | break; |
561 | case Key_E: | 449 | case Key_E: |
562 | runThis(); | 450 | runThis(); |
563 | break; | 451 | break; |
564 | case Key_G: | 452 | case Key_G: |
565 | { | 453 | { |
566 | currentPathCombo->lineEdit()->setFocus(); | 454 | currentPathCombo->lineEdit()->setFocus(); |
567 | } | 455 | } |
568 | break; | 456 | break; |
569 | 457 | ||
570 | case Key_H: | 458 | case Key_H: |
571 | showHidden(); | 459 | showHidden(); |
572 | break; | 460 | break; |
573 | case Key_I: | 461 | case Key_I: |
574 | fileStatus(); | 462 | fileStatus(); |
575 | break; | 463 | break; |
576 | case Key_M: | 464 | case Key_M: |
577 | move(); | 465 | move(); |
578 | break; | 466 | break; |
579 | case Key_N: | 467 | case Key_N: |
580 | mkDir(); | 468 | mkDir(); |
581 | break; | 469 | break; |
582 | case Key_P: | 470 | case Key_P: |
583 | filePerms(); | 471 | filePerms(); |
584 | break; | 472 | break; |
585 | case Key_R: | 473 | case Key_R: |
586 | rn(); | 474 | rn(); |
587 | break; | 475 | break; |
588 | case Key_U: | 476 | case Key_U: |
589 | upDir(); | 477 | upDir(); |
590 | break; | 478 | break; |
591 | case Key_1: | 479 | case Key_1: |
592 | switchToLocalTab(); | 480 | switchToLocalTab(); |
593 | break; | 481 | break; |
594 | case Key_2: | 482 | case Key_2: |
595 | switchToRemoteTab(); | 483 | switchToRemoteTab(); |
596 | break; | 484 | break; |
597 | case Key_3: | 485 | case Key_3: |
598 | CFButtonPushed(); | 486 | CFButtonPushed(); |
599 | break; | 487 | break; |
600 | case Key_4: | 488 | case Key_4: |
601 | SDButtonPushed(); | 489 | SDButtonPushed(); |
602 | break; | 490 | break; |
603 | case Key_5: | 491 | case Key_5: |
604 | homeButtonPushed(); | 492 | homeButtonPushed(); |
605 | break; | 493 | break; |
606 | case Key_6: | 494 | case Key_6: |
607 | docButtonPushed(); | 495 | docButtonPushed(); |
608 | break; | 496 | break; |
609 | case Key_7: | 497 | case Key_7: |
610 | break; | 498 | break; |
611 | case Key_8: | 499 | case Key_8: |
612 | break; | 500 | break; |
613 | case Key_9: | 501 | case Key_9: |
614 | break; | 502 | break; |
615 | case Key_0: | 503 | case Key_0: |
616 | break; | 504 | break; |
617 | }; | 505 | }; |
618 | e->accept(); | 506 | e->accept(); |
619 | } | 507 | } |
620 | } | 508 | } |
621 | 509 | ||
622 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 510 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
623 | { | 511 | { |
624 | if( CurrentView()->hasFocus() ) | 512 | if( CurrentView()->hasFocus() ) |
625 | e->ignore(); | 513 | e->ignore(); |
626 | } | 514 | } |
627 | 515 | ||
628 | 516 | ||
629 | void AdvancedFm::QPEButtonPushed() | 517 | void AdvancedFm::QPEButtonPushed() |
630 | { | 518 | { |
631 | QString current = QPEApplication::qpeDir(); | 519 | QString current = QPEApplication::qpeDir(); |
632 | chdir( current.latin1() ); | 520 | chdir( current.latin1() ); |
633 | CurrentDir()->cd( current, TRUE); | 521 | CurrentDir()->cd( current, TRUE); |
634 | PopulateView(); | 522 | populateView(); |
635 | update(); | 523 | update(); |
636 | } | 524 | } |
637 | 525 | ||
638 | void AdvancedFm::parsetab(const QString &fileName) | 526 | void AdvancedFm::parsetab(const QString &fileName) |
639 | { | 527 | { |
640 | 528 | ||
641 | fileSystemTypeList.clear(); | 529 | fileSystemTypeList.clear(); |
642 | fsList.clear(); | 530 | fsList.clear(); |
643 | struct mntent *me; | 531 | struct mntent *me; |
644 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 532 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
645 | if ( mntfp ) | 533 | if ( mntfp ) |
646 | { | 534 | { |
647 | while ( (me = getmntent( mntfp )) != 0 ) | 535 | while ( (me = getmntent( mntfp )) != 0 ) |
648 | { | 536 | { |
649 | QString deviceName = me->mnt_fsname; | 537 | QString deviceName = me->mnt_fsname; |
650 | QString filesystemType = me->mnt_type; | 538 | QString filesystemType = me->mnt_type; |
651 | QString mountDir = me->mnt_dir; | 539 | QString mountDir = me->mnt_dir; |
652 | if(deviceName != "none") | 540 | if(deviceName != "none") |
653 | { | 541 | { |
654 | if( fsList.contains(filesystemType) == 0 | 542 | if( fsList.contains(filesystemType) == 0 |
655 | & filesystemType.find("proc",0,TRUE) == -1 | 543 | & filesystemType.find("proc",0,TRUE) == -1 |
656 | & filesystemType.find("cramfs",0,TRUE) == -1 | 544 | & filesystemType.find("cramfs",0,TRUE) == -1 |
657 | & filesystemType.find("auto",0,TRUE) == -1) | 545 | & filesystemType.find("auto",0,TRUE) == -1) |
658 | fsList << filesystemType; | 546 | fsList << filesystemType; |
659 | fileSystemTypeList << mountDir+"::"+filesystemType; | 547 | fileSystemTypeList << mountDir+"::"+filesystemType; |
660 | } | 548 | } |
661 | } | 549 | } |
662 | } | 550 | } |
663 | endmntent( mntfp ); | 551 | endmntent( mntfp ); |
664 | } | 552 | } |
665 | 553 | ||
666 | QString AdvancedFm::getFileSystemType(const QString ¤tText) | 554 | QString AdvancedFm::getFileSystemType(const QString ¤tText) |
667 | { | 555 | { |
668 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 556 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
669 | QString current = currentText;//.right( currentText.length()-1); | 557 | QString current = currentText;//.right( currentText.length()-1); |
670 | QString baseFs; | 558 | QString baseFs; |
671 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 559 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
672 | QString temp = (*it); | 560 | QString temp = (*it); |
673 | QString path = temp.left(temp.find("::",0,TRUE) ); | 561 | QString path = temp.left(temp.find("::",0,TRUE) ); |
674 | path = path.right( path.length()-1); | 562 | path = path.right( path.length()-1); |
675 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 563 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
676 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 564 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
677 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 565 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
678 | } | 566 | } |
679 | } | 567 | } |
680 | return baseFs; | 568 | return baseFs; |
681 | } | 569 | } |
682 | 570 | ||
683 | QString AdvancedFm::getDiskSpace( const QString &path) | 571 | QString AdvancedFm::getDiskSpace( const QString &path) |
684 | { | 572 | { |
685 | struct statfs fss; | 573 | struct statfs fss; |
686 | if ( !statfs( path.latin1(), &fss ) ) { | 574 | if ( !statfs( path.latin1(), &fss ) ) { |
687 | int blkSize = fss.f_bsize; | 575 | int blkSize = fss.f_bsize; |
688 | // int totalBlks = fs.f_blocks; | 576 | // int totalBlks = fs.f_blocks; |
689 | int availBlks = fss.f_bavail; | 577 | int availBlks = fss.f_bavail; |
690 | 578 | ||
691 | long mult = blkSize / 1024; | 579 | long mult = blkSize / 1024; |
692 | long div = 1024 / blkSize; | 580 | long div = 1024 / blkSize; |
693 | if ( !mult ) mult = 1; | 581 | if ( !mult ) mult = 1; |
694 | if ( !div ) div = 1; | 582 | if ( !div ) div = 1; |
695 | 583 | ||
696 | return QString::number(availBlks * mult / div); | 584 | return QString::number(availBlks * mult / div); |
697 | } | 585 | } |
698 | return ""; | 586 | return ""; |
699 | } | 587 | } |
700 | 588 | ||
701 | 589 | ||
702 | void AdvancedFm::showFileMenu() | 590 | void AdvancedFm::showFileMenu() |
703 | { | 591 | { |
704 | QString curApp; | 592 | QString curApp; |
705 | curApp = CurrentView()->currentItem()->text(0); | 593 | curApp = CurrentView()->currentItem()->text(0); |
706 | 594 | ||
707 | MimeType mt( curApp ); | 595 | MimeType mt( curApp ); |
708 | const AppLnk* app = mt.application(); | 596 | const AppLnk* app = mt.application(); |
709 | QFile fi(curApp); | 597 | QFile fi(curApp); |
710 | QPopupMenu *m = new QPopupMenu(0); | 598 | QPopupMenu *m = new QPopupMenu(0); |
711 | QPopupMenu *n = new QPopupMenu(0); | 599 | QPopupMenu *n = new QPopupMenu(0); |
712 | // QPopupMenu *o = new QPopupMenu(0); | 600 | // QPopupMenu *o = new QPopupMenu(0); |
713 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 601 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
714 | 602 | ||
715 | if ( QFileInfo(fi).isDir() ) | 603 | if ( QFileInfo(fi).isDir() ) |
716 | { | 604 | { |
717 | m->insertSeparator(); | 605 | m->insertSeparator(); |
718 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); | 606 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); |
719 | } | 607 | } |
720 | else | 608 | else |
721 | { | 609 | { |
722 | 610 | ||
723 | if ( app ) | 611 | if ( app ) |
724 | m->insertItem( app->pixmap(), tr( "Open in " | 612 | m->insertItem( app->pixmap(), tr( "Open in " |
725 | + app->name() ), this, SLOT( runThis() ) ); | 613 | + app->name() ), this, SLOT( runThis() ) ); |
726 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 614 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
727 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 615 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
728 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 616 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
729 | } | 617 | } |
730 | 618 | ||
731 | m->insertItem(tr("Actions"),n); | 619 | m->insertItem(tr("Actions"),n); |
732 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); | 620 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); |
733 | 621 | ||
734 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 622 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
735 | 623 | ||
736 | n->insertSeparator(); | 624 | n->insertSeparator(); |
737 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); | 625 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); |
738 | 626 | ||
739 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 627 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
740 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 628 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
741 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 629 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
742 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 630 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
743 | 631 | ||
744 | n->insertSeparator(); | 632 | n->insertSeparator(); |
745 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); | 633 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); |
746 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 634 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
747 | 635 | ||
748 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 636 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
749 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 637 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
750 | 638 | ||
751 | m->insertSeparator(); | 639 | m->insertSeparator(); |
752 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 640 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
753 | 641 | ||
754 | #if defined(QT_QWS_OPIE) | 642 | #if defined(QT_QWS_OPIE) |
755 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 643 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
756 | #endif | 644 | #endif |
757 | m->setCheckable(TRUE); | 645 | m->setCheckable(TRUE); |
758 | if (!b) | 646 | if (!b) |
759 | m->setItemChecked(m->idAt(0),TRUE); | 647 | m->setItemChecked(m->idAt(0),TRUE); |
760 | else | 648 | else |
761 | m->setItemChecked(m->idAt(0),FALSE); | 649 | m->setItemChecked(m->idAt(0),FALSE); |
762 | 650 | ||
763 | if(Ir::supported()) | 651 | if(Ir::supported()) |
764 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 652 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
765 | m->setFocus(); | 653 | m->setFocus(); |
766 | m->exec( QPoint( 4,QCursor::pos().y()) ); | 654 | m->exec( QPoint( 4,QCursor::pos().y()) ); |
767 | 655 | ||
768 | if(m) delete m; | 656 | if(m) delete m; |
769 | } | 657 | } |
770 | 658 | ||
771 | 659 | ||
772 | void AdvancedFm::cancelMenuTimer() | 660 | void AdvancedFm::cancelMenuTimer() |
773 | { | 661 | { |
774 | // qDebug("selectionChanged: cancel menu timer"); | 662 | // qDebug("selectionChanged: cancel menu timer"); |
775 | if( menuTimer.isActive() ) | 663 | if( menuTimer.isActive() ) |
776 | menuTimer.stop(); | 664 | menuTimer.stop(); |
777 | } | 665 | } |
778 | 666 | ||
779 | QString AdvancedFm::checkDiskSpace(const QString &path) | 667 | QString AdvancedFm::checkDiskSpace(const QString &path) |
780 | { | 668 | { |
781 | struct statfs fss; | 669 | struct statfs fss; |
782 | if ( !statfs( path.latin1(), &fss ) ) | 670 | if ( !statfs( path.latin1(), &fss ) ) |
783 | { | 671 | { |
784 | int blkSize = fss.f_bsize; | 672 | int blkSize = fss.f_bsize; |
785 | // int totalBlks = fs.f_blocks; | 673 | // int totalBlks = fs.f_blocks; |
786 | int availBlks = fss.f_bavail; | 674 | int availBlks = fss.f_bavail; |
787 | 675 | ||
788 | long mult = blkSize / 1024; | 676 | long mult = blkSize / 1024; |
789 | long div = 1024 / blkSize; | 677 | long div = 1024 / blkSize; |
790 | if ( !mult ) mult = 1; | 678 | if ( !mult ) mult = 1; |
791 | if ( !div ) div = 1; | 679 | if ( !div ) div = 1; |
792 | 680 | ||
793 | 681 | ||
794 | return QString::number(availBlks * mult / div); | 682 | return QString::number(availBlks * mult / div); |
795 | } | 683 | } |
796 | return ""; | 684 | return ""; |
797 | } | 685 | } |
798 | 686 | ||
799 | void AdvancedFm::addToDocs() | 687 | void AdvancedFm::addToDocs() |
800 | { | 688 | { |
801 | QStringList strListPaths = getPath(); | 689 | QStringList strListPaths = getPath(); |
802 | QDir *thisDir = CurrentDir(); | 690 | QDir *thisDir = CurrentDir(); |
803 | 691 | ||
804 | if( strListPaths.count() > 0) | 692 | if( strListPaths.count() > 0) |
805 | { | 693 | { |
806 | QString curFile; | 694 | QString curFile; |
807 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) | 695 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) |
808 | { | 696 | { |
809 | curFile = thisDir->canonicalPath()+"/"+(*it); | 697 | curFile = thisDir->canonicalPath()+"/"+(*it); |
810 | // qDebug(curFile); | 698 | // qDebug(curFile); |
811 | DocLnk f; | 699 | DocLnk f; |
812 | // curFile.replace(QRegExp("\\..*"),""); | 700 | // curFile.replace(QRegExp("\\..*"),""); |
813 | f.setName((*it)); | 701 | f.setName((*it)); |
814 | f.setFile( curFile); | 702 | f.setFile( curFile); |
815 | f.writeLink(); | 703 | f.writeLink(); |
816 | } | 704 | } |
817 | } | 705 | } |
818 | } | 706 | } |
819 | 707 | ||
820 | 708 | ||
821 | void AdvancedFm::customDirsToMenu() | 709 | void AdvancedFm::customDirsToMenu() |
822 | { | 710 | { |
823 | 711 | ||
824 | Config cfg("AdvancedFm"); | 712 | Config cfg("AdvancedFm"); |
825 | cfg.setGroup("Menu"); | 713 | cfg.setGroup("Menu"); |
826 | 714 | ||
827 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 715 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
828 | menuButton->insertItems(list ); | 716 | menuButton->insertItems(list ); |
829 | 717 | ||
830 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 718 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
831 | // { | 719 | // { |
832 | // customDirMenu->insertItem(*it ); | 720 | // customDirMenu->insertItem(*it ); |
833 | // } | 721 | // } |
834 | } | 722 | } |
835 | 723 | ||
836 | void AdvancedFm::dirMenuSelected(int item) | 724 | void AdvancedFm::dirMenuSelected(int item) |
837 | { | 725 | { |
838 | qDebug("menu item %d", item); | 726 | qDebug("menu item %d", item); |
839 | switch(item) | 727 | switch(item) |
840 | { | 728 | { |
841 | 729 | ||
842 | case -21: | 730 | case -21: |
843 | case 0: | 731 | case 0: |
844 | addCustomDir(); | 732 | addCustomDir(); |
845 | break; | 733 | break; |
846 | case -22: | 734 | case -22: |
847 | case 1: | 735 | case 1: |
848 | removeCustomDir(); | 736 | removeCustomDir(); |
849 | break; | 737 | break; |
850 | default: | 738 | default: |
851 | { | 739 | { |
852 | // gotoCustomDir( menuButton->text(item)); | 740 | // gotoCustomDir( menuButton->text(item)); |
853 | // gotoCustomDir( customDirMenu->text(item)); | 741 | // gotoCustomDir( customDirMenu->text(item)); |
854 | } | 742 | } |
855 | break; | 743 | break; |
856 | 744 | ||
857 | }; | 745 | }; |
858 | } | 746 | } |
859 | 747 | ||
860 | void AdvancedFm::addCustomDir() | 748 | void AdvancedFm::addCustomDir() |
861 | { | 749 | { |
862 | Config cfg("AdvancedFm"); | 750 | Config cfg("AdvancedFm"); |
863 | cfg.setGroup("Menu"); | 751 | cfg.setGroup("Menu"); |
864 | QString dir; | 752 | QString dir; |
865 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 753 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
866 | 754 | ||
867 | dir = CurrentDir()->canonicalPath(); | 755 | dir = CurrentDir()->canonicalPath(); |
868 | 756 | ||
869 | bool addIt=true; | 757 | bool addIt=true; |
870 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 758 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
871 | { | 759 | { |
872 | if( dir == (*it)) | 760 | if( dir == (*it)) |
873 | { | 761 | { |
874 | addIt=false; | 762 | addIt=false; |
875 | } | 763 | } |
876 | } | 764 | } |
877 | if(addIt) | 765 | if(addIt) |
878 | { | 766 | { |
879 | menuButton->insertItem(dir); | 767 | menuButton->insertItem(dir); |
880 | // customDirMenu->insertItem(dir); | 768 | // customDirMenu->insertItem(dir); |
881 | list << dir; | 769 | list << dir; |
882 | } | 770 | } |
883 | 771 | ||
884 | cfg.writeEntry("CustomDir", list, ','); | 772 | cfg.writeEntry("CustomDir", list, ','); |
885 | cfg.write(); | 773 | cfg.write(); |
886 | } | 774 | } |
887 | 775 | ||
888 | void AdvancedFm::removeCustomDir() | 776 | void AdvancedFm::removeCustomDir() |
889 | { | 777 | { |
890 | // qDebug("remove custom dir"); | 778 | // qDebug("remove custom dir"); |
891 | Config cfg("AdvancedFm"); | 779 | Config cfg("AdvancedFm"); |
892 | cfg.setGroup("Menu"); | 780 | cfg.setGroup("Menu"); |
893 | QString dir; | 781 | QString dir; |
894 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 782 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
895 | QStringList list2; | 783 | QStringList list2; |
896 | dir = CurrentDir()->canonicalPath(); | 784 | dir = CurrentDir()->canonicalPath(); |
897 | int ramble=2; | 785 | int ramble=2; |
898 | // int ramble=-24; | 786 | // int ramble=-24; |
899 | //first remove list | 787 | //first remove list |
900 | if(list.grep(dir,true).isEmpty()) | 788 | if(list.grep(dir,true).isEmpty()) |
901 | { | 789 | { |
902 | QMessageBox::message("AdvancedFm",tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); | 790 | QMessageBox::message("AdvancedFm",tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); |
903 | } | 791 | } |
904 | else | 792 | else |
905 | { | 793 | { |
906 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 794 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
907 | { | 795 | { |
908 | if((*it) != dir)//current item is not our current dir, so add it to temp list | 796 | if((*it) != dir)//current item is not our current dir, so add it to temp list |
909 | { | 797 | { |
910 | list2 <<(*it); | 798 | list2 <<(*it); |
911 | } | 799 | } |
912 | else | 800 | else |
913 | { | 801 | { |
914 | // customDirMenu->removeItem( ramble); | 802 | // customDirMenu->removeItem( ramble); |
915 | menuButton->remove( ramble); | 803 | menuButton->remove( ramble); |
916 | 804 | ||
917 | } | 805 | } |
918 | ramble++; | 806 | ramble++; |
919 | // ramble--; | 807 | // ramble--; |
920 | } | 808 | } |
921 | 809 | ||
922 | cfg.writeEntry("CustomDir", list2, ','); | 810 | cfg.writeEntry("CustomDir", list2, ','); |
923 | cfg.write(); | 811 | cfg.write(); |
924 | } | 812 | } |
925 | // customDirsToMenu(); | 813 | // customDirsToMenu(); |
926 | 814 | ||
927 | } | 815 | } |
928 | 816 | ||
929 | void AdvancedFm::gotoCustomDir(const QString &dir) | 817 | void AdvancedFm::gotoCustomDir(const QString &dir) |
930 | { | 818 | { |
931 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); | 819 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); |
932 | QString curDir = dir; | 820 | QString curDir = dir; |
933 | QDir *thisDir = CurrentDir(); | 821 | QDir *thisDir = CurrentDir(); |
934 | // if( curDir.isEmpty()) { | 822 | // if( curDir.isEmpty()) { |
935 | // } | 823 | // } |
936 | if( curDir == s_addBookmark) | 824 | if( curDir == s_addBookmark) |
937 | { | 825 | { |
938 | addCustomDir(); | 826 | addCustomDir(); |
939 | } | 827 | } |
940 | if( curDir == s_removeBookmark) | 828 | if( curDir == s_removeBookmark) |
941 | { | 829 | { |
942 | removeCustomDir( ); | 830 | removeCustomDir( ); |
943 | } | 831 | } |
944 | else | 832 | else |
945 | { | 833 | { |
946 | if(QDir( curDir).exists() ) | 834 | if(QDir( curDir).exists() ) |
947 | { | 835 | { |
948 | thisDir->setPath( curDir ); | 836 | thisDir->setPath( curDir ); |
949 | chdir( curDir.latin1() ); | 837 | chdir( curDir.latin1() ); |
950 | thisDir->cd( curDir, TRUE); | 838 | thisDir->cd( curDir, TRUE); |
951 | PopulateView(); | 839 | populateView(); |
952 | } | 840 | } |
953 | } | 841 | } |
954 | } | 842 | } |
955 | 843 | ||
956 | QDir *AdvancedFm::CurrentDir() | 844 | QDir *AdvancedFm::CurrentDir() |
957 | { | 845 | { |
958 | if ( whichTab == 1) | 846 | if ( whichTab == 1) |
959 | { | 847 | { |
960 | return ¤tDir; | 848 | return ¤tDir; |
961 | } | 849 | } |
962 | else | 850 | else |
963 | { | 851 | { |
964 | return ¤tRemoteDir; | 852 | return ¤tRemoteDir; |
965 | } | 853 | } |
966 | } | 854 | } |
967 | 855 | ||
968 | QDir *AdvancedFm::OtherDir() | 856 | QDir *AdvancedFm::OtherDir() |
969 | { | 857 | { |
970 | if ( whichTab == 1) | 858 | if ( whichTab == 1) |
971 | { | 859 | { |
972 | return ¤tRemoteDir; | 860 | return ¤tRemoteDir; |
973 | } | 861 | } |
974 | else | 862 | else |
975 | { | 863 | { |
976 | return ¤tDir; | 864 | return ¤tDir; |
977 | } | 865 | } |
978 | } | 866 | } |
979 | 867 | ||
980 | void AdvancedFm::PopulateView() | ||
981 | { | ||
982 | if ( whichTab == 1) | ||
983 | populateLocalView(); | ||
984 | else | ||
985 | populateRemoteView(); | ||
986 | } | ||
987 | |||
988 | QListView * AdvancedFm::CurrentView() | 868 | QListView * AdvancedFm::CurrentView() |
989 | { | 869 | { |
990 | if ( whichTab == 1) | 870 | if ( whichTab == 1) |
991 | return Local_View; | 871 | return Local_View; |
992 | else | 872 | else |
993 | return Remote_View; | 873 | return Remote_View; |
994 | } | 874 | } |
995 | 875 | ||
996 | QListView * AdvancedFm::OtherView() | 876 | QListView * AdvancedFm::OtherView() |
997 | { | 877 | { |
998 | if ( whichTab == 1) | 878 | if ( whichTab == 1) |
999 | return Remote_View; | 879 | return Remote_View; |
1000 | else | 880 | else |
1001 | return Local_View; | 881 | return Local_View; |
1002 | } | 882 | } |
883 | |||
884 | void AdvancedFm::setOtherTabCurrent() | ||
885 | { | ||
886 | if ( whichTab == 1) | ||
887 | TabWidget->setCurrentTab(1); | ||
888 | else | ||
889 | TabWidget->setCurrentTab(0); | ||
890 | } | ||
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 8eec6ba..024ab29 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -1,171 +1,169 @@ | |||
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 | #define QT_QWS_OPIE |
16 | 16 | ||
17 | //#include <opie/otabwidget.h> | 17 | //#include <opie/otabwidget.h> |
18 | #include <qpe/ir.h> | 18 | #include <qpe/ir.h> |
19 | 19 | ||
20 | #include <qvariant.h> | 20 | #include <qvariant.h> |
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qdir.h> | 24 | #include <qdir.h> |
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qpoint.h> | 26 | #include <qpoint.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | 28 | ||
29 | class OTabWidget; | 29 | class OTabWidget; |
30 | class QVBoxLayout; | 30 | class QVBoxLayout; |
31 | class QHBoxLayout; | 31 | class QHBoxLayout; |
32 | class QGridLayout; | 32 | class QGridLayout; |
33 | class QComboBox; | 33 | class QComboBox; |
34 | class QListView; | 34 | class QListView; |
35 | class QListviewItem; | 35 | class QListviewItem; |
36 | class QLabel; | 36 | class QLabel; |
37 | class QProgressBar; | 37 | class QProgressBar; |
38 | class QSpinBox; | 38 | class QSpinBox; |
39 | class QTabWidget; | 39 | class QTabWidget; |
40 | class QWidget; | 40 | class QWidget; |
41 | class QPEToolBar; | 41 | class QPEToolBar; |
42 | class QPEMenuBar; | 42 | class QPEMenuBar; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QFile; | 44 | class QFile; |
45 | class QListViewItem; | 45 | class QListViewItem; |
46 | class QLineEdit; | 46 | class QLineEdit; |
47 | class MenuButton; | 47 | class MenuButton; |
48 | 48 | ||
49 | //class QPushButton; | 49 | //class QPushButton; |
50 | class QToolButton; | 50 | class QToolButton; |
51 | class Ir; | 51 | class Ir; |
52 | 52 | ||
53 | class AdvancedFm : public QMainWindow | 53 | class AdvancedFm : public QMainWindow |
54 | { | 54 | { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | public: | 56 | public: |
57 | AdvancedFm(); | 57 | AdvancedFm(); |
58 | ~AdvancedFm(); | 58 | ~AdvancedFm(); |
59 | protected slots: | 59 | protected slots: |
60 | void selectAll(); | 60 | void selectAll(); |
61 | void addToDocs(); | 61 | void addToDocs(); |
62 | void doDirChange(); | 62 | void doDirChange(); |
63 | void mkDir(); | 63 | void mkDir(); |
64 | void del(); | 64 | void del(); |
65 | void rn(); | 65 | void rn(); |
66 | void populateLocalView(); | 66 | void populateView(); |
67 | void populateRemoteView(); | ||
68 | void showHidden(); | 67 | void showHidden(); |
69 | void showMenuHidden(); | 68 | void showMenuHidden(); |
70 | // void showRemoteHidden(); | ||
71 | void writeConfig(); | 69 | void writeConfig(); |
72 | void readConfig(); | 70 | void readConfig(); |
73 | void ListClicked(QListViewItem *); | 71 | void ListClicked(QListViewItem *); |
74 | void ListPressed( int, QListViewItem *, const QPoint&, int); | 72 | void ListPressed( int, QListViewItem *, const QPoint&, int); |
75 | void makeDir(); | 73 | void makeDir(); |
76 | void doDelete(); | 74 | void doDelete(); |
77 | void tabChanged(QWidget*); | 75 | void tabChanged(QWidget*); |
78 | void cleanUp(); | 76 | void cleanUp(); |
79 | void renameIt(); | 77 | void renameIt(); |
80 | void runThis(); | 78 | void runThis(); |
81 | void runText(); | 79 | void runText(); |
82 | void filePerms(); | 80 | void filePerms(); |
83 | void doProperties(); | 81 | void doProperties(); |
84 | void runCommand(); | 82 | void runCommand(); |
85 | void runCommandStd(); | 83 | void runCommandStd(); |
86 | QStringList getPath(); | 84 | QStringList getPath(); |
87 | void mkSym(); | 85 | void mkSym(); |
88 | void switchToLocalTab(); | 86 | void switchToLocalTab(); |
89 | void switchToRemoteTab(); | 87 | void switchToRemoteTab(); |
90 | 88 | ||
91 | protected: | 89 | protected: |
92 | 90 | ||
93 | OTabWidget *TabWidget; | 91 | OTabWidget *TabWidget; |
94 | int whichTab; | 92 | int whichTab; |
95 | // QTabWidget *TabWidget; | 93 | // QTabWidget *TabWidget; |
96 | QWidget *tab, *tab_2, *tab_3; | 94 | QWidget *tab, *tab_2, *tab_3; |
97 | QListView *Local_View, *Remote_View; | 95 | QListView *Local_View, *Remote_View; |
98 | 96 | ||
99 | QLineEdit *currentPathEdit; | 97 | QLineEdit *currentPathEdit; |
100 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; | 98 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; |
101 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 99 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
102 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 100 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
103 | QDir currentDir, currentRemoteDir; | 101 | QDir currentDir, currentRemoteDir; |
104 | QComboBox *currentPathCombo; | 102 | QComboBox *currentPathCombo; |
105 | QString filterStr, s_addBookmark, s_removeBookmark; | 103 | QString filterStr, s_addBookmark, s_removeBookmark; |
106 | QListViewItem * item; | 104 | QListViewItem * item; |
107 | bool b; | 105 | bool b; |
108 | QStringList fileSystemTypeList, fsList; | 106 | QStringList fileSystemTypeList, fsList; |
109 | int currentServerConfig; | 107 | int currentServerConfig; |
110 | bool zaurusDevice; | 108 | bool zaurusDevice; |
111 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; | 109 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; |
112 | QStringList remoteDirPathStringList, localDirPathStringList; | 110 | QStringList remoteDirPathStringList, localDirPathStringList; |
113 | QLineEdit *renameBox; | 111 | QLineEdit *renameBox; |
114 | 112 | ||
115 | void init(); | 113 | void init(); |
116 | void initConnections(); | 114 | void initConnections(); |
117 | void keyReleaseEvent( QKeyEvent *); | 115 | void keyReleaseEvent( QKeyEvent *); |
118 | void keyPressEvent( QKeyEvent *); | 116 | void keyPressEvent( QKeyEvent *); |
119 | QString getFileSystemType(const QString &); | 117 | QString getFileSystemType(const QString &); |
120 | QString getDiskSpace(const QString &); | 118 | QString getDiskSpace(const QString &); |
121 | void parsetab(const QString &fileName); | 119 | void parsetab(const QString &fileName); |
122 | QString checkDiskSpace(const QString &); | 120 | QString checkDiskSpace(const QString &); |
123 | QString dealWithSymName(const QString &); | 121 | QString dealWithSymName(const QString &); |
124 | QDir *CurrentDir(); | 122 | QDir *CurrentDir(); |
125 | QDir *OtherDir(); | 123 | QDir *OtherDir(); |
126 | QListView *CurrentView(); | 124 | QListView *CurrentView(); |
127 | QListView *OtherView(); | 125 | QListView *OtherView(); |
128 | void PopulateView(); | 126 | void setOtherTabCurrent(); |
129 | 127 | ||
130 | protected slots: | 128 | protected slots: |
131 | void dirMenuSelected(int); | 129 | void dirMenuSelected(int); |
132 | void showFileMenu(); | 130 | void showFileMenu(); |
133 | void cancelMenuTimer(); | 131 | void cancelMenuTimer(); |
134 | void homeButtonPushed(); | 132 | void homeButtonPushed(); |
135 | void docButtonPushed(); | 133 | void docButtonPushed(); |
136 | void SDButtonPushed(); | 134 | void SDButtonPushed(); |
137 | void CFButtonPushed(); | 135 | void CFButtonPushed(); |
138 | void QPEButtonPushed(); | 136 | void QPEButtonPushed(); |
139 | void upDir(); | 137 | void upDir(); |
140 | void currentPathComboChanged(); | 138 | void currentPathComboChanged(); |
141 | void copy(); | 139 | void copy(); |
142 | void copyAs(); | 140 | void copyAs(); |
143 | void copySameDir(); | 141 | void copySameDir(); |
144 | void currentPathComboActivated(const QString &); | 142 | void currentPathComboActivated(const QString &); |
145 | void fillCombo(const QString &); | 143 | void fillCombo(const QString &); |
146 | bool copyFile( const QString & , const QString & ); | 144 | bool copyFile( const QString & , const QString & ); |
147 | void move(); | 145 | void move(); |
148 | void fileStatus(); | 146 | void fileStatus(); |
149 | void doAbout(); | 147 | void doAbout(); |
150 | void doBeam(); | 148 | void doBeam(); |
151 | void fileBeamFinished( Ir *); | 149 | void fileBeamFinished( Ir *); |
152 | 150 | ||
153 | private: | 151 | private: |
154 | MenuButton *menuButton; | 152 | MenuButton *menuButton; |
155 | QString oldName; | 153 | QString oldName; |
156 | QTimer menuTimer; | 154 | QTimer menuTimer; |
157 | void startProcess(const QString &); | 155 | void startProcess(const QString &); |
158 | bool eventFilter( QObject * , QEvent * ); | 156 | bool eventFilter( QObject * , QEvent * ); |
159 | void cancelRename(); | 157 | void cancelRename(); |
160 | void doRename(QListView *); | 158 | void doRename(QListView *); |
161 | void okRename(); | 159 | void okRename(); |
162 | void customDirsToMenu(); | 160 | void customDirsToMenu(); |
163 | void addCustomDir(); | 161 | void addCustomDir(); |
164 | void removeCustomDir(); | 162 | void removeCustomDir(); |
165 | 163 | ||
166 | private slots: | 164 | private slots: |
167 | void processEnded(); | 165 | void processEnded(); |
168 | void gotoCustomDir(const QString &); | 166 | void gotoCustomDir(const QString &); |
169 | }; | 167 | }; |
170 | 168 | ||
171 | #endif // ADVANCEDFM_H | 169 | #endif // ADVANCEDFM_H |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 13dad33..c553017 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,869 +1,849 @@ | |||
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 "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/ir.h> | 26 | #include <qpe/ir.h> |
27 | 27 | ||
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qmultilineedit.h> | 29 | #include <qmultilineedit.h> |
30 | 30 | ||
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | 32 | ||
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
46 | #include <dirent.h> | 46 | #include <dirent.h> |
47 | 47 | ||
48 | 48 | ||
49 | void AdvancedFm::doDirChange() | 49 | void AdvancedFm::doDirChange() |
50 | { | 50 | { |
51 | ListClicked( CurrentView()->currentItem()); | 51 | ListClicked( CurrentView()->currentItem()); |
52 | } | 52 | } |
53 | 53 | ||
54 | void AdvancedFm::showMenuHidden() | 54 | void AdvancedFm::showMenuHidden() |
55 | { | 55 | { |
56 | if (b) | 56 | if (b) |
57 | { | 57 | { |
58 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 58 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
59 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 59 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
61 | // b=FALSE; | 61 | // b=FALSE; |
62 | 62 | ||
63 | } | 63 | } |
64 | else | 64 | else |
65 | { | 65 | { |
66 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 66 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
69 | // b=TRUE; | 69 | // b=TRUE; |
70 | } | 70 | } |
71 | populateLocalView(); | 71 | populateView(); |
72 | populateRemoteView(); | 72 | // populateRemoteView(); |
73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
74 | if(b) b = false; else b = true; | 74 | if(b) b = false; else b = true; |
75 | } | 75 | } |
76 | 76 | ||
77 | void AdvancedFm::showHidden() | 77 | void AdvancedFm::showHidden() |
78 | { | 78 | { |
79 | if (b) | 79 | if (b) |
80 | { | 80 | { |
81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
83 | // b=FALSE; | 83 | // b=FALSE; |
84 | 84 | ||
85 | } | 85 | } |
86 | else | 86 | else |
87 | { | 87 | { |
88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
90 | // b=TRUE; | 90 | // b=TRUE; |
91 | } | 91 | } |
92 | PopulateView(); | 92 | populateView(); |
93 | } | 93 | } |
94 | 94 | ||
95 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 95 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
96 | { | 96 | { |
97 | QString strItem = fileName; | 97 | QString strItem = fileName; |
98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
99 | } | 99 | } |
100 | 100 | ||
101 | void AdvancedFm::runThis() | 101 | void AdvancedFm::runThis() |
102 | { | 102 | { |
103 | QString fs; | 103 | QString fs; |
104 | QDir *thisDir = CurrentDir(); | 104 | QDir *thisDir = CurrentDir(); |
105 | 105 | ||
106 | QString curFile = CurrentView()->currentItem()->text(0); | 106 | QString curFile = CurrentView()->currentItem()->text(0); |
107 | QString path = thisDir->canonicalPath(); | 107 | QString path = thisDir->canonicalPath(); |
108 | 108 | ||
109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
110 | 110 | ||
111 | curFile = dealWithSymName((const QString&)curFile); | 111 | curFile = dealWithSymName((const QString&)curFile); |
112 | 112 | ||
113 | if(curFile != "../") | 113 | if(curFile != "../") |
114 | { | 114 | { |
115 | 115 | ||
116 | fs = getFileSystemType((const QString &) path); | 116 | fs = getFileSystemType((const QString &) path); |
117 | QFileInfo fileInfo( path + "/" + curFile); | 117 | QFileInfo fileInfo( path + "/" + curFile); |
118 | qDebug( fileInfo.owner()); | 118 | qDebug( fileInfo.owner()); |
119 | 119 | ||
120 | if( (fileInfo.permission( QFileInfo::ExeUser) | 120 | if( (fileInfo.permission( QFileInfo::ExeUser) |
121 | | fileInfo.permission( QFileInfo::ExeGroup) | 121 | | fileInfo.permission( QFileInfo::ExeGroup) |
122 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 122 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
123 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 123 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
124 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 124 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
125 | e << curFile; | 125 | e << curFile; |
126 | } | 126 | } |
127 | else | 127 | else |
128 | { | 128 | { |
129 | curFile = path + "/" + curFile; | 129 | curFile = path + "/" + curFile; |
130 | DocLnk nf(curFile); | 130 | DocLnk nf(curFile); |
131 | QString execStr = nf.exec(); | 131 | QString execStr = nf.exec(); |
132 | qDebug( execStr); | 132 | qDebug( execStr); |
133 | if( execStr.isEmpty() ) | 133 | if( execStr.isEmpty() ) |
134 | { | 134 | { |
135 | } | 135 | } |
136 | else | 136 | else |
137 | { | 137 | { |
138 | nf.execute(); | 138 | nf.execute(); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void AdvancedFm::runText() | 144 | void AdvancedFm::runText() |
145 | { | 145 | { |
146 | QString curFile = CurrentView()->currentItem()->text(0); | 146 | QString curFile = CurrentView()->currentItem()->text(0); |
147 | if(curFile != "../") | 147 | if(curFile != "../") |
148 | { | 148 | { |
149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
150 | curFile = dealWithSymName((const QString&)curFile); | 150 | curFile = dealWithSymName((const QString&)curFile); |
151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
153 | e << curFile; | 153 | e << curFile; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | void AdvancedFm::makeDir() | 157 | void AdvancedFm::makeDir() |
158 | { | 158 | { |
159 | InputDialog *fileDlg; | 159 | InputDialog *fileDlg; |
160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
161 | fileDlg->exec(); | 161 | fileDlg->exec(); |
162 | if( fileDlg->result() == 1 ) | 162 | if( fileDlg->result() == 1 ) |
163 | { | 163 | { |
164 | QDir *thisDir = CurrentDir(); | 164 | QDir *thisDir = CurrentDir(); |
165 | QString filename = fileDlg->LineEdit1->text(); | 165 | QString filename = fileDlg->LineEdit1->text(); |
166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
167 | } | 167 | } |
168 | PopulateView(); | 168 | populateView(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void AdvancedFm::doDelete() | 171 | void AdvancedFm::doDelete() |
172 | { | 172 | { |
173 | 173 | ||
174 | QStringList curFileList = getPath(); | 174 | QStringList curFileList = getPath(); |
175 | bool doMsg=true; | 175 | bool doMsg=true; |
176 | int count = curFileList.count(); | 176 | int count = curFileList.count(); |
177 | if( count > 0) | 177 | if( count > 0) |
178 | { | 178 | { |
179 | if(count > 1 ) | 179 | if(count > 1 ) |
180 | { | 180 | { |
181 | QString msg; | 181 | QString msg; |
182 | msg=tr("Really delete\n%1 files?").arg(count); | 182 | msg=tr("Really delete\n%1 files?").arg(count); |
183 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 183 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
184 | ,tr("Yes"),tr("No"),0,0,1) ) | 184 | ,tr("Yes"),tr("No"),0,0,1) ) |
185 | { | 185 | { |
186 | case 0: | 186 | case 0: |
187 | doMsg=false; | 187 | doMsg=false; |
188 | break; | 188 | break; |
189 | case 1: | 189 | case 1: |
190 | return; | 190 | return; |
191 | break; | 191 | break; |
192 | }; | 192 | }; |
193 | } | 193 | } |
194 | 194 | ||
195 | QString myFile; | 195 | QString myFile; |
196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
197 | { | 197 | { |
198 | myFile = (*it); | 198 | myFile = (*it); |
199 | if( myFile.find(" -> ",0,TRUE) != -1) | 199 | if( myFile.find(" -> ",0,TRUE) != -1) |
200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
201 | 201 | ||
202 | QString f = CurrentDir()->canonicalPath(); | 202 | QString f = CurrentDir()->canonicalPath(); |
203 | if(f.right(1).find("/",0,TRUE) == -1) | 203 | if(f.right(1).find("/",0,TRUE) == -1) |
204 | f += "/"; | 204 | f += "/"; |
205 | f += myFile; | 205 | f += myFile; |
206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) | 206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) |
207 | { | 207 | { |
208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + | 208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + |
209 | "\nand all it's contents ?" | 209 | "\nand all it's contents ?" |
210 | ,tr("Yes"),tr("No"),0,0,1) ) | 210 | ,tr("Yes"),tr("No"),0,0,1) ) |
211 | { | 211 | { |
212 | case 0: | 212 | case 0: |
213 | { | 213 | { |
214 | f=f.left(f.length()-1); | 214 | f=f.left(f.length()-1); |
215 | QString cmd="rm -rf "+f; | 215 | QString cmd="rm -rf "+f; |
216 | startProcess( (const QString)cmd.latin1() ); | 216 | startProcess( (const QString)cmd.latin1() ); |
217 | PopulateView(); | 217 | populateView(); |
218 | } | 218 | } |
219 | break; | 219 | break; |
220 | case 1: | 220 | case 1: |
221 | // exit | 221 | // exit |
222 | break; | 222 | break; |
223 | }; | 223 | }; |
224 | 224 | ||
225 | } else { | 225 | } else { |
226 | if(doMsg) { | 226 | if(doMsg) { |
227 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 227 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
228 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 228 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
229 | case 1: | 229 | case 1: |
230 | return; | 230 | return; |
231 | break; | 231 | break; |
232 | }; | 232 | }; |
233 | } | 233 | } |
234 | QString cmd="rm "+f; | 234 | QString cmd="rm "+f; |
235 | QFile file(f); | 235 | QFile file(f); |
236 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 236 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
237 | file.remove(); | 237 | file.remove(); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | PopulateView(); | 241 | populateView(); |
242 | } | 242 | } |
243 | 243 | ||
244 | void AdvancedFm::filePerms() | 244 | void AdvancedFm::filePerms() |
245 | { | 245 | { |
246 | QStringList curFileList = getPath(); | 246 | QStringList curFileList = getPath(); |
247 | QString filePath; | 247 | QString filePath; |
248 | 248 | ||
249 | filePath = CurrentDir()->canonicalPath()+"/"; | 249 | filePath = CurrentDir()->canonicalPath()+"/"; |
250 | 250 | ||
251 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 251 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
252 | { | 252 | { |
253 | filePermissions *filePerm; | 253 | filePermissions *filePerm; |
254 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 254 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
255 | filePerm->showMaximized(); | 255 | filePerm->showMaximized(); |
256 | filePerm->exec(); | 256 | filePerm->exec(); |
257 | if( filePerm) | 257 | if( filePerm) |
258 | delete filePerm; | 258 | delete filePerm; |
259 | } | 259 | } |
260 | PopulateView(); | 260 | populateView(); |
261 | } | 261 | } |
262 | 262 | ||
263 | void AdvancedFm::doProperties() | 263 | void AdvancedFm::doProperties() |
264 | { | 264 | { |
265 | #if defined(QT_QWS_OPIE) | 265 | #if defined(QT_QWS_OPIE) |
266 | 266 | ||
267 | QStringList curFileList = getPath(); | 267 | QStringList curFileList = getPath(); |
268 | 268 | ||
269 | QString filePath; | 269 | QString filePath; |
270 | filePath = CurrentDir()->canonicalPath()+"/"; | 270 | filePath = CurrentDir()->canonicalPath()+"/"; |
271 | 271 | ||
272 | qDebug("%d",curFileList.count()); | 272 | qDebug("%d",curFileList.count()); |
273 | 273 | ||
274 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 274 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
275 | { | 275 | { |
276 | qDebug((filePath+*it)); | 276 | qDebug((filePath+*it)); |
277 | DocLnk lnk( (filePath+*it)); | 277 | DocLnk lnk( (filePath+*it)); |
278 | LnkProperties prop( &lnk ); | 278 | LnkProperties prop( &lnk ); |
279 | prop.showMaximized(); | 279 | prop.showMaximized(); |
280 | prop.exec(); | 280 | prop.exec(); |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | 283 | ||
284 | } | 284 | } |
285 | 285 | ||
286 | void AdvancedFm::upDir() | 286 | void AdvancedFm::upDir() |
287 | { | 287 | { |
288 | QDir *thisDir = CurrentDir(); | 288 | QDir *thisDir = CurrentDir(); |
289 | QString current = thisDir->canonicalPath(); | 289 | QString current = thisDir->canonicalPath(); |
290 | QDir dir(current); | 290 | QDir dir(current); |
291 | dir.cdUp(); | 291 | dir.cdUp(); |
292 | current = dir.canonicalPath(); | 292 | current = dir.canonicalPath(); |
293 | chdir( current.latin1() ); | 293 | chdir( current.latin1() ); |
294 | thisDir->cd( current, TRUE); | 294 | thisDir->cd( current, TRUE); |
295 | 295 | ||
296 | PopulateView(); | 296 | populateView(); |
297 | update(); | 297 | update(); |
298 | } | 298 | } |
299 | 299 | ||
300 | void AdvancedFm::copy() | 300 | void AdvancedFm::copy() |
301 | { | 301 | { |
302 | qApp->processEvents(); | 302 | qApp->processEvents(); |
303 | QStringList curFileList = getPath(); | 303 | QStringList curFileList = getPath(); |
304 | 304 | ||
305 | QDir *thisDir = CurrentDir(); | 305 | QDir *thisDir = CurrentDir(); |
306 | QDir *thatDir = OtherDir(); | 306 | QDir *thatDir = OtherDir(); |
307 | 307 | ||
308 | bool doMsg=true; | 308 | bool doMsg=true; |
309 | int count=curFileList.count(); | 309 | int count=curFileList.count(); |
310 | if( count > 0) { | 310 | if( count > 0) { |
311 | if(count > 1 ){ | 311 | if(count > 1 ){ |
312 | QString msg; | 312 | QString msg; |
313 | msg=tr("Really copy\n%1 files?").arg(count); | 313 | msg=tr("Really copy\n%1 files?").arg(count); |
314 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 314 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
315 | ,tr("Yes"),tr("No"),0,0,1) ) | 315 | ,tr("Yes"),tr("No"),0,0,1) ) |
316 | { | 316 | { |
317 | case 0: | 317 | case 0: |
318 | doMsg=false; | 318 | doMsg=false; |
319 | break; | 319 | break; |
320 | case 1: | 320 | case 1: |
321 | return; | 321 | return; |
322 | break; | 322 | break; |
323 | }; | 323 | }; |
324 | } | 324 | } |
325 | 325 | ||
326 | QString curFile, item, destFile; | 326 | QString curFile, item, destFile; |
327 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 327 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
328 | { | 328 | { |
329 | item=(*it); | 329 | item=(*it); |
330 | if(item.find("->",0,TRUE)) //symlink | 330 | if(item.find("->",0,TRUE)) //symlink |
331 | item = item.left(item.find("->",0,TRUE)); | 331 | item = item.left(item.find("->",0,TRUE)); |
332 | 332 | ||
333 | curFile = thisDir->canonicalPath()+"/"+ item; | 333 | curFile = thisDir->canonicalPath()+"/"+ item; |
334 | destFile = thatDir->canonicalPath()+"/"+ item; | 334 | destFile = thatDir->canonicalPath()+"/"+ item; |
335 | 335 | ||
336 | qDebug("Destination file is "+destFile); | 336 | qDebug("Destination file is "+destFile); |
337 | qDebug("CurrentFile file is " + curFile); | 337 | qDebug("CurrentFile file is " + curFile); |
338 | 338 | ||
339 | QFile f(destFile); | 339 | QFile f(destFile); |
340 | if( f.exists()) | 340 | if( f.exists()) |
341 | { | 341 | { |
342 | if(doMsg) | 342 | if(doMsg) |
343 | { | 343 | { |
344 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 344 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
345 | tr("%1 exists. Ok to overwrite?").arg( item ), | 345 | tr("%1 exists. Ok to overwrite?").arg( item ), |
346 | tr("Yes"),tr("No"),0,0,1) ) | 346 | tr("Yes"),tr("No"),0,0,1) ) |
347 | { | 347 | { |
348 | case 1: | 348 | case 1: |
349 | return; | 349 | return; |
350 | break; | 350 | break; |
351 | }; | 351 | }; |
352 | } | 352 | } |
353 | f.remove(); | 353 | f.remove(); |
354 | } | 354 | } |
355 | 355 | ||
356 | if( !copyFile( curFile, destFile) ) | 356 | if( !copyFile( curFile, destFile) ) |
357 | { | 357 | { |
358 | QMessageBox::message("AdvancedFm", | 358 | QMessageBox::message("AdvancedFm", |
359 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 359 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
360 | return; | 360 | return; |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | setOtherTabCurrent(); | |
364 | PopulateView(); | 364 | populateView(); |
365 | // TabWidget->setCurrentTab(1); | ||
366 | } | 365 | } |
367 | } | 366 | } |
368 | 367 | ||
369 | void AdvancedFm::copyAs() | 368 | void AdvancedFm::copyAs() |
370 | { | 369 | { |
371 | qApp->processEvents(); | 370 | qApp->processEvents(); |
372 | 371 | ||
373 | QStringList curFileList = getPath(); | 372 | QStringList curFileList = getPath(); |
374 | QString curFile, item; | 373 | QString curFile, item; |
375 | InputDialog *fileDlg; | 374 | InputDialog *fileDlg; |
376 | 375 | ||
377 | QDir *thisDir = CurrentDir(); | 376 | QDir *thisDir = CurrentDir(); |
378 | QDir *thatDir = OtherDir(); | 377 | QDir *thatDir = OtherDir(); |
379 | 378 | ||
380 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 379 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
381 | { | 380 | { |
382 | QString destFile; | 381 | QString destFile; |
383 | item=(*it); | 382 | item=(*it); |
384 | curFile = thisDir->canonicalPath()+"/"+(*it); | 383 | curFile = thisDir->canonicalPath()+"/"+(*it); |
385 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 384 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
386 | 385 | ||
387 | fileDlg->setInputText((const QString &) destFile ); | 386 | fileDlg->setInputText((const QString &) destFile ); |
388 | fileDlg->exec(); | 387 | fileDlg->exec(); |
389 | 388 | ||
390 | if( fileDlg->result() == 1 ) | 389 | if( fileDlg->result() == 1 ) |
391 | { | 390 | { |
392 | QString filename = fileDlg->LineEdit1->text(); | 391 | QString filename = fileDlg->LineEdit1->text(); |
393 | destFile = thatDir->canonicalPath()+"/"+filename; | 392 | destFile = thatDir->canonicalPath()+"/"+filename; |
394 | 393 | ||
395 | QFile f( destFile); | 394 | QFile f( destFile); |
396 | if( f.exists()) | 395 | if( f.exists()) |
397 | { | 396 | { |
398 | switch (QMessageBox::warning(this,tr("File Exists!"), | 397 | switch (QMessageBox::warning(this,tr("File Exists!"), |
399 | item+tr("\nexists. Ok to overwrite?"), | 398 | item+tr("\nexists. Ok to overwrite?"), |
400 | tr("Yes"),tr("No"),0,0,1) ) | 399 | tr("Yes"),tr("No"),0,0,1) ) |
401 | { | 400 | { |
402 | case 0: | 401 | case 0: |
403 | f.remove(); | 402 | f.remove(); |
404 | break; | 403 | break; |
405 | case 1: | 404 | case 1: |
406 | return; | 405 | return; |
407 | break; | 406 | break; |
408 | }; | 407 | }; |
409 | } | 408 | } |
410 | if( !copyFile( curFile, destFile) ) | 409 | if( !copyFile( curFile, destFile) ) |
411 | { | 410 | { |
412 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 411 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
413 | +curFile +tr("to\n")+destFile); | 412 | +curFile +tr("to\n")+destFile); |
414 | return; | 413 | return; |
415 | } | 414 | } |
416 | } | 415 | } |
417 | delete fileDlg; | 416 | delete fileDlg; |
418 | 417 | ||
419 | } | 418 | } |
420 | PopulateView(); | 419 | setOtherTabCurrent(); |
420 | populateView(); | ||
421 | } | 421 | } |
422 | 422 | ||
423 | void AdvancedFm::copySameDir() | 423 | void AdvancedFm::copySameDir() |
424 | { | 424 | { |
425 | qApp->processEvents(); | 425 | qApp->processEvents(); |
426 | QStringList curFileList = getPath(); | 426 | QStringList curFileList = getPath(); |
427 | QString curFile, item, destFile; | 427 | QString curFile, item, destFile; |
428 | InputDialog *fileDlg; | 428 | InputDialog *fileDlg; |
429 | 429 | ||
430 | QDir *thisDir = CurrentDir(); | 430 | QDir *thisDir = CurrentDir(); |
431 | 431 | ||
432 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 432 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
433 | { | 433 | { |
434 | item=(*it); | 434 | item=(*it); |
435 | curFile = thisDir->canonicalPath()+"/"+ item; | 435 | curFile = thisDir->canonicalPath()+"/"+ item; |
436 | 436 | ||
437 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 437 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
438 | fileDlg->setInputText((const QString &) destFile ); | 438 | fileDlg->setInputText((const QString &) destFile ); |
439 | fileDlg->exec(); | 439 | fileDlg->exec(); |
440 | 440 | ||
441 | if( fileDlg->result() == 1 ) | 441 | if( fileDlg->result() == 1 ) |
442 | { | 442 | { |
443 | 443 | ||
444 | QString filename = fileDlg->LineEdit1->text(); | 444 | QString filename = fileDlg->LineEdit1->text(); |
445 | destFile = thisDir->canonicalPath()+"/"+filename; | 445 | destFile = thisDir->canonicalPath()+"/"+filename; |
446 | 446 | ||
447 | QFile f(destFile); | 447 | QFile f(destFile); |
448 | if( f.exists()) | 448 | if( f.exists()) |
449 | { | 449 | { |
450 | switch (QMessageBox::warning(this,tr("Delete"), | 450 | switch (QMessageBox::warning(this,tr("Delete"), |
451 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 451 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
452 | tr("Yes"),tr("No"),0,0,1) ) { | 452 | tr("Yes"),tr("No"),0,0,1) ) { |
453 | case 0: | 453 | case 0: |
454 | 454 | ||
455 | f.remove(); | 455 | f.remove(); |
456 | break; | 456 | break; |
457 | case 1: | 457 | case 1: |
458 | return; | 458 | return; |
459 | break; | 459 | break; |
460 | }; | 460 | }; |
461 | } | 461 | } |
462 | if(!copyFile( curFile,destFile) ) | 462 | if(!copyFile( curFile,destFile) ) |
463 | { | 463 | { |
464 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 464 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
465 | +curFile +tr("to\n")+destFile); | 465 | +curFile +tr("to\n")+destFile); |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | 468 | ||
469 | qDebug("copy "+curFile+" as "+destFile); | 469 | qDebug("copy "+curFile+" as "+destFile); |
470 | } | 470 | } |
471 | delete fileDlg; | 471 | delete fileDlg; |
472 | } | 472 | } |
473 | PopulateView(); | 473 | populateView(); |
474 | } | 474 | } |
475 | 475 | ||
476 | void AdvancedFm::move() | 476 | void AdvancedFm::move() |
477 | { | 477 | { |
478 | qApp->processEvents(); | 478 | qApp->processEvents(); |
479 | 479 | ||
480 | QStringList curFileList = getPath(); | 480 | QStringList curFileList = getPath(); |
481 | if( curFileList.count() > 0) | 481 | if( curFileList.count() > 0) |
482 | { | 482 | { |
483 | QString curFile, destFile, item; | 483 | QString curFile, destFile, item; |
484 | 484 | ||
485 | QDir *thisDir = CurrentDir(); | 485 | QDir *thisDir = CurrentDir(); |
486 | QDir *thatDir = OtherDir(); | 486 | QDir *thatDir = OtherDir(); |
487 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 487 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
488 | { | 488 | { |
489 | item=(*it); | 489 | item=(*it); |
490 | QString destFile = thatDir->canonicalPath(); | 490 | QString destFile = thatDir->canonicalPath(); |
491 | 491 | ||
492 | if(destFile.right(1).find("/",0,TRUE) == -1) | 492 | if(destFile.right(1).find("/",0,TRUE) == -1) |
493 | destFile+="/"; | 493 | destFile+="/"; |
494 | destFile += item; | 494 | destFile += item; |
495 | qDebug("Destination file is "+destFile); | 495 | qDebug("Destination file is "+destFile); |
496 | 496 | ||
497 | curFile = thisDir->canonicalPath(); | 497 | curFile = thisDir->canonicalPath(); |
498 | if(curFile.right(1).find("/",0,TRUE) == -1) | 498 | if(curFile.right(1).find("/",0,TRUE) == -1) |
499 | curFile +="/"; | 499 | curFile +="/"; |
500 | curFile+= item; | 500 | curFile+= item; |
501 | qDebug("CurrentFile file is " + curFile); | 501 | qDebug("CurrentFile file is " + curFile); |
502 | 502 | ||
503 | QFile f( curFile); | 503 | QFile f( curFile); |
504 | if( f.exists()) { | 504 | if( f.exists()) { |
505 | if( !copyFile( curFile, destFile) ) | 505 | if( !copyFile( curFile, destFile) ) |
506 | { | 506 | { |
507 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 507 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
508 | return; | 508 | return; |
509 | } else | 509 | } else |
510 | QFile::remove(curFile); | 510 | QFile::remove(curFile); |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | } | 514 | } |
515 | populateRemoteView(); | 515 | setOtherTabCurrent(); |
516 | populateLocalView(); | 516 | populateView(); |
517 | // populateLocalView(); | ||
517 | } | 518 | } |
518 | 519 | ||
519 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 520 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) |
520 | { | 521 | { |
521 | char bf[ 50000 ]; | 522 | char bf[ 50000 ]; |
522 | int bytesRead; | 523 | int bytesRead; |
523 | bool success = TRUE; | 524 | bool success = TRUE; |
524 | struct stat status; | 525 | struct stat status; |
525 | 526 | ||
526 | QFile s( src ); | 527 | QFile s( src ); |
527 | QFile d( dest ); | 528 | QFile d( dest ); |
528 | 529 | ||
529 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) | 530 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) |
530 | { | 531 | { |
531 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) | 532 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) |
532 | { | 533 | { |
533 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 534 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
534 | success = FALSE; | 535 | success = FALSE; |
535 | break; | 536 | break; |
536 | } | 537 | } |
537 | } | 538 | } |
538 | if( success && (bytesRead > 0) ) | 539 | if( success && (bytesRead > 0) ) |
539 | { | 540 | { |
540 | d.writeBlock( bf, bytesRead ); | 541 | d.writeBlock( bf, bytesRead ); |
541 | } | 542 | } |
542 | } | 543 | } |
543 | else | 544 | else |
544 | { | 545 | { |
545 | success = FALSE; | 546 | success = FALSE; |
546 | } | 547 | } |
547 | 548 | ||
548 | // Set file permissions | 549 | // Set file permissions |
549 | if( stat( (const char *) src, &status ) == 0 ) | 550 | if( stat( (const char *) src, &status ) == 0 ) |
550 | { | 551 | { |
551 | chmod( (const char *) dest, status.st_mode ); | 552 | chmod( (const char *) dest, status.st_mode ); |
552 | } | 553 | } |
553 | 554 | ||
554 | return success; | 555 | return success; |
555 | } | 556 | } |
556 | 557 | ||
557 | void AdvancedFm::runCommand() | 558 | void AdvancedFm::runCommand() |
558 | { | 559 | { |
559 | QDir *thisDir = CurrentDir(); | 560 | QDir *thisDir = CurrentDir(); |
560 | 561 | ||
561 | QString curFile; | 562 | QString curFile; |
562 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 563 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
563 | 564 | ||
564 | InputDialog *fileDlg; | 565 | InputDialog *fileDlg; |
565 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 566 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
566 | fileDlg->setInputText(curFile); | 567 | fileDlg->setInputText(curFile); |
567 | fileDlg->exec(); | 568 | fileDlg->exec(); |
568 | //QString command; | 569 | //QString command; |
569 | 570 | ||
570 | if( fileDlg->result() == 1 ) | 571 | if( fileDlg->result() == 1 ) |
571 | { | 572 | { |
572 | qDebug(fileDlg->LineEdit1->text()); | 573 | qDebug(fileDlg->LineEdit1->text()); |
573 | QStringList command; | 574 | QStringList command; |
574 | 575 | ||
575 | command << "/bin/sh"; | 576 | command << "/bin/sh"; |
576 | command << "-c"; | 577 | command << "-c"; |
577 | command << fileDlg->LineEdit1->text(); | 578 | command << fileDlg->LineEdit1->text(); |
578 | Output *outDlg; | 579 | Output *outDlg; |
579 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 580 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
580 | outDlg->showMaximized(); | 581 | outDlg->showMaximized(); |
581 | outDlg->exec(); | 582 | outDlg->exec(); |
582 | qApp->processEvents(); | 583 | qApp->processEvents(); |
583 | 584 | ||
584 | } | 585 | } |
585 | } | 586 | } |
586 | 587 | ||
587 | void AdvancedFm::runCommandStd() | 588 | void AdvancedFm::runCommandStd() |
588 | { | 589 | { |
589 | QString curFile; | 590 | QString curFile; |
590 | QDir *thisDir = CurrentDir(); | 591 | QDir *thisDir = CurrentDir(); |
591 | QListView *thisView = CurrentView(); | 592 | QListView *thisView = CurrentView(); |
592 | if( thisView->currentItem()) | 593 | if( thisView->currentItem()) |
593 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 594 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
594 | 595 | ||
595 | InputDialog *fileDlg; | 596 | InputDialog *fileDlg; |
596 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 597 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
597 | fileDlg->setInputText(curFile); | 598 | fileDlg->setInputText(curFile); |
598 | fileDlg->exec(); | 599 | fileDlg->exec(); |
599 | 600 | ||
600 | if( fileDlg->result() == 1 ) | 601 | if( fileDlg->result() == 1 ) |
601 | { | 602 | { |
602 | qApp->processEvents(); | 603 | qApp->processEvents(); |
603 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 604 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
604 | } | 605 | } |
605 | } | 606 | } |
606 | 607 | ||
607 | void AdvancedFm::fileStatus() | 608 | void AdvancedFm::fileStatus() |
608 | { | 609 | { |
609 | QString curFile; | 610 | QString curFile; |
610 | curFile = CurrentView()->currentItem()->text(0); | 611 | curFile = CurrentView()->currentItem()->text(0); |
611 | 612 | ||
612 | QStringList command; | 613 | QStringList command; |
613 | command << "/bin/sh"; | 614 | command << "/bin/sh"; |
614 | command << "-c"; | 615 | command << "-c"; |
615 | command << "stat -l "+ curFile; | 616 | command << "stat -l "+ curFile; |
616 | 617 | ||
617 | Output *outDlg; | 618 | Output *outDlg; |
618 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 619 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
619 | outDlg->showMaximized(); | 620 | outDlg->showMaximized(); |
620 | outDlg->exec(); | 621 | outDlg->exec(); |
621 | qApp->processEvents(); | 622 | qApp->processEvents(); |
622 | } | 623 | } |
623 | 624 | ||
624 | 625 | ||
625 | void AdvancedFm::mkDir() | 626 | void AdvancedFm::mkDir() |
626 | { | 627 | { |
627 | makeDir(); | 628 | makeDir(); |
628 | } | 629 | } |
629 | 630 | ||
630 | void AdvancedFm::rn() | 631 | void AdvancedFm::rn() |
631 | { | 632 | { |
632 | renameIt(); | 633 | renameIt(); |
633 | } | 634 | } |
634 | 635 | ||
635 | void AdvancedFm::del() | 636 | void AdvancedFm::del() |
636 | { | 637 | { |
637 | doDelete(); | 638 | doDelete(); |
638 | } | 639 | } |
639 | 640 | ||
640 | void AdvancedFm::mkSym() | 641 | void AdvancedFm::mkSym() |
641 | { | 642 | { |
642 | QString cmd; | 643 | QString cmd; |
643 | QStringList curFileList = getPath(); | 644 | QStringList curFileList = getPath(); |
644 | if( curFileList.count() > 0) | 645 | if( curFileList.count() > 0) |
645 | { | 646 | { |
646 | if ( whichTab == 1) | 647 | QDir *thisDir = CurrentDir(); |
647 | { | 648 | QDir * thatDir = OtherDir(); |
648 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | ||
649 | { | ||
650 | 649 | ||
651 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 650 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
652 | if(destName.right(1) == "/") | ||
653 | { | ||
654 | destName = destName.left( destName.length() -1); | ||
655 | } | ||
656 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
657 | if( curFile.right(1) == "/") | ||
658 | { | ||
659 | curFile = curFile.left( curFile.length() -1); | ||
660 | } | ||
661 | cmd = "ln -s "+curFile+" "+destName; | ||
662 | qDebug(cmd); | ||
663 | startProcess( (const QString)cmd ); | ||
664 | } | ||
665 | populateRemoteView(); | ||
666 | TabWidget->setCurrentTab(1); | ||
667 | } | ||
668 | else | ||
669 | { | 651 | { |
670 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 652 | |
653 | QString destName = thatDir->canonicalPath()+"/"+(*it); | ||
654 | if(destName.right(1) == "/") | ||
671 | { | 655 | { |
656 | destName = destName.left( destName.length() -1); | ||
657 | } | ||
672 | 658 | ||
673 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 659 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
674 | if(destName.right(1) == "/") | ||
675 | { | ||
676 | destName = destName.left( destName.length() -1); | ||
677 | } | ||
678 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
679 | if( curFile.right(1) == "/") | ||
680 | { | ||
681 | curFile = curFile.left( curFile.length() -1); | ||
682 | } | ||
683 | 660 | ||
684 | cmd = "ln -s "+curFile+" "+destName; | 661 | if( curFile.right(1) == "/") |
685 | qDebug(cmd); | 662 | { |
686 | startProcess( (const QString)cmd ); | 663 | curFile = curFile.left( curFile.length() -1); |
687 | } | 664 | } |
688 | populateLocalView(); | 665 | |
689 | TabWidget->setCurrentTab(0); | 666 | cmd = "ln -s "+curFile+" "+destName; |
690 | } | 667 | qDebug(cmd); |
691 | } | 668 | startProcess( (const QString)cmd ); |
669 | } | ||
670 | setOtherTabCurrent(); | ||
671 | populateView(); | ||
672 | } | ||
692 | } | 673 | } |
693 | 674 | ||
694 | void AdvancedFm::doBeam() | 675 | void AdvancedFm::doBeam() |
695 | { | 676 | { |
696 | Ir ir; | 677 | Ir ir; |
697 | if(!ir.supported()) | 678 | if(!ir.supported()) |
698 | { | 679 | { |
699 | } | 680 | } |
700 | else | 681 | else |
701 | { | 682 | { |
702 | |||
703 | QStringList curFileList = getPath(); | 683 | QStringList curFileList = getPath(); |
704 | if( curFileList.count() > 0) | 684 | if( curFileList.count() > 0) |
705 | { | 685 | { |
706 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 686 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
707 | { | 687 | { |
708 | 688 | ||
709 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); | 689 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); |
710 | if( curFile.right(1) == "/") | 690 | if( curFile.right(1) == "/") |
711 | { | 691 | { |
712 | curFile = curFile.left( curFile.length() -1); | 692 | curFile = curFile.left( curFile.length() -1); |
713 | } | 693 | } |
714 | Ir *file = new Ir(this, "IR"); | 694 | Ir *file = new Ir(this, "IR"); |
715 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 695 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
716 | file->send( curFile, curFile ); | 696 | file->send( curFile, curFile ); |
717 | } | 697 | } |
718 | } | 698 | } |
719 | } | 699 | } |
720 | 700 | ||
721 | } | 701 | } |
722 | 702 | ||
723 | void AdvancedFm::fileBeamFinished( Ir *) | 703 | void AdvancedFm::fileBeamFinished( Ir *) |
724 | { | 704 | { |
725 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 705 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
726 | } | 706 | } |
727 | 707 | ||
728 | void AdvancedFm::selectAll() | 708 | void AdvancedFm::selectAll() |
729 | { | 709 | { |
730 | // if (TabWidget->getCurrentTab() == 0) { | 710 | // if (TabWidget->getCurrentTab() == 0) { |
731 | QListView *thisView = CurrentView(); | 711 | QListView *thisView = CurrentView(); |
732 | thisView->selectAll(true); | 712 | thisView->selectAll(true); |
733 | thisView->setSelected( thisView->firstChild(),false); | 713 | thisView->setSelected( thisView->firstChild(),false); |
734 | // } else { | 714 | // } else { |
735 | // Remote_View->selectAll(true); | 715 | // Remote_View->selectAll(true); |
736 | // Remote_View->setSelected( Remote_View->firstChild(),false); | 716 | // Remote_View->setSelected( Remote_View->firstChild(),false); |
737 | // } | 717 | // } |
738 | } | 718 | } |
739 | 719 | ||
740 | void AdvancedFm::startProcess(const QString & cmd) | 720 | void AdvancedFm::startProcess(const QString & cmd) |
741 | { | 721 | { |
742 | QStringList command; | 722 | QStringList command; |
743 | OProcess *process; | 723 | OProcess *process; |
744 | process = new OProcess(); | 724 | process = new OProcess(); |
745 | connect(process, SIGNAL(processExited(OProcess *)), | 725 | connect(process, SIGNAL(processExited(OProcess *)), |
746 | this, SLOT( processEnded())); | 726 | this, SLOT( processEnded())); |
747 | 727 | ||
748 | command << "/bin/sh"; | 728 | command << "/bin/sh"; |
749 | command << "-c"; | 729 | command << "-c"; |
750 | command << cmd.latin1(); | 730 | command << cmd.latin1(); |
751 | *process << command; | 731 | *process << command; |
752 | if(!process->start(OProcess::NotifyOnExit) ) | 732 | if(!process->start(OProcess::NotifyOnExit) ) |
753 | qDebug("could not start process"); | 733 | qDebug("could not start process"); |
754 | } | 734 | } |
755 | 735 | ||
756 | void AdvancedFm::processEnded() | 736 | void AdvancedFm::processEnded() |
757 | { | 737 | { |
758 | populateLocalView(); | 738 | // populateLocalView(); |
759 | populateRemoteView(); | 739 | populateView(); |
760 | } | 740 | } |
761 | 741 | ||
762 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 742 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) |
763 | { | 743 | { |
764 | if ( o->inherits( "QLineEdit" ) ) | 744 | if ( o->inherits( "QLineEdit" ) ) |
765 | { | 745 | { |
766 | if ( e->type() == QEvent::KeyPress ) | 746 | if ( e->type() == QEvent::KeyPress ) |
767 | { | 747 | { |
768 | QKeyEvent *ke = (QKeyEvent*)e; | 748 | QKeyEvent *ke = (QKeyEvent*)e; |
769 | if ( ke->key() == Key_Return || | 749 | if ( ke->key() == Key_Return || |
770 | ke->key() == Key_Enter ) | 750 | ke->key() == Key_Enter ) |
771 | { | 751 | { |
772 | okRename(); | 752 | okRename(); |
773 | return true; | 753 | return true; |
774 | } | 754 | } |
775 | else if ( ke->key() == Key_Escape ) | 755 | else if ( ke->key() == Key_Escape ) |
776 | { | 756 | { |
777 | cancelRename(); | 757 | cancelRename(); |
778 | return true; | 758 | return true; |
779 | } | 759 | } |
780 | } | 760 | } |
781 | else if ( e->type() == QEvent::FocusOut ) | 761 | else if ( e->type() == QEvent::FocusOut ) |
782 | { | 762 | { |
783 | cancelRename(); | 763 | cancelRename(); |
784 | return true; | 764 | return true; |
785 | } | 765 | } |
786 | } | 766 | } |
787 | if ( o->inherits( "QListView" ) ) | 767 | if ( o->inherits( "QListView" ) ) |
788 | { | 768 | { |
789 | if ( e->type() == QEvent::FocusOut ) | 769 | if ( e->type() == QEvent::FocusOut ) |
790 | { | 770 | { |
791 | printf("focusIn\n"); | 771 | printf("focusIn\n"); |
792 | 772 | ||
793 | } | 773 | } |
794 | } | 774 | } |
795 | 775 | ||
796 | return QWidget::eventFilter( o, e ); | 776 | return QWidget::eventFilter( o, e ); |
797 | } | 777 | } |
798 | 778 | ||
799 | 779 | ||
800 | void AdvancedFm::cancelRename() | 780 | void AdvancedFm::cancelRename() |
801 | { | 781 | { |
802 | qDebug("cancel rename"); | 782 | qDebug("cancel rename"); |
803 | QListView * view; | 783 | QListView * view; |
804 | view = CurrentView(); | 784 | view = CurrentView(); |
805 | 785 | ||
806 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 786 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
807 | delete renameBox; | 787 | delete renameBox; |
808 | renameBox = 0; | 788 | renameBox = 0; |
809 | if ( resetFocus ) | 789 | if ( resetFocus ) |
810 | { | 790 | { |
811 | view->viewport()->setFocusProxy( view); | 791 | view->viewport()->setFocusProxy( view); |
812 | view->setFocus(); | 792 | view->setFocus(); |
813 | } | 793 | } |
814 | } | 794 | } |
815 | 795 | ||
816 | void AdvancedFm::doRename(QListView * view) | 796 | void AdvancedFm::doRename(QListView * view) |
817 | { | 797 | { |
818 | 798 | ||
819 | QRect r = view->itemRect( view->currentItem( )); | 799 | QRect r = view->itemRect( view->currentItem( )); |
820 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 800 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
821 | r.setX( view->contentsX() ); | 801 | r.setX( view->contentsX() ); |
822 | if ( r.width() > view->visibleWidth() ) | 802 | if ( r.width() > view->visibleWidth() ) |
823 | r.setWidth( view->visibleWidth() ); | 803 | r.setWidth( view->visibleWidth() ); |
824 | 804 | ||
825 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 805 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
826 | renameBox->setFrame(true); | 806 | renameBox->setFrame(true); |
827 | 807 | ||
828 | renameBox->setText( view->currentItem()->text(0) ); | 808 | renameBox->setText( view->currentItem()->text(0) ); |
829 | 809 | ||
830 | renameBox->selectAll(); | 810 | renameBox->selectAll(); |
831 | renameBox->installEventFilter( this ); | 811 | renameBox->installEventFilter( this ); |
832 | view->addChild( renameBox, r.x(), r.y() ); | 812 | view->addChild( renameBox, r.x(), r.y() ); |
833 | renameBox->resize( r.size() ); | 813 | renameBox->resize( r.size() ); |
834 | view->viewport()->setFocusProxy( renameBox ); | 814 | view->viewport()->setFocusProxy( renameBox ); |
835 | renameBox->setFocus(); | 815 | renameBox->setFocus(); |
836 | renameBox->show(); | 816 | renameBox->show(); |
837 | 817 | ||
838 | } | 818 | } |
839 | 819 | ||
840 | 820 | ||
841 | void AdvancedFm::renameIt() | 821 | void AdvancedFm::renameIt() |
842 | { | 822 | { |
843 | QListView *thisView = CurrentView(); | 823 | QListView *thisView = CurrentView(); |
844 | oldName = thisView->currentItem()->text(0); | 824 | oldName = thisView->currentItem()->text(0); |
845 | doRename( thisView ); | 825 | doRename( thisView ); |
846 | PopulateView(); | 826 | populateView(); |
847 | } | 827 | } |
848 | 828 | ||
849 | void AdvancedFm::okRename() | 829 | void AdvancedFm::okRename() |
850 | { | 830 | { |
851 | QString newName = renameBox->text(); | 831 | QString newName = renameBox->text(); |
852 | cancelRename(); | 832 | cancelRename(); |
853 | //int tabs=0; | 833 | //int tabs=0; |
854 | QListView * view = CurrentView(); | 834 | QListView * view = CurrentView(); |
855 | QString path = CurrentDir()->canonicalPath() + "/"; | 835 | QString path = CurrentDir()->canonicalPath() + "/"; |
856 | oldName = path + oldName; | 836 | oldName = path + oldName; |
857 | newName = path + newName; | 837 | newName = path + newName; |
858 | 838 | ||
859 | if( view->currentItem() == NULL) | 839 | if( view->currentItem() == NULL) |
860 | return; | 840 | return; |
861 | if( rename( oldName.latin1(), newName.latin1())== -1) | 841 | if( rename( oldName.latin1(), newName.latin1())== -1) |
862 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 842 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
863 | else | 843 | else |
864 | oldName = ""; | 844 | oldName = ""; |
865 | 845 | ||
866 | view->takeItem( view->currentItem() ); | 846 | view->takeItem( view->currentItem() ); |
867 | delete view->currentItem(); | 847 | delete view->currentItem(); |
868 | PopulateView(); | 848 | populateView(); |
869 | } | 849 | } |