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