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