summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp137
1 files changed, 80 insertions, 57 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 4802771..f25048a 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,845 +1,868 @@
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 changeTo( 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("<p>Really delete %1 files?</p>").arg(count); 150 msg=tr("<p>Really delete %1 files?</p>").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 default:
161 return;
162 break;
160 }; 163 };
161 } 164 }
162 165
163 QString myFile; 166 QString myFile;
164 167
165 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 168 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
166 myFile = (*it); 169 myFile = (*it);
167 if( myFile.find(" -> ",0,TRUE) != -1) 170 if( myFile.find(" -> ",0,TRUE) != -1)
168 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 171 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
169 172
170 QString f = CurrentDir()->canonicalPath(); 173 QString f = CurrentDir()->canonicalPath();
171 if(f.right(1).find("/",0,TRUE) == -1) 174 if(f.right(1).find("/",0,TRUE) == -1)
172 f += "/"; 175 f += "/";
173 f += myFile; 176 f += myFile;
174 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 177 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
175 //if file is a directory 178 //if file is a directory
176 179
177 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 180 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
178 tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , 181 tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) ,
179 tr("Yes"), tr("No"), 0, 0, 1) ) { 182 tr("Yes"), tr("No"), 0, 0, 1) ) {
180 case 0: 183 case 0:
181 { 184 {
182 f=f.left(f.length()-1); 185 f=f.left(f.length()-1);
183 QString cmd="rm -rf "+f; 186 QString cmd="rm -rf "+f;
184 startProcess( (const QString)cmd.latin1() ); 187 startProcess( (const QString)cmd.latin1() );
185 populateView(); 188 populateView();
186 } 189 }
187 break; 190 break;
188 case 1: 191 case 1:
189 // exit 192 // exit
190 break; 193 break;
194 default:
195 break;
191 }; 196 };
192 197
193 } else { 198 } else {
194 if(doMsg) { 199 if(doMsg) {
195 switch ( QMessageBox::warning(this,tr("Delete"), 200 switch ( QMessageBox::warning(this,tr("Delete"),
196 tr("<p>Really delete %1?</p>").arg( myFile ), 201 tr("<p>Really delete %1?</p>").arg( myFile ),
197 tr("Yes"), tr("No"), 0, 0, 1) ) { 202 tr("Yes"), tr("No"), 0, 0, 1) ) {
198 case 1: 203 case 1:
199 return; 204 return;
200 break; 205 break;
201 }; 206 default:
207 return;
208 break;
209 };
202 } 210 }
203 211
204 QString cmd="rm "+f; 212 QString cmd="rm "+f;
205 QFile file(f); 213 QFile file(f);
206 QFileInfo fi(myFile); 214 QFileInfo fi(myFile);
207 if( fi.fileName().find("../",0,TRUE)==-1) { 215 if( fi.fileName().find("../",0,TRUE)==-1) {
208// odebug << "remove link files "+myFile << oendl; 216// odebug << "remove link files "+myFile << oendl;
209 217
210// DocLnk lnk(f); 218// DocLnk lnk(f);
211 DocLnk *lnk; 219 DocLnk *lnk;
212 lnk = new DocLnk(f); 220 lnk = new DocLnk(f);
213// odebug << "Deleting doclnk " + lnk->linkFile() << oendl; 221// odebug << "Deleting doclnk " + lnk->linkFile() << oendl;
214 if(lnk->isValid()) 222 if(lnk->isValid())
215 lnk->removeLinkFile(); 223 lnk->removeLinkFile();
216 // delete lnk; 224 // delete lnk;
217 file.remove(); 225 file.remove();
218 } 226 }
219 } 227 }
220 } 228 }
221 } 229 }
222 populateView(); 230 populateView();
223} 231}
224 232
225void AdvancedFm::filePerms() { 233void AdvancedFm::filePerms() {
226 QStringList curFileList = getPath(); 234 QStringList curFileList = getPath();
227 QString filePath; 235 QString filePath;
228 236
229 filePath = CurrentDir()->canonicalPath()+"/"; 237 filePath = CurrentDir()->canonicalPath()+"/";
230 238
231 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 239 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
232 filePermissions *filePerm; 240 filePermissions *filePerm;
233 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 241 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
234 QPEApplication::execDialog( filePerm ); 242 QPEApplication::execDialog( filePerm );
235 if( filePerm ) 243 if( filePerm )
236 delete filePerm; 244 delete filePerm;
237 } 245 }
238 populateView(); 246 populateView();
239} 247}
240 248
241void AdvancedFm::doProperties() { 249void AdvancedFm::doProperties() {
242#if defined(QT_QWS_OPIE) 250#if defined(QT_QWS_OPIE)
243 251
244 QStringList curFileList = getPath(); 252 QStringList curFileList = getPath();
245 253
246 QString filePath; 254 QString filePath;
247 filePath = CurrentDir()->canonicalPath()+"/"; 255 filePath = CurrentDir()->canonicalPath()+"/";
248 256
249// odebug << "" << curFileList.count() << "" << oendl; 257// odebug << "" << curFileList.count() << "" << oendl;
250 258
251 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 259 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
252// odebug << (filePath+*it) << oendl; 260// odebug << (filePath+*it) << oendl;
253 DocLnk lnk( (filePath+*it)); 261 DocLnk lnk( (filePath+*it));
254 LnkProperties prop( &lnk ); 262 LnkProperties prop( &lnk );
255 QPEApplication::execDialog( &prop ); 263 QPEApplication::execDialog( &prop );
256 } 264 }
257#endif 265#endif
258 266
259} 267}
260 268
261void AdvancedFm::upDir() { 269void AdvancedFm::upDir() {
262 270
263 QDir dir( CurrentDir()->canonicalPath()); 271 QDir dir( CurrentDir()->canonicalPath());
264 dir.cdUp(); 272 dir.cdUp();
265 changeTo(dir.canonicalPath()); 273 changeTo(dir.canonicalPath());
266} 274}
267 275
268void AdvancedFm::copyTimer() { 276void AdvancedFm::copyTimer() {
269 QTimer::singleShot(125,this,SLOT(copy())); 277 QTimer::singleShot(125,this,SLOT(copy()));
270} 278}
271 279
272void AdvancedFm::copy() { 280void AdvancedFm::copy() {
273 QStringList curFileList = getPath(); 281 QStringList curFileList = getPath();
274 282
275 QDir *thisDir = CurrentDir(); 283 QDir *thisDir = CurrentDir();
276 QDir *thatDir = OtherDir(); 284 QDir *thatDir = OtherDir();
277 285
278 bool doMsg = true; 286 bool doMsg = true;
279 int count = curFileList.count(); 287 int count = curFileList.count();
280 if( count > 0) { 288 if( count > 0) {
281 if(count > 1 ){ 289 if(count > 1 ){
282 QString msg; 290 QString msg;
283 msg=tr("<p>Really copy %1 files?</p>").arg(count); 291 msg=tr("<p>Really copy %1 files?</p>").arg(count);
284 switch ( QMessageBox::warning(this,tr("Copy"),msg 292 switch ( QMessageBox::warning(this,tr("Copy"),msg
285 ,tr("Yes"),tr("No"),0,0,1) ) 293 ,tr("Yes"),tr("No"),0,0,1) )
286 { 294 {
287 case 0: 295 case 0:
288 doMsg=false; 296 doMsg=false;
289 break; 297 break;
290 case 1: 298 case 1:
291 return; 299 return;
292 break; 300 break;
301 default:
302 return;
303 break;
293 }; 304 };
294 } 305 }
295 306
296 QString curFile, item, destFile; 307 QString curFile, item, destFile;
297 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 308 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
298 item=(*it); 309 item=(*it);
299 if(item.find("->",0,TRUE)) //symlink 310 if(item.find("->",0,TRUE)) //symlink
300 item = item.left(item.find("->",0,TRUE)); 311 item = item.left(item.find("->",0,TRUE));
301 312
302 curFile = thisDir->canonicalPath()+"/"+ item; 313 curFile = thisDir->canonicalPath()+"/"+ item;
303 destFile = thatDir->canonicalPath()+"/"+ item; 314 destFile = thatDir->canonicalPath()+"/"+ item;
304 315
305// odebug << "Destination file is "+destFile << oendl; 316// odebug << "Destination file is "+destFile << oendl;
306// odebug << "CurrentFile file is " + curFile << oendl; 317// odebug << "CurrentFile file is " + curFile << oendl;
307 318
308 QFile f(destFile); 319 QFile f(destFile);
309 if( f.exists()) { 320 if( f.exists()) {
310 if(doMsg) { 321 if(doMsg) {
311 switch ( QMessageBox::warning(this,tr("File Exists!"), 322 switch ( QMessageBox::warning(this,tr("File Exists!"),
312 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), 323 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item),
313 tr("Yes"),tr("No"),0,0,1)) { 324 tr("Yes"),tr("No"),0,0,1)) {
314 case 1: 325 case 1:
315 return; 326 return;
316 break; 327 break;
317 }; 328 default:
329 return;
330 break;
331 };
318 } 332 }
319 f.remove(); 333 f.remove();
320 } 334 }
321 335
322 if( !copyFile( curFile, destFile) ) { 336 if( !copyFile( curFile, destFile) ) {
323 QMessageBox::message("AdvancedFm", 337 QMessageBox::message("AdvancedFm",
324 tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 338 tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
325 return; 339 return;
326 } 340 }
327 } 341 }
328 rePopulate(); 342 rePopulate();
329 } 343 }
330} 344}
331 345
332void AdvancedFm::copyAsTimer() { 346void AdvancedFm::copyAsTimer() {
333 QTimer::singleShot(125,this,SLOT(copyAs())); 347 QTimer::singleShot(125,this,SLOT(copyAs()));
334} 348}
335 349
336void AdvancedFm::copyAs() { 350void AdvancedFm::copyAs() {
337 351
338 QStringList curFileList = getPath(); 352 QStringList curFileList = getPath();
339 QString curFile, item; 353 QString curFile, item;
340 InputDialog *fileDlg; 354 InputDialog *fileDlg;
341 355
342 QDir *thisDir = CurrentDir(); 356 QDir *thisDir = CurrentDir();
343 QDir *thatDir = OtherDir(); 357 QDir *thatDir = OtherDir();
344 358
345 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 359 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
346 QString destFile; 360 QString destFile;
347 item=(*it); 361 item=(*it);
348 curFile = thisDir->canonicalPath()+"/"+(*it); 362 curFile = thisDir->canonicalPath()+"/"+(*it);
349 fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); 363 fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0);
350 364
351 fileDlg->setInputText((const QString &) destFile ); 365 fileDlg->setInputText((const QString &) destFile );
352 fileDlg->exec(); 366 fileDlg->exec();
353 367
354 if( fileDlg->result() == 1 ) { 368 if( fileDlg->result() == 1 ) {
355 QString filename = fileDlg->LineEdit1->text(); 369 QString filename = fileDlg->LineEdit1->text();
356 destFile = thatDir->canonicalPath()+"/"+filename; 370 destFile = thatDir->canonicalPath()+"/"+filename;
357 371
358 QFile f( destFile); 372 QFile f( destFile);
359 if( f.exists()) { 373 if( f.exists()) {
360 switch (QMessageBox::warning(this,tr("File Exists!"), 374 switch (QMessageBox::warning(this,tr("File Exists!"),
361 tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), 375 tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item),
362 tr("Yes"),tr("No"),0,0,1) ) { 376 tr("Yes"),tr("No"),0,0,1) ) {
363 case 0: 377 case 0:
364 f.remove(); 378 f.remove();
365 break; 379 break;
366 case 1: 380 case 1:
367 return; 381 return;
368 break; 382 break;
369 }; 383 default:
384 return;
385 break;
386 };
370 } 387 }
371 if( !copyFile( curFile, destFile) ) { 388 if( !copyFile( curFile, destFile) ) {
372 QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 389 QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
373 return; 390 return;
374 } 391 }
375 } 392 }
376 delete fileDlg; 393 delete fileDlg;
377 394
378 } 395 }
379 rePopulate(); 396 rePopulate();
380 // setOtherTabCurrent(); 397 // setOtherTabCurrent();
381 qApp->processEvents(); 398 qApp->processEvents();
382 399
383} 400}
384 401
385void AdvancedFm::copySameDirTimer() { 402void AdvancedFm::copySameDirTimer() {
386 QTimer::singleShot(125,this,SLOT(copySameDir())); 403 QTimer::singleShot(125,this,SLOT(copySameDir()));
387} 404}
388 405
389void AdvancedFm::copySameDir() { 406void AdvancedFm::copySameDir() {
390 qApp->processEvents(); 407 qApp->processEvents();
391 QStringList curFileList = getPath(); 408 QStringList curFileList = getPath();
392 QString curFile, item, destFile; 409 QString curFile, item, destFile;
393 InputDialog *fileDlg; 410 InputDialog *fileDlg;
394 411
395 QDir *thisDir = CurrentDir(); 412 QDir *thisDir = CurrentDir();
396 413
397 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 414 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
398 item=(*it); 415 item=(*it);
399 curFile = thisDir->canonicalPath()+"/"+ item; 416 curFile = thisDir->canonicalPath()+"/"+ item;
400 417
401 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 418 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
402 fileDlg->setInputText((const QString &) destFile ); 419 fileDlg->setInputText((const QString &) destFile );
403 fileDlg->exec(); 420 fileDlg->exec();
404 421
405 if( fileDlg->result() == 1 ) { 422 if( fileDlg->result() == 1 ) {
406 423
407 QString filename = fileDlg->LineEdit1->text(); 424 QString filename = fileDlg->LineEdit1->text();
408 destFile = thisDir->canonicalPath()+"/"+filename; 425 destFile = thisDir->canonicalPath()+"/"+filename;
409 426
410 QFile f(destFile); 427 QFile f(destFile);
411 if( f.exists()) { 428 if( f.exists()) {
412 switch (QMessageBox::warning(this,tr("Delete"), 429 switch (QMessageBox::warning(this,tr("Delete"),
413 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), 430 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile),
414 tr("Yes"),tr("No"),0,0,1) ) { 431 tr("Yes"),tr("No"),0,0,1) ) {
415 case 0: 432 case 0:
416 433
417 f.remove(); 434 f.remove();
418 break; 435 break;
419 case 1: 436 case 1:
420 return; 437 return;
421 break; 438 break;
422 }; 439 default:
440 return;
441 break;
442 };
423 } 443 }
424 if(!copyFile( curFile,destFile) ) { 444 if(!copyFile( curFile,destFile) ) {
425 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 445 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
426 return; 446 return;
427 } 447 }
428 448
429// odebug << "copy "+curFile+" as "+destFile << oendl; 449// odebug << "copy "+curFile+" as "+destFile << oendl;
430 } 450 }
431 delete fileDlg; 451 delete fileDlg;
432 } 452 }
433 rePopulate(); 453 rePopulate();
434} 454}
435 455
436void AdvancedFm::moveTimer() { 456void AdvancedFm::moveTimer() {
437 QTimer::singleShot(125,this,SLOT(move())); 457 QTimer::singleShot(125,this,SLOT(move()));
438} 458}
439 459
440void AdvancedFm::move() { 460void AdvancedFm::move() {
441 461
442 QStringList curFileList = getPath(); 462 QStringList curFileList = getPath();
443 if( curFileList.count() > 0) { 463 if( curFileList.count() > 0) {
444 QString curFile, destFile, item; 464 QString curFile, destFile, item;
445 465
446 QDir *thisDir = CurrentDir(); 466 QDir *thisDir = CurrentDir();
447 QDir *thatDir = OtherDir(); 467 QDir *thatDir = OtherDir();
448 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 468 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
449 item=(*it); 469 item=(*it);
450 QString destFile = thatDir->canonicalPath(); 470 QString destFile = thatDir->canonicalPath();
451 471
452 if(destFile.right(1).find("/",0,TRUE) == -1) 472 if(destFile.right(1).find("/",0,TRUE) == -1)
453 destFile+="/"; 473 destFile+="/";
454 destFile += item; 474 destFile += item;
455// odebug << "Destination file is "+destFile << oendl; 475// odebug << "Destination file is "+destFile << oendl;
456 476
457 curFile = thisDir->canonicalPath(); 477 curFile = thisDir->canonicalPath();
458 if(curFile.right(1).find("/",0,TRUE) == -1) 478 if(curFile.right(1).find("/",0,TRUE) == -1)
459 curFile +="/"; 479 curFile +="/";
460 curFile+= item; 480 curFile+= item;
461// odebug << "CurrentFile file is " + curFile << oendl; 481// odebug << "CurrentFile file is " + curFile << oendl;
462 482
463 if(QFileInfo(curFile).isDir()) { 483 if(QFileInfo(curFile).isDir()) {
464 moveDirectory( curFile, destFile ); 484 moveDirectory( curFile, destFile );
465 rePopulate(); 485 rePopulate();
466 return; 486 return;
467 } 487 }
468 QFile f( destFile); 488 QFile f( destFile);
469 if( f.exists()) { 489 if( f.exists()) {
470 switch ( QMessageBox::warning(this,tr("File Exists!"), 490 switch ( QMessageBox::warning(this,tr("File Exists!"),
471 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), 491 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile),
472 tr("Yes"),tr("No"),0,0,1)) { 492 tr("Yes"),tr("No"),0,0,1)) {
473 case 1: 493 case 1:
474 return; 494 return;
475 break; 495 break;
476 }; 496 default:
497 return;
498 break;
499 };
477 if( !copyFile( curFile, destFile) ) { 500 if( !copyFile( curFile, destFile) ) {
478 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); 501 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile));
479 return; 502 return;
480 } else 503 } else
481 QFile::remove(curFile); 504 QFile::remove(curFile);
482 } 505 }
483 } 506 }
484 } 507 }
485 rePopulate(); 508 rePopulate();
486 //setOtherTabCurrent(); 509 //setOtherTabCurrent();
487} 510}
488 511
489bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { 512bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
490 int err = 0; 513 int err = 0;
491 if( copyDirectory( src, dest ) ) { 514 if( copyDirectory( src, dest ) ) {
492 QString cmd = "rm -rf " + src; 515 QString cmd = "rm -rf " + src;
493 err = system((const char*)cmd); 516 err = system((const char*)cmd);
494 } else 517 } else
495 err = -1; 518 err = -1;
496 519
497 if(err!=0) { 520 if(err!=0) {
498 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); 521 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src));
499 return false; 522 return false;
500 } 523 }
501 return true; 524 return true;
502} 525}
503 526
504bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { 527bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
505 528
506 QString cmd = "/bin/cp -fpR " + src + " " + dest; 529 QString cmd = "/bin/cp -fpR " + src + " " + dest;
507 owarn << cmd << oendl; 530 owarn << cmd << oendl;
508 int err = system( (const char *) cmd ); 531 int err = system( (const char *) cmd );
509 if ( err != 0 ) { 532 if ( err != 0 ) {
510 QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); 533 QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) );
511 return false; 534 return false;
512 } 535 }
513 536
514 return true; 537 return true;
515} 538}
516 539
517 540
518bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 541bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
519 if(QFileInfo(src).isDir()) { 542 if(QFileInfo(src).isDir()) {
520 if( copyDirectory( src, dest )) { 543 if( copyDirectory( src, dest )) {
521 // setOtherTabCurrent(); 544 // setOtherTabCurrent();
522 rePopulate(); 545 rePopulate();
523 return true; 546 return true;
524 } 547 }
525 else 548 else
526 return false; 549 return false;
527 } 550 }
528 551
529 552
530 bool success = true; 553 bool success = true;
531 struct stat status; 554 struct stat status;
532 QFile srcFile(src); 555 QFile srcFile(src);
533 QFile destFile(dest); 556 QFile destFile(dest);
534 int err=0; 557 int err=0;
535 int read_fd=0; 558 int read_fd=0;
536 int write_fd=0; 559 int write_fd=0;
537 struct stat stat_buf; 560 struct stat stat_buf;
538 off_t offset = 0; 561 off_t offset = 0;
539 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 562 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
540// owarn << "open failed" << oendl; 563// owarn << "open failed" << oendl;
541 return success = false; 564 return success = false;
542 } 565 }
543 read_fd = srcFile.handle(); 566 read_fd = srcFile.handle();
544 if(read_fd != -1) { 567 if(read_fd != -1) {
545 fstat (read_fd, &stat_buf); 568 fstat (read_fd, &stat_buf);
546 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 569 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
547// owarn << "destfile open failed" << oendl; 570// owarn << "destfile open failed" << oendl;
548 return success = false; 571 return success = false;
549 } 572 }
550 write_fd = destFile.handle(); 573 write_fd = destFile.handle();
551 if(write_fd != -1) { 574 if(write_fd != -1) {
552 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 575 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
553 if( err == -1) { 576 if( err == -1) {
554 QString msg; 577 QString msg;
555 switch(err) { 578 switch(err) {
556 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 579 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. "; 580 case EINVAL: msg = "Descriptor is not valid or locked. ";
558 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 581 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
559 case EIO: msg = "Unspecified error while reading from in_fd."; 582 case EIO: msg = "Unspecified error while reading from in_fd.";
560 }; 583 };
561 success = false; 584 success = false;
562// owarn << msg << oendl; 585// owarn << msg << oendl;
563 } 586 }
564 } else { 587 } else {
565 success = false; 588 success = false;
566 } 589 }
567 } else { 590 } else {
568 success = false; 591 success = false;
569 } 592 }
570 srcFile.close(); 593 srcFile.close();
571 destFile.close(); 594 destFile.close();
572 // Set file permissions 595 // Set file permissions
573 if( stat( QFile::encodeName(src), &status ) == 0 ) { 596 if( stat( QFile::encodeName(src), &status ) == 0 ) {
574 chmod( QFile::encodeName(dest), status.st_mode ); 597 chmod( QFile::encodeName(dest), status.st_mode );
575 } 598 }
576 599
577 return success; 600 return success;
578} 601}
579 602
580void AdvancedFm::runCommand() { 603void AdvancedFm::runCommand() {
581 if( !CurrentView()->currentItem()) return; 604 if( !CurrentView()->currentItem()) return;
582 QDir *thisDir = CurrentDir(); 605 QDir *thisDir = CurrentDir();
583 606
584 QString curFile; 607 QString curFile;
585 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 608 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
586 609
587 InputDialog *fileDlg; 610 InputDialog *fileDlg;
588 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 611 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
589 fileDlg->setInputText(curFile); 612 fileDlg->setInputText(curFile);
590 fileDlg->exec(); 613 fileDlg->exec();
591 //QString command; 614 //QString command;
592 615
593 if( fileDlg->result() == 1 ) { 616 if( fileDlg->result() == 1 ) {
594// odebug << fileDlg->LineEdit1->text() << oendl; 617// odebug << fileDlg->LineEdit1->text() << oendl;
595 QStringList command; 618 QStringList command;
596 619
597 command << "/bin/sh"; 620 command << "/bin/sh";
598 command << "-c"; 621 command << "-c";
599 command << fileDlg->LineEdit1->text(); 622 command << fileDlg->LineEdit1->text();
600 Output *outDlg; 623 Output *outDlg;
601 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 624 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
602 QPEApplication::execDialog( outDlg ); 625 QPEApplication::execDialog( outDlg );
603 qApp->processEvents(); 626 qApp->processEvents();
604 627
605 } 628 }
606} 629}
607 630
608void AdvancedFm::runCommandStd() { 631void AdvancedFm::runCommandStd() {
609 if( !CurrentView()->currentItem()) return; 632 if( !CurrentView()->currentItem()) return;
610 QString curFile; 633 QString curFile;
611 QDir *thisDir = CurrentDir(); 634 QDir *thisDir = CurrentDir();
612 QListView *thisView = CurrentView(); 635 QListView *thisView = CurrentView();
613 if( thisView->currentItem()) 636 if( thisView->currentItem())
614 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 637 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
615 638
616 InputDialog *fileDlg; 639 InputDialog *fileDlg;
617 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 640 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
618 fileDlg->setInputText(curFile); 641 fileDlg->setInputText(curFile);
619 fileDlg->exec(); 642 fileDlg->exec();
620 643
621 if( fileDlg->result() == 1 ) { 644 if( fileDlg->result() == 1 ) {
622 qApp->processEvents(); 645 qApp->processEvents();
623 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 646 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
624 } 647 }
625} 648}
626 649
627void AdvancedFm::fileStatus() { 650void AdvancedFm::fileStatus() {
628 if( !CurrentView()->currentItem()) return; 651 if( !CurrentView()->currentItem()) return;
629 QString curFile; 652 QString curFile;
630 curFile = CurrentView()->currentItem()->text(0); 653 curFile = CurrentView()->currentItem()->text(0);
631 654
632 QStringList command; 655 QStringList command;
633 command << "/bin/sh"; 656 command << "/bin/sh";
634 command << "-c"; 657 command << "-c";
635 command << "stat -l "+ curFile; 658 command << "stat -l "+ curFile;
636 659
637 Output *outDlg; 660 Output *outDlg;
638 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 661 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
639 QPEApplication::execDialog( outDlg ); 662 QPEApplication::execDialog( outDlg );
640 qApp->processEvents(); 663 qApp->processEvents();
641} 664}
642 665
643 666
644void AdvancedFm::mkDir() { 667void AdvancedFm::mkDir() {
645 makeDir(); 668 makeDir();
646} 669}
647 670
648void AdvancedFm::rn() { 671void AdvancedFm::rn() {
649 renameIt(); 672 renameIt();
650} 673}
651 674
652void AdvancedFm::del() { 675void AdvancedFm::del() {
653 doDelete(); 676 doDelete();
654} 677}
655 678
656void AdvancedFm::mkSym() { 679void AdvancedFm::mkSym() {
657 QString cmd; 680 QString cmd;
658 QStringList curFileList = getPath(); 681 QStringList curFileList = getPath();
659 if( curFileList.count() > 0) { 682 if( curFileList.count() > 0) {
660 QDir *thisDir = CurrentDir(); 683 QDir *thisDir = CurrentDir();
661 QDir * thatDir = OtherDir(); 684 QDir * thatDir = OtherDir();
662 685
663 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 686 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
664 687
665 QString destName = thatDir->canonicalPath()+"/"+(*it); 688 QString destName = thatDir->canonicalPath()+"/"+(*it);
666 if(destName.right(1) == "/") { 689 if(destName.right(1) == "/") {
667 destName = destName.left( destName.length() -1); 690 destName = destName.left( destName.length() -1);
668 } 691 }
669 692
670 QString curFile = thisDir->canonicalPath()+"/"+(*it); 693 QString curFile = thisDir->canonicalPath()+"/"+(*it);
671 694
672 if( curFile.right(1) == "/") { 695 if( curFile.right(1) == "/") {
673 curFile = curFile.left( curFile.length() -1); 696 curFile = curFile.left( curFile.length() -1);
674 } 697 }
675 698
676 cmd = "ln -s "+curFile+" "+destName; 699 cmd = "ln -s "+curFile+" "+destName;
677// odebug << cmd << oendl; 700// odebug << cmd << oendl;
678 startProcess( (const QString)cmd ); 701 startProcess( (const QString)cmd );
679 } 702 }
680 rePopulate(); 703 rePopulate();
681 setOtherTabCurrent(); 704 setOtherTabCurrent();
682 } 705 }
683} 706}
684 707
685void AdvancedFm::doBeam() { 708void AdvancedFm::doBeam() {
686 Ir ir; 709 Ir ir;
687 if(!ir.supported()) { 710 if(!ir.supported()) {
688 } else { 711 } else {
689 QStringList curFileList = getPath(); 712 QStringList curFileList = getPath();
690 if( curFileList.count() > 0) { 713 if( curFileList.count() > 0) {
691 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 714 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
692 QString curFile = (*it); 715 QString curFile = (*it);
693 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 716 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
694 if( curFilePath.right(1) == "/") { 717 if( curFilePath.right(1) == "/") {
695 curFilePath = curFilePath.left( curFilePath.length() -1); 718 curFilePath = curFilePath.left( curFilePath.length() -1);
696 } 719 }
697 Ir *file = new Ir(this, "IR"); 720 Ir *file = new Ir(this, "IR");
698 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); 721 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
699 file->send( curFilePath, curFile ); 722 file->send( curFilePath, curFile );
700 } 723 }
701 } 724 }
702 } 725 }
703} 726}
704 727
705void AdvancedFm::fileBeamFinished( Ir *) { 728void AdvancedFm::fileBeamFinished( Ir *) {
706 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 729 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
707} 730}
708 731
709void AdvancedFm::selectAll() { 732void AdvancedFm::selectAll() {
710 QListView *thisView = CurrentView(); 733 QListView *thisView = CurrentView();
711 thisView->selectAll(true); 734 thisView->selectAll(true);
712 thisView->setSelected( thisView->firstChild(),false); 735 thisView->setSelected( thisView->firstChild(),false);
713} 736}
714 737
715void AdvancedFm::startProcess(const QString & cmd) { 738void AdvancedFm::startProcess(const QString & cmd) {
716 QStringList command; 739 QStringList command;
717 OProcess *process; 740 OProcess *process;
718 process = new OProcess(); 741 process = new OProcess();
719 connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); 742 connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*)));
720 connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); 743 connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int)));
721 744
722 command << "/bin/sh"; 745 command << "/bin/sh";
723 command << "-c"; 746 command << "-c";
724 command << cmd.latin1(); 747 command << cmd.latin1();
725 *process << command; 748 *process << command;
726 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 749 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
727 odebug << "could not start process" << oendl; 750 odebug << "could not start process" << oendl;
728} 751}
729 752
730void AdvancedFm::processEnded(OProcess *) { 753void AdvancedFm::processEnded(OProcess *) {
731 rePopulate(); 754 rePopulate();
732} 755}
733 756
734void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 757void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
735// owarn << "received stderrt " << buflen << " bytes" << oendl; 758// owarn << "received stderrt " << buflen << " bytes" << oendl;
736 759
737 QString lineStr = buffer; 760 QString lineStr = buffer;
738 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 761 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
739} 762}
740 763
741bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 764bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
742 if ( o->inherits( "QLineEdit" ) ) { 765 if ( o->inherits( "QLineEdit" ) ) {
743 if ( e->type() == QEvent::KeyPress ) { 766 if ( e->type() == QEvent::KeyPress ) {
744 QKeyEvent *ke = (QKeyEvent*)e; 767 QKeyEvent *ke = (QKeyEvent*)e;
745 if ( ke->key() == Key_Return || 768 if ( ke->key() == Key_Return ||
746 ke->key() == Key_Enter ) { 769 ke->key() == Key_Enter ) {
747 okRename(); 770 okRename();
748 return true; 771 return true;
749 } 772 }
750 else if ( ke->key() == Key_Escape ) { 773 else if ( ke->key() == Key_Escape ) {
751 cancelRename(); 774 cancelRename();
752 return true; 775 return true;
753 } 776 }
754 } 777 }
755 else if ( e->type() == QEvent::FocusOut ) { 778 else if ( e->type() == QEvent::FocusOut ) {
756 cancelRename(); 779 cancelRename();
757 return true; 780 return true;
758 } 781 }
759 } 782 }
760 if ( o->inherits( "QListView" ) ) { 783 if ( o->inherits( "QListView" ) ) {
761 if ( e->type() == QEvent::FocusIn ) { 784 if ( e->type() == QEvent::FocusIn ) {
762 if( o == Local_View) { //keep track of which view 785 if( o == Local_View) { //keep track of which view
763 whichTab = 1; 786 whichTab = 1;
764 viewMenu->setItemChecked(viewMenu->idAt(0), true); 787 viewMenu->setItemChecked(viewMenu->idAt(0), true);
765 viewMenu->setItemChecked(viewMenu->idAt(1), false); 788 viewMenu->setItemChecked(viewMenu->idAt(1), false);
766 } else { 789 } else {
767 whichTab = 2; 790 whichTab = 2;
768 viewMenu->setItemChecked(viewMenu->idAt(0), false); 791 viewMenu->setItemChecked(viewMenu->idAt(0), false);
769 viewMenu->setItemChecked(viewMenu->idAt(1), true); 792 viewMenu->setItemChecked(viewMenu->idAt(1), true);
770 } 793 }
771 } 794 }
772 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection 795 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
773 } 796 }
774 797
775 return QWidget::eventFilter( o, e ); 798 return QWidget::eventFilter( o, e );
776} 799}
777 800
778 801
779void AdvancedFm::cancelRename() { 802void AdvancedFm::cancelRename() {
780// odebug << "cancel rename" << oendl; 803// odebug << "cancel rename" << oendl;
781 QListView * view; 804 QListView * view;
782 view = CurrentView(); 805 view = CurrentView();
783 806
784 bool resetFocus = view->viewport()->focusProxy() == renameBox; 807 bool resetFocus = view->viewport()->focusProxy() == renameBox;
785 delete renameBox; 808 delete renameBox;
786 renameBox = 0; 809 renameBox = 0;
787 if ( resetFocus ) { 810 if ( resetFocus ) {
788 view->viewport()->setFocusProxy( view); 811 view->viewport()->setFocusProxy( view);
789 view->setFocus(); 812 view->setFocus();
790 } 813 }
791} 814}
792 815
793void AdvancedFm::doRename(QListView * view) { 816void AdvancedFm::doRename(QListView * view) {
794 if( !CurrentView()->currentItem()) return; 817 if( !CurrentView()->currentItem()) return;
795 818
796 QRect r = view->itemRect( view->currentItem( )); 819 QRect r = view->itemRect( view->currentItem( ));
797 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 820 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
798 r.setX( view->contentsX() ); 821 r.setX( view->contentsX() );
799 if ( r.width() > view->visibleWidth() ) 822 if ( r.width() > view->visibleWidth() )
800 r.setWidth( view->visibleWidth() ); 823 r.setWidth( view->visibleWidth() );
801 824
802 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 825 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
803 renameBox->setFrame(true); 826 renameBox->setFrame(true);
804 renameBox->setText( view->currentItem()->text(0) ); 827 renameBox->setText( view->currentItem()->text(0) );
805 renameBox->selectAll(); 828 renameBox->selectAll();
806 renameBox->installEventFilter( this ); 829 renameBox->installEventFilter( this );
807 view->addChild( renameBox, r.x(), r.y() ); 830 view->addChild( renameBox, r.x(), r.y() );
808 renameBox->resize( r.size() ); 831 renameBox->resize( r.size() );
809 view->viewport()->setFocusProxy( renameBox ); 832 view->viewport()->setFocusProxy( renameBox );
810 renameBox->setFocus(); 833 renameBox->setFocus();
811 renameBox->show(); 834 renameBox->show();
812} 835}
813 836
814 837
815void AdvancedFm::renameIt() { 838void AdvancedFm::renameIt() {
816 if( !CurrentView()->currentItem()) return; 839 if( !CurrentView()->currentItem()) return;
817 840
818 QListView *thisView = CurrentView(); 841 QListView *thisView = CurrentView();
819 oldName = thisView->currentItem()->text(0); 842 oldName = thisView->currentItem()->text(0);
820 doRename( thisView ); 843 doRename( thisView );
821} 844}
822 845
823void AdvancedFm::okRename() { 846void AdvancedFm::okRename() {
824 qDebug("okrename"); 847 qDebug("okrename");
825 if( !renameBox) return; 848 if( !renameBox) return;
826 849
827 QString newName = renameBox->text(); 850 QString newName = renameBox->text();
828 cancelRename(); 851 cancelRename();
829 QListView * view = CurrentView(); 852 QListView * view = CurrentView();
830 QString path = CurrentDir()->canonicalPath() + "/"; 853 QString path = CurrentDir()->canonicalPath() + "/";
831 oldName = path + oldName; 854 oldName = path + oldName;
832 newName = path + newName; 855 newName = path + newName;
833 if( rename( oldName.latin1(), newName.latin1())== -1) 856 if( rename( oldName.latin1(), newName.latin1())== -1)
834 QMessageBox::message(tr("Note"),tr("Could not rename")); 857 QMessageBox::message(tr("Note"),tr("Could not rename"));
835 else 858 else
836 oldName = ""; 859 oldName = "";
837 QListViewItem *item = view->currentItem(); 860 QListViewItem *item = view->currentItem();
838 view->takeItem( item ); 861 view->takeItem( item );
839 delete item; 862 delete item;
840 rePopulate(); 863 rePopulate();
841} 864}
842 865
843void AdvancedFm::openSearch() { 866void AdvancedFm::openSearch() {
844 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 867 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
845} 868}