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