summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-12-20 21:08:25 (UTC)
committer llornkcor <llornkcor>2003-12-20 21:08:25 (UTC)
commitc7bad76e8d576fc0b6999775c89c724c6fa89158 (patch) (unidiff)
treeff4c08395c6c2f90efb75ca7f1037c5a3c77c830
parentef3584f1fd410e00d21d26d4ebbb9b6766669086 (diff)
downloadopie-c7bad76e8d576fc0b6999775c89c724c6fa89158.zip
opie-c7bad76e8d576fc0b6999775c89c724c6fa89158.tar.gz
opie-c7bad76e8d576fc0b6999775c89c724c6fa89158.tar.bz2
fix rename
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 90c887f..26bc36d 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,850 +1,854 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#include "advancedfm.h" 12#include "advancedfm.h"
13#include "output.h" 13#include "output.h"
14#include "filePermissions.h" 14#include "filePermissions.h"
15 15
16#include <opie/otabwidget.h> 16#include <opie/otabwidget.h>
17#include <opie/oprocess.h> 17#include <opie/oprocess.h>
18 18
19#include <qpe/lnkproperties.h> 19#include <qpe/lnkproperties.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/ir.h> 24#include <qpe/ir.h>
25 25
26#include <qmessagebox.h> 26#include <qmessagebox.h>
27#include <qmultilineedit.h> 27#include <qmultilineedit.h>
28 28
29#include <qstring.h> 29#include <qstring.h>
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qpixmap.h> 32#include <qpixmap.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtabwidget.h> 35#include <qtabwidget.h>
36#include <qtoolbutton.h> 36#include <qtoolbutton.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qlistview.h> 38#include <qlistview.h>
39 39
40#include <errno.h> 40#include <errno.h>
41#include <stdlib.h> 41#include <stdlib.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <sys/stat.h> 43#include <sys/stat.h>
44#include <dirent.h> 44#include <dirent.h>
45#include <sys/sendfile.h> 45#include <sys/sendfile.h>
46#include <fcntl.h> 46#include <fcntl.h>
47 47
48 48
49void AdvancedFm::doDirChange() { 49void AdvancedFm::doDirChange() {
50 QString pathItem = CurrentView()->currentItem()->text(0); 50 QString pathItem = CurrentView()->currentItem()->text(0);
51 if( pathItem == "../") { 51 if( pathItem == "../") {
52 ListClicked( CurrentView()->currentItem()); 52 ListClicked( CurrentView()->currentItem());
53 } else { 53 } else {
54 if( pathItem.find(" -> ",0,TRUE) != -1) 54 if( pathItem.find(" -> ",0,TRUE) != -1)
55 pathItem = dealWithSymName((const QString&)pathItem)+"/"; 55 pathItem = dealWithSymName((const QString&)pathItem)+"/";
56// qWarning(pathItem); 56// qWarning(pathItem);
57 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); 57 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
58 } 58 }
59} 59}
60 60
61void AdvancedFm::showMenuHidden() { 61void AdvancedFm::showMenuHidden() {
62 if (b) { 62 if (b) {
63 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 63 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
64 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 64 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
65 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 65 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
66 } else { 66 } else {
67 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 67 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
68 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 68 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
70 } 70 }
71 b = !b; 71 b = !b;
72 populateView(); 72 populateView();
73} 73}
74 74
75void AdvancedFm::showHidden() { 75void AdvancedFm::showHidden() {
76 if (b) { 76 if (b) {
77 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 77 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
78 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 78 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
79 } else { 79 } else {
80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
81 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 81 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
82 } 82 }
83 populateView(); 83 populateView();
84} 84}
85 85
86QString AdvancedFm::dealWithSymName(const QString &fileName) { 86QString AdvancedFm::dealWithSymName(const QString &fileName) {
87 QString strItem = fileName; 87 QString strItem = fileName;
88 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 88 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
89} 89}
90 90
91void AdvancedFm::runThis() { 91void AdvancedFm::runThis() {
92 if( !CurrentView()->currentItem()) return; 92 if( !CurrentView()->currentItem()) return;
93 QString fs; 93 QString fs;
94 QDir *thisDir = CurrentDir(); 94 QDir *thisDir = CurrentDir();
95 95
96 QString curFile = CurrentView()->currentItem()->text(0); 96 QString curFile = CurrentView()->currentItem()->text(0);
97 QString path = thisDir->canonicalPath(); 97 QString path = thisDir->canonicalPath();
98 98
99 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 99 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
100 100
101 curFile = dealWithSymName((const QString&)curFile); 101 curFile = dealWithSymName((const QString&)curFile);
102 102
103 if(curFile != "../") { 103 if(curFile != "../") {
104 104
105 fs = getFileSystemType((const QString &) path); 105 fs = getFileSystemType((const QString &) path);
106 QFileInfo fileInfo( path + "/" + curFile); 106 QFileInfo fileInfo( path + "/" + curFile);
107// qDebug( fileInfo.owner()); 107// qDebug( fileInfo.owner());
108 108
109 if( (fileInfo.permission( QFileInfo::ExeUser) 109 if( (fileInfo.permission( QFileInfo::ExeUser)
110 | fileInfo.permission( QFileInfo::ExeGroup) 110 | fileInfo.permission( QFileInfo::ExeGroup)
111 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 111 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
112 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 112 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
113 QCopEnvelope e("QPE/System", "execute(QString)" ); 113 QCopEnvelope e("QPE/System", "execute(QString)" );
114 e << curFile; 114 e << curFile;
115 } else { 115 } else {
116 curFile = path + "/" + curFile; 116 curFile = path + "/" + curFile;
117 DocLnk nf(curFile); 117 DocLnk nf(curFile);
118 QString execStr = nf.exec(); 118 QString execStr = nf.exec();
119// qDebug( execStr); 119// qDebug( execStr);
120 if( execStr.isEmpty() ) { 120 if( execStr.isEmpty() ) {
121 } else { 121 } else {
122 nf.execute(); 122 nf.execute();
123 } 123 }
124 } 124 }
125 } 125 }
126} 126}
127 127
128void AdvancedFm::runText() { 128void AdvancedFm::runText() {
129 if( !CurrentView()->currentItem()) return; 129 if( !CurrentView()->currentItem()) return;
130 QString curFile = CurrentView()->currentItem()->text(0); 130 QString curFile = CurrentView()->currentItem()->text(0);
131 if(curFile != "../") { 131 if(curFile != "../") {
132 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 132 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
133 curFile = dealWithSymName((const QString&)curFile); 133 curFile = dealWithSymName((const QString&)curFile);
134 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 134 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
135 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 135 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
136 e << curFile; 136 e << curFile;
137 } 137 }
138} 138}
139 139
140void AdvancedFm::makeDir() { 140void AdvancedFm::makeDir() {
141 InputDialog *fileDlg; 141 InputDialog *fileDlg;
142 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 142 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
143 fileDlg->exec(); 143 fileDlg->exec();
144 if( fileDlg->result() == 1 ) { 144 if( fileDlg->result() == 1 ) {
145 QDir *thisDir = CurrentDir(); 145 QDir *thisDir = CurrentDir();
146 QString filename = fileDlg->LineEdit1->text(); 146 QString filename = fileDlg->LineEdit1->text();
147 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 147 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
148 } 148 }
149 populateView(); 149 populateView();
150} 150}
151 151
152void AdvancedFm::doDelete() { 152void AdvancedFm::doDelete() {
153 QStringList curFileList = getPath(); 153 QStringList curFileList = getPath();
154 bool doMsg=true; 154 bool doMsg=true;
155 int count = curFileList.count(); 155 int count = curFileList.count();
156 if( count > 0) { 156 if( count > 0) {
157 if(count > 1 ) { 157 if(count > 1 ) {
158 QString msg; 158 QString msg;
159 msg=tr("Really delete\n%1 files?").arg(count); 159 msg=tr("Really delete\n%1 files?").arg(count);
160 switch ( QMessageBox::warning(this,tr("Delete"),msg 160 switch ( QMessageBox::warning(this,tr("Delete"),msg
161 ,tr("Yes"),tr("No"),0,0,1) ) 161 ,tr("Yes"),tr("No"),0,0,1) )
162 { 162 {
163 case 0: 163 case 0:
164 doMsg=false; 164 doMsg=false;
165 break; 165 break;
166 case 1: 166 case 1:
167 return; 167 return;
168 break; 168 break;
169 }; 169 };
170 } 170 }
171 171
172 QString myFile; 172 QString myFile;
173 173
174 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 174 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
175 myFile = (*it); 175 myFile = (*it);
176 if( myFile.find(" -> ",0,TRUE) != -1) 176 if( myFile.find(" -> ",0,TRUE) != -1)
177 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 177 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
178 178
179 QString f = CurrentDir()->canonicalPath(); 179 QString f = CurrentDir()->canonicalPath();
180 if(f.right(1).find("/",0,TRUE) == -1) 180 if(f.right(1).find("/",0,TRUE) == -1)
181 f += "/"; 181 f += "/";
182 f += myFile; 182 f += myFile;
183 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 183 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
184 //if file is a directory 184 //if file is a directory
185 185
186 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 186 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
187 tr("Really delete %1\nand all it's contents ?" ).arg( f ) , 187 tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
188 tr("Yes"), tr("No"), 0, 0, 1) ) { 188 tr("Yes"), tr("No"), 0, 0, 1) ) {
189 case 0: 189 case 0:
190 { 190 {
191 f=f.left(f.length()-1); 191 f=f.left(f.length()-1);
192 QString cmd="rm -rf "+f; 192 QString cmd="rm -rf "+f;
193 startProcess( (const QString)cmd.latin1() ); 193 startProcess( (const QString)cmd.latin1() );
194 populateView(); 194 populateView();
195 } 195 }
196 break; 196 break;
197 case 1: 197 case 1:
198 // exit 198 // exit
199 break; 199 break;
200 }; 200 };
201 201
202 } else { 202 } else {
203 if(doMsg) { 203 if(doMsg) {
204 switch ( QMessageBox::warning(this,tr("Delete"), 204 switch ( QMessageBox::warning(this,tr("Delete"),
205 tr("Really delete\n%1?").arg( myFile ), 205 tr("Really delete\n%1?").arg( myFile ),
206 tr("Yes"), tr("No"), 0, 0, 1) ) { 206 tr("Yes"), tr("No"), 0, 0, 1) ) {
207 case 1: 207 case 1:
208 return; 208 return;
209 break; 209 break;
210 }; 210 };
211 } 211 }
212 212
213 QString cmd="rm "+f; 213 QString cmd="rm "+f;
214 QFile file(f); 214 QFile file(f);
215 QFileInfo fi(myFile); 215 QFileInfo fi(myFile);
216 if( fi.fileName().find("../",0,TRUE)==-1) { 216 if( fi.fileName().find("../",0,TRUE)==-1) {
217// qDebug("remove link files "+myFile); 217// qDebug("remove link files "+myFile);
218 218
219// DocLnk lnk(f); 219// DocLnk lnk(f);
220 DocLnk *lnk; 220 DocLnk *lnk;
221 lnk = new DocLnk(f); 221 lnk = new DocLnk(f);
222// qDebug("Deleting doclnk " + lnk->linkFile()); 222// qDebug("Deleting doclnk " + lnk->linkFile());
223 if(lnk->isValid()) 223 if(lnk->isValid())
224 lnk->removeLinkFile(); 224 lnk->removeLinkFile();
225 // delete lnk; 225 // delete lnk;
226 file.remove(); 226 file.remove();
227 } 227 }
228 } 228 }
229 } 229 }
230 } 230 }
231 populateView(); 231 populateView();
232} 232}
233 233
234void AdvancedFm::filePerms() { 234void AdvancedFm::filePerms() {
235 QStringList curFileList = getPath(); 235 QStringList curFileList = getPath();
236 QString filePath; 236 QString filePath;
237 237
238 filePath = CurrentDir()->canonicalPath()+"/"; 238 filePath = CurrentDir()->canonicalPath()+"/";
239 239
240 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 240 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
241 filePermissions *filePerm; 241 filePermissions *filePerm;
242 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 242 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
243 filePerm->showMaximized(); 243 filePerm->showMaximized();
244 filePerm->exec(); 244 filePerm->exec();
245 if( filePerm) 245 if( filePerm)
246 delete filePerm; 246 delete filePerm;
247 } 247 }
248 populateView(); 248 populateView();
249} 249}
250 250
251void AdvancedFm::doProperties() { 251void AdvancedFm::doProperties() {
252#if defined(QT_QWS_OPIE) 252#if defined(QT_QWS_OPIE)
253 253
254 QStringList curFileList = getPath(); 254 QStringList curFileList = getPath();
255 255
256 QString filePath; 256 QString filePath;
257 filePath = CurrentDir()->canonicalPath()+"/"; 257 filePath = CurrentDir()->canonicalPath()+"/";
258 258
259// qDebug("%d",curFileList.count()); 259// qDebug("%d",curFileList.count());
260 260
261 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 261 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
262// qDebug((filePath+*it)); 262// qDebug((filePath+*it));
263 DocLnk lnk( (filePath+*it)); 263 DocLnk lnk( (filePath+*it));
264 LnkProperties prop( &lnk ); 264 LnkProperties prop( &lnk );
265 prop.showMaximized(); 265 prop.showMaximized();
266 prop.exec(); 266 prop.exec();
267 } 267 }
268#endif 268#endif
269 269
270} 270}
271 271
272void AdvancedFm::upDir() { 272void AdvancedFm::upDir() {
273 QDir *thisDir = CurrentDir(); 273 QDir *thisDir = CurrentDir();
274 QString current = thisDir->canonicalPath(); 274 QString current = thisDir->canonicalPath();
275 QDir dir(current); 275 QDir dir(current);
276 dir.cdUp(); 276 dir.cdUp();
277 current = dir.canonicalPath(); 277 current = dir.canonicalPath();
278 chdir( current.latin1() ); 278 chdir( current.latin1() );
279 thisDir->cd( current, TRUE); 279 thisDir->cd( current, TRUE);
280 280
281 populateView(); 281 populateView();
282 update(); 282 update();
283} 283}
284 284
285void AdvancedFm::copy() { 285void AdvancedFm::copy() {
286 qApp->processEvents(); 286 qApp->processEvents();
287 QStringList curFileList = getPath(); 287 QStringList curFileList = getPath();
288 288
289 QDir *thisDir = CurrentDir(); 289 QDir *thisDir = CurrentDir();
290 QDir *thatDir = OtherDir(); 290 QDir *thatDir = OtherDir();
291 291
292 bool doMsg=true; 292 bool doMsg=true;
293 int count=curFileList.count(); 293 int count=curFileList.count();
294 if( count > 0) { 294 if( count > 0) {
295 if(count > 1 ){ 295 if(count > 1 ){
296 QString msg; 296 QString msg;
297 msg=tr("Really copy\n%1 files?").arg(count); 297 msg=tr("Really copy\n%1 files?").arg(count);
298 switch ( QMessageBox::warning(this,tr("Copy"),msg 298 switch ( QMessageBox::warning(this,tr("Copy"),msg
299 ,tr("Yes"),tr("No"),0,0,1) ) 299 ,tr("Yes"),tr("No"),0,0,1) )
300 { 300 {
301 case 0: 301 case 0:
302 doMsg=false; 302 doMsg=false;
303 break; 303 break;
304 case 1: 304 case 1:
305 return; 305 return;
306 break; 306 break;
307 }; 307 };
308 } 308 }
309 309
310 QString curFile, item, destFile; 310 QString curFile, item, destFile;
311 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 311 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
312 item=(*it); 312 item=(*it);
313 if(item.find("->",0,TRUE)) //symlink 313 if(item.find("->",0,TRUE)) //symlink
314 item = item.left(item.find("->",0,TRUE)); 314 item = item.left(item.find("->",0,TRUE));
315 315
316 curFile = thisDir->canonicalPath()+"/"+ item; 316 curFile = thisDir->canonicalPath()+"/"+ item;
317 destFile = thatDir->canonicalPath()+"/"+ item; 317 destFile = thatDir->canonicalPath()+"/"+ item;
318 318
319// qDebug("Destination file is "+destFile); 319// qDebug("Destination file is "+destFile);
320// qDebug("CurrentFile file is " + curFile); 320// qDebug("CurrentFile file is " + curFile);
321 321
322 QFile f(destFile); 322 QFile f(destFile);
323 if( f.exists()) { 323 if( f.exists()) {
324 if(doMsg) { 324 if(doMsg) {
325 switch ( QMessageBox::warning(this,tr("File Exists!"), 325 switch ( QMessageBox::warning(this,tr("File Exists!"),
326 tr("%1 exists. Ok to overwrite?").arg( item ), 326 tr("%1 exists. Ok to overwrite?").arg( item ),
327 tr("Yes"),tr("No"),0,0,1) ) { 327 tr("Yes"),tr("No"),0,0,1) ) {
328 case 1: 328 case 1:
329 return; 329 return;
330 break; 330 break;
331 }; 331 };
332 } 332 }
333 f.remove(); 333 f.remove();
334 } 334 }
335 335
336 if( !copyFile( curFile, destFile) ) { 336 if( !copyFile( curFile, destFile) ) {
337 QMessageBox::message("AdvancedFm", 337 QMessageBox::message("AdvancedFm",
338 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 338 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
339 return; 339 return;
340 } 340 }
341 } 341 }
342 setOtherTabCurrent(); 342 setOtherTabCurrent();
343 rePopulate(); 343 rePopulate();
344 } 344 }
345} 345}
346 346
347void AdvancedFm::copyAs() { 347void AdvancedFm::copyAs() {
348 qApp->processEvents(); 348 qApp->processEvents();
349 349
350 QStringList curFileList = getPath(); 350 QStringList curFileList = getPath();
351 QString curFile, item; 351 QString curFile, item;
352 InputDialog *fileDlg; 352 InputDialog *fileDlg;
353 353
354 QDir *thisDir = CurrentDir(); 354 QDir *thisDir = CurrentDir();
355 QDir *thatDir = OtherDir(); 355 QDir *thatDir = OtherDir();
356 356
357 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 357 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
358 QString destFile; 358 QString destFile;
359 item=(*it); 359 item=(*it);
360 curFile = thisDir->canonicalPath()+"/"+(*it); 360 curFile = thisDir->canonicalPath()+"/"+(*it);
361 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); 361 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
362 362
363 fileDlg->setInputText((const QString &) destFile ); 363 fileDlg->setInputText((const QString &) destFile );
364 fileDlg->exec(); 364 fileDlg->exec();
365 365
366 if( fileDlg->result() == 1 ) { 366 if( fileDlg->result() == 1 ) {
367 QString filename = fileDlg->LineEdit1->text(); 367 QString filename = fileDlg->LineEdit1->text();
368 destFile = thatDir->canonicalPath()+"/"+filename; 368 destFile = thatDir->canonicalPath()+"/"+filename;
369 369
370 QFile f( destFile); 370 QFile f( destFile);
371 if( f.exists()) { 371 if( f.exists()) {
372 switch (QMessageBox::warning(this,tr("File Exists!"), 372 switch (QMessageBox::warning(this,tr("File Exists!"),
373 item+tr("\nexists. Ok to overwrite?"), 373 item+tr("\nexists. Ok to overwrite?"),
374 tr("Yes"),tr("No"),0,0,1) ) { 374 tr("Yes"),tr("No"),0,0,1) ) {
375 case 0: 375 case 0:
376 f.remove(); 376 f.remove();
377 break; 377 break;
378 case 1: 378 case 1:
379 return; 379 return;
380 break; 380 break;
381 }; 381 };
382 } 382 }
383 if( !copyFile( curFile, destFile) ) { 383 if( !copyFile( curFile, destFile) ) {
384 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 384 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
385 +curFile +tr("to\n")+destFile); 385 +curFile +tr("to\n")+destFile);
386 return; 386 return;
387 } 387 }
388 } 388 }
389 delete fileDlg; 389 delete fileDlg;
390 390
391 } 391 }
392 rePopulate(); 392 rePopulate();
393 setOtherTabCurrent(); 393 setOtherTabCurrent();
394} 394}
395 395
396void AdvancedFm::copySameDir() { 396void AdvancedFm::copySameDir() {
397 qApp->processEvents(); 397 qApp->processEvents();
398 QStringList curFileList = getPath(); 398 QStringList curFileList = getPath();
399 QString curFile, item, destFile; 399 QString curFile, item, destFile;
400 InputDialog *fileDlg; 400 InputDialog *fileDlg;
401 401
402 QDir *thisDir = CurrentDir(); 402 QDir *thisDir = CurrentDir();
403 403
404 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 404 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
405 item=(*it); 405 item=(*it);
406 curFile = thisDir->canonicalPath()+"/"+ item; 406 curFile = thisDir->canonicalPath()+"/"+ item;
407 407
408 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 408 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
409 fileDlg->setInputText((const QString &) destFile ); 409 fileDlg->setInputText((const QString &) destFile );
410 fileDlg->exec(); 410 fileDlg->exec();
411 411
412 if( fileDlg->result() == 1 ) { 412 if( fileDlg->result() == 1 ) {
413 413
414 QString filename = fileDlg->LineEdit1->text(); 414 QString filename = fileDlg->LineEdit1->text();
415 destFile = thisDir->canonicalPath()+"/"+filename; 415 destFile = thisDir->canonicalPath()+"/"+filename;
416 416
417 QFile f(destFile); 417 QFile f(destFile);
418 if( f.exists()) { 418 if( f.exists()) {
419 switch (QMessageBox::warning(this,tr("Delete"), 419 switch (QMessageBox::warning(this,tr("Delete"),
420 destFile+tr(" already exists.\nDo you really want to delete it?"), 420 destFile+tr(" already exists.\nDo you really want to delete it?"),
421 tr("Yes"),tr("No"),0,0,1) ) { 421 tr("Yes"),tr("No"),0,0,1) ) {
422 case 0: 422 case 0:
423 423
424 f.remove(); 424 f.remove();
425 break; 425 break;
426 case 1: 426 case 1:
427 return; 427 return;
428 break; 428 break;
429 }; 429 };
430 } 430 }
431 if(!copyFile( curFile,destFile) ) { 431 if(!copyFile( curFile,destFile) ) {
432 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 432 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
433 +curFile +tr("to\n")+destFile); 433 +curFile +tr("to\n")+destFile);
434 return; 434 return;
435 } 435 }
436 436
437// qDebug("copy "+curFile+" as "+destFile); 437// qDebug("copy "+curFile+" as "+destFile);
438 } 438 }
439 delete fileDlg; 439 delete fileDlg;
440 } 440 }
441 rePopulate(); 441 rePopulate();
442} 442}
443 443
444void AdvancedFm::move() { 444void AdvancedFm::move() {
445 qApp->processEvents(); 445 qApp->processEvents();
446 446
447 QStringList curFileList = getPath(); 447 QStringList curFileList = getPath();
448 if( curFileList.count() > 0) { 448 if( curFileList.count() > 0) {
449 QString curFile, destFile, item; 449 QString curFile, destFile, item;
450 450
451 QDir *thisDir = CurrentDir(); 451 QDir *thisDir = CurrentDir();
452 QDir *thatDir = OtherDir(); 452 QDir *thatDir = OtherDir();
453 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 453 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
454 item=(*it); 454 item=(*it);
455 QString destFile = thatDir->canonicalPath(); 455 QString destFile = thatDir->canonicalPath();
456 456
457 if(destFile.right(1).find("/",0,TRUE) == -1) 457 if(destFile.right(1).find("/",0,TRUE) == -1)
458 destFile+="/"; 458 destFile+="/";
459 destFile += item; 459 destFile += item;
460// qDebug("Destination file is "+destFile); 460// qDebug("Destination file is "+destFile);
461 461
462 curFile = thisDir->canonicalPath(); 462 curFile = thisDir->canonicalPath();
463 if(curFile.right(1).find("/",0,TRUE) == -1) 463 if(curFile.right(1).find("/",0,TRUE) == -1)
464 curFile +="/"; 464 curFile +="/";
465 curFile+= item; 465 curFile+= item;
466// qDebug("CurrentFile file is " + curFile); 466// qDebug("CurrentFile file is " + curFile);
467 467
468 if(QFileInfo(curFile).isDir()) { 468 if(QFileInfo(curFile).isDir()) {
469 moveDirectory( curFile, destFile ); 469 moveDirectory( curFile, destFile );
470 rePopulate(); 470 rePopulate();
471 return; 471 return;
472 } 472 }
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 QStringcmd = "/bin/cp -fpR " + src + " " + dest; 505 QStringcmd = "/bin/cp -fpR " + src + " " + dest;
506 qWarning(cmd); 506 qWarning(cmd);
507 interr = system( (const char *) cmd ); 507 interr = 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 519
520 520
521 if(QFileInfo(src).isDir()) { 521 if(QFileInfo(src).isDir()) {
522 if( copyDirectory( src, dest )) { 522 if( copyDirectory( src, dest )) {
523 setOtherTabCurrent(); 523 setOtherTabCurrent();
524 populateView(); 524 populateView();
525 return true; 525 return true;
526 } 526 }
527 else 527 else
528 return false; 528 return false;
529 } 529 }
530 530
531 531
532 bool success = true; 532 bool success = true;
533 struct stat status; 533 struct stat status;
534 QFile srcFile(src); 534 QFile srcFile(src);
535 QFile destFile(dest); 535 QFile destFile(dest);
536 int err=0; 536 int err=0;
537 int read_fd=0; 537 int read_fd=0;
538 int write_fd=0; 538 int write_fd=0;
539 struct stat stat_buf; 539 struct stat stat_buf;
540 off_t offset = 0; 540 off_t offset = 0;
541 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 541 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
542// qWarning("open failed"); 542// qWarning("open failed");
543 return success = false; 543 return success = false;
544 } 544 }
545 read_fd = srcFile.handle(); 545 read_fd = srcFile.handle();
546 if(read_fd != -1) { 546 if(read_fd != -1) {
547 fstat (read_fd, &stat_buf); 547 fstat (read_fd, &stat_buf);
548 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 548 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
549// qWarning("destfile open failed"); 549// qWarning("destfile open failed");
550 return success = false; 550 return success = false;
551 } 551 }
552 write_fd = destFile.handle(); 552 write_fd = destFile.handle();
553 if(write_fd != -1) { 553 if(write_fd != -1) {
554 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 554 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
555 if( err == -1) { 555 if( err == -1) {
556 QString msg; 556 QString msg;
557 switch(err) { 557 switch(err) {
558 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 558 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
559 case EINVAL: msg = "Descriptor is not valid or locked. "; 559 case EINVAL: msg = "Descriptor is not valid or locked. ";
560 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 560 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
561 case EIO: msg = "Unspecified error while reading from in_fd."; 561 case EIO: msg = "Unspecified error while reading from in_fd.";
562 }; 562 };
563 success = false; 563 success = false;
564// qWarning(msg); 564// qWarning(msg);
565 } 565 }
566 } else { 566 } else {
567 success = false; 567 success = false;
568 } 568 }
569 } else { 569 } else {
570 success = false; 570 success = false;
571 } 571 }
572 srcFile.close(); 572 srcFile.close();
573 destFile.close(); 573 destFile.close();
574 // Set file permissions 574 // Set file permissions
575 if( stat( (const char *) src, &status ) == 0 ) { 575 if( stat( (const char *) src, &status ) == 0 ) {
576 chmod( (const char *) dest, status.st_mode ); 576 chmod( (const char *) dest, status.st_mode );
577 } 577 }
578 578
579 return success; 579 return success;
580} 580}
581 581
582void AdvancedFm::runCommand() { 582void AdvancedFm::runCommand() {
583 if( !CurrentView()->currentItem()) return; 583 if( !CurrentView()->currentItem()) return;
584 QDir *thisDir = CurrentDir(); 584 QDir *thisDir = CurrentDir();
585 585
586 QString curFile; 586 QString curFile;
587 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 587 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
588 588
589 InputDialog *fileDlg; 589 InputDialog *fileDlg;
590 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 590 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
591 fileDlg->setInputText(curFile); 591 fileDlg->setInputText(curFile);
592 fileDlg->exec(); 592 fileDlg->exec();
593 //QString command; 593 //QString command;
594 594
595 if( fileDlg->result() == 1 ) { 595 if( fileDlg->result() == 1 ) {
596// qDebug(fileDlg->LineEdit1->text()); 596// qDebug(fileDlg->LineEdit1->text());
597 QStringList command; 597 QStringList command;
598 598
599 command << "/bin/sh"; 599 command << "/bin/sh";
600 command << "-c"; 600 command << "-c";
601 command << fileDlg->LineEdit1->text(); 601 command << fileDlg->LineEdit1->text();
602 Output *outDlg; 602 Output *outDlg;
603 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 603 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
604 outDlg->showMaximized(); 604 outDlg->showMaximized();
605 outDlg->exec(); 605 outDlg->exec();
606 qApp->processEvents(); 606 qApp->processEvents();
607 607
608 } 608 }
609} 609}
610 610
611void AdvancedFm::runCommandStd() { 611void AdvancedFm::runCommandStd() {
612 if( !CurrentView()->currentItem()) return; 612 if( !CurrentView()->currentItem()) return;
613 QString curFile; 613 QString curFile;
614 QDir *thisDir = CurrentDir(); 614 QDir *thisDir = CurrentDir();
615 QListView *thisView = CurrentView(); 615 QListView *thisView = CurrentView();
616 if( thisView->currentItem()) 616 if( thisView->currentItem())
617 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 617 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
618 618
619 InputDialog *fileDlg; 619 InputDialog *fileDlg;
620 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 620 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
621 fileDlg->setInputText(curFile); 621 fileDlg->setInputText(curFile);
622 fileDlg->exec(); 622 fileDlg->exec();
623 623
624 if( fileDlg->result() == 1 ) { 624 if( fileDlg->result() == 1 ) {
625 qApp->processEvents(); 625 qApp->processEvents();
626 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 626 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
627 } 627 }
628} 628}
629 629
630void AdvancedFm::fileStatus() { 630void AdvancedFm::fileStatus() {
631 if( !CurrentView()->currentItem()) return; 631 if( !CurrentView()->currentItem()) return;
632 QString curFile; 632 QString curFile;
633 curFile = CurrentView()->currentItem()->text(0); 633 curFile = CurrentView()->currentItem()->text(0);
634 634
635 QStringList command; 635 QStringList command;
636 command << "/bin/sh"; 636 command << "/bin/sh";
637 command << "-c"; 637 command << "-c";
638 command << "stat -l "+ curFile; 638 command << "stat -l "+ curFile;
639 639
640 Output *outDlg; 640 Output *outDlg;
641 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 641 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
642 outDlg->showMaximized(); 642 outDlg->showMaximized();
643 outDlg->exec(); 643 outDlg->exec();
644 qApp->processEvents(); 644 qApp->processEvents();
645} 645}
646 646
647 647
648void AdvancedFm::mkDir() { 648void AdvancedFm::mkDir() {
649 makeDir(); 649 makeDir();
650} 650}
651 651
652void AdvancedFm::rn() { 652void AdvancedFm::rn() {
653 renameIt(); 653 renameIt();
654} 654}
655 655
656void AdvancedFm::del() { 656void AdvancedFm::del() {
657 doDelete(); 657 doDelete();
658} 658}
659 659
660void AdvancedFm::mkSym() { 660void AdvancedFm::mkSym() {
661 QString cmd; 661 QString cmd;
662 QStringList curFileList = getPath(); 662 QStringList curFileList = getPath();
663 if( curFileList.count() > 0) { 663 if( curFileList.count() > 0) {
664 QDir *thisDir = CurrentDir(); 664 QDir *thisDir = CurrentDir();
665 QDir * thatDir = OtherDir(); 665 QDir * thatDir = OtherDir();
666 666
667 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 667 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
668 668
669 QString destName = thatDir->canonicalPath()+"/"+(*it); 669 QString destName = thatDir->canonicalPath()+"/"+(*it);
670 if(destName.right(1) == "/") { 670 if(destName.right(1) == "/") {
671 destName = destName.left( destName.length() -1); 671 destName = destName.left( destName.length() -1);
672 } 672 }
673 673
674 QString curFile = thisDir->canonicalPath()+"/"+(*it); 674 QString curFile = thisDir->canonicalPath()+"/"+(*it);
675 675
676 if( curFile.right(1) == "/") { 676 if( curFile.right(1) == "/") {
677 curFile = curFile.left( curFile.length() -1); 677 curFile = curFile.left( curFile.length() -1);
678 } 678 }
679 679
680 cmd = "ln -s "+curFile+" "+destName; 680 cmd = "ln -s "+curFile+" "+destName;
681// qDebug(cmd); 681// qDebug(cmd);
682 startProcess( (const QString)cmd ); 682 startProcess( (const QString)cmd );
683 } 683 }
684 rePopulate(); 684 rePopulate();
685 setOtherTabCurrent(); 685 setOtherTabCurrent();
686 } 686 }
687} 687}
688 688
689void AdvancedFm::doBeam() { 689void AdvancedFm::doBeam() {
690 Ir ir; 690 Ir ir;
691 if(!ir.supported()) { 691 if(!ir.supported()) {
692 } else { 692 } else {
693 QStringList curFileList = getPath(); 693 QStringList curFileList = getPath();
694 if( curFileList.count() > 0) { 694 if( curFileList.count() > 0) {
695 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 695 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
696 QString curFile = (*it); 696 QString curFile = (*it);
697 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 697 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
698 if( curFilePath.right(1) == "/") { 698 if( curFilePath.right(1) == "/") {
699 curFilePath = curFilePath.left( curFilePath.length() -1); 699 curFilePath = curFilePath.left( curFilePath.length() -1);
700 } 700 }
701 Ir *file = new Ir(this, "IR"); 701 Ir *file = new Ir(this, "IR");
702 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 702 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
703 file->send( curFilePath, curFile ); 703 file->send( curFilePath, curFile );
704 } 704 }
705 } 705 }
706 } 706 }
707} 707}
708 708
709void AdvancedFm::fileBeamFinished( Ir *) { 709void AdvancedFm::fileBeamFinished( Ir *) {
710 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 710 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
711} 711}
712 712
713void AdvancedFm::selectAll() { 713void AdvancedFm::selectAll() {
714 QListView *thisView = CurrentView(); 714 QListView *thisView = CurrentView();
715 thisView->selectAll(true); 715 thisView->selectAll(true);
716 thisView->setSelected( thisView->firstChild(),false); 716 thisView->setSelected( thisView->firstChild(),false);
717} 717}
718 718
719void AdvancedFm::startProcess(const QString & cmd) { 719void AdvancedFm::startProcess(const QString & cmd) {
720 QStringList command; 720 QStringList command;
721 OProcess *process; 721 OProcess *process;
722 process = new OProcess(); 722 process = new OProcess();
723 connect(process, SIGNAL(processExited(OProcess *)), 723 connect(process, SIGNAL(processExited(OProcess *)),
724 this, SLOT( processEnded(OProcess *))); 724 this, SLOT( processEnded(OProcess *)));
725 725
726 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), 726 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
727 this, SLOT( oprocessStderr(OProcess *, char *, int))); 727 this, SLOT( oprocessStderr(OProcess *, char *, int)));
728 728
729 command << "/bin/sh"; 729 command << "/bin/sh";
730 command << "-c"; 730 command << "-c";
731 command << cmd.latin1(); 731 command << cmd.latin1();
732 *process << command; 732 *process << command;
733 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 733 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
734 qDebug("could not start process"); 734 qDebug("could not start process");
735} 735}
736 736
737void AdvancedFm::processEnded(OProcess *) { 737void AdvancedFm::processEnded(OProcess *) {
738 rePopulate(); 738 rePopulate();
739} 739}
740 740
741void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 741void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
742// qWarning("received stderrt %d bytes", buflen); 742// qWarning("received stderrt %d bytes", buflen);
743 743
744 QString lineStr = buffer; 744 QString lineStr = buffer;
745 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 745 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
746} 746}
747 747
748bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 748bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
749 if ( o->inherits( "QLineEdit" ) ) { 749 if ( o->inherits( "QLineEdit" ) ) {
750 if ( e->type() == QEvent::KeyPress ) { 750 if ( e->type() == QEvent::KeyPress ) {
751 QKeyEvent *ke = (QKeyEvent*)e; 751 QKeyEvent *ke = (QKeyEvent*)e;
752 if ( ke->key() == Key_Return || 752 if ( ke->key() == Key_Return ||
753 ke->key() == Key_Enter ) { 753 ke->key() == Key_Enter ) {
754 okRename(); 754 okRename();
755 return true; 755 return true;
756 } 756 }
757 else if ( ke->key() == Key_Escape ) { 757 else if ( ke->key() == Key_Escape ) {
758 cancelRename(); 758 cancelRename();
759 return true; 759 return true;
760 } 760 }
761 } 761 }
762 else if ( e->type() == QEvent::FocusOut ) { 762 else if ( e->type() == QEvent::FocusOut ) {
763 cancelRename(); 763 cancelRename();
764 return true; 764 return true;
765 } 765 }
766 } 766 }
767 if ( o->inherits( "QListView" ) ) { 767 if ( o->inherits( "QListView" ) ) {
768 if ( e->type() == QEvent::FocusIn ) { 768 if ( e->type() == QEvent::FocusIn ) {
769 if( o == Local_View) { //keep track of which view 769 if( o == Local_View) { //keep track of which view
770 whichTab=1; 770 whichTab=1;
771 } 771 }
772 else { 772 else {
773 whichTab=2; 773 whichTab=2;
774 } 774 }
775 } 775 }
776 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection 776 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
777 } 777 }
778 778
779 return QWidget::eventFilter( o, e ); 779 return QWidget::eventFilter( o, e );
780} 780}
781 781
782 782
783void AdvancedFm::cancelRename() { 783void AdvancedFm::cancelRename() {
784// qDebug("cancel rename"); 784// qDebug("cancel rename");
785 QListView * view; 785 QListView * view;
786 view = CurrentView(); 786 view = CurrentView();
787 787
788 bool resetFocus = view->viewport()->focusProxy() == renameBox; 788 bool resetFocus = view->viewport()->focusProxy() == renameBox;
789 delete renameBox; 789 delete renameBox;
790 renameBox = 0; 790 renameBox = 0;
791 if ( resetFocus ) { 791 if ( resetFocus ) {
792 view->viewport()->setFocusProxy( view); 792 view->viewport()->setFocusProxy( view);
793 view->setFocus(); 793 view->setFocus();
794 } 794 }
795} 795}
796 796
797void AdvancedFm::doRename(QListView * view) { 797void AdvancedFm::doRename(QListView * view) {
798 if( !CurrentView()->currentItem()) return; 798 if( !CurrentView()->currentItem()) return;
799 799
800 QRect r = view->itemRect( view->currentItem( )); 800 QRect r = view->itemRect( view->currentItem( ));
801 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 801 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
802 r.setX( view->contentsX() ); 802 r.setX( view->contentsX() );
803 if ( r.width() > view->visibleWidth() ) 803
804 if ( r.width() > view->visibleWidth() )
804 r.setWidth( view->visibleWidth() ); 805 r.setWidth( view->visibleWidth() );
805 806
806 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 807 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
807 renameBox->setFrame(true); 808 renameBox->setFrame(true);
808 809
809 renameBox->setText( view->currentItem()->text(0) ); 810 renameBox->setText( view->currentItem()->text(0) );
810 811
811 renameBox->selectAll(); 812 renameBox->selectAll();
812 renameBox->installEventFilter( this ); 813 renameBox->installEventFilter( this );
814
813 view->addChild( renameBox, r.x(), r.y() ); 815 view->addChild( renameBox, r.x(), r.y() );
814 renameBox->resize( r.size() ); 816
815 view->viewport()->setFocusProxy( renameBox ); 817 renameBox->resize( r.size() );
816 renameBox->setFocus(); 818
819 view->viewport()->setFocusProxy( renameBox );
820
821 renameBox->setFocus();
817 renameBox->show(); 822 renameBox->show();
818} 823}
819 824
820 825
821void AdvancedFm::renameIt() { 826void AdvancedFm::renameIt() {
822 if( !CurrentView()->currentItem()) return; 827 if( !CurrentView()->currentItem()) return;
823 QListView *thisView = CurrentView(); 828
829 QListView *thisView = CurrentView();
824 oldName = thisView->currentItem()->text(0); 830 oldName = thisView->currentItem()->text(0);
825 doRename( thisView ); 831 doRename( thisView );
826 rePopulate();
827} 832}
828 833
829void AdvancedFm::okRename() { 834void AdvancedFm::okRename() {
830 if( !CurrentView()->currentItem()) return; 835 if( !CurrentView()->currentItem()) return;
836
831 QString newName = renameBox->text(); 837 QString newName = renameBox->text();
832 cancelRename(); 838 cancelRename();
833 QListView * view = CurrentView(); 839 QListView * view = CurrentView();
834 QString path = CurrentDir()->canonicalPath() + "/"; 840 QString path = CurrentDir()->canonicalPath() + "/";
835 oldName = path + oldName; 841 oldName = path + oldName;
836 newName = path + newName; 842 newName = path + newName;
837
838 if( rename( oldName.latin1(), newName.latin1())== -1) 843 if( rename( oldName.latin1(), newName.latin1())== -1)
839 QMessageBox::message(tr("Note"),tr("Could not rename")); 844 QMessageBox::message(tr("Note"),tr("Could not rename"));
840 else 845 else
841 oldName = ""; 846 oldName = "";
842
843 view->takeItem( view->currentItem() ); 847 view->takeItem( view->currentItem() );
844 delete view->currentItem(); 848 delete view->currentItem();
845 rePopulate(); 849 rePopulate();
846} 850}
847 851
848void AdvancedFm::openSearch() { 852void AdvancedFm::openSearch() {
849 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 853 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
850} 854}