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