summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-06 20:59:04 (UTC)
committer llornkcor <llornkcor>2002-10-06 20:59:04 (UTC)
commit2623a1e2fddf0bfb91191ea7224f016032336ed5 (patch) (unidiff)
tree3ee4d0330368bc3508778298b907ade1cfdf0ac1
parente334186122e512a57bd27026014f01f501db93fc (diff)
downloadopie-2623a1e2fddf0bfb91191ea7224f016032336ed5.zip
opie-2623a1e2fddf0bfb91191ea7224f016032336ed5.tar.gz
opie-2623a1e2fddf0bfb91191ea7224f016032336ed5.tar.bz2
fix select and scroll
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 3aa516c..ec475a4 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,851 +1,858 @@
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 13
14#include "advancedfm.h" 14#include "advancedfm.h"
15 15
16// #include <opie/ofileselector.h> 16// #include <opie/ofileselector.h>
17// #include <opie/ofiledialog.h> 17// #include <opie/ofiledialog.h>
18 18
19#include <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 *) { 90void AdvancedFm::tabChanged(QWidget *) {
91 if (TabWidget->currentPageIndex() == 0) { 91 if (TabWidget->currentPageIndex() == 0) {
92 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 92 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
93 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 93 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
94 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 94 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
95 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 95 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
96 setCaption("AdvancedFm :: "+fs+" :: " 96 setCaption("AdvancedFm :: "+fs+" :: "
97 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 97 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
98 98
99 } 99 }
100 if (TabWidget->currentPageIndex() == 1) { 100 if (TabWidget->currentPageIndex() == 1) {
101 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 101 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
102 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 102 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
103 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 103 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
104 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 104 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
105 setCaption("AdvancedFm :: "+fs+" :: " 105 setCaption("AdvancedFm :: "+fs+" :: "
106 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 106 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
107 } 107 }
108} 108}
109 109
110 110
111void AdvancedFm::populateLocalView() { 111void AdvancedFm::populateLocalView() {
112 QPixmap pm; 112 QPixmap pm;
113 Local_View->clear(); 113 Local_View->clear();
114 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 114 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
115 currentDir.setMatchAllDirs(TRUE); 115 currentDir.setMatchAllDirs(TRUE);
116 currentDir.setNameFilter(filterStr); 116 currentDir.setNameFilter(filterStr);
117 QString fileL, fileS, fileDate; 117 QString fileL, fileS, fileDate;
118 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 118 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
119 setCaption("AdvancedFm :: "+fs+" :: " 119 setCaption("AdvancedFm :: "+fs+" :: "
120 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 120 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
121 bool isDir=FALSE; 121 bool isDir=FALSE;
122 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 122 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
123 QFileInfoListIterator it(*list); 123 QFileInfoListIterator it(*list);
124 QFileInfo *fi; 124 QFileInfo *fi;
125 while ( (fi=it.current()) ) { 125 while ( (fi=it.current()) ) {
126 if (fi->isSymLink() ) { 126 if (fi->isSymLink() ) {
127 QString symLink=fi->readLink(); 127 QString symLink=fi->readLink();
128 QFileInfo sym( symLink); 128 QFileInfo sym( symLink);
129 fileS.sprintf( "%10i", sym.size() ); 129 fileS.sprintf( "%10i", sym.size() );
130 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 130 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
131 fileDate = sym.lastModified().toString(); 131 fileDate = sym.lastModified().toString();
132 } else { 132 } else {
133 fileS.sprintf( "%10i", fi->size() ); 133 fileS.sprintf( "%10i", fi->size() );
134 fileL.sprintf( "%s",fi->fileName().data() ); 134 fileL.sprintf( "%s",fi->fileName().data() );
135 fileDate= fi->lastModified().toString(); 135 fileDate= fi->lastModified().toString();
136 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 136 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
137 fileL+="/"; 137 fileL+="/";
138 isDir=TRUE; 138 isDir=TRUE;
139 } 139 }
140 } 140 }
141 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 141 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
142 if(fileL !="./" && fi->exists()) { 142 if(fileL !="./" && fi->exists()) {
143 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 143 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
144 144
145 if(isDir || fileL.find("/",0,TRUE) != -1) { 145 if(isDir || fileL.find("/",0,TRUE) != -1) {
146 146
147 if( !QDir( fi->filePath() ).isReadable()) //is directory 147 if( !QDir( fi->filePath() ).isReadable()) //is directory
148 pm = Resource::loadPixmap( "lockedfolder" ); 148 pm = Resource::loadPixmap( "lockedfolder" );
149 else 149 else
150 pm= Resource::loadPixmap( "folder" ); 150 pm= Resource::loadPixmap( "folder" );
151 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 151 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
152 pm = Resource::loadPixmap( "exec"); 152 pm = Resource::loadPixmap( "exec");
153 } else if( (fileInfo.permission( QFileInfo::ExeUser) 153 } else if( (fileInfo.permission( QFileInfo::ExeUser)
154 | fileInfo.permission( QFileInfo::ExeGroup) 154 | fileInfo.permission( QFileInfo::ExeGroup)
155 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 155 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
156 pm = Resource::loadPixmap( "exec"); 156 pm = Resource::loadPixmap( "exec");
157 } else if( !fi->isReadable() ) { 157 } else if( !fi->isReadable() ) {
158 pm = Resource::loadPixmap( "locked" ); 158 pm = Resource::loadPixmap( "locked" );
159 } else { //everything else goes by mimetype 159 } else { //everything else goes by mimetype
160 MimeType mt(fi->filePath()); 160 MimeType mt(fi->filePath());
161 pm=mt.pixmap(); //sets the correct pixmap for mimetype 161 pm=mt.pixmap(); //sets the correct pixmap for mimetype
162 if(pm.isNull()) 162 if(pm.isNull())
163 pm = Resource::loadPixmap( "UnknownDocument-14" ); 163 pm = Resource::loadPixmap( "UnknownDocument-14" );
164 } 164 }
165 item->setPixmap( 0,pm); 165 item->setPixmap( 0,pm);
166 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 166 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
167 // overlay link image 167 // overlay link image
168 pm= Resource::loadPixmap( "folder" ); 168 pm= Resource::loadPixmap( "folder" );
169 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 169 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
170 QPainter painter( &pm ); 170 QPainter painter( &pm );
171 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 171 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
172 pm.setMask( pm.createHeuristicMask( FALSE ) ); 172 pm.setMask( pm.createHeuristicMask( FALSE ) );
173 item->setPixmap( 0, pm); 173 item->setPixmap( 0, pm);
174 } 174 }
175 } 175 }
176 isDir=FALSE; 176 isDir=FALSE;
177 ++it; 177 ++it;
178 } 178 }
179 179
180 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 180 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
181 struct stat buf; 181 struct stat buf;
182 dev_t devT; 182 dev_t devT;
183 DIR *dir; 183 DIR *dir;
184 struct dirent *mydirent; 184 struct dirent *mydirent;
185 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 185 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
186 while ((mydirent = readdir(dir)) != NULL) { 186 while ((mydirent = readdir(dir)) != NULL) {
187 lstat( mydirent->d_name, &buf); 187 lstat( mydirent->d_name, &buf);
188 qDebug(mydirent->d_name); 188 qDebug(mydirent->d_name);
189 fileL.sprintf("%s", mydirent->d_name); 189 fileL.sprintf("%s", mydirent->d_name);
190 devT = buf.st_dev; 190 devT = buf.st_dev;
191 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 191 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
192 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 192 fileDate.sprintf("%s", ctime( &buf.st_mtime));
193 if( fileL.find(".") == -1 ){ 193 if( fileL.find(".") == -1 ){
194 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 194 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
195 pm = Resource::loadPixmap( "UnknownDocument-14" ); 195 pm = Resource::loadPixmap( "UnknownDocument-14" );
196 item->setPixmap( 0,pm); 196 item->setPixmap( 0,pm);
197 } 197 }
198 } 198 }
199 199
200 closedir(dir); 200 closedir(dir);
201 } 201 }
202 202
203 Local_View->setSorting( 3,FALSE); 203 Local_View->setSorting( 3,FALSE);
204 fillCombo( (const QString &) currentDir.canonicalPath()); 204 fillCombo( (const QString &) currentDir.canonicalPath());
205} 205}
206 206
207 207
208void AdvancedFm::populateRemoteView() { 208void AdvancedFm::populateRemoteView() {
209 QPixmap pm; 209 QPixmap pm;
210 Remote_View->clear(); 210 Remote_View->clear();
211 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 211 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
212 currentRemoteDir.setMatchAllDirs(TRUE); 212 currentRemoteDir.setMatchAllDirs(TRUE);
213 currentRemoteDir.setNameFilter(filterStr); 213 currentRemoteDir.setNameFilter(filterStr);
214 QString fileL, fileS, fileDate; 214 QString fileL, fileS, fileDate;
215 215
216 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 216 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
217 setCaption("AdvancedFm :: "+fs+" :: " 217 setCaption("AdvancedFm :: "+fs+" :: "
218 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 218 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
219 bool isDir=FALSE; 219 bool isDir=FALSE;
220 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 220 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
221 QFileInfoListIterator it(*list); 221 QFileInfoListIterator it(*list);
222 QFileInfo *fi; 222 QFileInfo *fi;
223 while ( (fi=it.current()) ) { 223 while ( (fi=it.current()) ) {
224 if (fi->isSymLink() ){ 224 if (fi->isSymLink() ){
225 QString symLink=fi->readLink(); 225 QString symLink=fi->readLink();
226 // qDebug("Symlink detected "+symLink); 226 // qDebug("Symlink detected "+symLink);
227 QFileInfo sym( symLink); 227 QFileInfo sym( symLink);
228 fileS.sprintf( "%10i", sym.size() ); 228 fileS.sprintf( "%10i", sym.size() );
229 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 229 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
230 fileDate = sym.lastModified().toString(); 230 fileDate = sym.lastModified().toString();
231 } else { 231 } else {
232 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 232 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
233 fileS.sprintf( "%10i", fi->size() ); 233 fileS.sprintf( "%10i", fi->size() );
234 fileL.sprintf( "%s",fi->fileName().data() ); 234 fileL.sprintf( "%s",fi->fileName().data() );
235 fileDate= fi->lastModified().toString(); 235 fileDate= fi->lastModified().toString();
236 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 236 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
237 fileL+="/"; 237 fileL+="/";
238 isDir=TRUE; 238 isDir=TRUE;
239 // qDebug( fileL); 239 // qDebug( fileL);
240 } 240 }
241 } 241 }
242 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 242 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
243 if(fileL !="./" && fi->exists()) { 243 if(fileL !="./" && fi->exists()) {
244 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 244 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
245 QPixmap pm; 245 QPixmap pm;
246 246
247 if(isDir || fileL.find("/",0,TRUE) != -1) { 247 if(isDir || fileL.find("/",0,TRUE) != -1) {
248 if( !QDir( fi->filePath() ).isReadable()) 248 if( !QDir( fi->filePath() ).isReadable())
249 pm = Resource::loadPixmap( "lockedfolder" ); 249 pm = Resource::loadPixmap( "lockedfolder" );
250 else 250 else
251 pm= Resource::loadPixmap( "folder" ); 251 pm= Resource::loadPixmap( "folder" );
252 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 252 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
253 pm = Resource::loadPixmap( "exec"); 253 pm = Resource::loadPixmap( "exec");
254 } else if( (fileInfo.permission( QFileInfo::ExeUser) 254 } else if( (fileInfo.permission( QFileInfo::ExeUser)
255 | fileInfo.permission( QFileInfo::ExeGroup) 255 | fileInfo.permission( QFileInfo::ExeGroup)
256 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 256 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
257 pm = Resource::loadPixmap( "exec"); 257 pm = Resource::loadPixmap( "exec");
258 } else if( !fi->isReadable() ) { 258 } else if( !fi->isReadable() ) {
259 pm = Resource::loadPixmap( "locked" ); 259 pm = Resource::loadPixmap( "locked" );
260 } else { 260 } else {
261 MimeType mt(fi->filePath()); 261 MimeType mt(fi->filePath());
262 pm=mt.pixmap(); //sets the correct pixmap for mimetype 262 pm=mt.pixmap(); //sets the correct pixmap for mimetype
263 if(pm.isNull()) 263 if(pm.isNull())
264 pm = Resource::loadPixmap( "UnknownDocument-14" ); 264 pm = Resource::loadPixmap( "UnknownDocument-14" );
265 } 265 }
266 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 266 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
267 // overlay link image 267 // overlay link image
268 pm= Resource::loadPixmap( "folder" ); 268 pm= Resource::loadPixmap( "folder" );
269 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 269 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
270 QPainter painter( &pm ); 270 QPainter painter( &pm );
271 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 271 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
272 pm.setMask( pm.createHeuristicMask( FALSE ) ); 272 pm.setMask( pm.createHeuristicMask( FALSE ) );
273 } 273 }
274 item->setPixmap( 0, pm); 274 item->setPixmap( 0, pm);
275 } 275 }
276 isDir=FALSE; 276 isDir=FALSE;
277 ++it; 277 ++it;
278 } 278 }
279 279
280 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 280 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
281 struct stat buf; 281 struct stat buf;
282 DIR *dir; 282 DIR *dir;
283 struct dirent *mydirent; 283 struct dirent *mydirent;
284 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 284 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
285 while ((mydirent = readdir(dir)) != NULL) { 285 while ((mydirent = readdir(dir)) != NULL) {
286 lstat( mydirent->d_name, &buf); 286 lstat( mydirent->d_name, &buf);
287 qDebug(mydirent->d_name); 287 qDebug(mydirent->d_name);
288 fileL.sprintf("%s", mydirent->d_name); 288 fileL.sprintf("%s", mydirent->d_name);
289 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 289 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
290 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 290 fileDate.sprintf("%s", ctime( &buf.st_mtime));
291 if( fileL.find(".") == -1 ){ 291 if( fileL.find(".") == -1 ){
292 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 292 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
293 pm = Resource::loadPixmap( "UnknownDocument-14" ); 293 pm = Resource::loadPixmap( "UnknownDocument-14" );
294 item->setPixmap( 0,pm); 294 item->setPixmap( 0,pm);
295 } 295 }
296 } 296 }
297 297
298 closedir(dir); 298 closedir(dir);
299 } 299 }
300 300
301 Remote_View->setSorting( 3,FALSE); 301 Remote_View->setSorting( 3,FALSE);
302 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 302 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
303} 303}
304 304
305void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 305void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
306 if(selectedItem) { 306 if(selectedItem) {
307 QString strItem=selectedItem->text(0); 307 QString strItem=selectedItem->text(0);
308 QString strSize=selectedItem->text(1); 308 QString strSize=selectedItem->text(1);
309 strSize=strSize.stripWhiteSpace(); 309 strSize=strSize.stripWhiteSpace();
310 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 310 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
311 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 311 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
312 if(QDir(strItem2).exists() ) { 312 if(QDir(strItem2).exists() ) {
313 currentDir.cd(strItem2, TRUE); 313 currentDir.cd(strItem2, TRUE);
314 populateLocalView(); 314 populateLocalView();
315 315
316 } 316 }
317 } else { // not a symlink 317 } else { // not a symlink
318 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 318 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
319 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 319 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
320 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 320 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
321 currentDir.cd(strItem,FALSE); 321 currentDir.cd(strItem,FALSE);
322 populateLocalView(); 322 populateLocalView();
323 Local_View->ensureItemVisible(Local_View->firstChild());
324
323 } else { 325 } else {
324 currentDir.cdUp(); 326 currentDir.cdUp();
325 populateLocalView(); 327 populateLocalView();
328 Local_View->ensureItemVisible(Local_View->firstChild());
326 } 329 }
327 if(QDir(strItem).exists()){ 330 if(QDir(strItem).exists()){
328 currentDir.cd(strItem, TRUE); 331 currentDir.cd(strItem, TRUE);
332 Local_View->ensureItemVisible(Local_View->firstChild());
329 populateLocalView(); 333 populateLocalView();
330 } 334 }
331 } else { 335 } else {
332 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 336 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
333 if( QFile::exists(strItem ) ) { 337 if( QFile::exists(strItem ) ) {
334 // qDebug("clicked item "+strItem); 338 // qDebug("clicked item "+strItem);
335 // DocLnk doc( strItem, FALSE ); 339 // DocLnk doc( strItem, FALSE );
336 // doc.execute(); 340 // doc.execute();
337 // Local_View->clearSelection(); 341 // Local_View->clearSelection();
338 } 342 }
339 } //end not symlink 343 } //end not symlink
340 chdir(strItem.latin1()); 344 chdir(strItem.latin1());
341 } 345 }
342 Local_View->ensureItemVisible(Local_View->firstChild());
343 346
344 } 347 }
345} 348}
346 349
347void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { 350void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
348 351
349 if(selectedItem) { 352 if(selectedItem) {
350 QString strItem=selectedItem->text(0); 353 QString strItem=selectedItem->text(0);
351 QString strSize=selectedItem->text(1); 354 QString strSize=selectedItem->text(1);
352 strSize=strSize.stripWhiteSpace(); 355 strSize=strSize.stripWhiteSpace();
353 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 356 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
354 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 357 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
355 currentRemoteDir.cd(strItem2, TRUE); 358 currentRemoteDir.cd(strItem2, TRUE);
356 populateRemoteView(); 359 populateRemoteView();
357 } else { // not a symlink 360 } else { // not a symlink
358 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 361 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
359 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 362 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
360 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 363 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
361 currentRemoteDir.cd(strItem,FALSE); 364 currentRemoteDir.cd(strItem,FALSE);
362 populateRemoteView(); 365 populateRemoteView();
366 Remote_View->ensureItemVisible(Remote_View->firstChild());
363 } else { 367 } else {
364 currentRemoteDir.cdUp(); 368 currentRemoteDir.cdUp();
365 populateRemoteView(); 369 populateRemoteView();
370 Remote_View->ensureItemVisible(Remote_View->firstChild());
366 } 371 }
367 if(QDir(strItem).exists()){ 372 if(QDir(strItem).exists()){
368 currentRemoteDir.cd(strItem, TRUE); 373 currentRemoteDir.cd(strItem, TRUE);
369 populateRemoteView(); 374 populateRemoteView();
375 Remote_View->ensureItemVisible(Remote_View->firstChild());
370 } 376 }
371 } else { 377 } else {
372 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 378 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
373 if( QFile::exists(strItem ) ) { 379 if( QFile::exists(strItem ) ) {
374 // qDebug("clicked item "+strItem); 380 // qDebug("clicked item "+strItem);
375 // DocLnk doc( strItem, FALSE ); 381 // DocLnk doc( strItem, FALSE );
376 // doc.execute(); 382 // doc.execute();
377 // Remote_View->clearSelection(); 383 // Remote_View->clearSelection();
378 } 384 }
379 } //end not symlink 385 } //end not symlink
380 chdir(strItem.latin1()); 386 chdir(strItem.latin1());
381 } 387 }
382 Remote_View->ensureItemVisible(Remote_View->firstChild());
383 } 388 }
384} 389}
385 390
386 391
387void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 392void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
388// qDebug("list pressed"); 393// qDebug("list pressed");
389 switch (mouse) { 394 switch (mouse) {
390 case 1: 395 case 1:
391 break; 396 break;
392 case 2: 397 case 2:
393 menuTimer.start( 750, TRUE ); 398 menuTimer.start( 750, TRUE );
394 qDebug("Start menu timer\n"); 399 qDebug("Start menu timer\n");
395 break; 400 break;
396 }; 401 };
397} 402}
398 403
399void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 404void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) {
400 405
401 switch (mouse) { 406 switch (mouse) {
402 case 1: 407 case 1:
403 break; 408 break;
404 case 2: 409 case 2:
405 menuTimer.start( 750, TRUE ); 410 menuTimer.start( 750, TRUE );
406 qDebug("Start menu timer"); 411 qDebug("Start menu timer");
407 break; 412 break;
408 }; 413 };
409} 414}
410 415
411 416
412void AdvancedFm::switchToLocalTab() { 417void AdvancedFm::switchToLocalTab() {
413 TabWidget->setCurrentPage(0); 418 TabWidget->setCurrentPage(0);
414 Local_View->setFocus(); 419 Local_View->setFocus();
415} 420}
416 421
417void AdvancedFm::switchToRemoteTab() { 422void AdvancedFm::switchToRemoteTab() {
418 TabWidget->setCurrentPage(1); 423 TabWidget->setCurrentPage(1);
419 Remote_View->setFocus(); 424 Remote_View->setFocus();
420} 425}
421 426
422void AdvancedFm::readConfig() { 427void AdvancedFm::readConfig() {
423 Config cfg("AdvancedFm"); 428 Config cfg("AdvancedFm");
424} 429}
425 430
426void AdvancedFm::writeConfig() { 431void AdvancedFm::writeConfig() {
427 Config cfg("AdvancedFm"); 432 Config cfg("AdvancedFm");
428} 433}
429 434
430void AdvancedFm::currentPathComboChanged() { 435void AdvancedFm::currentPathComboChanged() {
431 if (TabWidget->currentPageIndex() == 0) { 436 if (TabWidget->currentPageIndex() == 0) {
432 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 437 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
433 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 438 currentDir.setPath( currentPathCombo->lineEdit()->text() );
434 populateLocalView(); 439 populateLocalView();
435 } else { 440 } else {
436 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 441 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
437 } 442 }
438 } 443 }
439 if (TabWidget->currentPageIndex() == 0) { 444 if (TabWidget->currentPageIndex() == 0) {
440 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 445 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
441 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 446 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
442 populateRemoteView(); 447 populateRemoteView();
443 } else { 448 } else {
444 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 449 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
445 } 450 }
446 } 451 }
447} 452}
448 453
449void AdvancedFm::fillCombo(const QString &currentPath) { 454void AdvancedFm::fillCombo(const QString &currentPath) {
450 455
451 if (TabWidget->currentPageIndex() == 0) { 456 if (TabWidget->currentPageIndex() == 0) {
452 currentPathCombo->lineEdit()->setText( currentPath); 457 currentPathCombo->lineEdit()->setText( currentPath);
453 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 458 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
454 currentPathCombo->clear(); 459 currentPathCombo->clear();
455 localDirPathStringList.prepend( currentPath ); 460 localDirPathStringList.prepend( currentPath );
456 currentPathCombo->insertStringList( localDirPathStringList,-1); 461 currentPathCombo->insertStringList( localDirPathStringList,-1);
457 } 462 }
458 } else { 463 } else {
459 currentPathCombo->lineEdit()->setText( currentPath); 464 currentPathCombo->lineEdit()->setText( currentPath);
460 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 465 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
461 currentPathCombo->clear(); 466 currentPathCombo->clear();
462 remoteDirPathStringList.prepend( currentPath ); 467 remoteDirPathStringList.prepend( currentPath );
463 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 468 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
464 } 469 }
465 } 470 }
466} 471}
467 472
468void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 473void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
469 if (TabWidget->currentPageIndex() == 0) { 474 if (TabWidget->currentPageIndex() == 0) {
470 chdir( currentPath.latin1() ); 475 chdir( currentPath.latin1() );
471 currentDir.cd( currentPath, TRUE); 476 currentDir.cd( currentPath, TRUE);
472 populateLocalView(); 477 populateLocalView();
473 update(); 478 update();
474 } else { 479 } else {
475 chdir( currentPath.latin1() ); 480 chdir( currentPath.latin1() );
476 currentRemoteDir.cd( currentPath, TRUE); 481 currentRemoteDir.cd( currentPath, TRUE);
477 populateRemoteView(); 482 populateRemoteView();
478 update(); 483 update();
479 } 484 }
480} 485}
481 486
482QStringList AdvancedFm::getPath() { 487QStringList AdvancedFm::getPath() {
483 QStringList strList; 488 QStringList strList;
484 if (TabWidget->currentPageIndex() == 0) { 489 if (TabWidget->currentPageIndex() == 0) {
485 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 490 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
486 QListViewItemIterator it( Local_View ); 491 QListViewItemIterator it( Local_View );
487 for ( ; it.current(); ++it ) { 492 for ( ; it.current(); ++it ) {
488 if ( it.current()->isSelected() ) { 493 if ( it.current()->isSelected() ) {
489 strList << it.current()->text(0); 494 strList << it.current()->text(0);
490 qDebug(it.current()->text(0)); 495 qDebug(it.current()->text(0));
491 } 496 }
492 } 497 }
493 return strList; 498 return strList;
494 } else { 499 } else {
495 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 500 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
496 QListViewItemIterator it( Remote_View ); 501 QListViewItemIterator it( Remote_View );
497 for ( ; it.current(); ++it ) { 502 for ( ; it.current(); ++it ) {
498 if ( it.current()->isSelected() ) { 503 if ( it.current()->isSelected() ) {
499 strList << it.current()->text(0); 504 strList << it.current()->text(0);
500 qDebug(it.current()->text(0)); 505 qDebug(it.current()->text(0));
501 } 506 }
502 } 507 }
503 return strList; 508 return strList;
504 } 509 }
505 return ""; 510 return "";
506} 511}
507 512
508void AdvancedFm::homeButtonPushed() { 513void AdvancedFm::homeButtonPushed() {
509 QString current = QDir::homeDirPath(); 514 QString current = QDir::homeDirPath();
510 chdir( current.latin1() ); 515 chdir( current.latin1() );
511 if (TabWidget->currentPageIndex() == 0) { 516 if (TabWidget->currentPageIndex() == 0) {
512 currentDir.cd( current, TRUE); 517 currentDir.cd( current, TRUE);
513 populateLocalView(); 518 populateLocalView();
514 } else { 519 } else {
515 currentRemoteDir.cd( current, TRUE); 520 currentRemoteDir.cd( current, TRUE);
516 populateRemoteView(); 521 populateRemoteView();
517 } 522 }
518 update(); 523 update();
519} 524}
520 525
521void AdvancedFm::docButtonPushed() { 526void AdvancedFm::docButtonPushed() {
522 QString current = QPEApplication::documentDir(); 527 QString current = QPEApplication::documentDir();
523 chdir( current.latin1() ); 528 chdir( current.latin1() );
524 if (TabWidget->currentPageIndex() == 0) { 529 if (TabWidget->currentPageIndex() == 0) {
525 currentDir.cd( current, TRUE); 530 currentDir.cd( current, TRUE);
526 populateLocalView(); 531 populateLocalView();
527 } else { 532 } else {
528 currentRemoteDir.cd( current, TRUE); 533 currentRemoteDir.cd( current, TRUE);
529 populateRemoteView(); 534 populateRemoteView();
530 } 535 }
531 update(); 536 update();
532} 537}
533 538
534void AdvancedFm::SDButtonPushed() { 539void AdvancedFm::SDButtonPushed() {
535 QString current = "/mnt/card";// this can change so fix 540 QString current = "/mnt/card";// this can change so fix
536 chdir( current.latin1() ); 541 chdir( current.latin1() );
537 if (TabWidget->currentPageIndex() == 0) { 542 if (TabWidget->currentPageIndex() == 0) {
538 currentDir.cd( current, TRUE); 543 currentDir.cd( current, TRUE);
539 populateLocalView(); 544 populateLocalView();
540 } else { 545 } else {
541 currentRemoteDir.cd( current, TRUE); 546 currentRemoteDir.cd( current, TRUE);
542 populateRemoteView(); 547 populateRemoteView();
543 } 548 }
544 update(); 549 update();
545 550
546} 551}
547 552
548void AdvancedFm::CFButtonPushed() { 553void AdvancedFm::CFButtonPushed() {
549 QString current; 554 QString current;
550 if(zaurusDevice) 555 if(zaurusDevice)
551 current= "/mnt/cf"; //zaurus 556 current= "/mnt/cf"; //zaurus
552 else 557 else
553 current = "/mnt/hda"; //ipaq 558 current = "/mnt/hda"; //ipaq
554 559
555 chdir( current.latin1() ); 560 chdir( current.latin1() );
556 if (TabWidget->currentPageIndex() == 0) { 561 if (TabWidget->currentPageIndex() == 0) {
557 currentDir.cd( current, TRUE); 562 currentDir.cd( current, TRUE);
558 populateLocalView(); 563 populateLocalView();
559 } else { 564 } else {
560 currentRemoteDir.cd( current, TRUE); 565 currentRemoteDir.cd( current, TRUE);
561 populateRemoteView(); 566 populateRemoteView();
562 } 567 }
563 update(); 568 update();
564} 569}
565 570
566 571
567 572
568void AdvancedFm::doAbout() { 573void AdvancedFm::doAbout() {
569 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 574 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
570 "is copyright 2002 by\n" 575 "is copyright 2002 by\n"
571 "L.J.Potter<llornkcor@handhelds.org>\n" 576 "L.J.Potter<llornkcor@handhelds.org>\n"
572 "and is licensed by the GPL")); 577 "and is licensed by the GPL"));
573} 578}
574 579
575void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 580void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
576 if( TabWidget->hasFocus()) 581 if( TabWidget->hasFocus())
577 switch ( e->key() ) { 582 switch ( e->key() ) {
578 case Key_Delete: 583 case Key_Delete:
579 del(); 584 del();
580 break; 585 break;
581 case Key_H: 586 case Key_H:
582 showHidden(); 587 showHidden();
583 break; 588 break;
584 case Key_E: 589 case Key_E:
585 runThis(); 590 runThis();
586 break; 591 break;
587 case Key_C: 592 case Key_C:
588 copy(); 593 copy();
589 break; 594 break;
590 case Key_A: 595 case Key_A:
591 copyAs(); 596 copyAs();
592 break; 597 break;
593 case Key_M: 598 case Key_M:
594 move(); 599 move();
595 break; 600 break;
596 case Key_R: 601 case Key_R:
597 rn(); 602 rn();
598 break; 603 break;
599 case Key_I: 604 case Key_I:
600 fileStatus(); 605 fileStatus();
601 break; 606 break;
602 case Key_U: 607 case Key_U:
603 upDir(); 608 upDir();
604 break; 609 break;
605 case Key_P: 610 case Key_P:
606 filePerms(); 611 filePerms();
607 break; 612 break;
608 case Key_N: 613 case Key_N:
609 mkDir(); 614 mkDir();
610 break; 615 break;
611 case Key_1: 616 case Key_1:
612 switchToLocalTab(); 617 switchToLocalTab();
613 break; 618 break;
614 case Key_2: 619 case Key_2:
615 switchToRemoteTab(); 620 switchToRemoteTab();
616 break; 621 break;
617 case Key_3: 622 case Key_3:
618 CFButtonPushed(); 623 CFButtonPushed();
619 break; 624 break;
620 case Key_4: 625 case Key_4:
621 SDButtonPushed(); 626 SDButtonPushed();
622 break; 627 break;
623 case Key_5: 628 case Key_5:
624 homeButtonPushed(); 629 homeButtonPushed();
625 break; 630 break;
626 case Key_6: 631 case Key_6:
627 docButtonPushed(); 632 docButtonPushed();
628 break; 633 break;
629 case Key_7: 634 case Key_7:
630 break; 635 break;
631 case Key_8: 636 case Key_8:
632 break; 637 break;
633 case Key_9: 638 case Key_9:
634 break; 639 break;
635 case Key_0: 640 case Key_0:
636 break; 641 break;
637 } 642 }
638} 643}
639 644
640 645
641void AdvancedFm::QPEButtonPushed() { 646void AdvancedFm::QPEButtonPushed() {
642 QString current = QPEApplication::qpeDir(); 647 QString current = QPEApplication::qpeDir();
643 chdir( current.latin1() ); 648 chdir( current.latin1() );
644 if (TabWidget->currentPageIndex() == 0) { 649 if (TabWidget->currentPageIndex() == 0) {
645 currentDir.cd( current, TRUE); 650 currentDir.cd( current, TRUE);
646 populateLocalView(); 651 populateLocalView();
647 } else { 652 } else {
648 currentRemoteDir.cd( current, TRUE); 653 currentRemoteDir.cd( current, TRUE);
649 populateRemoteView(); 654 populateRemoteView();
650 } 655 }
651 update(); 656 update();
652} 657}
653 658
654void AdvancedFm::parsetab(const QString &fileName) { 659void AdvancedFm::parsetab(const QString &fileName) {
655 660
656 fileSystemTypeList.clear(); 661 fileSystemTypeList.clear();
657 fsList.clear(); 662 fsList.clear();
658 struct mntent *me; 663 struct mntent *me;
659 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 664 FILE *mntfp = setmntent( fileName.latin1(), "r" );
660 if ( mntfp ) { 665 if ( mntfp ) {
661 while ( (me = getmntent( mntfp )) != 0 ) { 666 while ( (me = getmntent( mntfp )) != 0 ) {
662 QString deviceName = me->mnt_fsname; 667 QString deviceName = me->mnt_fsname;
663 QString filesystemType = me->mnt_type; 668 QString filesystemType = me->mnt_type;
664 QString mountDir = me->mnt_dir; 669 QString mountDir = me->mnt_dir;
665 if(deviceName != "none") { 670 if(deviceName != "none") {
666 if( fsList.contains(filesystemType) == 0 671 if( fsList.contains(filesystemType) == 0
667 & filesystemType.find("proc",0,TRUE) == -1 672 & filesystemType.find("proc",0,TRUE) == -1
668 & filesystemType.find("cramfs",0,TRUE) == -1 673 & filesystemType.find("cramfs",0,TRUE) == -1
669 & filesystemType.find("auto",0,TRUE) == -1) 674 & filesystemType.find("auto",0,TRUE) == -1)
670 fsList << filesystemType; 675 fsList << filesystemType;
671 fileSystemTypeList << mountDir+"::"+filesystemType; 676 fileSystemTypeList << mountDir+"::"+filesystemType;
672 } 677 }
673 } 678 }
674 } 679 }
675 endmntent( mntfp ); 680 endmntent( mntfp );
676} 681}
677 682
678QString AdvancedFm::getFileSystemType(const QString &currentText) { 683QString AdvancedFm::getFileSystemType(const QString &currentText) {
679 parsetab("/etc/mtab"); //why did TT forget filesystem type? 684 parsetab("/etc/mtab"); //why did TT forget filesystem type?
680 QString current = currentText;//.right( currentText.length()-1); 685 QString current = currentText;//.right( currentText.length()-1);
681 QString baseFs; 686 QString baseFs;
682 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 687 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
683 QString temp = (*it); 688 QString temp = (*it);
684 QString path = temp.left(temp.find("::",0,TRUE) ); 689 QString path = temp.left(temp.find("::",0,TRUE) );
685 path = path.right( path.length()-1); 690 path = path.right( path.length()-1);
686 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 691 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
687 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 692 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
688 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 693 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
689 } 694 }
690 } 695 }
691 return baseFs; 696 return baseFs;
692} 697}
693 698
694QString AdvancedFm::getDiskSpace( const QString &path) { 699QString AdvancedFm::getDiskSpace( const QString &path) {
695 struct statfs fss; 700 struct statfs fss;
696 if ( !statfs( path.latin1(), &fss ) ) { 701 if ( !statfs( path.latin1(), &fss ) ) {
697 int blkSize = fss.f_bsize; 702 int blkSize = fss.f_bsize;
698 // int totalBlks = fs.f_blocks; 703 // int totalBlks = fs.f_blocks;
699 int availBlks = fss.f_bavail; 704 int availBlks = fss.f_bavail;
700 705
701 long mult = blkSize / 1024; 706 long mult = blkSize / 1024;
702 long div = 1024 / blkSize; 707 long div = 1024 / blkSize;
703 if ( !mult ) mult = 1; 708 if ( !mult ) mult = 1;
704 if ( !div ) div = 1; 709 if ( !div ) div = 1;
705 710
706 return QString::number(availBlks * mult / div); 711 return QString::number(availBlks * mult / div);
707 } 712 }
708 return ""; 713 return "";
709} 714}
710 715
711 716
712void AdvancedFm::showFileMenu() { 717void AdvancedFm::showFileMenu() {
713 718
714 QString curApp; 719 QString curApp;
715 bool isLocalView = false; 720 bool isLocalView = false;
716 if (TabWidget->currentPageIndex() == 0) { 721 if (TabWidget->currentPageIndex() == 0) {
717 isLocalView = TRUE; 722 isLocalView = TRUE;
718 curApp = Local_View->currentItem()->text(0); 723 curApp = Local_View->currentItem()->text(0);
719 } else { 724 } else {
720 curApp = Remote_View->currentItem()->text(0); 725 curApp = Remote_View->currentItem()->text(0);
721 } 726 }
722 727
723 MimeType mt( curApp ); 728 MimeType mt( curApp );
724 const AppLnk* app = mt.application(); 729 const AppLnk* app = mt.application();
725 QFile fi(curApp); 730 QFile fi(curApp);
726 731
727 QPopupMenu *m = new QPopupMenu(0); 732 QPopupMenu *m = new QPopupMenu(0);
728 733
729 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 734 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
730 if ( !QFileInfo(fi).isDir() ) { 735 if ( !QFileInfo(fi).isDir() ) {
731 m->insertSeparator(); 736 m->insertSeparator();
732// m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 737// m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
733// } else { 738// } else {
734 739
735 if ( app ) 740 if ( app )
736 m->insertItem( app->pixmap(), tr( "Open in " 741 m->insertItem( app->pixmap(), tr( "Open in "
737 + app->name() ), this, SLOT( runThis() ) ); 742 + app->name() ), this, SLOT( runThis() ) );
738 else if( QFileInfo(fi).isExecutable() ) 743 else if( QFileInfo(fi).isExecutable() )
739 m->insertItem( Resource::loadPixmap( app->name()), tr( "Execute" ), this, SLOT( runThis() ) ); 744 m->insertItem( Resource::loadPixmap( app->name()), tr( "Execute" ), this, SLOT( runThis() ) );
740 745
741 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 746 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
742 } 747 }
743 m->insertSeparator(); 748 m->insertSeparator();
744 749
745 750
746 if(isLocalView) 751 if(isLocalView)
747 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 752 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
748 else 753 else
749 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 754 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
750 755
751 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 756 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
752 m->insertSeparator(); 757 m->insertSeparator();
753 758
754 if(isLocalView) 759 if(isLocalView)
755 m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 760 m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
756 else 761 else
757 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 762 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
758 763
759 m->insertItem( tr( "Copy" ), this, SLOT( copy() )); 764 m->insertItem( tr( "Copy" ), this, SLOT( copy() ));
760 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 765 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
761 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 766 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
762 m->insertItem( tr( "Move" ), this, SLOT( move() )); 767 m->insertItem( tr( "Move" ), this, SLOT( move() ));
763 m->insertSeparator(); 768 m->insertSeparator();
764 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 769 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
765 770
766// if(isLocalView) 771// if(isLocalView)
767// m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); 772// m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() ));
768// else 773// else
769// m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); 774// m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() ));
770 775
771 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 776 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
772 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 777 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
773 m->insertSeparator(); 778 m->insertSeparator();
774 779
775 if(isLocalView) 780 if(isLocalView)
776 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 781 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
777 else 782 else
778 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 783 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
779 784
780 m->insertSeparator(); 785 m->insertSeparator();
781 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 786 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
782 787
788#if defined(QT_QWS_OPIE)
783 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 789 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
790#endif
784 m->setCheckable(TRUE); 791 m->setCheckable(TRUE);
785 if (!b) 792 if (!b)
786 m->setItemChecked(m->idAt(0),TRUE); 793 m->setItemChecked(m->idAt(0),TRUE);
787 else 794 else
788 m->setItemChecked(m->idAt(0),FALSE); 795 m->setItemChecked(m->idAt(0),FALSE);
789 796
790 if(Ir::supported()) 797 if(Ir::supported())
791 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 798 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
792 m->setFocus(); 799 m->setFocus();
793 m->exec( QCursor::pos() ); 800 m->exec( QCursor::pos() );
794 sleep(1); 801 sleep(1);
795 if(m) delete m; 802 if(m) delete m;
796} 803}
797 804
798 805
799void AdvancedFm::cancelMenuTimer() { 806void AdvancedFm::cancelMenuTimer() {
800 807
801// qDebug("selectionChanged: cancel menu timer"); 808// qDebug("selectionChanged: cancel menu timer");
802 if( menuTimer.isActive() ) 809 if( menuTimer.isActive() )
803 menuTimer.stop(); 810 menuTimer.stop();
804} 811}
805 812
806QString AdvancedFm::checkDiskSpace(const QString &path) { 813QString AdvancedFm::checkDiskSpace(const QString &path) {
807 struct statfs fss; 814 struct statfs fss;
808 if ( !statfs( path.latin1(), &fss ) ) { 815 if ( !statfs( path.latin1(), &fss ) ) {
809 int blkSize = fss.f_bsize; 816 int blkSize = fss.f_bsize;
810// int totalBlks = fs.f_blocks; 817// int totalBlks = fs.f_blocks;
811 int availBlks = fss.f_bavail; 818 int availBlks = fss.f_bavail;
812 819
813 long mult = blkSize / 1024; 820 long mult = blkSize / 1024;
814 long div = 1024 / blkSize; 821 long div = 1024 / blkSize;
815 if ( !mult ) mult = 1; 822 if ( !mult ) mult = 1;
816 if ( !div ) div = 1; 823 if ( !div ) div = 1;
817 824
818 825
819 return QString::number(availBlks * mult / div); 826 return QString::number(availBlks * mult / div);
820 } 827 }
821 return ""; 828 return "";
822} 829}
823 830
824void AdvancedFm::addToDocs() { 831void AdvancedFm::addToDocs() {
825 QStringList strListPaths = getPath(); 832 QStringList strListPaths = getPath();
826 if( strListPaths.count() > 0) { 833 if( strListPaths.count() > 0) {
827 QString curFile; 834 QString curFile;
828 if (TabWidget->currentPageIndex() == 0) { 835 if (TabWidget->currentPageIndex() == 0) {
829 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 836 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
830 curFile = currentDir.canonicalPath()+"/"+(*it); 837 curFile = currentDir.canonicalPath()+"/"+(*it);
831 qDebug(curFile); 838 qDebug(curFile);
832 DocLnk f; 839 DocLnk f;
833// curFile.replace(QRegExp("\\..*"),""); 840// curFile.replace(QRegExp("\\..*"),"");
834 f.setName((*it)); 841 f.setName((*it));
835 f.setFile( curFile); 842 f.setFile( curFile);
836 f.writeLink(); 843 f.writeLink();
837 } 844 }
838 } else { 845 } else {
839 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 846 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
840 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 847 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
841 qDebug(curFile); 848 qDebug(curFile);
842 849
843 DocLnk f; 850 DocLnk f;
844// curFile.replace(QRegExp("\\..*"),""); 851// curFile.replace(QRegExp("\\..*"),"");
845 f.setName((*it)); 852 f.setName((*it));
846 f.setFile( curFile); 853 f.setFile( curFile);
847 f.writeLink(); 854 f.writeLink();
848 } 855 }
849 } 856 }
850 } 857 }
851} 858}