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