summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-03-26 02:07:38 (UTC)
committer llornkcor <llornkcor>2003-03-26 02:07:38 (UTC)
commit445c957aeddcea7ee0b83657e00987103a6d35b0 (patch) (unidiff)
tree4efbff1b8896295e532d1c10dd33e4ab177f014c
parenta76176911328349414203edda3785ac8925c0648 (diff)
downloadopie-445c957aeddcea7ee0b83657e00987103a6d35b0.zip
opie-445c957aeddcea7ee0b83657e00987103a6d35b0.tar.gz
opie-445c957aeddcea7ee0b83657e00987103a6d35b0.tar.bz2
change to UnknownDocument icon and scale
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp943
-rw-r--r--noncore/apps/advancedfm/advancedfm.h2
2 files changed, 477 insertions, 468 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index bb7f346..1a5e131 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,897 +1,904 @@
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/config.h> 19#include <qpe/config.h>
20#include <qpe/filemanager.h> 20#include <qpe/filemanager.h>
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/mimetype.h> 27#include <qpe/mimetype.h>
28#include <qpe/applnk.h> 28#include <qpe/applnk.h>
29#include <qpe/ir.h> 29#include <qpe/ir.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/menubutton.h> 31#include <qpe/menubutton.h>
32 32
33 33
34#include <qwmatrix.h>
34#include <qregexp.h> 35#include <qregexp.h>
35#include <qtabwidget.h> 36#include <qtabwidget.h>
36#include <qtextstream.h> 37#include <qtextstream.h>
37#include <qpushbutton.h> 38#include <qpushbutton.h>
38#include <qdatetime.h> 39#include <qdatetime.h>
39#include <qdir.h> 40#include <qdir.h>
40#include <qfile.h> 41#include <qfile.h>
41#include <qstring.h> 42#include <qstring.h>
42#include <qcombobox.h> 43#include <qcombobox.h>
43#include <qpopupmenu.h> 44#include <qpopupmenu.h>
44#include <qlistview.h> 45#include <qlistview.h>
45#include <qmainwindow.h> 46#include <qmainwindow.h>
46#include <qlabel.h> 47#include <qlabel.h>
47#include <qprogressbar.h> 48#include <qprogressbar.h>
48#include <qspinbox.h> 49#include <qspinbox.h>
49#include <qwidget.h> 50#include <qwidget.h>
50#include <qlayout.h> 51#include <qlayout.h>
51#include <qimage.h> 52#include <qimage.h>
52#include <qpixmap.h> 53#include <qpixmap.h>
53#include <qmessagebox.h> 54#include <qmessagebox.h>
54#include <qlineedit.h> 55#include <qlineedit.h>
55#include <qregexp.h> 56#include <qregexp.h>
56 57
57#include <unistd.h> 58#include <unistd.h>
58#include <stdlib.h> 59#include <stdlib.h>
59#include <sys/stat.h> 60#include <sys/stat.h>
60#include <dirent.h> 61#include <dirent.h>
61#include <stdio.h> 62#include <stdio.h>
62#include <time.h> 63#include <time.h>
63#include <fcntl.h> 64#include <fcntl.h>
64#include <mntent.h> 65#include <mntent.h>
65#include <string.h> 66#include <string.h>
66#include <errno.h> 67#include <errno.h>
67#include <sys/vfs.h> 68#include <sys/vfs.h>
68#include <mntent.h> 69#include <mntent.h>
69#include <sys/utsname.h> 70#include <sys/utsname.h>
70 71
71AdvancedFm::AdvancedFm( ) 72AdvancedFm::AdvancedFm( )
72 : QMainWindow( ) { 73 : QMainWindow( ) {
73 init(); 74 init();
74 renameBox = 0; 75 renameBox = 0;
75 76
76 initConnections(); 77 QWMatrix matrix;
77 whichTab=1; 78 QPixmap pix(Resource::loadPixmap( "UnknownDocument" ));
78 rePopulate(); 79 matrix.scale( .4, .4);
79 currentPathCombo->setFocus(); 80 unknownXpm = pix.xForm(matrix);
81
82 initConnections();
83 whichTab=1;
84 rePopulate();
85 currentPathCombo->setFocus();
80} 86}
81 87
82AdvancedFm::~AdvancedFm() { 88AdvancedFm::~AdvancedFm() {
83} 89}
84 90
85 91
86void AdvancedFm::cleanUp() 92void AdvancedFm::cleanUp()
87{ 93{
88 QString sfile=QDir::homeDirPath(); 94 QString sfile=QDir::homeDirPath();
89 if(sfile.right(1) != "/") 95 if(sfile.right(1) != "/")
90 sfile+="/._temp"; 96 sfile+="/._temp";
91 else 97 else
92 sfile+="._temp"; 98 sfile+="._temp";
93 QFile file( sfile); 99 QFile file( sfile);
94 if(file.exists()) 100 if(file.exists())
95 file.remove(); 101 file.remove();
96} 102}
97 103
98void AdvancedFm::tabChanged(QWidget *w) 104void AdvancedFm::tabChanged(QWidget *w)
99{ 105{
100 if( w == tab) 106 if( w == tab)
101 whichTab = 1; 107 whichTab = 1;
102 else 108 else
103 whichTab = 2; 109 whichTab = 2;
104 110
105 //qDebug("tab changed %d", whichTab ); 111// qDebug("tab changed %d", whichTab );
106 112
107 QString path = CurrentDir()->canonicalPath(); 113 QString path = CurrentDir()->canonicalPath();
108 currentPathCombo->lineEdit()->setText( path ); 114 currentPathCombo->lineEdit()->setText( path );
109 115
110 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 116 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
111 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 117 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
112 118
113 QString fs= getFileSystemType( (const QString &) path); 119 QString fs= getFileSystemType( (const QString &) path);
114 120
115 setCaption("AdvancedFm :: "+fs+" :: " 121 setCaption("AdvancedFm :: "+fs+" :: "
116 +checkDiskSpace( (const QString &) path )+ " kB free" ); 122 +checkDiskSpace( (const QString &) path )+ " kB free" );
117 chdir( path.latin1()); 123 chdir( path.latin1());
118} 124}
119 125
120 126
121void AdvancedFm::populateView() 127void AdvancedFm::populateView()
122{ 128{
123 QPixmap pm; 129 QPixmap pm;
124 QListView *thisView = CurrentView(); 130 QListView *thisView = CurrentView();
125 QDir *thisDir = CurrentDir(); 131 QDir *thisDir = CurrentDir();
126 QString path = thisDir->canonicalPath(); 132 QString path = thisDir->canonicalPath();
127 133
128 thisView->clear(); 134 thisView->clear();
129 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 135 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
130 thisDir->setMatchAllDirs(TRUE); 136 thisDir->setMatchAllDirs(TRUE);
131 thisDir->setNameFilter(filterStr); 137 thisDir->setNameFilter(filterStr);
132 QString fileL, fileS, fileDate; 138 QString fileL, fileS, fileDate;
133 QString fs= getFileSystemType((const QString &) path); 139 QString fs= getFileSystemType((const QString &) path);
134 setCaption("AdvancedFm :: "+fs+" :: " 140 setCaption("AdvancedFm :: "+fs+" :: "
135 +checkDiskSpace((const QString &) path)+" kB free" ); 141 +checkDiskSpace((const QString &) path)+" kB free" );
136 bool isDir=FALSE; 142 bool isDir=FALSE;
137 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 143 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
138 QFileInfoListIterator it(*list); 144 QFileInfoListIterator it(*list);
139 QFileInfo *fi; 145 QFileInfo *fi;
140 while ( (fi=it.current()) ) 146 while ( (fi=it.current()) )
141 { 147 {
142 if (fi->isSymLink() ) 148 if (fi->isSymLink() )
143 { 149 {
144 QString symLink=fi->readLink(); 150 QString symLink=fi->readLink();
145 QFileInfo sym( symLink); 151 QFileInfo sym( symLink);
146 fileS.sprintf( "%10i", sym.size() ); 152 fileS.sprintf( "%10i", sym.size() );
147 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 153 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
148 fileDate = sym.lastModified().toString(); 154 fileDate = sym.lastModified().toString();
149 } 155 }
150 else 156 else
151 { 157 {
152 fileS.sprintf( "%10i", fi->size() ); 158 fileS.sprintf( "%10i", fi->size() );
153 fileL.sprintf( "%s",fi->fileName().data() ); 159 fileL.sprintf( "%s",fi->fileName().data() );
154 fileDate= fi->lastModified().toString(); 160 fileDate= fi->lastModified().toString();
155 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) 161 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() )
156 { 162 {
157 fileL+="/"; 163 fileL+="/";
158 isDir=TRUE; 164 isDir=TRUE;
159 } 165 }
160 } 166 }
161 167
162 QFileInfo fileInfo( path + "/" + fileL); 168 QFileInfo fileInfo( path + "/" + fileL);
163 169
164 if(fileL !="./" && fi->exists()) 170 if(fileL !="./" && fi->exists())
165 { 171 {
166 item= new QListViewItem( thisView, fileL, fileS , fileDate); 172 item= new QListViewItem( thisView, fileL, fileS , fileDate);
167 173
168 if(isDir || fileL.find("/",0,TRUE) != -1) 174 if(isDir || fileL.find("/",0,TRUE) != -1)
169 { 175 {
170 176
171 if( !QDir( fi->filePath() ).isReadable()) //is directory 177 if( !QDir( fi->filePath() ).isReadable()) //is directory
172 pm = Resource::loadPixmap( "lockedfolder" ); 178 pm = Resource::loadPixmap( "lockedfolder" );
173 else 179 else
174 pm= Resource::loadPixmap( "folder" ); 180 pm= Resource::loadPixmap( "folder" );
175 } 181 }
176 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) 182 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
177 { 183 {
178 pm = Resource::loadPixmap( "exec"); 184 pm = Resource::loadPixmap( "exec");
179 } 185 }
180 else if( (fileInfo.permission( QFileInfo::ExeUser) 186 else if( (fileInfo.permission( QFileInfo::ExeUser)
181 | fileInfo.permission( QFileInfo::ExeGroup) 187 | fileInfo.permission( QFileInfo::ExeGroup)
182 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) 188 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
183 { 189 {
184 pm = Resource::loadPixmap( "exec"); 190 pm = Resource::loadPixmap( "exec");
185 } 191 }
186 else if( !fi->isReadable() ) 192 else if( !fi->isReadable() )
187 { 193 {
188 pm = Resource::loadPixmap( "locked" ); 194 pm = Resource::loadPixmap( "locked" );
189 } 195 }
190 else { //everything else goes by mimetype 196 else { //everything else goes by mimetype
191 MimeType mt(fi->filePath()); 197 MimeType mt(fi->filePath());
192 pm=mt.pixmap(); //sets the correct pixmap for mimetype 198 pm=mt.pixmap(); //sets the correct pixmap for mimetype
193 if(pm.isNull()) 199 if(pm.isNull()) {
194 pm = Resource::loadPixmap( "UnknownDocument-14" ); 200 pm = unknownXpm;
195 } 201 }
196 item->setPixmap( 0,pm); 202 }
197 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) 203 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
198 { 204 {
199 // overlay link image 205 // overlay link image
200 pm= Resource::loadPixmap( "folder" ); 206 pm= Resource::loadPixmap( "folder" );
201 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 207 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
202 QPainter painter( &pm ); 208 QPainter painter( &pm );
203 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 209 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
204 pm.setMask( pm.createHeuristicMask( FALSE ) ); 210 pm.setMask( pm.createHeuristicMask( FALSE ) );
205 item->setPixmap( 0, pm); 211 }
206 } 212 item->setPixmap( 0,pm);
207 } 213
208 isDir=FALSE; 214 }
209 ++it; 215 isDir=FALSE;
210 } 216 ++it;
217 }
211 218
212 if( path.find("dev",0,TRUE) != -1) 219 if( path.find("dev",0,TRUE) != -1)
213 { 220 {
214 struct stat buf; 221 struct stat buf;
215 dev_t devT; 222 dev_t devT;
216 DIR *dir; 223 DIR *dir;
217 struct dirent *mydirent; 224 struct dirent *mydirent;
218 225
219 if((dir = opendir( path.latin1())) != NULL) 226 if((dir = opendir( path.latin1())) != NULL)
220 while ((mydirent = readdir(dir)) != NULL) 227 while ((mydirent = readdir(dir)) != NULL)
221 { 228 {
222 lstat( mydirent->d_name, &buf); 229 lstat( mydirent->d_name, &buf);
223// qDebug(mydirent->d_name); 230// qDebug(mydirent->d_name);
224 fileL.sprintf("%s", mydirent->d_name); 231 fileL.sprintf("%s", mydirent->d_name);
225 devT = buf.st_dev; 232 devT = buf.st_dev;
226 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 233 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
227 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 234 fileDate.sprintf("%s", ctime( &buf.st_mtime));
228 if( fileL.find(".") == -1 ) 235 if( fileL.find(".") == -1 )
229 { 236 {
230 item= new QListViewItem( thisView, fileL, fileS, fileDate); 237 item= new QListViewItem( thisView, fileL, fileS, fileDate);
231 pm = Resource::loadPixmap( "UnknownDocument-14" ); 238 pm = unknownXpm;
232 item->setPixmap( 0,pm); 239 item->setPixmap( 0,pm);
233 } 240 }
234 } 241 }
235 242
236 closedir(dir); 243 closedir(dir);
237 } 244 }
238 245
239 thisView->setSorting( 3,FALSE); 246 thisView->setSorting( 3,FALSE);
240 fillCombo( (const QString &) path ); 247 fillCombo( (const QString &) path );
241} 248}
242 249
243void AdvancedFm::rePopulate() 250void AdvancedFm::rePopulate()
244{ 251{
245 int tmpTab = whichTab; 252 int tmpTab = whichTab;
246 qDebug("%d", tmpTab); 253 qDebug("%d", tmpTab);
247 254
248 for(int i =1; i < 3; i++) 255 for(int i =1; i < 3; i++)
249 { 256 {
250 TabWidget->setCurrentTab(i - 1); 257 TabWidget->setCurrentTab(i - 1);
251 populateView(); 258 populateView();
252 } 259 }
253 TabWidget->setCurrentTab( tmpTab - 1); 260 TabWidget->setCurrentTab( tmpTab - 1);
254} 261}
255 262
256void AdvancedFm::ListClicked(QListViewItem *selectedItem) 263void AdvancedFm::ListClicked(QListViewItem *selectedItem)
257{ 264{
258 if(selectedItem) 265 if(selectedItem)
259 { 266 {
260 QString strItem=selectedItem->text(0); 267 QString strItem=selectedItem->text(0);
261 QString strSize=selectedItem->text(1); 268 QString strSize=selectedItem->text(1);
262 strSize=strSize.stripWhiteSpace(); 269 strSize=strSize.stripWhiteSpace();
263 bool isDirectory = false; 270 bool isDirectory = false;
264 QString strItem2; 271 QString strItem2;
265 272
266 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink 273 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink
267 { 274 {
268 strItem2 = dealWithSymName((const QString&)strItem); 275 strItem2 = dealWithSymName((const QString&)strItem);
269 if(QDir(strItem2).exists() ) 276 if(QDir(strItem2).exists() )
270 strItem = strItem2; 277 strItem = strItem2;
271 } 278 }
272 279
273 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) 280 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 )
274 { 281 {
275 282
276 if(QDir(strItem).exists()) 283 if(QDir(strItem).exists())
277 isDirectory = true; 284 isDirectory = true;
278 } 285 }
279 286
280 if( isDirectory ) 287 if( isDirectory )
281 { 288 {
282 CurrentDir()->cd( strItem, TRUE); 289 CurrentDir()->cd( strItem, TRUE);
283 populateView(); 290 populateView();
284 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 291 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
285 } 292 }
286 chdir( strItem.latin1()); 293 chdir( strItem.latin1());
287 } 294 }
288} 295}
289 296
290void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 297void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
291 switch (mouse) { 298 switch (mouse) {
292 case 1: 299 case 1:
293 { 300 {
294 if(renameBox != 0 ) 301 if(renameBox != 0 )
295 { 302 {
296 cancelRename(); 303 cancelRename();
297 } 304 }
298 } 305 }
299 break; 306 break;
300 case 2: 307 case 2:
301 menuTimer.start( 500, TRUE ); 308 menuTimer.start( 500, TRUE );
302 break; 309 break;
303 }; 310 };
304} 311}
305 312
306void AdvancedFm::switchToLocalTab() 313void AdvancedFm::switchToLocalTab()
307{ 314{
308 TabWidget->setCurrentTab(0); 315 TabWidget->setCurrentTab(0);
309 Local_View->setFocus(); 316 Local_View->setFocus();
310} 317}
311 318
312void AdvancedFm::switchToRemoteTab() 319void AdvancedFm::switchToRemoteTab()
313{ 320{
314 TabWidget->setCurrentTab(1); 321 TabWidget->setCurrentTab(1);
315 Remote_View->setFocus(); 322 Remote_View->setFocus();
316} 323}
317 324
318void AdvancedFm::readConfig() 325void AdvancedFm::readConfig()
319{ 326{
320 Config cfg("AdvancedFm"); 327 Config cfg("AdvancedFm");
321} 328}
322 329
323void AdvancedFm::writeConfig() 330void AdvancedFm::writeConfig()
324{ 331{
325 Config cfg("AdvancedFm"); 332 Config cfg("AdvancedFm");
326} 333}
327 334
328void AdvancedFm::currentPathComboChanged() 335void AdvancedFm::currentPathComboChanged()
329{ 336{
330 if(QDir( currentPathCombo->lineEdit()->text()).exists()) 337 if(QDir( currentPathCombo->lineEdit()->text()).exists())
331 { 338 {
332 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 339 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
333 populateView(); 340 populateView();
334 } 341 }
335 else 342 else
336 { 343 {
337 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 344 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
338 } 345 }
339} 346}
340 347
341void AdvancedFm::fillCombo(const QString &currentPath) 348void AdvancedFm::fillCombo(const QString &currentPath)
342{ 349{
343// qDebug("%d",TabWidget->getCurrentTab()); 350// qDebug("%d",TabWidget->getCurrentTab());
344 if ( whichTab == 1) 351 if ( whichTab == 1)
345 { 352 {
346 currentPathCombo->lineEdit()->setText( currentPath); 353 currentPathCombo->lineEdit()->setText( currentPath);
347 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 354 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() )
348 { 355 {
349 currentPathCombo->clear(); 356 currentPathCombo->clear();
350 localDirPathStringList.prepend( currentPath ); 357 localDirPathStringList.prepend( currentPath );
351 currentPathCombo->insertStringList( localDirPathStringList,-1); 358 currentPathCombo->insertStringList( localDirPathStringList,-1);
352 } 359 }
353 } 360 }
354 else 361 else
355 { 362 {
356 currentPathCombo->lineEdit()->setText( currentPath); 363 currentPathCombo->lineEdit()->setText( currentPath);
357 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 364 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() )
358 { 365 {
359 currentPathCombo->clear(); 366 currentPathCombo->clear();
360 remoteDirPathStringList.prepend( currentPath ); 367 remoteDirPathStringList.prepend( currentPath );
361 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 368 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
362 } 369 }
363 } 370 }
364} 371}
365 372
366void AdvancedFm::currentPathComboActivated(const QString & currentPath) 373void AdvancedFm::currentPathComboActivated(const QString & currentPath)
367{ 374{
368 chdir( currentPath.latin1() ); 375 chdir( currentPath.latin1() );
369 CurrentDir()->cd( currentPath, TRUE); 376 CurrentDir()->cd( currentPath, TRUE);
370 populateView(); 377 populateView();
371 update(); 378 update();
372} 379}
373 380
374QStringList AdvancedFm::getPath() 381QStringList AdvancedFm::getPath()
375{ 382{
376 QStringList strList; 383 QStringList strList;
377 QListView *thisView=CurrentView(); 384 QListView *thisView=CurrentView();
378 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 385 QList<QListViewItem> * getSelectedItems( QListView * thisView );
379 QListViewItemIterator it( thisView ); 386 QListViewItemIterator it( thisView );
380 for ( ; it.current(); ++it ) 387 for ( ; it.current(); ++it )
381 { 388 {
382 if ( it.current()->isSelected() ) 389 if ( it.current()->isSelected() )
383 { 390 {
384 strList << it.current()->text(0); 391 strList << it.current()->text(0);
385// qDebug(it.current()->text(0)); 392// qDebug(it.current()->text(0));
386 } 393 }
387 } 394 }
388 return strList; 395 return strList;
389} 396}
390 397
391void AdvancedFm::homeButtonPushed() 398void AdvancedFm::homeButtonPushed()
392{ 399{
393 QString current = QDir::homeDirPath(); 400 QString current = QDir::homeDirPath();
394 chdir( current.latin1() ); 401 chdir( current.latin1() );
395 CurrentDir()->cd( current, TRUE); 402 CurrentDir()->cd( current, TRUE);
396 populateView(); 403 populateView();
397 update(); 404 update();
398} 405}
399 406
400void AdvancedFm::docButtonPushed() 407void AdvancedFm::docButtonPushed()
401{ 408{
402 QString current = QPEApplication::documentDir(); 409 QString current = QPEApplication::documentDir();
403 chdir( current.latin1() ); 410 chdir( current.latin1() );
404 CurrentDir()->cd( current, TRUE); 411 CurrentDir()->cd( current, TRUE);
405 populateView(); 412 populateView();
406 update(); 413 update();
407} 414}
408 415
409void AdvancedFm::SDButtonPushed() 416void AdvancedFm::SDButtonPushed()
410{ 417{
411 QString current = "/mnt/card";// this can change so fix 418 QString current = "/mnt/card";// this can change so fix
412 chdir( current.latin1() ); 419 chdir( current.latin1() );
413 CurrentDir()->cd( current, TRUE); 420 CurrentDir()->cd( current, TRUE);
414 populateView(); 421 populateView();
415 update(); 422 update();
416} 423}
417 424
418void AdvancedFm::CFButtonPushed() 425void AdvancedFm::CFButtonPushed()
419{ 426{
420 QString current; 427 QString current;
421 if(zaurusDevice) 428 if(zaurusDevice)
422 current= "/mnt/cf"; //zaurus 429 current= "/mnt/cf"; //zaurus
423 else 430 else
424 current = "/mnt/hda"; //ipaq 431 current = "/mnt/hda"; //ipaq
425 chdir( current.latin1() ); 432 chdir( current.latin1() );
426 CurrentDir()->cd( current, TRUE); 433 CurrentDir()->cd( current, TRUE);
427 populateView(); 434 populateView();
428 update(); 435 update();
429} 436}
430 437
431 438
432void AdvancedFm::doAbout() 439void AdvancedFm::doAbout()
433{ 440{
434 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 441 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
435 "is copyright 2002-2003 by\n" 442 "is copyright 2002-2003 by\n"
436 "L.J.Potter<llornkcor@handhelds.org>\n" 443 "L.J.Potter<llornkcor@handhelds.org>\n"
437 "and is licensed by the GPL")); 444 "and is licensed by the GPL"));
438} 445}
439 446
440void AdvancedFm::keyPressEvent( QKeyEvent *e) 447void AdvancedFm::keyPressEvent( QKeyEvent *e)
441{ 448{
442// e->accept(); 449// e->accept();
443 if( CurrentView()->hasFocus() ) 450 if( CurrentView()->hasFocus() )
444 { 451 {
445 switch ( e->key() ) { 452 switch ( e->key() ) {
446 case Key_Delete: 453 case Key_Delete:
447 del(); 454 del();
448 break; 455 break;
449 case Key_A: 456 case Key_A:
450 copyAs(); 457 copyAs();
451 break; 458 break;
452 case Key_C: 459 case Key_C:
453 copy(); 460 copy();
454 break; 461 break;
455 case Key_E: 462 case Key_E:
456 runThis(); 463 runThis();
457 break; 464 break;
458 case Key_G: 465 case Key_G:
459 { 466 {
460 currentPathCombo->lineEdit()->setFocus(); 467 currentPathCombo->lineEdit()->setFocus();
461 } 468 }
462 break; 469 break;
463 470
464 case Key_H: 471 case Key_H:
465 showHidden(); 472 showHidden();
466 break; 473 break;
467 case Key_I: 474 case Key_I:
468 fileStatus(); 475 fileStatus();
469 break; 476 break;
470 case Key_M: 477 case Key_M:
471 move(); 478 move();
472 break; 479 break;
473 case Key_N: 480 case Key_N:
474 mkDir(); 481 mkDir();
475 break; 482 break;
476 case Key_P: 483 case Key_P:
477 filePerms(); 484 filePerms();
478 break; 485 break;
479 case Key_R: 486 case Key_R:
480 rn(); 487 rn();
481 break; 488 break;
482 case Key_U: 489 case Key_U:
483 upDir(); 490 upDir();
484 break; 491 break;
485 case Key_1: 492 case Key_1:
486 switchToLocalTab(); 493 switchToLocalTab();
487 break; 494 break;
488 case Key_2: 495 case Key_2:
489 switchToRemoteTab(); 496 switchToRemoteTab();
490 break; 497 break;
491 case Key_3: 498 case Key_3:
492 CFButtonPushed(); 499 CFButtonPushed();
493 break; 500 break;
494 case Key_4: 501 case Key_4:
495 SDButtonPushed(); 502 SDButtonPushed();
496 break; 503 break;
497 case Key_5: 504 case Key_5:
498 homeButtonPushed(); 505 homeButtonPushed();
499 break; 506 break;
500 case Key_6: 507 case Key_6:
501 docButtonPushed(); 508 docButtonPushed();
502 break; 509 break;
503 case Key_7: 510 case Key_7:
504 break; 511 break;
505 case Key_8: 512 case Key_8:
506 break; 513 break;
507 case Key_9: 514 case Key_9:
508 break; 515 break;
509 case Key_0: 516 case Key_0:
510 break; 517 break;
511 }; 518 };
512 e->accept(); 519 e->accept();
513 } 520 }
514} 521}
515 522
516void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 523void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
517{ 524{
518 if( CurrentView()->hasFocus() ) 525 if( CurrentView()->hasFocus() )
519 e->ignore(); 526 e->ignore();
520} 527}
521 528
522 529
523void AdvancedFm::QPEButtonPushed() 530void AdvancedFm::QPEButtonPushed()
524{ 531{
525 QString current = QPEApplication::qpeDir(); 532 QString current = QPEApplication::qpeDir();
526 chdir( current.latin1() ); 533 chdir( current.latin1() );
527 CurrentDir()->cd( current, TRUE); 534 CurrentDir()->cd( current, TRUE);
528 populateView(); 535 populateView();
529 update(); 536 update();
530} 537}
531 538
532void AdvancedFm::parsetab(const QString &fileName) 539void AdvancedFm::parsetab(const QString &fileName)
533{ 540{
534 541
535 fileSystemTypeList.clear(); 542 fileSystemTypeList.clear();
536 fsList.clear(); 543 fsList.clear();
537 struct mntent *me; 544 struct mntent *me;
538 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 545 FILE *mntfp = setmntent( fileName.latin1(), "r" );
539 if ( mntfp ) 546 if ( mntfp )
540 { 547 {
541 while ( (me = getmntent( mntfp )) != 0 ) 548 while ( (me = getmntent( mntfp )) != 0 )
542 { 549 {
543 QString deviceName = me->mnt_fsname; 550 QString deviceName = me->mnt_fsname;
544 QString filesystemType = me->mnt_type; 551 QString filesystemType = me->mnt_type;
545 QString mountDir = me->mnt_dir; 552 QString mountDir = me->mnt_dir;
546 if(deviceName != "none") 553 if(deviceName != "none")
547 { 554 {
548 if( fsList.contains(filesystemType) == 0 555 if( fsList.contains(filesystemType) == 0
549 & filesystemType.find("proc",0,TRUE) == -1 556 & filesystemType.find("proc",0,TRUE) == -1
550 & filesystemType.find("cramfs",0,TRUE) == -1 557 & filesystemType.find("cramfs",0,TRUE) == -1
551 & filesystemType.find("auto",0,TRUE) == -1) 558 & filesystemType.find("auto",0,TRUE) == -1)
552 fsList << filesystemType; 559 fsList << filesystemType;
553 fileSystemTypeList << mountDir+"::"+filesystemType; 560 fileSystemTypeList << mountDir+"::"+filesystemType;
554 } 561 }
555 } 562 }
556 } 563 }
557 endmntent( mntfp ); 564 endmntent( mntfp );
558} 565}
559 566
560QString AdvancedFm::getFileSystemType(const QString &currentText) 567QString AdvancedFm::getFileSystemType(const QString &currentText)
561{ 568{
562 parsetab("/etc/mtab"); //why did TT forget filesystem type? 569 parsetab("/etc/mtab"); //why did TT forget filesystem type?
563 QString current = currentText;//.right( currentText.length()-1); 570 QString current = currentText;//.right( currentText.length()-1);
564 QString baseFs; 571 QString baseFs;
565 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 572 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
566 QString temp = (*it); 573 QString temp = (*it);
567 QString path = temp.left(temp.find("::",0,TRUE) ); 574 QString path = temp.left(temp.find("::",0,TRUE) );
568 path = path.right( path.length()-1); 575 path = path.right( path.length()-1);
569 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 576 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
570 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 577 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
571 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 578 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
572 } 579 }
573 } 580 }
574 return baseFs; 581 return baseFs;
575} 582}
576 583
577QString AdvancedFm::getDiskSpace( const QString &path) 584QString AdvancedFm::getDiskSpace( const QString &path)
578{ 585{
579 struct statfs fss; 586 struct statfs fss;
580 if ( !statfs( path.latin1(), &fss ) ) { 587 if ( !statfs( path.latin1(), &fss ) ) {
581 int blkSize = fss.f_bsize; 588 int blkSize = fss.f_bsize;
582 // int totalBlks = fs.f_blocks; 589 // int totalBlks = fs.f_blocks;
583 int availBlks = fss.f_bavail; 590 int availBlks = fss.f_bavail;
584 591
585 long mult = blkSize / 1024; 592 long mult = blkSize / 1024;
586 long div = 1024 / blkSize; 593 long div = 1024 / blkSize;
587 if ( !mult ) mult = 1; 594 if ( !mult ) mult = 1;
588 if ( !div ) div = 1; 595 if ( !div ) div = 1;
589 596
590 return QString::number(availBlks * mult / div); 597 return QString::number(availBlks * mult / div);
591 } 598 }
592 return ""; 599 return "";
593} 600}
594 601
595 602
596void AdvancedFm::showFileMenu() 603void AdvancedFm::showFileMenu()
597{ 604{
598 QString curApp; 605 QString curApp;
599 curApp = CurrentView()->currentItem()->text(0); 606 curApp = CurrentView()->currentItem()->text(0);
600 607
601 MimeType mt( curApp ); 608 MimeType mt( curApp );
602 const AppLnk* app = mt.application(); 609 const AppLnk* app = mt.application();
603 QFile fi(curApp); 610 QFile fi(curApp);
604 QPopupMenu *m = new QPopupMenu(0); 611 QPopupMenu *m = new QPopupMenu(0);
605 QPopupMenu *n = new QPopupMenu(0); 612 QPopupMenu *n = new QPopupMenu(0);
606 // QPopupMenu *o = new QPopupMenu(0); 613 // QPopupMenu *o = new QPopupMenu(0);
607 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 614 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
608 615
609 if ( QFileInfo(fi).isDir() ) 616 if ( QFileInfo(fi).isDir() )
610 { 617 {
611 m->insertSeparator(); 618 m->insertSeparator();
612 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); 619 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
613 } 620 }
614 else 621 else
615 { 622 {
616 623
617 if ( app ) 624 if ( app )
618 m->insertItem( app->pixmap(), tr( "Open in " 625 m->insertItem( app->pixmap(), tr( "Open in "
619 + app->name() ), this, SLOT( runThis() ) ); 626 + app->name() ), this, SLOT( runThis() ) );
620 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 627 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
621 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 628 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
622 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 629 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
623 } 630 }
624 631
625 m->insertItem(tr("Actions"),n); 632 m->insertItem(tr("Actions"),n);
626 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); 633 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
627 634
628 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 635 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
629 636
630 n->insertSeparator(); 637 n->insertSeparator();
631 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); 638 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
632 639
633 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 640 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
634 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 641 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
635 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 642 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
636 n->insertItem( tr( "Move" ), this, SLOT( move() )); 643 n->insertItem( tr( "Move" ), this, SLOT( move() ));
637 644
638 n->insertSeparator(); 645 n->insertSeparator();
639 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); 646 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
640 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 647 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
641 648
642 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 649 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
643 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 650 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
644 651
645 m->insertSeparator(); 652 m->insertSeparator();
646 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 653 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
647 654
648#if defined(QT_QWS_OPIE) 655#if defined(QT_QWS_OPIE)
649 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 656 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
650#endif 657#endif
651 m->setCheckable(TRUE); 658 m->setCheckable(TRUE);
652 if (!b) 659 if (!b)
653 m->setItemChecked(m->idAt(0),TRUE); 660 m->setItemChecked(m->idAt(0),TRUE);
654 else 661 else
655 m->setItemChecked(m->idAt(0),FALSE); 662 m->setItemChecked(m->idAt(0),FALSE);
656 663
657 if(Ir::supported()) 664 if(Ir::supported())
658 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 665 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
659 m->setFocus(); 666 m->setFocus();
660 m->exec( QPoint( 4,QCursor::pos().y()) ); 667 m->exec( QPoint( 4,QCursor::pos().y()) );
661 668
662 if(m) delete m; 669 if(m) delete m;
663} 670}
664 671
665 672
666void AdvancedFm::cancelMenuTimer() 673void AdvancedFm::cancelMenuTimer()
667{ 674{
668// qDebug("selectionChanged: cancel menu timer"); 675// qDebug("selectionChanged: cancel menu timer");
669 if( menuTimer.isActive() ) 676 if( menuTimer.isActive() )
670 menuTimer.stop(); 677 menuTimer.stop();
671} 678}
672 679
673QString AdvancedFm::checkDiskSpace(const QString &path) 680QString AdvancedFm::checkDiskSpace(const QString &path)
674{ 681{
675 struct statfs fss; 682 struct statfs fss;
676 if ( !statfs( path.latin1(), &fss ) ) 683 if ( !statfs( path.latin1(), &fss ) )
677 { 684 {
678 int blkSize = fss.f_bsize; 685 int blkSize = fss.f_bsize;
679// int totalBlks = fs.f_blocks; 686// int totalBlks = fs.f_blocks;
680 int availBlks = fss.f_bavail; 687 int availBlks = fss.f_bavail;
681 688
682 long mult = blkSize / 1024; 689 long mult = blkSize / 1024;
683 long div = 1024 / blkSize; 690 long div = 1024 / blkSize;
684 if ( !mult ) mult = 1; 691 if ( !mult ) mult = 1;
685 if ( !div ) div = 1; 692 if ( !div ) div = 1;
686 693
687 694
688 return QString::number(availBlks * mult / div); 695 return QString::number(availBlks * mult / div);
689 } 696 }
690 return ""; 697 return "";
691} 698}
692 699
693void AdvancedFm::addToDocs() 700void AdvancedFm::addToDocs()
694{ 701{
695 QStringList strListPaths = getPath(); 702 QStringList strListPaths = getPath();
696 QDir *thisDir = CurrentDir(); 703 QDir *thisDir = CurrentDir();
697 704
698 if( strListPaths.count() > 0) 705 if( strListPaths.count() > 0)
699 { 706 {
700 QString curFile; 707 QString curFile;
701 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) 708 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it )
702 { 709 {
703 curFile = thisDir->canonicalPath()+"/"+(*it); 710 curFile = thisDir->canonicalPath()+"/"+(*it);
704// qDebug(curFile); 711// qDebug(curFile);
705 DocLnk f; 712 DocLnk f;
706// curFile.replace(QRegExp("\\..*"),""); 713// curFile.replace(QRegExp("\\..*"),"");
707 f.setName((*it)); 714 f.setName((*it));
708 f.setFile( curFile); 715 f.setFile( curFile);
709 f.writeLink(); 716 f.writeLink();
710 } 717 }
711 } 718 }
712} 719}
713 720
714 721
715void AdvancedFm::customDirsToMenu() 722void AdvancedFm::customDirsToMenu()
716{ 723{
717 724
718 Config cfg("AdvancedFm"); 725 Config cfg("AdvancedFm");
719 cfg.setGroup("Menu"); 726 cfg.setGroup("Menu");
720 727
721 QStringList list = cfg.readListEntry( "CustomDir", ','); 728 QStringList list = cfg.readListEntry( "CustomDir", ',');
722 menuButton->insertItems(list ); 729 menuButton->insertItems(list );
723 730
724// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 731// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
725// { 732// {
726// customDirMenu->insertItem(*it ); 733// customDirMenu->insertItem(*it );
727// } 734// }
728} 735}
729 736
730void AdvancedFm::dirMenuSelected(int item) 737void AdvancedFm::dirMenuSelected(int item)
731{ 738{
732 qDebug("menu item %d", item); 739 qDebug("menu item %d", item);
733 switch(item) 740 switch(item)
734 { 741 {
735 742
736 case -21: 743 case -21:
737 case 0: 744 case 0:
738 addCustomDir(); 745 addCustomDir();
739 break; 746 break;
740 case -22: 747 case -22:
741 case 1: 748 case 1:
742 removeCustomDir(); 749 removeCustomDir();
743 break; 750 break;
744 default: 751 default:
745 { 752 {
746// gotoCustomDir( menuButton->text(item)); 753// gotoCustomDir( menuButton->text(item));
747// gotoCustomDir( customDirMenu->text(item)); 754// gotoCustomDir( customDirMenu->text(item));
748 } 755 }
749 break; 756 break;
750 757
751 }; 758 };
752} 759}
753 760
754void AdvancedFm::addCustomDir() 761void AdvancedFm::addCustomDir()
755{ 762{
756 Config cfg("AdvancedFm"); 763 Config cfg("AdvancedFm");
757 cfg.setGroup("Menu"); 764 cfg.setGroup("Menu");
758 QString dir; 765 QString dir;
759 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 766 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
760 767
761 dir = CurrentDir()->canonicalPath(); 768 dir = CurrentDir()->canonicalPath();
762 769
763 bool addIt=true; 770 bool addIt=true;
764 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 771 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
765 { 772 {
766 if( dir == (*it)) 773 if( dir == (*it))
767 { 774 {
768 addIt=false; 775 addIt=false;
769 } 776 }
770 } 777 }
771 if(addIt) 778 if(addIt)
772 { 779 {
773 menuButton->insertItem(dir); 780 menuButton->insertItem(dir);
774// customDirMenu->insertItem(dir); 781// customDirMenu->insertItem(dir);
775 list << dir; 782 list << dir;
776 } 783 }
777 784
778 cfg.writeEntry("CustomDir", list, ','); 785 cfg.writeEntry("CustomDir", list, ',');
779 cfg.write(); 786 cfg.write();
780} 787}
781 788
782void AdvancedFm::removeCustomDir() 789void AdvancedFm::removeCustomDir()
783{ 790{
784// qDebug("remove custom dir"); 791// qDebug("remove custom dir");
785 Config cfg("AdvancedFm"); 792 Config cfg("AdvancedFm");
786 cfg.setGroup("Menu"); 793 cfg.setGroup("Menu");
787 QString dir; 794 QString dir;
788 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 795 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
789 QStringList list2; 796 QStringList list2;
790 dir = CurrentDir()->canonicalPath(); 797 dir = CurrentDir()->canonicalPath();
791 int ramble=2; 798 int ramble=2;
792// int ramble=-24; 799// int ramble=-24;
793//first remove list 800//first remove list
794 if(list.grep(dir,true).isEmpty()) 801 if(list.grep(dir,true).isEmpty())
795 { 802 {
796 QMessageBox::message("AdvancedFm", 803 QMessageBox::message("AdvancedFm",
797 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); 804 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!"));
798 } 805 }
799 else 806 else
800 { 807 {
801 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 808 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
802 { 809 {
803 if((*it) != dir)//current item is not our current dir, so add it to temp list 810 if((*it) != dir)//current item is not our current dir, so add it to temp list
804 { 811 {
805 list2 <<(*it); 812 list2 <<(*it);
806 } 813 }
807 else 814 else
808 { 815 {
809// customDirMenu->removeItem( ramble); 816// customDirMenu->removeItem( ramble);
810 menuButton->remove( ramble); 817 menuButton->remove( ramble);
811 818
812 } 819 }
813 ramble++; 820 ramble++;
814// ramble--; 821// ramble--;
815 } 822 }
816 823
817 cfg.writeEntry("CustomDir", list2, ','); 824 cfg.writeEntry("CustomDir", list2, ',');
818 cfg.write(); 825 cfg.write();
819 } 826 }
820// customDirsToMenu(); 827// customDirsToMenu();
821 828
822} 829}
823 830
824void AdvancedFm::gotoCustomDir(const QString &dir) 831void AdvancedFm::gotoCustomDir(const QString &dir)
825{ 832{
826// qDebug("gotoCustomDir(const QString &dir) " +dir ); 833// qDebug("gotoCustomDir(const QString &dir) " +dir );
827 QString curDir = dir; 834 QString curDir = dir;
828 QDir *thisDir = CurrentDir(); 835 QDir *thisDir = CurrentDir();
829// if( curDir.isEmpty()) { 836// if( curDir.isEmpty()) {
830// } 837// }
831 if( curDir == s_addBookmark) 838 if( curDir == s_addBookmark)
832 { 839 {
833 addCustomDir(); 840 addCustomDir();
834 } 841 }
835 if( curDir == s_removeBookmark) 842 if( curDir == s_removeBookmark)
836 { 843 {
837 removeCustomDir( ); 844 removeCustomDir( );
838 } 845 }
839 else 846 else
840 { 847 {
841 if(QDir( curDir).exists() ) 848 if(QDir( curDir).exists() )
842 { 849 {
843 thisDir->setPath( curDir ); 850 thisDir->setPath( curDir );
844 chdir( curDir.latin1() ); 851 chdir( curDir.latin1() );
845 thisDir->cd( curDir, TRUE); 852 thisDir->cd( curDir, TRUE);
846 populateView(); 853 populateView();
847 } 854 }
848 } 855 }
849} 856}
850 857
851QDir *AdvancedFm::CurrentDir() 858QDir *AdvancedFm::CurrentDir()
852{ 859{
853 if ( whichTab == 1) 860 if ( whichTab == 1)
854 { 861 {
855 return &currentDir; 862 return &currentDir;
856 } 863 }
857 else 864 else
858 { 865 {
859 return &currentRemoteDir; 866 return &currentRemoteDir;
860 } 867 }
861} 868}
862 869
863QDir *AdvancedFm::OtherDir() 870QDir *AdvancedFm::OtherDir()
864{ 871{
865 if ( whichTab == 1) 872 if ( whichTab == 1)
866 { 873 {
867 return &currentRemoteDir; 874 return &currentRemoteDir;
868 } 875 }
869 else 876 else
870 { 877 {
871 return &currentDir; 878 return &currentDir;
872 } 879 }
873} 880}
874 881
875QListView * AdvancedFm::CurrentView() 882QListView * AdvancedFm::CurrentView()
876{ 883{
877 if ( whichTab == 1) 884 if ( whichTab == 1)
878 return Local_View; 885 return Local_View;
879 else 886 else
880 return Remote_View; 887 return Remote_View;
881} 888}
882 889
883QListView * AdvancedFm::OtherView() 890QListView * AdvancedFm::OtherView()
884{ 891{
885 if ( whichTab == 1) 892 if ( whichTab == 1)
886 return Remote_View; 893 return Remote_View;
887 else 894 else
888 return Local_View; 895 return Local_View;
889} 896}
890 897
891void AdvancedFm::setOtherTabCurrent() 898void AdvancedFm::setOtherTabCurrent()
892{ 899{
893 if ( whichTab == 1) 900 if ( whichTab == 1)
894 TabWidget->setCurrentTab(1); 901 TabWidget->setCurrentTab(1);
895 else 902 else
896 TabWidget->setCurrentTab(0); 903 TabWidget->setCurrentTab(0);
897} 904}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index f31956c..c30d8e0 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -1,172 +1,174 @@
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 <opie/oprocess.h> 18#include <opie/oprocess.h>
19#include <qpe/ir.h> 19#include <qpe/ir.h>
20 20
21#include <qvariant.h> 21#include <qvariant.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qstringlist.h> 24#include <qstringlist.h>
25#include <qdir.h> 25#include <qdir.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qpixmap.h>
29 30
30class OTabWidget; 31class OTabWidget;
31class QVBoxLayout; 32class QVBoxLayout;
32class QHBoxLayout; 33class QHBoxLayout;
33class QGridLayout; 34class QGridLayout;
34class QComboBox; 35class QComboBox;
35class QListView; 36class QListView;
36class QListviewItem; 37class QListviewItem;
37class QLabel; 38class QLabel;
38class QProgressBar; 39class QProgressBar;
39class QSpinBox; 40class QSpinBox;
40class QTabWidget; 41class QTabWidget;
41class QWidget; 42class QWidget;
42class QPEToolBar; 43class QPEToolBar;
43class QPEMenuBar; 44class QPEMenuBar;
44class QPopupMenu; 45class QPopupMenu;
45class QFile; 46class QFile;
46class QListViewItem; 47class QListViewItem;
47class QLineEdit; 48class QLineEdit;
48class MenuButton; 49class MenuButton;
49 50
50//class QPushButton; 51//class QPushButton;
51class QToolButton; 52class QToolButton;
52class Ir; 53class Ir;
53 54
54class AdvancedFm : public QMainWindow 55class AdvancedFm : public QMainWindow
55{ 56{
56 Q_OBJECT 57 Q_OBJECT
57public: 58public:
58 AdvancedFm(); 59 AdvancedFm();
59 ~AdvancedFm(); 60 ~AdvancedFm();
60protected slots: 61protected slots:
61 void selectAll(); 62 void selectAll();
62 void addToDocs(); 63 void addToDocs();
63 void doDirChange(); 64 void doDirChange();
64 void mkDir(); 65 void mkDir();
65 void del(); 66 void del();
66 void rn(); 67 void rn();
67 void populateView(); 68 void populateView();
68 void rePopulate(); 69 void rePopulate();
69 void showHidden(); 70 void showHidden();
70 void showMenuHidden(); 71 void showMenuHidden();
71 void writeConfig(); 72 void writeConfig();
72 void readConfig(); 73 void readConfig();
73 void ListClicked(QListViewItem *); 74 void ListClicked(QListViewItem *);
74 void ListPressed( int, QListViewItem *, const QPoint&, int); 75 void ListPressed( int, QListViewItem *, const QPoint&, int);
75 void makeDir(); 76 void makeDir();
76 void doDelete(); 77 void doDelete();
77 void tabChanged(QWidget*); 78 void tabChanged(QWidget*);
78 void cleanUp(); 79 void cleanUp();
79 void renameIt(); 80 void renameIt();
80 void runThis(); 81 void runThis();
81 void runText(); 82 void runText();
82 void filePerms(); 83 void filePerms();
83 void doProperties(); 84 void doProperties();
84 void runCommand(); 85 void runCommand();
85 void runCommandStd(); 86 void runCommandStd();
86 QStringList getPath(); 87 QStringList getPath();
87 void mkSym(); 88 void mkSym();
88 void switchToLocalTab(); 89 void switchToLocalTab();
89 void switchToRemoteTab(); 90 void switchToRemoteTab();
90 91
91protected: 92protected:
92 93
93 OTabWidget *TabWidget; 94 OTabWidget *TabWidget;
95 QPixmap unknownXpm;
94 int whichTab; 96 int whichTab;
95// QTabWidget *TabWidget; 97// QTabWidget *TabWidget;
96 QWidget *tab, *tab_2, *tab_3; 98 QWidget *tab, *tab_2, *tab_3;
97 QListView *Local_View, *Remote_View; 99 QListView *Local_View, *Remote_View;
98 100
99 QLineEdit *currentPathEdit; 101 QLineEdit *currentPathEdit;
100 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; 102 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/;
101 QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 103 QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
102// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 104// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
103 QDir currentDir, currentRemoteDir; 105 QDir currentDir, currentRemoteDir;
104 QComboBox *currentPathCombo; 106 QComboBox *currentPathCombo;
105 QString filterStr, s_addBookmark, s_removeBookmark; 107 QString filterStr, s_addBookmark, s_removeBookmark;
106 QListViewItem * item; 108 QListViewItem * item;
107 bool b; 109 bool b;
108 QStringList fileSystemTypeList, fsList; 110 QStringList fileSystemTypeList, fsList;
109 int currentServerConfig; 111 int currentServerConfig;
110 bool zaurusDevice; 112 bool zaurusDevice;
111 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 113 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
112 QStringList remoteDirPathStringList, localDirPathStringList; 114 QStringList remoteDirPathStringList, localDirPathStringList;
113 QLineEdit *renameBox; 115 QLineEdit *renameBox;
114 116
115 void init(); 117 void init();
116 void initConnections(); 118 void initConnections();
117 void keyReleaseEvent( QKeyEvent *); 119 void keyReleaseEvent( QKeyEvent *);
118 void keyPressEvent( QKeyEvent *); 120 void keyPressEvent( QKeyEvent *);
119 QString getFileSystemType(const QString &); 121 QString getFileSystemType(const QString &);
120 QString getDiskSpace(const QString &); 122 QString getDiskSpace(const QString &);
121 void parsetab(const QString &fileName); 123 void parsetab(const QString &fileName);
122 QString checkDiskSpace(const QString &); 124 QString checkDiskSpace(const QString &);
123 QString dealWithSymName(const QString &); 125 QString dealWithSymName(const QString &);
124 QDir *CurrentDir(); 126 QDir *CurrentDir();
125 QDir *OtherDir(); 127 QDir *OtherDir();
126 QListView *CurrentView(); 128 QListView *CurrentView();
127 QListView *OtherView(); 129 QListView *OtherView();
128 void setOtherTabCurrent(); 130 void setOtherTabCurrent();
129 131
130protected slots: 132protected slots:
131 void dirMenuSelected(int); 133 void dirMenuSelected(int);
132 void showFileMenu(); 134 void showFileMenu();
133 void cancelMenuTimer(); 135 void cancelMenuTimer();
134 void homeButtonPushed(); 136 void homeButtonPushed();
135 void docButtonPushed(); 137 void docButtonPushed();
136 void SDButtonPushed(); 138 void SDButtonPushed();
137 void CFButtonPushed(); 139 void CFButtonPushed();
138 void QPEButtonPushed(); 140 void QPEButtonPushed();
139 void upDir(); 141 void upDir();
140 void currentPathComboChanged(); 142 void currentPathComboChanged();
141 void copy(); 143 void copy();
142 void copyAs(); 144 void copyAs();
143 void copySameDir(); 145 void copySameDir();
144 void currentPathComboActivated(const QString &); 146 void currentPathComboActivated(const QString &);
145 void fillCombo(const QString &); 147 void fillCombo(const QString &);
146 bool copyFile( const QString & , const QString & ); 148 bool copyFile( const QString & , const QString & );
147 void move(); 149 void move();
148 void fileStatus(); 150 void fileStatus();
149 void doAbout(); 151 void doAbout();
150 void doBeam(); 152 void doBeam();
151 void fileBeamFinished( Ir *); 153 void fileBeamFinished( Ir *);
152 154
153private: 155private:
154 MenuButton *menuButton; 156 MenuButton *menuButton;
155 QString oldName; 157 QString oldName;
156 QTimer menuTimer; 158 QTimer menuTimer;
157 void startProcess(const QString &); 159 void startProcess(const QString &);
158 bool eventFilter( QObject * , QEvent * ); 160 bool eventFilter( QObject * , QEvent * );
159 void cancelRename(); 161 void cancelRename();
160 void doRename(QListView *); 162 void doRename(QListView *);
161 void okRename(); 163 void okRename();
162 void customDirsToMenu(); 164 void customDirsToMenu();
163 void addCustomDir(); 165 void addCustomDir();
164 void removeCustomDir(); 166 void removeCustomDir();
165 167
166private slots: 168private slots:
167 void processEnded(OProcess *); 169 void processEnded(OProcess *);
168 void oprocessStderr(OProcess *, char *, int); 170 void oprocessStderr(OProcess *, char *, int);
169 void gotoCustomDir(const QString &); 171 void gotoCustomDir(const QString &);
170}; 172};
171 173
172#endif // ADVANCEDFM_H 174#endif // ADVANCEDFM_H