-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 44 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.pro | 24 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 1681 | ||||
-rw-r--r-- | noncore/apps/advancedfm/filePermissions.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/advancedfm/output.cpp | 23 |
6 files changed, 888 insertions, 898 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 | |||
@@ -62,53 +62,53 @@ AdvancedFm::~AdvancedFm() { | |||
62 | void AdvancedFm::cleanUp() { | 62 | void 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 | ||
73 | void AdvancedFm::tabChanged(QWidget *) { | 73 | void 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 | ||
94 | void AdvancedFm::populateView() { | 94 | void 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; |
@@ -151,87 +151,87 @@ void AdvancedFm::populateView() { | |||
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 | ||
206 | void AdvancedFm::rePopulate() { | 206 | void 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 | ||
221 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 221 | void 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 ) { |
@@ -258,31 +258,31 @@ void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , in | |||
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 | ||
269 | void AdvancedFm::switchToLocalTab() { | 269 | void 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 | ||
275 | void AdvancedFm::switchToRemoteTab() { | 275 | void 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 | ||
281 | void AdvancedFm::readConfig() { | 281 | void AdvancedFm::readConfig() { |
282 | Config cfg("AdvancedFm"); | 282 | Config cfg("AdvancedFm"); |
283 | } | 283 | } |
284 | 284 | ||
285 | void AdvancedFm::writeConfig() { | 285 | void AdvancedFm::writeConfig() { |
286 | Config cfg("AdvancedFm"); | 286 | Config cfg("AdvancedFm"); |
287 | } | 287 | } |
288 | 288 | ||
@@ -320,25 +320,25 @@ void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | |||
320 | populateView(); | 320 | populateView(); |
321 | update(); | 321 | update(); |
322 | } | 322 | } |
323 | 323 | ||
324 | QStringList AdvancedFm::getPath() { | 324 | QStringList 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 | ||
338 | void AdvancedFm::homeButtonPushed() { | 338 | void 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 | } |
@@ -371,25 +371,25 @@ void AdvancedFm::CFButtonPushed() { | |||
371 | update(); | 371 | update(); |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | void AdvancedFm::doAbout() { | 375 | void 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 | ||
382 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 382 | void 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; |
@@ -629,25 +629,25 @@ QString AdvancedFm::checkDiskSpace(const QString &path) { | |||
629 | } | 629 | } |
630 | return ""; | 630 | return ""; |
631 | } | 631 | } |
632 | 632 | ||
633 | void AdvancedFm::addToDocs() { | 633 | void 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 | ||
653 | void AdvancedFm::customDirsToMenu() { | 653 | void AdvancedFm::customDirsToMenu() { |
@@ -702,25 +702,25 @@ void AdvancedFm::addCustomDir() { | |||
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 | ||
713 | void AdvancedFm::removeCustomDir() { | 713 | void 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!")); |
@@ -737,25 +737,25 @@ void AdvancedFm::removeCustomDir() { | |||
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 | ||
748 | void AdvancedFm::gotoCustomDir(const QString &dir) { | 748 | void 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() ) |
@@ -778,68 +778,68 @@ QDir *AdvancedFm::CurrentDir() { | |||
778 | } | 778 | } |
779 | 779 | ||
780 | QDir *AdvancedFm::OtherDir() { | 780 | QDir *AdvancedFm::OtherDir() { |
781 | if ( whichTab == 1) { | 781 | if ( whichTab == 1) { |
782 | return ¤tRemoteDir; | 782 | return ¤tRemoteDir; |
783 | } else { | 783 | } else { |
784 | return ¤tDir; | 784 | return ¤tDir; |
785 | } | 785 | } |
786 | } | 786 | } |
787 | 787 | ||
788 | QListView * AdvancedFm::CurrentView() { | 788 | QListView * 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 | ||
798 | QListView * AdvancedFm::OtherView() { | 798 | QListView * 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 | ||
805 | void AdvancedFm::setOtherTabCurrent() { | 805 | void 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 | ||
816 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | 816 | void 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 | ||
827 | void AdvancedFm::setDocument(const QString &file) { | 827 | void AdvancedFm::setDocument(const QString &file) { |
828 | gotoDirectory( file); | 828 | gotoDirectory( file); |
829 | 829 | ||
830 | } | 830 | } |
831 | 831 | ||
832 | void AdvancedFm::gotoDirectory(const QString &file) { | 832 | void 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() ) { |
@@ -857,25 +857,25 @@ void 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 | ||
868 | void AdvancedFm::slotSwitchMenu(int ) { | 868 | void 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 | ||
873 | void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { | 873 | void 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 | ||
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro index 716343d..f1c518e 100644 --- a/noncore/apps/advancedfm/advancedfm.pro +++ b/noncore/apps/advancedfm/advancedfm.pro | |||
@@ -1,35 +1,15 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on quick-app | 2 | CONFIG += qt warn_on quick-app |
3 | # CONFIG += qt warn_on | ||
4 | HEADERS = advancedfm.h filePermissions.h output.h | 3 | HEADERS = advancedfm.h filePermissions.h output.h |
5 | SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp | 4 | SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp |
6 | TARGET = advancedfm | 5 | TARGET = advancedfm |
7 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 7 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopiecore2 -lopieui2 | 8 | LIBS += -lqpe -lopiecore2 -lopieui2 |
10 | |||
11 | TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ | ||
12 | ../../../i18n/nl/advancedfm.ts \ | ||
13 | ../../../i18n/da/advancedfm.ts \ | ||
14 | ../../../i18n/xx/advancedfm.ts \ | ||
15 | ../../../i18n/en/advancedfm.ts \ | ||
16 | ../../../i18n/es/advancedfm.ts \ | ||
17 | ../../../i18n/fr/advancedfm.ts \ | ||
18 | ../../../i18n/hu/advancedfm.ts \ | ||
19 | ../../../i18n/ja/advancedfm.ts \ | ||
20 | ../../../i18n/ko/advancedfm.ts \ | ||
21 | ../../../i18n/no/advancedfm.ts \ | ||
22 | ../../../i18n/pl/advancedfm.ts \ | ||
23 | ../../../i18n/pt/advancedfm.ts \ | ||
24 | ../../../i18n/pt_BR/advancedfm.ts \ | ||
25 | ../../../i18n/sl/advancedfm.ts \ | ||
26 | ../../../i18n/zh_CN/advancedfm.ts \ | ||
27 | ../../../i18n/zh_TW/advancedfm.ts | ||
28 | |||
29 | 9 | ||
30 | !contains(CONFIG,quick-app) { | 10 | !contains(CONFIG,quick-app) { |
31 | DESTDIR = $(OPIEDIR)/bin | 11 | DESTDIR = $(OPIEDIR)/bin |
32 | DEFINES += NOQUICKLAUNCH | 12 | DEFINES += NOQUICKLAUNCH |
33 | } | 13 | } |
34 | 14 | ||
35 | include ( $(OPIEDIR)/include.pro ) | 15 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index 2997c55..29335f8 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -2,41 +2,45 @@ | |||
2 | advancedfmData.cpp | 2 | advancedfmData.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Mon 09-23-2002 13:24:11 | 4 | ** Created: Mon 09-23-2002 13:24:11 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | 13 | ||
14 | /* OPIE */ | ||
15 | #include <opie2/odebug.h> | ||
14 | #include <qpe/storage.h> | 16 | #include <qpe/storage.h> |
15 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
17 | #include <qpe/menubutton.h> | 19 | #include <qpe/menubutton.h> |
20 | using namespace Opie::Core; | ||
21 | using namespace Opie::Ui; | ||
18 | 22 | ||
23 | /* QT */ | ||
19 | #include <qlayout.h> | 24 | #include <qlayout.h> |
20 | #include <qhbox.h> | 25 | #include <qhbox.h> |
21 | #include <qmenubar.h> | 26 | #include <qmenubar.h> |
22 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
23 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
24 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
25 | #include <qlistview.h> | 30 | #include <qlistview.h> |
26 | 31 | ||
32 | /* STD */ | ||
27 | #include <sys/utsname.h> | 33 | #include <sys/utsname.h> |
28 | 34 | ||
29 | |||
30 | using namespace Opie::Ui; | ||
31 | void AdvancedFm::init() { | 35 | void AdvancedFm::init() { |
32 | b = false; | 36 | b = false; |
33 | setCaption( tr( "AdvancedFm" ) ); | 37 | setCaption( tr( "AdvancedFm" ) ); |
34 | 38 | ||
35 | QVBoxLayout *layout = new QVBoxLayout( this ); | 39 | QVBoxLayout *layout = new QVBoxLayout( this ); |
36 | layout->setSpacing( 2); | 40 | layout->setSpacing( 2); |
37 | layout->setMargin( 0); // squeeze | 41 | layout->setMargin( 0); // squeeze |
38 | 42 | ||
39 | QMenuBar *menuBar = new QMenuBar(this); | 43 | QMenuBar *menuBar = new QMenuBar(this); |
40 | menuBar->setMargin( 0 ); // squeeze | 44 | menuBar->setMargin( 0 ); // squeeze |
41 | fileMenu = new QPopupMenu( this ); | 45 | fileMenu = new QPopupMenu( this ); |
42 | viewMenu = new QPopupMenu( this ); | 46 | viewMenu = new QPopupMenu( this ); |
@@ -210,29 +214,29 @@ void AdvancedFm::init() { | |||
210 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 214 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
211 | */ | 215 | */ |
212 | 216 | ||
213 | /////////////// | 217 | /////////////// |
214 | 218 | ||
215 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 219 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
216 | zaurusDevice=TRUE; | 220 | zaurusDevice=TRUE; |
217 | else | 221 | else |
218 | zaurusDevice=FALSE; | 222 | zaurusDevice=FALSE; |
219 | 223 | ||
220 | 224 | ||
221 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { | 225 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { |
222 | qDebug("not have sd"); | 226 | odebug << "not have sd" << oendl; |
223 | sdButton->hide(); | 227 | sdButton->hide(); |
224 | } | 228 | } |
225 | if( !StorageInfo::hasCf() ) { | 229 | if( !StorageInfo::hasCf() ) { |
226 | qDebug("not have cf"); | 230 | odebug << "not have cf" << oendl; |
227 | cfButton->hide(); | 231 | cfButton->hide(); |
228 | } | 232 | } |
229 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 233 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
230 | currentDir.setPath( QDir::currentDirPath()); | 234 | currentDir.setPath( QDir::currentDirPath()); |
231 | 235 | ||
232 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 236 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
233 | currentRemoteDir.setPath( QDir::currentDirPath()); | 237 | currentRemoteDir.setPath( QDir::currentDirPath()); |
234 | 238 | ||
235 | // b = TRUE; | 239 | // b = TRUE; |
236 | 240 | ||
237 | filterStr="*"; | 241 | filterStr="*"; |
238 | showMenuHidden(); | 242 | showMenuHidden(); |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 81a4318..d34f330 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,839 +1,842 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | |
13 | #include "output.h" | 13 | #include "advancedfm.h" |
14 | #include "filePermissions.h" | 14 | #include "output.h" |
15 | 15 | #include "filePermissions.h" | |
16 | #include <qpe/lnkproperties.h> | 16 | |
17 | #include <qpe/qpeapplication.h> | 17 | /* OPIE */ |
18 | #include <qpe/applnk.h> | 18 | #include <opie2/odebug.h> |
19 | 19 | #include <qpe/lnkproperties.h> | |
20 | #include <qmessagebox.h> | 20 | #include <qpe/qpeapplication.h> |
21 | 21 | #include <qpe/applnk.h> | |
22 | 22 | using namespace Opie::Core; | |
23 | #include <qpopupmenu.h> | 23 | |
24 | #include <qlistview.h> | 24 | /* QT*/ |
25 | 25 | ||
26 | #include <errno.h> | 26 | #include <qmessagebox.h> |
27 | #include <stdlib.h> | 27 | #include <qpopupmenu.h> |
28 | #include <unistd.h> | 28 | #include <qlistview.h> |
29 | #include <sys/stat.h> | 29 | |
30 | #include <dirent.h> | 30 | /* STD */ |
31 | #include <sys/sendfile.h> | 31 | |
32 | #include <fcntl.h> | 32 | #include <errno.h> |
33 | 33 | #include <stdlib.h> | |
34 | 34 | #include <unistd.h> | |
35 | using namespace Opie::Core; | 35 | #include <sys/stat.h> |
36 | using namespace Opie::Core; | 36 | #include <dirent.h> |
37 | void AdvancedFm::doDirChange() { | 37 | #include <sys/sendfile.h> |
38 | QString pathItem = CurrentView()->currentItem()->text(0); | 38 | #include <fcntl.h> |
39 | if( pathItem == "../") { | 39 | |
40 | ListClicked( CurrentView()->currentItem()); | 40 | void AdvancedFm::doDirChange() { |
41 | } else { | 41 | QString pathItem = CurrentView()->currentItem()->text(0); |
42 | if( pathItem.find(" -> ",0,TRUE) != -1) | 42 | if( pathItem == "../") { |
43 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | 43 | ListClicked( CurrentView()->currentItem()); |
44 | // qWarning(pathItem); | 44 | } else { |
45 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | 45 | if( pathItem.find(" -> ",0,TRUE) != -1) |
46 | } | 46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; |
47 | } | 47 | // owarn << pathItem << oendl; |
48 | 48 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | |
49 | void AdvancedFm::showMenuHidden() { | 49 | } |
50 | if (b) { | 50 | } |
51 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 51 | |
52 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 52 | void AdvancedFm::showMenuHidden() { |
53 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 53 | if (b) { |
54 | } else { | 54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
55 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
56 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
57 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 57 | } else { |
58 | } | 58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
59 | b = !b; | 59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
60 | populateView(); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
61 | } | 61 | } |
62 | 62 | b = !b; | |
63 | void AdvancedFm::showHidden() { | 63 | populateView(); |
64 | if (b) { | 64 | } |
65 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 65 | |
66 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 66 | void AdvancedFm::showHidden() { |
67 | } else { | 67 | if (b) { |
68 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 68 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
69 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 69 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
70 | } | 70 | } else { |
71 | populateView(); | 71 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
72 | } | 72 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
73 | 73 | } | |
74 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 74 | populateView(); |
75 | QString strItem = fileName; | 75 | } |
76 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 76 | |
77 | } | 77 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
78 | 78 | QString strItem = fileName; | |
79 | void AdvancedFm::runThis() { | 79 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
80 | if( !CurrentView()->currentItem()) return; | 80 | } |
81 | QString fs; | 81 | |
82 | QDir *thisDir = CurrentDir(); | 82 | void AdvancedFm::runThis() { |
83 | 83 | if( !CurrentView()->currentItem()) return; | |
84 | QString curFile = CurrentView()->currentItem()->text(0); | 84 | QString fs; |
85 | QString path = thisDir->canonicalPath(); | 85 | QDir *thisDir = CurrentDir(); |
86 | 86 | ||
87 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 87 | QString curFile = CurrentView()->currentItem()->text(0); |
88 | 88 | QString path = thisDir->canonicalPath(); | |
89 | curFile = dealWithSymName((const QString&)curFile); | 89 | |
90 | 90 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | |
91 | if(curFile != "../") { | 91 | |
92 | 92 | curFile = dealWithSymName((const QString&)curFile); | |
93 | fs = getFileSystemType((const QString &) path); | 93 | |
94 | QFileInfo fileInfo( path + "/" + curFile); | 94 | if(curFile != "../") { |
95 | // qDebug( fileInfo.owner()); | 95 | |
96 | 96 | fs = getFileSystemType((const QString &) path); | |
97 | if( (fileInfo.permission( QFileInfo::ExeUser) | 97 | QFileInfo fileInfo( path + "/" + curFile); |
98 | | fileInfo.permission( QFileInfo::ExeGroup) | 98 | // odebug << fileInfo.owner() << oendl; |
99 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 99 | |
100 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 100 | if( (fileInfo.permission( QFileInfo::ExeUser) |
101 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 101 | | fileInfo.permission( QFileInfo::ExeGroup) |
102 | e << curFile; | 102 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
103 | } else { | 103 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
104 | curFile = path + "/" + curFile; | 104 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
105 | DocLnk nf(curFile); | 105 | e << curFile; |
106 | QString execStr = nf.exec(); | 106 | } else { |
107 | // qDebug( execStr); | 107 | curFile = path + "/" + curFile; |
108 | if( execStr.isEmpty() ) { | 108 | DocLnk nf(curFile); |
109 | } else { | 109 | QString execStr = nf.exec(); |
110 | nf.execute(); | 110 | // odebug << execStr << oendl; |
111 | } | 111 | if( execStr.isEmpty() ) { |
112 | } | 112 | } else { |
113 | } | 113 | nf.execute(); |
114 | } | 114 | } |
115 | 115 | } | |
116 | void AdvancedFm::runText() { | 116 | } |
117 | if( !CurrentView()->currentItem()) return; | 117 | } |
118 | QString curFile = CurrentView()->currentItem()->text(0); | 118 | |
119 | if(curFile != "../") { | 119 | void AdvancedFm::runText() { |
120 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 120 | if( !CurrentView()->currentItem()) return; |
121 | curFile = dealWithSymName((const QString&)curFile); | 121 | QString curFile = CurrentView()->currentItem()->text(0); |
122 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 122 | if(curFile != "../") { |
123 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 123 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
124 | e << curFile; | 124 | curFile = dealWithSymName((const QString&)curFile); |
125 | } | 125 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
126 | } | 126 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
127 | 127 | e << curFile; | |
128 | void AdvancedFm::makeDir() { | 128 | } |
129 | InputDialog *fileDlg; | 129 | } |
130 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 130 | |
131 | fileDlg->exec(); | 131 | void AdvancedFm::makeDir() { |
132 | if( fileDlg->result() == 1 ) { | 132 | InputDialog *fileDlg; |
133 | QDir *thisDir = CurrentDir(); | 133 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
134 | QString filename = fileDlg->LineEdit1->text(); | 134 | fileDlg->exec(); |
135 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 135 | if( fileDlg->result() == 1 ) { |
136 | } | 136 | QDir *thisDir = CurrentDir(); |
137 | populateView(); | 137 | QString filename = fileDlg->LineEdit1->text(); |
138 | } | 138 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
139 | 139 | } | |
140 | void AdvancedFm::doDelete() { | 140 | populateView(); |
141 | QStringList curFileList = getPath(); | 141 | } |
142 | bool doMsg=true; | 142 | |
143 | int count = curFileList.count(); | 143 | void AdvancedFm::doDelete() { |
144 | if( count > 0) { | 144 | QStringList curFileList = getPath(); |
145 | if(count > 1 ) { | 145 | bool doMsg=true; |
146 | QString msg; | 146 | int count = curFileList.count(); |
147 | msg=tr("Really delete\n%1 files?").arg(count); | 147 | if( count > 0) { |
148 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 148 | if(count > 1 ) { |
149 | ,tr("Yes"),tr("No"),0,0,1) ) | 149 | QString msg; |
150 | { | 150 | msg=tr("Really delete\n%1 files?").arg(count); |
151 | case 0: | 151 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
152 | doMsg=false; | 152 | ,tr("Yes"),tr("No"),0,0,1) ) |
153 | break; | 153 | { |
154 | case 1: | 154 | case 0: |
155 | return; | 155 | doMsg=false; |
156 | break; | 156 | break; |
157 | }; | 157 | case 1: |
158 | } | 158 | return; |
159 | 159 | break; | |
160 | QString myFile; | 160 | }; |
161 | 161 | } | |
162 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 162 | |
163 | myFile = (*it); | 163 | QString myFile; |
164 | if( myFile.find(" -> ",0,TRUE) != -1) | 164 | |
165 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 165 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
166 | 166 | myFile = (*it); | |
167 | QString f = CurrentDir()->canonicalPath(); | 167 | if( myFile.find(" -> ",0,TRUE) != -1) |
168 | if(f.right(1).find("/",0,TRUE) == -1) | 168 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
169 | f += "/"; | 169 | |
170 | f += myFile; | 170 | QString f = CurrentDir()->canonicalPath(); |
171 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 171 | if(f.right(1).find("/",0,TRUE) == -1) |
172 | //if file is a directory | 172 | f += "/"; |
173 | 173 | f += myFile; | |
174 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 174 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
175 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , | 175 | //if file is a directory |
176 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 176 | |
177 | case 0: | 177 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
178 | { | 178 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , |
179 | f=f.left(f.length()-1); | 179 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
180 | QString cmd="rm -rf "+f; | 180 | case 0: |
181 | startProcess( (const QString)cmd.latin1() ); | 181 | { |
182 | populateView(); | 182 | f=f.left(f.length()-1); |
183 | } | 183 | QString cmd="rm -rf "+f; |
184 | break; | 184 | startProcess( (const QString)cmd.latin1() ); |
185 | case 1: | 185 | populateView(); |
186 | // exit | 186 | } |
187 | break; | 187 | break; |
188 | }; | 188 | case 1: |
189 | 189 | // exit | |
190 | } else { | 190 | break; |
191 | if(doMsg) { | 191 | }; |
192 | switch ( QMessageBox::warning(this,tr("Delete"), | 192 | |
193 | tr("Really delete\n%1?").arg( myFile ), | 193 | } else { |
194 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 194 | if(doMsg) { |
195 | case 1: | 195 | switch ( QMessageBox::warning(this,tr("Delete"), |
196 | return; | 196 | tr("Really delete\n%1?").arg( myFile ), |
197 | break; | 197 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
198 | }; | 198 | case 1: |
199 | } | 199 | return; |
200 | 200 | break; | |
201 | QString cmd="rm "+f; | 201 | }; |
202 | QFile file(f); | 202 | } |
203 | QFileInfo fi(myFile); | 203 | |
204 | if( fi.fileName().find("../",0,TRUE)==-1) { | 204 | QString cmd="rm "+f; |
205 | // qDebug("remove link files "+myFile); | 205 | QFile file(f); |
206 | 206 | QFileInfo fi(myFile); | |
207 | // DocLnk lnk(f); | 207 | if( fi.fileName().find("../",0,TRUE)==-1) { |
208 | DocLnk *lnk; | 208 | // odebug << "remove link files "+myFile << oendl; |
209 | lnk = new DocLnk(f); | 209 | |
210 | // qDebug("Deleting doclnk " + lnk->linkFile()); | 210 | // DocLnk lnk(f); |
211 | if(lnk->isValid()) | 211 | DocLnk *lnk; |
212 | lnk->removeLinkFile(); | 212 | lnk = new DocLnk(f); |
213 | // delete lnk; | 213 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; |
214 | file.remove(); | 214 | if(lnk->isValid()) |
215 | } | 215 | lnk->removeLinkFile(); |
216 | } | 216 | // delete lnk; |
217 | } | 217 | file.remove(); |
218 | } | 218 | } |
219 | populateView(); | 219 | } |
220 | } | 220 | } |
221 | 221 | } | |
222 | void AdvancedFm::filePerms() { | 222 | populateView(); |
223 | QStringList curFileList = getPath(); | 223 | } |
224 | QString filePath; | 224 | |
225 | 225 | void AdvancedFm::filePerms() { | |
226 | filePath = CurrentDir()->canonicalPath()+"/"; | 226 | QStringList curFileList = getPath(); |
227 | 227 | QString filePath; | |
228 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 228 | |
229 | filePermissions *filePerm; | 229 | filePath = CurrentDir()->canonicalPath()+"/"; |
230 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 230 | |
231 | QPEApplication::execDialog( filePerm ); | 231 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
232 | if( filePerm ) | 232 | filePermissions *filePerm; |
233 | delete filePerm; | 233 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
234 | } | 234 | QPEApplication::execDialog( filePerm ); |
235 | populateView(); | 235 | if( filePerm ) |
236 | } | 236 | delete filePerm; |
237 | 237 | } | |
238 | void AdvancedFm::doProperties() { | 238 | populateView(); |
239 | #if defined(QT_QWS_OPIE) | 239 | } |
240 | 240 | ||
241 | QStringList curFileList = getPath(); | 241 | void AdvancedFm::doProperties() { |
242 | 242 | #if defined(QT_QWS_OPIE) | |
243 | QString filePath; | 243 | |
244 | filePath = CurrentDir()->canonicalPath()+"/"; | 244 | QStringList curFileList = getPath(); |
245 | 245 | ||
246 | // qDebug("%d",curFileList.count()); | 246 | QString filePath; |
247 | 247 | filePath = CurrentDir()->canonicalPath()+"/"; | |
248 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 248 | |
249 | // qDebug((filePath+*it)); | 249 | // odebug << "" << curFileList.count() << "" << oendl; |
250 | DocLnk lnk( (filePath+*it)); | 250 | |
251 | LnkProperties prop( &lnk ); | 251 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
252 | QPEApplication::execDialog( &prop ); | 252 | // odebug << (filePath+*it) << oendl; |
253 | } | 253 | DocLnk lnk( (filePath+*it)); |
254 | #endif | 254 | LnkProperties prop( &lnk ); |
255 | 255 | QPEApplication::execDialog( &prop ); | |
256 | } | 256 | } |
257 | 257 | #endif | |
258 | void AdvancedFm::upDir() { | 258 | |
259 | QDir *thisDir = CurrentDir(); | 259 | } |
260 | QString current = thisDir->canonicalPath(); | 260 | |
261 | QDir dir(current); | 261 | void AdvancedFm::upDir() { |
262 | dir.cdUp(); | 262 | QDir *thisDir = CurrentDir(); |
263 | current = dir.canonicalPath(); | 263 | QString current = thisDir->canonicalPath(); |
264 | chdir( current.latin1() ); | 264 | QDir dir(current); |
265 | thisDir->cd( current, TRUE); | 265 | dir.cdUp(); |
266 | 266 | current = dir.canonicalPath(); | |
267 | populateView(); | 267 | chdir( current.latin1() ); |
268 | update(); | 268 | thisDir->cd( current, TRUE); |
269 | } | 269 | |
270 | 270 | populateView(); | |
271 | void AdvancedFm::copy() { | 271 | update(); |
272 | qApp->processEvents(); | 272 | } |
273 | QStringList curFileList = getPath(); | 273 | |
274 | 274 | void AdvancedFm::copy() { | |
275 | QDir *thisDir = CurrentDir(); | 275 | qApp->processEvents(); |
276 | QDir *thatDir = OtherDir(); | 276 | QStringList curFileList = getPath(); |
277 | 277 | ||
278 | bool doMsg=true; | 278 | QDir *thisDir = CurrentDir(); |
279 | int count=curFileList.count(); | 279 | QDir *thatDir = OtherDir(); |
280 | if( count > 0) { | 280 | |
281 | if(count > 1 ){ | 281 | bool doMsg=true; |
282 | QString msg; | 282 | int count=curFileList.count(); |
283 | msg=tr("Really copy\n%1 files?").arg(count); | 283 | if( count > 0) { |
284 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 284 | if(count > 1 ){ |
285 | ,tr("Yes"),tr("No"),0,0,1) ) | 285 | QString msg; |
286 | { | 286 | msg=tr("Really copy\n%1 files?").arg(count); |
287 | case 0: | 287 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
288 | doMsg=false; | 288 | ,tr("Yes"),tr("No"),0,0,1) ) |
289 | break; | 289 | { |
290 | case 1: | 290 | case 0: |
291 | return; | 291 | doMsg=false; |
292 | break; | 292 | break; |
293 | }; | 293 | case 1: |
294 | } | 294 | return; |
295 | 295 | break; | |
296 | QString curFile, item, destFile; | 296 | }; |
297 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 297 | } |
298 | item=(*it); | 298 | |
299 | if(item.find("->",0,TRUE)) //symlink | 299 | QString curFile, item, destFile; |
300 | item = item.left(item.find("->",0,TRUE)); | 300 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
301 | 301 | item=(*it); | |
302 | curFile = thisDir->canonicalPath()+"/"+ item; | 302 | if(item.find("->",0,TRUE)) //symlink |
303 | destFile = thatDir->canonicalPath()+"/"+ item; | 303 | item = item.left(item.find("->",0,TRUE)); |
304 | 304 | ||
305 | // qDebug("Destination file is "+destFile); | 305 | curFile = thisDir->canonicalPath()+"/"+ item; |
306 | // qDebug("CurrentFile file is " + curFile); | 306 | destFile = thatDir->canonicalPath()+"/"+ item; |
307 | 307 | ||
308 | QFile f(destFile); | 308 | // odebug << "Destination file is "+destFile << oendl; |
309 | if( f.exists()) { | 309 | // odebug << "CurrentFile file is " + curFile << oendl; |
310 | if(doMsg) { | 310 | |
311 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 311 | QFile f(destFile); |
312 | tr("%1 exists. Ok to overwrite?").arg( item ), | 312 | if( f.exists()) { |
313 | tr("Yes"),tr("No"),0,0,1) ) { | 313 | if(doMsg) { |
314 | case 1: | 314 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
315 | return; | 315 | tr("%1 exists. Ok to overwrite?").arg( item ), |
316 | break; | 316 | tr("Yes"),tr("No"),0,0,1) ) { |
317 | }; | 317 | case 1: |
318 | } | 318 | return; |
319 | f.remove(); | 319 | break; |
320 | } | 320 | }; |
321 | 321 | } | |
322 | if( !copyFile( curFile, destFile) ) { | 322 | f.remove(); |
323 | QMessageBox::message("AdvancedFm", | 323 | } |
324 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 324 | |
325 | return; | 325 | if( !copyFile( curFile, destFile) ) { |
326 | } | 326 | QMessageBox::message("AdvancedFm", |
327 | } | 327 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
328 | setOtherTabCurrent(); | 328 | return; |
329 | rePopulate(); | 329 | } |
330 | } | 330 | } |
331 | } | 331 | setOtherTabCurrent(); |
332 | 332 | rePopulate(); | |
333 | void AdvancedFm::copyAs() { | 333 | } |
334 | qApp->processEvents(); | 334 | } |
335 | 335 | ||
336 | QStringList curFileList = getPath(); | 336 | void AdvancedFm::copyAs() { |
337 | QString curFile, item; | 337 | qApp->processEvents(); |
338 | InputDialog *fileDlg; | 338 | |
339 | 339 | QStringList curFileList = getPath(); | |
340 | QDir *thisDir = CurrentDir(); | 340 | QString curFile, item; |
341 | QDir *thatDir = OtherDir(); | 341 | InputDialog *fileDlg; |
342 | 342 | ||
343 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 343 | QDir *thisDir = CurrentDir(); |
344 | QString destFile; | 344 | QDir *thatDir = OtherDir(); |
345 | item=(*it); | 345 | |
346 | curFile = thisDir->canonicalPath()+"/"+(*it); | 346 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
347 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 347 | QString destFile; |
348 | 348 | item=(*it); | |
349 | fileDlg->setInputText((const QString &) destFile ); | 349 | curFile = thisDir->canonicalPath()+"/"+(*it); |
350 | fileDlg->exec(); | 350 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
351 | 351 | ||
352 | if( fileDlg->result() == 1 ) { | 352 | fileDlg->setInputText((const QString &) destFile ); |
353 | QString filename = fileDlg->LineEdit1->text(); | 353 | fileDlg->exec(); |
354 | destFile = thatDir->canonicalPath()+"/"+filename; | 354 | |
355 | 355 | if( fileDlg->result() == 1 ) { | |
356 | QFile f( destFile); | 356 | QString filename = fileDlg->LineEdit1->text(); |
357 | if( f.exists()) { | 357 | destFile = thatDir->canonicalPath()+"/"+filename; |
358 | switch (QMessageBox::warning(this,tr("File Exists!"), | 358 | |
359 | item+tr("\nexists. Ok to overwrite?"), | 359 | QFile f( destFile); |
360 | tr("Yes"),tr("No"),0,0,1) ) { | 360 | if( f.exists()) { |
361 | case 0: | 361 | switch (QMessageBox::warning(this,tr("File Exists!"), |
362 | f.remove(); | 362 | item+tr("\nexists. Ok to overwrite?"), |
363 | break; | 363 | tr("Yes"),tr("No"),0,0,1) ) { |
364 | case 1: | 364 | case 0: |
365 | return; | 365 | f.remove(); |
366 | break; | 366 | break; |
367 | }; | 367 | case 1: |
368 | } | 368 | return; |
369 | if( !copyFile( curFile, destFile) ) { | 369 | break; |
370 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 370 | }; |
371 | +curFile +tr("to\n")+destFile); | 371 | } |
372 | return; | 372 | if( !copyFile( curFile, destFile) ) { |
373 | } | 373 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
374 | } | 374 | +curFile +tr("to\n")+destFile); |
375 | delete fileDlg; | 375 | return; |
376 | 376 | } | |
377 | } | 377 | } |
378 | rePopulate(); | 378 | delete fileDlg; |
379 | setOtherTabCurrent(); | 379 | |
380 | } | 380 | } |
381 | 381 | rePopulate(); | |
382 | void AdvancedFm::copySameDir() { | 382 | setOtherTabCurrent(); |
383 | qApp->processEvents(); | 383 | } |
384 | QStringList curFileList = getPath(); | 384 | |
385 | QString curFile, item, destFile; | 385 | void AdvancedFm::copySameDir() { |
386 | InputDialog *fileDlg; | 386 | qApp->processEvents(); |
387 | 387 | QStringList curFileList = getPath(); | |
388 | QDir *thisDir = CurrentDir(); | 388 | QString curFile, item, destFile; |
389 | 389 | InputDialog *fileDlg; | |
390 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 390 | |
391 | item=(*it); | 391 | QDir *thisDir = CurrentDir(); |
392 | curFile = thisDir->canonicalPath()+"/"+ item; | 392 | |
393 | 393 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | |
394 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 394 | item=(*it); |
395 | fileDlg->setInputText((const QString &) destFile ); | 395 | curFile = thisDir->canonicalPath()+"/"+ item; |
396 | fileDlg->exec(); | 396 | |
397 | 397 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | |
398 | if( fileDlg->result() == 1 ) { | 398 | fileDlg->setInputText((const QString &) destFile ); |
399 | 399 | fileDlg->exec(); | |
400 | QString filename = fileDlg->LineEdit1->text(); | 400 | |
401 | destFile = thisDir->canonicalPath()+"/"+filename; | 401 | if( fileDlg->result() == 1 ) { |
402 | 402 | ||
403 | QFile f(destFile); | 403 | QString filename = fileDlg->LineEdit1->text(); |
404 | if( f.exists()) { | 404 | destFile = thisDir->canonicalPath()+"/"+filename; |
405 | switch (QMessageBox::warning(this,tr("Delete"), | 405 | |
406 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 406 | QFile f(destFile); |
407 | tr("Yes"),tr("No"),0,0,1) ) { | 407 | if( f.exists()) { |
408 | case 0: | 408 | switch (QMessageBox::warning(this,tr("Delete"), |
409 | 409 | destFile+tr(" already exists.\nDo you really want to delete it?"), | |
410 | f.remove(); | 410 | tr("Yes"),tr("No"),0,0,1) ) { |
411 | break; | 411 | case 0: |
412 | case 1: | 412 | |
413 | return; | 413 | f.remove(); |
414 | break; | 414 | break; |
415 | }; | 415 | case 1: |
416 | } | 416 | return; |
417 | if(!copyFile( curFile,destFile) ) { | 417 | break; |
418 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 418 | }; |
419 | +curFile +tr("to\n")+destFile); | 419 | } |
420 | return; | 420 | if(!copyFile( curFile,destFile) ) { |
421 | } | 421 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
422 | 422 | +curFile +tr("to\n")+destFile); | |
423 | // qDebug("copy "+curFile+" as "+destFile); | 423 | return; |
424 | } | 424 | } |
425 | delete fileDlg; | 425 | |
426 | } | 426 | // odebug << "copy "+curFile+" as "+destFile << oendl; |
427 | rePopulate(); | 427 | } |
428 | } | 428 | delete fileDlg; |
429 | 429 | } | |
430 | void AdvancedFm::move() { | 430 | rePopulate(); |
431 | qApp->processEvents(); | 431 | } |
432 | 432 | ||
433 | QStringList curFileList = getPath(); | 433 | void AdvancedFm::move() { |
434 | if( curFileList.count() > 0) { | 434 | qApp->processEvents(); |
435 | QString curFile, destFile, item; | 435 | |
436 | 436 | QStringList curFileList = getPath(); | |
437 | QDir *thisDir = CurrentDir(); | 437 | if( curFileList.count() > 0) { |
438 | QDir *thatDir = OtherDir(); | 438 | QString curFile, destFile, item; |
439 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 439 | |
440 | item=(*it); | 440 | QDir *thisDir = CurrentDir(); |
441 | QString destFile = thatDir->canonicalPath(); | 441 | QDir *thatDir = OtherDir(); |
442 | 442 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | |
443 | if(destFile.right(1).find("/",0,TRUE) == -1) | 443 | item=(*it); |
444 | destFile+="/"; | 444 | QString destFile = thatDir->canonicalPath(); |
445 | destFile += item; | 445 | |
446 | // qDebug("Destination file is "+destFile); | 446 | if(destFile.right(1).find("/",0,TRUE) == -1) |
447 | 447 | destFile+="/"; | |
448 | curFile = thisDir->canonicalPath(); | 448 | destFile += item; |
449 | if(curFile.right(1).find("/",0,TRUE) == -1) | 449 | // odebug << "Destination file is "+destFile << oendl; |
450 | curFile +="/"; | 450 | |
451 | curFile+= item; | 451 | curFile = thisDir->canonicalPath(); |
452 | // qDebug("CurrentFile file is " + curFile); | 452 | if(curFile.right(1).find("/",0,TRUE) == -1) |
453 | 453 | curFile +="/"; | |
454 | if(QFileInfo(curFile).isDir()) { | 454 | curFile+= item; |
455 | moveDirectory( curFile, destFile ); | 455 | // odebug << "CurrentFile file is " + curFile << oendl; |
456 | rePopulate(); | 456 | |
457 | return; | 457 | if(QFileInfo(curFile).isDir()) { |
458 | } | 458 | moveDirectory( curFile, destFile ); |
459 | 459 | rePopulate(); | |
460 | QFile f( curFile); | 460 | return; |
461 | if( f.exists()) { | 461 | } |
462 | if( !copyFile( curFile, destFile) ) { | 462 | |
463 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 463 | QFile f( curFile); |
464 | return; | 464 | if( f.exists()) { |
465 | } else | 465 | if( !copyFile( curFile, destFile) ) { |
466 | QFile::remove(curFile); | 466 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
467 | } | 467 | return; |
468 | } | 468 | } else |
469 | 469 | QFile::remove(curFile); | |
470 | } | 470 | } |
471 | rePopulate(); | 471 | } |
472 | setOtherTabCurrent(); | 472 | |
473 | } | 473 | } |
474 | 474 | rePopulate(); | |
475 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 475 | setOtherTabCurrent(); |
476 | int err = 0; | 476 | } |
477 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; | 477 | |
478 | err = system((const char*)cmd); | 478 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
479 | } else | 479 | int err = 0; |
480 | err = -1; | 480 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; |
481 | 481 | err = system((const char*)cmd); | |
482 | if(err!=0) { | 482 | } else |
483 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); | 483 | err = -1; |
484 | return false; | 484 | |
485 | } | 485 | if(err!=0) { |
486 | return true; | 486 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); |
487 | } | 487 | return false; |
488 | 488 | } | |
489 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 489 | return true; |
490 | 490 | } | |
491 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 491 | |
492 | qWarning(cmd); | 492 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
493 | int err = system( (const char *) cmd ); | 493 | |
494 | if ( err != 0 ) { | 494 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
495 | QMessageBox::message("AdvancedFm", | 495 | owarn << cmd << oendl; |
496 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); | 496 | int err = system( (const char *) cmd ); |
497 | return false; | 497 | if ( err != 0 ) { |
498 | } | 498 | QMessageBox::message("AdvancedFm", |
499 | 499 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); | |
500 | return true; | 500 | return false; |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | return true; | |
504 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | if(QFileInfo(src).isDir()) { | 507 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
508 | if( copyDirectory( src, dest )) { | 508 | |
509 | setOtherTabCurrent(); | 509 | |
510 | populateView(); | 510 | if(QFileInfo(src).isDir()) { |
511 | return true; | 511 | if( copyDirectory( src, dest )) { |
512 | } | 512 | setOtherTabCurrent(); |
513 | else | 513 | populateView(); |
514 | return false; | 514 | return true; |
515 | } | 515 | } |
516 | 516 | else | |
517 | 517 | return false; | |
518 | bool success = true; | 518 | } |
519 | struct stat status; | 519 | |
520 | QFile srcFile(src); | 520 | |
521 | QFile destFile(dest); | 521 | bool success = true; |
522 | int err=0; | 522 | struct stat status; |
523 | int read_fd=0; | 523 | QFile srcFile(src); |
524 | int write_fd=0; | 524 | QFile destFile(dest); |
525 | struct stat stat_buf; | 525 | int err=0; |
526 | off_t offset = 0; | 526 | int read_fd=0; |
527 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 527 | int write_fd=0; |
528 | // qWarning("open failed"); | 528 | struct stat stat_buf; |
529 | return success = false; | 529 | off_t offset = 0; |
530 | } | 530 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
531 | read_fd = srcFile.handle(); | 531 | // owarn << "open failed" << oendl; |
532 | if(read_fd != -1) { | 532 | return success = false; |
533 | fstat (read_fd, &stat_buf); | 533 | } |
534 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 534 | read_fd = srcFile.handle(); |
535 | // qWarning("destfile open failed"); | 535 | if(read_fd != -1) { |
536 | return success = false; | 536 | fstat (read_fd, &stat_buf); |
537 | } | 537 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
538 | write_fd = destFile.handle(); | 538 | // owarn << "destfile open failed" << oendl; |
539 | if(write_fd != -1) { | 539 | return success = false; |
540 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 540 | } |
541 | if( err == -1) { | 541 | write_fd = destFile.handle(); |
542 | QString msg; | 542 | if(write_fd != -1) { |
543 | switch(err) { | 543 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
544 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 544 | if( err == -1) { |
545 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 545 | QString msg; |
546 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 546 | switch(err) { |
547 | case EIO: msg = "Unspecified error while reading from in_fd."; | 547 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
548 | }; | 548 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
549 | success = false; | 549 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
550 | // qWarning(msg); | 550 | case EIO: msg = "Unspecified error while reading from in_fd."; |
551 | } | 551 | }; |
552 | } else { | 552 | success = false; |
553 | success = false; | 553 | // owarn << msg << oendl; |
554 | } | 554 | } |
555 | } else { | 555 | } else { |
556 | success = false; | 556 | success = false; |
557 | } | 557 | } |
558 | srcFile.close(); | 558 | } else { |
559 | destFile.close(); | 559 | success = false; |
560 | // Set file permissions | 560 | } |
561 | if( stat( (const char *) src, &status ) == 0 ) { | 561 | srcFile.close(); |
562 | chmod( (const char *) dest, status.st_mode ); | 562 | destFile.close(); |
563 | } | 563 | // Set file permissions |
564 | 564 | if( stat( (const char *) src, &status ) == 0 ) { | |
565 | return success; | 565 | chmod( (const char *) dest, status.st_mode ); |
566 | } | 566 | } |
567 | 567 | ||
568 | void AdvancedFm::runCommand() { | 568 | return success; |
569 | if( !CurrentView()->currentItem()) return; | 569 | } |
570 | QDir *thisDir = CurrentDir(); | 570 | |
571 | 571 | void AdvancedFm::runCommand() { | |
572 | QString curFile; | 572 | if( !CurrentView()->currentItem()) return; |
573 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 573 | QDir *thisDir = CurrentDir(); |
574 | 574 | ||
575 | InputDialog *fileDlg; | 575 | QString curFile; |
576 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 576 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
577 | fileDlg->setInputText(curFile); | 577 | |
578 | fileDlg->exec(); | 578 | InputDialog *fileDlg; |
579 | //QString command; | 579 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
580 | 580 | fileDlg->setInputText(curFile); | |
581 | if( fileDlg->result() == 1 ) { | 581 | fileDlg->exec(); |
582 | // qDebug(fileDlg->LineEdit1->text()); | 582 | //QString command; |
583 | QStringList command; | 583 | |
584 | 584 | if( fileDlg->result() == 1 ) { | |
585 | command << "/bin/sh"; | 585 | // odebug << fileDlg->LineEdit1->text() << oendl; |
586 | command << "-c"; | 586 | QStringList command; |
587 | command << fileDlg->LineEdit1->text(); | 587 | |
588 | Output *outDlg; | 588 | command << "/bin/sh"; |
589 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 589 | command << "-c"; |
590 | QPEApplication::execDialog( outDlg ); | 590 | command << fileDlg->LineEdit1->text(); |
591 | qApp->processEvents(); | 591 | Output *outDlg; |
592 | 592 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | |
593 | } | 593 | QPEApplication::execDialog( outDlg ); |
594 | } | 594 | qApp->processEvents(); |
595 | 595 | ||
596 | void AdvancedFm::runCommandStd() { | 596 | } |
597 | if( !CurrentView()->currentItem()) return; | 597 | } |
598 | QString curFile; | 598 | |
599 | QDir *thisDir = CurrentDir(); | 599 | void AdvancedFm::runCommandStd() { |
600 | QListView *thisView = CurrentView(); | 600 | if( !CurrentView()->currentItem()) return; |
601 | if( thisView->currentItem()) | 601 | QString curFile; |
602 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 602 | QDir *thisDir = CurrentDir(); |
603 | 603 | QListView *thisView = CurrentView(); | |
604 | InputDialog *fileDlg; | 604 | if( thisView->currentItem()) |
605 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 605 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
606 | fileDlg->setInputText(curFile); | 606 | |
607 | fileDlg->exec(); | 607 | InputDialog *fileDlg; |
608 | 608 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | |
609 | if( fileDlg->result() == 1 ) { | 609 | fileDlg->setInputText(curFile); |
610 | qApp->processEvents(); | 610 | fileDlg->exec(); |
611 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 611 | |
612 | } | 612 | if( fileDlg->result() == 1 ) { |
613 | } | 613 | qApp->processEvents(); |
614 | 614 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | |
615 | void AdvancedFm::fileStatus() { | 615 | } |
616 | if( !CurrentView()->currentItem()) return; | 616 | } |
617 | QString curFile; | 617 | |
618 | curFile = CurrentView()->currentItem()->text(0); | 618 | void AdvancedFm::fileStatus() { |
619 | 619 | if( !CurrentView()->currentItem()) return; | |
620 | QStringList command; | 620 | QString curFile; |
621 | command << "/bin/sh"; | 621 | curFile = CurrentView()->currentItem()->text(0); |
622 | command << "-c"; | 622 | |
623 | command << "stat -l "+ curFile; | 623 | QStringList command; |
624 | 624 | command << "/bin/sh"; | |
625 | Output *outDlg; | 625 | command << "-c"; |
626 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 626 | command << "stat -l "+ curFile; |
627 | QPEApplication::execDialog( outDlg ); | 627 | |
628 | qApp->processEvents(); | 628 | Output *outDlg; |
629 | } | 629 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
630 | 630 | QPEApplication::execDialog( outDlg ); | |
631 | 631 | qApp->processEvents(); | |
632 | void AdvancedFm::mkDir() { | 632 | } |
633 | makeDir(); | 633 | |
634 | } | 634 | |
635 | 635 | void AdvancedFm::mkDir() { | |
636 | void AdvancedFm::rn() { | 636 | makeDir(); |
637 | renameIt(); | 637 | } |
638 | } | 638 | |
639 | 639 | void AdvancedFm::rn() { | |
640 | void AdvancedFm::del() { | 640 | renameIt(); |
641 | doDelete(); | 641 | } |
642 | } | 642 | |
643 | 643 | void AdvancedFm::del() { | |
644 | void AdvancedFm::mkSym() { | 644 | doDelete(); |
645 | QString cmd; | 645 | } |
646 | QStringList curFileList = getPath(); | 646 | |
647 | if( curFileList.count() > 0) { | 647 | void AdvancedFm::mkSym() { |
648 | QDir *thisDir = CurrentDir(); | 648 | QString cmd; |
649 | QDir * thatDir = OtherDir(); | 649 | QStringList curFileList = getPath(); |
650 | 650 | if( curFileList.count() > 0) { | |
651 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 651 | QDir *thisDir = CurrentDir(); |
652 | 652 | QDir * thatDir = OtherDir(); | |
653 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 653 | |
654 | if(destName.right(1) == "/") { | 654 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
655 | destName = destName.left( destName.length() -1); | 655 | |
656 | } | 656 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
657 | 657 | if(destName.right(1) == "/") { | |
658 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 658 | destName = destName.left( destName.length() -1); |
659 | 659 | } | |
660 | if( curFile.right(1) == "/") { | 660 | |
661 | curFile = curFile.left( curFile.length() -1); | 661 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
662 | } | 662 | |
663 | 663 | if( curFile.right(1) == "/") { | |
664 | cmd = "ln -s "+curFile+" "+destName; | 664 | curFile = curFile.left( curFile.length() -1); |
665 | // qDebug(cmd); | 665 | } |
666 | startProcess( (const QString)cmd ); | 666 | |
667 | } | 667 | cmd = "ln -s "+curFile+" "+destName; |
668 | rePopulate(); | 668 | // odebug << cmd << oendl; |
669 | setOtherTabCurrent(); | 669 | startProcess( (const QString)cmd ); |
670 | } | 670 | } |
671 | } | 671 | rePopulate(); |
672 | 672 | setOtherTabCurrent(); | |
673 | void AdvancedFm::doBeam() { | 673 | } |
674 | Ir ir; | 674 | } |
675 | if(!ir.supported()) { | 675 | |
676 | } else { | 676 | void AdvancedFm::doBeam() { |
677 | QStringList curFileList = getPath(); | 677 | Ir ir; |
678 | if( curFileList.count() > 0) { | 678 | if(!ir.supported()) { |
679 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 679 | } else { |
680 | QString curFile = (*it); | 680 | QStringList curFileList = getPath(); |
681 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 681 | if( curFileList.count() > 0) { |
682 | if( curFilePath.right(1) == "/") { | 682 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
683 | curFilePath = curFilePath.left( curFilePath.length() -1); | 683 | QString curFile = (*it); |
684 | } | 684 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
685 | Ir *file = new Ir(this, "IR"); | 685 | if( curFilePath.right(1) == "/") { |
686 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 686 | curFilePath = curFilePath.left( curFilePath.length() -1); |
687 | file->send( curFilePath, curFile ); | 687 | } |
688 | } | 688 | Ir *file = new Ir(this, "IR"); |
689 | } | 689 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
690 | } | 690 | file->send( curFilePath, curFile ); |
691 | } | 691 | } |
692 | 692 | } | |
693 | void AdvancedFm::fileBeamFinished( Ir *) { | 693 | } |
694 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 694 | } |
695 | } | 695 | |
696 | 696 | void AdvancedFm::fileBeamFinished( Ir *) { | |
697 | void AdvancedFm::selectAll() { | 697 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
698 | QListView *thisView = CurrentView(); | 698 | } |
699 | thisView->selectAll(true); | 699 | |
700 | thisView->setSelected( thisView->firstChild(),false); | 700 | void AdvancedFm::selectAll() { |
701 | } | 701 | QListView *thisView = CurrentView(); |
702 | 702 | thisView->selectAll(true); | |
703 | void AdvancedFm::startProcess(const QString & cmd) { | 703 | thisView->setSelected( thisView->firstChild(),false); |
704 | QStringList command; | 704 | } |
705 | OProcess *process; | 705 | |
706 | process = new OProcess(); | 706 | void AdvancedFm::startProcess(const QString & cmd) { |
707 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 707 | QStringList command; |
708 | this, SLOT( processEnded(Opie::Core::OProcess*))); | 708 | OProcess *process; |
709 | 709 | process = new OProcess(); | |
710 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 710 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
711 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | 711 | this, SLOT( processEnded(Opie::Core::OProcess*))); |
712 | 712 | ||
713 | command << "/bin/sh"; | 713 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
714 | command << "-c"; | 714 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
715 | command << cmd.latin1(); | 715 | |
716 | *process << command; | 716 | command << "/bin/sh"; |
717 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 717 | command << "-c"; |
718 | qDebug("could not start process"); | 718 | command << cmd.latin1(); |
719 | } | 719 | *process << command; |
720 | 720 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | |
721 | void AdvancedFm::processEnded(OProcess *) { | 721 | odebug << "could not start process" << oendl; |
722 | rePopulate(); | 722 | } |
723 | } | 723 | |
724 | 724 | void AdvancedFm::processEnded(OProcess *) { | |
725 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 725 | rePopulate(); |
726 | // qWarning("received stderrt %d bytes", buflen); | 726 | } |
727 | 727 | ||
728 | QString lineStr = buffer; | 728 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
729 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 729 | // owarn << "received stderrt " << buflen << " bytes" << oendl; |
730 | } | 730 | |
731 | 731 | QString lineStr = buffer; | |
732 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 732 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
733 | if ( o->inherits( "QLineEdit" ) ) { | 733 | } |
734 | if ( e->type() == QEvent::KeyPress ) { | 734 | |
735 | QKeyEvent *ke = (QKeyEvent*)e; | 735 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
736 | if ( ke->key() == Key_Return || | 736 | if ( o->inherits( "QLineEdit" ) ) { |
737 | ke->key() == Key_Enter ) { | 737 | if ( e->type() == QEvent::KeyPress ) { |
738 | okRename(); | 738 | QKeyEvent *ke = (QKeyEvent*)e; |
739 | return true; | 739 | if ( ke->key() == Key_Return || |
740 | } | 740 | ke->key() == Key_Enter ) { |
741 | else if ( ke->key() == Key_Escape ) { | 741 | okRename(); |
742 | cancelRename(); | 742 | return true; |
743 | return true; | 743 | } |
744 | } | 744 | else if ( ke->key() == Key_Escape ) { |
745 | } | 745 | cancelRename(); |
746 | else if ( e->type() == QEvent::FocusOut ) { | 746 | return true; |
747 | cancelRename(); | 747 | } |
748 | return true; | 748 | } |
749 | } | 749 | else if ( e->type() == QEvent::FocusOut ) { |
750 | } | 750 | cancelRename(); |
751 | if ( o->inherits( "QListView" ) ) { | 751 | return true; |
752 | if ( e->type() == QEvent::FocusIn ) { | 752 | } |
753 | if( o == Local_View) { //keep track of which view | 753 | } |
754 | whichTab=1; | 754 | if ( o->inherits( "QListView" ) ) { |
755 | } | 755 | if ( e->type() == QEvent::FocusIn ) { |
756 | else { | 756 | if( o == Local_View) { //keep track of which view |
757 | whichTab=2; | 757 | whichTab=1; |
758 | } | 758 | } |
759 | } | 759 | else { |
760 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 760 | whichTab=2; |
761 | } | 761 | } |
762 | 762 | } | |
763 | return QWidget::eventFilter( o, e ); | 763 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
764 | } | 764 | } |
765 | 765 | ||
766 | 766 | return QWidget::eventFilter( o, e ); | |
767 | void AdvancedFm::cancelRename() { | 767 | } |
768 | // qDebug("cancel rename"); | 768 | |
769 | QListView * view; | 769 | |
770 | view = CurrentView(); | 770 | void AdvancedFm::cancelRename() { |
771 | 771 | // odebug << "cancel rename" << oendl; | |
772 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 772 | QListView * view; |
773 | delete renameBox; | 773 | view = CurrentView(); |
774 | renameBox = 0; | 774 | |
775 | if ( resetFocus ) { | 775 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
776 | view->viewport()->setFocusProxy( view); | 776 | delete renameBox; |
777 | view->setFocus(); | 777 | renameBox = 0; |
778 | } | 778 | if ( resetFocus ) { |
779 | } | 779 | view->viewport()->setFocusProxy( view); |
780 | 780 | view->setFocus(); | |
781 | void AdvancedFm::doRename(QListView * view) { | 781 | } |
782 | if( !CurrentView()->currentItem()) return; | 782 | } |
783 | 783 | ||
784 | QRect r = view->itemRect( view->currentItem( )); | 784 | void AdvancedFm::doRename(QListView * view) { |
785 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 785 | if( !CurrentView()->currentItem()) return; |
786 | r.setX( view->contentsX() ); | 786 | |
787 | 787 | QRect r = view->itemRect( view->currentItem( )); | |
788 | if ( r.width() > view->visibleWidth() ) | 788 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
789 | r.setWidth( view->visibleWidth() ); | 789 | r.setX( view->contentsX() ); |
790 | 790 | ||
791 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 791 | if ( r.width() > view->visibleWidth() ) |
792 | renameBox->setFrame(true); | 792 | r.setWidth( view->visibleWidth() ); |
793 | 793 | ||
794 | renameBox->setText( view->currentItem()->text(0) ); | 794 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
795 | 795 | renameBox->setFrame(true); | |
796 | renameBox->selectAll(); | 796 | |
797 | renameBox->installEventFilter( this ); | 797 | renameBox->setText( view->currentItem()->text(0) ); |
798 | 798 | ||
799 | view->addChild( renameBox, r.x(), r.y() ); | 799 | renameBox->selectAll(); |
800 | 800 | renameBox->installEventFilter( this ); | |
801 | renameBox->resize( r.size() ); | 801 | |
802 | 802 | view->addChild( renameBox, r.x(), r.y() ); | |
803 | view->viewport()->setFocusProxy( renameBox ); | 803 | |
804 | 804 | renameBox->resize( r.size() ); | |
805 | renameBox->setFocus(); | 805 | |
806 | renameBox->show(); | 806 | view->viewport()->setFocusProxy( renameBox ); |
807 | } | 807 | |
808 | 808 | renameBox->setFocus(); | |
809 | 809 | renameBox->show(); | |
810 | void AdvancedFm::renameIt() { | 810 | } |
811 | if( !CurrentView()->currentItem()) return; | 811 | |
812 | 812 | ||
813 | QListView *thisView = CurrentView(); | 813 | void AdvancedFm::renameIt() { |
814 | oldName = thisView->currentItem()->text(0); | 814 | if( !CurrentView()->currentItem()) return; |
815 | doRename( thisView ); | 815 | |
816 | } | 816 | QListView *thisView = CurrentView(); |
817 | 817 | oldName = thisView->currentItem()->text(0); | |
818 | void AdvancedFm::okRename() { | 818 | doRename( thisView ); |
819 | if( !renameBox) return; | 819 | } |
820 | 820 | ||
821 | QString newName = renameBox->text(); | 821 | void AdvancedFm::okRename() { |
822 | cancelRename(); | 822 | if( !renameBox) return; |
823 | QListView * view = CurrentView(); | 823 | |
824 | QString path = CurrentDir()->canonicalPath() + "/"; | 824 | QString newName = renameBox->text(); |
825 | oldName = path + oldName; | 825 | cancelRename(); |
826 | newName = path + newName; | 826 | QListView * view = CurrentView(); |
827 | if( rename( oldName.latin1(), newName.latin1())== -1) | 827 | QString path = CurrentDir()->canonicalPath() + "/"; |
828 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 828 | oldName = path + oldName; |
829 | else | 829 | newName = path + newName; |
830 | oldName = ""; | 830 | if( rename( oldName.latin1(), newName.latin1())== -1) |
831 | QListViewItem *item = view->currentItem(); | 831 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
832 | view->takeItem( item ); | 832 | else |
833 | delete item; | 833 | oldName = ""; |
834 | rePopulate(); | 834 | QListViewItem *item = view->currentItem(); |
835 | } | 835 | view->takeItem( item ); |
836 | 836 | delete item; | |
837 | void AdvancedFm::openSearch() { | 837 | rePopulate(); |
838 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 838 | } |
839 | } | 839 | |
840 | void AdvancedFm::openSearch() { | ||
841 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | ||
842 | } | ||
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp index 9698de7..b7d48e8 100644 --- a/noncore/apps/advancedfm/filePermissions.cpp +++ b/noncore/apps/advancedfm/filePermissions.cpp | |||
@@ -23,25 +23,25 @@ | |||
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <pwd.h> | 27 | #include <pwd.h> |
28 | #include <grp.h> | 28 | #include <grp.h> |
29 | 29 | ||
30 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | 30 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) |
31 | : QDialog( parent, name, modal, fl ) | 31 | : QDialog( parent, name, modal, fl ) |
32 | { | 32 | { |
33 | if ( !name ) | 33 | if ( !name ) |
34 | setName( tr("filePermissions") ); | 34 | setName( tr("filePermissions") ); |
35 | // qDebug("FilePermissions "+fileName); | 35 | // odebug << "FilePermissions "+fileName << oendl; |
36 | /* resize( 236, 210 ); | 36 | /* resize( 236, 210 ); |
37 | setMaximumSize( QSize( 236, 210 ) ); | 37 | setMaximumSize( QSize( 236, 210 ) ); |
38 | */ setCaption( tr( "Set File Permissions" ) ); | 38 | */ setCaption( tr( "Set File Permissions" ) ); |
39 | 39 | ||
40 | TextLabel1 = new QLabel( this, "TextLabel1" ); | 40 | TextLabel1 = new QLabel( this, "TextLabel1" ); |
41 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | 41 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); |
42 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | 42 | TextLabel1->setText( tr( "Set file permissions for:" ) ); |
43 | 43 | ||
44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
45 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | 45 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); |
46 | LineEdit1->setReadOnly(true); | 46 | LineEdit1->setReadOnly(true); |
47 | 47 | ||
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 6906298..8c585f4 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp | |||
@@ -1,32 +1,35 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** outputEdit.cpp | 2 | ** outputEdit.cpp |
3 | ** | 3 | ** |
4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> | 4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> |
5 | ****************************************************************************/ | 5 | ****************************************************************************/ |
6 | #include "output.h" | 6 | #include "output.h" |
7 | 7 | ||
8 | /* OPIE */ | ||
9 | #include <opie2/odebug.h> | ||
8 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/applnk.h> | 11 | #include <qpe/applnk.h> |
12 | using namespace Opie::Core; | ||
10 | 13 | ||
14 | /* QT */ | ||
11 | #include <qfile.h> | 15 | #include <qfile.h> |
12 | #include <qmultilineedit.h> | 16 | #include <qmultilineedit.h> |
13 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
14 | #include <qlayout.h> | 18 | #include <qlayout.h> |
15 | 19 | ||
20 | /* STD */ | ||
16 | #include <errno.h> | 21 | #include <errno.h> |
17 | 22 | ||
18 | /* XPM */ | 23 | /* XPM */ |
19 | using namespace Opie::Core; | ||
20 | using namespace Opie::Core; | ||
21 | static char * filesave_xpm[] = { | 24 | static char * filesave_xpm[] = { |
22 | "16 16 78 1", | 25 | "16 16 78 1", |
23 | " c None", | 26 | " c None", |
24 | ". c #343434", | 27 | ". c #343434", |
25 | "+ c #A0A0A0", | 28 | "+ c #A0A0A0", |
26 | "@ c #565656", | 29 | "@ c #565656", |
27 | "# c #9E9E9E", | 30 | "# c #9E9E9E", |
28 | "$ c #525252", | 31 | "$ c #525252", |
29 | "% c #929292", | 32 | "% c #929292", |
30 | "& c #676767", | 33 | "& c #676767", |
31 | "* c #848484", | 34 | "* c #848484", |
32 | "= c #666666", | 35 | "= c #666666", |
@@ -112,25 +115,25 @@ static char * filesave_xpm[] = { | |||
112 | "CzDEvEv;;DssF$ ", | 115 | "CzDEvEv;;DssF$ ", |
113 | "G.H{E{E{IxsJ$+ ", | 116 | "G.H{E{E{IxsJ$+ ", |
114 | " +...vEKxzLM ", | 117 | " +...vEKxzLM ", |
115 | " +...z]n$ ", | 118 | " +...z]n$ ", |
116 | " +... "}; | 119 | " +... "}; |
117 | 120 | ||
118 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) | 121 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) |
119 | : QDialog( parent, name, modal, fl ) | 122 | : QDialog( parent, name, modal, fl ) |
120 | { | 123 | { |
121 | QStringList cmmds; | 124 | QStringList cmmds; |
122 | // cmmds=QStringList::split( " ", commands, false); | 125 | // cmmds=QStringList::split( " ", commands, false); |
123 | cmmds=commands; | 126 | cmmds=commands; |
124 | // qDebug("count %d", cmmds.count()); | 127 | // odebug << "count " << cmmds.count() << "" << oendl; |
125 | if ( !name ) | 128 | if ( !name ) |
126 | setName( tr("Output")); | 129 | setName( tr("Output")); |
127 | resize( 196, 269 ); | 130 | resize( 196, 269 ); |
128 | setCaption( name ); | 131 | setCaption( name ); |
129 | 132 | ||
130 | OutputLayout = new QGridLayout( this ); | 133 | OutputLayout = new QGridLayout( this ); |
131 | OutputLayout->setSpacing( 2); | 134 | OutputLayout->setSpacing( 2); |
132 | OutputLayout->setMargin( 2); | 135 | OutputLayout->setMargin( 2); |
133 | 136 | ||
134 | QPushButton *docButton; | 137 | QPushButton *docButton; |
135 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); | 138 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); |
136 | docButton->setFixedSize( QSize( 20, 20 ) ); | 139 | docButton->setFixedSize( QSize( 20, 20 ) ); |
@@ -148,25 +151,25 @@ Output::Output( const QStringList commands, QWidget* parent, const char* name, | |||
148 | 151 | ||
149 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | 152 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
150 | this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int))); | 153 | this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int))); |
151 | 154 | ||
152 | connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), | 155 | connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
153 | this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int))); | 156 | this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int))); |
154 | 157 | ||
155 | // connect( , SIGNAL(received(const QByteArray&)), | 158 | // connect( , SIGNAL(received(const QByteArray&)), |
156 | // this, SLOT(commandStdin(const QByteArray&))); | 159 | // this, SLOT(commandStdin(const QByteArray&))); |
157 | 160 | ||
158 | // * proc << commands.latin1(); | 161 | // * proc << commands.latin1(); |
159 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { | 162 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { |
160 | qDebug( "%s", (*it).latin1() ); | 163 | odebug << "" << (*it).latin1() << "" << oendl; |
161 | * proc << (*it).latin1(); | 164 | * proc << (*it).latin1(); |
162 | } | 165 | } |
163 | 166 | ||
164 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { | 167 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { |
165 | 168 | ||
166 | OutputEdit->append(tr("Process could not start") ); | 169 | OutputEdit->append(tr("Process could not start") ); |
167 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 170 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
168 | perror("Error: "); | 171 | perror("Error: "); |
169 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); | 172 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); |
170 | OutputEdit->append( errorMsg); | 173 | OutputEdit->append( errorMsg); |
171 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 174 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
172 | } | 175 | } |
@@ -177,67 +180,67 @@ Output::~Output() { | |||
177 | 180 | ||
178 | void Output::saveOutput() { | 181 | void Output::saveOutput() { |
179 | 182 | ||
180 | InputDialog *fileDlg; | 183 | InputDialog *fileDlg; |
181 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); | 184 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); |
182 | fileDlg->exec(); | 185 | fileDlg->exec(); |
183 | if( fileDlg->result() == 1 ) { | 186 | if( fileDlg->result() == 1 ) { |
184 | QString filename = QPEApplication::documentDir(); | 187 | QString filename = QPEApplication::documentDir(); |
185 | if(filename.right(1).find('/') == -1) | 188 | if(filename.right(1).find('/') == -1) |
186 | filename+="/"; | 189 | filename+="/"; |
187 | QString name = fileDlg->LineEdit1->text(); | 190 | QString name = fileDlg->LineEdit1->text(); |
188 | filename+="text/plain/"+name; | 191 | filename+="text/plain/"+name; |
189 | qDebug(filename); | 192 | odebug << filename << oendl; |
190 | 193 | ||
191 | QFile f(filename); | 194 | QFile f(filename); |
192 | f.open( IO_WriteOnly); | 195 | f.open( IO_WriteOnly); |
193 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { | 196 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { |
194 | DocLnk lnk; | 197 | DocLnk lnk; |
195 | lnk.setName(name); //sets file name | 198 | lnk.setName(name); //sets file name |
196 | lnk.setFile(filename); //sets File property | 199 | lnk.setFile(filename); //sets File property |
197 | lnk.setType("text/plain"); | 200 | lnk.setType("text/plain"); |
198 | if(!lnk.writeLink()) { | 201 | if(!lnk.writeLink()) { |
199 | qDebug("Writing doclink did not work"); | 202 | odebug << "Writing doclink did not work" << oendl; |
200 | } | 203 | } |
201 | } else | 204 | } else |
202 | qWarning("Could not write file"); | 205 | owarn << "Could not write file" << oendl; |
203 | f.close(); | 206 | f.close(); |
204 | } | 207 | } |
205 | } | 208 | } |
206 | 209 | ||
207 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { | 210 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { |
208 | qWarning("received stdout %d bytes", buflen); | 211 | owarn << "received stdout " << buflen << " bytes" << oendl; |
209 | 212 | ||
210 | // QByteArray data(buflen); | 213 | // QByteArray data(buflen); |
211 | // data.fill(*buffer, buflen); | 214 | // data.fill(*buffer, buflen); |
212 | // for (uint i = 0; i < data.count(); i++ ) { | 215 | // for (uint i = 0; i < data.count(); i++ ) { |
213 | // printf("%c", buffer[i] ); | 216 | // printf("%c", buffer[i] ); |
214 | // } | 217 | // } |
215 | // printf("\n"); | 218 | // printf("\n"); |
216 | 219 | ||
217 | QString lineStr = buffer; | 220 | QString lineStr = buffer; |
218 | lineStr=lineStr.left(lineStr.length()-1); | 221 | lineStr=lineStr.left(lineStr.length()-1); |
219 | OutputEdit->append(lineStr); | 222 | OutputEdit->append(lineStr); |
220 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 223 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
221 | } | 224 | } |
222 | 225 | ||
223 | 226 | ||
224 | void Output::commandStdin( const QByteArray &data) { | 227 | void Output::commandStdin( const QByteArray &data) { |
225 | qWarning("received stdin %d bytes", data.size()); | 228 | owarn << "received stdin " << data.size() << " bytes" << oendl; |
226 | // recieved data from the io layer goes to sz | 229 | // recieved data from the io layer goes to sz |
227 | proc->writeStdin(data.data(), data.size()); | 230 | proc->writeStdin(data.data(), data.size()); |
228 | } | 231 | } |
229 | 232 | ||
230 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { | 233 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { |
231 | qWarning("received stderrt %d bytes", buflen); | 234 | owarn << "received stderrt " << buflen << " bytes" << oendl; |
232 | 235 | ||
233 | QString lineStr = buffer; | 236 | QString lineStr = buffer; |
234 | // lineStr=lineStr.left(lineStr.length()-1); | 237 | // lineStr=lineStr.left(lineStr.length()-1); |
235 | OutputEdit->append(lineStr); | 238 | OutputEdit->append(lineStr); |
236 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 239 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
237 | } | 240 | } |
238 | 241 | ||
239 | void Output::processFinished() { | 242 | void Output::processFinished() { |
240 | 243 | ||
241 | delete proc; | 244 | delete proc; |
242 | OutputEdit->append( tr("\nFinished\n") ); | 245 | OutputEdit->append( tr("\nFinished\n") ); |
243 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 246 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |