summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro1
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp114
-rw-r--r--noncore/apps/advancedfm/fileInfoDialog.ui418
3 files changed, 506 insertions, 27 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
index 396f912..90d29e3 100644
--- a/noncore/apps/advancedfm/advancedfm.pro
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -1,15 +1,16 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qte warn_on quick-app debug 2CONFIG += qte warn_on quick-app debug
3HEADERS = advancedfm.h filePermissions.h output.h 3HEADERS = advancedfm.h filePermissions.h output.h
4SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp 4SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp
5TARGET = advancedfm 5TARGET = advancedfm
6INTERFACES += fileInfoDialog.ui
6INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
7DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
8LIBS += -lqpe -lopiecore2 -lopieui2 9LIBS += -lqpe -lopiecore2 -lopieui2
9 10
10!contains(CONFIG,quick-app) { 11!contains(CONFIG,quick-app) {
11 DESTDIR = $(OPIEDIR)/bin 12 DESTDIR = $(OPIEDIR)/bin
12 DEFINES += NOQUICKLAUNCH 13 DEFINES += NOQUICKLAUNCH
13} 14}
14 15
15include( $(OPIEDIR)/include.pro ) 16include( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index ed280aa..9181810 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,284 +1,286 @@
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#include "fileInfoDialog.h"
16 17
17/* OPIE */ 18/* OPIE */
18#include <opie2/odebug.h> 19#include <opie2/odebug.h>
19#include <qpe/lnkproperties.h> 20#include <qpe/lnkproperties.h>
20#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
21#include <qpe/applnk.h> 22#include <qpe/applnk.h>
22using namespace Opie::Core; 23using namespace Opie::Core;
23 24
24/* QT*/ 25/* QT*/
25 26
26#include <qmessagebox.h> 27#include <qmessagebox.h>
27#include <qpopupmenu.h> 28#include <qpopupmenu.h>
28#include <qlistview.h> 29#include <qlistview.h>
30#include <qlabel.h>
29 31
30/* STD */ 32/* STD */
31 33
32#include <errno.h> 34#include <errno.h>
33#include <stdlib.h> 35#include <stdlib.h>
34#include <unistd.h> 36#include <unistd.h>
35#include <sys/stat.h> 37#include <sys/stat.h>
36#include <dirent.h> 38#include <dirent.h>
37#include <sys/sendfile.h> 39#include <sys/sendfile.h>
38#include <fcntl.h> 40#include <fcntl.h>
39 41
40void AdvancedFm::doDirChange() { 42void AdvancedFm::doDirChange() {
41 QString pathItem = CurrentView()->currentItem()->text(0); 43 QString pathItem = CurrentView()->currentItem()->text(0);
42 if( pathItem == "../") { 44 if( pathItem == "../") {
43 ListClicked( CurrentView()->currentItem()); 45 ListClicked( CurrentView()->currentItem());
44 } else { 46 } else {
45 if( pathItem.find(" -> ",0,TRUE) != -1) 47 if( pathItem.find(" -> ",0,TRUE) != -1)
46 pathItem = dealWithSymName((const QString&)pathItem)+"/"; 48 pathItem = dealWithSymName((const QString&)pathItem)+"/";
47// owarn << pathItem << oendl; 49// owarn << pathItem << oendl;
48 changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); 50 changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
49 } 51 }
50} 52}
51 53
52void AdvancedFm::showMenuHidden() { 54void AdvancedFm::showMenuHidden() {
53 if (b) { 55 if (b) {
54 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 56 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
55 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 57 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
56 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 58 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
57 } else { 59 } else {
58 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 60 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
59 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 61 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
60 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 62 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
61 } 63 }
62 b = !b; 64 b = !b;
63 populateView(); 65 populateView();
64} 66}
65 67
66void AdvancedFm::showHidden() { 68void AdvancedFm::showHidden() {
67 if (b) { 69 if (b) {
68 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 70 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
69 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 71 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
70 } else { 72 } else {
71 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 73 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
72 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 74 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
73 } 75 }
74 populateView(); 76 populateView();
75} 77}
76 78
77QString AdvancedFm::dealWithSymName(const QString &fileName) { 79QString AdvancedFm::dealWithSymName(const QString &fileName) {
78 QString strItem = fileName; 80 QString strItem = fileName;
79 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 81 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
80} 82}
81 83
82void AdvancedFm::runThis() { 84void AdvancedFm::runThis() {
83 if( !CurrentView()->currentItem()) return; 85 if( !CurrentView()->currentItem()) return;
84 QString fs; 86 QString fs;
85 QDir *thisDir = CurrentDir(); 87 QDir *thisDir = CurrentDir();
86 88
87 QString curFile = CurrentView()->currentItem()->text(0); 89 QString curFile = CurrentView()->currentItem()->text(0);
88 QString path = thisDir->canonicalPath(); 90 QString path = thisDir->canonicalPath();
89 91
90 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 92 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
91 93
92 curFile = dealWithSymName((const QString&)curFile); 94 curFile = dealWithSymName((const QString&)curFile);
93 95
94 if(curFile != "../") { 96 if(curFile != "../") {
95 97
96 fs = getFileSystemType((const QString &) path); 98 fs = getFileSystemType((const QString &) path);
97 QFileInfo fileInfo( path + "/" + curFile); 99 QFileInfo fileInfo( path + "/" + curFile);
98// odebug << fileInfo.owner() << oendl; 100// odebug << fileInfo.owner() << oendl;
99 101
100 if( (fileInfo.permission( QFileInfo::ExeUser) 102 if( (fileInfo.permission( QFileInfo::ExeUser)
101 | fileInfo.permission( QFileInfo::ExeGroup) 103 | fileInfo.permission( QFileInfo::ExeGroup)
102 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 104 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
103 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 105 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
104 QCopEnvelope e("QPE/System", "execute(QString)" ); 106 QCopEnvelope e("QPE/System", "execute(QString)" );
105 e << curFile; 107 e << curFile;
106 } else { 108 } else {
107 curFile = path + "/" + curFile; 109 curFile = path + "/" + curFile;
108 DocLnk nf(curFile); 110 DocLnk nf(curFile);
109 QString execStr = nf.exec(); 111 QString execStr = nf.exec();
110// odebug << execStr << oendl; 112// odebug << execStr << oendl;
111 if( execStr.isEmpty() ) { 113 if( execStr.isEmpty() ) {
112 } else { 114 } else {
113 nf.execute(); 115 nf.execute();
114 } 116 }
115 } 117 }
116 } 118 }
117} 119}
118 120
119void AdvancedFm::runText() { 121void AdvancedFm::runText() {
120 if( !CurrentView()->currentItem()) return; 122 if( !CurrentView()->currentItem()) return;
121 QString curFile = CurrentView()->currentItem()->text(0); 123 QString curFile = CurrentView()->currentItem()->text(0);
122 if(curFile != "../") { 124 if(curFile != "../") {
123 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 125 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
124 curFile = dealWithSymName((const QString&)curFile); 126 curFile = dealWithSymName((const QString&)curFile);
125 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 127 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
126 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 128 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
127 e << curFile; 129 e << curFile;
128 } 130 }
129} 131}
130 132
131void AdvancedFm::makeDir() { 133void AdvancedFm::makeDir() {
132 InputDialog *fileDlg; 134 InputDialog *fileDlg;
133 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 135 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
134 fileDlg->exec(); 136 fileDlg->exec();
135 if( fileDlg->result() == 1 ) { 137 if( fileDlg->result() == 1 ) {
136 QDir *thisDir = CurrentDir(); 138 QDir *thisDir = CurrentDir();
137 QString filename = fileDlg->LineEdit1->text(); 139 QString filename = fileDlg->LineEdit1->text();
138 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 140 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
139 } 141 }
140 populateView(); 142 populateView();
141} 143}
142 144
143void AdvancedFm::doDelete() { 145void AdvancedFm::doDelete() {
144 QStringList curFileList = getPath(); 146 QStringList curFileList = getPath();
145 bool doMsg=true; 147 bool doMsg=true;
146 int count = curFileList.count(); 148 int count = curFileList.count();
147 if( count > 0) { 149 if( count > 0) {
148 if(count > 1 ) { 150 if(count > 1 ) {
149 QString msg; 151 QString msg;
150 msg=tr("<p>Really delete %1 files?</p>").arg(count); 152 msg=tr("<p>Really delete %1 files?</p>").arg(count);
151 switch ( QMessageBox::warning(this,tr("Delete"),msg 153 switch ( QMessageBox::warning(this,tr("Delete"),msg
152 ,tr("Yes"),tr("No"),0,0,1) ) 154 ,tr("Yes"),tr("No"),0,0,1) )
153 { 155 {
154 case 0: 156 case 0:
155 doMsg=false; 157 doMsg=false;
156 break; 158 break;
157 case 1: 159 case 1:
158 return; 160 return;
159 break; 161 break;
160 default: 162 default:
161 return; 163 return;
162 break; 164 break;
163 }; 165 };
164 } 166 }
165 167
166 QString myFile; 168 QString myFile;
167 169
168 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 170 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
169 myFile = (*it); 171 myFile = (*it);
170 if( myFile.find(" -> ",0,TRUE) != -1) 172 if( myFile.find(" -> ",0,TRUE) != -1)
171 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 173 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
172 174
173 QString f = CurrentDir()->canonicalPath(); 175 QString f = CurrentDir()->canonicalPath();
174 if(f.right(1).find("/",0,TRUE) == -1) 176 if(f.right(1).find("/",0,TRUE) == -1)
175 f += "/"; 177 f += "/";
176 f += myFile; 178 f += myFile;
177 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 179 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
178 //if file is a directory 180 //if file is a directory
179 181
180 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 182 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
181 tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , 183 tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) ,
182 tr("Yes"), tr("No"), 0, 0, 1) ) { 184 tr("Yes"), tr("No"), 0, 0, 1) ) {
183 case 0: 185 case 0:
184 { 186 {
185 f=f.left(f.length()-1); 187 f=f.left(f.length()-1);
186 QString cmd="rm -rf "+f; 188 QString cmd="rm -rf "+f;
187 startProcess( (const QString)cmd.latin1() ); 189 startProcess( (const QString)cmd.latin1() );
188 populateView(); 190 populateView();
189 } 191 }
190 break; 192 break;
191 case 1: 193 case 1:
192 // exit 194 // exit
193 break; 195 break;
194 default: 196 default:
195 break; 197 break;
196 }; 198 };
197 199
198 } else { 200 } else {
199 if(doMsg) { 201 if(doMsg) {
200 switch ( QMessageBox::warning(this,tr("Delete"), 202 switch ( QMessageBox::warning(this,tr("Delete"),
201 tr("<p>Really delete %1?</p>").arg( myFile ), 203 tr("<p>Really delete %1?</p>").arg( myFile ),
202 tr("Yes"), tr("No"), 0, 0, 1) ) { 204 tr("Yes"), tr("No"), 0, 0, 1) ) {
203 case 0: 205 case 0:
204 break; 206 break;
205 case 1: 207 case 1:
206 return; 208 return;
207 break; 209 break;
208 default: 210 default:
209 return; 211 return;
210 break; 212 break;
211 }; 213 };
212 } 214 }
213 215
214 QString cmd="rm "+f; 216 QString cmd="rm "+f;
215 QFile file(f); 217 QFile file(f);
216 QFileInfo fi(myFile); 218 QFileInfo fi(myFile);
217 if( fi.fileName().find("../",0,TRUE)==-1) { 219 if( fi.fileName().find("../",0,TRUE)==-1) {
218// odebug << "remove link files "+myFile << oendl; 220// odebug << "remove link files "+myFile << oendl;
219 221
220// DocLnk lnk(f); 222// DocLnk lnk(f);
221 DocLnk *lnk; 223 DocLnk *lnk;
222 lnk = new DocLnk(f); 224 lnk = new DocLnk(f);
223// odebug << "Deleting doclnk " + lnk->linkFile() << oendl; 225// odebug << "Deleting doclnk " + lnk->linkFile() << oendl;
224 if(lnk->isValid()) 226 if(lnk->isValid())
225 lnk->removeLinkFile(); 227 lnk->removeLinkFile();
226 // delete lnk; 228 // delete lnk;
227 file.remove(); 229 file.remove();
228 } 230 }
229 } 231 }
230 } 232 }
231 } 233 }
232 populateView(); 234 populateView();
233} 235}
234 236
235void AdvancedFm::filePerms() { 237void AdvancedFm::filePerms() {
236 QStringList curFileList = getPath(); 238 QStringList curFileList = getPath();
237 QString filePath; 239 QString filePath;
238 240
239 filePath = CurrentDir()->canonicalPath()+"/"; 241 filePath = CurrentDir()->canonicalPath()+"/";
240 242
241 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 243 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
242 filePermissions *filePerm; 244 filePermissions *filePerm;
243 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 245 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
244 QPEApplication::execDialog( filePerm ); 246 QPEApplication::execDialog( filePerm );
245 if( filePerm ) 247 if( filePerm )
246 delete filePerm; 248 delete filePerm;
247 } 249 }
248 populateView(); 250 populateView();
249} 251}
250 252
251void AdvancedFm::doProperties() { 253void AdvancedFm::doProperties() {
252#if defined(QT_QWS_OPIE) 254#if defined(QT_QWS_OPIE)
253 255
254 QStringList curFileList = getPath(); 256 QStringList curFileList = getPath();
255 257
256 QString filePath; 258 QString filePath;
257 filePath = CurrentDir()->canonicalPath()+"/"; 259 filePath = CurrentDir()->canonicalPath()+"/";
258 260
259// odebug << "" << curFileList.count() << "" << oendl; 261// odebug << "" << curFileList.count() << "" << oendl;
260 262
261 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 263 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
262// odebug << (filePath+*it) << oendl; 264// odebug << (filePath+*it) << oendl;
263 DocLnk lnk( (filePath+*it)); 265 DocLnk lnk( (filePath+*it));
264 LnkProperties prop( &lnk ); 266 LnkProperties prop( &lnk );
265 QPEApplication::execDialog( &prop ); 267 QPEApplication::execDialog( &prop );
266 } 268 }
267#endif 269#endif
268 270
269} 271}
270 272
271void AdvancedFm::upDir() { 273void AdvancedFm::upDir() {
272 274
273 QDir dir( CurrentDir()->canonicalPath()); 275 QDir dir( CurrentDir()->canonicalPath());
274 dir.cdUp(); 276 dir.cdUp();
275 changeTo(dir.canonicalPath()); 277 changeTo(dir.canonicalPath());
276} 278}
277 279
278void AdvancedFm::copyTimer() { 280void AdvancedFm::copyTimer() {
279 QTimer::singleShot(125,this,SLOT(copy())); 281 QTimer::singleShot(125,this,SLOT(copy()));
280} 282}
281 283
282void AdvancedFm::copy() { 284void AdvancedFm::copy() {
283 QStringList curFileList = getPath(); 285 QStringList curFileList = getPath();
284 286
@@ -400,489 +402,547 @@ void AdvancedFm::copyAs() {
400 rePopulate(); 402 rePopulate();
401 // setOtherTabCurrent(); 403 // setOtherTabCurrent();
402 qApp->processEvents(); 404 qApp->processEvents();
403 405
404} 406}
405 407
406void AdvancedFm::copySameDirTimer() { 408void AdvancedFm::copySameDirTimer() {
407 QTimer::singleShot(125,this,SLOT(copySameDir())); 409 QTimer::singleShot(125,this,SLOT(copySameDir()));
408} 410}
409 411
410void AdvancedFm::copySameDir() { 412void AdvancedFm::copySameDir() {
411 qApp->processEvents(); 413 qApp->processEvents();
412 QStringList curFileList = getPath(); 414 QStringList curFileList = getPath();
413 QString curFile, item, destFile; 415 QString curFile, item, destFile;
414 InputDialog *fileDlg; 416 InputDialog *fileDlg;
415 417
416 QDir *thisDir = CurrentDir(); 418 QDir *thisDir = CurrentDir();
417 419
418 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 420 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
419 item=(*it); 421 item=(*it);
420 curFile = thisDir->canonicalPath()+"/"+ item; 422 curFile = thisDir->canonicalPath()+"/"+ item;
421 423
422 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 424 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
423 fileDlg->setInputText((const QString &) destFile ); 425 fileDlg->setInputText((const QString &) destFile );
424 fileDlg->exec(); 426 fileDlg->exec();
425 427
426 if( fileDlg->result() == 1 ) { 428 if( fileDlg->result() == 1 ) {
427 429
428 QString filename = fileDlg->LineEdit1->text(); 430 QString filename = fileDlg->LineEdit1->text();
429 destFile = thisDir->canonicalPath()+"/"+filename; 431 destFile = thisDir->canonicalPath()+"/"+filename;
430 432
431 QFile f(destFile); 433 QFile f(destFile);
432 if( f.exists()) { 434 if( f.exists()) {
433 switch (QMessageBox::warning(this,tr("Delete"), 435 switch (QMessageBox::warning(this,tr("Delete"),
434 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), 436 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile),
435 tr("Yes"),tr("No"),0,0,1) ) { 437 tr("Yes"),tr("No"),0,0,1) ) {
436 case 0: 438 case 0:
437 f.remove(); 439 f.remove();
438 break; 440 break;
439 case 1: 441 case 1:
440 return; 442 return;
441 break; 443 break;
442 default: 444 default:
443 return; 445 return;
444 break; 446 break;
445 }; 447 };
446 } 448 }
447 if(!copyFile( curFile,destFile) ) { 449 if(!copyFile( curFile,destFile) ) {
448 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 450 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
449 return; 451 return;
450 } 452 }
451 453
452// odebug << "copy "+curFile+" as "+destFile << oendl; 454// odebug << "copy "+curFile+" as "+destFile << oendl;
453 } 455 }
454 delete fileDlg; 456 delete fileDlg;
455 } 457 }
456 rePopulate(); 458 rePopulate();
457} 459}
458 460
459void AdvancedFm::moveTimer() { 461void AdvancedFm::moveTimer() {
460 QTimer::singleShot(125,this,SLOT(move())); 462 QTimer::singleShot(125,this,SLOT(move()));
461} 463}
462 464
463void AdvancedFm::move() { 465void AdvancedFm::move() {
464 466
465 QStringList curFileList = getPath(); 467 QStringList curFileList = getPath();
466 if( curFileList.count() > 0) { 468 if( curFileList.count() > 0) {
467 QString curFile, destFile, item; 469 QString curFile, destFile, item;
468 470
469 QDir *thisDir = CurrentDir(); 471 QDir *thisDir = CurrentDir();
470 QDir *thatDir = OtherDir(); 472 QDir *thatDir = OtherDir();
471 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 473 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
472 item=(*it); 474 item=(*it);
473 QString destFile = thatDir->canonicalPath(); 475 QString destFile = thatDir->canonicalPath();
474 476
475 if(destFile.right(1).find("/",0,TRUE) == -1) 477 if(destFile.right(1).find("/",0,TRUE) == -1)
476 destFile+="/"; 478 destFile+="/";
477 destFile += item; 479 destFile += item;
478// odebug << "Destination file is "+destFile << oendl; 480// odebug << "Destination file is "+destFile << oendl;
479 481
480 curFile = thisDir->canonicalPath(); 482 curFile = thisDir->canonicalPath();
481 if(curFile.right(1).find("/",0,TRUE) == -1) 483 if(curFile.right(1).find("/",0,TRUE) == -1)
482 curFile +="/"; 484 curFile +="/";
483 curFile+= item; 485 curFile+= item;
484// odebug << "CurrentFile file is " + curFile << oendl; 486// odebug << "CurrentFile file is " + curFile << oendl;
485 487
486 if(QFileInfo(curFile).isDir()) { 488 if(QFileInfo(curFile).isDir()) {
487 moveDirectory( curFile, destFile ); 489 moveDirectory( curFile, destFile );
488 rePopulate(); 490 rePopulate();
489 return; 491 return;
490 } 492 }
491 QFile f( destFile); 493 QFile f( destFile);
492 if( f.exists()) { 494 if( f.exists()) {
493 switch ( QMessageBox::warning(this,tr("File Exists!"), 495 switch ( QMessageBox::warning(this,tr("File Exists!"),
494 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), 496 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile),
495 tr("Yes"),tr("No"),0,0,1)) { 497 tr("Yes"),tr("No"),0,0,1)) {
496 case 0: 498 case 0:
497 break; 499 break;
498 case 1: 500 case 1:
499 return; 501 return;
500 break; 502 break;
501 default: 503 default:
502 return; 504 return;
503 break; 505 break;
504 }; 506 };
505 } 507 }
506 if( !copyFile( curFile, destFile) ) { 508 if( !copyFile( curFile, destFile) ) {
507 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); 509 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile));
508 return; 510 return;
509 } else 511 } else
510 QFile::remove(curFile); 512 QFile::remove(curFile);
511 } 513 }
512 } 514 }
513 rePopulate(); 515 rePopulate();
514 //setOtherTabCurrent(); 516 //setOtherTabCurrent();
515} 517}
516 518
517bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { 519bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
518 int err = 0; 520 int err = 0;
519 if( copyDirectory( src, dest ) ) { 521 if( copyDirectory( src, dest ) ) {
520 QString cmd = "rm -rf " + src; 522 QString cmd = "rm -rf " + src;
521 err = system((const char*)cmd); 523 err = system((const char*)cmd);
522 } else 524 } else
523 err = -1; 525 err = -1;
524 526
525 if(err!=0) { 527 if(err!=0) {
526 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); 528 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src));
527 return false; 529 return false;
528 } 530 }
529 return true; 531 return true;
530} 532}
531 533
532bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { 534bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
533 535
534 QString cmd = "/bin/cp -fpR " + src + " " + dest; 536 QString cmd = "/bin/cp -fpR " + src + " " + dest;
535 owarn << cmd << oendl; 537 owarn << cmd << oendl;
536 int err = system( (const char *) cmd ); 538 int err = system( (const char *) cmd );
537 if ( err != 0 ) { 539 if ( err != 0 ) {
538 QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); 540 QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) );
539 return false; 541 return false;
540 } 542 }
541 543
542 return true; 544 return true;
543} 545}
544 546
545 547
546bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 548bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
547 if(QFileInfo(src).isDir()) { 549 if(QFileInfo(src).isDir()) {
548 if( copyDirectory( src, dest )) { 550 if( copyDirectory( src, dest )) {
549 // setOtherTabCurrent(); 551 // setOtherTabCurrent();
550 rePopulate(); 552 rePopulate();
551 return true; 553 return true;
552 } 554 }
553 else 555 else
554 return false; 556 return false;
555 } 557 }
556 558
557 559
558 bool success = true; 560 bool success = true;
559 struct stat status; 561 struct stat status;
560 QFile srcFile(src); 562 QFile srcFile(src);
561 QFile destFile(dest); 563 QFile destFile(dest);
562 int err=0; 564 int err=0;
563 int read_fd=0; 565 int read_fd=0;
564 int write_fd=0; 566 int write_fd=0;
565 struct stat stat_buf; 567 struct stat stat_buf;
566 off_t offset = 0; 568 off_t offset = 0;
567 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 569 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
568// owarn << "open failed" << oendl; 570// owarn << "open failed" << oendl;
569 return success = false; 571 return success = false;
570 } 572 }
571 read_fd = srcFile.handle(); 573 read_fd = srcFile.handle();
572 if(read_fd != -1) { 574 if(read_fd != -1) {
573 fstat (read_fd, &stat_buf); 575 fstat (read_fd, &stat_buf);
574 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 576 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
575// owarn << "destfile open failed" << oendl; 577// owarn << "destfile open failed" << oendl;
576 return success = false; 578 return success = false;
577 } 579 }
578 write_fd = destFile.handle(); 580 write_fd = destFile.handle();
579 if(write_fd != -1) { 581 if(write_fd != -1) {
580 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 582 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
581 if( err == -1) { 583 if( err == -1) {
582 QString msg; 584 QString msg;
583 switch(err) { 585 switch(err) {
584 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 586 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
585 case EINVAL: msg = "Descriptor is not valid or locked. "; 587 case EINVAL: msg = "Descriptor is not valid or locked. ";
586 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 588 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
587 case EIO: msg = "Unspecified error while reading from in_fd."; 589 case EIO: msg = "Unspecified error while reading from in_fd.";
588 }; 590 };
589 success = false; 591 success = false;
590// owarn << msg << oendl; 592// owarn << msg << oendl;
591 } 593 }
592 } else { 594 } else {
593 success = false; 595 success = false;
594 } 596 }
595 } else { 597 } else {
596 success = false; 598 success = false;
597 } 599 }
598 srcFile.close(); 600 srcFile.close();
599 destFile.close(); 601 destFile.close();
600 // Set file permissions 602 // Set file permissions
601 if( stat( QFile::encodeName(src), &status ) == 0 ) { 603 if( stat( QFile::encodeName(src), &status ) == 0 ) {
602 chmod( QFile::encodeName(dest), status.st_mode ); 604 chmod( QFile::encodeName(dest), status.st_mode );
603 } 605 }
604 606
605 return success; 607 return success;
606} 608}
607 609
608void AdvancedFm::runCommand() { 610void AdvancedFm::runCommand() {
609 if( !CurrentView()->currentItem()) return; 611 if( !CurrentView()->currentItem()) return;
610 QDir *thisDir = CurrentDir(); 612 QDir *thisDir = CurrentDir();
611 613
612 QString curFile; 614 QString curFile;
613 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 615 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
614 616
615 InputDialog *fileDlg; 617 InputDialog *fileDlg;
616 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 618 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
617 fileDlg->setInputText(curFile); 619 fileDlg->setInputText(curFile);
618 fileDlg->exec(); 620 fileDlg->exec();
619 //QString command; 621 //QString command;
620 622
621 if( fileDlg->result() == 1 ) { 623 if( fileDlg->result() == 1 ) {
622// odebug << fileDlg->LineEdit1->text() << oendl; 624// odebug << fileDlg->LineEdit1->text() << oendl;
623 QStringList command; 625 QStringList command;
624 626
625 command << "/bin/sh"; 627 command << "/bin/sh";
626 command << "-c"; 628 command << "-c";
627 command << fileDlg->LineEdit1->text(); 629 command << fileDlg->LineEdit1->text();
628 Output *outDlg; 630 Output *outDlg;
629 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 631 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
630 QPEApplication::execDialog( outDlg ); 632 QPEApplication::execDialog( outDlg );
631 qApp->processEvents(); 633 qApp->processEvents();
632 634
633 } 635 }
634} 636}
635 637
636void AdvancedFm::runCommandStd() { 638void AdvancedFm::runCommandStd() {
637 if( !CurrentView()->currentItem()) return; 639 if( !CurrentView()->currentItem()) return;
638 QString curFile; 640 QString curFile;
639 QDir *thisDir = CurrentDir(); 641 QDir *thisDir = CurrentDir();
640 QListView *thisView = CurrentView(); 642 QListView *thisView = CurrentView();
641 if( thisView->currentItem()) 643 if( thisView->currentItem())
642 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 644 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
643 645
644 InputDialog *fileDlg; 646 InputDialog *fileDlg;
645 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 647 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
646 fileDlg->setInputText(curFile); 648 fileDlg->setInputText(curFile);
647 fileDlg->exec(); 649 fileDlg->exec();
648 650
649 if( fileDlg->result() == 1 ) { 651 if( fileDlg->result() == 1 ) {
650 qApp->processEvents(); 652 qApp->processEvents();
651 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 653 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
652 } 654 }
653} 655}
654 656
655void AdvancedFm::fileStatus() { 657void AdvancedFm::fileStatus() {
656 if( !CurrentView()->currentItem()) return; 658 if( !CurrentView()->currentItem()) return;
657 QString curFile; 659
658 curFile = CurrentView()->currentItem()->text(0); 660 QString curFile;
659 if(QFileInfo("/usr/bin/stat").exists()) { 661 curFile = CurrentView()->currentItem()->text(0);
660 QStringList command; 662
661 command << "/bin/sh"; 663 QFileInfo curFileInfo(curFile);
662 command << "-c"; 664
663 command << "stat -l "+ curFile; 665 FileInfoDialog *infoDlg = new FileInfoDialog(this);
664 Output *outDlg; 666 infoDlg->setCaption(tr("Info for %1").arg(curFile));
665 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 667
666 QPEApplication::execDialog( outDlg ); 668 uint size = curFileInfo.size();
667 } else { 669 QString sizestr;
668/* struct stat buf; 670 if( size > 1048576 )
669 stat( curFile.local8bit(), &buf); 671 sizestr = tr("%1MB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1048576.0)).arg(size);
670 672 else if( size > 1024 )
671 st_dev dev; 673 sizestr = tr("%1kB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1024.0)).arg(size);
672 st_uid uid; 674 else
673 st_gid gid; 675 sizestr = tr("%1 bytes").arg(size);
674 st_size size; 676
675 st_atime atime; 677 infoDlg->sizeLabel->setText(sizestr);
676 st_mtime mtime; 678
677 st_ctime ctime; 679 if(curFileInfo.isSymLink())
678 st_mode mode; 680 infoDlg->typeLabel->setText(tr("symbolic link"));
679*/ 681 else if(curFileInfo.isFile()) {
680 } 682 if(curFileInfo.isExecutable())
681 683 infoDlg->typeLabel->setText(tr("executable file"));
682 qApp->processEvents(); 684 else
685 infoDlg->typeLabel->setText(tr("file"));
686 }
687 else if(curFileInfo.isDir())
688 infoDlg->typeLabel->setText(tr("directory"));
689 else
690 infoDlg->typeLabel->setText(tr("unknown"));
691
692 infoDlg->ownerLabel->setText( QString("%1 (%2)").arg(curFileInfo.owner()).arg(curFileInfo.ownerId()) );
693 infoDlg->groupLabel->setText( QString("%1 (%2)").arg(curFileInfo.group()).arg(curFileInfo.groupId()) );
694
695 infoDlg->lastReadLabel->setText( curFileInfo.lastRead().toString() );
696 infoDlg->lastModifiedLabel->setText( curFileInfo.lastModified().toString() );
697
698 QString perms;
699 // User
700 if(curFileInfo.permission(QFileInfo::ReadUser))
701 perms += "r";
702 else
703 perms += "-";
704 if(curFileInfo.permission(QFileInfo::WriteUser))
705 perms += "w";
706 else
707 perms += "-";
708 if(curFileInfo.permission(QFileInfo::ExeUser))
709 perms += "x";
710 else
711 perms += "-";
712 // Group
713 if(curFileInfo.permission(QFileInfo::ReadGroup))
714 perms += "r";
715 else
716 perms += "-";
717 if(curFileInfo.permission(QFileInfo::WriteGroup))
718 perms += "w";
719 else
720 perms += "-";
721 if(curFileInfo.permission(QFileInfo::ExeGroup))
722 perms += "x";
723 else
724 perms += "-";
725 // Other
726 if(curFileInfo.permission(QFileInfo::ReadOther))
727 perms += "r";
728 else
729 perms += "-";
730 if(curFileInfo.permission(QFileInfo::WriteOther))
731 perms += "w";
732 else
733 perms += "-";
734 if(curFileInfo.permission(QFileInfo::ExeOther))
735 perms += "x";
736 else
737 perms += "-";
738 infoDlg->permsLabel->setText( perms );
739
740 QPEApplication::execDialog( infoDlg );
741
742 qApp->processEvents();
683} 743}
684 744
685 745
686void AdvancedFm::mkDir() { 746void AdvancedFm::mkDir() {
687 makeDir(); 747 makeDir();
688} 748}
689 749
690void AdvancedFm::rn() { 750void AdvancedFm::rn() {
691 renameIt(); 751 renameIt();
692} 752}
693 753
694void AdvancedFm::del() { 754void AdvancedFm::del() {
695 doDelete(); 755 doDelete();
696} 756}
697 757
698void AdvancedFm::mkSym() { 758void AdvancedFm::mkSym() {
699 QString cmd; 759 QString cmd;
700 QStringList curFileList = getPath(); 760 QStringList curFileList = getPath();
701 if( curFileList.count() > 0) { 761 if( curFileList.count() > 0) {
702 QDir *thisDir = CurrentDir(); 762 QDir *thisDir = CurrentDir();
703 QDir * thatDir = OtherDir(); 763 QDir * thatDir = OtherDir();
704 764
705 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 765 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
706 766
707 QString destName = thatDir->canonicalPath()+"/"+(*it); 767 QString destName = thatDir->canonicalPath()+"/"+(*it);
708 if(destName.right(1) == "/") { 768 if(destName.right(1) == "/") {
709 destName = destName.left( destName.length() -1); 769 destName = destName.left( destName.length() -1);
710 } 770 }
711 771
712 QString curFile = thisDir->canonicalPath()+"/"+(*it); 772 QString curFile = thisDir->canonicalPath()+"/"+(*it);
713 773
714 if( curFile.right(1) == "/") { 774 if( curFile.right(1) == "/") {
715 curFile = curFile.left( curFile.length() -1); 775 curFile = curFile.left( curFile.length() -1);
716 } 776 }
717 777
718 cmd = "ln -s "+curFile+" "+destName; 778 cmd = "ln -s "+curFile+" "+destName;
719// odebug << cmd << oendl; 779// odebug << cmd << oendl;
720 startProcess( (const QString)cmd ); 780 startProcess( (const QString)cmd );
721 } 781 }
722 rePopulate(); 782 rePopulate();
723 setOtherTabCurrent(); 783 setOtherTabCurrent();
724 } 784 }
725} 785}
726 786
727void AdvancedFm::doBeam() { 787void AdvancedFm::doBeam() {
728 Ir ir; 788 Ir ir;
729 if(!ir.supported()) { 789 if(!ir.supported()) {
730 } else { 790 } else {
731 QStringList curFileList = getPath(); 791 QStringList curFileList = getPath();
732 if( curFileList.count() > 0) { 792 if( curFileList.count() > 0) {
733 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 793 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
734 QString curFile = (*it); 794 QString curFile = (*it);
735 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 795 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
736 if( curFilePath.right(1) == "/") { 796 if( curFilePath.right(1) == "/") {
737 curFilePath = curFilePath.left( curFilePath.length() -1); 797 curFilePath = curFilePath.left( curFilePath.length() -1);
738 } 798 }
739 Ir *file = new Ir(this, "IR"); 799 Ir *file = new Ir(this, "IR");
740 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); 800 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
741 file->send( curFilePath, curFile ); 801 file->send( curFilePath, curFile );
742 } 802 }
743 } 803 }
744 } 804 }
745} 805}
746 806
747void AdvancedFm::fileBeamFinished( Ir *) { 807void AdvancedFm::fileBeamFinished( Ir *) {
748 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 808 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
749} 809}
750 810
751void AdvancedFm::selectAll() { 811void AdvancedFm::selectAll() {
752 QListView *thisView = CurrentView(); 812 QListView *thisView = CurrentView();
753 thisView->selectAll(true); 813 thisView->selectAll(true);
754 thisView->setSelected( thisView->firstChild(),false); 814 thisView->setSelected( thisView->firstChild(),false);
755} 815}
756 816
757void AdvancedFm::startProcess(const QString & cmd) { 817void AdvancedFm::startProcess(const QString & cmd) {
758 QStringList command; 818 QStringList command;
759 OProcess *process; 819 OProcess *process;
760 process = new OProcess(); 820 process = new OProcess();
761 connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); 821 connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*)));
762 connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); 822 connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int)));
763 823
764 command << "/bin/sh"; 824 command << "/bin/sh";
765 command << "-c"; 825 command << "-c";
766 command << cmd.latin1(); 826 command << cmd.latin1();
767 *process << command; 827 *process << command;
768 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 828 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
769 odebug << "could not start process" << oendl; 829 odebug << "could not start process" << oendl;
770} 830}
771 831
772void AdvancedFm::processEnded(OProcess *) { 832void AdvancedFm::processEnded(OProcess *) {
773 rePopulate(); 833 rePopulate();
774} 834}
775 835
776void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 836void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
777// owarn << "received stderrt " << buflen << " bytes" << oendl; 837// owarn << "received stderrt " << buflen << " bytes" << oendl;
778 838
779 QString lineStr = buffer; 839 QString lineStr = buffer;
780 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 840 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
781} 841}
782 842
783bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 843bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
784 if ( o->inherits( "QLineEdit" ) ) { 844 if ( o->inherits( "QLineEdit" ) ) {
785 if ( e->type() == QEvent::KeyPress ) { 845 if ( e->type() == QEvent::KeyPress ) {
786 QKeyEvent *ke = (QKeyEvent*)e; 846 QKeyEvent *ke = (QKeyEvent*)e;
787 if ( ke->key() == Key_Return || 847 if ( ke->key() == Key_Return ||
788 ke->key() == Key_Enter ) { 848 ke->key() == Key_Enter ) {
789 okRename(); 849 okRename();
790 return true; 850 return true;
791 } 851 }
792 else if ( ke->key() == Key_Escape ) { 852 else if ( ke->key() == Key_Escape ) {
793 cancelRename(); 853 cancelRename();
794 return true; 854 return true;
795 } 855 }
796 } 856 }
797 else if ( e->type() == QEvent::FocusOut ) { 857 else if ( e->type() == QEvent::FocusOut ) {
798 cancelRename(); 858 cancelRename();
799 return true; 859 return true;
800 } 860 }
801 } 861 }
802 if ( o->inherits( "QListView" ) ) { 862 if ( o->inherits( "QListView" ) ) {
803 if ( e->type() == QEvent::FocusIn ) { 863 if ( e->type() == QEvent::FocusIn ) {
804 if( o == Local_View) { //keep track of which view 864 if( o == Local_View) { //keep track of which view
805 whichTab = 1; 865 whichTab = 1;
806 viewMenu->setItemChecked(viewMenu->idAt(0), true); 866 viewMenu->setItemChecked(viewMenu->idAt(0), true);
807 viewMenu->setItemChecked(viewMenu->idAt(1), false); 867 viewMenu->setItemChecked(viewMenu->idAt(1), false);
808 } else { 868 } else {
809 whichTab = 2; 869 whichTab = 2;
810 viewMenu->setItemChecked(viewMenu->idAt(0), false); 870 viewMenu->setItemChecked(viewMenu->idAt(0), false);
811 viewMenu->setItemChecked(viewMenu->idAt(1), true); 871 viewMenu->setItemChecked(viewMenu->idAt(1), true);
812 } 872 }
813 } 873 }
814 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection 874 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
815 } 875 }
816 876
817 return QWidget::eventFilter( o, e ); 877 return QWidget::eventFilter( o, e );
818} 878}
819 879
820 880
821void AdvancedFm::cancelRename() { 881void AdvancedFm::cancelRename() {
822// odebug << "cancel rename" << oendl; 882// odebug << "cancel rename" << oendl;
823 QListView * view; 883 QListView * view;
824 view = CurrentView(); 884 view = CurrentView();
825 885
826 bool resetFocus = view->viewport()->focusProxy() == renameBox; 886 bool resetFocus = view->viewport()->focusProxy() == renameBox;
827 delete renameBox; 887 delete renameBox;
828 renameBox = 0; 888 renameBox = 0;
829 if ( resetFocus ) { 889 if ( resetFocus ) {
830 view->viewport()->setFocusProxy( view); 890 view->viewport()->setFocusProxy( view);
831 view->setFocus(); 891 view->setFocus();
832 } 892 }
833} 893}
834 894
835void AdvancedFm::doRename(QListView * view) { 895void AdvancedFm::doRename(QListView * view) {
836 if( !CurrentView()->currentItem()) return; 896 if( !CurrentView()->currentItem()) return;
837 897
838 QRect r = view->itemRect( view->currentItem( )); 898 QRect r = view->itemRect( view->currentItem( ));
839 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 899 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
840 r.setX( view->contentsX() ); 900 r.setX( view->contentsX() );
841 if ( r.width() > view->visibleWidth() ) 901 if ( r.width() > view->visibleWidth() )
842 r.setWidth( view->visibleWidth() ); 902 r.setWidth( view->visibleWidth() );
843 903
844 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 904 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
845 renameBox->setFrame(true); 905 renameBox->setFrame(true);
846 renameBox->setText( view->currentItem()->text(0) ); 906 renameBox->setText( view->currentItem()->text(0) );
847 renameBox->selectAll(); 907 renameBox->selectAll();
848 renameBox->installEventFilter( this ); 908 renameBox->installEventFilter( this );
849 view->addChild( renameBox, r.x(), r.y() ); 909 view->addChild( renameBox, r.x(), r.y() );
850 renameBox->resize( r.size() ); 910 renameBox->resize( r.size() );
851 view->viewport()->setFocusProxy( renameBox ); 911 view->viewport()->setFocusProxy( renameBox );
852 renameBox->setFocus(); 912 renameBox->setFocus();
853 renameBox->show(); 913 renameBox->show();
854} 914}
855 915
856 916
857void AdvancedFm::renameIt() { 917void AdvancedFm::renameIt() {
858 if( !CurrentView()->currentItem()) return; 918 if( !CurrentView()->currentItem()) return;
859 919
860 QListView *thisView = CurrentView(); 920 QListView *thisView = CurrentView();
861 oldName = thisView->currentItem()->text(0); 921 oldName = thisView->currentItem()->text(0);
862 doRename( thisView ); 922 doRename( thisView );
863} 923}
864 924
865void AdvancedFm::okRename() { 925void AdvancedFm::okRename() {
866 qDebug("okrename"); 926 qDebug("okrename");
867 if( !renameBox) return; 927 if( !renameBox) return;
868 928
869 QString newName = renameBox->text(); 929 QString newName = renameBox->text();
870 cancelRename(); 930 cancelRename();
871 QListView * view = CurrentView(); 931 QListView * view = CurrentView();
872 QString path = CurrentDir()->canonicalPath() + "/"; 932 QString path = CurrentDir()->canonicalPath() + "/";
873 oldName = path + oldName; 933 oldName = path + oldName;
874 newName = path + newName; 934 newName = path + newName;
875 if( rename( oldName.latin1(), newName.latin1())== -1) 935 if( rename( oldName.latin1(), newName.latin1())== -1)
876 QMessageBox::message(tr("Note"),tr("Could not rename")); 936 QMessageBox::message(tr("Note"),tr("Could not rename"));
877 else 937 else
878 oldName = ""; 938 oldName = "";
879 QListViewItem *item = view->currentItem(); 939 QListViewItem *item = view->currentItem();
880 view->takeItem( item ); 940 view->takeItem( item );
881 delete item; 941 delete item;
882 populateView(); 942 populateView();
883 943
884} 944}
885 945
886void AdvancedFm::openSearch() { 946void AdvancedFm::openSearch() {
887 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 947 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
888} 948}
diff --git a/noncore/apps/advancedfm/fileInfoDialog.ui b/noncore/apps/advancedfm/fileInfoDialog.ui
new file mode 100644
index 0000000..c8997fc
--- a/dev/null
+++ b/noncore/apps/advancedfm/fileInfoDialog.ui
@@ -0,0 +1,418 @@
1<!DOCTYPE UI><UI>
2<class>FileInfoDialog</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>FileInfoDialog</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>225</width>
15 <height>303</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>FileInfoDialog</string>
21 </property>
22 <vbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QGroupBox</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>GroupBox1</cstring>
36 </property>
37 <property stdset="1">
38 <name>sizePolicy</name>
39 <sizepolicy>
40 <hsizetype>5</hsizetype>
41 <vsizetype>5</vsizetype>
42 </sizepolicy>
43 </property>
44 <property stdset="1">
45 <name>title</name>
46 <string>General</string>
47 </property>
48 <grid>
49 <property stdset="1">
50 <name>margin</name>
51 <number>11</number>
52 </property>
53 <property stdset="1">
54 <name>spacing</name>
55 <number>6</number>
56 </property>
57 <widget row="0" column="1" >
58 <class>QLabel</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>typeLabel</cstring>
62 </property>
63 <property stdset="1">
64 <name>sizePolicy</name>
65 <sizepolicy>
66 <hsizetype>1</hsizetype>
67 <vsizetype>1</vsizetype>
68 </sizepolicy>
69 </property>
70 <property stdset="1">
71 <name>text</name>
72 <string>executable file</string>
73 </property>
74 </widget>
75 <widget row="1" column="1" >
76 <class>QLabel</class>
77 <property stdset="1">
78 <name>name</name>
79 <cstring>sizeLabel</cstring>
80 </property>
81 <property stdset="1">
82 <name>sizePolicy</name>
83 <sizepolicy>
84 <hsizetype>1</hsizetype>
85 <vsizetype>1</vsizetype>
86 </sizepolicy>
87 </property>
88 <property stdset="1">
89 <name>text</name>
90 <string>3kb (3100 bytes)</string>
91 </property>
92 </widget>
93 <widget row="2" column="1" >
94 <class>QLabel</class>
95 <property stdset="1">
96 <name>name</name>
97 <cstring>ownerLabel</cstring>
98 </property>
99 <property stdset="1">
100 <name>sizePolicy</name>
101 <sizepolicy>
102 <hsizetype>1</hsizetype>
103 <vsizetype>1</vsizetype>
104 </sizepolicy>
105 </property>
106 <property stdset="1">
107 <name>maximumSize</name>
108 <size>
109 <width>32767</width>
110 <height>32767</height>
111 </size>
112 </property>
113 <property stdset="1">
114 <name>text</name>
115 <string>bill (100)</string>
116 </property>
117 <property stdset="1">
118 <name>alignment</name>
119 <set>AlignVCenter|AlignLeft</set>
120 </property>
121 <property>
122 <name>hAlign</name>
123 </property>
124 </widget>
125 <widget row="2" column="0" >
126 <class>QLabel</class>
127 <property stdset="1">
128 <name>name</name>
129 <cstring>ownerCaptionLabel</cstring>
130 </property>
131 <property stdset="1">
132 <name>sizePolicy</name>
133 <sizepolicy>
134 <hsizetype>1</hsizetype>
135 <vsizetype>1</vsizetype>
136 </sizepolicy>
137 </property>
138 <property stdset="1">
139 <name>maximumSize</name>
140 <size>
141 <width>32767</width>
142 <height>32767</height>
143 </size>
144 </property>
145 <property stdset="1">
146 <name>text</name>
147 <string>Owner:</string>
148 </property>
149 <property stdset="1">
150 <name>alignment</name>
151 <set>AlignVCenter|AlignLeft</set>
152 </property>
153 <property>
154 <name>hAlign</name>
155 </property>
156 </widget>
157 <widget row="1" column="0" >
158 <class>QLabel</class>
159 <property stdset="1">
160 <name>name</name>
161 <cstring>sizeCaptionLabel</cstring>
162 </property>
163 <property stdset="1">
164 <name>sizePolicy</name>
165 <sizepolicy>
166 <hsizetype>1</hsizetype>
167 <vsizetype>1</vsizetype>
168 </sizepolicy>
169 </property>
170 <property stdset="1">
171 <name>maximumSize</name>
172 <size>
173 <width>32767</width>
174 <height>32767</height>
175 </size>
176 </property>
177 <property stdset="1">
178 <name>text</name>
179 <string>Size:</string>
180 </property>
181 </widget>
182 <widget row="0" column="0" >
183 <class>QLabel</class>
184 <property stdset="1">
185 <name>name</name>
186 <cstring>typeCaptionLabel</cstring>
187 </property>
188 <property stdset="1">
189 <name>sizePolicy</name>
190 <sizepolicy>
191 <hsizetype>1</hsizetype>
192 <vsizetype>1</vsizetype>
193 </sizepolicy>
194 </property>
195 <property stdset="1">
196 <name>maximumSize</name>
197 <size>
198 <width>60</width>
199 <height>32767</height>
200 </size>
201 </property>
202 <property stdset="1">
203 <name>text</name>
204 <string>Type:</string>
205 </property>
206 </widget>
207 <widget row="3" column="0" >
208 <class>QLabel</class>
209 <property stdset="1">
210 <name>name</name>
211 <cstring>groupCaptionLabel</cstring>
212 </property>
213 <property stdset="1">
214 <name>sizePolicy</name>
215 <sizepolicy>
216 <hsizetype>1</hsizetype>
217 <vsizetype>1</vsizetype>
218 </sizepolicy>
219 </property>
220 <property stdset="1">
221 <name>text</name>
222 <string>Group:</string>
223 </property>
224 </widget>
225 <widget row="3" column="1" >
226 <class>QLabel</class>
227 <property stdset="1">
228 <name>name</name>
229 <cstring>groupLabel</cstring>
230 </property>
231 <property stdset="1">
232 <name>sizePolicy</name>
233 <sizepolicy>
234 <hsizetype>1</hsizetype>
235 <vsizetype>1</vsizetype>
236 </sizepolicy>
237 </property>
238 <property stdset="1">
239 <name>text</name>
240 <string>users (500)</string>
241 </property>
242 </widget>
243 <widget row="4" column="0" >
244 <class>QLabel</class>
245 <property stdset="1">
246 <name>name</name>
247 <cstring>permsCaptionLabel</cstring>
248 </property>
249 <property stdset="1">
250 <name>sizePolicy</name>
251 <sizepolicy>
252 <hsizetype>1</hsizetype>
253 <vsizetype>1</vsizetype>
254 </sizepolicy>
255 </property>
256 <property stdset="1">
257 <name>text</name>
258 <string>Permissions:</string>
259 </property>
260 </widget>
261 <widget row="4" column="1" >
262 <class>QLabel</class>
263 <property stdset="1">
264 <name>name</name>
265 <cstring>permsLabel</cstring>
266 </property>
267 <property stdset="1">
268 <name>sizePolicy</name>
269 <sizepolicy>
270 <hsizetype>1</hsizetype>
271 <vsizetype>1</vsizetype>
272 </sizepolicy>
273 </property>
274 <property stdset="1">
275 <name>text</name>
276 <string>rwxrwxrwx</string>
277 </property>
278 </widget>
279 </grid>
280 </widget>
281 <widget>
282 <class>QGroupBox</class>
283 <property stdset="1">
284 <name>name</name>
285 <cstring>GroupBox2</cstring>
286 </property>
287 <property stdset="1">
288 <name>title</name>
289 <string>Times</string>
290 </property>
291 <grid>
292 <property stdset="1">
293 <name>margin</name>
294 <number>11</number>
295 </property>
296 <property stdset="1">
297 <name>spacing</name>
298 <number>6</number>
299 </property>
300 <widget row="0" column="1" >
301 <class>QLabel</class>
302 <property stdset="1">
303 <name>name</name>
304 <cstring>lastReadLabel</cstring>
305 </property>
306 <property stdset="1">
307 <name>text</name>
308 <string>users (500)</string>
309 </property>
310 </widget>
311 <widget row="1" column="1" >
312 <class>QLabel</class>
313 <property stdset="1">
314 <name>name</name>
315 <cstring>lastModifiedLabel</cstring>
316 </property>
317 <property stdset="1">
318 <name>sizePolicy</name>
319 <sizepolicy>
320 <hsizetype>1</hsizetype>
321 <vsizetype>1</vsizetype>
322 </sizepolicy>
323 </property>
324 <property stdset="1">
325 <name>maximumSize</name>
326 <size>
327 <width>32767</width>
328 <height>32767</height>
329 </size>
330 </property>
331 <property stdset="1">
332 <name>text</name>
333 <string>users (500)</string>
334 </property>
335 <property stdset="1">
336 <name>alignment</name>
337 <set>AlignVCenter|AlignLeft</set>
338 </property>
339 <property>
340 <name>hAlign</name>
341 </property>
342 </widget>
343 <widget row="0" column="0" >
344 <class>QLabel</class>
345 <property stdset="1">
346 <name>name</name>
347 <cstring>lastReadCaptionLabel</cstring>
348 </property>
349 <property stdset="1">
350 <name>sizePolicy</name>
351 <sizepolicy>
352 <hsizetype>1</hsizetype>
353 <vsizetype>1</vsizetype>
354 </sizepolicy>
355 </property>
356 <property stdset="1">
357 <name>maximumSize</name>
358 <size>
359 <width>60</width>
360 <height>32767</height>
361 </size>
362 </property>
363 <property stdset="1">
364 <name>text</name>
365 <string>Accessed:</string>
366 </property>
367 <property stdset="1">
368 <name>alignment</name>
369 <set>AlignVCenter|AlignLeft</set>
370 </property>
371 <property>
372 <name>hAlign</name>
373 </property>
374 </widget>
375 <widget row="1" column="0" >
376 <class>QLabel</class>
377 <property stdset="1">
378 <name>name</name>
379 <cstring>lastModifiedCaptionLabel</cstring>
380 </property>
381 <property stdset="1">
382 <name>sizePolicy</name>
383 <sizepolicy>
384 <hsizetype>1</hsizetype>
385 <vsizetype>1</vsizetype>
386 </sizepolicy>
387 </property>
388 <property stdset="1">
389 <name>text</name>
390 <string>Modified:</string>
391 </property>
392 </widget>
393 </grid>
394 </widget>
395 <spacer>
396 <property>
397 <name>name</name>
398 <cstring>Spacer1</cstring>
399 </property>
400 <property stdset="1">
401 <name>orientation</name>
402 <enum>Vertical</enum>
403 </property>
404 <property stdset="1">
405 <name>sizeType</name>
406 <enum>Expanding</enum>
407 </property>
408 <property>
409 <name>sizeHint</name>
410 <size>
411 <width>20</width>
412 <height>20</height>
413 </size>
414 </property>
415 </spacer>
416 </vbox>
417</widget>
418</UI>