summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 73d0d57..48332b7 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,826 +1,828 @@
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
371 371
372void AdvancedFm::doAbout() { 372void AdvancedFm::doAbout() {
373 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>")); 373 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>"));
374} 374}
375 375
376void AdvancedFm::keyPressEvent( QKeyEvent *e) { 376void AdvancedFm::keyPressEvent( QKeyEvent *e) {
377 qDebug("keypressevent");
378}
379
380void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
381 qDebug("key release");
382 if( CurrentView()->hasFocus() )
383 e->ignore();
377 if( e->key() == Key_Left ) 384 if( e->key() == Key_Left )
378 upDir(); 385 upDir();
379 else if( e->key() == Key_Return || e->key() == Key_Enter) 386 else if( e->key() == Key_Return || e->key() == Key_Enter)
380 navigateToSelected(); 387 navigateToSelected();
381 else if( e->key() == Key_Tab) 388 else if( e->key() == Key_Tab)
382 setOtherTabCurrent(); 389 setOtherTabCurrent();
383 else if( e->key() == Key_Delete ) 390 else if( e->key() == Key_Delete )
384 del(); 391 del();
385 else if( e->key() == Key_A) 392 else if( e->key() == Key_A)
386 copyAs(); 393 copyAs();
387 else if( e->key() == Key_C) 394 else if( e->key() == Key_C)
388 copy(); 395 copy();
389 else if( e->key() == Key_E) 396 else if( e->key() == Key_E)
390 runThis(); 397 runThis();
391 else if( e->key() == Key_G) 398 else if( e->key() == Key_G)
392 currentPathCombo->lineEdit()->setFocus(); 399 currentPathCombo->lineEdit()->setFocus();
393 else if( e->key() == Key_H ) 400 else if( e->key() == Key_H )
394 showHidden(); 401 showHidden();
395 else if( e->key() == Key_I) 402 else if( e->key() == Key_I)
396 fileStatus(); 403 fileStatus();
397 else if( e->key() == Key_M) 404 else if( e->key() == Key_M)
398 move(); 405 move();
399 else if( e->key() == Key_N ) 406 else if( e->key() == Key_N )
400 mkDir(); 407 mkDir();
401 else if( e->key() == Key_P) 408 else if( e->key() == Key_P)
402 filePerms(); 409 filePerms();
403 else if( e->key() == Key_R ) 410 else if( e->key() == Key_R )
404 rn(); 411 rn();
405 else if( e->key() == Key_U ) 412 else if( e->key() == Key_U )
406 upDir(); 413 upDir();
407 else if( e->key() == Key_1) 414 else if( e->key() == Key_1)
408 switchToLocalTab(); 415 switchToLocalTab();
409 else if( e->key() == Key_2) 416 else if( e->key() == Key_2)
410 switchToRemoteTab(); 417 switchToRemoteTab();
411 else if( e->key() == Key_3) 418 else if( e->key() == Key_3)
412 CFButtonPushed(); 419 CFButtonPushed();
413 else if( e->key() == Key_4) 420 else if( e->key() == Key_4)
414 SDButtonPushed(); 421 SDButtonPushed();
415 else if( e->key() == Key_5 ) 422 else if( e->key() == Key_5 )
416 homeButtonPushed(); 423 homeButtonPushed();
417 else if( e->key() == Key_6 ) 424 else if( e->key() == Key_6 )
418 docButtonPushed(); 425 docButtonPushed();
419 else 426 else
420 e->accept(); 427 e->accept();
421} 428}
422 429
423void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
424 if( CurrentView()->hasFocus() )
425 e->ignore();
426}
427
428 430
429void AdvancedFm::QPEButtonPushed() { 431void AdvancedFm::QPEButtonPushed() {
430 QString current = QPEApplication::qpeDir(); 432 QString current = QPEApplication::qpeDir();
431 chdir( current.latin1() ); 433 chdir( current.latin1() );
432 CurrentDir()->cd( current, TRUE); 434 CurrentDir()->cd( current, TRUE);
433 populateView(); 435 populateView();
434 update(); 436 update();
435} 437}
436 438
437void AdvancedFm::parsetab(const QString &fileName) { 439void AdvancedFm::parsetab(const QString &fileName) {
438 440
439 fileSystemTypeList.clear(); 441 fileSystemTypeList.clear();
440 fsList.clear(); 442 fsList.clear();
441 struct mntent *me; 443 struct mntent *me;
442 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 444 FILE *mntfp = setmntent( fileName.latin1(), "r" );
443 if ( mntfp ) { 445 if ( mntfp ) {
444 while ( (me = getmntent( mntfp )) != 0 ) { 446 while ( (me = getmntent( mntfp )) != 0 ) {
445 QString deviceName = me->mnt_fsname; 447 QString deviceName = me->mnt_fsname;
446 QString filesystemType = me->mnt_type; 448 QString filesystemType = me->mnt_type;
447 QString mountDir = me->mnt_dir; 449 QString mountDir = me->mnt_dir;
448 if(deviceName != "none") { 450 if(deviceName != "none") {
449 if( fsList.contains(filesystemType) == 0 451 if( fsList.contains(filesystemType) == 0
450 & filesystemType.find("proc",0,TRUE) == -1 452 & filesystemType.find("proc",0,TRUE) == -1
451 & filesystemType.find("cramfs",0,TRUE) == -1 453 & filesystemType.find("cramfs",0,TRUE) == -1
452 & filesystemType.find("auto",0,TRUE) == -1) 454 & filesystemType.find("auto",0,TRUE) == -1)
453 fsList << filesystemType; 455 fsList << filesystemType;
454 fileSystemTypeList << mountDir+"::"+filesystemType; 456 fileSystemTypeList << mountDir+"::"+filesystemType;
455 } 457 }
456 } 458 }
457 } 459 }
458 endmntent( mntfp ); 460 endmntent( mntfp );
459} 461}
460 462
461QString AdvancedFm::getFileSystemType(const QString &currentText) { 463QString AdvancedFm::getFileSystemType(const QString &currentText) {
462 parsetab("/etc/mtab"); //why did TT forget filesystem type? 464 parsetab("/etc/mtab"); //why did TT forget filesystem type?
463 QString current = currentText;//.right( currentText.length()-1); 465 QString current = currentText;//.right( currentText.length()-1);
464 QString baseFs; 466 QString baseFs;
465 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 467 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
466 QString temp = (*it); 468 QString temp = (*it);
467 QString path = temp.left(temp.find("::",0,TRUE) ); 469 QString path = temp.left(temp.find("::",0,TRUE) );
468 path = path.right( path.length()-1); 470 path = path.right( path.length()-1);
469 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 471 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
470 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 472 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
471 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 473 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
472 } 474 }
473 } 475 }
474 return baseFs; 476 return baseFs;
475} 477}
476 478
477QString AdvancedFm::getDiskSpace( const QString &path) { 479QString AdvancedFm::getDiskSpace( const QString &path) {
478 struct statfs fss; 480 struct statfs fss;
479 if ( !statfs( path.latin1(), &fss ) ) { 481 if ( !statfs( path.latin1(), &fss ) ) {
480 int blkSize = fss.f_bsize; 482 int blkSize = fss.f_bsize;
481 // int totalBlks = fs.f_blocks; 483 // int totalBlks = fs.f_blocks;
482 int availBlks = fss.f_bavail; 484 int availBlks = fss.f_bavail;
483 485
484 long mult = blkSize / 1024; 486 long mult = blkSize / 1024;
485 long div = 1024 / blkSize; 487 long div = 1024 / blkSize;
486 if ( !mult ) mult = 1; 488 if ( !mult ) mult = 1;
487 if ( !div ) div = 1; 489 if ( !div ) div = 1;
488 490
489 return QString::number(availBlks * mult / div); 491 return QString::number(availBlks * mult / div);
490 } 492 }
491 return ""; 493 return "";
492} 494}
493 495
494 496
495void AdvancedFm::showFileMenu() { 497void AdvancedFm::showFileMenu() {
496 QString curApp; 498 QString curApp;
497 curApp = CurrentView()->currentItem()->text(0); 499 curApp = CurrentView()->currentItem()->text(0);
498 500
499 MimeType mt(curApp); 501 MimeType mt(curApp);
500 const AppLnk* app = mt.application(); 502 const AppLnk* app = mt.application();
501 QFile fi(curApp); 503 QFile fi(curApp);
502 QPopupMenu *m = new QPopupMenu(0); 504 QPopupMenu *m = new QPopupMenu(0);
503 QPopupMenu *n = new QPopupMenu(0); 505 QPopupMenu *n = new QPopupMenu(0);
504 // QPopupMenu *o = new QPopupMenu(0); 506 // QPopupMenu *o = new QPopupMenu(0);
505 m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); 507 m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden()));
506 508
507 if ( QFileInfo(fi).isDir()) { 509 if ( QFileInfo(fi).isDir()) {
508 m->insertSeparator(); 510 m->insertSeparator();
509 m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); 511 m->insertItem(tr("Change Directory"),this,SLOT(doDirChange()));
510 } else { 512 } else {
511 513
512 if (app) 514 if (app)
513 m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); 515 m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis()));
514 else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 516 else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
515 m->insertItem(tr("Execute"),this,SLOT(runThis())); 517 m->insertItem(tr("Execute"),this,SLOT(runThis()));
516 m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); 518 m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText()));
517 } 519 }
518 520
519 m->insertItem(tr("Actions"),n); 521 m->insertItem(tr("Actions"),n);
520 n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); 522 n->insertItem(tr("Make Directory"),this,SLOT(makeDir()));
521 523
522 n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); 524 n->insertItem(tr("Make Symlink"),this,SLOT(mkSym()));
523 525
524 n->insertSeparator(); 526 n->insertSeparator();
525 n->insertItem(tr("Rename"),this,SLOT(renameIt())); 527 n->insertItem(tr("Rename"),this,SLOT(renameIt()));
526 528
527 n->insertItem(tr("Copy"),this,SLOT(copyTimer())); 529 n->insertItem(tr("Copy"),this,SLOT(copyTimer()));
528 n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); 530 n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer()));
529 n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); 531 n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer()));
530 n->insertItem(tr("Move"),this,SLOT(moveTimer())); 532 n->insertItem(tr("Move"),this,SLOT(moveTimer()));
531 533
532 n->insertSeparator(); 534 n->insertSeparator();
533 n->insertItem(tr("Delete"),this,SLOT(doDelete())); 535 n->insertItem(tr("Delete"),this,SLOT(doDelete()));
534 m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); 536 m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs()));
535 537
536 m->insertItem(tr("Run Command"),this,SLOT(runCommand())); 538 m->insertItem(tr("Run Command"),this,SLOT(runCommand()));
537 m->insertItem(tr("File Info"),this,SLOT(fileStatus())); 539 m->insertItem(tr("File Info"),this,SLOT(fileStatus()));
538 540
539 m->insertSeparator(); 541 m->insertSeparator();
540 m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); 542 m->insertItem(tr("Set Permissions"),this,SLOT(filePerms()));
541 543
542#if defined(QT_QWS_OPIE) 544#if defined(QT_QWS_OPIE)
543 m->insertItem(tr("Properties"),this,SLOT(doProperties())); 545 m->insertItem(tr("Properties"),this,SLOT(doProperties()));
544#endif 546#endif
545 m->setCheckable(TRUE); 547 m->setCheckable(TRUE);
546 if (!b) 548 if (!b)
547 m->setItemChecked(m->idAt(0),TRUE); 549 m->setItemChecked(m->idAt(0),TRUE);
548 else 550 else
549 m->setItemChecked(m->idAt(0),FALSE); 551 m->setItemChecked(m->idAt(0),FALSE);
550 552
551 if(Ir::supported()) 553 if(Ir::supported())
552 m->insertItem(tr("Beam File"),this,SLOT(doBeam())); 554 m->insertItem(tr("Beam File"),this,SLOT(doBeam()));
553 m->setFocus(); 555 m->setFocus();
554 556
555 m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); 557 m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y()));
556 558
557 if(m) delete m; 559 if(m) delete m;
558} 560}
559 561
560 562
561QString AdvancedFm::checkDiskSpace(const QString &path) { 563QString AdvancedFm::checkDiskSpace(const QString &path) {
562 struct statfs fss; 564 struct statfs fss;
563 if ( !statfs( path.latin1(), &fss ) ) { 565 if ( !statfs( path.latin1(), &fss ) ) {
564 int blkSize = fss.f_bsize; 566 int blkSize = fss.f_bsize;
565// int totalBlks = fs.f_blocks; 567// int totalBlks = fs.f_blocks;
566 int availBlks = fss.f_bavail; 568 int availBlks = fss.f_bavail;
567 569
568 long mult = blkSize / 1024; 570 long mult = blkSize / 1024;
569 long div = 1024 / blkSize; 571 long div = 1024 / blkSize;
570 if ( !mult ) mult = 1; 572 if ( !mult ) mult = 1;
571 if ( !div ) div = 1; 573 if ( !div ) div = 1;
572 574
573 575
574 return QString::number(availBlks * mult / div); 576 return QString::number(availBlks * mult / div);
575 } 577 }
576 return ""; 578 return "";
577} 579}
578 580
579void AdvancedFm::addToDocs() { 581void AdvancedFm::addToDocs() {
580 QStringList strListPaths = getPath(); 582 QStringList strListPaths = getPath();
581 QDir *thisDir = CurrentDir(); 583 QDir *thisDir = CurrentDir();
582 584
583 if( strListPaths.count() > 0) { 585 if( strListPaths.count() > 0) {
584 QString curFile; 586 QString curFile;
585 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 587 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
586 curFile = thisDir->canonicalPath()+"/"+(*it); 588 curFile = thisDir->canonicalPath()+"/"+(*it);
587// odebug << curFile << oendl; 589// odebug << curFile << oendl;
588 QFileInfo fi(curFile); 590 QFileInfo fi(curFile);
589 DocLnk f; 591 DocLnk f;
590// curFile.replace(QRegExp("\\..*"),""); 592// curFile.replace(QRegExp("\\..*"),"");
591 f.setName(fi.baseName() ); 593 f.setName(fi.baseName() );
592 f.setFile( curFile); 594 f.setFile( curFile);
593 f.writeLink(); 595 f.writeLink();
594 } 596 }
595 } 597 }
596} 598}
597 599
598 600
599void AdvancedFm::customDirsToMenu() { 601void AdvancedFm::customDirsToMenu() {
600 602
601 Config cfg("AdvancedFm"); 603 Config cfg("AdvancedFm");
602 cfg.setGroup("Menu"); 604 cfg.setGroup("Menu");
603 605
604 QStringList list = cfg.readListEntry( "CustomDir", ','); 606 QStringList list = cfg.readListEntry( "CustomDir", ',');
605 menuButton->insertItems(list ); 607 menuButton->insertItems(list );
606 608
607// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 609// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
608// { 610// {
609// customDirMenu->insertItem(*it ); 611// customDirMenu->insertItem(*it );
610// } 612// }
611} 613}
612 614
613void AdvancedFm::dirMenuSelected(int item) { 615void AdvancedFm::dirMenuSelected(int item) {
614 switch(item) 616 switch(item)
615 { 617 {
616 618
617 case -21: 619 case -21:
618 case 0: 620 case 0:
619 addCustomDir(); 621 addCustomDir();
620 break; 622 break;
621 case -22: 623 case -22:
622 case 1: 624 case 1:
623 removeCustomDir(); 625 removeCustomDir();
624 break; 626 break;
625 default: 627 default:
626 { 628 {
627// gotoCustomDir( menuButton->text(item)); 629// gotoCustomDir( menuButton->text(item));
628// gotoCustomDir( customDirMenu->text(item)); 630// gotoCustomDir( customDirMenu->text(item));
629 } 631 }
630 break; 632 break;
631 633
632 }; 634 };
633} 635}
634 636
635void AdvancedFm::addCustomDir() { 637void AdvancedFm::addCustomDir() {
636 Config cfg("AdvancedFm"); 638 Config cfg("AdvancedFm");
637 cfg.setGroup("Menu"); 639 cfg.setGroup("Menu");
638 QString dir; 640 QString dir;
639 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 641 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
640 642
641 dir = CurrentDir()->canonicalPath(); 643 dir = CurrentDir()->canonicalPath();
642 644
643 bool addIt=true; 645 bool addIt=true;
644 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 646 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
645 if( dir == (*it)) { 647 if( dir == (*it)) {
646 addIt=false; 648 addIt=false;
647 } 649 }
648 } 650 }
649 if(addIt) { 651 if(addIt) {
650 menuButton->insertItem(dir); 652 menuButton->insertItem(dir);
651// customDirMenu->insertItem(dir); 653// customDirMenu->insertItem(dir);
652 list << dir; 654 list << dir;
653 } 655 }
654 656
655 cfg.writeEntry("CustomDir", list, ','); 657 cfg.writeEntry("CustomDir", list, ',');
656 cfg.write(); 658 cfg.write();
657} 659}
658 660
659void AdvancedFm::removeCustomDir() { 661void AdvancedFm::removeCustomDir() {
660// odebug << "remove custom dir" << oendl; 662// odebug << "remove custom dir" << oendl;
661 Config cfg("AdvancedFm"); 663 Config cfg("AdvancedFm");
662 cfg.setGroup("Menu"); 664 cfg.setGroup("Menu");
663 QString dir; 665 QString dir;
664 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 666 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
665 QStringList list2; 667 QStringList list2;
666 dir = CurrentDir()->canonicalPath(); 668 dir = CurrentDir()->canonicalPath();
667 int ramble=2; 669 int ramble=2;
668// int ramble=-24; 670// int ramble=-24;
669//first remove list 671//first remove list
670 if(list.grep(dir,true).isEmpty()) { 672 if(list.grep(dir,true).isEmpty()) {
671 QMessageBox::message(tr( "AdvancedFm" ), 673 QMessageBox::message(tr( "AdvancedFm" ),
672 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); 674 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
673 } else { 675 } else {
674 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 676 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
675 if((*it) != dir) { 677 if((*it) != dir) {
676//current item is not our current dir, so add it to temp list 678//current item is not our current dir, so add it to temp list
677 list2 <<(*it); 679 list2 <<(*it);
678 } else { 680 } else {
679// customDirMenu->removeItem( ramble); 681// customDirMenu->removeItem( ramble);
680 menuButton->remove( ramble); 682 menuButton->remove( ramble);
681 683
682 } 684 }
683 ramble++; 685 ramble++;
684// ramble--; 686// ramble--;
685 } 687 }
686 688
687 cfg.writeEntry("CustomDir", list2, ','); 689 cfg.writeEntry("CustomDir", list2, ',');
688 cfg.write(); 690 cfg.write();
689 } 691 }
690// customDirsToMenu(); 692// customDirsToMenu();
691 693
692} 694}
693 695
694void AdvancedFm::gotoCustomDir(const QString &dir) { 696void AdvancedFm::gotoCustomDir(const QString &dir) {
695// odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; 697// odebug << "gotoCustomDir(const QString &dir) " +dir << oendl;
696// QString curDir = dir; 698// QString curDir = dir;
697// QDir *thisDir = CurrentDir(); 699// QDir *thisDir = CurrentDir();
698// if( curDir.isEmpty()) { 700// if( curDir.isEmpty()) {
699// } 701// }
700 if( dir == s_addBookmark) { 702 if( dir == s_addBookmark) {
701 addCustomDir(); 703 addCustomDir();
702 } 704 }
703 if( dir == s_removeBookmark) { 705 if( dir == s_removeBookmark) {
704 removeCustomDir( ); 706 removeCustomDir( );
705 } else { 707 } else {
706 gotoDirectory( dir); 708 gotoDirectory( dir);
707// if(QDir( curDir).exists() ) 709// if(QDir( curDir).exists() )
708// { 710// {
709// thisDir->setPath( curDir ); 711// thisDir->setPath( curDir );
710// chdir( curDir.latin1() ); 712// chdir( curDir.latin1() );
711// thisDir->cd( curDir, TRUE); 713// thisDir->cd( curDir, TRUE);
712// populateView(); 714// populateView();
713// } 715// }
714 } 716 }
715} 717}
716 718
717QDir *AdvancedFm::CurrentDir() { 719QDir *AdvancedFm::CurrentDir() {
718 if ( whichTab == 1) { 720 if ( whichTab == 1) {
719 // qDebug("CurrentTab is Local"); 721 // qDebug("CurrentTab is Local");
720 return &currentDir; 722 return &currentDir;
721 } else { 723 } else {
722 // qDebug("CurrentTab is Remote"); 724 // qDebug("CurrentTab is Remote");
723 return &currentRemoteDir; 725 return &currentRemoteDir;
724 } 726 }
725} 727}
726 728
727QDir *AdvancedFm::OtherDir() { 729QDir *AdvancedFm::OtherDir() {
728 // if ( TabWidget->currentWidget() == tab) { 730 // if ( TabWidget->currentWidget() == tab) {
729 if ( whichTab == 1) { 731 if ( whichTab == 1) {
730 return &currentRemoteDir; 732 return &currentRemoteDir;
731 } else { 733 } else {
732 return &currentDir; 734 return &currentDir;
733 } 735 }
734} 736}
735 737
736QListView * AdvancedFm::CurrentView() { 738QListView * AdvancedFm::CurrentView() {
737 // if ( TabWidget->currentWidget() == tab) { 739 // if ( TabWidget->currentWidget() == tab) {
738 if ( whichTab == 1) { 740 if ( whichTab == 1) {
739 // qDebug("CurrentView: local"); 741 // qDebug("CurrentView: local");
740 return Local_View; 742 return Local_View;
741 } else { 743 } else {
742// owarn << "CurrentView Tab 2" << oendl; 744// owarn << "CurrentView Tab 2" << oendl;
743 // qDebug("CurrentView: remote"); 745 // qDebug("CurrentView: remote");
744 return Remote_View; 746 return Remote_View;
745 } 747 }
746} 748}
747 749
748QListView * AdvancedFm::OtherView() { 750QListView * AdvancedFm::OtherView() {
749 if ( whichTab == 1) 751 if ( whichTab == 1)
750 return Remote_View; 752 return Remote_View;
751 else 753 else
752 return Local_View; 754 return Local_View;
753} 755}
754 756
755void AdvancedFm::setOtherTabCurrent() { 757void AdvancedFm::setOtherTabCurrent() {
756 // qDebug("setOtherTabCurrent() %d",whichTab); 758 // qDebug("setOtherTabCurrent() %d",whichTab);
757 if ( whichTab == 1) { 759 if ( whichTab == 1) {
758 TabWidget->setCurrentWidget(1); 760 TabWidget->setCurrentWidget(1);
759 } else { 761 } else {
760 TabWidget->setCurrentWidget(0); 762 TabWidget->setCurrentWidget(0);
761 } 763 }
762 OtherView()->setFocus(); 764 OtherView()->setFocus();
763 OtherView()->setSelected( CurrentView()->firstChild(), true); 765 OtherView()->setSelected( CurrentView()->firstChild(), true);
764} 766}
765 767
766void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 768void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
767// odebug << "qcop message "+msg << oendl; 769// odebug << "qcop message "+msg << oendl;
768 QDataStream stream ( data, IO_ReadOnly ); 770 QDataStream stream ( data, IO_ReadOnly );
769 if ( msg == "openDirectory(QString)" ) { 771 if ( msg == "openDirectory(QString)" ) {
770// odebug << "received" << oendl; 772// odebug << "received" << oendl;
771 QString file; 773 QString file;
772 stream >> file; 774 stream >> file;
773 gotoDirectory( (const QString &) file); 775 gotoDirectory( (const QString &) file);
774 } 776 }
775} 777}
776 778
777void AdvancedFm::setDocument(const QString &file) { 779void AdvancedFm::setDocument(const QString &file) {
778 gotoDirectory( file); 780 gotoDirectory( file);
779 781
780} 782}
781 783
782void AdvancedFm::gotoDirectory(const QString &file) { 784void AdvancedFm::gotoDirectory(const QString &file) {
783// qDebug("goto dir "+file); 785// qDebug("goto dir "+file);
784 QString curDir = file; 786 QString curDir = file;
785 QDir *thisDir = CurrentDir(); 787 QDir *thisDir = CurrentDir();
786 if(QDir( curDir).exists() ) { 788 if(QDir( curDir).exists() ) {
787 thisDir->setPath( curDir ); 789 thisDir->setPath( curDir );
788 chdir( curDir.latin1() ); 790 chdir( curDir.latin1() );
789 thisDir->cd( curDir, TRUE); 791 thisDir->cd( curDir, TRUE);
790 populateView(); 792 populateView();
791 } 793 }
792 else if(QFileInfo(curDir).exists()) { 794 else if(QFileInfo(curDir).exists()) {
793 QFileInfo fileInfo(curDir); 795 QFileInfo fileInfo(curDir);
794 curDir=fileInfo.dirPath(); 796 curDir=fileInfo.dirPath();
795 if(QDir( curDir).exists() ) { 797 if(QDir( curDir).exists() ) {
796 thisDir->setPath( curDir ); 798 thisDir->setPath( curDir );
797 chdir( curDir.latin1() ); 799 chdir( curDir.latin1() );
798 thisDir->cd( curDir, TRUE); 800 thisDir->cd( curDir, TRUE);
799 populateView(); 801 populateView();
800 } 802 }
801 findFile(file); 803 findFile(file);
802 } 804 }
803 805
804} 806}
805 807
806void AdvancedFm::findFile(const QString &fileName) { 808void AdvancedFm::findFile(const QString &fileName) {
807 QFileInfo fi(fileName); 809 QFileInfo fi(fileName);
808 QListView *thisView = CurrentView(); 810 QListView *thisView = CurrentView();
809 QListViewItemIterator it( thisView ); 811 QListViewItemIterator it( thisView );
810 for ( ; it.current(); ++it ) { 812 for ( ; it.current(); ++it ) {
811 if(it.current()->text(0) == fi.fileName()) { 813 if(it.current()->text(0) == fi.fileName()) {
812 it.current()->setSelected(true); 814 it.current()->setSelected(true);
813 thisView->ensureItemVisible(it.current()); 815 thisView->ensureItemVisible(it.current());
814 } 816 }
815 } 817 }
816} 818}
817 819
818void AdvancedFm::slotSwitchMenu(int item) { 820void AdvancedFm::slotSwitchMenu(int item) {
819 // qDebug( "Switch %d",item); 821 // qDebug( "Switch %d",item);
820 // viewMenu->setItemChecked(item, true); 822 // viewMenu->setItemChecked(item, true);
821} 823}
822 824
823void AdvancedFm::navigateToSelected() { 825void AdvancedFm::navigateToSelected() {
824 if( !CurrentView()->currentItem()) return; 826 if( !CurrentView()->currentItem()) return;
825 doDirChange(); 827 doDirChange();
826} 828}