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