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 /noncore/apps | |
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 | |||
@@ -65,26 +65,28 @@ | |||
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"; |
@@ -106,67 +108,74 @@ void AdvancedFm::tabChanged(QWidget *w) | |||
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"); |
@@ -194,177 +203,56 @@ void AdvancedFm::populateLocalView() | |||
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 | { |
@@ -374,25 +262,25 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) | |||
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 | { |
@@ -425,25 +313,25 @@ void AdvancedFm::readConfig() | |||
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 | { |
@@ -462,25 +350,25 @@ void AdvancedFm::fillCombo(const QString ¤tPath) | |||
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() ) |
@@ -488,58 +376,58 @@ QStringList AdvancedFm::getPath() | |||
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 | ||
@@ -622,25 +510,25 @@ void AdvancedFm::keyPressEvent( QKeyEvent *e) | |||
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 | { |
@@ -939,25 +827,25 @@ void AdvancedFm::gotoCustomDir(const QString &dir) | |||
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 | { |
@@ -968,35 +856,35 @@ QDir *AdvancedFm::CurrentDir() | |||
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 | |||
@@ -54,29 +54,27 @@ 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(); |
@@ -116,25 +114,25 @@ protected: | |||
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(); |
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 | |||
@@ -59,46 +59,46 @@ void AdvancedFm::showMenuHidden() | |||
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(); |
@@ -156,25 +156,25 @@ void AdvancedFm::runText() | |||
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 | { |
@@ -205,68 +205,68 @@ void AdvancedFm::doDelete() | |||
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()); |
@@ -284,25 +284,25 @@ void AdvancedFm::doProperties() | |||
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; |
@@ -351,27 +351,26 @@ void AdvancedFm::copy() | |||
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(); |
@@ -408,25 +407,26 @@ void AdvancedFm::copyAs() | |||
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 ) |
@@ -461,25 +461,25 @@ void AdvancedFm::copySameDir() | |||
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(); |
@@ -503,26 +503,27 @@ void AdvancedFm::move() | |||
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 | ||
@@ -634,81 +635,60 @@ void AdvancedFm::rn() | |||
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"); |
@@ -746,26 +726,26 @@ void AdvancedFm::startProcess(const QString & cmd) | |||
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 | { |
@@ -834,36 +814,36 @@ void AdvancedFm::doRename(QListView * view) | |||
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 | } |