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