summaryrefslogtreecommitdiff
path: root/noncore
authorllornkcor <llornkcor>2003-11-07 12:37:57 (UTC)
committer llornkcor <llornkcor>2003-11-07 12:37:57 (UTC)
commitfa1e47631442d509e9c1603684bdc9e9590cf866 (patch) (unidiff)
tree5411adf72ccde8c46b13b0487a2602609b081d9e /noncore
parent82fdb639058354177d27b432f97e8750ac846ee6 (diff)
downloadopie-fa1e47631442d509e9c1603684bdc9e9590cf866.zip
opie-fa1e47631442d509e9c1603684bdc9e9590cf866.tar.gz
opie-fa1e47631442d509e9c1603684bdc9e9590cf866.tar.bz2
from 1.0, needs fix
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp201
-rw-r--r--noncore/apps/advancedfm/advancedfm.h4
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp114
3 files changed, 186 insertions, 133 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 2fc4b49..ecf471d 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -104,70 +104,73 @@ void AdvancedFm::tabChanged(QWidget *) {
104void AdvancedFm::populateView() { 104void AdvancedFm::populateView() {
105 QPixmap pm;
106 QListView *thisView = CurrentView();
107 QDir *thisDir = CurrentDir();
108 QString path = thisDir->canonicalPath();
109// qWarning("path is "+path);
110 thisView->clear();
111 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
112 thisDir->setMatchAllDirs(TRUE);
113 thisDir->setNameFilter(filterStr);
114 QString fileL, fileS, fileDate;
115 QString fs= getFileSystemType((const QString &) path);
116 setCaption(tr("AdvancedFm :: ")+fs+" :: "
117 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
118 bool isDir=FALSE;
119 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
120 QFileInfoListIterator it(*list);
121 QFileInfo *fi;
122 while ( (fi=it.current()) ) {
123 if (fi->isSymLink() ) {
124 QString symLink=fi->readLink();
125 QFileInfo sym( symLink);
126 fileS.sprintf( "%10i", sym.size() );
127 fileL = fi->fileName() +" -> " + sym.filePath().data();
128 fileDate = sym.lastModified().toString();
129 } else {
130 fileS.sprintf( "%10i", fi->size() );
131 fileL = fi->fileName();
132 fileDate= fi->lastModified().toString();
133 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
134// if(fileL == "..")
135 fileL += "/";
136 isDir=TRUE;
137 }
138 }
139 QFileInfo fileInfo( path + "/" + fileL);
140 105
141 if(fileL !="./" && fi->exists()) { 106qWarning("PopulateView");
142 item = new QListViewItem( thisView, fileL, fileS , fileDate); 107 QPixmap pm;
143 108 QListView *thisView = CurrentView();
144 if(isDir || fileL.find("/",0,TRUE) != -1) { 109 QDir *thisDir = CurrentDir();
145 110 QString path = thisDir->canonicalPath();
146 if( !QDir( fi->filePath() ).isReadable()) //is directory 111
147 pm = Resource::loadPixmap( "lockedfolder" ); 112qWarning("path is "+path);
148 else 113 thisView->clear();
149 pm= Resource::loadPixmap( "folder" ); 114 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
150 } 115 thisDir->setMatchAllDirs(TRUE);
151 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 116 thisDir->setNameFilter(filterStr);
152 pm = Resource::loadPixmap( "exec"); 117 QString fileL, fileS, fileDate;
153 } 118 QString fs= getFileSystemType((const QString &) path);
154 else if( (fileInfo.permission( QFileInfo::ExeUser) 119 setCaption(tr("AdvancedFm :: ")+fs+" :: "
155 | fileInfo.permission( QFileInfo::ExeGroup) 120 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
156 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 121 bool isDir=FALSE;
157 pm = Resource::loadPixmap( "exec"); 122 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
158 } 123 QFileInfoListIterator it(*list);
159 else if( !fi->isReadable() ) { 124 QFileInfo *fi;
160 pm = Resource::loadPixmap( "locked" ); 125 while ( (fi=it.current()) ) {
161 } 126 if (fi->isSymLink() ) {
162 else { //everything else goes by mimetype 127 QString symLink=fi->readLink();
163 MimeType mt(fi->filePath()); 128 QFileInfo sym( symLink);
164 pm=mt.pixmap(); //sets the correct pixmap for mimetype 129 fileS.sprintf( "%10i", sym.size() );
165 if(pm.isNull()) { 130 fileL = fi->fileName() +" -> " + sym.filePath().data();
166 pm = unknownXpm; 131 fileDate = sym.lastModified().toString();
167 } 132 } else {
168 } 133 fileS.sprintf( "%10i", fi->size() );
169 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { 134 fileL = fi->fileName();
170 // qDebug(" overlay link image"); 135 fileDate= fi->lastModified().toString();
171 pm= Resource::loadPixmap( "advancedfm/symlink" ); 136 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
172 // pm= Resource::loadPixmap( "folder" ); 137// if(fileL == "..")
138 fileL += "/";
139 isDir=TRUE;
140 }
141 }
142 QFileInfo fileInfo( path + "/" + fileL);
143
144 if(fileL !="./" && fi->exists()) {
145 item = new QListViewItem( thisView, fileL, fileS , fileDate);
146
147 if(isDir || fileL.find("/",0,TRUE) != -1) {
148
149 if( !QDir( fi->filePath() ).isReadable()) //is directory
150 pm = Resource::loadPixmap( "lockedfolder" );
151 else
152 pm= Resource::loadPixmap( "folder" );
153 }
154 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
155 pm = Resource::loadPixmap( "exec");
156 }
157 else if( (fileInfo.permission( QFileInfo::ExeUser)
158 | fileInfo.permission( QFileInfo::ExeGroup)
159 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
160 pm = Resource::loadPixmap( "exec");
161 }
162 else if( !fi->isReadable() ) {
163 pm = Resource::loadPixmap( "locked" );
164 }
165 else { //everything else goes by mimetype
166 MimeType mt(fi->filePath());
167 pm=mt.pixmap(); //sets the correct pixmap for mimetype
168 if(pm.isNull()) {
169 pm = unknownXpm;
170 }
171 }
172 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
173 // qDebug(" overlay link image");
174 pm= Resource::loadPixmap( "advancedfm/symlink" );
175 // pm= Resource::loadPixmap( "folder" );
173// QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 176// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
@@ -176,36 +179,36 @@ void AdvancedFm::populateView() {
176// pm.setMask( pm.createHeuristicMask( FALSE ) ); 179// pm.setMask( pm.createHeuristicMask( FALSE ) );
177 } 180 }
178 item->setPixmap( 0,pm); 181 item->setPixmap( 0,pm);
179 182
180 } 183 }
181 isDir=FALSE; 184 isDir=FALSE;
182 ++it; 185 ++it;
183 } 186 }
184 187
185 if( path.find("dev",0,TRUE) != -1) { 188 if( path.find("dev",0,TRUE) != -1) {
186 struct stat buf; 189 struct stat buf;
187 dev_t devT; 190 dev_t devT;
188 DIR *dir; 191 DIR *dir;
189 struct dirent *mydirent; 192 struct dirent *mydirent;
190 193
191 if((dir = opendir( path.latin1())) != NULL) 194 if((dir = opendir( path.latin1())) != NULL)
192 while ((mydirent = readdir(dir)) != NULL) { 195 while ((mydirent = readdir(dir)) != NULL) {
193 lstat( mydirent->d_name, &buf); 196 lstat( mydirent->d_name, &buf);
194// qDebug(mydirent->d_name); 197// qDebug(mydirent->d_name);
195 fileL.sprintf("%s", mydirent->d_name); 198 fileL.sprintf("%s", mydirent->d_name);
196 devT = buf.st_dev; 199 devT = buf.st_dev;
197 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 200 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
198 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 201 fileDate.sprintf("%s", ctime( &buf.st_mtime));
199 if( fileL.find(".") == -1 ) { 202 if( fileL.find(".") == -1 ) {
200 item= new QListViewItem( thisView, fileL, fileS, fileDate); 203 item= new QListViewItem( thisView, fileL, fileS, fileDate);
201 pm = unknownXpm; 204 pm = unknownXpm;
202 item->setPixmap( 0,pm); 205 item->setPixmap( 0,pm);
203 } 206 }
204 } 207 }
205 208
206 closedir(dir); 209 closedir(dir);
207 } 210 }
208 211
209 thisView->setSorting( 3,FALSE); 212 thisView->setSorting( 3,FALSE);
210 fillCombo( (const QString &) path ); 213 fillCombo( (const QString &) path );
211} 214}
@@ -811,3 +814,3 @@ QListView * AdvancedFm::OtherView() {
811void AdvancedFm::setOtherTabCurrent() { 814void AdvancedFm::setOtherTabCurrent() {
812// qWarning("setOtherTabCurrent()"); 815 qWarning("setOtherTabCurrent() %d", whichTab);
813 if ( whichTab == 1) { 816 if ( whichTab == 1) {
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 5f6eabb..be574c4 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -156,3 +156,5 @@ protected slots:
156 void fileBeamFinished( Ir *); 156 void fileBeamFinished( Ir *);
157 157 bool copyDirectory( const QString & , const QString & );
158// void navigateToSelected();
159 bool moveDirectory( const QString & , const QString & );
158// void slotSwitchtoLocal(int); 160// void slotSwitchtoLocal(int);
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index c0be948..90c887f 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -70,4 +70,4 @@ void AdvancedFm::showMenuHidden() {
70 } 70 }
71 rePopulate();
72 b = !b; 71 b = !b;
72 populateView();
73} 73}
@@ -82,3 +82,3 @@ void AdvancedFm::showHidden() {
82 } 82 }
83 rePopulate(); 83 populateView();
84} 84}
@@ -148,3 +148,3 @@ void AdvancedFm::makeDir() {
148 } 148 }
149 populateView(); 149 populateView();
150} 150}
@@ -193,3 +193,3 @@ void AdvancedFm::doDelete() {
193 startProcess( (const QString)cmd.latin1() ); 193 startProcess( (const QString)cmd.latin1() );
194 populateView(); 194 populateView();
195 } 195 }
@@ -230,3 +230,3 @@ void AdvancedFm::doDelete() {
230 } 230 }
231 populateView(); 231 populateView();
232} 232}
@@ -247,3 +247,3 @@ void AdvancedFm::filePerms() {
247 } 247 }
248 populateView(); 248 populateView();
249} 249}
@@ -280,3 +280,3 @@ void AdvancedFm::upDir() {
280 280
281 populateView(); 281 populateView();
282 update(); 282 update();
@@ -341,4 +341,4 @@ void AdvancedFm::copy() {
341 } 341 }
342 rePopulate(); 342 setOtherTabCurrent();
343 setOtherTabCurrent(); 343 rePopulate();
344 } 344 }
@@ -391,4 +391,4 @@ void AdvancedFm::copyAs() {
391 } 391 }
392 rePopulate(); 392 rePopulate();
393 setOtherTabCurrent(); 393 setOtherTabCurrent();
394} 394}
@@ -440,3 +440,3 @@ void AdvancedFm::copySameDir() {
440 } 440 }
441 populateView(); 441 rePopulate();
442} 442}
@@ -463,3 +463,3 @@ void AdvancedFm::move() {
463 if(curFile.right(1).find("/",0,TRUE) == -1) 463 if(curFile.right(1).find("/",0,TRUE) == -1)
464 curFile +="/"; 464 curFile +="/";
465 curFile+= item; 465 curFile+= item;
@@ -467,24 +467,72 @@ void AdvancedFm::move() {
467 467
468 QFile f( curFile); 468 if(QFileInfo(curFile).isDir()) {
469 moveDirectory( curFile, destFile );
470 rePopulate();
471 return;
472 }
473
474 QFile f( curFile);
469 if( f.exists()) { 475 if( f.exists()) {
470 if( !copyFile( curFile, destFile) ) { 476 if( !copyFile( curFile, destFile) ) {
471 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 477 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
472 return; 478 return;
473 } else 479 } else
474 QFile::remove(curFile); 480 QFile::remove(curFile);
475 } 481 }
476 } 482 }
477 483
478 } 484 }
479 rePopulate(); 485 rePopulate();
480 setOtherTabCurrent(); 486 setOtherTabCurrent();
487}
488
489bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
490 int err = 0;
491 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
492 err = system((const char*)cmd);
493 } else
494 err = -1;
495
496 if(err!=0) {
497 QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
498 return false;
499 }
500 return true;
481} 501}
482 502
503bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
504
505 QStringcmd = "/bin/cp -fpR " + src + " " + dest;
506 qWarning(cmd);
507 interr = system( (const char *) cmd );
508 if ( err != 0 ) {
509 QMessageBox::message("AdvancedFm",
510 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
511 return false;
512 }
513
514 return true;
515}
516
517
483bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 518bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
484 bool success = true; 519
485 struct stat status; 520
486 QFile srcFile(src); 521 if(QFileInfo(src).isDir()) {
487 QFile destFile(dest); 522 if( copyDirectory( src, dest )) {
488 int err=0; 523 setOtherTabCurrent();
489 int read_fd=0; 524 populateView();
525 return true;
526 }
527 else
528 return false;
529 }
530
531
532 bool success = true;
533 struct stat status;
534 QFile srcFile(src);
535 QFile destFile(dest);
536 int err=0;
537 int read_fd=0;
490 int write_fd=0; 538 int write_fd=0;
@@ -635,5 +683,5 @@ void AdvancedFm::mkSym() {
635 } 683 }
636 rePopulate(); 684 rePopulate();
637 setOtherTabCurrent(); 685 setOtherTabCurrent();
638 } 686 }
639} 687}
@@ -689,3 +737,3 @@ void AdvancedFm::startProcess(const QString & cmd) {
689void AdvancedFm::processEnded(OProcess *) { 737void AdvancedFm::processEnded(OProcess *) {
690 populateView(); 738 rePopulate();
691} 739}
@@ -777,3 +825,3 @@ void AdvancedFm::renameIt() {
777 doRename( thisView ); 825 doRename( thisView );
778 populateView(); 826 rePopulate();
779} 827}
@@ -796,3 +844,3 @@ void AdvancedFm::okRename() {
796 delete view->currentItem(); 844 delete view->currentItem();
797 populateView(); 845 rePopulate();
798} 846}