summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp34
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp18
2 files changed, 26 insertions, 26 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index fc6c3bf..d56e746 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,890 +1,888 @@
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
71AdvancedFm::AdvancedFm( ) 71AdvancedFm::AdvancedFm( )
72 : QMainWindow( ) { 72 : QMainWindow( ) {
73 init(); 73 init();
74 renameBox = 0; 74 renameBox = 0;
75 75
76 initConnections(); 76 initConnections();
77 TabWidget->setCurrentTab(1); 77 TabWidget->setCurrentTab(1);
78 populateView(); 78 populateView();
79 TabWidget->setCurrentTab(0); 79 TabWidget->setCurrentTab(0);
80 populateView(); 80 populateView();
81 currentPathCombo->setFocus(); 81 currentPathCombo->setFocus();
82} 82}
83 83
84AdvancedFm::~AdvancedFm() { 84AdvancedFm::~AdvancedFm() {
85} 85}
86 86
87 87
88void AdvancedFm::cleanUp() 88void AdvancedFm::cleanUp()
89{ 89{
90 QString sfile=QDir::homeDirPath(); 90 QString sfile=QDir::homeDirPath();
91 if(sfile.right(1) != "/") 91 if(sfile.right(1) != "/")
92 sfile+="/._temp"; 92 sfile+="/._temp";
93 else 93 else
94 sfile+="._temp"; 94 sfile+="._temp";
95 QFile file( sfile); 95 QFile file( sfile);
96 if(file.exists()) 96 if(file.exists())
97 file.remove(); 97 file.remove();
98} 98}
99 99
100void AdvancedFm::tabChanged(QWidget *w) 100void AdvancedFm::tabChanged(QWidget *w)
101{ 101{
102 if( w == tab) 102 if( w == tab)
103 whichTab = 1; 103 whichTab = 1;
104 else 104 else
105 whichTab = 2; 105 whichTab = 2;
106 106
107 //qDebug("tab changed %d", whichTab ); 107 //qDebug("tab changed %d", whichTab );
108 108
109 QString path = CurrentDir()->canonicalPath(); 109 QString path = CurrentDir()->canonicalPath();
110 currentPathCombo->lineEdit()->setText( path ); 110 currentPathCombo->lineEdit()->setText( path );
111 111
112 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 112 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
113 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 113 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
114 114
115 QString fs= getFileSystemType( (const QString &) path); 115 QString fs= getFileSystemType( (const QString &) path);
116 116
117 setCaption("AdvancedFm :: "+fs+" :: " 117 setCaption("AdvancedFm :: "+fs+" :: "
118 +checkDiskSpace( (const QString &) path )+ " kB free" ); 118 +checkDiskSpace( (const QString &) path )+ " kB free" );
119 chdir( path.latin1()); 119 chdir( path.latin1());
120 //2populateView(); 120 //2populateView();
121} 121}
122 122
123 123
124void AdvancedFm::populateView() 124void AdvancedFm::populateView()
125{ 125{
126 QPixmap pm; 126 QPixmap pm;
127 QListView *thisView = CurrentView(); 127 QListView *thisView = CurrentView();
128 QDir *thisDir = CurrentDir(); 128 QDir *thisDir = CurrentDir();
129 QString path = thisDir->canonicalPath(); 129 QString path = thisDir->canonicalPath();
130 130
131 thisView->clear(); 131 thisView->clear();
132 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 132 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
133 thisDir->setMatchAllDirs(TRUE); 133 thisDir->setMatchAllDirs(TRUE);
134 thisDir->setNameFilter(filterStr); 134 thisDir->setNameFilter(filterStr);
135 QString fileL, fileS, fileDate; 135 QString fileL, fileS, fileDate;
136 QString fs= getFileSystemType((const QString &) path); 136 QString fs= getFileSystemType((const QString &) path);
137 setCaption("AdvancedFm :: "+fs+" :: " 137 setCaption("AdvancedFm :: "+fs+" :: "
138 +checkDiskSpace((const QString &) path)+" kB free" ); 138 +checkDiskSpace((const QString &) path)+" kB free" );
139 bool isDir=FALSE; 139 bool isDir=FALSE;
140 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 140 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
141 QFileInfoListIterator it(*list); 141 QFileInfoListIterator it(*list);
142 QFileInfo *fi; 142 QFileInfo *fi;
143 while ( (fi=it.current()) ) 143 while ( (fi=it.current()) )
144 { 144 {
145 if (fi->isSymLink() ) 145 if (fi->isSymLink() )
146 { 146 {
147 QString symLink=fi->readLink(); 147 QString symLink=fi->readLink();
148 QFileInfo sym( symLink); 148 QFileInfo sym( symLink);
149 fileS.sprintf( "%10i", sym.size() ); 149 fileS.sprintf( "%10i", sym.size() );
150 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 150 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
151 fileDate = sym.lastModified().toString(); 151 fileDate = sym.lastModified().toString();
152 } 152 }
153 else 153 else
154 { 154 {
155 fileS.sprintf( "%10i", fi->size() ); 155 fileS.sprintf( "%10i", fi->size() );
156 fileL.sprintf( "%s",fi->fileName().data() ); 156 fileL.sprintf( "%s",fi->fileName().data() );
157 fileDate= fi->lastModified().toString(); 157 fileDate= fi->lastModified().toString();
158 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) 158 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() )
159 { 159 {
160 fileL+="/"; 160 fileL+="/";
161 isDir=TRUE; 161 isDir=TRUE;
162 } 162 }
163 } 163 }
164 164
165 QFileInfo fileInfo( path + "/" + fileL); 165 QFileInfo fileInfo( path + "/" + fileL);
166 166
167 if(fileL !="./" && fi->exists()) 167 if(fileL !="./" && fi->exists())
168 { 168 {
169 item= new QListViewItem( thisView, fileL, fileS , fileDate); 169 item= new QListViewItem( thisView, fileL, fileS , fileDate);
170 170
171 if(isDir || fileL.find("/",0,TRUE) != -1) 171 if(isDir || fileL.find("/",0,TRUE) != -1)
172 { 172 {
173 173
174 if( !QDir( fi->filePath() ).isReadable()) //is directory 174 if( !QDir( fi->filePath() ).isReadable()) //is directory
175 pm = Resource::loadPixmap( "lockedfolder" ); 175 pm = Resource::loadPixmap( "lockedfolder" );
176 else 176 else
177 pm= Resource::loadPixmap( "folder" ); 177 pm= Resource::loadPixmap( "folder" );
178 } 178 }
179 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) 179 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
180 { 180 {
181 pm = Resource::loadPixmap( "exec"); 181 pm = Resource::loadPixmap( "exec");
182 } 182 }
183 else if( (fileInfo.permission( QFileInfo::ExeUser) 183 else if( (fileInfo.permission( QFileInfo::ExeUser)
184 | fileInfo.permission( QFileInfo::ExeGroup) 184 | fileInfo.permission( QFileInfo::ExeGroup)
185 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) 185 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
186 { 186 {
187 pm = Resource::loadPixmap( "exec"); 187 pm = Resource::loadPixmap( "exec");
188 } 188 }
189 else if( !fi->isReadable() ) 189 else if( !fi->isReadable() )
190 { 190 {
191 pm = Resource::loadPixmap( "locked" ); 191 pm = Resource::loadPixmap( "locked" );
192 } 192 }
193 else { //everything else goes by mimetype 193 else { //everything else goes by mimetype
194 MimeType mt(fi->filePath()); 194 MimeType mt(fi->filePath());
195 pm=mt.pixmap(); //sets the correct pixmap for mimetype 195 pm=mt.pixmap(); //sets the correct pixmap for mimetype
196 if(pm.isNull()) 196 if(pm.isNull())
197 pm = Resource::loadPixmap( "UnknownDocument-14" ); 197 pm = Resource::loadPixmap( "UnknownDocument-14" );
198 } 198 }
199 item->setPixmap( 0,pm); 199 item->setPixmap( 0,pm);
200 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) 200 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
201 { 201 {
202 // overlay link image 202 // overlay link image
203 pm= Resource::loadPixmap( "folder" ); 203 pm= Resource::loadPixmap( "folder" );
204 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 204 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
205 QPainter painter( &pm ); 205 QPainter painter( &pm );
206 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 206 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
207 pm.setMask( pm.createHeuristicMask( FALSE ) ); 207 pm.setMask( pm.createHeuristicMask( FALSE ) );
208 item->setPixmap( 0, pm); 208 item->setPixmap( 0, pm);
209 } 209 }
210 } 210 }
211 isDir=FALSE; 211 isDir=FALSE;
212 ++it; 212 ++it;
213 } 213 }
214 214
215 if( path.find("dev",0,TRUE) != -1) 215 if( path.find("dev",0,TRUE) != -1)
216 { 216 {
217 struct stat buf; 217 struct stat buf;
218 dev_t devT; 218 dev_t devT;
219 DIR *dir; 219 DIR *dir;
220 struct dirent *mydirent; 220 struct dirent *mydirent;
221 221
222 if((dir = opendir( path.latin1())) != NULL) 222 if((dir = opendir( path.latin1())) != NULL)
223 while ((mydirent = readdir(dir)) != NULL) 223 while ((mydirent = readdir(dir)) != NULL)
224 { 224 {
225 lstat( mydirent->d_name, &buf); 225 lstat( mydirent->d_name, &buf);
226// qDebug(mydirent->d_name); 226// qDebug(mydirent->d_name);
227 fileL.sprintf("%s", mydirent->d_name); 227 fileL.sprintf("%s", mydirent->d_name);
228 devT = buf.st_dev; 228 devT = buf.st_dev;
229 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 229 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
230 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 230 fileDate.sprintf("%s", ctime( &buf.st_mtime));
231 if( fileL.find(".") == -1 ) 231 if( fileL.find(".") == -1 )
232 { 232 {
233 item= new QListViewItem( thisView, fileL, fileS, fileDate); 233 item= new QListViewItem( thisView, fileL, fileS, fileDate);
234 pm = Resource::loadPixmap( "UnknownDocument-14" ); 234 pm = Resource::loadPixmap( "UnknownDocument-14" );
235 item->setPixmap( 0,pm); 235 item->setPixmap( 0,pm);
236 } 236 }
237 } 237 }
238 238
239 closedir(dir); 239 closedir(dir);
240 } 240 }
241 241
242 thisView->setSorting( 3,FALSE); 242 thisView->setSorting( 3,FALSE);
243 fillCombo( (const QString &) path ); 243 fillCombo( (const QString &) path );
244} 244}
245 245
246 246
247void AdvancedFm::ListClicked(QListViewItem *selectedItem) 247void AdvancedFm::ListClicked(QListViewItem *selectedItem)
248{ 248{
249 if(selectedItem) 249 if(selectedItem)
250 { 250 {
251 QString strItem=selectedItem->text(0); 251 QString strItem=selectedItem->text(0);
252 QString strSize=selectedItem->text(1); 252 QString strSize=selectedItem->text(1);
253 strSize=strSize.stripWhiteSpace(); 253 strSize=strSize.stripWhiteSpace();
254 bool isDirectory = false; 254 bool isDirectory = false;
255 QString strItem2; 255 QString strItem2;
256 256
257 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
258 { 258 {
259 strItem2 = dealWithSymName((const QString&)strItem); 259 strItem2 = dealWithSymName((const QString&)strItem);
260 if(QDir(strItem2).exists() ) 260 if(QDir(strItem2).exists() )
261 strItem = strItem2; 261 strItem = strItem2;
262 } 262 }
263 263
264 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) 264 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 )
265 { 265 {
266 266
267 if(QDir(strItem).exists()) 267 if(QDir(strItem).exists())
268 isDirectory = true; 268 isDirectory = true;
269 } 269 }
270 270
271 if( isDirectory ) 271 if( isDirectory )
272 { 272 {
273 CurrentDir()->cd( strItem, TRUE); 273 CurrentDir()->cd( strItem, TRUE);
274 populateView(); 274 populateView();
275 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 275 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
276 } 276 }
277 chdir( strItem.latin1()); 277 chdir( strItem.latin1());
278 } 278 }
279} 279}
280 280
281void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 281void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
282 switch (mouse) { 282 switch (mouse) {
283 case 1: 283 case 1:
284 { 284 {
285 if(renameBox != 0 ) 285 if(renameBox != 0 )
286 { 286 {
287 cancelRename(); 287 cancelRename();
288 } 288 }
289
290 } 289 }
291 break; 290 break;
292 case 2: 291 case 2:
293 menuTimer.start( 500, TRUE ); 292 menuTimer.start( 500, TRUE );
294 break; 293 break;
295 }; 294 };
296} 295}
297 296
298void AdvancedFm::switchToLocalTab() 297void AdvancedFm::switchToLocalTab()
299{ 298{
300 TabWidget->setCurrentTab(0); 299 TabWidget->setCurrentTab(0);
301 Local_View->setFocus(); 300 Local_View->setFocus();
302} 301}
303 302
304void AdvancedFm::switchToRemoteTab() 303void AdvancedFm::switchToRemoteTab()
305{ 304{
306 TabWidget->setCurrentTab(1); 305 TabWidget->setCurrentTab(1);
307 Remote_View->setFocus(); 306 Remote_View->setFocus();
308} 307}
309 308
310void AdvancedFm::readConfig() 309void AdvancedFm::readConfig()
311{ 310{
312 Config cfg("AdvancedFm"); 311 Config cfg("AdvancedFm");
313} 312}
314 313
315void AdvancedFm::writeConfig() 314void AdvancedFm::writeConfig()
316{ 315{
317 Config cfg("AdvancedFm"); 316 Config cfg("AdvancedFm");
318} 317}
319 318
320void AdvancedFm::currentPathComboChanged() 319void AdvancedFm::currentPathComboChanged()
321{ 320{
322 if(QDir( currentPathCombo->lineEdit()->text()).exists()) 321 if(QDir( currentPathCombo->lineEdit()->text()).exists())
323 { 322 {
324 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 323 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
325 populateView(); 324 populateView();
326 } 325 }
327 else 326 else
328 { 327 {
329 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 328 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
330 } 329 }
331} 330}
332 331
333void AdvancedFm::fillCombo(const QString &currentPath) 332void AdvancedFm::fillCombo(const QString &currentPath)
334{ 333{
335// qDebug("%d",TabWidget->getCurrentTab()); 334// qDebug("%d",TabWidget->getCurrentTab());
336 if ( whichTab == 1) 335 if ( whichTab == 1)
337 { 336 {
338 currentPathCombo->lineEdit()->setText( currentPath); 337 currentPathCombo->lineEdit()->setText( currentPath);
339 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 338 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() )
340 { 339 {
341 currentPathCombo->clear(); 340 currentPathCombo->clear();
342 localDirPathStringList.prepend( currentPath ); 341 localDirPathStringList.prepend( currentPath );
343 currentPathCombo->insertStringList( localDirPathStringList,-1); 342 currentPathCombo->insertStringList( localDirPathStringList,-1);
344 } 343 }
345 } 344 }
346 else 345 else
347 { 346 {
348 currentPathCombo->lineEdit()->setText( currentPath); 347 currentPathCombo->lineEdit()->setText( currentPath);
349 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 348 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() )
350 { 349 {
351 currentPathCombo->clear(); 350 currentPathCombo->clear();
352 remoteDirPathStringList.prepend( currentPath ); 351 remoteDirPathStringList.prepend( currentPath );
353 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 352 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
354 } 353 }
355 } 354 }
356} 355}
357 356
358void AdvancedFm::currentPathComboActivated(const QString & currentPath) 357void AdvancedFm::currentPathComboActivated(const QString & currentPath)
359{ 358{
360 chdir( currentPath.latin1() ); 359 chdir( currentPath.latin1() );
361 CurrentDir()->cd( currentPath, TRUE); 360 CurrentDir()->cd( currentPath, TRUE);
362 populateView(); 361 populateView();
363 update(); 362 update();
364} 363}
365 364
366QStringList AdvancedFm::getPath() 365QStringList AdvancedFm::getPath()
367{ 366{
368 QStringList strList; 367 QStringList strList;
369 QListView *thisView=CurrentView(); 368 QListView *thisView=CurrentView();
370 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 369 QList<QListViewItem> * getSelectedItems( QListView * thisView );
371 QListViewItemIterator it( thisView ); 370 QListViewItemIterator it( thisView );
372 for ( ; it.current(); ++it ) 371 for ( ; it.current(); ++it )
373 { 372 {
374 if ( it.current()->isSelected() ) 373 if ( it.current()->isSelected() )
375 { 374 {
376 strList << it.current()->text(0); 375 strList << it.current()->text(0);
377// qDebug(it.current()->text(0)); 376// qDebug(it.current()->text(0));
378 } 377 }
379 } 378 }
380 return strList; 379 return strList;
381} 380}
382 381
383void AdvancedFm::homeButtonPushed() 382void AdvancedFm::homeButtonPushed()
384{ 383{
385 QString current = QDir::homeDirPath(); 384 QString current = QDir::homeDirPath();
386 chdir( current.latin1() ); 385 chdir( current.latin1() );
387 CurrentDir()->cd( current, TRUE); 386 CurrentDir()->cd( current, TRUE);
388 populateView(); 387 populateView();
389 update(); 388 update();
390} 389}
391 390
392void AdvancedFm::docButtonPushed() 391void AdvancedFm::docButtonPushed()
393{ 392{
394 QString current = QPEApplication::documentDir(); 393 QString current = QPEApplication::documentDir();
395 chdir( current.latin1() ); 394 chdir( current.latin1() );
396 395 CurrentDir()->cd( current, TRUE);
397 CurrentDir()->cd( current, TRUE); 396 populateView();
398 populateView();
399 update(); 397 update();
400} 398}
401 399
402void AdvancedFm::SDButtonPushed() 400void AdvancedFm::SDButtonPushed()
403{ 401{
404 QString current = "/mnt/card";// this can change so fix 402 QString current = "/mnt/card";// this can change so fix
405 chdir( current.latin1() ); 403 chdir( current.latin1() );
406 CurrentDir()->cd( current, TRUE); 404 CurrentDir()->cd( current, TRUE);
407 populateView(); 405 populateView();
408 update(); 406 update();
409} 407}
410 408
411void AdvancedFm::CFButtonPushed() 409void AdvancedFm::CFButtonPushed()
412{ 410{
413 QString current; 411 QString current;
414 if(zaurusDevice) 412 if(zaurusDevice)
415 current= "/mnt/cf"; //zaurus 413 current= "/mnt/cf"; //zaurus
416 else 414 else
417 current = "/mnt/hda"; //ipaq 415 current = "/mnt/hda"; //ipaq
418
419 chdir( current.latin1() ); 416 chdir( current.latin1() );
420 CurrentDir()->cd( current, TRUE); 417 CurrentDir()->cd( current, TRUE);
421 populateView(); 418 populateView();
422 update(); 419 update();
423} 420}
424 421
425 422
426void AdvancedFm::doAbout() 423void AdvancedFm::doAbout()
427{ 424{
428 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 425 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
429 "is copyright 2002-2003 by\n" 426 "is copyright 2002-2003 by\n"
430 "L.J.Potter<llornkcor@handhelds.org>\n" 427 "L.J.Potter<llornkcor@handhelds.org>\n"
431 "and is licensed by the GPL")); 428 "and is licensed by the GPL"));
432} 429}
433 430
434void AdvancedFm::keyPressEvent( QKeyEvent *e) 431void AdvancedFm::keyPressEvent( QKeyEvent *e)
435{ 432{
436// e->accept(); 433// e->accept();
437 if( CurrentView()->hasFocus() ) 434 if( CurrentView()->hasFocus() )
438 { 435 {
439 switch ( e->key() ) { 436 switch ( e->key() ) {
440 case Key_Delete: 437 case Key_Delete:
441 del(); 438 del();
442 break; 439 break;
443 case Key_A: 440 case Key_A:
444 copyAs(); 441 copyAs();
445 break; 442 break;
446 case Key_C: 443 case Key_C:
447 copy(); 444 copy();
448 break; 445 break;
449 case Key_E: 446 case Key_E:
450 runThis(); 447 runThis();
451 break; 448 break;
452 case Key_G: 449 case Key_G:
453 { 450 {
454 currentPathCombo->lineEdit()->setFocus(); 451 currentPathCombo->lineEdit()->setFocus();
455 } 452 }
456 break; 453 break;
457 454
458 case Key_H: 455 case Key_H:
459 showHidden(); 456 showHidden();
460 break; 457 break;
461 case Key_I: 458 case Key_I:
462 fileStatus(); 459 fileStatus();
463 break; 460 break;
464 case Key_M: 461 case Key_M:
465 move(); 462 move();
466 break; 463 break;
467 case Key_N: 464 case Key_N:
468 mkDir(); 465 mkDir();
469 break; 466 break;
470 case Key_P: 467 case Key_P:
471 filePerms(); 468 filePerms();
472 break; 469 break;
473 case Key_R: 470 case Key_R:
474 rn(); 471 rn();
475 break; 472 break;
476 case Key_U: 473 case Key_U:
477 upDir(); 474 upDir();
478 break; 475 break;
479 case Key_1: 476 case Key_1:
480 switchToLocalTab(); 477 switchToLocalTab();
481 break; 478 break;
482 case Key_2: 479 case Key_2:
483 switchToRemoteTab(); 480 switchToRemoteTab();
484 break; 481 break;
485 case Key_3: 482 case Key_3:
486 CFButtonPushed(); 483 CFButtonPushed();
487 break; 484 break;
488 case Key_4: 485 case Key_4:
489 SDButtonPushed(); 486 SDButtonPushed();
490 break; 487 break;
491 case Key_5: 488 case Key_5:
492 homeButtonPushed(); 489 homeButtonPushed();
493 break; 490 break;
494 case Key_6: 491 case Key_6:
495 docButtonPushed(); 492 docButtonPushed();
496 break; 493 break;
497 case Key_7: 494 case Key_7:
498 break; 495 break;
499 case Key_8: 496 case Key_8:
500 break; 497 break;
501 case Key_9: 498 case Key_9:
502 break; 499 break;
503 case Key_0: 500 case Key_0:
504 break; 501 break;
505 }; 502 };
506 e->accept(); 503 e->accept();
507 } 504 }
508} 505}
509 506
510void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 507void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
511{ 508{
512 if( CurrentView()->hasFocus() ) 509 if( CurrentView()->hasFocus() )
513 e->ignore(); 510 e->ignore();
514} 511}
515 512
516 513
517void AdvancedFm::QPEButtonPushed() 514void AdvancedFm::QPEButtonPushed()
518{ 515{
519 QString current = QPEApplication::qpeDir(); 516 QString current = QPEApplication::qpeDir();
520 chdir( current.latin1() ); 517 chdir( current.latin1() );
521 CurrentDir()->cd( current, TRUE); 518 CurrentDir()->cd( current, TRUE);
522 populateView(); 519 populateView();
523 update(); 520 update();
524} 521}
525 522
526void AdvancedFm::parsetab(const QString &fileName) 523void AdvancedFm::parsetab(const QString &fileName)
527{ 524{
528 525
529 fileSystemTypeList.clear(); 526 fileSystemTypeList.clear();
530 fsList.clear(); 527 fsList.clear();
531 struct mntent *me; 528 struct mntent *me;
532 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 529 FILE *mntfp = setmntent( fileName.latin1(), "r" );
533 if ( mntfp ) 530 if ( mntfp )
534 { 531 {
535 while ( (me = getmntent( mntfp )) != 0 ) 532 while ( (me = getmntent( mntfp )) != 0 )
536 { 533 {
537 QString deviceName = me->mnt_fsname; 534 QString deviceName = me->mnt_fsname;
538 QString filesystemType = me->mnt_type; 535 QString filesystemType = me->mnt_type;
539 QString mountDir = me->mnt_dir; 536 QString mountDir = me->mnt_dir;
540 if(deviceName != "none") 537 if(deviceName != "none")
541 { 538 {
542 if( fsList.contains(filesystemType) == 0 539 if( fsList.contains(filesystemType) == 0
543 & filesystemType.find("proc",0,TRUE) == -1 540 & filesystemType.find("proc",0,TRUE) == -1
544 & filesystemType.find("cramfs",0,TRUE) == -1 541 & filesystemType.find("cramfs",0,TRUE) == -1
545 & filesystemType.find("auto",0,TRUE) == -1) 542 & filesystemType.find("auto",0,TRUE) == -1)
546 fsList << filesystemType; 543 fsList << filesystemType;
547 fileSystemTypeList << mountDir+"::"+filesystemType; 544 fileSystemTypeList << mountDir+"::"+filesystemType;
548 } 545 }
549 } 546 }
550 } 547 }
551 endmntent( mntfp ); 548 endmntent( mntfp );
552} 549}
553 550
554QString AdvancedFm::getFileSystemType(const QString &currentText) 551QString AdvancedFm::getFileSystemType(const QString &currentText)
555{ 552{
556 parsetab("/etc/mtab"); //why did TT forget filesystem type? 553 parsetab("/etc/mtab"); //why did TT forget filesystem type?
557 QString current = currentText;//.right( currentText.length()-1); 554 QString current = currentText;//.right( currentText.length()-1);
558 QString baseFs; 555 QString baseFs;
559 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 556 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
560 QString temp = (*it); 557 QString temp = (*it);
561 QString path = temp.left(temp.find("::",0,TRUE) ); 558 QString path = temp.left(temp.find("::",0,TRUE) );
562 path = path.right( path.length()-1); 559 path = path.right( path.length()-1);
563 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 560 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
564 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 561 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
565 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 562 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
566 } 563 }
567 } 564 }
568 return baseFs; 565 return baseFs;
569} 566}
570 567
571QString AdvancedFm::getDiskSpace( const QString &path) 568QString AdvancedFm::getDiskSpace( const QString &path)
572{ 569{
573 struct statfs fss; 570 struct statfs fss;
574 if ( !statfs( path.latin1(), &fss ) ) { 571 if ( !statfs( path.latin1(), &fss ) ) {
575 int blkSize = fss.f_bsize; 572 int blkSize = fss.f_bsize;
576 // int totalBlks = fs.f_blocks; 573 // int totalBlks = fs.f_blocks;
577 int availBlks = fss.f_bavail; 574 int availBlks = fss.f_bavail;
578 575
579 long mult = blkSize / 1024; 576 long mult = blkSize / 1024;
580 long div = 1024 / blkSize; 577 long div = 1024 / blkSize;
581 if ( !mult ) mult = 1; 578 if ( !mult ) mult = 1;
582 if ( !div ) div = 1; 579 if ( !div ) div = 1;
583 580
584 return QString::number(availBlks * mult / div); 581 return QString::number(availBlks * mult / div);
585 } 582 }
586 return ""; 583 return "";
587} 584}
588 585
589 586
590void AdvancedFm::showFileMenu() 587void AdvancedFm::showFileMenu()
591{ 588{
592 QString curApp; 589 QString curApp;
593 curApp = CurrentView()->currentItem()->text(0); 590 curApp = CurrentView()->currentItem()->text(0);
594 591
595 MimeType mt( curApp ); 592 MimeType mt( curApp );
596 const AppLnk* app = mt.application(); 593 const AppLnk* app = mt.application();
597 QFile fi(curApp); 594 QFile fi(curApp);
598 QPopupMenu *m = new QPopupMenu(0); 595 QPopupMenu *m = new QPopupMenu(0);
599 QPopupMenu *n = new QPopupMenu(0); 596 QPopupMenu *n = new QPopupMenu(0);
600 // QPopupMenu *o = new QPopupMenu(0); 597 // QPopupMenu *o = new QPopupMenu(0);
601 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 598 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
602 599
603 if ( QFileInfo(fi).isDir() ) 600 if ( QFileInfo(fi).isDir() )
604 { 601 {
605 m->insertSeparator(); 602 m->insertSeparator();
606 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); 603 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
607 } 604 }
608 else 605 else
609 { 606 {
610 607
611 if ( app ) 608 if ( app )
612 m->insertItem( app->pixmap(), tr( "Open in " 609 m->insertItem( app->pixmap(), tr( "Open in "
613 + app->name() ), this, SLOT( runThis() ) ); 610 + app->name() ), this, SLOT( runThis() ) );
614 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 611 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
615 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 612 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
616 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 613 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
617 } 614 }
618 615
619 m->insertItem(tr("Actions"),n); 616 m->insertItem(tr("Actions"),n);
620 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); 617 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
621 618
622 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 619 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
623 620
624 n->insertSeparator(); 621 n->insertSeparator();
625 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); 622 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
626 623
627 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 624 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
628 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 625 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
629 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 626 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
630 n->insertItem( tr( "Move" ), this, SLOT( move() )); 627 n->insertItem( tr( "Move" ), this, SLOT( move() ));
631 628
632 n->insertSeparator(); 629 n->insertSeparator();
633 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); 630 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
634 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 631 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
635 632
636 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 633 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
637 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 634 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
638 635
639 m->insertSeparator(); 636 m->insertSeparator();
640 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 637 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
641 638
642#if defined(QT_QWS_OPIE) 639#if defined(QT_QWS_OPIE)
643 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 640 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
644#endif 641#endif
645 m->setCheckable(TRUE); 642 m->setCheckable(TRUE);
646 if (!b) 643 if (!b)
647 m->setItemChecked(m->idAt(0),TRUE); 644 m->setItemChecked(m->idAt(0),TRUE);
648 else 645 else
649 m->setItemChecked(m->idAt(0),FALSE); 646 m->setItemChecked(m->idAt(0),FALSE);
650 647
651 if(Ir::supported()) 648 if(Ir::supported())
652 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 649 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
653 m->setFocus(); 650 m->setFocus();
654 m->exec( QPoint( 4,QCursor::pos().y()) ); 651 m->exec( QPoint( 4,QCursor::pos().y()) );
655 652
656 if(m) delete m; 653 if(m) delete m;
657} 654}
658 655
659 656
660void AdvancedFm::cancelMenuTimer() 657void AdvancedFm::cancelMenuTimer()
661{ 658{
662// qDebug("selectionChanged: cancel menu timer"); 659// qDebug("selectionChanged: cancel menu timer");
663 if( menuTimer.isActive() ) 660 if( menuTimer.isActive() )
664 menuTimer.stop(); 661 menuTimer.stop();
665} 662}
666 663
667QString AdvancedFm::checkDiskSpace(const QString &path) 664QString AdvancedFm::checkDiskSpace(const QString &path)
668{ 665{
669 struct statfs fss; 666 struct statfs fss;
670 if ( !statfs( path.latin1(), &fss ) ) 667 if ( !statfs( path.latin1(), &fss ) )
671 { 668 {
672 int blkSize = fss.f_bsize; 669 int blkSize = fss.f_bsize;
673// int totalBlks = fs.f_blocks; 670// int totalBlks = fs.f_blocks;
674 int availBlks = fss.f_bavail; 671 int availBlks = fss.f_bavail;
675 672
676 long mult = blkSize / 1024; 673 long mult = blkSize / 1024;
677 long div = 1024 / blkSize; 674 long div = 1024 / blkSize;
678 if ( !mult ) mult = 1; 675 if ( !mult ) mult = 1;
679 if ( !div ) div = 1; 676 if ( !div ) div = 1;
680 677
681 678
682 return QString::number(availBlks * mult / div); 679 return QString::number(availBlks * mult / div);
683 } 680 }
684 return ""; 681 return "";
685} 682}
686 683
687void AdvancedFm::addToDocs() 684void AdvancedFm::addToDocs()
688{ 685{
689 QStringList strListPaths = getPath(); 686 QStringList strListPaths = getPath();
690 QDir *thisDir = CurrentDir(); 687 QDir *thisDir = CurrentDir();
691 688
692 if( strListPaths.count() > 0) 689 if( strListPaths.count() > 0)
693 { 690 {
694 QString curFile; 691 QString curFile;
695 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) 692 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it )
696 { 693 {
697 curFile = thisDir->canonicalPath()+"/"+(*it); 694 curFile = thisDir->canonicalPath()+"/"+(*it);
698// qDebug(curFile); 695// qDebug(curFile);
699 DocLnk f; 696 DocLnk f;
700// curFile.replace(QRegExp("\\..*"),""); 697// curFile.replace(QRegExp("\\..*"),"");
701 f.setName((*it)); 698 f.setName((*it));
702 f.setFile( curFile); 699 f.setFile( curFile);
703 f.writeLink(); 700 f.writeLink();
704 } 701 }
705 } 702 }
706} 703}
707 704
708 705
709void AdvancedFm::customDirsToMenu() 706void AdvancedFm::customDirsToMenu()
710{ 707{
711 708
712 Config cfg("AdvancedFm"); 709 Config cfg("AdvancedFm");
713 cfg.setGroup("Menu"); 710 cfg.setGroup("Menu");
714 711
715 QStringList list = cfg.readListEntry( "CustomDir", ','); 712 QStringList list = cfg.readListEntry( "CustomDir", ',');
716 menuButton->insertItems(list ); 713 menuButton->insertItems(list );
717 714
718// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 715// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
719// { 716// {
720// customDirMenu->insertItem(*it ); 717// customDirMenu->insertItem(*it );
721// } 718// }
722} 719}
723 720
724void AdvancedFm::dirMenuSelected(int item) 721void AdvancedFm::dirMenuSelected(int item)
725{ 722{
726 qDebug("menu item %d", item); 723 qDebug("menu item %d", item);
727 switch(item) 724 switch(item)
728 { 725 {
729 726
730 case -21: 727 case -21:
731 case 0: 728 case 0:
732 addCustomDir(); 729 addCustomDir();
733 break; 730 break;
734 case -22: 731 case -22:
735 case 1: 732 case 1:
736 removeCustomDir(); 733 removeCustomDir();
737 break; 734 break;
738 default: 735 default:
739 { 736 {
740// gotoCustomDir( menuButton->text(item)); 737// gotoCustomDir( menuButton->text(item));
741// gotoCustomDir( customDirMenu->text(item)); 738// gotoCustomDir( customDirMenu->text(item));
742 } 739 }
743 break; 740 break;
744 741
745 }; 742 };
746} 743}
747 744
748void AdvancedFm::addCustomDir() 745void AdvancedFm::addCustomDir()
749{ 746{
750 Config cfg("AdvancedFm"); 747 Config cfg("AdvancedFm");
751 cfg.setGroup("Menu"); 748 cfg.setGroup("Menu");
752 QString dir; 749 QString dir;
753 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 750 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
754 751
755 dir = CurrentDir()->canonicalPath(); 752 dir = CurrentDir()->canonicalPath();
756 753
757 bool addIt=true; 754 bool addIt=true;
758 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 755 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
759 { 756 {
760 if( dir == (*it)) 757 if( dir == (*it))
761 { 758 {
762 addIt=false; 759 addIt=false;
763 } 760 }
764 } 761 }
765 if(addIt) 762 if(addIt)
766 { 763 {
767 menuButton->insertItem(dir); 764 menuButton->insertItem(dir);
768// customDirMenu->insertItem(dir); 765// customDirMenu->insertItem(dir);
769 list << dir; 766 list << dir;
770 } 767 }
771 768
772 cfg.writeEntry("CustomDir", list, ','); 769 cfg.writeEntry("CustomDir", list, ',');
773 cfg.write(); 770 cfg.write();
774} 771}
775 772
776void AdvancedFm::removeCustomDir() 773void AdvancedFm::removeCustomDir()
777{ 774{
778// qDebug("remove custom dir"); 775// qDebug("remove custom dir");
779 Config cfg("AdvancedFm"); 776 Config cfg("AdvancedFm");
780 cfg.setGroup("Menu"); 777 cfg.setGroup("Menu");
781 QString dir; 778 QString dir;
782 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 779 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
783 QStringList list2; 780 QStringList list2;
784 dir = CurrentDir()->canonicalPath(); 781 dir = CurrentDir()->canonicalPath();
785 int ramble=2; 782 int ramble=2;
786// int ramble=-24; 783// int ramble=-24;
787//first remove list 784//first remove list
788 if(list.grep(dir,true).isEmpty()) 785 if(list.grep(dir,true).isEmpty())
789 { 786 {
790 QMessageBox::message("AdvancedFm",tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); 787 QMessageBox::message("AdvancedFm",
788 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!"));
791 } 789 }
792 else 790 else
793 { 791 {
794 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 792 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
795 { 793 {
796 if((*it) != dir)//current item is not our current dir, so add it to temp list 794 if((*it) != dir)//current item is not our current dir, so add it to temp list
797 { 795 {
798 list2 <<(*it); 796 list2 <<(*it);
799 } 797 }
800 else 798 else
801 { 799 {
802// customDirMenu->removeItem( ramble); 800// customDirMenu->removeItem( ramble);
803 menuButton->remove( ramble); 801 menuButton->remove( ramble);
804 802
805 } 803 }
806 ramble++; 804 ramble++;
807// ramble--; 805// ramble--;
808 } 806 }
809 807
810 cfg.writeEntry("CustomDir", list2, ','); 808 cfg.writeEntry("CustomDir", list2, ',');
811 cfg.write(); 809 cfg.write();
812 } 810 }
813// customDirsToMenu(); 811// customDirsToMenu();
814 812
815} 813}
816 814
817void AdvancedFm::gotoCustomDir(const QString &dir) 815void AdvancedFm::gotoCustomDir(const QString &dir)
818{ 816{
819// qDebug("gotoCustomDir(const QString &dir) " +dir ); 817// qDebug("gotoCustomDir(const QString &dir) " +dir );
820 QString curDir = dir; 818 QString curDir = dir;
821 QDir *thisDir = CurrentDir(); 819 QDir *thisDir = CurrentDir();
822// if( curDir.isEmpty()) { 820// if( curDir.isEmpty()) {
823// } 821// }
824 if( curDir == s_addBookmark) 822 if( curDir == s_addBookmark)
825 { 823 {
826 addCustomDir(); 824 addCustomDir();
827 } 825 }
828 if( curDir == s_removeBookmark) 826 if( curDir == s_removeBookmark)
829 { 827 {
830 removeCustomDir( ); 828 removeCustomDir( );
831 } 829 }
832 else 830 else
833 { 831 {
834 if(QDir( curDir).exists() ) 832 if(QDir( curDir).exists() )
835 { 833 {
836 thisDir->setPath( curDir ); 834 thisDir->setPath( curDir );
837 chdir( curDir.latin1() ); 835 chdir( curDir.latin1() );
838 thisDir->cd( curDir, TRUE); 836 thisDir->cd( curDir, TRUE);
839 populateView(); 837 populateView();
840 } 838 }
841 } 839 }
842} 840}
843 841
844QDir *AdvancedFm::CurrentDir() 842QDir *AdvancedFm::CurrentDir()
845{ 843{
846 if ( whichTab == 1) 844 if ( whichTab == 1)
847 { 845 {
848 return &currentDir; 846 return &currentDir;
849 } 847 }
850 else 848 else
851 { 849 {
852 return &currentRemoteDir; 850 return &currentRemoteDir;
853 } 851 }
854} 852}
855 853
856QDir *AdvancedFm::OtherDir() 854QDir *AdvancedFm::OtherDir()
857{ 855{
858 if ( whichTab == 1) 856 if ( whichTab == 1)
859 { 857 {
860 return &currentRemoteDir; 858 return &currentRemoteDir;
861 } 859 }
862 else 860 else
863 { 861 {
864 return &currentDir; 862 return &currentDir;
865 } 863 }
866} 864}
867 865
868QListView * AdvancedFm::CurrentView() 866QListView * AdvancedFm::CurrentView()
869{ 867{
870 if ( whichTab == 1) 868 if ( whichTab == 1)
871 return Local_View; 869 return Local_View;
872 else 870 else
873 return Remote_View; 871 return Remote_View;
874} 872}
875 873
876QListView * AdvancedFm::OtherView() 874QListView * AdvancedFm::OtherView()
877{ 875{
878 if ( whichTab == 1) 876 if ( whichTab == 1)
879 return Remote_View; 877 return Remote_View;
880 else 878 else
881 return Local_View; 879 return Local_View;
882} 880}
883 881
884void AdvancedFm::setOtherTabCurrent() 882void AdvancedFm::setOtherTabCurrent()
885{ 883{
886 if ( whichTab == 1) 884 if ( whichTab == 1)
887 TabWidget->setCurrentTab(1); 885 TabWidget->setCurrentTab(1);
888 else 886 else
889 TabWidget->setCurrentTab(0); 887 TabWidget->setCurrentTab(0);
890} 888}
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index c553017..062a013 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,472 +1,474 @@
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
49void AdvancedFm::doDirChange() 49void AdvancedFm::doDirChange()
50{ 50{
51 ListClicked( CurrentView()->currentItem()); 51 ListClicked( CurrentView()->currentItem());
52} 52}
53 53
54void AdvancedFm::showMenuHidden() 54void 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 OtherDir()->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 OtherDir()->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 populateView(); 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
77void AdvancedFm::showHidden() 77void 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 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
82// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 83// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
83// b=FALSE; 84// b=FALSE;
84 85
85 } 86 }
86 else 87 else
87 { 88 {
88 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 89 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
90 s OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
89// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 91// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
90// b=TRUE; 92// b=TRUE;
91 } 93 }
92 populateView(); 94 populateView();
93} 95}
94 96
95QString AdvancedFm::dealWithSymName(const QString &fileName) 97QString AdvancedFm::dealWithSymName(const QString &fileName)
96{ 98{
97 QString strItem = fileName; 99 QString strItem = fileName;
98 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 100 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
99} 101}
100 102
101void AdvancedFm::runThis() 103void AdvancedFm::runThis()
102{ 104{
103 QString fs; 105 QString fs;
104 QDir *thisDir = CurrentDir(); 106 QDir *thisDir = CurrentDir();
105 107
106 QString curFile = CurrentView()->currentItem()->text(0); 108 QString curFile = CurrentView()->currentItem()->text(0);
107 QString path = thisDir->canonicalPath(); 109 QString path = thisDir->canonicalPath();
108 110
109 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 111 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
110 112
111 curFile = dealWithSymName((const QString&)curFile); 113 curFile = dealWithSymName((const QString&)curFile);
112 114
113 if(curFile != "../") 115 if(curFile != "../")
114 { 116 {
115 117
116 fs = getFileSystemType((const QString &) path); 118 fs = getFileSystemType((const QString &) path);
117 QFileInfo fileInfo( path + "/" + curFile); 119 QFileInfo fileInfo( path + "/" + curFile);
118 qDebug( fileInfo.owner()); 120 qDebug( fileInfo.owner());
119 121
120 if( (fileInfo.permission( QFileInfo::ExeUser) 122 if( (fileInfo.permission( QFileInfo::ExeUser)
121 | fileInfo.permission( QFileInfo::ExeGroup) 123 | fileInfo.permission( QFileInfo::ExeGroup)
122 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 124 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
123 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 125 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
124 QCopEnvelope e("QPE/System", "execute(QString)" ); 126 QCopEnvelope e("QPE/System", "execute(QString)" );
125 e << curFile; 127 e << curFile;
126 } 128 }
127 else 129 else
128 { 130 {
129 curFile = path + "/" + curFile; 131 curFile = path + "/" + curFile;
130 DocLnk nf(curFile); 132 DocLnk nf(curFile);
131 QString execStr = nf.exec(); 133 QString execStr = nf.exec();
132 qDebug( execStr); 134 qDebug( execStr);
133 if( execStr.isEmpty() ) 135 if( execStr.isEmpty() )
134 { 136 {
135 } 137 }
136 else 138 else
137 { 139 {
138 nf.execute(); 140 nf.execute();
139 } 141 }
140 } 142 }
141 } 143 }
142} 144}
143 145
144void AdvancedFm::runText() 146void AdvancedFm::runText()
145{ 147{
146 QString curFile = CurrentView()->currentItem()->text(0); 148 QString curFile = CurrentView()->currentItem()->text(0);
147 if(curFile != "../") 149 if(curFile != "../")
148 { 150 {
149 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 151 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
150 curFile = dealWithSymName((const QString&)curFile); 152 curFile = dealWithSymName((const QString&)curFile);
151 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 153 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
152 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 154 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
153 e << curFile; 155 e << curFile;
154 } 156 }
155} 157}
156 158
157void AdvancedFm::makeDir() 159void AdvancedFm::makeDir()
158{ 160{
159 InputDialog *fileDlg; 161 InputDialog *fileDlg;
160 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 162 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
161 fileDlg->exec(); 163 fileDlg->exec();
162 if( fileDlg->result() == 1 ) 164 if( fileDlg->result() == 1 )
163 { 165 {
164 QDir *thisDir = CurrentDir(); 166 QDir *thisDir = CurrentDir();
165 QString filename = fileDlg->LineEdit1->text(); 167 QString filename = fileDlg->LineEdit1->text();
166 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 168 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
167 } 169 }
168 populateView(); 170 populateView();
169} 171}
170 172
171void AdvancedFm::doDelete() 173void AdvancedFm::doDelete()
172{ 174{
173 175
174 QStringList curFileList = getPath(); 176 QStringList curFileList = getPath();
175 bool doMsg=true; 177 bool doMsg=true;
176 int count = curFileList.count(); 178 int count = curFileList.count();
177 if( count > 0) 179 if( count > 0)
178 { 180 {
179 if(count > 1 ) 181 if(count > 1 )
180 { 182 {
181 QString msg; 183 QString msg;
182 msg=tr("Really delete\n%1 files?").arg(count); 184 msg=tr("Really delete\n%1 files?").arg(count);
183 switch ( QMessageBox::warning(this,tr("Delete"),msg 185 switch ( QMessageBox::warning(this,tr("Delete"),msg
184 ,tr("Yes"),tr("No"),0,0,1) ) 186 ,tr("Yes"),tr("No"),0,0,1) )
185 { 187 {
186 case 0: 188 case 0:
187 doMsg=false; 189 doMsg=false;
188 break; 190 break;
189 case 1: 191 case 1:
190 return; 192 return;
191 break; 193 break;
192 }; 194 };
193 } 195 }
194 196
195 QString myFile; 197 QString myFile;
196 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 198 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
197 { 199 {
198 myFile = (*it); 200 myFile = (*it);
199 if( myFile.find(" -> ",0,TRUE) != -1) 201 if( myFile.find(" -> ",0,TRUE) != -1)
200 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 202 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
201 203
202 QString f = CurrentDir()->canonicalPath(); 204 QString f = CurrentDir()->canonicalPath();
203 if(f.right(1).find("/",0,TRUE) == -1) 205 if(f.right(1).find("/",0,TRUE) == -1)
204 f += "/"; 206 f += "/";
205 f += myFile; 207 f += myFile;
206 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) 208 if(QDir(f).exists() && !QFileInfo(f).isSymLink() )
207 { 209 {
208 switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + 210 switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f +
209 "\nand all it's contents ?" 211 "\nand all it's contents ?"
210 ,tr("Yes"),tr("No"),0,0,1) ) 212 ,tr("Yes"),tr("No"),0,0,1) )
211 { 213 {
212 case 0: 214 case 0:
213 { 215 {
214 f=f.left(f.length()-1); 216 f=f.left(f.length()-1);
215 QString cmd="rm -rf "+f; 217 QString cmd="rm -rf "+f;
216 startProcess( (const QString)cmd.latin1() ); 218 startProcess( (const QString)cmd.latin1() );
217 populateView(); 219 populateView();
218 } 220 }
219 break; 221 break;
220 case 1: 222 case 1:
221 // exit 223 // exit
222 break; 224 break;
223 }; 225 };
224 226
225 } else { 227 } else {
226 if(doMsg) { 228 if(doMsg) {
227 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 229 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
228 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 230 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
229 case 1: 231 case 1:
230 return; 232 return;
231 break; 233 break;
232 }; 234 };
233 } 235 }
234 QString cmd="rm "+f; 236 QString cmd="rm "+f;
235 QFile file(f); 237 QFile file(f);
236 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 238 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
237 file.remove(); 239 file.remove();
238 } 240 }
239 } 241 }
240 } 242 }
241 populateView(); 243 populateView();
242} 244}
243 245
244void AdvancedFm::filePerms() 246void AdvancedFm::filePerms()
245{ 247{
246 QStringList curFileList = getPath(); 248 QStringList curFileList = getPath();
247 QString filePath; 249 QString filePath;
248 250
249 filePath = CurrentDir()->canonicalPath()+"/"; 251 filePath = CurrentDir()->canonicalPath()+"/";
250 252
251 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 253 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
252 { 254 {
253 filePermissions *filePerm; 255 filePermissions *filePerm;
254 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 256 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
255 filePerm->showMaximized(); 257 filePerm->showMaximized();
256 filePerm->exec(); 258 filePerm->exec();
257 if( filePerm) 259 if( filePerm)
258 delete filePerm; 260 delete filePerm;
259 } 261 }
260 populateView(); 262 populateView();
261} 263}
262 264
263void AdvancedFm::doProperties() 265void AdvancedFm::doProperties()
264{ 266{
265#if defined(QT_QWS_OPIE) 267#if defined(QT_QWS_OPIE)
266 268
267 QStringList curFileList = getPath(); 269 QStringList curFileList = getPath();
268 270
269 QString filePath; 271 QString filePath;
270 filePath = CurrentDir()->canonicalPath()+"/"; 272 filePath = CurrentDir()->canonicalPath()+"/";
271 273
272 qDebug("%d",curFileList.count()); 274 qDebug("%d",curFileList.count());
273 275
274 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 276 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
275 { 277 {
276 qDebug((filePath+*it)); 278 qDebug((filePath+*it));
277 DocLnk lnk( (filePath+*it)); 279 DocLnk lnk( (filePath+*it));
278 LnkProperties prop( &lnk ); 280 LnkProperties prop( &lnk );
279 prop.showMaximized(); 281 prop.showMaximized();
280 prop.exec(); 282 prop.exec();
281 } 283 }
282#endif 284#endif
283 285
284} 286}
285 287
286void AdvancedFm::upDir() 288void AdvancedFm::upDir()
287{ 289{
288 QDir *thisDir = CurrentDir(); 290 QDir *thisDir = CurrentDir();
289 QString current = thisDir->canonicalPath(); 291 QString current = thisDir->canonicalPath();
290 QDir dir(current); 292 QDir dir(current);
291 dir.cdUp(); 293 dir.cdUp();
292 current = dir.canonicalPath(); 294 current = dir.canonicalPath();
293 chdir( current.latin1() ); 295 chdir( current.latin1() );
294 thisDir->cd( current, TRUE); 296 thisDir->cd( current, TRUE);
295 297
296 populateView(); 298 populateView();
297 update(); 299 update();
298} 300}
299 301
300void AdvancedFm::copy() 302void AdvancedFm::copy()
301{ 303{
302 qApp->processEvents(); 304 qApp->processEvents();
303 QStringList curFileList = getPath(); 305 QStringList curFileList = getPath();
304 306
305 QDir *thisDir = CurrentDir(); 307 QDir *thisDir = CurrentDir();
306 QDir *thatDir = OtherDir(); 308 QDir *thatDir = OtherDir();
307 309
308 bool doMsg=true; 310 bool doMsg=true;
309 int count=curFileList.count(); 311 int count=curFileList.count();
310 if( count > 0) { 312 if( count > 0) {
311 if(count > 1 ){ 313 if(count > 1 ){
312 QString msg; 314 QString msg;
313 msg=tr("Really copy\n%1 files?").arg(count); 315 msg=tr("Really copy\n%1 files?").arg(count);
314 switch ( QMessageBox::warning(this,tr("Delete"),msg 316 switch ( QMessageBox::warning(this,tr("Delete"),msg
315 ,tr("Yes"),tr("No"),0,0,1) ) 317 ,tr("Yes"),tr("No"),0,0,1) )
316 { 318 {
317 case 0: 319 case 0:
318 doMsg=false; 320 doMsg=false;
319 break; 321 break;
320 case 1: 322 case 1:
321 return; 323 return;
322 break; 324 break;
323 }; 325 };
324 } 326 }
325 327
326 QString curFile, item, destFile; 328 QString curFile, item, destFile;
327 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 329 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
328 { 330 {
329 item=(*it); 331 item=(*it);
330 if(item.find("->",0,TRUE)) //symlink 332 if(item.find("->",0,TRUE)) //symlink
331 item = item.left(item.find("->",0,TRUE)); 333 item = item.left(item.find("->",0,TRUE));
332 334
333 curFile = thisDir->canonicalPath()+"/"+ item; 335 curFile = thisDir->canonicalPath()+"/"+ item;
334 destFile = thatDir->canonicalPath()+"/"+ item; 336 destFile = thatDir->canonicalPath()+"/"+ item;
335 337
336 qDebug("Destination file is "+destFile); 338 qDebug("Destination file is "+destFile);
337 qDebug("CurrentFile file is " + curFile); 339 qDebug("CurrentFile file is " + curFile);
338 340
339 QFile f(destFile); 341 QFile f(destFile);
340 if( f.exists()) 342 if( f.exists())
341 { 343 {
342 if(doMsg) 344 if(doMsg)
343 { 345 {
344 switch ( QMessageBox::warning(this,tr("File Exists!"), 346 switch ( QMessageBox::warning(this,tr("File Exists!"),
345 tr("%1 exists. Ok to overwrite?").arg( item ), 347 tr("%1 exists. Ok to overwrite?").arg( item ),
346 tr("Yes"),tr("No"),0,0,1) ) 348 tr("Yes"),tr("No"),0,0,1) )
347 { 349 {
348 case 1: 350 case 1:
349 return; 351 return;
350 break; 352 break;
351 }; 353 };
352 } 354 }
353 f.remove(); 355 f.remove();
354 } 356 }
355 357
356 if( !copyFile( curFile, destFile) ) 358 if( !copyFile( curFile, destFile) )
357 { 359 {
358 QMessageBox::message("AdvancedFm", 360 QMessageBox::message("AdvancedFm",
359 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 361 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
360 return; 362 return;
361 } 363 }
362 } 364 }
363 setOtherTabCurrent(); 365 setOtherTabCurrent();
364 populateView(); 366 populateView();
365 } 367 }
366} 368}
367 369
368void AdvancedFm::copyAs() 370void AdvancedFm::copyAs()
369{ 371{
370 qApp->processEvents(); 372 qApp->processEvents();
371 373
372 QStringList curFileList = getPath(); 374 QStringList curFileList = getPath();
373 QString curFile, item; 375 QString curFile, item;
374 InputDialog *fileDlg; 376 InputDialog *fileDlg;
375 377
376 QDir *thisDir = CurrentDir(); 378 QDir *thisDir = CurrentDir();
377 QDir *thatDir = OtherDir(); 379 QDir *thatDir = OtherDir();
378 380
379 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 381 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
380 { 382 {
381 QString destFile; 383 QString destFile;
382 item=(*it); 384 item=(*it);
383 curFile = thisDir->canonicalPath()+"/"+(*it); 385 curFile = thisDir->canonicalPath()+"/"+(*it);
384 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); 386 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
385 387
386 fileDlg->setInputText((const QString &) destFile ); 388 fileDlg->setInputText((const QString &) destFile );
387 fileDlg->exec(); 389 fileDlg->exec();
388 390
389 if( fileDlg->result() == 1 ) 391 if( fileDlg->result() == 1 )
390 { 392 {
391 QString filename = fileDlg->LineEdit1->text(); 393 QString filename = fileDlg->LineEdit1->text();
392 destFile = thatDir->canonicalPath()+"/"+filename; 394 destFile = thatDir->canonicalPath()+"/"+filename;
393 395
394 QFile f( destFile); 396 QFile f( destFile);
395 if( f.exists()) 397 if( f.exists())
396 { 398 {
397 switch (QMessageBox::warning(this,tr("File Exists!"), 399 switch (QMessageBox::warning(this,tr("File Exists!"),
398 item+tr("\nexists. Ok to overwrite?"), 400 item+tr("\nexists. Ok to overwrite?"),
399 tr("Yes"),tr("No"),0,0,1) ) 401 tr("Yes"),tr("No"),0,0,1) )
400 { 402 {
401 case 0: 403 case 0:
402 f.remove(); 404 f.remove();
403 break; 405 break;
404 case 1: 406 case 1:
405 return; 407 return;
406 break; 408 break;
407 }; 409 };
408 } 410 }
409 if( !copyFile( curFile, destFile) ) 411 if( !copyFile( curFile, destFile) )
410 { 412 {
411 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 413 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
412 +curFile +tr("to\n")+destFile); 414 +curFile +tr("to\n")+destFile);
413 return; 415 return;
414 } 416 }
415 } 417 }
416 delete fileDlg; 418 delete fileDlg;
417 419
418 } 420 }
419 setOtherTabCurrent(); 421 setOtherTabCurrent();
420 populateView(); 422 populateView();
421} 423}
422 424
423void AdvancedFm::copySameDir() 425void AdvancedFm::copySameDir()
424{ 426{
425 qApp->processEvents(); 427 qApp->processEvents();
426 QStringList curFileList = getPath(); 428 QStringList curFileList = getPath();
427 QString curFile, item, destFile; 429 QString curFile, item, destFile;
428 InputDialog *fileDlg; 430 InputDialog *fileDlg;
429 431
430 QDir *thisDir = CurrentDir(); 432 QDir *thisDir = CurrentDir();
431 433
432 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 434 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
433 { 435 {
434 item=(*it); 436 item=(*it);
435 curFile = thisDir->canonicalPath()+"/"+ item; 437 curFile = thisDir->canonicalPath()+"/"+ item;
436 438
437 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 439 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
438 fileDlg->setInputText((const QString &) destFile ); 440 fileDlg->setInputText((const QString &) destFile );
439 fileDlg->exec(); 441 fileDlg->exec();
440 442
441 if( fileDlg->result() == 1 ) 443 if( fileDlg->result() == 1 )
442 { 444 {
443 445
444 QString filename = fileDlg->LineEdit1->text(); 446 QString filename = fileDlg->LineEdit1->text();
445 destFile = thisDir->canonicalPath()+"/"+filename; 447 destFile = thisDir->canonicalPath()+"/"+filename;
446 448
447 QFile f(destFile); 449 QFile f(destFile);
448 if( f.exists()) 450 if( f.exists())
449 { 451 {
450 switch (QMessageBox::warning(this,tr("Delete"), 452 switch (QMessageBox::warning(this,tr("Delete"),
451 destFile+tr(" already exists.\nDo you really want to delete it?"), 453 destFile+tr(" already exists.\nDo you really want to delete it?"),
452 tr("Yes"),tr("No"),0,0,1) ) { 454 tr("Yes"),tr("No"),0,0,1) ) {
453 case 0: 455 case 0:
454 456
455 f.remove(); 457 f.remove();
456 break; 458 break;
457 case 1: 459 case 1:
458 return; 460 return;
459 break; 461 break;
460 }; 462 };
461 } 463 }
462 if(!copyFile( curFile,destFile) ) 464 if(!copyFile( curFile,destFile) )
463 { 465 {
464 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 466 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
465 +curFile +tr("to\n")+destFile); 467 +curFile +tr("to\n")+destFile);
466 return; 468 return;
467 } 469 }
468 470
469 qDebug("copy "+curFile+" as "+destFile); 471 qDebug("copy "+curFile+" as "+destFile);
470 } 472 }
471 delete fileDlg; 473 delete fileDlg;
472 } 474 }