summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index a6b59c7..98d024d 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -105,780 +105,778 @@ void AdvancedFm::showRemoteHidden() {
105 105
106QString AdvancedFm::dealWithSymName(const QString &fileName) { 106QString AdvancedFm::dealWithSymName(const QString &fileName) {
107 QString strItem = fileName; 107 QString strItem = fileName;
108 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 108 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
109} 109}
110 110
111void AdvancedFm::runThis() { 111void AdvancedFm::runThis() {
112 QString fs; 112 QString fs;
113 if (TabWidget->getCurrentTab() == 0) { 113 if (TabWidget->getCurrentTab() == 0) {
114 QString curFile = Local_View->currentItem()->text(0); 114 QString curFile = Local_View->currentItem()->text(0);
115 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 115 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
116 curFile = dealWithSymName((const QString&)curFile); 116 curFile = dealWithSymName((const QString&)curFile);
117 117
118 if(curFile != "../") { 118 if(curFile != "../") {
119 119
120 fs = getFileSystemType((const QString &) currentDir.canonicalPath()); 120 fs = getFileSystemType((const QString &) currentDir.canonicalPath());
121 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 121 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
122 qDebug( fileInfo.owner()); 122 qDebug( fileInfo.owner());
123 if( (fileInfo.permission( QFileInfo::ExeUser) 123 if( (fileInfo.permission( QFileInfo::ExeUser)
124 | fileInfo.permission( QFileInfo::ExeGroup) 124 | fileInfo.permission( QFileInfo::ExeGroup)
125 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 125 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
126 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 126 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
127 QCopEnvelope e("QPE/System", "execute(QString)" ); 127 QCopEnvelope e("QPE/System", "execute(QString)" );
128 e << curFile; 128 e << curFile;
129 } else { 129 } else {
130 curFile = currentDir.canonicalPath()+"/"+curFile; 130 curFile = currentDir.canonicalPath()+"/"+curFile;
131 DocLnk nf(curFile); 131 DocLnk nf(curFile);
132 QString execStr = nf.exec(); 132 QString execStr = nf.exec();
133 qDebug( execStr); 133 qDebug( execStr);
134 if( execStr.isEmpty() ) { 134 if( execStr.isEmpty() ) {
135 } else { 135 } else {
136 nf.execute(); 136 nf.execute();
137 } 137 }
138 } 138 }
139 } 139 }
140 } else { 140 } else {
141 QString curFile = Remote_View->currentItem()->text(0); 141 QString curFile = Remote_View->currentItem()->text(0);
142 if(curFile != "../") { 142 if(curFile != "../") {
143 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 143 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
144 curFile = dealWithSymName((const QString&)curFile); 144 curFile = dealWithSymName((const QString&)curFile);
145 145
146 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 146 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
147 qDebug("Filesystemtype is "+fs); 147 qDebug("Filesystemtype is "+fs);
148 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); 148 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
149 if( (fileInfo.permission( QFileInfo::ExeUser) 149 if( (fileInfo.permission( QFileInfo::ExeUser)
150 | fileInfo.permission( QFileInfo::ExeGroup) 150 | fileInfo.permission( QFileInfo::ExeGroup)
151 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 151 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
152 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 152 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
153 QCopEnvelope e("QPE/System", "execute(QString)" ); 153 QCopEnvelope e("QPE/System", "execute(QString)" );
154 e << curFile; 154 e << curFile;
155 } else { 155 } else {
156 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 156 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
157 DocLnk nf(curFile); 157 DocLnk nf(curFile);
158 QString execStr = nf.exec(); 158 QString execStr = nf.exec();
159 qDebug(execStr); 159 qDebug(execStr);
160 if( execStr.isEmpty() ) { 160 if( execStr.isEmpty() ) {
161 } else { 161 } else {
162 nf.execute(); 162 nf.execute();
163 } 163 }
164 } 164 }
165 } 165 }
166 } 166 }
167} 167}
168 168
169void AdvancedFm::runText() { 169void AdvancedFm::runText() {
170 if (TabWidget->getCurrentTab() == 0) { 170 if (TabWidget->getCurrentTab() == 0) {
171 QString curFile = Local_View->currentItem()->text(0); 171 QString curFile = Local_View->currentItem()->text(0);
172 if(curFile != "../") { 172 if(curFile != "../") {
173 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 173 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
174 curFile = dealWithSymName((const QString&)curFile); 174 curFile = dealWithSymName((const QString&)curFile);
175 curFile = currentDir.canonicalPath()+"/"+curFile; 175 curFile = currentDir.canonicalPath()+"/"+curFile;
176 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 176 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
177 e << curFile; 177 e << curFile;
178 } 178 }
179 } else { 179 } else {
180 QString curFile = Remote_View->currentItem()->text(0); 180 QString curFile = Remote_View->currentItem()->text(0);
181 if(curFile != "../") { 181 if(curFile != "../") {
182 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 182 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
183 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 183 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
184 curFile = dealWithSymName((const QString&)curFile); 184 curFile = dealWithSymName((const QString&)curFile);
185 DocLnk nf(curFile); 185 DocLnk nf(curFile);
186 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 186 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
187 e << curFile; 187 e << curFile;
188 } 188 }
189 } 189 }
190} 190}
191 191
192void AdvancedFm::localMakDir() { 192void AdvancedFm::localMakDir() {
193 InputDialog *fileDlg; 193 InputDialog *fileDlg;
194 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 194 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
195 fileDlg->exec(); 195 fileDlg->exec();
196 if( fileDlg->result() == 1 ) { 196 if( fileDlg->result() == 1 ) {
197 QString filename = fileDlg->LineEdit1->text(); 197 QString filename = fileDlg->LineEdit1->text();
198 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 198 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
199 } 199 }
200 populateLocalView(); 200 populateLocalView();
201} 201}
202 202
203void AdvancedFm::remoteMakDir() { 203void AdvancedFm::remoteMakDir() {
204 InputDialog *fileDlg; 204 InputDialog *fileDlg;
205 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 205 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
206 fileDlg->exec(); 206 fileDlg->exec();
207 if( fileDlg->result() == 1 ) { 207 if( fileDlg->result() == 1 ) {
208 QString filename = fileDlg->LineEdit1->text(); 208 QString filename = fileDlg->LineEdit1->text();
209 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); 209 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
210 } 210 }
211 populateRemoteView(); 211 populateRemoteView();
212} 212}
213 213
214void AdvancedFm::localDelete() { 214void AdvancedFm::localDelete() {
215 QStringList curFileList = getPath(); 215 QStringList curFileList = getPath();
216 bool doMsg=true; 216 bool doMsg=true;
217 int count=curFileList.count(); 217 int count=curFileList.count();
218 if( count > 0) { 218 if( count > 0) {
219 if(count > 1 ){ 219 if(count > 1 ){
220 QString msg; 220 QString msg;
221 msg=tr("Really delete\n%1 files?").arg(count); 221 msg=tr("Really delete\n%1 files?").arg(count);
222 switch ( QMessageBox::warning(this,tr("Delete"),msg 222 switch ( QMessageBox::warning(this,tr("Delete"),msg
223 ,tr("Yes"),tr("No"),0,0,1) ) { 223 ,tr("Yes"),tr("No"),0,0,1) ) {
224 case 0: 224 case 0:
225 doMsg=false; 225 doMsg=false;
226 break; 226 break;
227 case 1: 227 case 1:
228 return; 228 return;
229 break; 229 break;
230 }; 230 };
231 } 231 }
232 232
233 QString myFile; 233 QString myFile;
234 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 234 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
235 myFile = (*it); 235 myFile = (*it);
236 if( myFile.find(" -> ",0,TRUE) != -1) 236 if( myFile.find(" -> ",0,TRUE) != -1)
237 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 237 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
238 238
239 QString f = currentDir.canonicalPath(); 239 QString f = currentDir.canonicalPath();
240 if(f.right(1).find("/",0,TRUE) == -1) 240 if(f.right(1).find("/",0,TRUE) == -1)
241 f+="/"; 241 f+="/";
242 f+=myFile; 242 f+=myFile;
243 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 243 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
244 switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ 244 switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+
245 "\nand all it's contents ?" 245 "\nand all it's contents ?"
246 ,tr("Yes"),tr("No"),0,0,1) ) { 246 ,tr("Yes"),tr("No"),0,0,1) ) {
247 case 0: { 247 case 0: {
248 f=f.left(f.length()-1); 248 f=f.left(f.length()-1);
249 QString cmd="rm -rf "+f; 249 QString cmd="rm -rf "+f;
250 startProcess( (const QString)cmd.latin1() ); 250 startProcess( (const QString)cmd.latin1() );
251 populateLocalView(); 251 populateLocalView();
252 } 252 }
253 break; 253 break;
254 case 1: 254 case 1:
255 // exit 255 // exit
256 break; 256 break;
257 }; 257 };
258 258
259 } else { 259 } else {
260 if(doMsg) { 260 if(doMsg) {
261 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 261 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
262 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 262 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
263 case 1: 263 case 1:
264 return; 264 return;
265 break; 265 break;
266 }; 266 };
267 } 267 }
268 QString cmd="rm "+f; 268 QString cmd="rm "+f;
269 QFile file(f); 269 QFile file(f);
270 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 270 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
271 file.remove(); 271 file.remove();
272 } 272 }
273 } 273 }
274 } 274 }
275 populateLocalView(); 275 populateLocalView();
276} 276}
277 277
278void AdvancedFm::remoteDelete() { 278void AdvancedFm::remoteDelete() {
279 QStringList curFileList = getPath(); 279 QStringList curFileList = getPath();
280 bool doMsg=true; 280 bool doMsg=true;
281 int count=curFileList.count(); 281 int count=curFileList.count();
282 if( count > 0) { 282 if( count > 0) {
283 if(count > 1 ){ 283 if(count > 1 ){
284 QString msg; 284 QString msg;
285 msg=tr("Really delete\n%1 files?").arg(count); 285 msg=tr("Really delete\n%1 files?").arg(count);
286 switch ( QMessageBox::warning(this,tr("Delete"),msg 286 switch ( QMessageBox::warning(this,tr("Delete"),msg
287 ,tr("Yes"),tr("No"),0,0,1) ) { 287 ,tr("Yes"),tr("No"),0,0,1) ) {
288 case 0: 288 case 0:
289 doMsg=false; 289 doMsg=false;
290 break; 290 break;
291 case 1: 291 case 1:
292 return; 292 return;
293 break; 293 break;
294 }; 294 };
295 } 295 }
296 296
297 QString myFile; 297 QString myFile;
298 298
299 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 299 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
300 myFile = (*it); 300 myFile = (*it);
301 if(myFile.find(" -> ",0,TRUE) != -1) 301 if(myFile.find(" -> ",0,TRUE) != -1)
302 myFile = myFile.left(myFile.find(" -> ",0,TRUE)); 302 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
303 QString f = currentRemoteDir.canonicalPath(); 303 QString f = currentRemoteDir.canonicalPath();
304 if(f.right(1).find("/",0,TRUE) == -1) 304 if(f.right(1).find("/",0,TRUE) == -1)
305 f+="/"; 305 f+="/";
306 f+=myFile; 306 f+=myFile;
307 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 307 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
308 switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ 308 switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+
309 "\nand all it's contents ?", 309 "\nand all it's contents ?",
310 tr("Yes"),tr("No"),0,0,1) ) { 310 tr("Yes"),tr("No"),0,0,1) ) {
311 case 0: { 311 case 0: {
312 f=f.left(f.length()-1); 312 f=f.left(f.length()-1);
313 QString cmd="rm -rf "+f; 313 QString cmd="rm -rf "+f;
314 startProcess( (const QString)cmd ); 314 startProcess( (const QString)cmd );
315 populateRemoteView(); 315 populateRemoteView();
316 } 316 }
317 break; 317 break;
318 case 1: 318 case 1:
319 // exit 319 // exit
320 break; 320 break;
321 }; 321 };
322 322
323 } else { 323 } else {
324 if(doMsg) { 324 if(doMsg) {
325 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 325 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
326 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 326 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
327 case 1: 327 case 1:
328 return; 328 return;
329 break; 329 break;
330 }; 330 };
331 } 331 }
332 QString cmd="rm "+f; 332 QString cmd="rm "+f;
333 QFile file(f); 333 QFile file(f);
334 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 334 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
335 file.remove(); 335 file.remove();
336 } 336 }
337 } 337 }
338 } 338 }
339 populateRemoteView(); 339 populateRemoteView();
340} 340}
341 341
342void AdvancedFm::localRename() { 342void AdvancedFm::localRename() {
343 QString curFile = Local_View->currentItem()->text(0); 343 QString curFile = Local_View->currentItem()->text(0);
344 qDebug("currentItem "+curFile); 344 qDebug("currentItem "+curFile);
345 if( curFile !="../") { 345 if( curFile !="../") {
346 InputDialog *fileDlg; 346 InputDialog *fileDlg;
347 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 347 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
348 fileDlg->setInputText((const QString &)curFile); 348 fileDlg->setInputText((const QString &)curFile);
349 fileDlg->exec(); 349 fileDlg->exec();
350 if( fileDlg->result() == 1 ) { 350 if( fileDlg->result() == 1 ) {
351 QString oldname = currentDir.canonicalPath() + "/" + curFile; 351 QString oldname = currentDir.canonicalPath() + "/" + curFile;
352 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); 352 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
353//+".playlist"; 353//+".playlist";
354 if( rename(oldname.latin1(), newName.latin1())== -1) 354 if( rename(oldname.latin1(), newName.latin1())== -1)
355 QMessageBox::message(tr("Note"),tr("Could not rename")); 355 QMessageBox::message(tr("Note"),tr("Could not rename"));
356 } 356 }
357 populateLocalView(); 357 populateLocalView();
358 } 358 }
359} 359}
360 360
361void AdvancedFm::remoteRename() 361void AdvancedFm::remoteRename()
362{ 362{
363 QString curFile = Remote_View->currentItem()->text(0); 363 QString curFile = Remote_View->currentItem()->text(0);
364 if( curFile !="../") { 364 if( curFile !="../") {
365 InputDialog *fileDlg; 365 InputDialog *fileDlg;
366 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 366 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
367 fileDlg->setInputText((const QString &)curFile); 367 fileDlg->setInputText((const QString &)curFile);
368 fileDlg->exec(); 368 fileDlg->exec();
369 if( fileDlg->result() == 1 ) { 369 if( fileDlg->result() == 1 ) {
370 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; 370 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
371 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); 371 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
372//+".playlist"; 372//+".playlist";
373 if( rename(oldname.latin1(), newName.latin1())== -1) 373 if( rename(oldname.latin1(), newName.latin1())== -1)
374 QMessageBox::message(tr("Note"),tr("Could not rename")); 374 QMessageBox::message(tr("Note"),tr("Could not rename"));
375 } 375 }
376 populateRemoteView(); 376 populateRemoteView();
377 } 377 }
378} 378}
379 379
380 380
381void AdvancedFm::filePerms() { 381void AdvancedFm::filePerms() {
382 382
383 QStringList curFileList = getPath(); 383 QStringList curFileList = getPath();
384 QString filePath; 384 QString filePath;
385 385
386 if (TabWidget->getCurrentTab() == 0) { 386 if (TabWidget->getCurrentTab() == 0) {
387 filePath = currentDir.canonicalPath()+"/"; 387 filePath = currentDir.canonicalPath()+"/";
388 } else { 388 } else {
389 filePath= currentRemoteDir.canonicalPath()+"/"; 389 filePath= currentRemoteDir.canonicalPath()+"/";
390 } 390 }
391 391
392 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 392 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
393 filePermissions *filePerm; 393 filePermissions *filePerm;
394 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 394 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
395 filePerm->showMaximized(); 395 filePerm->showMaximized();
396 filePerm->exec(); 396 filePerm->exec();
397 if( filePerm) 397 if( filePerm)
398 delete filePerm; 398 delete filePerm;
399 } 399 }
400 if (TabWidget->getCurrentTab() == 0) { 400 if (TabWidget->getCurrentTab() == 0) {
401 populateLocalView(); 401 populateLocalView();
402 } else { 402 } else {
403 populateRemoteView(); 403 populateRemoteView();
404 } 404 }
405} 405}
406 406
407void AdvancedFm::doProperties() { 407void AdvancedFm::doProperties() {
408#if defined(QT_QWS_OPIE) 408#if defined(QT_QWS_OPIE)
409 409
410 QStringList curFileList = getPath(); 410 QStringList curFileList = getPath();
411 411
412 QString filePath; 412 QString filePath;
413 if (TabWidget->getCurrentTab() == 0) { 413 if (TabWidget->getCurrentTab() == 0) {
414 filePath = currentDir.canonicalPath()+"/"; 414 filePath = currentDir.canonicalPath()+"/";
415 } else { 415 } else {
416 filePath= currentRemoteDir.canonicalPath()+"/"; 416 filePath= currentRemoteDir.canonicalPath()+"/";
417 } 417 }
418 qDebug("%d",curFileList.count()); 418 qDebug("%d",curFileList.count());
419 419
420 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 420 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
421 qDebug((filePath+*it)); 421 qDebug((filePath+*it));
422 DocLnk lnk( (filePath+*it)); 422 DocLnk lnk( (filePath+*it));
423 LnkProperties prop( &lnk ); 423 LnkProperties prop( &lnk );
424 prop.showMaximized(); 424 prop.showMaximized();
425 prop.exec(); 425 prop.exec();
426 } 426 }
427#endif 427#endif
428 428
429} 429}
430 430
431void AdvancedFm::upDir() { 431void AdvancedFm::upDir() {
432 if (TabWidget->getCurrentTab() == 0) { 432 if (TabWidget->getCurrentTab() == 0) {
433 QString current = currentDir.canonicalPath(); 433 QString current = currentDir.canonicalPath();
434 QDir dir(current); 434 QDir dir(current);
435 dir.cdUp(); 435 dir.cdUp();
436 current = dir.canonicalPath(); 436 current = dir.canonicalPath();
437 chdir( current.latin1() ); 437 chdir( current.latin1() );
438 currentDir.cd( current, TRUE); 438 currentDir.cd( current, TRUE);
439 populateLocalView(); 439 populateLocalView();
440 update(); 440 update();
441 } else { 441 } else {
442 QString current = currentRemoteDir.canonicalPath(); 442 QString current = currentRemoteDir.canonicalPath();
443 QDir dir(current); 443 QDir dir(current);
444 dir.cdUp(); 444 dir.cdUp();
445 current = dir.canonicalPath(); 445 current = dir.canonicalPath();
446 chdir( current.latin1() ); 446 chdir( current.latin1() );
447 currentRemoteDir.cd( current, TRUE); 447 currentRemoteDir.cd( current, TRUE);
448 populateRemoteView(); 448 populateRemoteView();
449 update(); 449 update();
450 } 450 }
451} 451}
452 452
453void AdvancedFm::copy() { 453void AdvancedFm::copy() {
454 qApp->processEvents(); 454 qApp->processEvents();
455 QStringList curFileList = getPath(); 455 QStringList curFileList = getPath();
456 bool doMsg=true; 456 bool doMsg=true;
457 int count=curFileList.count(); 457 int count=curFileList.count();
458 if( count > 0) { 458 if( count > 0) {
459 if(count > 1 ){ 459 if(count > 1 ){
460 QString msg; 460 QString msg;
461 msg=tr("Really copy\n%1 files?").arg(count); 461 msg=tr("Really copy\n%1 files?").arg(count);
462 switch ( QMessageBox::warning(this,tr("Delete"),msg 462 switch ( QMessageBox::warning(this,tr("Delete"),msg
463 ,tr("Yes"),tr("No"),0,0,1) ) { 463 ,tr("Yes"),tr("No"),0,0,1) ) {
464 case 0: 464 case 0:
465 doMsg=false; 465 doMsg=false;
466 break; 466 break;
467 case 1: 467 case 1:
468 return; 468 return;
469 break; 469 break;
470 }; 470 };
471 } 471 }
472 472
473 QString curFile, item, destFile; 473 QString curFile, item, destFile;
474 if (TabWidget->getCurrentTab() == 0) { 474 if (TabWidget->getCurrentTab() == 0) {
475 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 475 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
476 item=(*it); 476 item=(*it);
477 if(item.find("->",0,TRUE)) //symlink 477 if(item.find("->",0,TRUE)) //symlink
478 item = item.left(item.find("->",0,TRUE)); 478 item = item.left(item.find("->",0,TRUE));
479 479
480 destFile = currentRemoteDir.canonicalPath()+"/"+ item; 480 destFile = currentRemoteDir.canonicalPath()+"/"+ item;
481 qDebug("Destination file is "+destFile); 481 qDebug("Destination file is "+destFile);
482 482
483 curFile = currentDir.canonicalPath()+"/"+ item; 483 curFile = currentDir.canonicalPath()+"/"+ item;
484 qDebug("CurrentFile file is " + curFile); 484 qDebug("CurrentFile file is " + curFile);
485 485
486 QFile f(destFile); 486 QFile f(destFile);
487 if( f.exists()) { 487 if( f.exists()) {
488 if(doMsg) { 488 if(doMsg) {
489 switch ( QMessageBox::warning(this,tr("File Exists!"), 489 switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) {
490 item+tr("\nexists. Ok to overwrite?"),
491 tr("Yes"),tr("No"),0,0,1) ) {
492 case 1: 490 case 1:
493 return; 491 return;
494 break; 492 break;
495 }; 493 };
496 } 494 }
497 f.remove(); 495 f.remove();
498 } 496 }
499 if(!copyFile( curFile, destFile) ) { 497 if(!copyFile( curFile, destFile) ) {
500 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 498 QMessageBox::message("AdvancedFm",tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
501 return; 499 return;
502 } 500 }
503 } 501 }
504 populateRemoteView(); 502 populateRemoteView();
505 TabWidget->setCurrentTab(1); 503 TabWidget->setCurrentTab(1);
506 504
507 } else { 505 } else {
508 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 506 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
509 item= (*it); 507 item= (*it);
510 if(item.find("->",0,TRUE)) //symlink 508 if(item.find("->",0,TRUE)) //symlink
511 item = item.left(item.find("->",0,TRUE)); 509 item = item.left(item.find("->",0,TRUE));
512 510
513 destFile = currentDir.canonicalPath()+"/"+ item; 511 destFile = currentDir.canonicalPath()+"/"+ item;
514 qDebug("Destination file is "+destFile); 512 qDebug("Destination file is "+destFile);
515 513
516 curFile = currentRemoteDir.canonicalPath()+"/"+ item;; 514 curFile = currentRemoteDir.canonicalPath()+"/"+ item;;
517 qDebug("CurrentFile file is " + curFile); 515 qDebug("CurrentFile file is " + curFile);
518 516
519 QFile f(destFile); 517 QFile f(destFile);
520 if( f.exists()) { 518 if( f.exists()) {
521 switch ( QMessageBox::warning(this,tr("File Exists!"), 519 switch ( QMessageBox::warning(this,tr("File Exists!"),
522 item+tr("\nexists. Ok to overwrite?"), 520 item+tr("\nexists. Ok to overwrite?"),
523 tr("Yes"),tr("No"),0,0,1) ) { 521 tr("Yes"),tr("No"),0,0,1) ) {
524 case 1: 522 case 1:
525 return; 523 return;
526 break; 524 break;
527 }; 525 };
528 f.remove(); 526 f.remove();
529 } 527 }
530 if(!copyFile( curFile, destFile) ) { 528 if(!copyFile( curFile, destFile) ) {
531 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 529 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
532 +curFile +tr("to\n")+destFile); 530 +curFile +tr("to\n")+destFile);
533 return; 531 return;
534 532
535 } 533 }
536 } 534 }
537 populateLocalView(); 535 populateLocalView();
538 TabWidget->setCurrentTab(0); 536 TabWidget->setCurrentTab(0);
539 } 537 }
540 538
541 } 539 }
542} 540}
543 541
544void AdvancedFm::copyAs() { 542void AdvancedFm::copyAs() {
545 qApp->processEvents(); 543 qApp->processEvents();
546 544
547 QStringList curFileList = getPath(); 545 QStringList curFileList = getPath();
548 QString curFile, item; 546 QString curFile, item;
549 InputDialog *fileDlg; 547 InputDialog *fileDlg;
550 if (TabWidget->getCurrentTab() == 0) { 548 if (TabWidget->getCurrentTab() == 0) {
551 qDebug("tab 1"); 549 qDebug("tab 1");
552 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 550 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
553 QString destFile; 551 QString destFile;
554 item=(*it); 552 item=(*it);
555 curFile = currentDir.canonicalPath()+"/"+(*it); 553 curFile = currentDir.canonicalPath()+"/"+(*it);
556 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 554 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
557 555
558 fileDlg->setInputText((const QString &) destFile ); 556 fileDlg->setInputText((const QString &) destFile );
559 fileDlg->exec(); 557 fileDlg->exec();
560 558
561 if( fileDlg->result() == 1 ) { 559 if( fileDlg->result() == 1 ) {
562 QString filename = fileDlg->LineEdit1->text(); 560 QString filename = fileDlg->LineEdit1->text();
563 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 561 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
564 562
565 QFile f(destFile); 563 QFile f(destFile);
566 if( f.exists()) { 564 if( f.exists()) {
567 switch (QMessageBox::warning(this,tr("File Exists!"), 565 switch (QMessageBox::warning(this,tr("File Exists!"),
568 item+tr("\nexists. Ok to overwrite?"), 566 item+tr("\nexists. Ok to overwrite?"),
569 tr("Yes"),tr("No"),0,0,1) ) { 567 tr("Yes"),tr("No"),0,0,1) ) {
570 case 0: 568 case 0:
571 f.remove(); 569 f.remove();
572 break; 570 break;
573 case 1: 571 case 1:
574 return; 572 return;
575 break; 573 break;
576 }; 574 };
577 } 575 }
578 if(!copyFile( curFile,destFile) ) { 576 if(!copyFile( curFile,destFile) ) {
579 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 577 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
580 +curFile +tr("to\n")+destFile); 578 +curFile +tr("to\n")+destFile);
581 return; 579 return;
582 } 580 }
583 } 581 }
584 delete fileDlg; 582 delete fileDlg;
585 583
586 } 584 }
587 populateRemoteView(); 585 populateRemoteView();
588 TabWidget->setCurrentTab(1); 586 TabWidget->setCurrentTab(1);
589 587
590 } else { 588 } else {
591 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 589 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
592 590
593 item=(*it); 591 item=(*it);
594 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 592 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
595 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 593 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
596 594
597 QString destFile; 595 QString destFile;
598 fileDlg->setInputText((const QString &) destFile); 596 fileDlg->setInputText((const QString &) destFile);
599 fileDlg->exec(); 597 fileDlg->exec();
600 598
601 if( fileDlg->result() == 1 ) { 599 if( fileDlg->result() == 1 ) {
602 QString filename = fileDlg->LineEdit1->text(); 600 QString filename = fileDlg->LineEdit1->text();
603 destFile = currentDir.canonicalPath()+"/"+filename; 601 destFile = currentDir.canonicalPath()+"/"+filename;
604 602
605 QFile f( destFile); 603 QFile f( destFile);
606 if( f.exists()) { 604 if( f.exists()) {
607 switch ( QMessageBox::warning(this,tr("File Exists!"), 605 switch ( QMessageBox::warning(this,tr("File Exists!"),
608 item+tr("\nexists. Ok to overwrite?"), 606 item+tr("\nexists. Ok to overwrite?"),
609 tr("Yes"),tr("No"),0,0,1) ) { 607 tr("Yes"),tr("No"),0,0,1) ) {
610 case 0: 608 case 0:
611 f.remove(); 609 f.remove();
612 break; 610 break;
613 case 1: 611 case 1:
614 return; 612 return;
615 break; 613 break;
616 }; 614 };
617 } 615 }
618 if(!copyFile( curFile,destFile) ) { 616 if(!copyFile( curFile,destFile) ) {
619 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 617 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
620 +curFile +tr("to\n")+destFile); 618 +curFile +tr("to\n")+destFile);
621 return; 619 return;
622 } 620 }
623 621
624 } 622 }
625 delete fileDlg; 623 delete fileDlg;
626 624
627 } 625 }
628 populateLocalView(); 626 populateLocalView();
629 TabWidget->setCurrentTab(0); 627 TabWidget->setCurrentTab(0);
630 } 628 }
631} 629}
632 630
633void AdvancedFm::copySameDir() { 631void AdvancedFm::copySameDir() {
634 qApp->processEvents(); 632 qApp->processEvents();
635 QStringList curFileList = getPath(); 633 QStringList curFileList = getPath();
636 QString curFile, item, destFile; 634 QString curFile, item, destFile;
637 InputDialog *fileDlg; 635 InputDialog *fileDlg;
638 636
639 if (TabWidget->getCurrentTab() == 0) { 637 if (TabWidget->getCurrentTab() == 0) {
640 638
641 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 639 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
642 item=(*it); 640 item=(*it);
643 curFile = currentDir.canonicalPath()+"/"+ item; 641 curFile = currentDir.canonicalPath()+"/"+ item;
644 642
645 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 643 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
646 fileDlg->setInputText((const QString &) destFile ); 644 fileDlg->setInputText((const QString &) destFile );
647 fileDlg->exec(); 645 fileDlg->exec();
648 646
649 if( fileDlg->result() == 1 ) { 647 if( fileDlg->result() == 1 ) {
650 648
651 QString filename = fileDlg->LineEdit1->text(); 649 QString filename = fileDlg->LineEdit1->text();
652 destFile = currentDir.canonicalPath()+"/"+filename; 650 destFile = currentDir.canonicalPath()+"/"+filename;
653 651
654 QFile f(destFile); 652 QFile f(destFile);
655 if( f.exists()) { 653 if( f.exists()) {
656 switch (QMessageBox::warning(this,tr("Delete"), 654 switch (QMessageBox::warning(this,tr("Delete"),
657 destFile+tr(" already exists.\nDo you really want to delete it?"), 655 destFile+tr(" already exists.\nDo you really want to delete it?"),
658 tr("Yes"),tr("No"),0,0,1) ) { 656 tr("Yes"),tr("No"),0,0,1) ) {
659 case 0: 657 case 0:
660 658
661 f.remove(); 659 f.remove();
662 break; 660 break;
663 case 1: 661 case 1:
664 return; 662 return;
665 break; 663 break;
666 }; 664 };
667 } 665 }
668 if(!copyFile( curFile,destFile) ) { 666 if(!copyFile( curFile,destFile) ) {
669 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 667 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
670 +curFile +tr("to\n")+destFile); 668 +curFile +tr("to\n")+destFile);
671 return; 669 return;
672 } 670 }
673 671
674 qDebug("copy "+curFile+" as "+destFile); 672 qDebug("copy "+curFile+" as "+destFile);
675 } 673 }
676 delete fileDlg; 674 delete fileDlg;
677 } 675 }
678 populateLocalView(); 676 populateLocalView();
679 677
680 } else { 678 } else {
681 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 679 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
682 item=(*it); 680 item=(*it);
683 curFile = currentRemoteDir.canonicalPath()+"/"+ item; 681 curFile = currentRemoteDir.canonicalPath()+"/"+ item;
684 682
685 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 683 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
686 fileDlg->setInputText((const QString &) destFile); 684 fileDlg->setInputText((const QString &) destFile);
687 fileDlg->exec(); 685 fileDlg->exec();
688 if( fileDlg->result() == 1 ) { 686 if( fileDlg->result() == 1 ) {
689 QString filename = fileDlg->LineEdit1->text(); 687 QString filename = fileDlg->LineEdit1->text();
690 688
691 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 689 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
692 690
693 QFile f(destFile); 691 QFile f(destFile);
694 if( f.exists()) { 692 if( f.exists()) {
695 switch ( QMessageBox::warning(this,tr("Delete"), 693 switch ( QMessageBox::warning(this,tr("Delete"),
696 destFile+tr(" already exists.\nDo you really want to delete it?"), 694 destFile+tr(" already exists.\nDo you really want to delete it?"),
697 tr("Yes"),tr("No"),0,0,1) ) { 695 tr("Yes"),tr("No"),0,0,1) ) {
698 case 0: 696 case 0:
699 f.remove(); 697 f.remove();
700 break; 698 break;
701 case 1: 699 case 1:
702 return; 700 return;
703 break; 701 break;
704 }; 702 };
705 } 703 }
706 if(!copyFile( curFile,destFile) ) { 704 if(!copyFile( curFile,destFile) ) {
707 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 705 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
708 +curFile +tr("to\n")+destFile); 706 +curFile +tr("to\n")+destFile);
709 return; 707 return;
710 } 708 }
711 qDebug("copy "+curFile+" as "+destFile); 709 qDebug("copy "+curFile+" as "+destFile);
712 } 710 }
713 delete fileDlg; 711 delete fileDlg;
714 } 712 }
715 populateRemoteView(); 713 populateRemoteView();
716 } 714 }
717} 715}
718 716
719void AdvancedFm::move() { 717void AdvancedFm::move() {
720 qApp->processEvents(); 718 qApp->processEvents();
721 719
722 QStringList curFileList = getPath(); 720 QStringList curFileList = getPath();
723 if( curFileList.count() > 0) { 721 if( curFileList.count() > 0) {
724 QString curFile, destFile, item; 722 QString curFile, destFile, item;
725 723
726 if (TabWidget->getCurrentTab() == 0) { 724 if (TabWidget->getCurrentTab() == 0) {
727 725
728 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 726 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
729 item=(*it); 727 item=(*it);
730 QString destFile = currentRemoteDir.canonicalPath(); 728 QString destFile = currentRemoteDir.canonicalPath();
731 729
732 if(destFile.right(1).find("/",0,TRUE) == -1) 730 if(destFile.right(1).find("/",0,TRUE) == -1)
733 destFile+="/"; 731 destFile+="/";
734 destFile += item; 732 destFile += item;
735 curFile = currentDir.canonicalPath(); 733 curFile = currentDir.canonicalPath();
736 734
737 qDebug("Destination file is "+destFile); 735 qDebug("Destination file is "+destFile);
738 736
739 if(curFile.right(1).find("/",0,TRUE) == -1) 737 if(curFile.right(1).find("/",0,TRUE) == -1)
740 curFile +="/"; 738 curFile +="/";
741 739
742 curFile+= item; 740 curFile+= item;
743 qDebug("CurrentFile file is " + curFile); 741 qDebug("CurrentFile file is " + curFile);
744 742
745 QFile f( curFile); 743 QFile f( curFile);
746 if( f.exists()) { 744 if( f.exists()) {
747 if(!copyFile( curFile,destFile) ) { 745 if(!copyFile( curFile,destFile) ) {
748 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 746 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
749 return; 747 return;
750 } else 748 } else
751 QFile::remove(curFile); 749 QFile::remove(curFile);
752 } 750 }
753 } 751 }
754 752
755 TabWidget->setCurrentTab(1); 753 TabWidget->setCurrentTab(1);
756 754
757 } else { //view 2 755 } else { //view 2
758 756
759 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 757 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
760 item = (*it); 758 item = (*it);
761 QString destFile = currentDir.canonicalPath(); 759 QString destFile = currentDir.canonicalPath();
762 760
763 if(destFile.right(1).find("/",0,TRUE) == -1) 761 if(destFile.right(1).find("/",0,TRUE) == -1)
764 destFile+="/"; 762 destFile+="/";
765 763
766 destFile += item; 764 destFile += item;
767 765
768 qDebug("Destination file is "+destFile); 766 qDebug("Destination file is "+destFile);
769 767
770 curFile = currentRemoteDir.canonicalPath(); 768 curFile = currentRemoteDir.canonicalPath();
771 769
772 if(curFile.right(1).find("/",0,TRUE) == -1) 770 if(curFile.right(1).find("/",0,TRUE) == -1)
773 curFile +="/"; 771 curFile +="/";
774 curFile+= item; 772 curFile+= item;
775 qDebug("CurrentFile file is " + curFile); 773 qDebug("CurrentFile file is " + curFile);
776 774
777 QFile f( curFile); 775 QFile f( curFile);
778 if( f.exists()) { 776 if( f.exists()) {
779 if(!copyFile( curFile, destFile) ) { 777 if(!copyFile( curFile, destFile) ) {
780 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); 778 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
781 return; 779 return;
782 } else 780 } else
783 QFile::remove( curFile); 781 QFile::remove( curFile);
784 } 782 }
785 TabWidget->setCurrentTab(0); 783 TabWidget->setCurrentTab(0);
786 } 784 }
787 } 785 }
788 populateRemoteView(); 786 populateRemoteView();
789 populateLocalView(); 787 populateLocalView();
790 } 788 }
791} 789}
792 790
793bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 791bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
794 char bf[ 50000 ]; 792 char bf[ 50000 ];
795 int bytesRead; 793 int bytesRead;
796 bool success = TRUE; 794 bool success = TRUE;
797 struct stat status; 795 struct stat status;
798 796
799 QFile s( src ); 797 QFile s( src );
800 QFile d( dest ); 798 QFile d( dest );
801 799
802 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 800 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
803 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 801 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
804 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 802 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
805 success = FALSE; 803 success = FALSE;
806 break; 804 break;
807 } 805 }
808 } 806 }
809 if( success && (bytesRead > 0) ){ 807 if( success && (bytesRead > 0) ){
810 d.writeBlock( bf, bytesRead ); 808 d.writeBlock( bf, bytesRead );
811 } 809 }
812 } else { 810 } else {
813 success = FALSE; 811 success = FALSE;
814 } 812 }
815 813
816 // Set file permissions 814 // Set file permissions
817 if( stat( (const char *) src, &status ) == 0 ){ 815 if( stat( (const char *) src, &status ) == 0 ){
818 chmod( (const char *) dest, status.st_mode ); 816 chmod( (const char *) dest, status.st_mode );
819 } 817 }
820 818
821 return success; 819 return success;
822} 820}
823 821
824void AdvancedFm::runCommand() { 822void AdvancedFm::runCommand() {
825 QString curFile; 823 QString curFile;
826 if (TabWidget->getCurrentTab() == 0) { 824 if (TabWidget->getCurrentTab() == 0) {
827 if( Local_View->currentItem()) 825 if( Local_View->currentItem())
828 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 826 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
829 } else { 827 } else {
830 if(Remote_View->currentItem()) 828 if(Remote_View->currentItem())
831 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); 829 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
832 } 830 }
833 831
834 InputDialog *fileDlg; 832 InputDialog *fileDlg;
835 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 833 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
836 fileDlg->setInputText(curFile); 834 fileDlg->setInputText(curFile);
837 fileDlg->exec(); 835 fileDlg->exec();
838 //QString command; 836 //QString command;
839 837
840 if( fileDlg->result() == 1 ) { 838 if( fileDlg->result() == 1 ) {
841 qDebug(fileDlg->LineEdit1->text()); 839 qDebug(fileDlg->LineEdit1->text());
842 QStringList command; 840 QStringList command;
843 841
844 command << "/bin/sh"; 842 command << "/bin/sh";
845 command << "-c"; 843 command << "-c";
846 command << fileDlg->LineEdit1->text(); 844 command << fileDlg->LineEdit1->text();
847 Output *outDlg; 845 Output *outDlg;
848 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 846 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
849 outDlg->showMaximized(); 847 outDlg->showMaximized();
850 outDlg->exec(); 848 outDlg->exec();
851 qApp->processEvents(); 849 qApp->processEvents();
852 850
853 } 851 }
854} 852}
855 853
856void AdvancedFm::runCommandStd() { 854void AdvancedFm::runCommandStd() {
857 QString curFile; 855 QString curFile;
858 if (TabWidget->getCurrentTab() == 0) { 856 if (TabWidget->getCurrentTab() == 0) {
859 if( Local_View->currentItem()) 857 if( Local_View->currentItem())
860 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 858 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
861 } else { 859 } else {
862 if(Remote_View->currentItem()) 860 if(Remote_View->currentItem())
863 curFile = currentRemoteDir.canonicalPath() +"/" 861 curFile = currentRemoteDir.canonicalPath() +"/"
864 + Remote_View->currentItem()->text(0); 862 + Remote_View->currentItem()->text(0);
865 } 863 }
866 864
867 InputDialog *fileDlg; 865 InputDialog *fileDlg;
868 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 866 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
869 fileDlg->setInputText(curFile); 867 fileDlg->setInputText(curFile);
870 fileDlg->exec(); 868 fileDlg->exec();
871 869
872 if( fileDlg->result() == 1 ) { 870 if( fileDlg->result() == 1 ) {
873 qApp->processEvents(); 871 qApp->processEvents();
874 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 872 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
875 } 873 }
876} 874}
877 875
878void AdvancedFm::fileStatus() { 876void AdvancedFm::fileStatus() {
879 QString curFile; 877 QString curFile;
880 if (TabWidget->getCurrentTab() == 0) { 878 if (TabWidget->getCurrentTab() == 0) {
881 curFile = Local_View->currentItem()->text(0); 879 curFile = Local_View->currentItem()->text(0);
882 } else { 880 } else {
883 curFile = Remote_View->currentItem()->text(0); 881 curFile = Remote_View->currentItem()->text(0);
884 } 882 }