Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index a47edd8..afb44f5 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -26,29 +26,25 @@ | |||
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | 27 | ||
28 | 28 | ||
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <time.h> | 30 | #include <time.h> |
31 | #include <dirent.h> | 31 | #include <dirent.h> |
32 | #include <fcntl.h> | 32 | #include <fcntl.h> |
33 | #include <sys/vfs.h> | 33 | #include <sys/vfs.h> |
34 | #include <mntent.h> | 34 | #include <mntent.h> |
35 | 35 | ||
36 | using namespace Opie::Ui; | 36 | using namespace Opie::Ui; |
37 | 37 | ||
38 | #ifdef NOQUICKLAUNCH | ||
39 | AdvancedFm::AdvancedFm( ) | ||
40 | #else | ||
41 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) | 38 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) |
42 | #endif | ||
43 | : QMainWindow( ) { | 39 | : QMainWindow( ) { |
44 | init(); | 40 | init(); |
45 | renameBox = 0; | 41 | renameBox = 0; |
46 | 42 | ||
47 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 43 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
48 | 44 | ||
49 | initConnections(); | 45 | initConnections(); |
50 | whichTab=1; | 46 | whichTab=1; |
51 | rePopulate(); | 47 | rePopulate(); |
52 | currentPathCombo->setFocus(); | 48 | currentPathCombo->setFocus(); |
53 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 49 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
54 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 50 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
@@ -62,53 +58,53 @@ AdvancedFm::~AdvancedFm() { | |||
62 | void AdvancedFm::cleanUp() { | 58 | void AdvancedFm::cleanUp() { |
63 | QString sfile=QDir::homeDirPath(); | 59 | QString sfile=QDir::homeDirPath(); |
64 | if(sfile.right(1) != "/") | 60 | if(sfile.right(1) != "/") |
65 | sfile+="/._temp"; | 61 | sfile+="/._temp"; |
66 | else | 62 | else |
67 | sfile+="._temp"; | 63 | sfile+="._temp"; |
68 | QFile file( sfile); | 64 | QFile file( sfile); |
69 | if(file.exists()) | 65 | if(file.exists()) |
70 | file.remove(); | 66 | file.remove(); |
71 | } | 67 | } |
72 | 68 | ||
73 | void AdvancedFm::tabChanged(QWidget *) { | 69 | void AdvancedFm::tabChanged(QWidget *) { |
74 | // owarn << "tab changed" << oendl; | 70 | // owarn << "tab changed" << oendl; |
75 | QString path = CurrentDir()->canonicalPath(); | 71 | QString path = CurrentDir()->canonicalPath(); |
76 | currentPathCombo->lineEdit()->setText( path ); | 72 | currentPathCombo->lineEdit()->setText( path ); |
77 | 73 | ||
78 | if(whichTab == 1) { | 74 | if(whichTab == 1) { |
79 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 75 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
80 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 76 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
81 | } else { | 77 | } else { |
82 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 78 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
83 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 79 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
84 | } | 80 | } |
85 | 81 | ||
86 | QString fs= getFileSystemType( (const QString &) path); | 82 | QString fs= getFileSystemType( (const QString &) path); |
87 | 83 | ||
88 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 84 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
89 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); | 85 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); |
90 | chdir( path.latin1()); | 86 | chdir( path.latin1()); |
91 | } | 87 | } |
92 | 88 | ||
93 | 89 | ||
94 | void AdvancedFm::populateView() { | 90 | void AdvancedFm::populateView() { |
95 | 91 | ||
96 | // owarn << "PopulateView" << oendl; | 92 | // owarn << "PopulateView" << oendl; |
97 | QPixmap pm; | 93 | QPixmap pm; |
98 | QListView *thisView = CurrentView(); | 94 | QListView *thisView = CurrentView(); |
99 | QDir *thisDir = CurrentDir(); | 95 | QDir *thisDir = CurrentDir(); |
100 | QString path = thisDir->canonicalPath(); | 96 | QString path = thisDir->canonicalPath(); |
101 | 97 | ||
102 | //owarn << "path is "+path << oendl; | 98 | //owarn << "path is "+path << oendl; |
103 | thisView->clear(); | 99 | thisView->clear(); |
104 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 100 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
105 | thisDir->setMatchAllDirs(TRUE); | 101 | thisDir->setMatchAllDirs(TRUE); |
106 | thisDir->setNameFilter(filterStr); | 102 | thisDir->setNameFilter(filterStr); |
107 | QString fileL, fileS, fileDate; | 103 | QString fileL, fileS, fileDate; |
108 | QString fs= getFileSystemType((const QString &) path); | 104 | QString fs= getFileSystemType((const QString &) path); |
109 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 105 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
110 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 106 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
111 | bool isDir=FALSE; | 107 | bool isDir=FALSE; |
112 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 108 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
113 | QFileInfoListIterator it(*list); | 109 | QFileInfoListIterator it(*list); |
114 | QFileInfo *fi; | 110 | QFileInfo *fi; |
@@ -151,87 +147,87 @@ void AdvancedFm::populateView() { | |||
151 | } | 147 | } |
152 | else if( !fi->isReadable() ) { | 148 | else if( !fi->isReadable() ) { |
153 | pm = Resource::loadPixmap( "locked" ); | 149 | pm = Resource::loadPixmap( "locked" ); |
154 | } | 150 | } |
155 | else { //everything else goes by mimetype | 151 | else { //everything else goes by mimetype |
156 | MimeType mt(fi->filePath()); | 152 | MimeType mt(fi->filePath()); |
157 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 153 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
158 | if(pm.isNull()) { | 154 | if(pm.isNull()) { |
159 | pm = unknownXpm; | 155 | pm = unknownXpm; |
160 | } | 156 | } |
161 | } | 157 | } |
162 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 158 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
163 | // odebug << " overlay link image" << oendl; | 159 | // odebug << " overlay link image" << oendl; |
164 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 160 | pm= Resource::loadPixmap( "advancedfm/symlink" ); |
165 | // pm= Resource::loadPixmap( "folder" ); | 161 | // pm= Resource::loadPixmap( "folder" ); |
166 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 162 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
167 | // QPainter painter( &pm ); | 163 | // QPainter painter( &pm ); |
168 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 164 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
169 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 165 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
170 | } | 166 | } |
171 | item->setPixmap( 0,pm); | 167 | item->setPixmap( 0,pm); |
172 | 168 | ||
173 | } | 169 | } |
174 | isDir=FALSE; | 170 | isDir=FALSE; |
175 | ++it; | 171 | ++it; |
176 | } | 172 | } |
177 | 173 | ||
178 | if( path.find("dev",0,TRUE) != -1) { | 174 | if( path.find("dev",0,TRUE) != -1) { |
179 | struct stat buf; | 175 | struct stat buf; |
180 | dev_t devT; | 176 | dev_t devT; |
181 | DIR *dir; | 177 | DIR *dir; |
182 | struct dirent *mydirent; | 178 | struct dirent *mydirent; |
183 | 179 | ||
184 | if((dir = opendir( path.latin1())) != NULL) | 180 | if((dir = opendir( path.latin1())) != NULL) |
185 | while ((mydirent = readdir(dir)) != NULL) { | 181 | while ((mydirent = readdir(dir)) != NULL) { |
186 | lstat( mydirent->d_name, &buf); | 182 | lstat( mydirent->d_name, &buf); |
187 | // odebug << mydirent->d_name << oendl; | 183 | // odebug << mydirent->d_name << oendl; |
188 | fileL.sprintf("%s", mydirent->d_name); | 184 | fileL.sprintf("%s", mydirent->d_name); |
189 | devT = buf.st_dev; | 185 | devT = buf.st_dev; |
190 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 186 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
191 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 187 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
192 | if( fileL.find(".") == -1 ) { | 188 | if( fileL.find(".") == -1 ) { |
193 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 189 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
194 | pm = unknownXpm; | 190 | pm = unknownXpm; |
195 | item->setPixmap( 0,pm); | 191 | item->setPixmap( 0,pm); |
196 | } | 192 | } |
197 | } | 193 | } |
198 | 194 | ||
199 | closedir(dir); | 195 | closedir(dir); |
200 | } | 196 | } |
201 | 197 | ||
202 | thisView->setSorting( 3,FALSE); | 198 | thisView->setSorting( 3,FALSE); |
203 | fillCombo( (const QString &) path ); | 199 | fillCombo( (const QString &) path ); |
204 | } | 200 | } |
205 | 201 | ||
206 | void AdvancedFm::rePopulate() { | 202 | void AdvancedFm::rePopulate() { |
207 | populateView(); | 203 | populateView(); |
208 | setOtherTabCurrent(); | 204 | setOtherTabCurrent(); |
209 | populateView(); | 205 | populateView(); |
210 | 206 | ||
211 | // int tmpTab = whichTab; | 207 | // int tmpTab = whichTab; |
212 | // // odebug << "" << tmpTab << "" << oendl; | 208 | // // odebug << "" << tmpTab << "" << oendl; |
213 | 209 | ||
214 | // for(int i =1; i < 3; i++) { | 210 | // for(int i =1; i < 3; i++) { |
215 | // TabWidget->setCurrentWidget(i - 1); | 211 | // TabWidget->setCurrentWidget(i - 1); |
216 | // populateView(); | 212 | // populateView(); |
217 | // } | 213 | // } |
218 | // TabWidget->setCurrentWidget( tmpTab - 1); | 214 | // TabWidget->setCurrentWidget( tmpTab - 1); |
219 | } | 215 | } |
220 | 216 | ||
221 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 217 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
222 | //owarn << "listclicked" << oendl; | 218 | //owarn << "listclicked" << oendl; |
223 | if(selectedItem) { | 219 | if(selectedItem) { |
224 | QString strItem=selectedItem->text(0); | 220 | QString strItem=selectedItem->text(0); |
225 | // owarn << strItem << oendl; | 221 | // owarn << strItem << oendl; |
226 | QString strSize=selectedItem->text(1); | 222 | QString strSize=selectedItem->text(1); |
227 | strSize=strSize.stripWhiteSpace(); | 223 | strSize=strSize.stripWhiteSpace(); |
228 | bool isDirectory = false; | 224 | bool isDirectory = false; |
229 | QString strItem2; | 225 | QString strItem2; |
230 | 226 | ||
231 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink | 227 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink |
232 | strItem2 = dealWithSymName((const QString&)strItem); | 228 | strItem2 = dealWithSymName((const QString&)strItem); |
233 | if(QDir(strItem2).exists() ) | 229 | if(QDir(strItem2).exists() ) |
234 | strItem = strItem2; | 230 | strItem = strItem2; |
235 | } | 231 | } |
236 | 232 | ||
237 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 233 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
@@ -250,39 +246,36 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | |||
250 | } | 246 | } |
251 | 247 | ||
252 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 248 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
253 | dealWithSchmooSchmaa( item->listView()); | 249 | dealWithSchmooSchmaa( item->listView()); |
254 | switch (mouse) { | 250 | switch (mouse) { |
255 | case 1: | 251 | case 1: |
256 | { | 252 | { |
257 | if(renameBox != 0 ) { | 253 | if(renameBox != 0 ) { |
258 | cancelRename(); | 254 | cancelRename(); |
259 | } | 255 | } |
260 | } | 256 | } |
261 | break; | 257 | break; |
262 | case 2: | ||
263 | menuTimer.start( 500, TRUE ); | ||
264 | break; | ||
265 | }; | 258 | }; |
266 | } | 259 | } |
267 | 260 | ||
268 | 261 | ||
269 | void AdvancedFm::switchToLocalTab() { | 262 | void AdvancedFm::switchToLocalTab() { |
270 | //owarn << "switch to local view" << oendl; | 263 | //owarn << "switch to local view" << oendl; |
271 | TabWidget->setCurrentWidget(0); | 264 | TabWidget->setCurrentWidget(0); |
272 | Local_View->setFocus(); | 265 | Local_View->setFocus(); |
273 | } | 266 | } |
274 | 267 | ||
275 | void AdvancedFm::switchToRemoteTab() { | 268 | void AdvancedFm::switchToRemoteTab() { |
276 | //owarn << "switch to local view" << oendl; | 269 | //owarn << "switch to local view" << oendl; |
277 | TabWidget->setCurrentWidget(1); | 270 | TabWidget->setCurrentWidget(1); |
278 | Remote_View->setFocus(); | 271 | Remote_View->setFocus(); |
279 | } | 272 | } |
280 | 273 | ||
281 | void AdvancedFm::readConfig() { | 274 | void AdvancedFm::readConfig() { |
282 | Config cfg("AdvancedFm"); | 275 | Config cfg("AdvancedFm"); |
283 | } | 276 | } |
284 | 277 | ||
285 | void AdvancedFm::writeConfig() { | 278 | void AdvancedFm::writeConfig() { |
286 | Config cfg("AdvancedFm"); | 279 | Config cfg("AdvancedFm"); |
287 | } | 280 | } |
288 | 281 | ||
@@ -320,25 +313,25 @@ void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | |||
320 | populateView(); | 313 | populateView(); |
321 | update(); | 314 | update(); |
322 | } | 315 | } |
323 | 316 | ||
324 | QStringList AdvancedFm::getPath() { | 317 | QStringList AdvancedFm::getPath() { |
325 | QStringList strList; | 318 | QStringList strList; |
326 | QListView *thisView=CurrentView(); | 319 | QListView *thisView=CurrentView(); |
327 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 320 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
328 | QListViewItemIterator it( thisView ); | 321 | QListViewItemIterator it( thisView ); |
329 | for ( ; it.current(); ++it ) { | 322 | for ( ; it.current(); ++it ) { |
330 | if ( it.current()->isSelected() ) { | 323 | if ( it.current()->isSelected() ) { |
331 | strList << it.current()->text(0); | 324 | strList << it.current()->text(0); |
332 | // odebug << it.current()->text(0) << oendl; | 325 | // odebug << it.current()->text(0) << oendl; |
333 | } | 326 | } |
334 | } | 327 | } |
335 | return strList; | 328 | return strList; |
336 | } | 329 | } |
337 | 330 | ||
338 | void AdvancedFm::homeButtonPushed() { | 331 | void AdvancedFm::homeButtonPushed() { |
339 | QString current = QDir::homeDirPath(); | 332 | QString current = QDir::homeDirPath(); |
340 | chdir( current.latin1() ); | 333 | chdir( current.latin1() ); |
341 | CurrentDir()->cd( current, TRUE); | 334 | CurrentDir()->cd( current, TRUE); |
342 | populateView(); | 335 | populateView(); |
343 | update(); | 336 | update(); |
344 | } | 337 | } |
@@ -371,25 +364,25 @@ void AdvancedFm::CFButtonPushed() { | |||
371 | update(); | 364 | update(); |
372 | } | 365 | } |
373 | 366 | ||
374 | 367 | ||
375 | void AdvancedFm::doAbout() { | 368 | void AdvancedFm::doAbout() { |
376 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 369 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
377 | "is copyright 2002-2003 by\n" | 370 | "is copyright 2002-2003 by\n" |
378 | "L.J.Potter<llornkcor@handhelds.org>\n" | 371 | "L.J.Potter<llornkcor@handhelds.org>\n" |
379 | "and is licensed by the GPL")); | 372 | "and is licensed by the GPL")); |
380 | } | 373 | } |
381 | 374 | ||
382 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 375 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
383 | // owarn << "key " << e->key() << "" << oendl; | 376 | // owarn << "key " << e->key() << "" << oendl; |
384 | // if( CurrentView()->hasFocus() ) | 377 | // if( CurrentView()->hasFocus() ) |
385 | { | 378 | { |
386 | switch ( e->key() ) { | 379 | switch ( e->key() ) { |
387 | case Key_Left: | 380 | case Key_Left: |
388 | upDir(); | 381 | upDir(); |
389 | break; | 382 | break; |
390 | case Key_Next: | 383 | case Key_Next: |
391 | break; | 384 | break; |
392 | case Key_Return: | 385 | case Key_Return: |
393 | case Key_Enter: | 386 | case Key_Enter: |
394 | navigateToSelected(); | 387 | navigateToSelected(); |
395 | break; | 388 | break; |
@@ -597,30 +590,24 @@ void AdvancedFm::showFileMenu() { | |||
597 | m->setItemChecked(m->idAt(0),FALSE); | 590 | m->setItemChecked(m->idAt(0),FALSE); |
598 | 591 | ||
599 | if(Ir::supported()) | 592 | if(Ir::supported()) |
600 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 593 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
601 | m->setFocus(); | 594 | m->setFocus(); |
602 | 595 | ||
603 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 596 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
604 | 597 | ||
605 | if(m) delete m; | 598 | if(m) delete m; |
606 | } | 599 | } |
607 | 600 | ||
608 | 601 | ||
609 | void AdvancedFm::cancelMenuTimer() { | ||
610 | |||
611 | if( menuTimer.isActive() ) | ||
612 | menuTimer.stop(); | ||
613 | } | ||
614 | |||
615 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 602 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
616 | struct statfs fss; | 603 | struct statfs fss; |
617 | if ( !statfs( path.latin1(), &fss ) ) { | 604 | if ( !statfs( path.latin1(), &fss ) ) { |
618 | int blkSize = fss.f_bsize; | 605 | int blkSize = fss.f_bsize; |
619 | // int totalBlks = fs.f_blocks; | 606 | // int totalBlks = fs.f_blocks; |
620 | int availBlks = fss.f_bavail; | 607 | int availBlks = fss.f_bavail; |
621 | 608 | ||
622 | long mult = blkSize / 1024; | 609 | long mult = blkSize / 1024; |
623 | long div = 1024 / blkSize; | 610 | long div = 1024 / blkSize; |
624 | if ( !mult ) mult = 1; | 611 | if ( !mult ) mult = 1; |
625 | if ( !div ) div = 1; | 612 | if ( !div ) div = 1; |
626 | 613 | ||
@@ -629,25 +616,25 @@ QString AdvancedFm::checkDiskSpace(const QString &path) { | |||
629 | } | 616 | } |
630 | return ""; | 617 | return ""; |
631 | } | 618 | } |
632 | 619 | ||
633 | void AdvancedFm::addToDocs() { | 620 | void AdvancedFm::addToDocs() { |
634 | QStringList strListPaths = getPath(); | 621 | QStringList strListPaths = getPath(); |
635 | QDir *thisDir = CurrentDir(); | 622 | QDir *thisDir = CurrentDir(); |
636 | 623 | ||
637 | if( strListPaths.count() > 0) { | 624 | if( strListPaths.count() > 0) { |
638 | QString curFile; | 625 | QString curFile; |
639 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 626 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
640 | curFile = thisDir->canonicalPath()+"/"+(*it); | 627 | curFile = thisDir->canonicalPath()+"/"+(*it); |
641 | // odebug << curFile << oendl; | 628 | // odebug << curFile << oendl; |
642 | QFileInfo fi(curFile); | 629 | QFileInfo fi(curFile); |
643 | DocLnk f; | 630 | DocLnk f; |
644 | // curFile.replace(QRegExp("\\..*"),""); | 631 | // curFile.replace(QRegExp("\\..*"),""); |
645 | f.setName(fi.baseName() ); | 632 | f.setName(fi.baseName() ); |
646 | f.setFile( curFile); | 633 | f.setFile( curFile); |
647 | f.writeLink(); | 634 | f.writeLink(); |
648 | } | 635 | } |
649 | } | 636 | } |
650 | } | 637 | } |
651 | 638 | ||
652 | 639 | ||
653 | void AdvancedFm::customDirsToMenu() { | 640 | void AdvancedFm::customDirsToMenu() { |
@@ -702,25 +689,25 @@ void AdvancedFm::addCustomDir() { | |||
702 | } | 689 | } |
703 | if(addIt) { | 690 | if(addIt) { |
704 | menuButton->insertItem(dir); | 691 | menuButton->insertItem(dir); |
705 | // customDirMenu->insertItem(dir); | 692 | // customDirMenu->insertItem(dir); |
706 | list << dir; | 693 | list << dir; |
707 | } | 694 | } |
708 | 695 | ||
709 | cfg.writeEntry("CustomDir", list, ','); | 696 | cfg.writeEntry("CustomDir", list, ','); |
710 | cfg.write(); | 697 | cfg.write(); |
711 | } | 698 | } |
712 | 699 | ||
713 | void AdvancedFm::removeCustomDir() { | 700 | void AdvancedFm::removeCustomDir() { |
714 | // odebug << "remove custom dir" << oendl; | 701 | // odebug << "remove custom dir" << oendl; |
715 | Config cfg("AdvancedFm"); | 702 | Config cfg("AdvancedFm"); |
716 | cfg.setGroup("Menu"); | 703 | cfg.setGroup("Menu"); |
717 | QString dir; | 704 | QString dir; |
718 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 705 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
719 | QStringList list2; | 706 | QStringList list2; |
720 | dir = CurrentDir()->canonicalPath(); | 707 | dir = CurrentDir()->canonicalPath(); |
721 | int ramble=2; | 708 | int ramble=2; |
722 | // int ramble=-24; | 709 | // int ramble=-24; |
723 | //first remove list | 710 | //first remove list |
724 | if(list.grep(dir,true).isEmpty()) { | 711 | if(list.grep(dir,true).isEmpty()) { |
725 | QMessageBox::message(tr( "AdvancedFm" ), | 712 | QMessageBox::message(tr( "AdvancedFm" ), |
726 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); | 713 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); |
@@ -737,25 +724,25 @@ void AdvancedFm::removeCustomDir() { | |||
737 | ramble++; | 724 | ramble++; |
738 | // ramble--; | 725 | // ramble--; |
739 | } | 726 | } |
740 | 727 | ||
741 | cfg.writeEntry("CustomDir", list2, ','); | 728 | cfg.writeEntry("CustomDir", list2, ','); |
742 | cfg.write(); | 729 | cfg.write(); |
743 | } | 730 | } |
744 | // customDirsToMenu(); | 731 | // customDirsToMenu(); |
745 | 732 | ||
746 | } | 733 | } |
747 | 734 | ||
748 | void AdvancedFm::gotoCustomDir(const QString &dir) { | 735 | void AdvancedFm::gotoCustomDir(const QString &dir) { |
749 | // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; | 736 | // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; |
750 | // QString curDir = dir; | 737 | // QString curDir = dir; |
751 | // QDir *thisDir = CurrentDir(); | 738 | // QDir *thisDir = CurrentDir(); |
752 | // if( curDir.isEmpty()) { | 739 | // if( curDir.isEmpty()) { |
753 | // } | 740 | // } |
754 | if( dir == s_addBookmark) { | 741 | if( dir == s_addBookmark) { |
755 | addCustomDir(); | 742 | addCustomDir(); |
756 | } | 743 | } |
757 | if( dir == s_removeBookmark) { | 744 | if( dir == s_removeBookmark) { |
758 | removeCustomDir( ); | 745 | removeCustomDir( ); |
759 | } else { | 746 | } else { |
760 | gotoDirectory( dir); | 747 | gotoDirectory( dir); |
761 | // if(QDir( curDir).exists() ) | 748 | // if(QDir( curDir).exists() ) |
@@ -778,68 +765,68 @@ QDir *AdvancedFm::CurrentDir() { | |||
778 | } | 765 | } |
779 | 766 | ||
780 | QDir *AdvancedFm::OtherDir() { | 767 | QDir *AdvancedFm::OtherDir() { |
781 | if ( whichTab == 1) { | 768 | if ( whichTab == 1) { |
782 | return ¤tRemoteDir; | 769 | return ¤tRemoteDir; |
783 | } else { | 770 | } else { |
784 | return ¤tDir; | 771 | return ¤tDir; |
785 | } | 772 | } |
786 | } | 773 | } |
787 | 774 | ||
788 | QListView * AdvancedFm::CurrentView() { | 775 | QListView * AdvancedFm::CurrentView() { |
789 | if ( whichTab == 1) { | 776 | if ( whichTab == 1) { |
790 | // owarn << "CurrentView Tab 1" << oendl; | 777 | // owarn << "CurrentView Tab 1" << oendl; |
791 | return Local_View; | 778 | return Local_View; |
792 | } else { | 779 | } else { |
793 | // owarn << "CurrentView Tab 2" << oendl; | 780 | // owarn << "CurrentView Tab 2" << oendl; |
794 | return Remote_View; | 781 | return Remote_View; |
795 | } | 782 | } |
796 | } | 783 | } |
797 | 784 | ||
798 | QListView * AdvancedFm::OtherView() { | 785 | QListView * AdvancedFm::OtherView() { |
799 | if ( whichTab == 1) | 786 | if ( whichTab == 1) |
800 | return Remote_View; | 787 | return Remote_View; |
801 | else | 788 | else |
802 | return Local_View; | 789 | return Local_View; |
803 | } | 790 | } |
804 | 791 | ||
805 | void AdvancedFm::setOtherTabCurrent() { | 792 | void AdvancedFm::setOtherTabCurrent() { |
806 | // owarn << "setOtherTabCurrent() " << whichTab << "" << oendl; | 793 | // owarn << "setOtherTabCurrent() " << whichTab << "" << oendl; |
807 | if ( whichTab == 1) { | 794 | if ( whichTab == 1) { |
808 | TabWidget->setCurrentWidget(1); | 795 | TabWidget->setCurrentWidget(1); |
809 | } else { | 796 | } else { |
810 | TabWidget->setCurrentWidget(0); | 797 | TabWidget->setCurrentWidget(0); |
811 | } | 798 | } |
812 | OtherView()->setFocus(); | 799 | OtherView()->setFocus(); |
813 | OtherView()->setSelected( CurrentView()->firstChild(), true); | 800 | OtherView()->setSelected( CurrentView()->firstChild(), true); |
814 | } | 801 | } |
815 | 802 | ||
816 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | 803 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { |
817 | // odebug << "qcop message "+msg << oendl; | 804 | // odebug << "qcop message "+msg << oendl; |
818 | QDataStream stream ( data, IO_ReadOnly ); | 805 | QDataStream stream ( data, IO_ReadOnly ); |
819 | if ( msg == "openDirectory(QString)" ) { | 806 | if ( msg == "openDirectory(QString)" ) { |
820 | // odebug << "received" << oendl; | 807 | // odebug << "received" << oendl; |
821 | QString file; | 808 | QString file; |
822 | stream >> file; | 809 | stream >> file; |
823 | gotoDirectory( (const QString &) file); | 810 | gotoDirectory( (const QString &) file); |
824 | } | 811 | } |
825 | } | 812 | } |
826 | 813 | ||
827 | void AdvancedFm::setDocument(const QString &file) { | 814 | void AdvancedFm::setDocument(const QString &file) { |
828 | gotoDirectory( file); | 815 | gotoDirectory( file); |
829 | 816 | ||
830 | } | 817 | } |
831 | 818 | ||
832 | void AdvancedFm::gotoDirectory(const QString &file) { | 819 | void AdvancedFm::gotoDirectory(const QString &file) { |
833 | // owarn << "goto dir "+file << oendl; | 820 | // owarn << "goto dir "+file << oendl; |
834 | QString curDir = file; | 821 | QString curDir = file; |
835 | QDir *thisDir = CurrentDir(); | 822 | QDir *thisDir = CurrentDir(); |
836 | if(QDir( curDir).exists() ) { | 823 | if(QDir( curDir).exists() ) { |
837 | thisDir->setPath( curDir ); | 824 | thisDir->setPath( curDir ); |
838 | chdir( curDir.latin1() ); | 825 | chdir( curDir.latin1() ); |
839 | thisDir->cd( curDir, TRUE); | 826 | thisDir->cd( curDir, TRUE); |
840 | populateView(); | 827 | populateView(); |
841 | } | 828 | } |
842 | else if(QFileInfo(curDir).exists()) { | 829 | else if(QFileInfo(curDir).exists()) { |
843 | QFileInfo fileInfo(curDir); | 830 | QFileInfo fileInfo(curDir); |
844 | curDir=fileInfo.dirPath(); | 831 | curDir=fileInfo.dirPath(); |
845 | if(QDir( curDir).exists() ) { | 832 | if(QDir( curDir).exists() ) { |
@@ -857,25 +844,25 @@ void AdvancedFm::findFile(const QString &fileName) { | |||
857 | QFileInfo fi(fileName); | 844 | QFileInfo fi(fileName); |
858 | QListView *thisView = CurrentView(); | 845 | QListView *thisView = CurrentView(); |
859 | QListViewItemIterator it( thisView ); | 846 | QListViewItemIterator it( thisView ); |
860 | for ( ; it.current(); ++it ) { | 847 | for ( ; it.current(); ++it ) { |
861 | if(it.current()->text(0) == fi.fileName()) { | 848 | if(it.current()->text(0) == fi.fileName()) { |
862 | it.current()->setSelected(true); | 849 | it.current()->setSelected(true); |
863 | thisView->ensureItemVisible(it.current()); | 850 | thisView->ensureItemVisible(it.current()); |
864 | } | 851 | } |
865 | } | 852 | } |
866 | } | 853 | } |
867 | 854 | ||
868 | void AdvancedFm::slotSwitchMenu(int ) { | 855 | void AdvancedFm::slotSwitchMenu(int ) { |
869 | // odebug << "Switch " << item << "" << oendl; | 856 | // odebug << "Switch " << item << "" << oendl; |
870 | // viewMenu->setItemChecked(item, true); | 857 | // viewMenu->setItemChecked(item, true); |
871 | } | 858 | } |
872 | 859 | ||
873 | void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { | 860 | void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { |
874 | tabChanged( w); | 861 | tabChanged( w); |
875 | if( w == Local_View) { | 862 | if( w == Local_View) { |
876 | Remote_View->clearFocus(); | 863 | Remote_View->clearFocus(); |
877 | } else { | 864 | } else { |
878 | Local_View->clearFocus(); | 865 | Local_View->clearFocus(); |
879 | } | 866 | } |
880 | } | 867 | } |
881 | 868 | ||