summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index a60d6ce..a47edd8 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -50,77 +50,77 @@ AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags )
50 whichTab=1; 50 whichTab=1;
51 rePopulate(); 51 rePopulate();
52 currentPathCombo->setFocus(); 52 currentPathCombo->setFocus();
53 channel = new QCopChannel( "QPE/Application/advancedfm", this ); 53 channel = new QCopChannel( "QPE/Application/advancedfm", this );
54 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 54 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
55 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 55 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
56} 56}
57 57
58AdvancedFm::~AdvancedFm() { 58AdvancedFm::~AdvancedFm() {
59} 59}
60 60
61 61
62void AdvancedFm::cleanUp() { 62void AdvancedFm::cleanUp() {
63 QString sfile=QDir::homeDirPath(); 63 QString sfile=QDir::homeDirPath();
64 if(sfile.right(1) != "/") 64 if(sfile.right(1) != "/")
65 sfile+="/._temp"; 65 sfile+="/._temp";
66 else 66 else
67 sfile+="._temp"; 67 sfile+="._temp";
68 QFile file( sfile); 68 QFile file( sfile);
69 if(file.exists()) 69 if(file.exists())
70 file.remove(); 70 file.remove();
71} 71}
72 72
73void AdvancedFm::tabChanged(QWidget *) { 73void AdvancedFm::tabChanged(QWidget *) {
74// qWarning("tab changed"); 74// owarn << "tab changed" << oendl;
75 QString path = CurrentDir()->canonicalPath(); 75 QString path = CurrentDir()->canonicalPath();
76 currentPathCombo->lineEdit()->setText( path ); 76 currentPathCombo->lineEdit()->setText( path );
77 77
78 if(whichTab == 1) { 78 if(whichTab == 1) {
79 viewMenu->setItemChecked(viewMenu->idAt(0), true); 79 viewMenu->setItemChecked(viewMenu->idAt(0), true);
80 viewMenu->setItemChecked(viewMenu->idAt(1), false); 80 viewMenu->setItemChecked(viewMenu->idAt(1), false);
81 } else { 81 } else {
82 viewMenu->setItemChecked(viewMenu->idAt(0), false); 82 viewMenu->setItemChecked(viewMenu->idAt(0), false);
83 viewMenu->setItemChecked(viewMenu->idAt(1), true); 83 viewMenu->setItemChecked(viewMenu->idAt(1), true);
84 } 84 }
85 85
86 QString fs= getFileSystemType( (const QString &) path); 86 QString fs= getFileSystemType( (const QString &) path);
87 87
88 setCaption(tr("AdvancedFm :: ")+fs+" :: " 88 setCaption(tr("AdvancedFm :: ")+fs+" :: "
89 +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); 89 +checkDiskSpace( (const QString &) path )+ tr(" kB free") );
90 chdir( path.latin1()); 90 chdir( path.latin1());
91} 91}
92 92
93 93
94void AdvancedFm::populateView() { 94void AdvancedFm::populateView() {
95 95
96// qWarning("PopulateView"); 96// owarn << "PopulateView" << oendl;
97 QPixmap pm; 97 QPixmap pm;
98 QListView *thisView = CurrentView(); 98 QListView *thisView = CurrentView();
99 QDir *thisDir = CurrentDir(); 99 QDir *thisDir = CurrentDir();
100 QString path = thisDir->canonicalPath(); 100 QString path = thisDir->canonicalPath();
101 101
102//qWarning("path is "+path); 102//owarn << "path is "+path << oendl;
103 thisView->clear(); 103 thisView->clear();
104 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 104 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
105 thisDir->setMatchAllDirs(TRUE); 105 thisDir->setMatchAllDirs(TRUE);
106 thisDir->setNameFilter(filterStr); 106 thisDir->setNameFilter(filterStr);
107 QString fileL, fileS, fileDate; 107 QString fileL, fileS, fileDate;
108 QString fs= getFileSystemType((const QString &) path); 108 QString fs= getFileSystemType((const QString &) path);
109 setCaption(tr("AdvancedFm :: ")+fs+" :: " 109 setCaption(tr("AdvancedFm :: ")+fs+" :: "
110 +checkDiskSpace((const QString &) path)+ tr(" kB free") ); 110 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
111 bool isDir=FALSE; 111 bool isDir=FALSE;
112 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 112 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
113 QFileInfoListIterator it(*list); 113 QFileInfoListIterator it(*list);
114 QFileInfo *fi; 114 QFileInfo *fi;
115 while ( (fi=it.current()) ) { 115 while ( (fi=it.current()) ) {
116 if (fi->isSymLink() ) { 116 if (fi->isSymLink() ) {
117 QString symLink=fi->readLink(); 117 QString symLink=fi->readLink();
118 QFileInfo sym( symLink); 118 QFileInfo sym( symLink);
119 fileS.sprintf( "%10i", sym.size() ); 119 fileS.sprintf( "%10i", sym.size() );
120 fileL = fi->fileName() +" -> " + sym.filePath().data(); 120 fileL = fi->fileName() +" -> " + sym.filePath().data();
121 fileDate = sym.lastModified().toString(); 121 fileDate = sym.lastModified().toString();
122 } else { 122 } else {
123 fileS.sprintf( "%10i", fi->size() ); 123 fileS.sprintf( "%10i", fi->size() );
124 fileL = fi->fileName(); 124 fileL = fi->fileName();
125 fileDate= fi->lastModified().toString(); 125 fileDate= fi->lastModified().toString();
126 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { 126 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
@@ -139,162 +139,162 @@ void AdvancedFm::populateView() {
139 if( !QDir( fi->filePath() ).isReadable()) //is directory 139 if( !QDir( fi->filePath() ).isReadable()) //is directory
140 pm = Resource::loadPixmap( "lockedfolder" ); 140 pm = Resource::loadPixmap( "lockedfolder" );
141 else 141 else
142 pm= Resource::loadPixmap( "folder" ); 142 pm= Resource::loadPixmap( "folder" );
143 } 143 }
144 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 144 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
145 pm = Resource::loadPixmap( "exec"); 145 pm = Resource::loadPixmap( "exec");
146 } 146 }
147 else if( (fileInfo.permission( QFileInfo::ExeUser) 147 else if( (fileInfo.permission( QFileInfo::ExeUser)
148 | fileInfo.permission( QFileInfo::ExeGroup) 148 | fileInfo.permission( QFileInfo::ExeGroup)
149 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 149 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
150 pm = Resource::loadPixmap( "exec"); 150 pm = Resource::loadPixmap( "exec");
151 } 151 }
152 else if( !fi->isReadable() ) { 152 else if( !fi->isReadable() ) {
153 pm = Resource::loadPixmap( "locked" ); 153 pm = Resource::loadPixmap( "locked" );
154 } 154 }
155 else { //everything else goes by mimetype 155 else { //everything else goes by mimetype
156 MimeType mt(fi->filePath()); 156 MimeType mt(fi->filePath());
157 pm=mt.pixmap(); //sets the correct pixmap for mimetype 157 pm=mt.pixmap(); //sets the correct pixmap for mimetype
158 if(pm.isNull()) { 158 if(pm.isNull()) {
159 pm = unknownXpm; 159 pm = unknownXpm;
160 } 160 }
161 } 161 }
162 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { 162 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
163 // qDebug(" overlay link image"); 163 // odebug << " overlay link image" << oendl;
164 pm= Resource::loadPixmap( "advancedfm/symlink" ); 164 pm= Resource::loadPixmap( "advancedfm/symlink" );
165 // pm= Resource::loadPixmap( "folder" ); 165 // pm= Resource::loadPixmap( "folder" );
166// QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 166// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
167// QPainter painter( &pm ); 167// QPainter painter( &pm );
168// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 168// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
169// pm.setMask( pm.createHeuristicMask( FALSE ) ); 169// pm.setMask( pm.createHeuristicMask( FALSE ) );
170 } 170 }
171 item->setPixmap( 0,pm); 171 item->setPixmap( 0,pm);
172 172
173 } 173 }
174 isDir=FALSE; 174 isDir=FALSE;
175 ++it; 175 ++it;
176 } 176 }
177 177
178 if( path.find("dev",0,TRUE) != -1) { 178 if( path.find("dev",0,TRUE) != -1) {
179 struct stat buf; 179 struct stat buf;
180 dev_t devT; 180 dev_t devT;
181 DIR *dir; 181 DIR *dir;
182 struct dirent *mydirent; 182 struct dirent *mydirent;
183 183
184 if((dir = opendir( path.latin1())) != NULL) 184 if((dir = opendir( path.latin1())) != NULL)
185 while ((mydirent = readdir(dir)) != NULL) { 185 while ((mydirent = readdir(dir)) != NULL) {
186 lstat( mydirent->d_name, &buf); 186 lstat( mydirent->d_name, &buf);
187// qDebug(mydirent->d_name); 187// odebug << mydirent->d_name << oendl;
188 fileL.sprintf("%s", mydirent->d_name); 188 fileL.sprintf("%s", mydirent->d_name);
189 devT = buf.st_dev; 189 devT = buf.st_dev;
190 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 190 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
191 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 191 fileDate.sprintf("%s", ctime( &buf.st_mtime));
192 if( fileL.find(".") == -1 ) { 192 if( fileL.find(".") == -1 ) {
193 item= new QListViewItem( thisView, fileL, fileS, fileDate); 193 item= new QListViewItem( thisView, fileL, fileS, fileDate);
194 pm = unknownXpm; 194 pm = unknownXpm;
195 item->setPixmap( 0,pm); 195 item->setPixmap( 0,pm);
196 } 196 }
197 } 197 }
198 198
199 closedir(dir); 199 closedir(dir);
200 } 200 }
201 201
202 thisView->setSorting( 3,FALSE); 202 thisView->setSorting( 3,FALSE);
203 fillCombo( (const QString &) path ); 203 fillCombo( (const QString &) path );
204} 204}
205 205
206void AdvancedFm::rePopulate() { 206void AdvancedFm::rePopulate() {
207 populateView(); 207 populateView();
208 setOtherTabCurrent(); 208 setOtherTabCurrent();
209 populateView(); 209 populateView();
210 210
211// int tmpTab = whichTab; 211// int tmpTab = whichTab;
212// // qDebug("%d", tmpTab); 212// // odebug << "" << tmpTab << "" << oendl;
213 213
214// for(int i =1; i < 3; i++) { 214// for(int i =1; i < 3; i++) {
215// TabWidget->setCurrentWidget(i - 1); 215// TabWidget->setCurrentWidget(i - 1);
216// populateView(); 216// populateView();
217// } 217// }
218// TabWidget->setCurrentWidget( tmpTab - 1); 218// TabWidget->setCurrentWidget( tmpTab - 1);
219} 219}
220 220
221void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 221void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
222//qWarning("listclicked"); 222//owarn << "listclicked" << oendl;
223 if(selectedItem) { 223 if(selectedItem) {
224 QString strItem=selectedItem->text(0); 224 QString strItem=selectedItem->text(0);
225// qWarning(strItem); 225// owarn << strItem << oendl;
226 QString strSize=selectedItem->text(1); 226 QString strSize=selectedItem->text(1);
227 strSize=strSize.stripWhiteSpace(); 227 strSize=strSize.stripWhiteSpace();
228 bool isDirectory = false; 228 bool isDirectory = false;
229 QString strItem2; 229 QString strItem2;
230 230
231 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink 231 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
232 strItem2 = dealWithSymName((const QString&)strItem); 232 strItem2 = dealWithSymName((const QString&)strItem);
233 if(QDir(strItem2).exists() ) 233 if(QDir(strItem2).exists() )
234 strItem = strItem2; 234 strItem = strItem2;
235 } 235 }
236 236
237 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 237 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
238 238
239 if(QDir(strItem).exists()) 239 if(QDir(strItem).exists())
240 isDirectory = true; 240 isDirectory = true;
241 } 241 }
242 242
243 if( isDirectory ) { 243 if( isDirectory ) {
244 CurrentDir()->cd( strItem, TRUE); 244 CurrentDir()->cd( strItem, TRUE);
245 populateView(); 245 populateView();
246 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 246 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
247 } 247 }
248 chdir( strItem.latin1()); 248 chdir( strItem.latin1());
249 } 249 }
250} 250}
251 251
252void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { 252void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
253 dealWithSchmooSchmaa( item->listView()); 253 dealWithSchmooSchmaa( item->listView());
254 switch (mouse) { 254 switch (mouse) {
255 case 1: 255 case 1:
256 { 256 {
257 if(renameBox != 0 ) { 257 if(renameBox != 0 ) {
258 cancelRename(); 258 cancelRename();
259 } 259 }
260 } 260 }
261 break; 261 break;
262 case 2: 262 case 2:
263 menuTimer.start( 500, TRUE ); 263 menuTimer.start( 500, TRUE );
264 break; 264 break;
265 }; 265 };
266} 266}
267 267
268 268
269void AdvancedFm::switchToLocalTab() { 269void AdvancedFm::switchToLocalTab() {
270//qWarning("switch to local view"); 270//owarn << "switch to local view" << oendl;
271 TabWidget->setCurrentWidget(0); 271 TabWidget->setCurrentWidget(0);
272 Local_View->setFocus(); 272 Local_View->setFocus();
273} 273}
274 274
275void AdvancedFm::switchToRemoteTab() { 275void AdvancedFm::switchToRemoteTab() {
276//qWarning("switch to local view"); 276//owarn << "switch to local view" << oendl;
277 TabWidget->setCurrentWidget(1); 277 TabWidget->setCurrentWidget(1);
278 Remote_View->setFocus(); 278 Remote_View->setFocus();
279} 279}
280 280
281void AdvancedFm::readConfig() { 281void AdvancedFm::readConfig() {
282 Config cfg("AdvancedFm"); 282 Config cfg("AdvancedFm");
283} 283}
284 284
285void AdvancedFm::writeConfig() { 285void AdvancedFm::writeConfig() {
286 Config cfg("AdvancedFm"); 286 Config cfg("AdvancedFm");
287} 287}
288 288
289void AdvancedFm::currentPathComboChanged() { 289void AdvancedFm::currentPathComboChanged() {
290 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 290 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
291 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 291 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
292 populateView(); 292 populateView();
293 } else { 293 } else {
294 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 294 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
295 } 295 }
296} 296}
297 297
298void AdvancedFm::fillCombo(const QString &currentPath) { 298void AdvancedFm::fillCombo(const QString &currentPath) {
299 299
300 if ( whichTab == 1) { 300 if ( whichTab == 1) {
@@ -308,49 +308,49 @@ void AdvancedFm::fillCombo(const QString &currentPath) {
308 currentPathCombo->lineEdit()->setText( currentPath); 308 currentPathCombo->lineEdit()->setText( currentPath);
309 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 309 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
310 currentPathCombo->clear(); 310 currentPathCombo->clear();
311 remoteDirPathStringList.prepend( currentPath ); 311 remoteDirPathStringList.prepend( currentPath );
312 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 312 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
313 } 313 }
314 } 314 }
315} 315}
316 316
317void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 317void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
318 chdir( currentPath.latin1() ); 318 chdir( currentPath.latin1() );
319 CurrentDir()->cd( currentPath, TRUE); 319 CurrentDir()->cd( currentPath, TRUE);
320 populateView(); 320 populateView();
321 update(); 321 update();
322} 322}
323 323
324QStringList AdvancedFm::getPath() { 324QStringList AdvancedFm::getPath() {
325 QStringList strList; 325 QStringList strList;
326 QListView *thisView=CurrentView(); 326 QListView *thisView=CurrentView();
327 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 327 QList<QListViewItem> * getSelectedItems( QListView * thisView );
328 QListViewItemIterator it( thisView ); 328 QListViewItemIterator it( thisView );
329 for ( ; it.current(); ++it ) { 329 for ( ; it.current(); ++it ) {
330 if ( it.current()->isSelected() ) { 330 if ( it.current()->isSelected() ) {
331 strList << it.current()->text(0); 331 strList << it.current()->text(0);
332// qDebug(it.current()->text(0)); 332// odebug << it.current()->text(0) << oendl;
333 } 333 }
334 } 334 }
335 return strList; 335 return strList;
336} 336}
337 337
338void AdvancedFm::homeButtonPushed() { 338void AdvancedFm::homeButtonPushed() {
339 QString current = QDir::homeDirPath(); 339 QString current = QDir::homeDirPath();
340 chdir( current.latin1() ); 340 chdir( current.latin1() );
341 CurrentDir()->cd( current, TRUE); 341 CurrentDir()->cd( current, TRUE);
342 populateView(); 342 populateView();
343 update(); 343 update();
344} 344}
345 345
346void AdvancedFm::docButtonPushed() { 346void AdvancedFm::docButtonPushed() {
347 QString current = QPEApplication::documentDir(); 347 QString current = QPEApplication::documentDir();
348 chdir( current.latin1() ); 348 chdir( current.latin1() );
349 CurrentDir()->cd( current, TRUE); 349 CurrentDir()->cd( current, TRUE);
350 populateView(); 350 populateView();
351 update(); 351 update();
352} 352}
353 353
354void AdvancedFm::SDButtonPushed() { 354void AdvancedFm::SDButtonPushed() {
355 QString current = "/mnt/card";// this can change so fix 355 QString current = "/mnt/card";// this can change so fix
356 chdir( current.latin1() ); 356 chdir( current.latin1() );
@@ -359,49 +359,49 @@ void AdvancedFm::SDButtonPushed() {
359 update(); 359 update();
360} 360}
361 361
362void AdvancedFm::CFButtonPushed() { 362void AdvancedFm::CFButtonPushed() {
363 QString current; 363 QString current;
364 if(zaurusDevice) 364 if(zaurusDevice)
365 current= "/mnt/cf"; //zaurus 365 current= "/mnt/cf"; //zaurus
366 else 366 else
367 current = "/mnt/hda"; //ipaq 367 current = "/mnt/hda"; //ipaq
368 chdir( current.latin1() ); 368 chdir( current.latin1() );
369 CurrentDir()->cd( current, TRUE); 369 CurrentDir()->cd( current, TRUE);
370 populateView(); 370 populateView();
371 update(); 371 update();
372} 372}
373 373
374 374
375void AdvancedFm::doAbout() { 375void AdvancedFm::doAbout() {
376 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 376 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
377 "is copyright 2002-2003 by\n" 377 "is copyright 2002-2003 by\n"
378 "L.J.Potter<llornkcor@handhelds.org>\n" 378 "L.J.Potter<llornkcor@handhelds.org>\n"
379 "and is licensed by the GPL")); 379 "and is licensed by the GPL"));
380} 380}
381 381
382void AdvancedFm::keyPressEvent( QKeyEvent *e) { 382void AdvancedFm::keyPressEvent( QKeyEvent *e) {
383// qWarning("key %d", e->key()); 383// owarn << "key " << e->key() << "" << oendl;
384// if( CurrentView()->hasFocus() ) 384// if( CurrentView()->hasFocus() )
385 { 385 {
386 switch ( e->key() ) { 386 switch ( e->key() ) {
387 case Key_Left: 387 case Key_Left:
388 upDir(); 388 upDir();
389 break; 389 break;
390 case Key_Next: 390 case Key_Next:
391 break; 391 break;
392 case Key_Return: 392 case Key_Return:
393 case Key_Enter: 393 case Key_Enter:
394 navigateToSelected(); 394 navigateToSelected();
395 break; 395 break;
396 case Key_Tab: { 396 case Key_Tab: {
397 setOtherTabCurrent(); 397 setOtherTabCurrent();
398 } 398 }
399 break; 399 break;
400 case Key_Delete: 400 case Key_Delete:
401 del(); 401 del();
402 break; 402 break;
403 case Key_A: 403 case Key_A:
404 copyAs(); 404 copyAs();
405 break; 405 break;
406 case Key_C: 406 case Key_C:
407 copy(); 407 copy();
@@ -617,49 +617,49 @@ QString AdvancedFm::checkDiskSpace(const QString &path) {
617 if ( !statfs( path.latin1(), &fss ) ) { 617 if ( !statfs( path.latin1(), &fss ) ) {
618 int blkSize = fss.f_bsize; 618 int blkSize = fss.f_bsize;
619// int totalBlks = fs.f_blocks; 619// int totalBlks = fs.f_blocks;
620 int availBlks = fss.f_bavail; 620 int availBlks = fss.f_bavail;
621 621
622 long mult = blkSize / 1024; 622 long mult = blkSize / 1024;
623 long div = 1024 / blkSize; 623 long div = 1024 / blkSize;
624 if ( !mult ) mult = 1; 624 if ( !mult ) mult = 1;
625 if ( !div ) div = 1; 625 if ( !div ) div = 1;
626 626
627 627
628 return QString::number(availBlks * mult / div); 628 return QString::number(availBlks * mult / div);
629 } 629 }
630 return ""; 630 return "";
631} 631}
632 632
633void AdvancedFm::addToDocs() { 633void AdvancedFm::addToDocs() {
634 QStringList strListPaths = getPath(); 634 QStringList strListPaths = getPath();
635 QDir *thisDir = CurrentDir(); 635 QDir *thisDir = CurrentDir();
636 636
637 if( strListPaths.count() > 0) { 637 if( strListPaths.count() > 0) {
638 QString curFile; 638 QString curFile;
639 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 639 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
640 curFile = thisDir->canonicalPath()+"/"+(*it); 640 curFile = thisDir->canonicalPath()+"/"+(*it);
641// qDebug(curFile); 641// odebug << curFile << oendl;
642 QFileInfo fi(curFile); 642 QFileInfo fi(curFile);
643 DocLnk f; 643 DocLnk f;
644// curFile.replace(QRegExp("\\..*"),""); 644// curFile.replace(QRegExp("\\..*"),"");
645 f.setName(fi.baseName() ); 645 f.setName(fi.baseName() );
646 f.setFile( curFile); 646 f.setFile( curFile);
647 f.writeLink(); 647 f.writeLink();
648 } 648 }
649 } 649 }
650} 650}
651 651
652 652
653void AdvancedFm::customDirsToMenu() { 653void AdvancedFm::customDirsToMenu() {
654 654
655 Config cfg("AdvancedFm"); 655 Config cfg("AdvancedFm");
656 cfg.setGroup("Menu"); 656 cfg.setGroup("Menu");
657 657
658 QStringList list = cfg.readListEntry( "CustomDir", ','); 658 QStringList list = cfg.readListEntry( "CustomDir", ',');
659 menuButton->insertItems(list ); 659 menuButton->insertItems(list );
660 660
661// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 661// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
662// { 662// {
663// customDirMenu->insertItem(*it ); 663// customDirMenu->insertItem(*it );
664// } 664// }
665} 665}
@@ -690,196 +690,196 @@ void AdvancedFm::addCustomDir() {
690 Config cfg("AdvancedFm"); 690 Config cfg("AdvancedFm");
691 cfg.setGroup("Menu"); 691 cfg.setGroup("Menu");
692 QString dir; 692 QString dir;
693 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 693 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
694 694
695 dir = CurrentDir()->canonicalPath(); 695 dir = CurrentDir()->canonicalPath();
696 696
697 bool addIt=true; 697 bool addIt=true;
698 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 698 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
699 if( dir == (*it)) { 699 if( dir == (*it)) {
700 addIt=false; 700 addIt=false;
701 } 701 }
702 } 702 }
703 if(addIt) { 703 if(addIt) {
704 menuButton->insertItem(dir); 704 menuButton->insertItem(dir);
705// customDirMenu->insertItem(dir); 705// customDirMenu->insertItem(dir);
706 list << dir; 706 list << dir;
707 } 707 }
708 708
709 cfg.writeEntry("CustomDir", list, ','); 709 cfg.writeEntry("CustomDir", list, ',');
710 cfg.write(); 710 cfg.write();
711} 711}
712 712
713void AdvancedFm::removeCustomDir() { 713void AdvancedFm::removeCustomDir() {
714// qDebug("remove custom dir"); 714// odebug << "remove custom dir" << oendl;
715 Config cfg("AdvancedFm"); 715 Config cfg("AdvancedFm");
716 cfg.setGroup("Menu"); 716 cfg.setGroup("Menu");
717 QString dir; 717 QString dir;
718 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 718 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
719 QStringList list2; 719 QStringList list2;
720 dir = CurrentDir()->canonicalPath(); 720 dir = CurrentDir()->canonicalPath();
721 int ramble=2; 721 int ramble=2;
722// int ramble=-24; 722// int ramble=-24;
723//first remove list 723//first remove list
724 if(list.grep(dir,true).isEmpty()) { 724 if(list.grep(dir,true).isEmpty()) {
725 QMessageBox::message(tr( "AdvancedFm" ), 725 QMessageBox::message(tr( "AdvancedFm" ),
726 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); 726 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
727 } else { 727 } else {
728 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 728 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
729 if((*it) != dir) { 729 if((*it) != dir) {
730//current item is not our current dir, so add it to temp list 730//current item is not our current dir, so add it to temp list
731 list2 <<(*it); 731 list2 <<(*it);
732 } else { 732 } else {
733// customDirMenu->removeItem( ramble); 733// customDirMenu->removeItem( ramble);
734 menuButton->remove( ramble); 734 menuButton->remove( ramble);
735 735
736 } 736 }
737 ramble++; 737 ramble++;
738// ramble--; 738// ramble--;
739 } 739 }
740 740
741 cfg.writeEntry("CustomDir", list2, ','); 741 cfg.writeEntry("CustomDir", list2, ',');
742 cfg.write(); 742 cfg.write();
743 } 743 }
744// customDirsToMenu(); 744// customDirsToMenu();
745 745
746} 746}
747 747
748void AdvancedFm::gotoCustomDir(const QString &dir) { 748void AdvancedFm::gotoCustomDir(const QString &dir) {
749// qDebug("gotoCustomDir(const QString &dir) " +dir ); 749// odebug << "gotoCustomDir(const QString &dir) " +dir << oendl;
750// QString curDir = dir; 750// QString curDir = dir;
751// QDir *thisDir = CurrentDir(); 751// QDir *thisDir = CurrentDir();
752// if( curDir.isEmpty()) { 752// if( curDir.isEmpty()) {
753// } 753// }
754 if( dir == s_addBookmark) { 754 if( dir == s_addBookmark) {
755 addCustomDir(); 755 addCustomDir();
756 } 756 }
757 if( dir == s_removeBookmark) { 757 if( dir == s_removeBookmark) {
758 removeCustomDir( ); 758 removeCustomDir( );
759 } else { 759 } else {
760 gotoDirectory( dir); 760 gotoDirectory( dir);
761// if(QDir( curDir).exists() ) 761// if(QDir( curDir).exists() )
762// { 762// {
763// thisDir->setPath( curDir ); 763// thisDir->setPath( curDir );
764// chdir( curDir.latin1() ); 764// chdir( curDir.latin1() );
765// thisDir->cd( curDir, TRUE); 765// thisDir->cd( curDir, TRUE);
766// populateView(); 766// populateView();
767// } 767// }
768 } 768 }
769} 769}
770 770
771QDir *AdvancedFm::CurrentDir() { 771QDir *AdvancedFm::CurrentDir() {
772 772
773 if ( whichTab == 1) { 773 if ( whichTab == 1) {
774 return &currentDir; 774 return &currentDir;
775 } else { 775 } else {
776 return &currentRemoteDir; 776 return &currentRemoteDir;
777 } 777 }
778} 778}
779 779
780QDir *AdvancedFm::OtherDir() { 780QDir *AdvancedFm::OtherDir() {
781 if ( whichTab == 1) { 781 if ( whichTab == 1) {
782 return &currentRemoteDir; 782 return &currentRemoteDir;
783 } else { 783 } else {
784 return &currentDir; 784 return &currentDir;
785 } 785 }
786} 786}
787 787
788QListView * AdvancedFm::CurrentView() { 788QListView * AdvancedFm::CurrentView() {
789 if ( whichTab == 1) { 789 if ( whichTab == 1) {
790// qWarning("CurrentView Tab 1"); 790// owarn << "CurrentView Tab 1" << oendl;
791 return Local_View; 791 return Local_View;
792 } else { 792 } else {
793// qWarning("CurrentView Tab 2"); 793// owarn << "CurrentView Tab 2" << oendl;
794 return Remote_View; 794 return Remote_View;
795 } 795 }
796} 796}
797 797
798QListView * AdvancedFm::OtherView() { 798QListView * AdvancedFm::OtherView() {
799 if ( whichTab == 1) 799 if ( whichTab == 1)
800 return Remote_View; 800 return Remote_View;
801 else 801 else
802 return Local_View; 802 return Local_View;
803} 803}
804 804
805void AdvancedFm::setOtherTabCurrent() { 805void AdvancedFm::setOtherTabCurrent() {
806// qWarning("setOtherTabCurrent() %d", whichTab); 806// owarn << "setOtherTabCurrent() " << whichTab << "" << oendl;
807 if ( whichTab == 1) { 807 if ( whichTab == 1) {
808 TabWidget->setCurrentWidget(1); 808 TabWidget->setCurrentWidget(1);
809 } else { 809 } else {
810 TabWidget->setCurrentWidget(0); 810 TabWidget->setCurrentWidget(0);
811 } 811 }
812 OtherView()->setFocus(); 812 OtherView()->setFocus();
813 OtherView()->setSelected( CurrentView()->firstChild(), true); 813 OtherView()->setSelected( CurrentView()->firstChild(), true);
814} 814}
815 815
816void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 816void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
817// qDebug("qcop message "+msg ); 817// odebug << "qcop message "+msg << oendl;
818 QDataStream stream ( data, IO_ReadOnly ); 818 QDataStream stream ( data, IO_ReadOnly );
819 if ( msg == "openDirectory(QString)" ) { 819 if ( msg == "openDirectory(QString)" ) {
820// qDebug("received"); 820// odebug << "received" << oendl;
821 QString file; 821 QString file;
822 stream >> file; 822 stream >> file;
823 gotoDirectory( (const QString &) file); 823 gotoDirectory( (const QString &) file);
824 } 824 }
825} 825}
826 826
827void AdvancedFm::setDocument(const QString &file) { 827void AdvancedFm::setDocument(const QString &file) {
828 gotoDirectory( file); 828 gotoDirectory( file);
829 829
830} 830}
831 831
832void AdvancedFm::gotoDirectory(const QString &file) { 832void AdvancedFm::gotoDirectory(const QString &file) {
833// qWarning("goto dir "+file); 833// owarn << "goto dir "+file << oendl;
834 QString curDir = file; 834 QString curDir = file;
835 QDir *thisDir = CurrentDir(); 835 QDir *thisDir = CurrentDir();
836 if(QDir( curDir).exists() ) { 836 if(QDir( curDir).exists() ) {
837 thisDir->setPath( curDir ); 837 thisDir->setPath( curDir );
838 chdir( curDir.latin1() ); 838 chdir( curDir.latin1() );
839 thisDir->cd( curDir, TRUE); 839 thisDir->cd( curDir, TRUE);
840 populateView(); 840 populateView();
841 } 841 }
842 else if(QFileInfo(curDir).exists()) { 842 else if(QFileInfo(curDir).exists()) {
843 QFileInfo fileInfo(curDir); 843 QFileInfo fileInfo(curDir);
844 curDir=fileInfo.dirPath(); 844 curDir=fileInfo.dirPath();
845 if(QDir( curDir).exists() ) { 845 if(QDir( curDir).exists() ) {
846 thisDir->setPath( curDir ); 846 thisDir->setPath( curDir );
847 chdir( curDir.latin1() ); 847 chdir( curDir.latin1() );
848 thisDir->cd( curDir, TRUE); 848 thisDir->cd( curDir, TRUE);
849 populateView(); 849 populateView();
850 } 850 }
851 findFile(file); 851 findFile(file);
852 } 852 }
853 853
854} 854}
855 855
856void AdvancedFm::findFile(const QString &fileName) { 856void AdvancedFm::findFile(const QString &fileName) {
857 QFileInfo fi(fileName); 857 QFileInfo fi(fileName);
858 QListView *thisView = CurrentView(); 858 QListView *thisView = CurrentView();
859 QListViewItemIterator it( thisView ); 859 QListViewItemIterator it( thisView );
860 for ( ; it.current(); ++it ) { 860 for ( ; it.current(); ++it ) {
861 if(it.current()->text(0) == fi.fileName()) { 861 if(it.current()->text(0) == fi.fileName()) {
862 it.current()->setSelected(true); 862 it.current()->setSelected(true);
863 thisView->ensureItemVisible(it.current()); 863 thisView->ensureItemVisible(it.current());
864 } 864 }
865 } 865 }
866} 866}
867 867
868void AdvancedFm::slotSwitchMenu(int ) { 868void AdvancedFm::slotSwitchMenu(int ) {
869// qDebug("Switch %d", item); 869// odebug << "Switch " << item << "" << oendl;
870 // viewMenu->setItemChecked(item, true); 870 // viewMenu->setItemChecked(item, true);
871} 871}
872 872
873void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { 873void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) {
874 tabChanged( w); 874 tabChanged( w);
875 if( w == Local_View) { 875 if( w == Local_View) {
876 Remote_View->clearFocus(); 876 Remote_View->clearFocus();
877 } else { 877 } else {
878 Local_View->clearFocus(); 878 Local_View->clearFocus();
879 } 879 }
880} 880}
881 881
882void AdvancedFm::navigateToSelected() { 882void AdvancedFm::navigateToSelected() {
883 if( !CurrentView()->currentItem()) return; 883 if( !CurrentView()->currentItem()) return;
884 doDirChange(); 884 doDirChange();
885} 885}