summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp8
-rw-r--r--noncore/apps/advancedfm/advancedfm.h1
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp34
3 files changed, 30 insertions, 13 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 92804b2..c653b90 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,848 +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#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#include "advancedfm.h" 13#include "advancedfm.h"
14 14
15#include <opie/otabwidget.h> 15#include <opie/otabwidget.h>
16// #include <opie/ofileselector.h> 16// #include <opie/ofileselector.h>
17// #include <opie/ofiledialog.h> 17// #include <opie/ofiledialog.h>
18 18
19#include <qpe/filemanager.h> 19#include <qpe/filemanager.h>
20#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
21#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/mimetype.h> 26#include <qpe/mimetype.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/ir.h> 28#include <qpe/ir.h>
29#include <qpe/resource.h> 29#include <qpe/resource.h>
30 30
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qdir.h> 35#include <qdir.h>
36#include <qfile.h> 36#include <qfile.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qlistview.h> 40#include <qlistview.h>
41#include <qmainwindow.h> 41#include <qmainwindow.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qprogressbar.h> 43#include <qprogressbar.h>
44#include <qspinbox.h> 44#include <qspinbox.h>
45#include <qwidget.h> 45#include <qwidget.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qimage.h> 47#include <qimage.h>
48#include <qpixmap.h> 48#include <qpixmap.h>
49#include <qmessagebox.h> 49#include <qmessagebox.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qregexp.h> 51#include <qregexp.h>
52 52
53#include <unistd.h> 53#include <unistd.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <sys/stat.h> 55#include <sys/stat.h>
56#include <dirent.h> 56#include <dirent.h>
57#include <stdio.h> 57#include <stdio.h>
58#include <time.h> 58#include <time.h>
59#include <fcntl.h> 59#include <fcntl.h>
60#include <mntent.h> 60#include <mntent.h>
61#include <string.h> 61#include <string.h>
62#include <errno.h> 62#include <errno.h>
63#include <sys/vfs.h> 63#include <sys/vfs.h>
64#include <mntent.h> 64#include <mntent.h>
65#include <sys/utsname.h> 65#include <sys/utsname.h>
66 66
67AdvancedFm::AdvancedFm( ) 67AdvancedFm::AdvancedFm( )
68 : QMainWindow( ) { 68 : QMainWindow( ) {
69 init(); 69 init();
70 initConnections(); 70 initConnections();
71 populateLocalView(); 71 populateLocalView();
72 populateRemoteView(); 72 populateRemoteView();
73 currentPathCombo->setFocus(); 73 currentPathCombo->setFocus();
74} 74}
75 75
76AdvancedFm::~AdvancedFm() { 76AdvancedFm::~AdvancedFm() {
77} 77}
78 78
79void AdvancedFm::cleanUp() { 79void AdvancedFm::cleanUp() {
80 QString sfile=QDir::homeDirPath(); 80 QString sfile=QDir::homeDirPath();
81 if(sfile.right(1) != "/") 81 if(sfile.right(1) != "/")
82 sfile+="/._temp"; 82 sfile+="/._temp";
83 else 83 else
84 sfile+="._temp"; 84 sfile+="._temp";
85 QFile file( sfile); 85 QFile file( sfile);
86 if(file.exists()) 86 if(file.exists())
87 file.remove(); 87 file.remove();
88} 88}
89 89
90void AdvancedFm::tabChanged(QWidget *w) { 90void AdvancedFm::tabChanged(QWidget *w) {
91 qDebug("tab changed %d",TabWidget->getCurrentTab()); 91 qDebug("tab changed %d",TabWidget->getCurrentTab());
92 92
93 if ( w == tab) { 93 if ( w == tab) {
94// if (TabWidget->getCurrentTab() == 0) { 94// if (TabWidget->getCurrentTab() == 0) {
95// if (TabWidget->currentPageIndex() == 0) { 95// if (TabWidget->currentPageIndex() == 0) {
96 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 96 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
97 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 97 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
98 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 98 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
99 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 99 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
100 setCaption("AdvancedFm :: "+fs+" :: " 100 setCaption("AdvancedFm :: "+fs+" :: "
101 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 101 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
102 102
103 } 103 }
104 if ( w == tab_2) { 104 if ( w == tab_2) {
105// if (TabWidget->getCurrentTab() == 1) { 105// if (TabWidget->getCurrentTab() == 1) {
106 106
107// if (TabWidget->currentPageIndex() == 1) { 107// if (TabWidget->currentPageIndex() == 1) {
108 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 108 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
109 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 109 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
110 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 110 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
111 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 111 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
112 setCaption("AdvancedFm :: "+fs+" :: " 112 setCaption("AdvancedFm :: "+fs+" :: "
113 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 113 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
114 } 114 }
115} 115}
116 116
117 117
118void AdvancedFm::populateLocalView() { 118void AdvancedFm::populateLocalView() {
119 QPixmap pm; 119 QPixmap pm;
120 Local_View->clear(); 120 Local_View->clear();
121 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 121 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
122 currentDir.setMatchAllDirs(TRUE); 122 currentDir.setMatchAllDirs(TRUE);
123 currentDir.setNameFilter(filterStr); 123 currentDir.setNameFilter(filterStr);
124 QString fileL, fileS, fileDate; 124 QString fileL, fileS, fileDate;
125 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 125 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
126 setCaption("AdvancedFm :: "+fs+" :: " 126 setCaption("AdvancedFm :: "+fs+" :: "
127 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 127 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
128 bool isDir=FALSE; 128 bool isDir=FALSE;
129 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 129 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
130 QFileInfoListIterator it(*list); 130 QFileInfoListIterator it(*list);
131 QFileInfo *fi; 131 QFileInfo *fi;
132 while ( (fi=it.current()) ) { 132 while ( (fi=it.current()) ) {
133 if (fi->isSymLink() ) { 133 if (fi->isSymLink() ) {
134 QString symLink=fi->readLink(); 134 QString symLink=fi->readLink();
135 QFileInfo sym( symLink); 135 QFileInfo sym( symLink);
136 fileS.sprintf( "%10i", sym.size() ); 136 fileS.sprintf( "%10i", sym.size() );
137 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 137 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
138 fileDate = sym.lastModified().toString(); 138 fileDate = sym.lastModified().toString();
139 } else { 139 } else {
140 fileS.sprintf( "%10i", fi->size() ); 140 fileS.sprintf( "%10i", fi->size() );
141 fileL.sprintf( "%s",fi->fileName().data() ); 141 fileL.sprintf( "%s",fi->fileName().data() );
142 fileDate= fi->lastModified().toString(); 142 fileDate= fi->lastModified().toString();
143 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 143 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
144 fileL+="/"; 144 fileL+="/";
145 isDir=TRUE; 145 isDir=TRUE;
146 } 146 }
147 } 147 }
148 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 148 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
149 if(fileL !="./" && fi->exists()) { 149 if(fileL !="./" && fi->exists()) {
150 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 150 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
151 151
152 if(isDir || fileL.find("/",0,TRUE) != -1) { 152 if(isDir || fileL.find("/",0,TRUE) != -1) {
153 153
154 if( !QDir( fi->filePath() ).isReadable()) //is directory 154 if( !QDir( fi->filePath() ).isReadable()) //is directory
155 pm = Resource::loadPixmap( "lockedfolder" ); 155 pm = Resource::loadPixmap( "lockedfolder" );
156 else 156 else
157 pm= Resource::loadPixmap( "folder" ); 157 pm= Resource::loadPixmap( "folder" );
158 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 158 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
159 pm = Resource::loadPixmap( "exec"); 159 pm = Resource::loadPixmap( "exec");
160 } else if( (fileInfo.permission( QFileInfo::ExeUser) 160 } else if( (fileInfo.permission( QFileInfo::ExeUser)
161 | fileInfo.permission( QFileInfo::ExeGroup) 161 | fileInfo.permission( QFileInfo::ExeGroup)
162 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 162 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
163 pm = Resource::loadPixmap( "exec"); 163 pm = Resource::loadPixmap( "exec");
164 } else if( !fi->isReadable() ) { 164 } else if( !fi->isReadable() ) {
165 pm = Resource::loadPixmap( "locked" ); 165 pm = Resource::loadPixmap( "locked" );
166 } else { //everything else goes by mimetype 166 } else { //everything else goes by mimetype
167 MimeType mt(fi->filePath()); 167 MimeType mt(fi->filePath());
168 pm=mt.pixmap(); //sets the correct pixmap for mimetype 168 pm=mt.pixmap(); //sets the correct pixmap for mimetype
169 if(pm.isNull()) 169 if(pm.isNull())
170 pm = Resource::loadPixmap( "UnknownDocument-14" ); 170 pm = Resource::loadPixmap( "UnknownDocument-14" );
171 } 171 }
172 item->setPixmap( 0,pm); 172 item->setPixmap( 0,pm);
173 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 173 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
174 // overlay link image 174 // overlay link image
175 pm= Resource::loadPixmap( "folder" ); 175 pm= Resource::loadPixmap( "folder" );
176 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 176 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
177 QPainter painter( &pm ); 177 QPainter painter( &pm );
178 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 178 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
179 pm.setMask( pm.createHeuristicMask( FALSE ) ); 179 pm.setMask( pm.createHeuristicMask( FALSE ) );
180 item->setPixmap( 0, pm); 180 item->setPixmap( 0, pm);
181 } 181 }
182 } 182 }
183 isDir=FALSE; 183 isDir=FALSE;
184 ++it; 184 ++it;
185 } 185 }
186 186
187 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 187 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
188 struct stat buf; 188 struct stat buf;
189 dev_t devT; 189 dev_t devT;
190 DIR *dir; 190 DIR *dir;
191 struct dirent *mydirent; 191 struct dirent *mydirent;
192 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 192 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
193 while ((mydirent = readdir(dir)) != NULL) { 193 while ((mydirent = readdir(dir)) != NULL) {
194 lstat( mydirent->d_name, &buf); 194 lstat( mydirent->d_name, &buf);
195 qDebug(mydirent->d_name); 195 qDebug(mydirent->d_name);
196 fileL.sprintf("%s", mydirent->d_name); 196 fileL.sprintf("%s", mydirent->d_name);
197 devT = buf.st_dev; 197 devT = buf.st_dev;
198 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 198 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
199 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 199 fileDate.sprintf("%s", ctime( &buf.st_mtime));
200 if( fileL.find(".") == -1 ){ 200 if( fileL.find(".") == -1 ){
201 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 201 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
202 pm = Resource::loadPixmap( "UnknownDocument-14" ); 202 pm = Resource::loadPixmap( "UnknownDocument-14" );
203 item->setPixmap( 0,pm); 203 item->setPixmap( 0,pm);
204 } 204 }
205 } 205 }
206 206
207 closedir(dir); 207 closedir(dir);
208 } 208 }
209 209
210 Local_View->setSorting( 3,FALSE); 210 Local_View->setSorting( 3,FALSE);
211 fillCombo( (const QString &) currentDir.canonicalPath()); 211 fillCombo( (const QString &) currentDir.canonicalPath());
212} 212}
213 213
214 214
215void AdvancedFm::populateRemoteView() { 215void AdvancedFm::populateRemoteView() {
216 QPixmap pm; 216 QPixmap pm;
217 Remote_View->clear(); 217 Remote_View->clear();
218 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 218 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
219 currentRemoteDir.setMatchAllDirs(TRUE); 219 currentRemoteDir.setMatchAllDirs(TRUE);
220 currentRemoteDir.setNameFilter(filterStr); 220 currentRemoteDir.setNameFilter(filterStr);
221 QString fileL, fileS, fileDate; 221 QString fileL, fileS, fileDate;
222 222
223 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 223 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
224 setCaption("AdvancedFm :: "+fs+" :: " 224 setCaption("AdvancedFm :: "+fs+" :: "
225 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 225 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
226 bool isDir=FALSE; 226 bool isDir=FALSE;
227 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 227 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
228 QFileInfoListIterator it(*list); 228 QFileInfoListIterator it(*list);
229 QFileInfo *fi; 229 QFileInfo *fi;
230 while ( (fi=it.current()) ) { 230 while ( (fi=it.current()) ) {
231 if (fi->isSymLink() ){ 231 if (fi->isSymLink() ){
232 QString symLink=fi->readLink(); 232 QString symLink=fi->readLink();
233 // qDebug("Symlink detected "+symLink); 233 // qDebug("Symlink detected "+symLink);
234 QFileInfo sym( symLink); 234 QFileInfo sym( symLink);
235 fileS.sprintf( "%10i", sym.size() ); 235 fileS.sprintf( "%10i", sym.size() );
236 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 236 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
237 fileDate = sym.lastModified().toString(); 237 fileDate = sym.lastModified().toString();
238 } else { 238 } else {
239 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 239 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
240 fileS.sprintf( "%10i", fi->size() ); 240 fileS.sprintf( "%10i", fi->size() );
241 fileL.sprintf( "%s",fi->fileName().data() ); 241 fileL.sprintf( "%s",fi->fileName().data() );
242 fileDate= fi->lastModified().toString(); 242 fileDate= fi->lastModified().toString();
243 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 243 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
244 fileL+="/"; 244 fileL+="/";
245 isDir=TRUE; 245 isDir=TRUE;
246 // qDebug( fileL); 246 // qDebug( fileL);
247 } 247 }
248 } 248 }
249 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 249 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
250 if(fileL !="./" && fi->exists()) { 250 if(fileL !="./" && fi->exists()) {
251 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 251 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
252 QPixmap pm; 252 QPixmap pm;
253 253
254 if(isDir || fileL.find("/",0,TRUE) != -1) { 254 if(isDir || fileL.find("/",0,TRUE) != -1) {
255 if( !QDir( fi->filePath() ).isReadable()) 255 if( !QDir( fi->filePath() ).isReadable())
256 pm = Resource::loadPixmap( "lockedfolder" ); 256 pm = Resource::loadPixmap( "lockedfolder" );
257 else 257 else
258 pm= Resource::loadPixmap( "folder" ); 258 pm= Resource::loadPixmap( "folder" );
259 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 259 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
260 pm = Resource::loadPixmap( "exec"); 260 pm = Resource::loadPixmap( "exec");
261 } else if( (fileInfo.permission( QFileInfo::ExeUser) 261 } else if( (fileInfo.permission( QFileInfo::ExeUser)
262 | fileInfo.permission( QFileInfo::ExeGroup) 262 | fileInfo.permission( QFileInfo::ExeGroup)
263 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 263 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
264 pm = Resource::loadPixmap( "exec"); 264 pm = Resource::loadPixmap( "exec");
265 } else if( !fi->isReadable() ) { 265 } else if( !fi->isReadable() ) {
266 pm = Resource::loadPixmap( "locked" ); 266 pm = Resource::loadPixmap( "locked" );
267 } else { 267 } else {
268 MimeType mt(fi->filePath()); 268 MimeType mt(fi->filePath());
269 pm=mt.pixmap(); //sets the correct pixmap for mimetype 269 pm=mt.pixmap(); //sets the correct pixmap for mimetype
270 if(pm.isNull()) 270 if(pm.isNull())
271 pm = Resource::loadPixmap( "UnknownDocument-14" ); 271 pm = Resource::loadPixmap( "UnknownDocument-14" );
272 } 272 }
273 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 273 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
274 // overlay link image 274 // overlay link image
275 pm= Resource::loadPixmap( "folder" ); 275 pm= Resource::loadPixmap( "folder" );
276 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 276 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
277 QPainter painter( &pm ); 277 QPainter painter( &pm );
278 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 278 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
279 pm.setMask( pm.createHeuristicMask( FALSE ) ); 279 pm.setMask( pm.createHeuristicMask( FALSE ) );
280 } 280 }
281 item->setPixmap( 0, pm); 281 item->setPixmap( 0, pm);
282 } 282 }
283 isDir=FALSE; 283 isDir=FALSE;
284 ++it; 284 ++it;
285 } 285 }
286 286
287 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 287 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
288 struct stat buf; 288 struct stat buf;
289 DIR *dir; 289 DIR *dir;
290 struct dirent *mydirent; 290 struct dirent *mydirent;
291 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 291 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
292 while ((mydirent = readdir(dir)) != NULL) { 292 while ((mydirent = readdir(dir)) != NULL) {
293 lstat( mydirent->d_name, &buf); 293 lstat( mydirent->d_name, &buf);
294 qDebug(mydirent->d_name); 294 qDebug(mydirent->d_name);
295 fileL.sprintf("%s", mydirent->d_name); 295 fileL.sprintf("%s", mydirent->d_name);
296 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 296 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
297 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 297 fileDate.sprintf("%s", ctime( &buf.st_mtime));
298 if( fileL.find(".") == -1 ){ 298 if( fileL.find(".") == -1 ){
299 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 299 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
300 pm = Resource::loadPixmap( "UnknownDocument-14" ); 300 pm = Resource::loadPixmap( "UnknownDocument-14" );
301 item->setPixmap( 0,pm); 301 item->setPixmap( 0,pm);
302 } 302 }
303 } 303 }
304 304
305 closedir(dir); 305 closedir(dir);
306 } 306 }
307 307
308 Remote_View->setSorting( 3,FALSE); 308 Remote_View->setSorting( 3,FALSE);
309 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 309 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
310} 310}
311 311
312void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 312void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
313 if(selectedItem) { 313 if(selectedItem) {
314 QString strItem=selectedItem->text(0); 314 QString strItem=selectedItem->text(0);
315 QString strSize=selectedItem->text(1); 315 QString strSize=selectedItem->text(1);
316 strSize=strSize.stripWhiteSpace(); 316 strSize=strSize.stripWhiteSpace();
317 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 317 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
318 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 318 QString strItem2 = dealWithSymName((const QString&)strItem);
319// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
319 if(QDir(strItem2).exists() ) { 320 if(QDir(strItem2).exists() ) {
320 currentDir.cd(strItem2, TRUE); 321 currentDir.cd(strItem2, TRUE);
321 populateLocalView(); 322 populateLocalView();
322 323
323 } 324 }
324 } else { // not a symlink 325 } else { // not a symlink
325 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 326 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
326 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 327 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
327 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 328 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
328 currentDir.cd(strItem,FALSE); 329 currentDir.cd(strItem,FALSE);
329 populateLocalView(); 330 populateLocalView();
330 Local_View->ensureItemVisible(Local_View->firstChild()); 331 Local_View->ensureItemVisible(Local_View->firstChild());
331 332
332 } else { 333 } else {
333 currentDir.cdUp(); 334 currentDir.cdUp();
334 populateLocalView(); 335 populateLocalView();
335 Local_View->ensureItemVisible(Local_View->firstChild()); 336 Local_View->ensureItemVisible(Local_View->firstChild());
336 } 337 }
337 if(QDir(strItem).exists()){ 338 if(QDir(strItem).exists()){
338 currentDir.cd(strItem, TRUE); 339 currentDir.cd(strItem, TRUE);
339 Local_View->ensureItemVisible(Local_View->firstChild()); 340 Local_View->ensureItemVisible(Local_View->firstChild());
340 populateLocalView(); 341 populateLocalView();
341 } 342 }
342 } else { 343 } else {
343 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 344 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
344 if( QFile::exists(strItem ) ) { 345 if( QFile::exists(strItem ) ) {
345 // qDebug("clicked item "+strItem); 346 // qDebug("clicked item "+strItem);
346 // DocLnk doc( strItem, FALSE ); 347 // DocLnk doc( strItem, FALSE );
347 // doc.execute(); 348 // doc.execute();
348 // Local_View->clearSelection(); 349 // Local_View->clearSelection();
349 } 350 }
350 } //end not symlink 351 } //end not symlink
351 chdir(strItem.latin1()); 352 chdir(strItem.latin1());
352 } 353 }
353 354
354 } 355 }
355} 356}
356 357
357void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { 358void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
358 359
359 if(selectedItem) { 360 if(selectedItem) {
360 QString strItem=selectedItem->text(0); 361 QString strItem=selectedItem->text(0);
361 QString strSize=selectedItem->text(1); 362 QString strSize=selectedItem->text(1);
362 strSize=strSize.stripWhiteSpace(); 363 strSize=strSize.stripWhiteSpace();
363 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 364 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
364 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 365 QString strItem2 = dealWithSymName((const QString&)strItem);
366// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
365 currentRemoteDir.cd(strItem2, TRUE); 367 currentRemoteDir.cd(strItem2, TRUE);
366 populateRemoteView(); 368 populateRemoteView();
367 } else { // not a symlink 369 } else { // not a symlink
368 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 370 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
369 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 371 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
370 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 372 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
371 currentRemoteDir.cd(strItem,FALSE); 373 currentRemoteDir.cd(strItem,FALSE);
372 populateRemoteView(); 374 populateRemoteView();
373 Remote_View->ensureItemVisible(Remote_View->firstChild()); 375 Remote_View->ensureItemVisible(Remote_View->firstChild());
374 } else { 376 } else {
375 currentRemoteDir.cdUp(); 377 currentRemoteDir.cdUp();
376 populateRemoteView(); 378 populateRemoteView();
377 Remote_View->ensureItemVisible(Remote_View->firstChild()); 379 Remote_View->ensureItemVisible(Remote_View->firstChild());
378 } 380 }
379 if(QDir(strItem).exists()){ 381 if(QDir(strItem).exists()){
380 currentRemoteDir.cd(strItem, TRUE); 382 currentRemoteDir.cd(strItem, TRUE);
381 populateRemoteView(); 383 populateRemoteView();
382 Remote_View->ensureItemVisible(Remote_View->firstChild()); 384 Remote_View->ensureItemVisible(Remote_View->firstChild());
383 } 385 }
384 } else { 386 } else {
385 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 387 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
386 if( QFile::exists(strItem ) ) { 388 if( QFile::exists(strItem ) ) {
387 // qDebug("clicked item "+strItem); 389 // qDebug("clicked item "+strItem);
388 // DocLnk doc( strItem, FALSE ); 390 // DocLnk doc( strItem, FALSE );
389 // doc.execute(); 391 // doc.execute();
390 // Remote_View->clearSelection(); 392 // Remote_View->clearSelection();
391 } 393 }
392 } //end not symlink 394 } //end not symlink
393 chdir(strItem.latin1()); 395 chdir(strItem.latin1());
394 } 396 }
395 } 397 }
396} 398}
397 399
398 400
399void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 401void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
400// qDebug("list pressed"); 402// qDebug("list pressed");
401 switch (mouse) { 403 switch (mouse) {
402 case 1: 404 case 1:
403 break; 405 break;
404 case 2: 406 case 2:
405 menuTimer.start( 500, TRUE ); 407 menuTimer.start( 500, TRUE );
406 qDebug("Start menu timer\n"); 408 qDebug("Start menu timer\n");
407 break; 409 break;
408 }; 410 };
409} 411}
410 412
411void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 413void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) {
412 414
413 switch (mouse) { 415 switch (mouse) {
414 case 1: 416 case 1:
415 break; 417 break;
416 case 2: 418 case 2:
417 menuTimer.start( 500, TRUE ); 419 menuTimer.start( 500, TRUE );
418 qDebug("Start menu timer"); 420 qDebug("Start menu timer");
419 break; 421 break;
420 }; 422 };
421} 423}
422 424
423 425
424void AdvancedFm::switchToLocalTab() { 426void AdvancedFm::switchToLocalTab() {
425 TabWidget->setCurrentTab(0); 427 TabWidget->setCurrentTab(0);
426 Local_View->setFocus(); 428 Local_View->setFocus();
427} 429}
428 430
429void AdvancedFm::switchToRemoteTab() { 431void AdvancedFm::switchToRemoteTab() {
430 TabWidget->setCurrentTab(1); 432 TabWidget->setCurrentTab(1);
431 Remote_View->setFocus(); 433 Remote_View->setFocus();
432} 434}
433 435
434void AdvancedFm::readConfig() { 436void AdvancedFm::readConfig() {
435 Config cfg("AdvancedFm"); 437 Config cfg("AdvancedFm");
436} 438}
437 439
438void AdvancedFm::writeConfig() { 440void AdvancedFm::writeConfig() {
439 Config cfg("AdvancedFm"); 441 Config cfg("AdvancedFm");
440} 442}
441 443
442void AdvancedFm::currentPathComboChanged() { 444void AdvancedFm::currentPathComboChanged() {
443 if (TabWidget->getCurrentTab() == 0) { 445 if (TabWidget->getCurrentTab() == 0) {
444// if (TabWidget->currentPageIndex() == 0) { 446// if (TabWidget->currentPageIndex() == 0) {
445 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 447 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
446 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 448 currentDir.setPath( currentPathCombo->lineEdit()->text() );
447 populateLocalView(); 449 populateLocalView();
448 } else { 450 } else {
449 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 451 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
450 } 452 }
451 } 453 }
452 if (TabWidget->getCurrentTab() == 0) { 454 if (TabWidget->getCurrentTab() == 0) {
453// if (TabWidget->currentPageIndex() == 0) { 455// if (TabWidget->currentPageIndex() == 0) {
454 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 456 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
455 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 457 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
456 populateRemoteView(); 458 populateRemoteView();
457 } else { 459 } else {
458 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 460 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
459 } 461 }
460 } 462 }
461} 463}
462 464
463void AdvancedFm::fillCombo(const QString &currentPath) { 465void AdvancedFm::fillCombo(const QString &currentPath) {
464 466 qDebug("%d",TabWidget->getCurrentTab());
465 if (TabWidget->getCurrentTab() == 0) { 467 if (TabWidget->getCurrentTab() == 0) {
466// if (TabWidget->currentPageIndex() == 0) { 468// if (TabWidget->currentPageIndex() == 0) {
467 currentPathCombo->lineEdit()->setText( currentPath); 469 currentPathCombo->lineEdit()->setText( currentPath);
468 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 470 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
469 currentPathCombo->clear(); 471 currentPathCombo->clear();
470 localDirPathStringList.prepend( currentPath ); 472 localDirPathStringList.prepend( currentPath );
471 currentPathCombo->insertStringList( localDirPathStringList,-1); 473 currentPathCombo->insertStringList( localDirPathStringList,-1);
472 } 474 }
473 } else { 475 } else {
474 currentPathCombo->lineEdit()->setText( currentPath); 476 currentPathCombo->lineEdit()->setText( currentPath);
475 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 477 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
476 currentPathCombo->clear(); 478 currentPathCombo->clear();
477 remoteDirPathStringList.prepend( currentPath ); 479 remoteDirPathStringList.prepend( currentPath );
478 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 480 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
479 } 481 }
480 } 482 }
481} 483}
482 484
483void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 485void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
484 if (TabWidget->getCurrentTab() == 0) { 486 if (TabWidget->getCurrentTab() == 0) {
485// if (TabWidget->currentPageIndex() == 0) { 487// if (TabWidget->currentPageIndex() == 0) {
486 chdir( currentPath.latin1() ); 488 chdir( currentPath.latin1() );
487 currentDir.cd( currentPath, TRUE); 489 currentDir.cd( currentPath, TRUE);
488 populateLocalView(); 490 populateLocalView();
489 update(); 491 update();
490 } else { 492 } else {
491 chdir( currentPath.latin1() ); 493 chdir( currentPath.latin1() );
492 currentRemoteDir.cd( currentPath, TRUE); 494 currentRemoteDir.cd( currentPath, TRUE);
493 populateRemoteView(); 495 populateRemoteView();
494 update(); 496 update();
495 } 497 }
496} 498}
497 499
498QStringList AdvancedFm::getPath() { 500QStringList AdvancedFm::getPath() {
499 QStringList strList; 501 QStringList strList;
500 if (TabWidget->getCurrentTab() == 0) { 502 if (TabWidget->getCurrentTab() == 0) {
501// if (TabWidget->currentPageIndex() == 0) { 503// if (TabWidget->currentPageIndex() == 0) {
502 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 504 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
503 QListViewItemIterator it( Local_View ); 505 QListViewItemIterator it( Local_View );
504 for ( ; it.current(); ++it ) { 506 for ( ; it.current(); ++it ) {
505 if ( it.current()->isSelected() ) { 507 if ( it.current()->isSelected() ) {
506 strList << it.current()->text(0); 508 strList << it.current()->text(0);
507 qDebug(it.current()->text(0)); 509 qDebug(it.current()->text(0));
508 } 510 }
509 } 511 }
510 return strList; 512 return strList;
511 } else { 513 } else {
512 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 514 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
513 QListViewItemIterator it( Remote_View ); 515 QListViewItemIterator it( Remote_View );
514 for ( ; it.current(); ++it ) { 516 for ( ; it.current(); ++it ) {
515 if ( it.current()->isSelected() ) { 517 if ( it.current()->isSelected() ) {
516 strList << it.current()->text(0); 518 strList << it.current()->text(0);
517 qDebug(it.current()->text(0)); 519 qDebug(it.current()->text(0));
518 } 520 }
519 } 521 }
520 return strList; 522 return strList;
521 } 523 }
522 return ""; 524 return "";
523} 525}
524 526
525void AdvancedFm::homeButtonPushed() { 527void AdvancedFm::homeButtonPushed() {
526 QString current = QDir::homeDirPath(); 528 QString current = QDir::homeDirPath();
527 chdir( current.latin1() ); 529 chdir( current.latin1() );
528 if (TabWidget->getCurrentTab() == 0) { 530 if (TabWidget->getCurrentTab() == 0) {
529// if (TabWidget->currentPageIndex() == 0) { 531// if (TabWidget->currentPageIndex() == 0) {
530 currentDir.cd( current, TRUE); 532 currentDir.cd( current, TRUE);
531 populateLocalView(); 533 populateLocalView();
532 } else { 534 } else {
533 currentRemoteDir.cd( current, TRUE); 535 currentRemoteDir.cd( current, TRUE);
534 populateRemoteView(); 536 populateRemoteView();
535 } 537 }
536 update(); 538 update();
537} 539}
538 540
539void AdvancedFm::docButtonPushed() { 541void AdvancedFm::docButtonPushed() {
540 QString current = QPEApplication::documentDir(); 542 QString current = QPEApplication::documentDir();
541 chdir( current.latin1() ); 543 chdir( current.latin1() );
542 544
543 if (TabWidget->getCurrentTab() == 0) { 545 if (TabWidget->getCurrentTab() == 0) {
544//if (TabWidget->currentPageIndex() == 0) { 546//if (TabWidget->currentPageIndex() == 0) {
545 currentDir.cd( current, TRUE); 547 currentDir.cd( current, TRUE);
546 populateLocalView(); 548 populateLocalView();
547 } else { 549 } else {
548 currentRemoteDir.cd( current, TRUE); 550 currentRemoteDir.cd( current, TRUE);
549 populateRemoteView(); 551 populateRemoteView();
550 } 552 }
551 update(); 553 update();
552} 554}
553 555
554void AdvancedFm::SDButtonPushed() { 556void AdvancedFm::SDButtonPushed() {
555 QString current = "/mnt/card";// this can change so fix 557 QString current = "/mnt/card";// this can change so fix
556 chdir( current.latin1() ); 558 chdir( current.latin1() );
557 if (TabWidget->getCurrentTab() == 0) { 559 if (TabWidget->getCurrentTab() == 0) {
558// if (TabWidget->currentPageIndex() == 0) { 560// if (TabWidget->currentPageIndex() == 0) {
559 currentDir.cd( current, TRUE); 561 currentDir.cd( current, TRUE);
560 populateLocalView(); 562 populateLocalView();
561 } else { 563 } else {
562 currentRemoteDir.cd( current, TRUE); 564 currentRemoteDir.cd( current, TRUE);
563 populateRemoteView(); 565 populateRemoteView();
564 } 566 }
565 update(); 567 update();
566 568
567} 569}
568 570
569void AdvancedFm::CFButtonPushed() { 571void AdvancedFm::CFButtonPushed() {
570 QString current; 572 QString current;
571 if(zaurusDevice) 573 if(zaurusDevice)
572 current= "/mnt/cf"; //zaurus 574 current= "/mnt/cf"; //zaurus
573 else 575 else
574 current = "/mnt/hda"; //ipaq 576 current = "/mnt/hda"; //ipaq
575 577
576 chdir( current.latin1() ); 578 chdir( current.latin1() );
577 if (TabWidget->getCurrentTab() == 0) { 579 if (TabWidget->getCurrentTab() == 0) {
578// if (TabWidget->currentPageIndex() == 0) { 580// if (TabWidget->currentPageIndex() == 0) {
579 currentDir.cd( current, TRUE); 581 currentDir.cd( current, TRUE);
580 populateLocalView(); 582 populateLocalView();
581 } else { 583 } else {
582 currentRemoteDir.cd( current, TRUE); 584 currentRemoteDir.cd( current, TRUE);
583 populateRemoteView(); 585 populateRemoteView();
584 } 586 }
585 update(); 587 update();
586} 588}
587 589
588 590
589 591
590void AdvancedFm::doAbout() { 592void AdvancedFm::doAbout() {
591 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 593 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
592 "is copyright 2002 by\n" 594 "is copyright 2002 by\n"
593 "L.J.Potter<llornkcor@handhelds.org>\n" 595 "L.J.Potter<llornkcor@handhelds.org>\n"
594 "and is licensed by the GPL")); 596 "and is licensed by the GPL"));
595} 597}
596 598
597void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 599void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
598 if( TabWidget->hasFocus()) 600 if( TabWidget->hasFocus())
599 switch ( e->key() ) { 601 switch ( e->key() ) {
600 case Key_Delete: 602 case Key_Delete:
601 del(); 603 del();
602 break; 604 break;
603 case Key_H: 605 case Key_H:
604 showHidden(); 606 showHidden();
605 break; 607 break;
606 case Key_E: 608 case Key_E:
607 runThis(); 609 runThis();
608 break; 610 break;
609 case Key_C: 611 case Key_C:
610 copy(); 612 copy();
611 break; 613 break;
612 case Key_A: 614 case Key_A:
613 copyAs(); 615 copyAs();
614 break; 616 break;
615 case Key_M: 617 case Key_M:
616 move(); 618 move();
617 break; 619 break;
618 case Key_R: 620 case Key_R:
619 rn(); 621 rn();
620 break; 622 break;
621 case Key_I: 623 case Key_I:
622 fileStatus(); 624 fileStatus();
623 break; 625 break;
624 case Key_U: 626 case Key_U:
625 upDir(); 627 upDir();
626 break; 628 break;
627 case Key_P: 629 case Key_P:
628 filePerms(); 630 filePerms();
629 break; 631 break;
630 case Key_N: 632 case Key_N:
631 mkDir(); 633 mkDir();
632 break; 634 break;
633 case Key_1: 635 case Key_1:
634 switchToLocalTab(); 636 switchToLocalTab();
635 break; 637 break;
636 case Key_2: 638 case Key_2:
637 switchToRemoteTab(); 639 switchToRemoteTab();
638 break; 640 break;
639 case Key_3: 641 case Key_3:
640 CFButtonPushed(); 642 CFButtonPushed();
641 break; 643 break;
642 case Key_4: 644 case Key_4:
643 SDButtonPushed(); 645 SDButtonPushed();
644 break; 646 break;
645 case Key_5: 647 case Key_5:
646 homeButtonPushed(); 648 homeButtonPushed();
647 break; 649 break;
648 case Key_6: 650 case Key_6:
649 docButtonPushed(); 651 docButtonPushed();
650 break; 652 break;
651 case Key_7: 653 case Key_7:
652 break; 654 break;
653 case Key_8: 655 case Key_8:
654 break; 656 break;
655 case Key_9: 657 case Key_9:
656 break; 658 break;
657 case Key_0: 659 case Key_0:
658 break; 660 break;
659 } 661 }
660} 662}
661 663
662 664
663void AdvancedFm::QPEButtonPushed() { 665void AdvancedFm::QPEButtonPushed() {
664 QString current = QPEApplication::qpeDir(); 666 QString current = QPEApplication::qpeDir();
665 chdir( current.latin1() ); 667 chdir( current.latin1() );
666 if (TabWidget->getCurrentTab() == 0) { 668 if (TabWidget->getCurrentTab() == 0) {
667// if (TabWidget->currentPageIndex() == 0) { 669// if (TabWidget->currentPageIndex() == 0) {
668 currentDir.cd( current, TRUE); 670 currentDir.cd( current, TRUE);
669 populateLocalView(); 671 populateLocalView();
670 } else { 672 } else {
671 currentRemoteDir.cd( current, TRUE); 673 currentRemoteDir.cd( current, TRUE);
672 populateRemoteView(); 674 populateRemoteView();
673 } 675 }
674 update(); 676 update();
675} 677}
676 678
677void AdvancedFm::parsetab(const QString &fileName) { 679void AdvancedFm::parsetab(const QString &fileName) {
678 680
679 fileSystemTypeList.clear(); 681 fileSystemTypeList.clear();
680 fsList.clear(); 682 fsList.clear();
681 struct mntent *me; 683 struct mntent *me;
682 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 684 FILE *mntfp = setmntent( fileName.latin1(), "r" );
683 if ( mntfp ) { 685 if ( mntfp ) {
684 while ( (me = getmntent( mntfp )) != 0 ) { 686 while ( (me = getmntent( mntfp )) != 0 ) {
685 QString deviceName = me->mnt_fsname; 687 QString deviceName = me->mnt_fsname;
686 QString filesystemType = me->mnt_type; 688 QString filesystemType = me->mnt_type;
687 QString mountDir = me->mnt_dir; 689 QString mountDir = me->mnt_dir;
688 if(deviceName != "none") { 690 if(deviceName != "none") {
689 if( fsList.contains(filesystemType) == 0 691 if( fsList.contains(filesystemType) == 0
690 & filesystemType.find("proc",0,TRUE) == -1 692 & filesystemType.find("proc",0,TRUE) == -1
691 & filesystemType.find("cramfs",0,TRUE) == -1 693 & filesystemType.find("cramfs",0,TRUE) == -1
692 & filesystemType.find("auto",0,TRUE) == -1) 694 & filesystemType.find("auto",0,TRUE) == -1)
693 fsList << filesystemType; 695 fsList << filesystemType;
694 fileSystemTypeList << mountDir+"::"+filesystemType; 696 fileSystemTypeList << mountDir+"::"+filesystemType;
695 } 697 }
696 } 698 }
697 } 699 }
698 endmntent( mntfp ); 700 endmntent( mntfp );
699} 701}
700 702
701QString AdvancedFm::getFileSystemType(const QString &currentText) { 703QString AdvancedFm::getFileSystemType(const QString &currentText) {
702 parsetab("/etc/mtab"); //why did TT forget filesystem type? 704 parsetab("/etc/mtab"); //why did TT forget filesystem type?
703 QString current = currentText;//.right( currentText.length()-1); 705 QString current = currentText;//.right( currentText.length()-1);
704 QString baseFs; 706 QString baseFs;
705 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 707 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
706 QString temp = (*it); 708 QString temp = (*it);
707 QString path = temp.left(temp.find("::",0,TRUE) ); 709 QString path = temp.left(temp.find("::",0,TRUE) );
708 path = path.right( path.length()-1); 710 path = path.right( path.length()-1);
709 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 711 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
710 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 712 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
711 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 713 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
712 } 714 }
713 } 715 }
714 return baseFs; 716 return baseFs;
715} 717}
716 718
717QString AdvancedFm::getDiskSpace( const QString &path) { 719QString AdvancedFm::getDiskSpace( const QString &path) {
718 struct statfs fss; 720 struct statfs fss;
719 if ( !statfs( path.latin1(), &fss ) ) { 721 if ( !statfs( path.latin1(), &fss ) ) {
720 int blkSize = fss.f_bsize; 722 int blkSize = fss.f_bsize;
721 // int totalBlks = fs.f_blocks; 723 // int totalBlks = fs.f_blocks;
722 int availBlks = fss.f_bavail; 724 int availBlks = fss.f_bavail;
723 725
724 long mult = blkSize / 1024; 726 long mult = blkSize / 1024;
725 long div = 1024 / blkSize; 727 long div = 1024 / blkSize;
726 if ( !mult ) mult = 1; 728 if ( !mult ) mult = 1;
727 if ( !div ) div = 1; 729 if ( !div ) div = 1;
728 730
729 return QString::number(availBlks * mult / div); 731 return QString::number(availBlks * mult / div);
730 } 732 }
731 return ""; 733 return "";
732} 734}
733 735
734 736
735void AdvancedFm::showFileMenu() { 737void AdvancedFm::showFileMenu() {
736 738
737 QString curApp; 739 QString curApp;
738 bool isLocalView = false; 740 bool isLocalView = false;
739 if (TabWidget->getCurrentTab() == 0) { 741 if (TabWidget->getCurrentTab() == 0) {
740// if (TabWidget->currentPageIndex() == 0) { 742// if (TabWidget->currentPageIndex() == 0) {
741 isLocalView = TRUE; 743 isLocalView = TRUE;
742 curApp = Local_View->currentItem()->text(0); 744 curApp = Local_View->currentItem()->text(0);
743 } else { 745 } else {
744 curApp = Remote_View->currentItem()->text(0); 746 curApp = Remote_View->currentItem()->text(0);
745 } 747 }
746 748
747 MimeType mt( curApp ); 749 MimeType mt( curApp );
748 const AppLnk* app = mt.application(); 750 const AppLnk* app = mt.application();
749 QFile fi(curApp); 751 QFile fi(curApp);
750 QPopupMenu *m = new QPopupMenu(0); 752 QPopupMenu *m = new QPopupMenu(0);
751 QPopupMenu *n = new QPopupMenu(0); 753 QPopupMenu *n = new QPopupMenu(0);
752 // QPopupMenu *o = new QPopupMenu(0); 754 // QPopupMenu *o = new QPopupMenu(0);
753 if (TabWidget->getCurrentTab() == 0) 755 if (TabWidget->getCurrentTab() == 0)
754 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 756 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
755 else 757 else
756 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); 758 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() ));
757 759
758 if ( QFileInfo(fi).isDir() ) { 760 if ( QFileInfo(fi).isDir() ) {
759 m->insertSeparator(); 761 m->insertSeparator();
760 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 762 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
761 } else { 763 } else {
762 764
763 if ( app ) 765 if ( app )
764 m->insertItem( app->pixmap(), tr( "Open in " 766 m->insertItem( app->pixmap(), tr( "Open in "
765 + app->name() ), this, SLOT( runThis() ) ); 767 + app->name() ), this, SLOT( runThis() ) );
766 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 768 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
767 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 769 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
768 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 770 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
769 } 771 }
770 772
771 m->insertItem(tr("Actions"),n); 773 m->insertItem(tr("Actions"),n);
772 if(isLocalView) 774 if(isLocalView)
773 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 775 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
774 else 776 else
775 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 777 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
776 778
777 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 779 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
778 780
779 n->insertSeparator(); 781 n->insertSeparator();
780 782
781 783
782 if(isLocalView) 784 if(isLocalView)
783 n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 785 n->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
784 else 786 else
785 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 787 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
786 788
787 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 789 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
788 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 790 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
789 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 791 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
790 n->insertItem( tr( "Move" ), this, SLOT( move() )); 792 n->insertItem( tr( "Move" ), this, SLOT( move() ));
791 793
792 n->insertSeparator(); 794 n->insertSeparator();
793 795
794 if(isLocalView) 796 if(isLocalView)
795 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 797 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
796 else 798 else
797 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 799 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
798 800
799 801
800 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 802 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
801 803
802 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 804 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
803 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 805 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
804 806
805 m->insertSeparator(); 807 m->insertSeparator();
806 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 808 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
807 809
808#if defined(QT_QWS_OPIE) 810#if defined(QT_QWS_OPIE)
809 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 811 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
810#endif 812#endif
811 m->setCheckable(TRUE); 813 m->setCheckable(TRUE);
812 if (!b) 814 if (!b)
813 m->setItemChecked(m->idAt(0),TRUE); 815 m->setItemChecked(m->idAt(0),TRUE);
814 else 816 else
815 m->setItemChecked(m->idAt(0),FALSE); 817 m->setItemChecked(m->idAt(0),FALSE);
816 818
817 if(Ir::supported()) 819 if(Ir::supported())
818 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 820 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
819 m->setFocus(); 821 m->setFocus();
820 m->exec( QPoint( 4,QCursor::pos().y()) ); 822 m->exec( QPoint( 4,QCursor::pos().y()) );
821 823
822 if(m) delete m; 824 if(m) delete m;
823} 825}
824 826
825 827
826void AdvancedFm::cancelMenuTimer() { 828void AdvancedFm::cancelMenuTimer() {
827 829
828// qDebug("selectionChanged: cancel menu timer"); 830// qDebug("selectionChanged: cancel menu timer");
829 if( menuTimer.isActive() ) 831 if( menuTimer.isActive() )
830 menuTimer.stop(); 832 menuTimer.stop();
831} 833}
832 834
833QString AdvancedFm::checkDiskSpace(const QString &path) { 835QString AdvancedFm::checkDiskSpace(const QString &path) {
834 struct statfs fss; 836 struct statfs fss;
835 if ( !statfs( path.latin1(), &fss ) ) { 837 if ( !statfs( path.latin1(), &fss ) ) {
836 int blkSize = fss.f_bsize; 838 int blkSize = fss.f_bsize;
837// int totalBlks = fs.f_blocks; 839// int totalBlks = fs.f_blocks;
838 int availBlks = fss.f_bavail; 840 int availBlks = fss.f_bavail;
839 841
840 long mult = blkSize / 1024; 842 long mult = blkSize / 1024;
841 long div = 1024 / blkSize; 843 long div = 1024 / blkSize;
842 if ( !mult ) mult = 1; 844 if ( !mult ) mult = 1;
843 if ( !div ) div = 1; 845 if ( !div ) div = 1;
844 846
845 847
846 return QString::number(availBlks * mult / div); 848 return QString::number(availBlks * mult / div);
847 } 849 }
848 return ""; 850 return "";
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 9948255..7ced056 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -1,157 +1,158 @@
1/*************************************************************************** 1/***************************************************************************
2 advancedfm.h 2 advancedfm.h
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#ifndef ADVANCEDFM_H 12#ifndef ADVANCEDFM_H
13#define ADVANCEDFM_H 13#define ADVANCEDFM_H
14#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties 14#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties
15#define QT_QWS_OPIE 15#define QT_QWS_OPIE
16 16
17//#include <opie/otabwidget.h> 17//#include <opie/otabwidget.h>
18#include <qpe/ir.h> 18#include <qpe/ir.h>
19 19
20#include <qvariant.h> 20#include <qvariant.h>
21#include <qdialog.h> 21#include <qdialog.h>
22#include <qmainwindow.h> 22#include <qmainwindow.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qdir.h> 24#include <qdir.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qpoint.h> 26#include <qpoint.h>
27#include <qtimer.h> 27#include <qtimer.h>
28 28
29class OTabWidget; 29class OTabWidget;
30class QVBoxLayout; 30class QVBoxLayout;
31class QHBoxLayout; 31class QHBoxLayout;
32class QGridLayout; 32class QGridLayout;
33class QComboBox; 33class QComboBox;
34class QListView; 34class QListView;
35class QListviewItem; 35class QListviewItem;
36class QLabel; 36class QLabel;
37class QProgressBar; 37class QProgressBar;
38class QSpinBox; 38class QSpinBox;
39class QTabWidget; 39class QTabWidget;
40class QWidget; 40class QWidget;
41class QPEToolBar; 41class QPEToolBar;
42class QPEMenuBar; 42class QPEMenuBar;
43class QPopupMenu; 43class QPopupMenu;
44class QFile; 44class QFile;
45class QListViewItem; 45class QListViewItem;
46class QLineEdit; 46class QLineEdit;
47//class QPushButton; 47//class QPushButton;
48class QToolButton; 48class QToolButton;
49class Ir; 49class Ir;
50 50
51class AdvancedFm : public QMainWindow 51class AdvancedFm : public QMainWindow
52{ 52{
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
55 AdvancedFm(); 55 AdvancedFm();
56 ~AdvancedFm(); 56 ~AdvancedFm();
57 57
58 OTabWidget *TabWidget; 58 OTabWidget *TabWidget;
59// QTabWidget *TabWidget; 59// QTabWidget *TabWidget;
60 QWidget *tab, *tab_2, *tab_3; 60 QWidget *tab, *tab_2, *tab_3;
61 QListView *Local_View, *Remote_View; 61 QListView *Local_View, *Remote_View;
62 62
63 QLineEdit *currentPathEdit; 63 QLineEdit *currentPathEdit;
64 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; 64 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu;
65 QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 65 QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
66// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 66// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
67 QDir currentDir, currentRemoteDir; 67 QDir currentDir, currentRemoteDir;
68 QComboBox *currentPathCombo; 68 QComboBox *currentPathCombo;
69 QString filterStr; 69 QString filterStr;
70 QListViewItem * item; 70 QListViewItem * item;
71 bool b; 71 bool b;
72 QStringList fileSystemTypeList, fsList; 72 QStringList fileSystemTypeList, fsList;
73 int currentServerConfig; 73 int currentServerConfig;
74protected slots: 74protected slots:
75 void selectAll(); 75 void selectAll();
76 void addToDocs(); 76 void addToDocs();
77 void doLocalCd(); 77 void doLocalCd();
78 void doRemoteCd(); 78 void doRemoteCd();
79// void copy(); 79// void copy();
80 void mkDir(); 80 void mkDir();
81 void del(); 81 void del();
82 void rn(); 82 void rn();
83 void populateLocalView(); 83 void populateLocalView();
84 void populateRemoteView(); 84 void populateRemoteView();
85 void showHidden(); 85 void showHidden();
86 void showMenuHidden(); 86 void showMenuHidden();
87 void showRemoteHidden(); 87 void showRemoteHidden();
88 void writeConfig(); 88 void writeConfig();
89 void readConfig(); 89 void readConfig();
90 void localListClicked(QListViewItem *); 90 void localListClicked(QListViewItem *);
91 void remoteListClicked(QListViewItem *); 91 void remoteListClicked(QListViewItem *);
92 void localListPressed( int, QListViewItem *, const QPoint&, int); 92 void localListPressed( int, QListViewItem *, const QPoint&, int);
93 void remoteListPressed( int, QListViewItem *, const QPoint&, int); 93 void remoteListPressed( int, QListViewItem *, const QPoint&, int);
94 void localMakDir(); 94 void localMakDir();
95 void localDelete(); 95 void localDelete();
96 void remoteMakDir(); 96 void remoteMakDir();
97 void remoteDelete(); 97 void remoteDelete();
98/* bool remoteDirList(const QString &); */ 98/* bool remoteDirList(const QString &); */
99/* bool remoteChDir(const QString &); */ 99/* bool remoteChDir(const QString &); */
100 void tabChanged(QWidget*); 100 void tabChanged(QWidget*);
101 void cleanUp(); 101 void cleanUp();
102 void remoteRename(); 102 void remoteRename();
103 void localRename(); 103 void localRename();
104 void runThis(); 104 void runThis();
105 void runText(); 105 void runText();
106 void filePerms(); 106 void filePerms();
107 void doProperties(); 107 void doProperties();
108 void runCommand(); 108 void runCommand();
109 void runCommandStd(); 109 void runCommandStd();
110 QStringList getPath(); 110 QStringList getPath();
111 void mkSym(); 111 void mkSym();
112 void switchToLocalTab(); 112 void switchToLocalTab();
113 void switchToRemoteTab(); 113 void switchToRemoteTab();
114 114
115protected: 115protected:
116 bool zaurusDevice; 116 bool zaurusDevice;
117 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 117 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
118 QStringList remoteDirPathStringList, localDirPathStringList; 118 QStringList remoteDirPathStringList, localDirPathStringList;
119 119
120 void init(); 120 void init();
121 void initConnections(); 121 void initConnections();
122 void keyReleaseEvent( QKeyEvent *); 122 void keyReleaseEvent( QKeyEvent *);
123 QString getFileSystemType(const QString &); 123 QString getFileSystemType(const QString &);
124 QString getDiskSpace(const QString &); 124 QString getDiskSpace(const QString &);
125 void parsetab(const QString &fileName); 125 void parsetab(const QString &fileName);
126 QString checkDiskSpace(const QString &); 126 QString checkDiskSpace(const QString &);
127 QString dealWithSymName(const QString &);
127 128
128protected slots: 129protected slots:
129 void showFileMenu(); 130 void showFileMenu();
130 void cancelMenuTimer(); 131 void cancelMenuTimer();
131 void homeButtonPushed(); 132 void homeButtonPushed();
132 void docButtonPushed(); 133 void docButtonPushed();
133 void SDButtonPushed(); 134 void SDButtonPushed();
134 void CFButtonPushed(); 135 void CFButtonPushed();
135 void QPEButtonPushed(); 136 void QPEButtonPushed();
136 void upDir(); 137 void upDir();
137 void currentPathComboChanged(); 138 void currentPathComboChanged();
138 void copy(); 139 void copy();
139 void copyAs(); 140 void copyAs();
140 void copySameDir(); 141 void copySameDir();
141 void currentPathComboActivated(const QString &); 142 void currentPathComboActivated(const QString &);
142 void fillCombo(const QString &); 143 void fillCombo(const QString &);
143 bool copyFile( const QString & , const QString & ); 144 bool copyFile( const QString & , const QString & );
144 void move(); 145 void move();
145 void fileStatus(); 146 void fileStatus();
146 void doAbout(); 147 void doAbout();
147 void doBeam(); 148 void doBeam();
148 void fileBeamFinished( Ir *); 149 void fileBeamFinished( Ir *);
149 150
150private: 151private:
151 QTimer menuTimer; 152 QTimer menuTimer;
152 void startProcess(const QString &); 153 void startProcess(const QString &);
153private slots: 154private slots:
154 void processEnded(); 155 void processEnded();
155}; 156};
156 157
157#endif // ADVANCEDFM_H 158#endif // ADVANCEDFM_H
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 0a9f921..f77554a 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,1037 +1,1051 @@
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/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qpe/ir.h> 26#include <qpe/ir.h>
27 27
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qmultilineedit.h> 29#include <qmultilineedit.h>
30 30
31#include <qstring.h> 31#include <qstring.h>
32 32
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37#include <qtabwidget.h> 37#include <qtabwidget.h>
38#include <qtoolbutton.h> 38#include <qtoolbutton.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qlineedit.h> 40#include <qlineedit.h>
41#include <qlistview.h> 41#include <qlistview.h>
42 42
43#include <stdlib.h> 43#include <stdlib.h>
44#include <unistd.h> 44#include <unistd.h>
45#include <sys/stat.h> 45#include <sys/stat.h>
46#include <dirent.h> 46#include <dirent.h>
47 47
48 48
49void AdvancedFm::doLocalCd() { 49void AdvancedFm::doLocalCd() {
50 localListClicked( Local_View->currentItem()); 50 localListClicked( Local_View->currentItem());
51} 51}
52 52
53void AdvancedFm::doRemoteCd() { 53void AdvancedFm::doRemoteCd() {
54 localListClicked( Remote_View->currentItem()); 54 localListClicked( Remote_View->currentItem());
55} 55}
56 56
57void AdvancedFm::showMenuHidden() { 57void AdvancedFm::showMenuHidden() {
58 if (b) { 58 if (b) {
59 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 59 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
60 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 60 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
61 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 61 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
62// b=FALSE; 62// b=FALSE;
63 63
64 } else { 64 } else {
65 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 65 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
66 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 66 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
67 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 67 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
68// b=TRUE; 68// b=TRUE;
69 } 69 }
70 populateLocalView(); 70 populateLocalView();
71 populateRemoteView(); 71 populateRemoteView();
72// if(TabWidget->getCurrentTab() == 0) 72// if(TabWidget->getCurrentTab() == 0)
73// showHidden(); 73// showHidden();
74// else 74// else
75// showRemoteHidden(); 75// showRemoteHidden();
76// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); 76// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
77 if(b) b = false; else b = true; 77 if(b) b = false; else b = true;
78} 78}
79 79
80void AdvancedFm::showHidden() { 80void AdvancedFm::showHidden() {
81 if (b) { 81 if (b) {
82 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 82 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
83// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 83// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
84// b=FALSE; 84// b=FALSE;
85 85
86 } else { 86 } else {
87 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 87 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
88// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 88// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
89// b=TRUE; 89// b=TRUE;
90 } 90 }
91 populateLocalView(); 91 populateLocalView();
92} 92}
93 93
94void AdvancedFm::showRemoteHidden() { 94void AdvancedFm::showRemoteHidden() {
95 if (b) { 95 if (b) {
96 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 96 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
97// b=TRUE; 97// b=TRUE;
98 98
99 } else { 99 } else {
100 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 100 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
101// b=FALSE; 101// b=FALSE;
102 } 102 }
103 populateRemoteView(); 103 populateRemoteView();
104} 104}
105 105
106QString AdvancedFm::dealWithSymName(const QString &fileName) {
107 QString strItem = fileName;
108 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
109}
110
106void AdvancedFm::runThis() { 111void AdvancedFm::runThis() {
107 QString fs; 112 QString fs;
108 if (TabWidget->getCurrentTab() == 0) { 113 if (TabWidget->getCurrentTab() == 0) {
109 QString curFile = Local_View->currentItem()->text(0); 114 QString curFile = Local_View->currentItem()->text(0);
115 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
116 curFile = dealWithSymName((const QString&)curFile);
117
110 if(curFile != "../") { 118 if(curFile != "../") {
111 119
112 fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 120 fs = getFileSystemType((const QString &) currentDir.canonicalPath());
113 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 121 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
114 qDebug( fileInfo.owner()); 122 qDebug( fileInfo.owner());
115 if( (fileInfo.permission( QFileInfo::ExeUser) 123 if( (fileInfo.permission( QFileInfo::ExeUser)
116 | fileInfo.permission( QFileInfo::ExeGroup) 124 | fileInfo.permission( QFileInfo::ExeGroup)
117 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 125 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
118 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 126 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
119 QCopEnvelope e("QPE/System", "execute(QString)" ); 127 QCopEnvelope e("QPE/System", "execute(QString)" );
120 e << curFile; 128 e << curFile;
121 } else { 129 } else {
122 curFile = currentDir.canonicalPath()+"/"+curFile; 130 curFile = currentDir.canonicalPath()+"/"+curFile;
123 DocLnk nf(curFile); 131 DocLnk nf(curFile);
124 QString execStr = nf.exec(); 132 QString execStr = nf.exec();
125 qDebug( execStr); 133 qDebug( execStr);
126 if( execStr.isEmpty() ) { 134 if( execStr.isEmpty() ) {
127 } else { 135 } else {
128 nf.execute(); 136 nf.execute();
129 } 137 }
130 } 138 }
131 } 139 }
132 } else { 140 } else {
133 QString curFile = Remote_View->currentItem()->text(0); 141 QString curFile = Remote_View->currentItem()->text(0);
134 if(curFile != "../") { 142 if(curFile != "../") {
143 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
144 curFile = dealWithSymName((const QString&)curFile);
135 145
136 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 146 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
137 qDebug("Filesystemtype is "+fs); 147 qDebug("Filesystemtype is "+fs);
138 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); 148 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
139 if( (fileInfo.permission( QFileInfo::ExeUser) 149 if( (fileInfo.permission( QFileInfo::ExeUser)
140 | fileInfo.permission( QFileInfo::ExeGroup) 150 | fileInfo.permission( QFileInfo::ExeGroup)
141 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 151 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
142 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 152 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
143 QCopEnvelope e("QPE/System", "execute(QString)" ); 153 QCopEnvelope e("QPE/System", "execute(QString)" );
144 e << curFile; 154 e << curFile;
145 } else { 155 } else {
146 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 156 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
147 DocLnk nf(curFile); 157 DocLnk nf(curFile);
148 QString execStr = nf.exec(); 158 QString execStr = nf.exec();
149 qDebug(execStr); 159 qDebug(execStr);
150 if( execStr.isEmpty() ) { 160 if( execStr.isEmpty() ) {
151 } else { 161 } else {
152 nf.execute(); 162 nf.execute();
153 } 163 }
154 } 164 }
155 } 165 }
156 } 166 }
157} 167}
158 168
159void AdvancedFm::runText() { 169void AdvancedFm::runText() {
160 if (TabWidget->getCurrentTab() == 0) { 170 if (TabWidget->getCurrentTab() == 0) {
161 QString curFile = Local_View->currentItem()->text(0); 171 QString curFile = Local_View->currentItem()->text(0);
162 if(curFile != "../") { 172 if(curFile != "../") {
173 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
174 curFile = dealWithSymName((const QString&)curFile);
163 curFile = currentDir.canonicalPath()+"/"+curFile; 175 curFile = currentDir.canonicalPath()+"/"+curFile;
164 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 176 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
165 e << curFile; 177 e << curFile;
166 } 178 }
167 } else { 179 } else {
168 QString curFile = Remote_View->currentItem()->text(0); 180 QString curFile = Remote_View->currentItem()->text(0);
169 if(curFile != "../") { 181 if(curFile != "../") {
170 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 182 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
183 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
184 curFile = dealWithSymName((const QString&)curFile);
171 DocLnk nf(curFile); 185 DocLnk nf(curFile);
172 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 186 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
173 e << curFile; 187 e << curFile;
174 } 188 }
175 } 189 }
176} 190}
177 191
178void AdvancedFm::localMakDir() { 192void AdvancedFm::localMakDir() {
179 InputDialog *fileDlg; 193 InputDialog *fileDlg;
180 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 194 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
181 fileDlg->exec(); 195 fileDlg->exec();
182 if( fileDlg->result() == 1 ) { 196 if( fileDlg->result() == 1 ) {
183 QString filename = fileDlg->LineEdit1->text(); 197 QString filename = fileDlg->LineEdit1->text();
184 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 198 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
185 } 199 }
186 populateLocalView(); 200 populateLocalView();
187} 201}
188 202
189void AdvancedFm::remoteMakDir() { 203void AdvancedFm::remoteMakDir() {
190 InputDialog *fileDlg; 204 InputDialog *fileDlg;
191 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 205 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
192 fileDlg->exec(); 206 fileDlg->exec();
193 if( fileDlg->result() == 1 ) { 207 if( fileDlg->result() == 1 ) {
194 QString filename = fileDlg->LineEdit1->text(); 208 QString filename = fileDlg->LineEdit1->text();
195 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); 209 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
196 } 210 }
197 populateRemoteView(); 211 populateRemoteView();
198} 212}
199 213
200void AdvancedFm::localDelete() { 214void AdvancedFm::localDelete() {
201 QStringList curFileList = getPath(); 215 QStringList curFileList = getPath();
202 bool doMsg=true; 216 bool doMsg=true;
203 int count=curFileList.count(); 217 int count=curFileList.count();
204 if( count > 0) { 218 if( count > 0) {
205 if(count > 1 ){ 219 if(count > 1 ){
206 QString msg; 220 QString msg;
207 msg=tr("Really delete\n%1 files?").arg(count); 221 msg=tr("Really delete\n%1 files?").arg(count);
208 switch ( QMessageBox::warning(this,tr("Delete"),msg 222 switch ( QMessageBox::warning(this,tr("Delete"),msg
209 ,tr("Yes"),tr("No"),0,0,1) ) { 223 ,tr("Yes"),tr("No"),0,0,1) ) {
210 case 0: 224 case 0:
211 doMsg=false; 225 doMsg=false;
212 break; 226 break;
213 case 1: 227 case 1:
214 return; 228 return;
215 break; 229 break;
216 }; 230 };
217 } 231 }
218 232
219 QString myFile; 233 QString myFile;
220 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 234 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
221 myFile = (*it); 235 myFile = (*it);
222 if( myFile.find(" -> ",0,TRUE) != -1) 236 if( myFile.find(" -> ",0,TRUE) != -1)
223 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 237 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
224 238
225 QString f = currentDir.canonicalPath(); 239 QString f = currentDir.canonicalPath();
226 if(f.right(1).find("/",0,TRUE) == -1) 240 if(f.right(1).find("/",0,TRUE) == -1)
227 f+="/"; 241 f+="/";
228 f+=myFile; 242 f+=myFile;
229 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 243 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
230 switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ 244 switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+
231 "\nand all it's contents ?" 245 "\nand all it's contents ?"
232 ,tr("Yes"),tr("No"),0,0,1) ) { 246 ,tr("Yes"),tr("No"),0,0,1) ) {
233 case 0: { 247 case 0: {
234 f=f.left(f.length()-1); 248 f=f.left(f.length()-1);
235 QString cmd="rm -rf "+f; 249 QString cmd="rm -rf "+f;
236 startProcess( (const QString)cmd.latin1() ); 250 startProcess( (const QString)cmd.latin1() );
237 populateLocalView(); 251 populateLocalView();
238 } 252 }
239 break; 253 break;
240 case 1: 254 case 1:
241 // exit 255 // exit
242 break; 256 break;
243 }; 257 };
244 258
245 } else { 259 } else {
246 if(doMsg) { 260 if(doMsg) {
247 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 261 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
248 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 262 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
249 case 1: 263 case 1:
250 return; 264 return;
251 break; 265 break;
252 }; 266 };
253 } 267 }
254 QString cmd="rm "+f; 268 QString cmd="rm "+f;
255 QFile file(f); 269 QFile file(f);
256 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 270 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
257 file.remove(); 271 file.remove();
258 } 272 }
259 } 273 }
260 } 274 }
261 populateLocalView(); 275 populateLocalView();
262} 276}
263 277
264void AdvancedFm::remoteDelete() { 278void AdvancedFm::remoteDelete() {
265 QStringList curFileList = getPath(); 279 QStringList curFileList = getPath();
266 bool doMsg=true; 280 bool doMsg=true;
267 int count=curFileList.count(); 281 int count=curFileList.count();
268 if( count > 0) { 282 if( count > 0) {
269 if(count > 1 ){ 283 if(count > 1 ){
270 QString msg; 284 QString msg;
271 msg=tr("Really delete\n%1 files?").arg(count); 285 msg=tr("Really delete\n%1 files?").arg(count);
272 switch ( QMessageBox::warning(this,tr("Delete"),msg 286 switch ( QMessageBox::warning(this,tr("Delete"),msg
273 ,tr("Yes"),tr("No"),0,0,1) ) { 287 ,tr("Yes"),tr("No"),0,0,1) ) {
274 case 0: 288 case 0:
275 doMsg=false; 289 doMsg=false;
276 break; 290 break;
277 case 1: 291 case 1:
278 return; 292 return;
279 break; 293 break;
280 }; 294 };
281 } 295 }
282 296
283 QString myFile; 297 QString myFile;
284 298
285 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 299 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
286 myFile = (*it); 300 myFile = (*it);
287 if(myFile.find(" -> ",0,TRUE) != -1) 301 if(myFile.find(" -> ",0,TRUE) != -1)
288 myFile = myFile.left(myFile.find(" -> ",0,TRUE)); 302 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
289 QString f = currentRemoteDir.canonicalPath(); 303 QString f = currentRemoteDir.canonicalPath();
290 if(f.right(1).find("/",0,TRUE) == -1) 304 if(f.right(1).find("/",0,TRUE) == -1)
291 f+="/"; 305 f+="/";
292 f+=myFile; 306 f+=myFile;
293 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 307 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
294 switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ 308 switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+
295 "\nand all it's contents ?", 309 "\nand all it's contents ?",
296 tr("Yes"),tr("No"),0,0,1) ) { 310 tr("Yes"),tr("No"),0,0,1) ) {
297 case 0: { 311 case 0: {
298 f=f.left(f.length()-1); 312 f=f.left(f.length()-1);
299 QString cmd="rm -rf "+f; 313 QString cmd="rm -rf "+f;
300 startProcess( (const QString)cmd ); 314 startProcess( (const QString)cmd );
301 populateRemoteView(); 315 populateRemoteView();
302 } 316 }
303 break; 317 break;
304 case 1: 318 case 1:
305 // exit 319 // exit
306 break; 320 break;
307 }; 321 };
308 322
309 } else { 323 } else {
310 if(doMsg) { 324 if(doMsg) {
311 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 325 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
312 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 326 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
313 case 1: 327 case 1:
314 return; 328 return;
315 break; 329 break;
316 }; 330 };
317 } 331 }
318 QString cmd="rm "+f; 332 QString cmd="rm "+f;
319 QFile file(f); 333 QFile file(f);
320 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 334 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
321 file.remove(); 335 file.remove();
322 } 336 }
323 } 337 }
324 } 338 }
325 populateRemoteView(); 339 populateRemoteView();
326} 340}
327 341
328void AdvancedFm::localRename() { 342void AdvancedFm::localRename() {
329 QString curFile = Local_View->currentItem()->text(0); 343 QString curFile = Local_View->currentItem()->text(0);
330 qDebug("currentItem "+curFile); 344 qDebug("currentItem "+curFile);
331 if( curFile !="../") { 345 if( curFile !="../") {
332 InputDialog *fileDlg; 346 InputDialog *fileDlg;
333 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 347 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
334 fileDlg->setInputText((const QString &)curFile); 348 fileDlg->setInputText((const QString &)curFile);
335 fileDlg->exec(); 349 fileDlg->exec();
336 if( fileDlg->result() == 1 ) { 350 if( fileDlg->result() == 1 ) {
337 QString oldname = currentDir.canonicalPath() + "/" + curFile; 351 QString oldname = currentDir.canonicalPath() + "/" + curFile;
338 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); 352 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
339//+".playlist"; 353//+".playlist";
340 if( rename(oldname.latin1(), newName.latin1())== -1) 354 if( rename(oldname.latin1(), newName.latin1())== -1)
341 QMessageBox::message(tr("Note"),tr("Could not rename")); 355 QMessageBox::message(tr("Note"),tr("Could not rename"));
342 } 356 }
343 populateLocalView(); 357 populateLocalView();
344 } 358 }
345} 359}
346 360
347void AdvancedFm::remoteRename() 361void AdvancedFm::remoteRename()
348{ 362{
349 QString curFile = Remote_View->currentItem()->text(0); 363 QString curFile = Remote_View->currentItem()->text(0);
350 if( curFile !="../") { 364 if( curFile !="../") {
351 InputDialog *fileDlg; 365 InputDialog *fileDlg;
352 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 366 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
353 fileDlg->setInputText((const QString &)curFile); 367 fileDlg->setInputText((const QString &)curFile);
354 fileDlg->exec(); 368 fileDlg->exec();
355 if( fileDlg->result() == 1 ) { 369 if( fileDlg->result() == 1 ) {
356 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; 370 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
357 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); 371 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
358//+".playlist"; 372//+".playlist";
359 if( rename(oldname.latin1(), newName.latin1())== -1) 373 if( rename(oldname.latin1(), newName.latin1())== -1)
360 QMessageBox::message(tr("Note"),tr("Could not rename")); 374 QMessageBox::message(tr("Note"),tr("Could not rename"));
361 } 375 }
362 populateRemoteView(); 376 populateRemoteView();
363 } 377 }
364} 378}
365 379
366 380
367void AdvancedFm::filePerms() { 381void AdvancedFm::filePerms() {
368 382
369 QStringList curFileList = getPath(); 383 QStringList curFileList = getPath();
370 QString filePath; 384 QString filePath;
371 385
372 if (TabWidget->getCurrentTab() == 0) { 386 if (TabWidget->getCurrentTab() == 0) {
373 filePath = currentDir.canonicalPath()+"/"; 387 filePath = currentDir.canonicalPath()+"/";
374 } else { 388 } else {
375 filePath= currentRemoteDir.canonicalPath()+"/"; 389 filePath= currentRemoteDir.canonicalPath()+"/";
376 } 390 }
377 391
378 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 392 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
379 filePermissions *filePerm; 393 filePermissions *filePerm;
380 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 394 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
381 filePerm->showMaximized(); 395 filePerm->showMaximized();
382 filePerm->exec(); 396 filePerm->exec();
383 if( filePerm) 397 if( filePerm)
384 delete filePerm; 398 delete filePerm;
385 } 399 }
386 if (TabWidget->getCurrentTab() == 0) { 400 if (TabWidget->getCurrentTab() == 0) {
387 populateLocalView(); 401 populateLocalView();
388 } else { 402 } else {
389 populateRemoteView(); 403 populateRemoteView();
390 } 404 }
391} 405}
392 406
393void AdvancedFm::doProperties() { 407void AdvancedFm::doProperties() {
394#if defined(QT_QWS_OPIE) 408#if defined(QT_QWS_OPIE)
395 409
396 QStringList curFileList = getPath(); 410 QStringList curFileList = getPath();
397 411
398 QString filePath; 412 QString filePath;
399 if (TabWidget->getCurrentTab() == 0) { 413 if (TabWidget->getCurrentTab() == 0) {
400 filePath = currentDir.canonicalPath()+"/"; 414 filePath = currentDir.canonicalPath()+"/";
401 } else { 415 } else {
402 filePath= currentRemoteDir.canonicalPath()+"/"; 416 filePath= currentRemoteDir.canonicalPath()+"/";
403 } 417 }
404 qDebug("%d",curFileList.count()); 418 qDebug("%d",curFileList.count());
405 419
406 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 420 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
407 qDebug((filePath+*it)); 421 qDebug((filePath+*it));
408 DocLnk lnk( (filePath+*it)); 422 DocLnk lnk( (filePath+*it));
409 LnkProperties prop( &lnk ); 423 LnkProperties prop( &lnk );
410 prop.showMaximized(); 424 prop.showMaximized();
411 prop.exec(); 425 prop.exec();
412 } 426 }
413#endif 427#endif
414 428
415} 429}
416 430
417void AdvancedFm::upDir() { 431void AdvancedFm::upDir() {
418 if (TabWidget->getCurrentTab() == 0) { 432 if (TabWidget->getCurrentTab() == 0) {
419 QString current = currentDir.canonicalPath(); 433 QString current = currentDir.canonicalPath();
420 QDir dir(current); 434 QDir dir(current);
421 dir.cdUp(); 435 dir.cdUp();
422 current = dir.canonicalPath(); 436 current = dir.canonicalPath();
423 chdir( current.latin1() ); 437 chdir( current.latin1() );
424 currentDir.cd( current, TRUE); 438 currentDir.cd( current, TRUE);
425 populateLocalView(); 439 populateLocalView();
426 update(); 440 update();
427 } else { 441 } else {
428 QString current = currentRemoteDir.canonicalPath(); 442 QString current = currentRemoteDir.canonicalPath();
429 QDir dir(current); 443 QDir dir(current);
430 dir.cdUp(); 444 dir.cdUp();
431 current = dir.canonicalPath(); 445 current = dir.canonicalPath();
432 chdir( current.latin1() ); 446 chdir( current.latin1() );
433 currentRemoteDir.cd( current, TRUE); 447 currentRemoteDir.cd( current, TRUE);
434 populateRemoteView(); 448 populateRemoteView();
435 update(); 449 update();
436 } 450 }
437} 451}
438 452
439void AdvancedFm::copy() { 453void AdvancedFm::copy() {
440 qApp->processEvents(); 454 qApp->processEvents();
441 QStringList curFileList = getPath(); 455 QStringList curFileList = getPath();
442 bool doMsg=true; 456 bool doMsg=true;
443 int count=curFileList.count(); 457 int count=curFileList.count();
444 if( count > 0) { 458 if( count > 0) {
445 if(count > 1 ){ 459 if(count > 1 ){
446 QString msg; 460 QString msg;
447 msg=tr("Really copy\n%1 files?").arg(count); 461 msg=tr("Really copy\n%1 files?").arg(count);
448 switch ( QMessageBox::warning(this,tr("Delete"),msg 462 switch ( QMessageBox::warning(this,tr("Delete"),msg
449 ,tr("Yes"),tr("No"),0,0,1) ) { 463 ,tr("Yes"),tr("No"),0,0,1) ) {
450 case 0: 464 case 0:
451 doMsg=false; 465 doMsg=false;
452 break; 466 break;
453 case 1: 467 case 1:
454 return; 468 return;
455 break; 469 break;
456 }; 470 };
457 } 471 }
458 472
459 QString curFile, item, destFile; 473 QString curFile, item, destFile;
460 if (TabWidget->getCurrentTab() == 0) { 474 if (TabWidget->getCurrentTab() == 0) {
461 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 475 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
462 item=(*it); 476 item=(*it);
463 if(item.find("->",0,TRUE)) //symlink 477 if(item.find("->",0,TRUE)) //symlink
464 item = item.left(item.find("->",0,TRUE)); 478 item = item.left(item.find("->",0,TRUE));
465 479
466 destFile = currentRemoteDir.canonicalPath()+"/"+ item; 480 destFile = currentRemoteDir.canonicalPath()+"/"+ item;
467 qDebug("Destination file is "+destFile); 481 qDebug("Destination file is "+destFile);
468 482
469 curFile = currentDir.canonicalPath()+"/"+ item; 483 curFile = currentDir.canonicalPath()+"/"+ item;
470 qDebug("CurrentFile file is " + curFile); 484 qDebug("CurrentFile file is " + curFile);
471 485
472 QFile f(destFile); 486 QFile f(destFile);
473 if( f.exists()) { 487 if( f.exists()) {
474 if(doMsg) { 488 if(doMsg) {
475 switch ( QMessageBox::warning(this,tr("File Exists!"), 489 switch ( QMessageBox::warning(this,tr("File Exists!"),
476 item+tr("\nexists. Ok to overwrite?"), 490 item+tr("\nexists. Ok to overwrite?"),
477 tr("Yes"),tr("No"),0,0,1) ) { 491 tr("Yes"),tr("No"),0,0,1) ) {
478 case 1: 492 case 1:
479 return; 493 return;
480 break; 494 break;
481 }; 495 };
482 } 496 }
483 f.remove(); 497 f.remove();
484 } 498 }
485 if(!copyFile(destFile, curFile) ) { 499 if(!copyFile( curFile, destFile) ) {
486 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 500 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
487 return; 501 return;
488 } 502 }
489 } 503 }
490 populateRemoteView(); 504 populateRemoteView();
491 TabWidget->setCurrentTab(1); 505 TabWidget->setCurrentTab(1);
492 506
493 } else { 507 } else {
494 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 508 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
495 item= (*it); 509 item= (*it);
496 if(item.find("->",0,TRUE)) //symlink 510 if(item.find("->",0,TRUE)) //symlink
497 item = item.left(item.find("->",0,TRUE)); 511 item = item.left(item.find("->",0,TRUE));
498 512
499 destFile = currentDir.canonicalPath()+"/"+ item; 513 destFile = currentDir.canonicalPath()+"/"+ item;
500 qDebug("Destination file is "+destFile); 514 qDebug("Destination file is "+destFile);
501 515
502 curFile = currentRemoteDir.canonicalPath()+"/"+ item;; 516 curFile = currentRemoteDir.canonicalPath()+"/"+ item;;
503 qDebug("CurrentFile file is " + curFile); 517 qDebug("CurrentFile file is " + curFile);
504 518
505 QFile f(destFile); 519 QFile f(destFile);
506 if( f.exists()) { 520 if( f.exists()) {
507 switch ( QMessageBox::warning(this,tr("File Exists!"), 521 switch ( QMessageBox::warning(this,tr("File Exists!"),
508 item+tr("\nexists. Ok to overwrite?"), 522 item+tr("\nexists. Ok to overwrite?"),
509 tr("Yes"),tr("No"),0,0,1) ) { 523 tr("Yes"),tr("No"),0,0,1) ) {
510 case 1: 524 case 1:
511 return; 525 return;
512 break; 526 break;
513 }; 527 };
514 f.remove(); 528 f.remove();
515 } 529 }
516 if(!copyFile(destFile, curFile) ) { 530 if(!copyFile( curFile, destFile) ) {
517 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 531 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
518 +curFile +tr("to\n")+destFile); 532 +curFile +tr("to\n")+destFile);
519 return; 533 return;
520 534
521 } 535 }
522 } 536 }
523 populateLocalView(); 537 populateLocalView();
524 TabWidget->setCurrentTab(0); 538 TabWidget->setCurrentTab(0);
525 } 539 }
526 540
527 } 541 }
528} 542}
529 543
530void AdvancedFm::copyAs() { 544void AdvancedFm::copyAs() {
531 qApp->processEvents(); 545 qApp->processEvents();
532 546
533 QStringList curFileList = getPath(); 547 QStringList curFileList = getPath();
534 QString curFile, item; 548 QString curFile, item;
535 InputDialog *fileDlg; 549 InputDialog *fileDlg;
536 if (TabWidget->getCurrentTab() == 0) { 550 if (TabWidget->getCurrentTab() == 0) {
537 qDebug("tab 1"); 551 qDebug("tab 1");
538 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 552 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
539 QString destFile; 553 QString destFile;
540 item=(*it); 554 item=(*it);
541 curFile = currentDir.canonicalPath()+"/"+(*it); 555 curFile = currentDir.canonicalPath()+"/"+(*it);
542 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 556 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
543 557
544 fileDlg->setInputText((const QString &) destFile ); 558 fileDlg->setInputText((const QString &) destFile );
545 fileDlg->exec(); 559 fileDlg->exec();
546 560
547 if( fileDlg->result() == 1 ) { 561 if( fileDlg->result() == 1 ) {
548 QString filename = fileDlg->LineEdit1->text(); 562 QString filename = fileDlg->LineEdit1->text();
549 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 563 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
550 564
551 QFile f(destFile); 565 QFile f(destFile);
552 if( f.exists()) { 566 if( f.exists()) {
553 switch (QMessageBox::warning(this,tr("File Exists!"), 567 switch (QMessageBox::warning(this,tr("File Exists!"),
554 item+tr("\nexists. Ok to overwrite?"), 568 item+tr("\nexists. Ok to overwrite?"),
555 tr("Yes"),tr("No"),0,0,1) ) { 569 tr("Yes"),tr("No"),0,0,1) ) {
556 case 0: 570 case 0:
557 f.remove(); 571 f.remove();
558 break; 572 break;
559 case 1: 573 case 1:
560 return; 574 return;
561 break; 575 break;
562 }; 576 };
563 } 577 }
564 if(!copyFile(destFile, curFile) ) { 578 if(!copyFile( curFile,destFile) ) {
565 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 579 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
566 +curFile +tr("to\n")+destFile); 580 +curFile +tr("to\n")+destFile);
567 return; 581 return;
568 } 582 }
569 } 583 }
570 delete fileDlg; 584 delete fileDlg;
571 585
572 } 586 }
573 populateRemoteView(); 587 populateRemoteView();
574 TabWidget->setCurrentTab(1); 588 TabWidget->setCurrentTab(1);
575 589
576 } else { 590 } else {
577 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 591 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
578 592
579 item=(*it); 593 item=(*it);
580 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 594 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
581 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 595 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
582 596
583 QString destFile; 597 QString destFile;
584 fileDlg->setInputText((const QString &) destFile); 598 fileDlg->setInputText((const QString &) destFile);
585 fileDlg->exec(); 599 fileDlg->exec();
586 600
587 if( fileDlg->result() == 1 ) { 601 if( fileDlg->result() == 1 ) {
588 QString filename = fileDlg->LineEdit1->text(); 602 QString filename = fileDlg->LineEdit1->text();
589 destFile = currentDir.canonicalPath()+"/"+filename; 603 destFile = currentDir.canonicalPath()+"/"+filename;
590 604
591 QFile f( destFile); 605 QFile f( destFile);
592 if( f.exists()) { 606 if( f.exists()) {
593 switch ( QMessageBox::warning(this,tr("File Exists!"), 607 switch ( QMessageBox::warning(this,tr("File Exists!"),
594 item+tr("\nexists. Ok to overwrite?"), 608 item+tr("\nexists. Ok to overwrite?"),
595 tr("Yes"),tr("No"),0,0,1) ) { 609 tr("Yes"),tr("No"),0,0,1) ) {
596 case 0: 610 case 0:
597 f.remove(); 611 f.remove();
598 break; 612 break;
599 case 1: 613 case 1:
600 return; 614 return;
601 break; 615 break;
602 }; 616 };
603 } 617 }
604 if(!copyFile(destFile, curFile) ) { 618 if(!copyFile( curFile,destFile) ) {
605 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 619 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
606 +curFile +tr("to\n")+destFile); 620 +curFile +tr("to\n")+destFile);
607 return; 621 return;
608 } 622 }
609 623
610 } 624 }
611 delete fileDlg; 625 delete fileDlg;
612 626
613 } 627 }
614 populateLocalView(); 628 populateLocalView();
615 TabWidget->setCurrentTab(0); 629 TabWidget->setCurrentTab(0);
616 } 630 }
617} 631}
618 632
619void AdvancedFm::copySameDir() { 633void AdvancedFm::copySameDir() {
620 qApp->processEvents(); 634 qApp->processEvents();
621 QStringList curFileList = getPath(); 635 QStringList curFileList = getPath();
622 QString curFile, item, destFile; 636 QString curFile, item, destFile;
623 InputDialog *fileDlg; 637 InputDialog *fileDlg;
624 638
625 if (TabWidget->getCurrentTab() == 0) { 639 if (TabWidget->getCurrentTab() == 0) {
626 640
627 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 641 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
628 item=(*it); 642 item=(*it);
629 curFile = currentDir.canonicalPath()+"/"+ item; 643 curFile = currentDir.canonicalPath()+"/"+ item;
630 644
631 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 645 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
632 fileDlg->setInputText((const QString &) destFile ); 646 fileDlg->setInputText((const QString &) destFile );
633 fileDlg->exec(); 647 fileDlg->exec();
634 648
635 if( fileDlg->result() == 1 ) { 649 if( fileDlg->result() == 1 ) {
636 650
637 QString filename = fileDlg->LineEdit1->text(); 651 QString filename = fileDlg->LineEdit1->text();
638 destFile = currentDir.canonicalPath()+"/"+filename; 652 destFile = currentDir.canonicalPath()+"/"+filename;
639 653
640 QFile f(destFile); 654 QFile f(destFile);
641 if( f.exists()) { 655 if( f.exists()) {
642 switch (QMessageBox::warning(this,tr("Delete"), 656 switch (QMessageBox::warning(this,tr("Delete"),
643 destFile+tr(" already exists\nDo you really want to delete it?"), 657 destFile+tr(" already exists\nDo you really want to delete it?"),
644 tr("Yes"),tr("No"),0,0,1) ) { 658 tr("Yes"),tr("No"),0,0,1) ) {
645 case 0: 659 case 0:
646 660
647 f.remove(); 661 f.remove();
648 break; 662 break;
649 case 1: 663 case 1:
650 return; 664 return;
651 break; 665 break;
652 }; 666 };
653 } 667 }
654 if(!copyFile(destFile, curFile) ) { 668 if(!copyFile( curFile,destFile) ) {
655 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 669 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
656 +curFile +tr("to\n")+destFile); 670 +curFile +tr("to\n")+destFile);
657 return; 671 return;
658 } 672 }
659 673
660 qDebug("copy "+curFile+" as "+destFile); 674 qDebug("copy "+curFile+" as "+destFile);
661 } 675 }
662 delete fileDlg; 676 delete fileDlg;
663 } 677 }
664 populateLocalView(); 678 populateLocalView();
665 679
666 } else { 680 } else {
667 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 681 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
668 item=(*it); 682 item=(*it);
669 curFile = currentRemoteDir.canonicalPath()+"/"+ item; 683 curFile = currentRemoteDir.canonicalPath()+"/"+ item;
670 684
671 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 685 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
672 fileDlg->setInputText((const QString &) destFile); 686 fileDlg->setInputText((const QString &) destFile);
673 fileDlg->exec(); 687 fileDlg->exec();
674 if( fileDlg->result() == 1 ) { 688 if( fileDlg->result() == 1 ) {
675 QString filename = fileDlg->LineEdit1->text(); 689 QString filename = fileDlg->LineEdit1->text();
676 690
677 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 691 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
678 692
679 QFile f(destFile); 693 QFile f(destFile);
680 if( f.exists()) { 694 if( f.exists()) {
681 switch ( QMessageBox::warning(this,tr("Delete"), 695 switch ( QMessageBox::warning(this,tr("Delete"),
682 destFile+tr(" already exists\nDo you really want to delete it?"), 696 destFile+tr(" already exists\nDo you really want to delete it?"),
683 tr("Yes"),tr("No"),0,0,1) ) { 697 tr("Yes"),tr("No"),0,0,1) ) {
684 case 0: 698 case 0:
685 f.remove(); 699 f.remove();
686 break; 700 break;
687 case 1: 701 case 1:
688 return; 702 return;
689 break; 703 break;
690 }; 704 };
691 } 705 }
692 if(!copyFile(destFile, curFile) ) { 706 if(!copyFile( curFile,destFile) ) {
693 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 707 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
694 +curFile +tr("to\n")+destFile); 708 +curFile +tr("to\n")+destFile);
695 return; 709 return;
696 } 710 }
697 qDebug("copy "+curFile+" as "+destFile); 711 qDebug("copy "+curFile+" as "+destFile);
698 } 712 }
699 delete fileDlg; 713 delete fileDlg;
700 } 714 }
701 populateRemoteView(); 715 populateRemoteView();
702 } 716 }
703} 717}
704 718
705void AdvancedFm::move() { 719void AdvancedFm::move() {
706 qApp->processEvents(); 720 qApp->processEvents();
707 721
708 QStringList curFileList = getPath(); 722 QStringList curFileList = getPath();
709 if( curFileList.count() > 0) { 723 if( curFileList.count() > 0) {
710 QString curFile, destFile, item; 724 QString curFile, destFile, item;
711 725
712 if (TabWidget->getCurrentTab() == 0) { 726 if (TabWidget->getCurrentTab() == 0) {
713 727
714 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 728 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
715 item=(*it); 729 item=(*it);
716 QString destFile = currentRemoteDir.canonicalPath(); 730 QString destFile = currentRemoteDir.canonicalPath();
717 731
718 if(destFile.right(1).find("/",0,TRUE) == -1) 732 if(destFile.right(1).find("/",0,TRUE) == -1)
719 destFile+="/"; 733 destFile+="/";
720 destFile += item; 734 destFile += item;
721 curFile = currentDir.canonicalPath(); 735 curFile = currentDir.canonicalPath();
722 736
723 qDebug("Destination file is "+destFile); 737 qDebug("Destination file is "+destFile);
724 738
725 if(curFile.right(1).find("/",0,TRUE) == -1) 739 if(curFile.right(1).find("/",0,TRUE) == -1)
726 curFile +="/"; 740 curFile +="/";
727 741
728 curFile+= item; 742 curFile+= item;
729 qDebug("CurrentFile file is " + curFile); 743 qDebug("CurrentFile file is " + curFile);
730 744
731 QFile f( curFile); 745 QFile f( curFile);
732 if( f.exists()) { 746 if( f.exists()) {
733 if(!copyFile( destFile, curFile) ) { 747 if(!copyFile( curFile,destFile) ) {
734 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 748 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
735 return; 749 return;
736 } else 750 } else
737 QFile::remove(curFile); 751 QFile::remove(curFile);
738 } 752 }
739 } 753 }
740 754
741 TabWidget->setCurrentTab(1); 755 TabWidget->setCurrentTab(1);
742 756
743 } else { //view 2 757 } else { //view 2
744 758
745 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 759 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
746 item = (*it); 760 item = (*it);
747 QString destFile = currentDir.canonicalPath(); 761 QString destFile = currentDir.canonicalPath();
748 762
749 if(destFile.right(1).find("/",0,TRUE) == -1) 763 if(destFile.right(1).find("/",0,TRUE) == -1)
750 destFile+="/"; 764 destFile+="/";
751 765
752 destFile += item; 766 destFile += item;
753 767
754 qDebug("Destination file is "+destFile); 768 qDebug("Destination file is "+destFile);
755 769
756 curFile = currentRemoteDir.canonicalPath(); 770 curFile = currentRemoteDir.canonicalPath();
757 771
758 if(curFile.right(1).find("/",0,TRUE) == -1) 772 if(curFile.right(1).find("/",0,TRUE) == -1)
759 curFile +="/"; 773 curFile +="/";
760 curFile+= item; 774 curFile+= item;
761 qDebug("CurrentFile file is " + curFile); 775 qDebug("CurrentFile file is " + curFile);
762 776
763 QFile f( curFile); 777 QFile f( curFile);
764 if( f.exists()) { 778 if( f.exists()) {
765 if(!copyFile( destFile, curFile) ) { 779 if(!copyFile( curFile, destFile) ) {
766 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); 780 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
767 return; 781 return;
768 } else 782 } else
769 QFile::remove( curFile); 783 QFile::remove( curFile);
770 } 784 }
771 TabWidget->setCurrentTab(0); 785 TabWidget->setCurrentTab(0);
772 } 786 }
773 } 787 }
774 populateRemoteView(); 788 populateRemoteView();
775 populateLocalView(); 789 populateLocalView();
776 } 790 }
777} 791}
778 792
779bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { 793bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
780 char bf[ 50000 ]; 794 char bf[ 50000 ];
781 int bytesRead; 795 int bytesRead;
782 bool success = TRUE; 796 bool success = TRUE;
783 struct stat status; 797 struct stat status;
784 798
785 QFile s( src ); 799 QFile s( src );
786 QFile d( dest ); 800 QFile d( dest );
787 801
788 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 802 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
789 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 803 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
790 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 804 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
791 success = FALSE; 805 success = FALSE;
792 break; 806 break;
793 } 807 }
794 } 808 }
795 if( success && (bytesRead > 0) ){ 809 if( success && (bytesRead > 0) ){
796 d.writeBlock( bf, bytesRead ); 810 d.writeBlock( bf, bytesRead );
797 } 811 }
798 } else { 812 } else {
799 success = FALSE; 813 success = FALSE;
800 } 814 }
801 815
802 // Set file permissions 816 // Set file permissions
803 if( stat( (const char *) src, &status ) == 0 ){ 817 if( stat( (const char *) src, &status ) == 0 ){
804 chmod( (const char *) dest, status.st_mode ); 818 chmod( (const char *) dest, status.st_mode );
805 } 819 }
806 820
807 return success; 821 return success;
808} 822}
809 823
810void AdvancedFm::runCommand() { 824void AdvancedFm::runCommand() {
811 QString curFile; 825 QString curFile;
812 if (TabWidget->getCurrentTab() == 0) { 826 if (TabWidget->getCurrentTab() == 0) {
813 if( Local_View->currentItem()) 827 if( Local_View->currentItem())
814 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 828 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
815 } else { 829 } else {
816 if(Remote_View->currentItem()) 830 if(Remote_View->currentItem())
817 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); 831 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
818 } 832 }
819 833
820 InputDialog *fileDlg; 834 InputDialog *fileDlg;
821 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 835 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
822 fileDlg->setInputText(curFile); 836 fileDlg->setInputText(curFile);
823 fileDlg->exec(); 837 fileDlg->exec();
824 //QString command; 838 //QString command;
825 839
826 if( fileDlg->result() == 1 ) { 840 if( fileDlg->result() == 1 ) {
827 qDebug(fileDlg->LineEdit1->text()); 841 qDebug(fileDlg->LineEdit1->text());
828 QStringList command; 842 QStringList command;
829 843
830 command << "/bin/sh"; 844 command << "/bin/sh";
831 command << "-c"; 845 command << "-c";
832 command << fileDlg->LineEdit1->text(); 846 command << fileDlg->LineEdit1->text();
833 Output *outDlg; 847 Output *outDlg;
834 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 848 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
835 outDlg->showMaximized(); 849 outDlg->showMaximized();
836 outDlg->exec(); 850 outDlg->exec();
837 qApp->processEvents(); 851 qApp->processEvents();
838 852
839 } 853 }
840} 854}
841 855
842void AdvancedFm::runCommandStd() { 856void AdvancedFm::runCommandStd() {
843 QString curFile; 857 QString curFile;
844 if (TabWidget->getCurrentTab() == 0) { 858 if (TabWidget->getCurrentTab() == 0) {
845 if( Local_View->currentItem()) 859 if( Local_View->currentItem())
846 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 860 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
847 } else { 861 } else {
848 if(Remote_View->currentItem()) 862 if(Remote_View->currentItem())
849 curFile = currentRemoteDir.canonicalPath() +"/" 863 curFile = currentRemoteDir.canonicalPath() +"/"
850 + Remote_View->currentItem()->text(0); 864 + Remote_View->currentItem()->text(0);
851 } 865 }
852 866
853 InputDialog *fileDlg; 867 InputDialog *fileDlg;
854 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 868 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
855 fileDlg->setInputText(curFile); 869 fileDlg->setInputText(curFile);
856 fileDlg->exec(); 870 fileDlg->exec();
857 871
858 if( fileDlg->result() == 1 ) { 872 if( fileDlg->result() == 1 ) {
859 qApp->processEvents(); 873 qApp->processEvents();
860 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 874 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
861 } 875 }
862} 876}
863 877
864void AdvancedFm::fileStatus() { 878void AdvancedFm::fileStatus() {
865 QString curFile; 879 QString curFile;
866 if (TabWidget->getCurrentTab() == 0) { 880 if (TabWidget->getCurrentTab() == 0) {
867 curFile = Local_View->currentItem()->text(0); 881 curFile = Local_View->currentItem()->text(0);
868 } else { 882 } else {
869 curFile = Remote_View->currentItem()->text(0); 883 curFile = Remote_View->currentItem()->text(0);
870 } 884 }
871 885
872 QStringList command; 886 QStringList command;
873 command << "/bin/sh"; 887 command << "/bin/sh";
874 command << "-c"; 888 command << "-c";
875 command << "stat -l "+ curFile; 889 command << "stat -l "+ curFile;
876 890
877 Output *outDlg; 891 Output *outDlg;
878 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 892 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
879 outDlg->showMaximized(); 893 outDlg->showMaximized();
880 outDlg->exec(); 894 outDlg->exec();
881 qApp->processEvents(); 895 qApp->processEvents();
882 896
883 897
884// Output *outDlg; 898// Output *outDlg;
885// outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 899// outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
886// outDlg->showMaximized(); 900// outDlg->showMaximized();
887// outDlg->show(); 901// outDlg->show();
888// qApp->processEvents(); 902// qApp->processEvents();
889 903
890// FILE *fp; 904// FILE *fp;
891// char line[130]; 905// char line[130];
892// sleep(1); 906// sleep(1);
893// fp = popen( (const char *) command, "r"); 907// fp = popen( (const char *) command, "r");
894// if ( !fp ) { 908// if ( !fp ) {
895// qDebug("Could not execute '" + command + "'! err=%d", fp); 909// qDebug("Could not execute '" + command + "'! err=%d", fp);
896// QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 910// QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
897// pclose(fp); 911// pclose(fp);
898// return; 912// return;
899// } else { 913// } else {
900// while ( fgets( line, sizeof line, fp)) { 914// while ( fgets( line, sizeof line, fp)) {
901// outDlg->OutputEdit->append(line); 915// outDlg->OutputEdit->append(line);
902// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 916// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
903 917
904// } 918// }
905 919
906// } 920// }
907// pclose(fp); 921// pclose(fp);
908} 922}
909 923
910 924
911void AdvancedFm::mkDir() { 925void AdvancedFm::mkDir() {
912 if (TabWidget->getCurrentTab() == 0) 926 if (TabWidget->getCurrentTab() == 0)
913 localMakDir(); 927 localMakDir();
914 else 928 else
915 remoteMakDir(); 929 remoteMakDir();
916 930
917} 931}
918 932
919void AdvancedFm::rn() { 933void AdvancedFm::rn() {
920 if (TabWidget->getCurrentTab() == 0) 934 if (TabWidget->getCurrentTab() == 0)
921 localRename(); 935 localRename();
922 else 936 else
923 remoteRename(); 937 remoteRename();
924 938
925} 939}
926 940
927void AdvancedFm::del() { 941void AdvancedFm::del() {
928 if (TabWidget->getCurrentTab() == 0) 942 if (TabWidget->getCurrentTab() == 0)
929 localDelete(); 943 localDelete();
930 else 944 else
931 remoteDelete(); 945 remoteDelete();
932} 946}
933 947
934void AdvancedFm::mkSym() { 948void AdvancedFm::mkSym() {
935 QString cmd; 949 QString cmd;
936 QStringList curFileList = getPath(); 950 QStringList curFileList = getPath();
937 if( curFileList.count() > 0) { 951 if( curFileList.count() > 0) {
938 952
939 if (TabWidget->getCurrentTab() == 0) { 953 if (TabWidget->getCurrentTab() == 0) {
940 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 954 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
941 955
942 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); 956 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
943 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 957 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
944 QString curFile = currentDir.canonicalPath()+"/"+(*it); 958 QString curFile = currentDir.canonicalPath()+"/"+(*it);
945 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 959 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
946 cmd = "ln -s "+curFile+" "+destName; 960 cmd = "ln -s "+curFile+" "+destName;
947 qDebug(cmd); 961 qDebug(cmd);
948 startProcess( (const QString)cmd ); 962 startProcess( (const QString)cmd );
949 } 963 }
950 populateRemoteView(); 964 populateRemoteView();
951 TabWidget->setCurrentTab(1); 965 TabWidget->setCurrentTab(1);
952 } else { 966 } else {
953 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 967 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
954 968
955 QString destName = currentDir.canonicalPath()+"/"+(*it); 969 QString destName = currentDir.canonicalPath()+"/"+(*it);
956 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 970 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
957 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 971 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
958 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 972 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
959 973
960 cmd = "ln -s "+curFile+" "+destName; 974 cmd = "ln -s "+curFile+" "+destName;
961 qDebug(cmd); 975 qDebug(cmd);
962 startProcess( (const QString)cmd ); 976 startProcess( (const QString)cmd );
963 } 977 }
964 populateLocalView(); 978 populateLocalView();
965 TabWidget->setCurrentTab(0); 979 TabWidget->setCurrentTab(0);
966 } 980 }
967 } 981 }
968} 982}
969 983
970void AdvancedFm::doBeam() { 984void AdvancedFm::doBeam() {
971 Ir ir; 985 Ir ir;
972 if(!ir.supported()){ 986 if(!ir.supported()){
973 } else { 987 } else {
974 988
975 QStringList curFileList = getPath(); 989 QStringList curFileList = getPath();
976 if( curFileList.count() > 0) { 990 if( curFileList.count() > 0) {
977 991
978 if (TabWidget->getCurrentTab() == 0) { 992 if (TabWidget->getCurrentTab() == 0) {
979 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 993 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
980 994
981 QString curFile = currentDir.canonicalPath()+"/"+(*it); 995 QString curFile = currentDir.canonicalPath()+"/"+(*it);
982 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 996 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
983 Ir *file = new Ir(this, "IR"); 997 Ir *file = new Ir(this, "IR");
984 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 998 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
985 file->send( curFile, curFile ); 999 file->send( curFile, curFile );
986 } 1000 }
987 1001
988 } else { 1002 } else {
989 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1003 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
990 1004
991 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1005 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
992 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 1006 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
993 Ir *file = new Ir(this, "IR"); 1007 Ir *file = new Ir(this, "IR");
994 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 1008 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
995 file->send( curFile, curFile ); 1009 file->send( curFile, curFile );
996 1010
997 } 1011 }
998 } 1012 }
999 } 1013 }
1000 } 1014 }
1001 1015
1002} 1016}
1003 1017
1004void AdvancedFm::fileBeamFinished( Ir *) { 1018void AdvancedFm::fileBeamFinished( Ir *) {
1005 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 1019 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
1006 1020
1007} 1021}
1008 1022
1009void AdvancedFm::selectAll() { 1023void AdvancedFm::selectAll() {
1010 if (TabWidget->getCurrentTab() == 0) { 1024 if (TabWidget->getCurrentTab() == 0) {
1011 Local_View->selectAll(true); 1025 Local_View->selectAll(true);
1012 Local_View->setSelected( Local_View->firstChild(),false); 1026 Local_View->setSelected( Local_View->firstChild(),false);
1013 } else { 1027 } else {
1014 Remote_View->selectAll(true); 1028 Remote_View->selectAll(true);
1015 Remote_View->setSelected( Remote_View->firstChild(),false); 1029 Remote_View->setSelected( Remote_View->firstChild(),false);
1016 } 1030 }
1017} 1031}
1018 1032
1019void AdvancedFm::startProcess(const QString & cmd) { 1033void AdvancedFm::startProcess(const QString & cmd) {
1020 QStringList command; 1034 QStringList command;
1021 OProcess *process; 1035 OProcess *process;
1022 process = new OProcess(); 1036 process = new OProcess();
1023 connect(process, SIGNAL(processExited(OProcess *)), 1037 connect(process, SIGNAL(processExited(OProcess *)),
1024 this, SLOT( processEnded())); 1038 this, SLOT( processEnded()));
1025 1039
1026 command << "/bin/sh"; 1040 command << "/bin/sh";
1027 command << "-c"; 1041 command << "-c";
1028 command << cmd.latin1(); 1042 command << cmd.latin1();
1029 *process << command; 1043 *process << command;
1030 if(!process->start(OProcess::NotifyOnExit) ) 1044 if(!process->start(OProcess::NotifyOnExit) )
1031 qDebug("could not start process"); 1045 qDebug("could not start process");
1032} 1046}
1033 1047
1034void AdvancedFm::processEnded() { 1048void AdvancedFm::processEnded() {
1035 populateLocalView(); 1049 populateLocalView();
1036 populateRemoteView(); 1050 populateRemoteView();
1037} 1051}