-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 942 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 2 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.pro | 2 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 940 |
5 files changed, 979 insertions, 912 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 8f49a53..3aa516c 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,1725 +1,851 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #define DEVELOPERS_VERSION | 12 | #define DEVELOPERS_VERSION |
13 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | ||
14 | 13 | ||
15 | #include "advancedfm.h" | 14 | #include "advancedfm.h" |
16 | #include "inputDialog.h" | ||
17 | #include "filePermissions.h" | ||
18 | #include "output.h" | ||
19 | 15 | ||
20 | // #include <opie/ofileselector.h> | 16 | // #include <opie/ofileselector.h> |
21 | // #include <opie/ofiledialog.h> | 17 | // #include <opie/ofiledialog.h> |
22 | 18 | ||
23 | #include <qpe/lnkproperties.h> | ||
24 | #include <qpe/filemanager.h> | 19 | #include <qpe/filemanager.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 20 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
27 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
28 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
30 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
31 | #include <qpe/mimetype.h> | 26 | #include <qpe/mimetype.h> |
32 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
33 | #include <qpe/ir.h> | 28 | #include <qpe/ir.h> |
34 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
35 | 30 | ||
36 | //#include <opie/ofileselector.h> | ||
37 | #include <qmultilineedit.h> | ||
38 | |||
39 | #include <qtabwidget.h> | 31 | #include <qtabwidget.h> |
40 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
41 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
42 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
43 | #include <qdir.h> | 35 | #include <qdir.h> |
44 | #include <qfile.h> | 36 | #include <qfile.h> |
45 | #include <qstring.h> | 37 | #include <qstring.h> |
46 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
47 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
48 | #include <qlistview.h> | 40 | #include <qlistview.h> |
49 | #include <qmainwindow.h> | 41 | #include <qmainwindow.h> |
50 | #include <qlabel.h> | 42 | #include <qlabel.h> |
51 | #include <qprogressbar.h> | 43 | #include <qprogressbar.h> |
52 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
53 | #include <qwidget.h> | 45 | #include <qwidget.h> |
54 | #include <qlayout.h> | 46 | #include <qlayout.h> |
55 | #include <qimage.h> | 47 | #include <qimage.h> |
56 | #include <qpixmap.h> | 48 | #include <qpixmap.h> |
57 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
58 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
59 | #include <qregexp.h> | 51 | #include <qregexp.h> |
60 | 52 | ||
61 | #include <unistd.h> | 53 | #include <unistd.h> |
62 | #include <stdlib.h> | 54 | #include <stdlib.h> |
63 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
64 | #include <dirent.h> | 56 | #include <dirent.h> |
65 | #include <stdio.h> | 57 | #include <stdio.h> |
66 | #include <time.h> | 58 | #include <time.h> |
67 | #include <fcntl.h> | 59 | #include <fcntl.h> |
68 | #include <mntent.h> | 60 | #include <mntent.h> |
69 | #include <string.h> | 61 | #include <string.h> |
70 | #include <errno.h> | 62 | #include <errno.h> |
71 | #include <sys/vfs.h> | 63 | #include <sys/vfs.h> |
72 | #include <mntent.h> | 64 | #include <mntent.h> |
73 | #include <sys/utsname.h> | 65 | #include <sys/utsname.h> |
74 | 66 | ||
75 | AdvancedFm::AdvancedFm( ) | 67 | AdvancedFm::AdvancedFm( ) |
76 | : QMainWindow( ) { | 68 | : QMainWindow( ) { |
77 | init(); | 69 | init(); |
78 | 70 | initConnections(); | |
79 | populateLocalView(); | 71 | populateLocalView(); |
80 | populateRemoteView(); | 72 | populateRemoteView(); |
81 | currentPathCombo->setFocus(); | 73 | currentPathCombo->setFocus(); |
82 | } | 74 | } |
83 | 75 | ||
84 | AdvancedFm::~AdvancedFm() { | 76 | AdvancedFm::~AdvancedFm() { |
85 | } | 77 | } |
86 | 78 | ||
87 | void AdvancedFm::cleanUp() { | 79 | void AdvancedFm::cleanUp() { |
88 | QString sfile=QDir::homeDirPath(); | 80 | QString sfile=QDir::homeDirPath(); |
89 | if(sfile.right(1) != "/") | 81 | if(sfile.right(1) != "/") |
90 | sfile+="/._temp"; | 82 | sfile+="/._temp"; |
91 | else | 83 | else |
92 | sfile+="._temp"; | 84 | sfile+="._temp"; |
93 | QFile file( sfile); | 85 | QFile file( sfile); |
94 | if(file.exists()) | 86 | if(file.exists()) |
95 | file.remove(); | 87 | file.remove(); |
96 | } | 88 | } |
97 | 89 | ||
98 | void AdvancedFm::tabChanged(QWidget *) { | 90 | void AdvancedFm::tabChanged(QWidget *) { |
99 | if (TabWidget->currentPageIndex() == 0) { | 91 | if (TabWidget->currentPageIndex() == 0) { |
100 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 92 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
101 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 93 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
102 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 94 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
103 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 95 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
104 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 96 | setCaption("AdvancedFm :: "+fs+" :: " |
97 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | ||
105 | 98 | ||
106 | } | 99 | } |
107 | if (TabWidget->currentPageIndex() == 1) { | 100 | if (TabWidget->currentPageIndex() == 1) { |
108 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 101 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
109 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 102 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
110 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 103 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
111 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 104 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
112 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 105 | setCaption("AdvancedFm :: "+fs+" :: " |
106 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | ||
113 | } | 107 | } |
114 | } | 108 | } |
115 | 109 | ||
116 | 110 | ||
117 | void AdvancedFm::populateLocalView() { | 111 | void AdvancedFm::populateLocalView() { |
118 | QPixmap pm; | 112 | QPixmap pm; |
119 | Local_View->clear(); | 113 | Local_View->clear(); |
120 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 114 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
121 | currentDir.setMatchAllDirs(TRUE); | 115 | currentDir.setMatchAllDirs(TRUE); |
122 | currentDir.setNameFilter(filterStr); | 116 | currentDir.setNameFilter(filterStr); |
123 | QString fileL, fileS, fileDate; | 117 | QString fileL, fileS, fileDate; |
124 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 118 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
125 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 119 | setCaption("AdvancedFm :: "+fs+" :: " |
120 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | ||
126 | bool isDir=FALSE; | 121 | bool isDir=FALSE; |
127 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 122 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
128 | QFileInfoListIterator it(*list); | 123 | QFileInfoListIterator it(*list); |
129 | QFileInfo *fi; | 124 | QFileInfo *fi; |
130 | while ( (fi=it.current()) ) { | 125 | while ( (fi=it.current()) ) { |
131 | if (fi->isSymLink() ) { | 126 | if (fi->isSymLink() ) { |
132 | QString symLink=fi->readLink(); | 127 | QString symLink=fi->readLink(); |
133 | QFileInfo sym( symLink); | 128 | QFileInfo sym( symLink); |
134 | fileS.sprintf( "%10i", sym.size() ); | 129 | fileS.sprintf( "%10i", sym.size() ); |
135 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 130 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
136 | fileDate = sym.lastModified().toString(); | 131 | fileDate = sym.lastModified().toString(); |
137 | } else { | 132 | } else { |
138 | fileS.sprintf( "%10i", fi->size() ); | 133 | fileS.sprintf( "%10i", fi->size() ); |
139 | fileL.sprintf( "%s",fi->fileName().data() ); | 134 | fileL.sprintf( "%s",fi->fileName().data() ); |
140 | fileDate= fi->lastModified().toString(); | 135 | fileDate= fi->lastModified().toString(); |
141 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 136 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
142 | fileL+="/"; | 137 | fileL+="/"; |
143 | isDir=TRUE; | 138 | isDir=TRUE; |
144 | } | 139 | } |
145 | } | 140 | } |
146 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 141 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
147 | if(fileL !="./" && fi->exists()) { | 142 | if(fileL !="./" && fi->exists()) { |
148 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 143 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
149 | 144 | ||
150 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 145 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
151 | 146 | ||
152 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 147 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
153 | pm = Resource::loadPixmap( "lockedfolder" ); | 148 | pm = Resource::loadPixmap( "lockedfolder" ); |
154 | else | 149 | else |
155 | pm= Resource::loadPixmap( "folder" ); | 150 | pm= Resource::loadPixmap( "folder" ); |
156 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 151 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
157 | pm = Resource::loadPixmap( "exec"); | 152 | pm = Resource::loadPixmap( "exec"); |
158 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 153 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
159 | | fileInfo.permission( QFileInfo::ExeGroup) | 154 | | fileInfo.permission( QFileInfo::ExeGroup) |
160 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 155 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
161 | pm = Resource::loadPixmap( "exec"); | 156 | pm = Resource::loadPixmap( "exec"); |
162 | } else if( !fi->isReadable() ) { | 157 | } else if( !fi->isReadable() ) { |
163 | pm = Resource::loadPixmap( "locked" ); | 158 | pm = Resource::loadPixmap( "locked" ); |
164 | } else { //everything else goes by mimetype | 159 | } else { //everything else goes by mimetype |
165 | MimeType mt(fi->filePath()); | 160 | MimeType mt(fi->filePath()); |
166 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 161 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
167 | if(pm.isNull()) | 162 | if(pm.isNull()) |
168 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 163 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
169 | } | 164 | } |
170 | item->setPixmap( 0,pm); | 165 | item->setPixmap( 0,pm); |
171 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 166 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
172 | // overlay link image | 167 | // overlay link image |
173 | pm= Resource::loadPixmap( "folder" ); | 168 | pm= Resource::loadPixmap( "folder" ); |
174 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 169 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
175 | QPainter painter( &pm ); | 170 | QPainter painter( &pm ); |
176 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 171 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
177 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 172 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
178 | item->setPixmap( 0, pm); | 173 | item->setPixmap( 0, pm); |
179 | } | 174 | } |
180 | } | 175 | } |
181 | isDir=FALSE; | 176 | isDir=FALSE; |
182 | ++it; | 177 | ++it; |
183 | } | 178 | } |
184 | 179 | ||
185 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 180 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
186 | struct stat buf; | 181 | struct stat buf; |
187 | dev_t devT; | 182 | dev_t devT; |
188 | DIR *dir; | 183 | DIR *dir; |
189 | struct dirent *mydirent; | 184 | struct dirent *mydirent; |
190 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 185 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
191 | while ((mydirent = readdir(dir)) != NULL) { | 186 | while ((mydirent = readdir(dir)) != NULL) { |
192 | lstat( mydirent->d_name, &buf); | 187 | lstat( mydirent->d_name, &buf); |
193 | qDebug(mydirent->d_name); | 188 | qDebug(mydirent->d_name); |
194 | fileL.sprintf("%s", mydirent->d_name); | 189 | fileL.sprintf("%s", mydirent->d_name); |
195 | devT = buf.st_dev; | 190 | devT = buf.st_dev; |
196 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 191 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
197 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 192 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
198 | if( fileL.find(".") == -1 ){ | 193 | if( fileL.find(".") == -1 ){ |
199 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 194 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
200 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 195 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
201 | item->setPixmap( 0,pm); | 196 | item->setPixmap( 0,pm); |
202 | } | 197 | } |
203 | } | 198 | } |
204 | 199 | ||
205 | closedir(dir); | 200 | closedir(dir); |
206 | } | 201 | } |
207 | 202 | ||
208 | Local_View->setSorting( 3,FALSE); | 203 | Local_View->setSorting( 3,FALSE); |
209 | fillCombo( (const QString &) currentDir.canonicalPath()); | 204 | fillCombo( (const QString &) currentDir.canonicalPath()); |
210 | } | 205 | } |
211 | 206 | ||
212 | 207 | ||
213 | void AdvancedFm::populateRemoteView() { | 208 | void AdvancedFm::populateRemoteView() { |
214 | QPixmap pm; | 209 | QPixmap pm; |
215 | Remote_View->clear(); | 210 | Remote_View->clear(); |
216 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 211 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
217 | currentRemoteDir.setMatchAllDirs(TRUE); | 212 | currentRemoteDir.setMatchAllDirs(TRUE); |
218 | currentRemoteDir.setNameFilter(filterStr); | 213 | currentRemoteDir.setNameFilter(filterStr); |
219 | QString fileL, fileS, fileDate; | 214 | QString fileL, fileS, fileDate; |
220 | 215 | ||
221 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 216 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
222 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 217 | setCaption("AdvancedFm :: "+fs+" :: " |
218 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | ||
223 | bool isDir=FALSE; | 219 | bool isDir=FALSE; |
224 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 220 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
225 | QFileInfoListIterator it(*list); | 221 | QFileInfoListIterator it(*list); |
226 | QFileInfo *fi; | 222 | QFileInfo *fi; |
227 | while ( (fi=it.current()) ) { | 223 | while ( (fi=it.current()) ) { |
228 | if (fi->isSymLink() ){ | 224 | if (fi->isSymLink() ){ |
229 | QString symLink=fi->readLink(); | 225 | QString symLink=fi->readLink(); |
230 | // qDebug("Symlink detected "+symLink); | 226 | // qDebug("Symlink detected "+symLink); |
231 | QFileInfo sym( symLink); | 227 | QFileInfo sym( symLink); |
232 | fileS.sprintf( "%10i", sym.size() ); | 228 | fileS.sprintf( "%10i", sym.size() ); |
233 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 229 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
234 | fileDate = sym.lastModified().toString(); | 230 | fileDate = sym.lastModified().toString(); |
235 | } else { | 231 | } else { |
236 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 232 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
237 | fileS.sprintf( "%10i", fi->size() ); | 233 | fileS.sprintf( "%10i", fi->size() ); |
238 | fileL.sprintf( "%s",fi->fileName().data() ); | 234 | fileL.sprintf( "%s",fi->fileName().data() ); |
239 | fileDate= fi->lastModified().toString(); | 235 | fileDate= fi->lastModified().toString(); |
240 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 236 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
241 | fileL+="/"; | 237 | fileL+="/"; |
242 | isDir=TRUE; | 238 | isDir=TRUE; |
243 | // qDebug( fileL); | 239 | // qDebug( fileL); |
244 | } | 240 | } |
245 | } | 241 | } |
246 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); | 242 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); |
247 | if(fileL !="./" && fi->exists()) { | 243 | if(fileL !="./" && fi->exists()) { |
248 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 244 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
249 | QPixmap pm; | 245 | QPixmap pm; |
250 | 246 | ||
251 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 247 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
252 | if( !QDir( fi->filePath() ).isReadable()) | 248 | if( !QDir( fi->filePath() ).isReadable()) |
253 | pm = Resource::loadPixmap( "lockedfolder" ); | 249 | pm = Resource::loadPixmap( "lockedfolder" ); |
254 | else | 250 | else |
255 | pm= Resource::loadPixmap( "folder" ); | 251 | pm= Resource::loadPixmap( "folder" ); |
256 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 252 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
257 | pm = Resource::loadPixmap( "exec"); | 253 | pm = Resource::loadPixmap( "exec"); |
258 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 254 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
259 | | fileInfo.permission( QFileInfo::ExeGroup) | 255 | | fileInfo.permission( QFileInfo::ExeGroup) |
260 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 256 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
261 | pm = Resource::loadPixmap( "exec"); | 257 | pm = Resource::loadPixmap( "exec"); |
262 | } else if( !fi->isReadable() ) { | 258 | } else if( !fi->isReadable() ) { |
263 | pm = Resource::loadPixmap( "locked" ); | 259 | pm = Resource::loadPixmap( "locked" ); |
264 | } else { | 260 | } else { |
265 | MimeType mt(fi->filePath()); | 261 | MimeType mt(fi->filePath()); |
266 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 262 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
267 | if(pm.isNull()) | 263 | if(pm.isNull()) |
268 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 264 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
269 | } | 265 | } |
270 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 266 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
271 | // overlay link image | 267 | // overlay link image |
272 | pm= Resource::loadPixmap( "folder" ); | 268 | pm= Resource::loadPixmap( "folder" ); |
273 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 269 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
274 | QPainter painter( &pm ); | 270 | QPainter painter( &pm ); |
275 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 271 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
276 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 272 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
277 | } | 273 | } |
278 | item->setPixmap( 0, pm); | 274 | item->setPixmap( 0, pm); |
279 | } | 275 | } |
280 | isDir=FALSE; | 276 | isDir=FALSE; |
281 | ++it; | 277 | ++it; |
282 | } | 278 | } |
283 | 279 | ||
284 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 280 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
285 | struct stat buf; | 281 | struct stat buf; |
286 | DIR *dir; | 282 | DIR *dir; |
287 | struct dirent *mydirent; | 283 | struct dirent *mydirent; |
288 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 284 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
289 | while ((mydirent = readdir(dir)) != NULL) { | 285 | while ((mydirent = readdir(dir)) != NULL) { |
290 | lstat( mydirent->d_name, &buf); | 286 | lstat( mydirent->d_name, &buf); |
291 | qDebug(mydirent->d_name); | 287 | qDebug(mydirent->d_name); |
292 | fileL.sprintf("%s", mydirent->d_name); | 288 | fileL.sprintf("%s", mydirent->d_name); |
293 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 289 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
294 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 290 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
295 | if( fileL.find(".") == -1 ){ | 291 | if( fileL.find(".") == -1 ){ |
296 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 292 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
297 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 293 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
298 | item->setPixmap( 0,pm); | 294 | item->setPixmap( 0,pm); |
299 | } | 295 | } |
300 | } | 296 | } |
301 | 297 | ||
302 | closedir(dir); | 298 | closedir(dir); |
303 | } | 299 | } |
304 | 300 | ||
305 | Remote_View->setSorting( 3,FALSE); | 301 | Remote_View->setSorting( 3,FALSE); |
306 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 302 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
307 | } | 303 | } |
308 | 304 | ||
309 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) { | 305 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) { |
310 | if(selectedItem) { | 306 | if(selectedItem) { |
311 | QString strItem=selectedItem->text(0); | 307 | QString strItem=selectedItem->text(0); |
312 | QString strSize=selectedItem->text(1); | 308 | QString strSize=selectedItem->text(1); |
313 | strSize=strSize.stripWhiteSpace(); | 309 | strSize=strSize.stripWhiteSpace(); |
314 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 310 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
315 | // is symlink | ||
316 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 311 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
317 | if(QDir(strItem2).exists() ) { | 312 | if(QDir(strItem2).exists() ) { |
318 | currentDir.cd(strItem2, TRUE); | 313 | currentDir.cd(strItem2, TRUE); |
319 | populateLocalView(); | 314 | populateLocalView(); |
315 | |||
320 | } | 316 | } |
321 | } else { // not a symlink | 317 | } else { // not a symlink |
322 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 318 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
323 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 319 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
324 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 320 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
325 | currentDir.cd(strItem,FALSE); | 321 | currentDir.cd(strItem,FALSE); |
326 | populateLocalView(); | 322 | populateLocalView(); |
327 | } else { | 323 | } else { |
328 | currentDir.cdUp(); | 324 | currentDir.cdUp(); |
329 | populateLocalView(); | 325 | populateLocalView(); |
330 | } | 326 | } |
331 | if(QDir(strItem).exists()){ | 327 | if(QDir(strItem).exists()){ |
332 | currentDir.cd(strItem, TRUE); | 328 | currentDir.cd(strItem, TRUE); |
333 | populateLocalView(); | 329 | populateLocalView(); |
334 | } | 330 | } |
335 | } else { | 331 | } else { |
336 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 332 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
337 | if( QFile::exists(strItem ) ) { | 333 | if( QFile::exists(strItem ) ) { |
338 | // qDebug("clicked item "+strItem); | 334 | // qDebug("clicked item "+strItem); |
339 | // DocLnk doc( strItem, FALSE ); | 335 | // DocLnk doc( strItem, FALSE ); |
340 | // doc.execute(); | 336 | // doc.execute(); |
341 | // Local_View->clearSelection(); | 337 | // Local_View->clearSelection(); |
342 | } | 338 | } |
343 | } //end not symlink | 339 | } //end not symlink |
344 | chdir(strItem.latin1()); | 340 | chdir(strItem.latin1()); |
345 | } | 341 | } |
342 | Local_View->ensureItemVisible(Local_View->firstChild()); | ||
343 | |||
346 | } | 344 | } |
347 | } | 345 | } |
348 | 346 | ||
349 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { | 347 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { |
350 | 348 | ||
351 | if(selectedItem) { | 349 | if(selectedItem) { |
352 | QString strItem=selectedItem->text(0); | 350 | QString strItem=selectedItem->text(0); |
353 | QString strSize=selectedItem->text(1); | 351 | QString strSize=selectedItem->text(1); |
354 | strSize=strSize.stripWhiteSpace(); | 352 | strSize=strSize.stripWhiteSpace(); |
355 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 353 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
356 | // is symlink | ||
357 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 354 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
358 | if(QDir(strItem2).exists() ) { | ||
359 | currentRemoteDir.cd(strItem2, TRUE); | 355 | currentRemoteDir.cd(strItem2, TRUE); |
360 | populateRemoteView(); | 356 | populateRemoteView(); |
361 | } | ||
362 | } else { // not a symlink | 357 | } else { // not a symlink |
363 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 358 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
364 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 359 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
365 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 360 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
366 | currentRemoteDir.cd(strItem,FALSE); | 361 | currentRemoteDir.cd(strItem,FALSE); |
367 | populateRemoteView(); | 362 | populateRemoteView(); |
368 | } else { | 363 | } else { |
369 | currentRemoteDir.cdUp(); | 364 | currentRemoteDir.cdUp(); |
370 | populateRemoteView(); | 365 | populateRemoteView(); |
371 | } | 366 | } |
372 | if(QDir(strItem).exists()){ | 367 | if(QDir(strItem).exists()){ |
373 | currentRemoteDir.cd(strItem, TRUE); | 368 | currentRemoteDir.cd(strItem, TRUE); |
374 | populateRemoteView(); | 369 | populateRemoteView(); |
375 | } | 370 | } |
376 | } else { | 371 | } else { |
377 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 372 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
378 | if( QFile::exists(strItem ) ) { | 373 | if( QFile::exists(strItem ) ) { |
379 | // qDebug("clicked item "+strItem); | 374 | // qDebug("clicked item "+strItem); |
380 | // DocLnk doc( strItem, FALSE ); | 375 | // DocLnk doc( strItem, FALSE ); |
381 | // doc.execute(); | 376 | // doc.execute(); |
382 | // Remote_View->clearSelection(); | 377 | // Remote_View->clearSelection(); |
383 | } | 378 | } |
384 | } //end not symlink | 379 | } //end not symlink |
385 | chdir(strItem.latin1()); | 380 | chdir(strItem.latin1()); |
386 | } | 381 | } |
382 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | ||
387 | } | 383 | } |
388 | } | 384 | } |
389 | 385 | ||
390 | void AdvancedFm::doLocalCd() { | ||
391 | localListClicked( Local_View->currentItem()); | ||
392 | } | ||
393 | |||
394 | void AdvancedFm::doRemoteCd() { | ||
395 | localListClicked( Remote_View->currentItem()); | ||
396 | } | ||
397 | |||
398 | void AdvancedFm::showHidden() { | ||
399 | if (b) { | ||
400 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | ||
401 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | ||
402 | b=FALSE; | ||
403 | |||
404 | } else { | ||
405 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
406 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | ||
407 | b=TRUE; | ||
408 | } | ||
409 | populateLocalView(); | ||
410 | |||
411 | } | ||
412 | |||
413 | void AdvancedFm::showRemoteHidden() { | ||
414 | if (b) { | ||
415 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | ||
416 | b=TRUE; | ||
417 | |||
418 | } else { | ||
419 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
420 | b=FALSE; | ||
421 | } | ||
422 | populateRemoteView(); | ||
423 | } | ||
424 | 386 | ||
425 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 387 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
426 | qDebug("list pressed"); | 388 | // qDebug("list pressed"); |
427 | switch (mouse) { | 389 | switch (mouse) { |
428 | case 1: | 390 | case 1: |
429 | break; | 391 | break; |
430 | case 2: | 392 | case 2: |
431 | menuTimer.start( 750, TRUE ); | 393 | menuTimer.start( 750, TRUE ); |
432 | qDebug("Start menu timer\n"); | 394 | qDebug("Start menu timer\n"); |
433 | break; | 395 | break; |
434 | }; | 396 | }; |
435 | } | 397 | } |
436 | 398 | ||
437 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { | 399 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { |
438 | 400 | ||
439 | switch (mouse) { | 401 | switch (mouse) { |
440 | case 1: | 402 | case 1: |
441 | break; | 403 | break; |
442 | case 2: | 404 | case 2: |
443 | menuTimer.start( 750, TRUE ); | 405 | menuTimer.start( 750, TRUE ); |
444 | qDebug("Start menu timer"); | 406 | qDebug("Start menu timer"); |
445 | break; | 407 | break; |
446 | }; | 408 | }; |
447 | } | 409 | } |
448 | 410 | ||
449 | void AdvancedFm::runThis() { | ||
450 | QString fs; | ||
451 | if (TabWidget->currentPageIndex() == 0) { | ||
452 | QString curFile = Local_View->currentItem()->text(0); | ||
453 | if(curFile != "../") { | ||
454 | |||
455 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | ||
456 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | ||
457 | qDebug( fileInfo.owner()); | ||
458 | if( (fileInfo.permission( QFileInfo::ExeUser) | ||
459 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
460 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | ||
461 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
462 | QCopEnvelope e("QPE/System", "execute(QString)" ); | ||
463 | e << curFile; | ||
464 | } else { | ||
465 | curFile = currentDir.canonicalPath()+"/"+curFile; | ||
466 | DocLnk nf(curFile); | ||
467 | QString execStr = nf.exec(); | ||
468 | qDebug( execStr); | ||
469 | if( execStr.isEmpty() ) { | ||
470 | } else { | ||
471 | nf.execute(); | ||
472 | } | ||
473 | } | ||
474 | } | ||
475 | } else { | ||
476 | QString curFile = Remote_View->currentItem()->text(0); | ||
477 | if(curFile != "../") { | ||
478 | |||
479 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | ||
480 | qDebug("Filesystemtype is "+fs); | ||
481 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | ||
482 | if( (fileInfo.permission( QFileInfo::ExeUser) | ||
483 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
484 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | ||
485 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
486 | QCopEnvelope e("QPE/System", "execute(QString)" ); | ||
487 | e << curFile; | ||
488 | } else { | ||
489 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | ||
490 | DocLnk nf(curFile); | ||
491 | QString execStr = nf.exec(); | ||
492 | qDebug(execStr); | ||
493 | if( execStr.isEmpty() ) { | ||
494 | } else { | ||
495 | nf.execute(); | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | } | ||
501 | |||
502 | void AdvancedFm::runText() { | ||
503 | if (TabWidget->currentPageIndex() == 0) { | ||
504 | QString curFile = Local_View->currentItem()->text(0); | ||
505 | if(curFile != "../") { | ||
506 | curFile = currentDir.canonicalPath()+"/"+curFile; | ||
507 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | ||
508 | e << curFile; | ||
509 | } | ||
510 | } else { | ||
511 | QString curFile = Remote_View->currentItem()->text(0); | ||
512 | if(curFile != "../") { | ||
513 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | ||
514 | DocLnk nf(curFile); | ||
515 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | ||
516 | e << curFile; | ||
517 | } | ||
518 | } | ||
519 | } | ||
520 | |||
521 | void AdvancedFm::localMakDir() { | ||
522 | InputDialog *fileDlg; | ||
523 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | ||
524 | fileDlg->exec(); | ||
525 | if( fileDlg->result() == 1 ) { | ||
526 | QString filename = fileDlg->LineEdit1->text(); | ||
527 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | ||
528 | } | ||
529 | populateLocalView(); | ||
530 | } | ||
531 | |||
532 | void AdvancedFm::remoteMakDir() { | ||
533 | InputDialog *fileDlg; | ||
534 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | ||
535 | fileDlg->exec(); | ||
536 | if( fileDlg->result() == 1 ) { | ||
537 | QString filename = fileDlg->LineEdit1->text(); | ||
538 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | ||
539 | } | ||
540 | populateRemoteView(); | ||
541 | } | ||
542 | |||
543 | void AdvancedFm::localDelete() { | ||
544 | QStringList curFileList = getPath(); | ||
545 | if(curFileList.count() > 0) { | ||
546 | QString myFile; | ||
547 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
548 | myFile = (*it); | ||
549 | if( myFile.find(" -> ",0,TRUE) != -1) | ||
550 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | ||
551 | |||
552 | QString f = currentDir.canonicalPath(); | ||
553 | if(f.right(1).find("/",0,TRUE) == -1) | ||
554 | f+="/"; | ||
555 | f+=myFile; | ||
556 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | ||
557 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | ||
558 | "\nand all it's contents ?" | ||
559 | ,tr("Yes"),tr("No"),0,0,1) ) { | ||
560 | case 0: { | ||
561 | f=f.left(f.length()-1); | ||
562 | QString cmd="rm -rf "+f; | ||
563 | system( cmd.latin1()); | ||
564 | populateLocalView(); | ||
565 | } | ||
566 | break; | ||
567 | case 1: | ||
568 | // exit | ||
569 | break; | ||
570 | }; | ||
571 | |||
572 | } else { | ||
573 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | ||
574 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | ||
575 | case 0: { | ||
576 | QString cmd="rm "+f; | ||
577 | QFile file(f); | ||
578 | file.remove(); | ||
579 | // system( cmd.latin1()); | ||
580 | populateLocalView(); | ||
581 | } | ||
582 | break; | ||
583 | case 1: | ||
584 | // exit | ||
585 | break; | ||
586 | }; | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | } | ||
591 | |||
592 | void AdvancedFm::remoteDelete() { | ||
593 | QStringList curFileList = getPath(); | ||
594 | if( curFileList.count() > 0) { | ||
595 | QString myFile; | ||
596 | |||
597 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
598 | myFile = (*it); | ||
599 | if(myFile.find(" -> ",0,TRUE) != -1) | ||
600 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | ||
601 | QString f = currentRemoteDir.canonicalPath(); | ||
602 | if(f.right(1).find("/",0,TRUE) == -1) | ||
603 | f+="/"; | ||
604 | f+=myFile; | ||
605 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | ||
606 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | ||
607 | "\nand all it's contents ?", | ||
608 | tr("Yes"),tr("No"),0,0,1) ) { | ||
609 | case 0: { | ||
610 | f=f.left(f.length()-1); | ||
611 | QString cmd="rm -rf "+f; | ||
612 | system( cmd.latin1()); | ||
613 | populateRemoteView(); | ||
614 | } | ||
615 | break; | ||
616 | case 1: | ||
617 | // exit | ||
618 | break; | ||
619 | }; | ||
620 | |||
621 | } else { | ||
622 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | ||
623 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | ||
624 | case 0: { | ||
625 | QString cmd="rm "+f; | ||
626 | QFile file(f); | ||
627 | file.remove(); | ||
628 | // system( cmd.latin1()); | ||
629 | populateRemoteView(); | ||
630 | } | ||
631 | break; | ||
632 | case 1: | ||
633 | // exit | ||
634 | break; | ||
635 | }; | ||
636 | } | ||
637 | } | ||
638 | } | ||
639 | } | ||
640 | |||
641 | void AdvancedFm::localRename() { | ||
642 | QString curFile = Local_View->currentItem()->text(0); | ||
643 | qDebug("currentItem "+curFile); | ||
644 | if( curFile !="../") { | ||
645 | InputDialog *fileDlg; | ||
646 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | ||
647 | fileDlg->setInputText((const QString &)curFile); | ||
648 | fileDlg->exec(); | ||
649 | if( fileDlg->result() == 1 ) { | ||
650 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | ||
651 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | ||
652 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
653 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
654 | } | ||
655 | populateLocalView(); | ||
656 | } | ||
657 | } | ||
658 | |||
659 | void AdvancedFm::remoteRename() | ||
660 | { | ||
661 | QString curFile = Remote_View->currentItem()->text(0); | ||
662 | if( curFile !="../") { | ||
663 | InputDialog *fileDlg; | ||
664 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | ||
665 | fileDlg->setInputText((const QString &)curFile); | ||
666 | fileDlg->exec(); | ||
667 | if( fileDlg->result() == 1 ) { | ||
668 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | ||
669 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | ||
670 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
671 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
672 | } | ||
673 | populateRemoteView(); | ||
674 | } | ||
675 | } | ||
676 | 411 | ||
677 | void AdvancedFm::switchToLocalTab() { | 412 | void AdvancedFm::switchToLocalTab() { |
678 | TabWidget->setCurrentPage(0); | 413 | TabWidget->setCurrentPage(0); |
679 | Local_View->setFocus(); | 414 | Local_View->setFocus(); |
680 | } | 415 | } |
681 | 416 | ||
682 | void AdvancedFm::switchToRemoteTab() { | 417 | void AdvancedFm::switchToRemoteTab() { |
683 | TabWidget->setCurrentPage(1); | 418 | TabWidget->setCurrentPage(1); |
684 | Remote_View->setFocus(); | 419 | Remote_View->setFocus(); |
685 | } | 420 | } |
686 | 421 | ||
687 | void AdvancedFm::readConfig() { | 422 | void AdvancedFm::readConfig() { |
688 | Config cfg("AdvancedFm"); | 423 | Config cfg("AdvancedFm"); |
689 | } | 424 | } |
690 | 425 | ||
691 | void AdvancedFm::writeConfig() { | 426 | void AdvancedFm::writeConfig() { |
692 | Config cfg("AdvancedFm"); | 427 | Config cfg("AdvancedFm"); |
693 | } | 428 | } |
694 | 429 | ||
695 | void AdvancedFm::currentPathComboChanged() { | 430 | void AdvancedFm::currentPathComboChanged() { |
696 | if (TabWidget->currentPageIndex() == 0) { | 431 | if (TabWidget->currentPageIndex() == 0) { |
697 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 432 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
698 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 433 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
699 | populateLocalView(); | 434 | populateLocalView(); |
700 | } else { | 435 | } else { |
701 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 436 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
702 | } | 437 | } |
703 | } | 438 | } |
704 | if (TabWidget->currentPageIndex() == 0) { | 439 | if (TabWidget->currentPageIndex() == 0) { |
705 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 440 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
706 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 441 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
707 | populateRemoteView(); | 442 | populateRemoteView(); |
708 | } else { | 443 | } else { |
709 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 444 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
710 | } | 445 | } |
711 | } | 446 | } |
712 | } | 447 | } |
713 | 448 | ||
714 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 449 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
715 | 450 | ||
716 | if (TabWidget->currentPageIndex() == 0) { | 451 | if (TabWidget->currentPageIndex() == 0) { |
717 | currentPathCombo->lineEdit()->setText( currentPath); | 452 | currentPathCombo->lineEdit()->setText( currentPath); |
718 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 453 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
719 | currentPathCombo->clear(); | 454 | currentPathCombo->clear(); |
720 | localDirPathStringList.prepend( currentPath ); | 455 | localDirPathStringList.prepend( currentPath ); |
721 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 456 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
722 | } | 457 | } |
723 | } else { | 458 | } else { |
724 | currentPathCombo->lineEdit()->setText( currentPath); | 459 | currentPathCombo->lineEdit()->setText( currentPath); |
725 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 460 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
726 | currentPathCombo->clear(); | 461 | currentPathCombo->clear(); |
727 | remoteDirPathStringList.prepend( currentPath ); | 462 | remoteDirPathStringList.prepend( currentPath ); |
728 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 463 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
729 | } | 464 | } |
730 | } | 465 | } |
731 | } | 466 | } |
732 | 467 | ||
733 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 468 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
734 | if (TabWidget->currentPageIndex() == 0) { | 469 | if (TabWidget->currentPageIndex() == 0) { |
735 | chdir( currentPath.latin1() ); | 470 | chdir( currentPath.latin1() ); |
736 | currentDir.cd( currentPath, TRUE); | 471 | currentDir.cd( currentPath, TRUE); |
737 | populateLocalView(); | 472 | populateLocalView(); |
738 | update(); | 473 | update(); |
739 | } else { | 474 | } else { |
740 | chdir( currentPath.latin1() ); | 475 | chdir( currentPath.latin1() ); |
741 | currentRemoteDir.cd( currentPath, TRUE); | 476 | currentRemoteDir.cd( currentPath, TRUE); |
742 | populateRemoteView(); | 477 | populateRemoteView(); |
743 | update(); | 478 | update(); |
744 | } | 479 | } |
745 | } | 480 | } |
746 | 481 | ||
747 | void AdvancedFm::filePerms() { | ||
748 | |||
749 | QStringList curFileList = getPath(); | ||
750 | QString filePath; | ||
751 | |||
752 | if (TabWidget->currentPageIndex() == 0) { | ||
753 | filePath = currentDir.canonicalPath()+"/"; | ||
754 | } else { | ||
755 | filePath= currentRemoteDir.canonicalPath()+"/"; | ||
756 | } | ||
757 | |||
758 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
759 | filePermissions *filePerm; | ||
760 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | ||
761 | filePerm->showMaximized(); | ||
762 | filePerm->exec(); | ||
763 | if( filePerm) | ||
764 | delete filePerm; | ||
765 | } | ||
766 | if (TabWidget->currentPageIndex() == 0) { | ||
767 | populateLocalView(); | ||
768 | } else { | ||
769 | populateRemoteView(); | ||
770 | } | ||
771 | } | ||
772 | |||
773 | void AdvancedFm::doProperties() { | ||
774 | QStringList curFileList = getPath(); | ||
775 | QString filePath; | ||
776 | if (TabWidget->currentPageIndex() == 0) { | ||
777 | filePath = currentDir.canonicalPath()+"/"; | ||
778 | } else { | ||
779 | filePath= currentRemoteDir.canonicalPath()+"/"; | ||
780 | } | ||
781 | // qDebug("%d",curFileList.count()); | ||
782 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
783 | qDebug((filePath+*it)); | ||
784 | DocLnk lnk( (filePath+*it)); | ||
785 | LnkProperties prop( &lnk ); | ||
786 | prop.showMaximized(); | ||
787 | prop.exec(); | ||
788 | } | ||
789 | } | ||
790 | |||
791 | QStringList AdvancedFm::getPath() { | 482 | QStringList AdvancedFm::getPath() { |
792 | QStringList strList; | 483 | QStringList strList; |
793 | if (TabWidget->currentPageIndex() == 0) { | 484 | if (TabWidget->currentPageIndex() == 0) { |
794 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 485 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
795 | QListViewItemIterator it( Local_View ); | 486 | QListViewItemIterator it( Local_View ); |
796 | for ( ; it.current(); ++it ) { | 487 | for ( ; it.current(); ++it ) { |
797 | if ( it.current()->isSelected() ) { | 488 | if ( it.current()->isSelected() ) { |
798 | strList << it.current()->text(0); | 489 | strList << it.current()->text(0); |
799 | qDebug(it.current()->text(0)); | 490 | qDebug(it.current()->text(0)); |
800 | } | 491 | } |
801 | } | 492 | } |
802 | return strList; | 493 | return strList; |
803 | } else { | 494 | } else { |
804 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 495 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
805 | QListViewItemIterator it( Remote_View ); | 496 | QListViewItemIterator it( Remote_View ); |
806 | for ( ; it.current(); ++it ) { | 497 | for ( ; it.current(); ++it ) { |
807 | if ( it.current()->isSelected() ) { | 498 | if ( it.current()->isSelected() ) { |
808 | strList << it.current()->text(0); | 499 | strList << it.current()->text(0); |
809 | qDebug(it.current()->text(0)); | 500 | qDebug(it.current()->text(0)); |
810 | } | 501 | } |
811 | } | 502 | } |
812 | return strList; | 503 | return strList; |
813 | } | 504 | } |
814 | return ""; | 505 | return ""; |
815 | } | 506 | } |
816 | 507 | ||
817 | void AdvancedFm::homeButtonPushed() { | 508 | void AdvancedFm::homeButtonPushed() { |
818 | QString current = QDir::homeDirPath(); | 509 | QString current = QDir::homeDirPath(); |
819 | chdir( current.latin1() ); | 510 | chdir( current.latin1() ); |
820 | if (TabWidget->currentPageIndex() == 0) { | 511 | if (TabWidget->currentPageIndex() == 0) { |
821 | currentDir.cd( current, TRUE); | 512 | currentDir.cd( current, TRUE); |
822 | populateLocalView(); | 513 | populateLocalView(); |
823 | } else { | 514 | } else { |
824 | currentRemoteDir.cd( current, TRUE); | 515 | currentRemoteDir.cd( current, TRUE); |
825 | populateRemoteView(); | 516 | populateRemoteView(); |
826 | } | 517 | } |
827 | update(); | 518 | update(); |
828 | } | 519 | } |
829 | 520 | ||
830 | void AdvancedFm::docButtonPushed() { | 521 | void AdvancedFm::docButtonPushed() { |
831 | QString current = QPEApplication::documentDir(); | 522 | QString current = QPEApplication::documentDir(); |
832 | chdir( current.latin1() ); | 523 | chdir( current.latin1() ); |
833 | if (TabWidget->currentPageIndex() == 0) { | 524 | if (TabWidget->currentPageIndex() == 0) { |
834 | currentDir.cd( current, TRUE); | 525 | currentDir.cd( current, TRUE); |
835 | populateLocalView(); | 526 | populateLocalView(); |
836 | } else { | 527 | } else { |
837 | currentRemoteDir.cd( current, TRUE); | 528 | currentRemoteDir.cd( current, TRUE); |
838 | populateRemoteView(); | 529 | populateRemoteView(); |
839 | } | 530 | } |
840 | update(); | 531 | update(); |
841 | } | 532 | } |
842 | 533 | ||
843 | void AdvancedFm::SDButtonPushed() { | 534 | void AdvancedFm::SDButtonPushed() { |
844 | QString current = "/mnt/card"; | 535 | QString current = "/mnt/card";// this can change so fix |
845 | chdir( current.latin1() ); | 536 | chdir( current.latin1() ); |
846 | if (TabWidget->currentPageIndex() == 0) { | 537 | if (TabWidget->currentPageIndex() == 0) { |
847 | currentDir.cd( current, TRUE); | 538 | currentDir.cd( current, TRUE); |
848 | populateLocalView(); | 539 | populateLocalView(); |
849 | } else { | 540 | } else { |
850 | currentRemoteDir.cd( current, TRUE); | 541 | currentRemoteDir.cd( current, TRUE); |
851 | populateRemoteView(); | 542 | populateRemoteView(); |
852 | } | 543 | } |
853 | update(); | 544 | update(); |
854 | 545 | ||
855 | } | 546 | } |
856 | 547 | ||
857 | void AdvancedFm::CFButtonPushed() { | 548 | void AdvancedFm::CFButtonPushed() { |
858 | QString current; | 549 | QString current; |
859 | if(zaurusDevice) | 550 | if(zaurusDevice) |
860 | current= "/mnt/cf"; | 551 | current= "/mnt/cf"; //zaurus |
861 | else | 552 | else |
862 | current = "/mnt/hda"; | 553 | current = "/mnt/hda"; //ipaq |
863 | 554 | ||
864 | chdir( current.latin1() ); | 555 | chdir( current.latin1() ); |
865 | if (TabWidget->currentPageIndex() == 0) { | 556 | if (TabWidget->currentPageIndex() == 0) { |
866 | currentDir.cd( current, TRUE); | 557 | currentDir.cd( current, TRUE); |
867 | populateLocalView(); | 558 | populateLocalView(); |
868 | } else { | 559 | } else { |
869 | currentRemoteDir.cd( current, TRUE); | 560 | currentRemoteDir.cd( current, TRUE); |
870 | populateRemoteView(); | 561 | populateRemoteView(); |
871 | } | 562 | } |
872 | update(); | 563 | update(); |
873 | |||
874 | } | ||
875 | |||
876 | |||
877 | void AdvancedFm::upDir() { | ||
878 | if (TabWidget->currentPageIndex() == 0) { | ||
879 | QString current = currentDir.canonicalPath(); | ||
880 | QDir dir(current); | ||
881 | dir.cdUp(); | ||
882 | current = dir.canonicalPath(); | ||
883 | chdir( current.latin1() ); | ||
884 | currentDir.cd( current, TRUE); | ||
885 | populateLocalView(); | ||
886 | update(); | ||
887 | } else { | ||
888 | QString current = currentRemoteDir.canonicalPath(); | ||
889 | QDir dir(current); | ||
890 | dir.cdUp(); | ||
891 | current = dir.canonicalPath(); | ||
892 | chdir( current.latin1() ); | ||
893 | currentRemoteDir.cd( current, TRUE); | ||
894 | populateRemoteView(); | ||
895 | update(); | ||
896 | } | ||
897 | } | ||
898 | |||
899 | void AdvancedFm::copy() { | ||
900 | qApp->processEvents(); | ||
901 | QStringList curFileList = getPath(); | ||
902 | if( curFileList.count() > 0) { | ||
903 | QString curFile; | ||
904 | if (TabWidget->currentPageIndex() == 0) { | ||
905 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
906 | |||
907 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
908 | qDebug("Destination file is "+destFile); | ||
909 | |||
910 | curFile = currentDir.canonicalPath()+"/"+(*it); | ||
911 | qDebug("CurrentFile file is " + curFile); | ||
912 | |||
913 | QFile f(destFile); | ||
914 | if( f.exists()) { | ||
915 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
916 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
917 | tr("Yes"),tr("No"),0,0,1) ) { | ||
918 | case 0: | ||
919 | f.remove(); | ||
920 | break; | ||
921 | case 1: | ||
922 | return; | ||
923 | break; | ||
924 | }; | ||
925 | } | ||
926 | if(!copyFile(destFile, curFile) ) { | ||
927 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | ||
928 | qWarning("nothin doing"); | ||
929 | } | ||
930 | } | ||
931 | populateRemoteView(); | ||
932 | TabWidget->setCurrentPage(1); | ||
933 | |||
934 | } else { | ||
935 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
936 | |||
937 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | ||
938 | qDebug("Destination file is "+destFile); | ||
939 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
940 | qDebug("CurrentFile file is " + curFile); | ||
941 | |||
942 | QFile f(destFile); | ||
943 | if( f.exists()) { | ||
944 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
945 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
946 | tr("Yes"),tr("No"),0,0,1) ) { | ||
947 | case 0: | ||
948 | f.remove(); | ||
949 | break; | ||
950 | case 1: | ||
951 | return; | ||
952 | break; | ||
953 | }; | ||
954 | } | ||
955 | if(!copyFile(destFile, curFile) ) { | ||
956 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
957 | |||
958 | qWarning("nothin doing"); | ||
959 | } | ||
960 | } | ||
961 | populateLocalView(); | ||
962 | TabWidget->setCurrentPage(0); | ||
963 | } | ||
964 | |||
965 | } | ||
966 | } | ||
967 | |||
968 | void AdvancedFm::copyAs() { | ||
969 | qApp->processEvents(); | ||
970 | |||
971 | QStringList curFileList = getPath(); | ||
972 | QString curFile; | ||
973 | InputDialog *fileDlg; | ||
974 | if (TabWidget->currentPageIndex() == 0) { | ||
975 | qDebug("tab 1"); | ||
976 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
977 | QString destFile; | ||
978 | curFile = currentDir.canonicalPath()+"/"+(*it); | ||
979 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
980 | |||
981 | fileDlg->setInputText((const QString &) destFile ); | ||
982 | fileDlg->exec(); | ||
983 | |||
984 | if( fileDlg->result() == 1 ) { | ||
985 | QString filename = fileDlg->LineEdit1->text(); | ||
986 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | ||
987 | |||
988 | QFile f(destFile); | ||
989 | if( f.exists()) { | ||
990 | switch (QMessageBox::warning(this,tr("Delete"), | ||
991 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
992 | tr("Yes"),tr("No"),0,0,1) ) { | ||
993 | case 0: | ||
994 | f.remove(); | ||
995 | break; | ||
996 | case 1: | ||
997 | return; | ||
998 | break; | ||
999 | }; | ||
1000 | } | ||
1001 | if(!copyFile(destFile, curFile) ) { | ||
1002 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1003 | qWarning("nothin doing"); | ||
1004 | } | ||
1005 | } | ||
1006 | delete fileDlg; | ||
1007 | |||
1008 | } | ||
1009 | populateRemoteView(); | ||
1010 | TabWidget->setCurrentPage(1); | ||
1011 | |||
1012 | } else { | ||
1013 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1014 | |||
1015 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1016 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
1017 | |||
1018 | QString destFile; | ||
1019 | fileDlg->setInputText((const QString &) destFile); | ||
1020 | fileDlg->exec(); | ||
1021 | |||
1022 | if( fileDlg->result() == 1 ) { | ||
1023 | QString filename = fileDlg->LineEdit1->text(); | ||
1024 | destFile = currentDir.canonicalPath()+"/"+filename; | ||
1025 | |||
1026 | QFile f( destFile); | ||
1027 | if( f.exists()) { | ||
1028 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
1029 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1030 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1031 | case 0: | ||
1032 | f.remove(); | ||
1033 | break; | ||
1034 | case 1: | ||
1035 | return; | ||
1036 | break; | ||
1037 | }; | ||
1038 | } | ||
1039 | if(!copyFile(destFile, curFile) ) { | ||
1040 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1041 | qWarning("nothin doing"); | ||
1042 | } | ||
1043 | |||
1044 | } | ||
1045 | delete fileDlg; | ||
1046 | |||
1047 | } | ||
1048 | populateLocalView(); | ||
1049 | TabWidget->setCurrentPage(0); | ||
1050 | } | ||
1051 | } | ||
1052 | |||
1053 | void AdvancedFm::copySameDir() { | ||
1054 | qApp->processEvents(); | ||
1055 | QStringList curFileList = getPath(); | ||
1056 | QString curFile; | ||
1057 | InputDialog *fileDlg; | ||
1058 | |||
1059 | if (TabWidget->currentPageIndex() == 0) { | ||
1060 | |||
1061 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1062 | |||
1063 | QString destFile; | ||
1064 | curFile = currentDir.canonicalPath()+"/"+(*it); | ||
1065 | |||
1066 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | ||
1067 | fileDlg->setInputText((const QString &) destFile ); | ||
1068 | fileDlg->exec(); | ||
1069 | |||
1070 | if( fileDlg->result() == 1 ) { | ||
1071 | |||
1072 | QString filename = fileDlg->LineEdit1->text(); | ||
1073 | destFile = currentDir.canonicalPath()+"/"+filename; | ||
1074 | |||
1075 | QFile f(destFile); | ||
1076 | if( f.exists()) { | ||
1077 | switch (QMessageBox::warning(this,tr("Delete"), | ||
1078 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1079 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1080 | case 0: | ||
1081 | |||
1082 | f.remove(); | ||
1083 | break; | ||
1084 | case 1: | ||
1085 | return; | ||
1086 | break; | ||
1087 | }; | ||
1088 | } | ||
1089 | if(!copyFile(destFile, curFile) ) { | ||
1090 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1091 | qWarning("nothin doing"); | ||
1092 | } | ||
1093 | |||
1094 | qDebug("copy "+curFile+" as "+destFile); | ||
1095 | } | ||
1096 | delete fileDlg; | ||
1097 | } | ||
1098 | populateLocalView(); | ||
1099 | |||
1100 | } else { | ||
1101 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1102 | |||
1103 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1104 | |||
1105 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | ||
1106 | QString destFile; | ||
1107 | fileDlg->setInputText((const QString &) destFile); | ||
1108 | fileDlg->exec(); | ||
1109 | if( fileDlg->result() == 1 ) { | ||
1110 | QString filename = fileDlg->LineEdit1->text(); | ||
1111 | |||
1112 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | ||
1113 | |||
1114 | QFile f(destFile); | ||
1115 | if( f.exists()) { | ||
1116 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
1117 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1118 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1119 | case 0: | ||
1120 | f.remove(); | ||
1121 | break; | ||
1122 | case 1: | ||
1123 | return; | ||
1124 | break; | ||
1125 | }; | ||
1126 | } | ||
1127 | if(!copyFile(destFile, curFile) ) { | ||
1128 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1129 | qWarning("nothin doing"); | ||
1130 | } | ||
1131 | qDebug("copy "+curFile+" as "+destFile); | ||
1132 | } | ||
1133 | delete fileDlg; | ||
1134 | } | ||
1135 | populateRemoteView(); | ||
1136 | } | ||
1137 | } | ||
1138 | |||
1139 | void AdvancedFm::move() { | ||
1140 | qApp->processEvents(); | ||
1141 | |||
1142 | QStringList curFileList = getPath(); | ||
1143 | if( curFileList.count() > 0) { | ||
1144 | QString curFile; | ||
1145 | QString destFile; | ||
1146 | |||
1147 | if (TabWidget->currentPageIndex() == 0) { | ||
1148 | |||
1149 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1150 | |||
1151 | QString destFile = currentRemoteDir.canonicalPath(); | ||
1152 | |||
1153 | if(destFile.right(1).find("/",0,TRUE) == -1) | ||
1154 | destFile+="/"; | ||
1155 | destFile +=(*it); | ||
1156 | curFile = currentDir.canonicalPath(); | ||
1157 | |||
1158 | qDebug("Destination file is "+destFile); | ||
1159 | |||
1160 | if(curFile.right(1).find("/",0,TRUE) == -1) | ||
1161 | curFile +="/"; | ||
1162 | |||
1163 | curFile+=(*it); | ||
1164 | qDebug("CurrentFile file is " + curFile); | ||
1165 | |||
1166 | QFile f( curFile); | ||
1167 | if( f.exists()) { | ||
1168 | if(!copyFile( destFile, curFile) ) { | ||
1169 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | ||
1170 | return; | ||
1171 | } else | ||
1172 | QFile::remove(curFile); | ||
1173 | } | ||
1174 | } | ||
1175 | |||
1176 | TabWidget->setCurrentPage(1); | ||
1177 | |||
1178 | } else { //view 2 | ||
1179 | |||
1180 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1181 | |||
1182 | QString destFile = currentDir.canonicalPath(); | ||
1183 | |||
1184 | if(destFile.right(1).find("/",0,TRUE) == -1) | ||
1185 | destFile+="/"; | ||
1186 | |||
1187 | destFile +=(*it); | ||
1188 | |||
1189 | qDebug("Destination file is "+destFile); | ||
1190 | |||
1191 | curFile = currentRemoteDir.canonicalPath(); | ||
1192 | |||
1193 | if(curFile.right(1).find("/",0,TRUE) == -1) | ||
1194 | curFile +="/"; | ||
1195 | curFile+=(*it); | ||
1196 | qDebug("CurrentFile file is " + curFile); | ||
1197 | |||
1198 | QFile f( curFile); | ||
1199 | if( f.exists()) { | ||
1200 | if(!copyFile( destFile, curFile) ) { | ||
1201 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | ||
1202 | return; | ||
1203 | } else | ||
1204 | QFile::remove( curFile); | ||
1205 | } | ||
1206 | TabWidget->setCurrentPage(0); | ||
1207 | } | ||
1208 | } | ||
1209 | populateRemoteView(); | ||
1210 | populateLocalView(); | ||
1211 | } | ||
1212 | } | ||
1213 | |||
1214 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { | ||
1215 | char bf[ 50000 ]; | ||
1216 | int bytesRead; | ||
1217 | bool success = TRUE; | ||
1218 | struct stat status; | ||
1219 | |||
1220 | QFile s( src ); | ||
1221 | QFile d( dest ); | ||
1222 | |||
1223 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | ||
1224 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | ||
1225 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | ||
1226 | success = FALSE; | ||
1227 | break; | ||
1228 | } | ||
1229 | } | ||
1230 | if( success && (bytesRead > 0) ){ | ||
1231 | d.writeBlock( bf, bytesRead ); | ||
1232 | } | ||
1233 | } else { | ||
1234 | success = FALSE; | ||
1235 | } | ||
1236 | |||
1237 | // Set file permissions | ||
1238 | if( stat( (const char *) src, &status ) == 0 ){ | ||
1239 | chmod( (const char *) dest, status.st_mode ); | ||
1240 | } | ||
1241 | |||
1242 | return success; | ||
1243 | } | ||
1244 | |||
1245 | void AdvancedFm::runCommand() { | ||
1246 | QString curFile; | ||
1247 | if (TabWidget->currentPageIndex() == 0) { | ||
1248 | if( Local_View->currentItem()) | ||
1249 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | ||
1250 | } else { | ||
1251 | if(Remote_View->currentItem()) | ||
1252 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | ||
1253 | } | ||
1254 | |||
1255 | InputDialog *fileDlg; | ||
1256 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | ||
1257 | fileDlg->setInputText(curFile); | ||
1258 | fileDlg->exec(); | ||
1259 | QString command; | ||
1260 | if( fileDlg->result() == 1 ) { | ||
1261 | command = fileDlg->LineEdit1->text(); | ||
1262 | |||
1263 | Output *outDlg; | ||
1264 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
1265 | outDlg->showMaximized(); | ||
1266 | outDlg->show(); | ||
1267 | qApp->processEvents(); | ||
1268 | FILE *fp; | ||
1269 | char line[130]; | ||
1270 | sleep(1); | ||
1271 | command +=" 2>&1"; | ||
1272 | fp = popen( (const char *) command, "r"); | ||
1273 | if ( !fp ) { | ||
1274 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
1275 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
1276 | pclose(fp); | ||
1277 | return; | ||
1278 | } else { | ||
1279 | while ( fgets( line, sizeof line, fp)) { | ||
1280 | QString lineStr = line; | ||
1281 | lineStr=lineStr.left(lineStr.length()-1); | ||
1282 | outDlg->OutputEdit->append(lineStr); | ||
1283 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
1284 | } | ||
1285 | } | ||
1286 | pclose(fp); | ||
1287 | |||
1288 | } | ||
1289 | } | ||
1290 | |||
1291 | void AdvancedFm::runCommandStd() { | ||
1292 | QString curFile; | ||
1293 | if (TabWidget->currentPageIndex() == 0) { | ||
1294 | if( Local_View->currentItem()) | ||
1295 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | ||
1296 | } else { | ||
1297 | if(Remote_View->currentItem()) | ||
1298 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); | ||
1299 | } | ||
1300 | |||
1301 | InputDialog *fileDlg; | ||
1302 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | ||
1303 | fileDlg->setInputText(curFile); | ||
1304 | fileDlg->exec(); | ||
1305 | QString command; | ||
1306 | if( fileDlg->result() == 1 ) { | ||
1307 | qApp->processEvents(); | ||
1308 | command = fileDlg->LineEdit1->text() + " &"; | ||
1309 | system(command.latin1()); | ||
1310 | } | ||
1311 | } | ||
1312 | |||
1313 | void AdvancedFm::fileStatus() { | ||
1314 | QString curFile; | ||
1315 | if (TabWidget->currentPageIndex() == 0) { | ||
1316 | curFile = Local_View->currentItem()->text(0); | ||
1317 | } else { | ||
1318 | curFile = Remote_View->currentItem()->text(0); | ||
1319 | } | ||
1320 | QString command = " stat -l "+ curFile +" 2>&1"; | ||
1321 | Output *outDlg; | ||
1322 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
1323 | outDlg->showMaximized(); | ||
1324 | outDlg->show(); | ||
1325 | qApp->processEvents(); | ||
1326 | FILE *fp; | ||
1327 | char line[130]; | ||
1328 | sleep(1); | ||
1329 | fp = popen( (const char *) command, "r"); | ||
1330 | if ( !fp ) { | ||
1331 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
1332 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
1333 | pclose(fp); | ||
1334 | return; | ||
1335 | } else { | ||
1336 | while ( fgets( line, sizeof line, fp)) { | ||
1337 | outDlg->OutputEdit->append(line); | ||
1338 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
1339 | |||
1340 | } | ||
1341 | |||
1342 | } | ||
1343 | pclose(fp); | ||
1344 | } | 564 | } |
1345 | 565 | ||
1346 | void AdvancedFm::mkDir() { | ||
1347 | if (TabWidget->currentPageIndex() == 0) | ||
1348 | localMakDir(); | ||
1349 | else | ||
1350 | remoteMakDir(); | ||
1351 | |||
1352 | } | ||
1353 | 566 | ||
1354 | void AdvancedFm::rn() { | ||
1355 | if (TabWidget->currentPageIndex() == 0) | ||
1356 | localRename(); | ||
1357 | else | ||
1358 | remoteRename(); | ||
1359 | |||
1360 | } | ||
1361 | |||
1362 | void AdvancedFm::del() { | ||
1363 | if (TabWidget->currentPageIndex() == 0) | ||
1364 | localDelete(); | ||
1365 | else | ||
1366 | remoteDelete(); | ||
1367 | } | ||
1368 | 567 | ||
1369 | void AdvancedFm::doAbout() { | 568 | void AdvancedFm::doAbout() { |
1370 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 569 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
1371 | "is copyright 2002 by\n" | 570 | "is copyright 2002 by\n" |
1372 | "L.J.Potter<llornkcor@handhelds.org>\n" | 571 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1373 | "and is licensed by the GPL")); | 572 | "and is licensed by the GPL")); |
1374 | } | 573 | } |
1375 | 574 | ||
1376 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 575 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
1377 | if( TabWidget->hasFocus()) | 576 | if( TabWidget->hasFocus()) |
1378 | switch ( e->key() ) { | 577 | switch ( e->key() ) { |
1379 | case Key_Delete: | 578 | case Key_Delete: |
1380 | del(); | 579 | del(); |
1381 | break; | 580 | break; |
1382 | case Key_H: | 581 | case Key_H: |
1383 | showHidden(); | 582 | showHidden(); |
1384 | break; | 583 | break; |
1385 | case Key_E: | 584 | case Key_E: |
1386 | runThis(); | 585 | runThis(); |
1387 | break; | 586 | break; |
1388 | case Key_C: | 587 | case Key_C: |
1389 | copy(); | 588 | copy(); |
1390 | break; | 589 | break; |
1391 | case Key_A: | 590 | case Key_A: |
1392 | copyAs(); | 591 | copyAs(); |
1393 | break; | 592 | break; |
1394 | case Key_M: | 593 | case Key_M: |
1395 | move(); | 594 | move(); |
1396 | break; | 595 | break; |
1397 | case Key_R: | 596 | case Key_R: |
1398 | rn(); | 597 | rn(); |
1399 | break; | 598 | break; |
1400 | case Key_I: | 599 | case Key_I: |
1401 | fileStatus(); | 600 | fileStatus(); |
1402 | break; | 601 | break; |
1403 | case Key_U: | 602 | case Key_U: |
1404 | upDir(); | 603 | upDir(); |
1405 | break; | 604 | break; |
1406 | case Key_P: | 605 | case Key_P: |
1407 | filePerms(); | 606 | filePerms(); |
1408 | break; | 607 | break; |
1409 | case Key_N: | 608 | case Key_N: |
1410 | mkDir(); | 609 | mkDir(); |
1411 | break; | 610 | break; |
1412 | case Key_1: | 611 | case Key_1: |
1413 | switchToLocalTab(); | 612 | switchToLocalTab(); |
1414 | break; | 613 | break; |
1415 | case Key_2: | 614 | case Key_2: |
1416 | switchToRemoteTab(); | 615 | switchToRemoteTab(); |
1417 | break; | 616 | break; |
1418 | case Key_3: | 617 | case Key_3: |
1419 | CFButtonPushed(); | 618 | CFButtonPushed(); |
1420 | break; | 619 | break; |
1421 | case Key_4: | 620 | case Key_4: |
1422 | SDButtonPushed(); | 621 | SDButtonPushed(); |
1423 | break; | 622 | break; |
1424 | case Key_5: | 623 | case Key_5: |
1425 | homeButtonPushed(); | 624 | homeButtonPushed(); |
1426 | break; | 625 | break; |
1427 | case Key_6: | 626 | case Key_6: |
1428 | docButtonPushed(); | 627 | docButtonPushed(); |
1429 | break; | 628 | break; |
1430 | case Key_7: | 629 | case Key_7: |
1431 | break; | 630 | break; |
1432 | case Key_8: | 631 | case Key_8: |
1433 | break; | 632 | break; |
1434 | case Key_9: | 633 | case Key_9: |
1435 | break; | 634 | break; |
1436 | case Key_0: | 635 | case Key_0: |
1437 | break; | 636 | break; |
1438 | } | 637 | } |
1439 | } | 638 | } |
1440 | 639 | ||
1441 | void AdvancedFm::mkSym() { | ||
1442 | QString cmd; | ||
1443 | QStringList curFileList = getPath(); | ||
1444 | if( curFileList.count() > 0) { | ||
1445 | |||
1446 | if (TabWidget->currentPageIndex() == 0) { | ||
1447 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1448 | |||
1449 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1450 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | ||
1451 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
1452 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
1453 | cmd = "ln -s "+curFile+" "+destName; | ||
1454 | qDebug(cmd); | ||
1455 | system(cmd.latin1() ); | ||
1456 | } | ||
1457 | populateRemoteView(); | ||
1458 | TabWidget->setCurrentPage(1); | ||
1459 | } else { | ||
1460 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1461 | |||
1462 | QString destName = currentDir.canonicalPath()+"/"+(*it); | ||
1463 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | ||
1464 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1465 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
1466 | |||
1467 | cmd = "ln -s "+curFile+" "+destName; | ||
1468 | qDebug(cmd); | ||
1469 | system(cmd.latin1() ); | ||
1470 | } | ||
1471 | populateLocalView(); | ||
1472 | TabWidget->setCurrentPage(0); | ||
1473 | } | ||
1474 | } | ||
1475 | } | ||
1476 | 640 | ||
1477 | void AdvancedFm::QPEButtonPushed() { | 641 | void AdvancedFm::QPEButtonPushed() { |
1478 | QString current = QPEApplication::qpeDir(); | 642 | QString current = QPEApplication::qpeDir(); |
1479 | chdir( current.latin1() ); | 643 | chdir( current.latin1() ); |
1480 | if (TabWidget->currentPageIndex() == 0) { | 644 | if (TabWidget->currentPageIndex() == 0) { |
1481 | currentDir.cd( current, TRUE); | 645 | currentDir.cd( current, TRUE); |
1482 | populateLocalView(); | 646 | populateLocalView(); |
1483 | } else { | 647 | } else { |
1484 | currentRemoteDir.cd( current, TRUE); | 648 | currentRemoteDir.cd( current, TRUE); |
1485 | populateRemoteView(); | 649 | populateRemoteView(); |
1486 | } | 650 | } |
1487 | update(); | 651 | update(); |
1488 | } | 652 | } |
1489 | 653 | ||
1490 | void AdvancedFm::parsetab(const QString &fileName) { | 654 | void AdvancedFm::parsetab(const QString &fileName) { |
1491 | 655 | ||
1492 | fileSystemTypeList.clear(); | 656 | fileSystemTypeList.clear(); |
1493 | fsList.clear(); | 657 | fsList.clear(); |
1494 | struct mntent *me; | 658 | struct mntent *me; |
1495 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 659 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
1496 | if ( mntfp ) { | 660 | if ( mntfp ) { |
1497 | while ( (me = getmntent( mntfp )) != 0 ) { | 661 | while ( (me = getmntent( mntfp )) != 0 ) { |
1498 | QString deviceName = me->mnt_fsname; | 662 | QString deviceName = me->mnt_fsname; |
1499 | QString filesystemType = me->mnt_type; | 663 | QString filesystemType = me->mnt_type; |
1500 | QString mountDir = me->mnt_dir; | 664 | QString mountDir = me->mnt_dir; |
1501 | if(deviceName != "none") { | 665 | if(deviceName != "none") { |
1502 | if( fsList.contains(filesystemType) == 0 | 666 | if( fsList.contains(filesystemType) == 0 |
1503 | & filesystemType.find("proc",0,TRUE) == -1 | 667 | & filesystemType.find("proc",0,TRUE) == -1 |
1504 | & filesystemType.find("cramfs",0,TRUE) == -1 | 668 | & filesystemType.find("cramfs",0,TRUE) == -1 |
1505 | & filesystemType.find("auto",0,TRUE) == -1) | 669 | & filesystemType.find("auto",0,TRUE) == -1) |
1506 | fsList << filesystemType; | 670 | fsList << filesystemType; |
1507 | fileSystemTypeList << mountDir+"::"+filesystemType; | 671 | fileSystemTypeList << mountDir+"::"+filesystemType; |
1508 | } | 672 | } |
1509 | } | 673 | } |
1510 | } | 674 | } |
1511 | endmntent( mntfp ); | 675 | endmntent( mntfp ); |
1512 | } | 676 | } |
1513 | 677 | ||
1514 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 678 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
1515 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 679 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
1516 | QString current = currentText;//.right( currentText.length()-1); | 680 | QString current = currentText;//.right( currentText.length()-1); |
1517 | QString baseFs; | 681 | QString baseFs; |
1518 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 682 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
1519 | QString temp = (*it); | 683 | QString temp = (*it); |
1520 | QString path = temp.left(temp.find("::",0,TRUE) ); | 684 | QString path = temp.left(temp.find("::",0,TRUE) ); |
1521 | path = path.right( path.length()-1); | 685 | path = path.right( path.length()-1); |
1522 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 686 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
1523 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 687 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
1524 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 688 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
1525 | } | 689 | } |
1526 | } | 690 | } |
1527 | return baseFs; | 691 | return baseFs; |
1528 | } | 692 | } |
1529 | 693 | ||
1530 | QString AdvancedFm::getDiskSpace( const QString &path) { | 694 | QString AdvancedFm::getDiskSpace( const QString &path) { |
1531 | struct statfs fss; | 695 | struct statfs fss; |
1532 | if ( !statfs( path.latin1(), &fss ) ) { | 696 | if ( !statfs( path.latin1(), &fss ) ) { |
1533 | int blkSize = fss.f_bsize; | 697 | int blkSize = fss.f_bsize; |
1534 | // int totalBlks = fs.f_blocks; | 698 | // int totalBlks = fs.f_blocks; |
1535 | int availBlks = fss.f_bavail; | 699 | int availBlks = fss.f_bavail; |
1536 | 700 | ||
1537 | long mult = blkSize / 1024; | 701 | long mult = blkSize / 1024; |
1538 | long div = 1024 / blkSize; | 702 | long div = 1024 / blkSize; |
1539 | if ( !mult ) mult = 1; | 703 | if ( !mult ) mult = 1; |
1540 | if ( !div ) div = 1; | 704 | if ( !div ) div = 1; |
1541 | 705 | ||
1542 | return QString::number(availBlks * mult / div); | 706 | return QString::number(availBlks * mult / div); |
1543 | } | 707 | } |
1544 | return ""; | 708 | return ""; |
1545 | } | 709 | } |
1546 | 710 | ||
1547 | void AdvancedFm::doBeam() { | ||
1548 | Ir ir; | ||
1549 | if(!ir.supported()){ | ||
1550 | } else { | ||
1551 | |||
1552 | QStringList curFileList = getPath(); | ||
1553 | if( curFileList.count() > 0) { | ||
1554 | |||
1555 | if (TabWidget->currentPageIndex() == 0) { | ||
1556 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1557 | |||
1558 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
1559 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
1560 | Ir *file = new Ir(this, "IR"); | ||
1561 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | ||
1562 | file->send( curFile, curFile ); | ||
1563 | } | ||
1564 | |||
1565 | } else { | ||
1566 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1567 | |||
1568 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
1569 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
1570 | Ir *file = new Ir(this, "IR"); | ||
1571 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | ||
1572 | file->send( curFile, curFile ); | ||
1573 | |||
1574 | } | ||
1575 | } | ||
1576 | } | ||
1577 | } | ||
1578 | |||
1579 | } | ||
1580 | |||
1581 | void AdvancedFm::fileBeamFinished( Ir *) { | ||
1582 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | ||
1583 | |||
1584 | } | ||
1585 | 711 | ||
1586 | void AdvancedFm::showFileMenu() { | 712 | void AdvancedFm::showFileMenu() { |
1587 | 713 | ||
1588 | QString curApp; | 714 | QString curApp; |
1589 | bool isLocalView = false; | 715 | bool isLocalView = false; |
1590 | if (TabWidget->currentPageIndex() == 0) { | 716 | if (TabWidget->currentPageIndex() == 0) { |
1591 | isLocalView = TRUE; | 717 | isLocalView = TRUE; |
1592 | curApp = Local_View->currentItem()->text(0); | 718 | curApp = Local_View->currentItem()->text(0); |
1593 | } else { | 719 | } else { |
1594 | curApp = Remote_View->currentItem()->text(0); | 720 | curApp = Remote_View->currentItem()->text(0); |
1595 | } | 721 | } |
1596 | 722 | ||
1597 | MimeType mt( curApp ); | 723 | MimeType mt( curApp ); |
1598 | const AppLnk* app = mt.application(); | 724 | const AppLnk* app = mt.application(); |
1599 | QFile fi(curApp); | 725 | QFile fi(curApp); |
1600 | 726 | ||
1601 | QPopupMenu *m = new QPopupMenu(0); | 727 | QPopupMenu *m = new QPopupMenu(0); |
1602 | 728 | ||
1603 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 729 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
730 | if ( !QFileInfo(fi).isDir() ) { | ||
1604 | m->insertSeparator(); | 731 | m->insertSeparator(); |
1605 | if ( QFileInfo(fi).isDir() ) { | 732 | // m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
1606 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 733 | // } else { |
1607 | } else { | ||
1608 | 734 | ||
1609 | if ( app ) | 735 | if ( app ) |
1610 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); | 736 | m->insertItem( app->pixmap(), tr( "Open in " |
737 | + app->name() ), this, SLOT( runThis() ) ); | ||
1611 | else if( QFileInfo(fi).isExecutable() ) | 738 | else if( QFileInfo(fi).isExecutable() ) |
1612 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 739 | m->insertItem( Resource::loadPixmap( app->name()), tr( "Execute" ), this, SLOT( runThis() ) ); |
1613 | 740 | ||
1614 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 741 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
1615 | } | 742 | } |
1616 | m->insertSeparator(); | 743 | m->insertSeparator(); |
1617 | 744 | ||
1618 | 745 | ||
1619 | if(isLocalView) | 746 | if(isLocalView) |
1620 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 747 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
1621 | else | 748 | else |
1622 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 749 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
1623 | 750 | ||
1624 | m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 751 | m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
1625 | m->insertSeparator(); | 752 | m->insertSeparator(); |
1626 | 753 | ||
1627 | if(isLocalView) | 754 | if(isLocalView) |
1628 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 755 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
1629 | else | 756 | else |
1630 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 757 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
1631 | 758 | ||
1632 | m->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 759 | m->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
1633 | m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 760 | m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
1634 | m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 761 | m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
1635 | m->insertItem( tr( "Move" ), this, SLOT( move() )); | 762 | m->insertItem( tr( "Move" ), this, SLOT( move() )); |
1636 | m->insertSeparator(); | 763 | m->insertSeparator(); |
1637 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 764 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
1638 | 765 | ||
1639 | // if(isLocalView) | 766 | // if(isLocalView) |
1640 | // m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); | 767 | // m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); |
1641 | // else | 768 | // else |
1642 | // m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); | 769 | // m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); |
1643 | 770 | ||
1644 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 771 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
1645 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 772 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
1646 | m->insertSeparator(); | 773 | m->insertSeparator(); |
1647 | 774 | ||
1648 | if(isLocalView) | 775 | if(isLocalView) |
1649 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 776 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
1650 | else | 777 | else |
1651 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 778 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
1652 | 779 | ||
1653 | m->insertSeparator(); | 780 | m->insertSeparator(); |
1654 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 781 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
1655 | 782 | ||
1656 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings | 783 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
1657 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | ||
1658 | m->setCheckable(TRUE); | 784 | m->setCheckable(TRUE); |
1659 | if (!b) | 785 | if (!b) |
1660 | m->setItemChecked(m->idAt(0),TRUE); | 786 | m->setItemChecked(m->idAt(0),TRUE); |
1661 | else | 787 | else |
1662 | m->setItemChecked(m->idAt(0),FALSE); | 788 | m->setItemChecked(m->idAt(0),FALSE); |
1663 | 789 | ||
1664 | if(Ir::supported()) | 790 | if(Ir::supported()) |
1665 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 791 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
1666 | m->setFocus(); | 792 | m->setFocus(); |
1667 | m->exec( QCursor::pos() ); | 793 | m->exec( QCursor::pos() ); |
1668 | sleep(1); | 794 | sleep(1); |
1669 | if(m) delete m; | 795 | if(m) delete m; |
1670 | } | 796 | } |
1671 | 797 | ||
1672 | 798 | ||
1673 | void AdvancedFm::cancelMenuTimer() { | 799 | void AdvancedFm::cancelMenuTimer() { |
1674 | 800 | ||
1675 | qDebug("selectionChanged: cancel menu timer"); | 801 | // qDebug("selectionChanged: cancel menu timer"); |
1676 | if( menuTimer.isActive() ) | 802 | if( menuTimer.isActive() ) |
1677 | menuTimer.stop(); | 803 | menuTimer.stop(); |
1678 | } | 804 | } |
1679 | 805 | ||
1680 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 806 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
1681 | struct statfs fss; | 807 | struct statfs fss; |
1682 | if ( !statfs( path.latin1(), &fss ) ) { | 808 | if ( !statfs( path.latin1(), &fss ) ) { |
1683 | int blkSize = fss.f_bsize; | 809 | int blkSize = fss.f_bsize; |
1684 | // int totalBlks = fs.f_blocks; | 810 | // int totalBlks = fs.f_blocks; |
1685 | int availBlks = fss.f_bavail; | 811 | int availBlks = fss.f_bavail; |
1686 | 812 | ||
1687 | long mult = blkSize / 1024; | 813 | long mult = blkSize / 1024; |
1688 | long div = 1024 / blkSize; | 814 | long div = 1024 / blkSize; |
1689 | if ( !mult ) mult = 1; | 815 | if ( !mult ) mult = 1; |
1690 | if ( !div ) div = 1; | 816 | if ( !div ) div = 1; |
1691 | 817 | ||
1692 | 818 | ||
1693 | return QString::number(availBlks * mult / div); | 819 | return QString::number(availBlks * mult / div); |
1694 | } | 820 | } |
1695 | return ""; | 821 | return ""; |
1696 | } | 822 | } |
1697 | 823 | ||
1698 | void AdvancedFm::addToDocs() { | 824 | void AdvancedFm::addToDocs() { |
1699 | QStringList strListPaths = getPath(); | 825 | QStringList strListPaths = getPath(); |
1700 | if( strListPaths.count() > 0) { | 826 | if( strListPaths.count() > 0) { |
1701 | QString curFile; | 827 | QString curFile; |
1702 | if (TabWidget->currentPageIndex() == 0) { | 828 | if (TabWidget->currentPageIndex() == 0) { |
1703 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 829 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
1704 | curFile = currentDir.canonicalPath()+"/"+(*it); | 830 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1705 | qDebug(curFile); | 831 | qDebug(curFile); |
1706 | DocLnk f; | 832 | DocLnk f; |
1707 | // curFile.replace(QRegExp("\\..*"),""); | 833 | // curFile.replace(QRegExp("\\..*"),""); |
1708 | f.setName((*it)); | 834 | f.setName((*it)); |
1709 | f.setFile( curFile); | 835 | f.setFile( curFile); |
1710 | f.writeLink(); | 836 | f.writeLink(); |
1711 | } | 837 | } |
1712 | } else { | 838 | } else { |
1713 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 839 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
1714 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 840 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1715 | qDebug(curFile); | 841 | qDebug(curFile); |
1716 | 842 | ||
1717 | DocLnk f; | 843 | DocLnk f; |
1718 | // curFile.replace(QRegExp("\\..*"),""); | 844 | // curFile.replace(QRegExp("\\..*"),""); |
1719 | f.setName((*it)); | 845 | f.setName((*it)); |
1720 | f.setFile( curFile); | 846 | f.setFile( curFile); |
1721 | f.writeLink(); | 847 | f.writeLink(); |
1722 | } | 848 | } |
1723 | } | 849 | } |
1724 | } | 850 | } |
1725 | } | 851 | } |
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index b2705b8..12ad474 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -1,143 +1,145 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfm.h | 2 | advancedfm.h |
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 | #ifndef ADVANCEDFM_H | 12 | #ifndef ADVANCEDFM_H |
13 | #define ADVANCEDFM_H | 13 | #define ADVANCEDFM_H |
14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | ||
14 | 15 | ||
15 | #include <qpe/ir.h> | 16 | #include <qpe/ir.h> |
16 | 17 | ||
17 | #include <qvariant.h> | 18 | #include <qvariant.h> |
18 | #include <qdialog.h> | 19 | #include <qdialog.h> |
19 | #include <qmainwindow.h> | 20 | #include <qmainwindow.h> |
20 | #include <qstringlist.h> | 21 | #include <qstringlist.h> |
21 | #include <qdir.h> | 22 | #include <qdir.h> |
22 | #include <qstring.h> | 23 | #include <qstring.h> |
23 | #include <qpoint.h> | 24 | #include <qpoint.h> |
24 | #include <qtimer.h> | 25 | #include <qtimer.h> |
25 | 26 | ||
26 | class QVBoxLayout; | 27 | class QVBoxLayout; |
27 | class QHBoxLayout; | 28 | class QHBoxLayout; |
28 | class QGridLayout; | 29 | class QGridLayout; |
29 | class QComboBox; | 30 | class QComboBox; |
30 | class QListView; | 31 | class QListView; |
31 | class QListviewItem; | 32 | class QListviewItem; |
32 | class QLabel; | 33 | class QLabel; |
33 | class QProgressBar; | 34 | class QProgressBar; |
34 | class QSpinBox; | 35 | class QSpinBox; |
35 | class QTabWidget; | 36 | class QTabWidget; |
36 | class QWidget; | 37 | class QWidget; |
37 | class QPEToolBar; | 38 | class QPEToolBar; |
38 | class QPEMenuBar; | 39 | class QPEMenuBar; |
39 | class QPopupMenu; | 40 | class QPopupMenu; |
40 | class QFile; | 41 | class QFile; |
41 | class QListViewItem; | 42 | class QListViewItem; |
42 | class QLineEdit; | 43 | class QLineEdit; |
43 | //class QPushButton; | 44 | //class QPushButton; |
44 | class QToolButton; | 45 | class QToolButton; |
45 | class Ir; | 46 | class Ir; |
46 | 47 | ||
47 | class AdvancedFm : public QMainWindow | 48 | class AdvancedFm : public QMainWindow |
48 | { | 49 | { |
49 | Q_OBJECT | 50 | Q_OBJECT |
50 | public: | 51 | public: |
51 | AdvancedFm(); | 52 | AdvancedFm(); |
52 | ~AdvancedFm(); | 53 | ~AdvancedFm(); |
53 | 54 | ||
54 | QTabWidget *TabWidget; | 55 | QTabWidget *TabWidget; |
55 | QWidget *tab, *tab_2, *tab_3; | 56 | QWidget *tab, *tab_2, *tab_3; |
56 | QListView *Local_View, *Remote_View; | 57 | QListView *Local_View, *Remote_View; |
57 | 58 | ||
58 | QLineEdit *currentPathEdit; | 59 | QLineEdit *currentPathEdit; |
59 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; | 60 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; |
60 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 61 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
61 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 62 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
62 | QDir currentDir, currentRemoteDir; | 63 | QDir currentDir, currentRemoteDir; |
63 | QComboBox *currentPathCombo; | 64 | QComboBox *currentPathCombo; |
64 | QString filterStr; | 65 | QString filterStr; |
65 | QListViewItem * item; | 66 | QListViewItem * item; |
66 | bool b; | 67 | bool b; |
67 | QStringList fileSystemTypeList, fsList; | 68 | QStringList fileSystemTypeList, fsList; |
68 | int currentServerConfig; | 69 | int currentServerConfig; |
69 | protected slots: | 70 | protected slots: |
70 | void addToDocs(); | 71 | void addToDocs(); |
71 | void doLocalCd(); | 72 | void doLocalCd(); |
72 | void doRemoteCd(); | 73 | void doRemoteCd(); |
73 | // void copy(); | 74 | // void copy(); |
74 | void mkDir(); | 75 | void mkDir(); |
75 | void del(); | 76 | void del(); |
76 | void rn(); | 77 | void rn(); |
77 | void populateLocalView(); | 78 | void populateLocalView(); |
78 | void populateRemoteView(); | 79 | void populateRemoteView(); |
79 | void showHidden(); | 80 | void showHidden(); |
81 | void showMenuHidden(); | ||
80 | void showRemoteHidden(); | 82 | void showRemoteHidden(); |
81 | void writeConfig(); | 83 | void writeConfig(); |
82 | void readConfig(); | 84 | void readConfig(); |
83 | void localListClicked(QListViewItem *); | 85 | void localListClicked(QListViewItem *); |
84 | void remoteListClicked(QListViewItem *); | 86 | void remoteListClicked(QListViewItem *); |
85 | void localListPressed( int, QListViewItem *, const QPoint&, int); | 87 | void localListPressed( int, QListViewItem *, const QPoint&, int); |
86 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); | 88 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); |
87 | void localMakDir(); | 89 | void localMakDir(); |
88 | void localDelete(); | 90 | void localDelete(); |
89 | void remoteMakDir(); | 91 | void remoteMakDir(); |
90 | void remoteDelete(); | 92 | void remoteDelete(); |
91 | /* bool remoteDirList(const QString &); */ | 93 | /* bool remoteDirList(const QString &); */ |
92 | /* bool remoteChDir(const QString &); */ | 94 | /* bool remoteChDir(const QString &); */ |
93 | void tabChanged(QWidget*); | 95 | void tabChanged(QWidget*); |
94 | void cleanUp(); | 96 | void cleanUp(); |
95 | void remoteRename(); | 97 | void remoteRename(); |
96 | void localRename(); | 98 | void localRename(); |
97 | void runThis(); | 99 | void runThis(); |
98 | void runText(); | 100 | void runText(); |
99 | void filePerms(); | 101 | void filePerms(); |
100 | void doProperties(); | 102 | void doProperties(); |
101 | void runCommand(); | 103 | void runCommand(); |
102 | void runCommandStd(); | 104 | void runCommandStd(); |
103 | QStringList getPath(); | 105 | QStringList getPath(); |
104 | void mkSym(); | 106 | void mkSym(); |
105 | void switchToLocalTab(); | 107 | void switchToLocalTab(); |
106 | void switchToRemoteTab(); | 108 | void switchToRemoteTab(); |
107 | 109 | ||
108 | protected: | 110 | protected: |
109 | bool zaurusDevice; | 111 | bool zaurusDevice; |
110 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; | 112 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; |
111 | QStringList remoteDirPathStringList, localDirPathStringList; | 113 | QStringList remoteDirPathStringList, localDirPathStringList; |
112 | 114 | ||
113 | void init(); | 115 | void init(); |
114 | void initConnections(); | 116 | void initConnections(); |
115 | void keyReleaseEvent( QKeyEvent *); | 117 | void keyReleaseEvent( QKeyEvent *); |
116 | QString getFileSystemType(const QString &); | 118 | QString getFileSystemType(const QString &); |
117 | QString getDiskSpace(const QString &); | 119 | QString getDiskSpace(const QString &); |
118 | void parsetab(const QString &fileName); | 120 | void parsetab(const QString &fileName); |
119 | QString checkDiskSpace(const QString &); | 121 | QString checkDiskSpace(const QString &); |
120 | 122 | ||
121 | protected slots: | 123 | protected slots: |
122 | void showFileMenu(); | 124 | void showFileMenu(); |
123 | void cancelMenuTimer(); | 125 | void cancelMenuTimer(); |
124 | void homeButtonPushed(); | 126 | void homeButtonPushed(); |
125 | void docButtonPushed(); | 127 | void docButtonPushed(); |
126 | void SDButtonPushed(); | 128 | void SDButtonPushed(); |
127 | void CFButtonPushed(); | 129 | void CFButtonPushed(); |
128 | void QPEButtonPushed(); | 130 | void QPEButtonPushed(); |
129 | void upDir(); | 131 | void upDir(); |
130 | void currentPathComboChanged(); | 132 | void currentPathComboChanged(); |
131 | void copy(); | 133 | void copy(); |
132 | void copyAs(); | 134 | void copyAs(); |
133 | void copySameDir(); | 135 | void copySameDir(); |
134 | void currentPathComboActivated(const QString &); | 136 | void currentPathComboActivated(const QString &); |
135 | void fillCombo(const QString &); | 137 | void fillCombo(const QString &); |
136 | bool copyFile( const QString & , const QString & ); | 138 | bool copyFile( const QString & , const QString & ); |
137 | void move(); | 139 | void move(); |
138 | void fileStatus(); | 140 | void fileStatus(); |
139 | void doAbout(); | 141 | void doAbout(); |
140 | void doBeam(); | 142 | void doBeam(); |
141 | void fileBeamFinished( Ir *); | 143 | void fileBeamFinished( Ir *); |
142 | 144 | ||
143 | private: | 145 | private: |
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro index 9629f0e..eb4f122 100644 --- a/noncore/apps/advancedfm/advancedfm.pro +++ b/noncore/apps/advancedfm/advancedfm.pro | |||
@@ -1,25 +1,25 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h | 3 | HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h |
4 | SOURCES = advancedfm.cpp advancedfmData.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp | 4 | SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp |
5 | TARGET = advancedfm | 5 | TARGET = advancedfm |
6 | REQUIRES=medium-config | 6 | REQUIRES=medium-config |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | DESTDIR = $(OPIEDIR)/bin | 9 | DESTDIR = $(OPIEDIR)/bin |
10 | LIBS += -lqpe | 10 | LIBS += -lqpe |
11 | 11 | ||
12 | TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ | 12 | TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ |
13 | ../../../i18n/en/advancedfm.ts \ | 13 | ../../../i18n/en/advancedfm.ts \ |
14 | ../../../i18n/es/advancedfm.ts \ | 14 | ../../../i18n/es/advancedfm.ts \ |
15 | ../../../i18n/fr/advancedfm.ts \ | 15 | ../../../i18n/fr/advancedfm.ts \ |
16 | ../../../i18n/hu/advancedfm.ts \ | 16 | ../../../i18n/hu/advancedfm.ts \ |
17 | ../../../i18n/ja/advancedfm.ts \ | 17 | ../../../i18n/ja/advancedfm.ts \ |
18 | ../../../i18n/ko/advancedfm.ts \ | 18 | ../../../i18n/ko/advancedfm.ts \ |
19 | ../../../i18n/no/advancedfm.ts \ | 19 | ../../../i18n/no/advancedfm.ts \ |
20 | ../../../i18n/pl/advancedfm.ts \ | 20 | ../../../i18n/pl/advancedfm.ts \ |
21 | ../../../i18n/pt/advancedfm.ts \ | 21 | ../../../i18n/pt/advancedfm.ts \ |
22 | ../../../i18n/pt_BR/advancedfm.ts \ | 22 | ../../../i18n/pt_BR/advancedfm.ts \ |
23 | ../../../i18n/sl/advancedfm.ts \ | 23 | ../../../i18n/sl/advancedfm.ts \ |
24 | ../../../i18n/zh_CN/advancedfm.ts \ | 24 | ../../../i18n/zh_CN/advancedfm.ts \ |
25 | ../../../i18n/zh_TW/advancedfm.ts | 25 | ../../../i18n/zh_TW/advancedfm.ts |
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index a4f4d59..4c24e83 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -16,221 +16,220 @@ | |||
16 | #include <qpe/qpetoolbar.h> | 16 | #include <qpe/qpetoolbar.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | 18 | ||
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qpixmap.h> | 20 | #include <qpixmap.h> |
21 | #include <qcombobox.h> | 21 | #include <qcombobox.h> |
22 | #include <qpopupmenu.h> | 22 | #include <qpopupmenu.h> |
23 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | #include <qtabwidget.h> | 25 | #include <qtabwidget.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | 28 | ||
29 | #include <sys/utsname.h> | 29 | #include <sys/utsname.h> |
30 | 30 | ||
31 | 31 | ||
32 | void AdvancedFm::init() { | 32 | void AdvancedFm::init() { |
33 | 33 | ||
34 | setCaption( tr( "AdvancedFm" ) ); | 34 | setCaption( tr( "AdvancedFm" ) ); |
35 | 35 | ||
36 | QGridLayout *layout = new QGridLayout( this ); | 36 | QGridLayout *layout = new QGridLayout( this ); |
37 | layout->setSpacing( 2); | 37 | layout->setSpacing( 2); |
38 | layout->setMargin( 2); | 38 | layout->setMargin( 2); |
39 | 39 | ||
40 | 40 | ||
41 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 41 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
42 | fileMenu = new QPopupMenu( this ); | 42 | fileMenu = new QPopupMenu( this ); |
43 | viewMenu = new QPopupMenu( this ); | 43 | viewMenu = new QPopupMenu( this ); |
44 | 44 | ||
45 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); | 45 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); |
46 | 46 | ||
47 | menuBar->insertItem( tr( "File" ), fileMenu); | 47 | menuBar->insertItem( tr( "File" ), fileMenu); |
48 | menuBar->insertItem( tr( "View" ), viewMenu); | 48 | menuBar->insertItem( tr( "View" ), viewMenu); |
49 | 49 | ||
50 | qpeDirButton= new QToolButton(this,"QPEButton"); | 50 | qpeDirButton= new QToolButton(this,"QPEButton"); |
51 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); | 51 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); |
52 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); | 52 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); |
53 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); | 53 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); |
54 | 54 | ||
55 | cfButton = new QToolButton( this,"CFButton"); | 55 | cfButton = new QToolButton( this,"CFButton"); |
56 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); | 56 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); |
57 | cfButton ->setFixedSize( QSize( 20, 20 ) ); | 57 | cfButton ->setFixedSize( QSize( 20, 20 ) ); |
58 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); | 58 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); |
59 | 59 | ||
60 | sdButton = new QToolButton( this,"SDButton"); | 60 | sdButton = new QToolButton( this,"SDButton"); |
61 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); | 61 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); |
62 | sdButton->setFixedSize( QSize( 20, 20 ) ); | 62 | sdButton->setFixedSize( QSize( 20, 20 ) ); |
63 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); | 63 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); |
64 | 64 | ||
65 | cdUpButton = new QToolButton( this,"cdUpButton"); | 65 | cdUpButton = new QToolButton( this,"cdUpButton"); |
66 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 66 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
67 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 67 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
68 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); | 68 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); |
69 | 69 | ||
70 | docButton = new QToolButton( this,"docsButton"); | 70 | docButton = new QToolButton( this,"docsButton"); |
71 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); | 71 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); |
72 | docButton->setFixedSize( QSize( 20, 20 ) ); | 72 | docButton->setFixedSize( QSize( 20, 20 ) ); |
73 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); | 73 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); |
74 | 74 | ||
75 | homeButton = new QToolButton( this,"homeButton"); | 75 | homeButton = new QToolButton( this,"homeButton"); |
76 | homeButton->setPixmap(Resource::loadPixmap("home")); | 76 | homeButton->setPixmap(Resource::loadPixmap("home")); |
77 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 77 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
78 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); | 78 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); |
79 | 79 | ||
80 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 80 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); |
81 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 81 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
82 | fileMenu->insertSeparator(); | 82 | fileMenu->insertSeparator(); |
83 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 83 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
84 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 84 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
85 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 85 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
86 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 86 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
87 | fileMenu->insertSeparator(); | 87 | fileMenu->insertSeparator(); |
88 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 88 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
89 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 89 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
90 | fileMenu->setCheckable(TRUE); | 90 | fileMenu->setCheckable(TRUE); |
91 | 91 | ||
92 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 92 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
93 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 93 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
94 | viewMenu->insertSeparator(); | 94 | viewMenu->insertSeparator(); |
95 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 95 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
96 | viewMenu->setCheckable(TRUE); | 96 | viewMenu->setCheckable(TRUE); |
97 | 97 | ||
98 | 98 | ||
99 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 99 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
100 | currentPathCombo->setEditable(TRUE); | 100 | currentPathCombo->setEditable(TRUE); |
101 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); | 101 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); |
102 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 102 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
103 | 103 | ||
104 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 104 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
105 | 105 | ||
106 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); | 106 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); |
107 | 107 | ||
108 | 108 | ||
109 | TabWidget = new QTabWidget( this, "TabWidget" ); | 109 | TabWidget = new QTabWidget( this, "TabWidget" ); |
110 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); | 110 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); |
111 | 111 | ||
112 | tab = new QWidget( TabWidget, "tab" ); | 112 | tab = new QWidget( TabWidget, "tab" ); |
113 | tabLayout = new QGridLayout( tab ); | 113 | tabLayout = new QGridLayout( tab ); |
114 | tabLayout->setSpacing( 2); | 114 | tabLayout->setSpacing( 2); |
115 | tabLayout->setMargin( 2); | 115 | tabLayout->setMargin( 2); |
116 | 116 | ||
117 | Local_View = new QListView( tab, "Local_View" ); | 117 | Local_View = new QListView( tab, "Local_View" ); |
118 | Local_View->addColumn( tr("File"),130); | 118 | Local_View->addColumn( tr("File"),130); |
119 | Local_View->addColumn( tr("Size"),-1); | 119 | Local_View->addColumn( tr("Size"),-1); |
120 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 120 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
121 | Local_View->addColumn( tr("Date"),-1); | 121 | Local_View->addColumn( tr("Date"),-1); |
122 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 122 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
123 | Local_View->setAllColumnsShowFocus(TRUE); | 123 | Local_View->setAllColumnsShowFocus(TRUE); |
124 | Local_View->setMultiSelection( TRUE ); | 124 | Local_View->setMultiSelection( TRUE ); |
125 | Local_View->setSelectionMode(QListView::Extended); | 125 | Local_View->setSelectionMode(QListView::Extended); |
126 | 126 | ||
127 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 127 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
128 | 128 | ||
129 | tabLayout->addWidget( Local_View, 0, 0 ); | 129 | tabLayout->addWidget( Local_View, 0, 0 ); |
130 | 130 | ||
131 | TabWidget->insertTab( tab, tr("1")); | 131 | TabWidget->insertTab( tab, tr("1")); |
132 | 132 | ||
133 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 133 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
134 | tabLayout_2 = new QGridLayout( tab_2 ); | 134 | tabLayout_2 = new QGridLayout( tab_2 ); |
135 | tabLayout_2->setSpacing( 2); | 135 | tabLayout_2->setSpacing( 2); |
136 | tabLayout_2->setMargin( 2); | 136 | tabLayout_2->setMargin( 2); |
137 | 137 | ||
138 | Remote_View = new QListView( tab_2, "Remote_View" ); | 138 | Remote_View = new QListView( tab_2, "Remote_View" ); |
139 | Remote_View->addColumn( tr("File"),130); | 139 | Remote_View->addColumn( tr("File"),130); |
140 | Remote_View->addColumn( tr("Size"),-1); | 140 | Remote_View->addColumn( tr("Size"),-1); |
141 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 141 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
142 | Remote_View->addColumn( tr("Date"),-1); | 142 | Remote_View->addColumn( tr("Date"),-1); |
143 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 143 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
144 | Remote_View->setAllColumnsShowFocus(TRUE); | 144 | Remote_View->setAllColumnsShowFocus(TRUE); |
145 | Remote_View->setMultiSelection( TRUE ); | 145 | Remote_View->setMultiSelection( TRUE ); |
146 | Remote_View->setSelectionMode(QListView::Extended); | 146 | Remote_View->setSelectionMode(QListView::Extended); |
147 | 147 | ||
148 | 148 | ||
149 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 149 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
150 | 150 | ||
151 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 151 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
152 | 152 | ||
153 | 153 | ||
154 | TabWidget->insertTab( tab_2, tr( "2")); | 154 | TabWidget->insertTab( tab_2, tr( "2")); |
155 | 155 | ||
156 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 156 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
157 | tabLayout_3 = new QGridLayout( tab_3 ); | 157 | tabLayout_3 = new QGridLayout( tab_3 ); |
158 | tabLayout_3->setSpacing( 2); | 158 | tabLayout_3->setSpacing( 2); |
159 | tabLayout_3->setMargin( 2); | 159 | tabLayout_3->setMargin( 2); |
160 | 160 | ||
161 | 161 | ||
162 | // OFileDialog fileDialog; | 162 | // OFileDialog fileDialog; |
163 | // fileDialog; | 163 | // fileDialog; |
164 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 164 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
165 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 165 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
166 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 166 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
167 | 167 | ||
168 | QListView *fileTree; | 168 | QListView *fileTree; |
169 | fileTree = new QListView( tab_3, "tree" ); | 169 | fileTree = new QListView( tab_3, "tree" ); |
170 | 170 | ||
171 | 171 | ||
172 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 172 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
173 | 173 | ||
174 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 174 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
175 | */ | 175 | */ |
176 | 176 | ||
177 | /////////////// | 177 | /////////////// |
178 | 178 | ||
179 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 179 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
180 | if (uname(&name) != -1) { | 180 | if (uname(&name) != -1) { |
181 | QString release=name.release; | 181 | QString release=name.release; |
182 | if(release.find("embedix",0,TRUE) !=-1) { | 182 | if(release.find("embedix",0,TRUE) !=-1) { |
183 | zaurusDevice=TRUE; | 183 | zaurusDevice=TRUE; |
184 | } else { | 184 | } else { |
185 | zaurusDevice=FALSE; | 185 | zaurusDevice=FALSE; |
186 | sdButton->hide(); | 186 | sdButton->hide(); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 190 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
191 | currentDir.setPath( QDir::currentDirPath()); | 191 | currentDir.setPath( QDir::currentDirPath()); |
192 | 192 | ||
193 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 193 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
194 | currentRemoteDir.setPath( QDir::currentDirPath()); | 194 | currentRemoteDir.setPath( QDir::currentDirPath()); |
195 | 195 | ||
196 | b = TRUE; | 196 | b = TRUE; |
197 | 197 | ||
198 | filterStr="*"; | 198 | filterStr="*"; |
199 | b=FALSE; | 199 | b=FALSE; |
200 | 200 | ||
201 | 201 | ||
202 | |||
203 | } | 202 | } |
204 | 203 | ||
205 | void AdvancedFm::initConnections() { | 204 | void AdvancedFm::initConnections() { |
206 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 205 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
207 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); | 206 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); |
208 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); | 207 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); |
209 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); | 208 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); |
210 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 209 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
211 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 210 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
212 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 211 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
213 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 212 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
214 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 213 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
215 | 214 | ||
216 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 215 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
217 | this,SLOT(currentPathComboChanged())); | 216 | this,SLOT(currentPathComboChanged())); |
218 | 217 | ||
219 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 218 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
220 | this,SLOT( localListClicked(QListViewItem *)) ); | 219 | this,SLOT( localListClicked(QListViewItem *)) ); |
221 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 220 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
222 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); | 221 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); |
223 | 222 | ||
224 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 223 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
225 | 224 | ||
226 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 225 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
227 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 226 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
228 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 227 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
229 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 228 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
230 | 229 | ||
231 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 230 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
232 | this,SLOT(tabChanged(QWidget*))); | 231 | this,SLOT(tabChanged(QWidget*))); |
233 | 232 | ||
234 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 233 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
235 | 234 | ||
236 | } | 235 | } |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp new file mode 100644 index 0000000..7ee5065 --- a/dev/null +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -0,0 +1,940 @@ | |||
1 | /*************************************************************************** | ||
2 | AdvancedFm.cpp | ||
3 | ------------------- | ||
4 | ** Created: Sat Mar 9 23:33:09 2002 | ||
5 | copyright : (C) 2002 by ljp | ||
6 | email : ljp@llornkcor.com | ||
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 * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | ***************************************************************************/ | ||
12 | #include "advancedfm.h" | ||
13 | #include "inputDialog.h" | ||
14 | #include "output.h" | ||
15 | #include "filePermissions.h" | ||
16 | |||
17 | #include <qpe/lnkproperties.h> | ||
18 | #include <qpe/qpeapplication.h> | ||
19 | #include <qpe/qpemenubar.h> | ||
20 | #include <qpe/qpetoolbar.h> | ||
21 | #include <qpe/resource.h> | ||
22 | #include <qpe/qcopenvelope_qws.h> | ||
23 | #include <qpe/applnk.h> | ||
24 | #include <qpe/ir.h> | ||
25 | |||
26 | #include <qmessagebox.h> | ||
27 | #include <qmultilineedit.h> | ||
28 | |||
29 | #include <qstring.h> | ||
30 | |||
31 | #include <qlayout.h> | ||
32 | #include <qpixmap.h> | ||
33 | #include <qcombobox.h> | ||
34 | #include <qpopupmenu.h> | ||
35 | #include <qtabwidget.h> | ||
36 | #include <qtoolbutton.h> | ||
37 | #include <qtabwidget.h> | ||
38 | #include <qlineedit.h> | ||
39 | #include <qlistview.h> | ||
40 | |||
41 | #include <stdlib.h> | ||
42 | #include <unistd.h> | ||
43 | #include <sys/stat.h> | ||
44 | #include <dirent.h> | ||
45 | |||
46 | |||
47 | void AdvancedFm::doLocalCd() { | ||
48 | localListClicked( Local_View->currentItem()); | ||
49 | } | ||
50 | |||
51 | void AdvancedFm::doRemoteCd() { | ||
52 | localListClicked( Remote_View->currentItem()); | ||
53 | } | ||
54 | |||
55 | void AdvancedFm::showMenuHidden() { | ||
56 | showHidden(); | ||
57 | if(b) b= false; else b=true; | ||
58 | showRemoteHidden(); | ||
59 | } | ||
60 | |||
61 | void AdvancedFm::showHidden() { | ||
62 | if (b) { | ||
63 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | ||
64 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | ||
65 | b=FALSE; | ||
66 | |||
67 | } else { | ||
68 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | ||
70 | b=TRUE; | ||
71 | } | ||
72 | populateLocalView(); | ||
73 | |||
74 | } | ||
75 | |||
76 | void AdvancedFm::showRemoteHidden() { | ||
77 | if (b) { | ||
78 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | ||
79 | b=TRUE; | ||
80 | |||
81 | } else { | ||
82 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
83 | b=FALSE; | ||
84 | } | ||
85 | populateRemoteView(); | ||
86 | } | ||
87 | |||
88 | void AdvancedFm::runThis() { | ||
89 | QString fs; | ||
90 | if (TabWidget->currentPageIndex() == 0) { | ||
91 | QString curFile = Local_View->currentItem()->text(0); | ||
92 | if(curFile != "../") { | ||
93 | |||
94 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | ||
95 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | ||
96 | qDebug( fileInfo.owner()); | ||
97 | if( (fileInfo.permission( QFileInfo::ExeUser) | ||
98 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
99 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | ||
100 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
101 | QCopEnvelope e("QPE/System", "execute(QString)" ); | ||
102 | e << curFile; | ||
103 | } else { | ||
104 | curFile = currentDir.canonicalPath()+"/"+curFile; | ||
105 | DocLnk nf(curFile); | ||
106 | QString execStr = nf.exec(); | ||
107 | qDebug( execStr); | ||
108 | if( execStr.isEmpty() ) { | ||
109 | } else { | ||
110 | nf.execute(); | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } else { | ||
115 | QString curFile = Remote_View->currentItem()->text(0); | ||
116 | if(curFile != "../") { | ||
117 | |||
118 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | ||
119 | qDebug("Filesystemtype is "+fs); | ||
120 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | ||
121 | if( (fileInfo.permission( QFileInfo::ExeUser) | ||
122 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
123 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | ||
124 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
125 | QCopEnvelope e("QPE/System", "execute(QString)" ); | ||
126 | e << curFile; | ||
127 | } else { | ||
128 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | ||
129 | DocLnk nf(curFile); | ||
130 | QString execStr = nf.exec(); | ||
131 | qDebug(execStr); | ||
132 | if( execStr.isEmpty() ) { | ||
133 | } else { | ||
134 | nf.execute(); | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | |||
141 | void AdvancedFm::runText() { | ||
142 | if (TabWidget->currentPageIndex() == 0) { | ||
143 | QString curFile = Local_View->currentItem()->text(0); | ||
144 | if(curFile != "../") { | ||
145 | curFile = currentDir.canonicalPath()+"/"+curFile; | ||
146 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | ||
147 | e << curFile; | ||
148 | } | ||
149 | } else { | ||
150 | QString curFile = Remote_View->currentItem()->text(0); | ||
151 | if(curFile != "../") { | ||
152 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | ||
153 | DocLnk nf(curFile); | ||
154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | ||
155 | e << curFile; | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | |||
160 | void AdvancedFm::localMakDir() { | ||
161 | InputDialog *fileDlg; | ||
162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | ||
163 | fileDlg->exec(); | ||
164 | if( fileDlg->result() == 1 ) { | ||
165 | QString filename = fileDlg->LineEdit1->text(); | ||
166 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | ||
167 | } | ||
168 | populateLocalView(); | ||
169 | } | ||
170 | |||
171 | void AdvancedFm::remoteMakDir() { | ||
172 | InputDialog *fileDlg; | ||
173 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | ||
174 | fileDlg->exec(); | ||
175 | if( fileDlg->result() == 1 ) { | ||
176 | QString filename = fileDlg->LineEdit1->text(); | ||
177 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | ||
178 | } | ||
179 | populateRemoteView(); | ||
180 | } | ||
181 | |||
182 | void AdvancedFm::localDelete() { | ||
183 | QStringList curFileList = getPath(); | ||
184 | if(curFileList.count() > 0) { | ||
185 | QString myFile; | ||
186 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
187 | myFile = (*it); | ||
188 | if( myFile.find(" -> ",0,TRUE) != -1) | ||
189 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | ||
190 | |||
191 | QString f = currentDir.canonicalPath(); | ||
192 | if(f.right(1).find("/",0,TRUE) == -1) | ||
193 | f+="/"; | ||
194 | f+=myFile; | ||
195 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | ||
196 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | ||
197 | "\nand all it's contents ?" | ||
198 | ,tr("Yes"),tr("No"),0,0,1) ) { | ||
199 | case 0: { | ||
200 | f=f.left(f.length()-1); | ||
201 | QString cmd="rm -rf "+f; | ||
202 | system( cmd.latin1()); | ||
203 | populateLocalView(); | ||
204 | } | ||
205 | break; | ||
206 | case 1: | ||
207 | // exit | ||
208 | break; | ||
209 | }; | ||
210 | |||
211 | } else { | ||
212 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | ||
213 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | ||
214 | case 0: { | ||
215 | QString cmd="rm "+f; | ||
216 | QFile file(f); | ||
217 | file.remove(); | ||
218 | // system( cmd.latin1()); | ||
219 | populateLocalView(); | ||
220 | } | ||
221 | break; | ||
222 | case 1: | ||
223 | // exit | ||
224 | break; | ||
225 | }; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | void AdvancedFm::remoteDelete() { | ||
232 | QStringList curFileList = getPath(); | ||
233 | if( curFileList.count() > 0) { | ||
234 | QString myFile; | ||
235 | |||
236 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
237 | myFile = (*it); | ||
238 | if(myFile.find(" -> ",0,TRUE) != -1) | ||
239 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | ||
240 | QString f = currentRemoteDir.canonicalPath(); | ||
241 | if(f.right(1).find("/",0,TRUE) == -1) | ||
242 | f+="/"; | ||
243 | f+=myFile; | ||
244 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | ||
245 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | ||
246 | "\nand all it's contents ?", | ||
247 | tr("Yes"),tr("No"),0,0,1) ) { | ||
248 | case 0: { | ||
249 | f=f.left(f.length()-1); | ||
250 | QString cmd="rm -rf "+f; | ||
251 | system( cmd.latin1()); | ||
252 | populateRemoteView(); | ||
253 | } | ||
254 | break; | ||
255 | case 1: | ||
256 | // exit | ||
257 | break; | ||
258 | }; | ||
259 | |||
260 | } else { | ||
261 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | ||
262 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | ||
263 | case 0: { | ||
264 | QString cmd="rm "+f; | ||
265 | QFile file(f); | ||
266 | file.remove(); | ||
267 | // system( cmd.latin1()); | ||
268 | populateRemoteView(); | ||
269 | } | ||
270 | break; | ||
271 | case 1: | ||
272 | // exit | ||
273 | break; | ||
274 | }; | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | |||
280 | void AdvancedFm::localRename() { | ||
281 | QString curFile = Local_View->currentItem()->text(0); | ||
282 | qDebug("currentItem "+curFile); | ||
283 | if( curFile !="../") { | ||
284 | InputDialog *fileDlg; | ||
285 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | ||
286 | fileDlg->setInputText((const QString &)curFile); | ||
287 | fileDlg->exec(); | ||
288 | if( fileDlg->result() == 1 ) { | ||
289 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | ||
290 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); | ||
291 | //+".playlist"; | ||
292 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
293 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
294 | } | ||
295 | populateLocalView(); | ||
296 | } | ||
297 | } | ||
298 | |||
299 | void AdvancedFm::remoteRename() | ||
300 | { | ||
301 | QString curFile = Remote_View->currentItem()->text(0); | ||
302 | if( curFile !="../") { | ||
303 | InputDialog *fileDlg; | ||
304 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | ||
305 | fileDlg->setInputText((const QString &)curFile); | ||
306 | fileDlg->exec(); | ||
307 | if( fileDlg->result() == 1 ) { | ||
308 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | ||
309 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); | ||
310 | //+".playlist"; | ||
311 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
312 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
313 | } | ||
314 | populateRemoteView(); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | |||
319 | void AdvancedFm::filePerms() { | ||
320 | |||
321 | QStringList curFileList = getPath(); | ||
322 | QString filePath; | ||
323 | |||
324 | if (TabWidget->currentPageIndex() == 0) { | ||
325 | filePath = currentDir.canonicalPath()+"/"; | ||
326 | } else { | ||
327 | filePath= currentRemoteDir.canonicalPath()+"/"; | ||
328 | } | ||
329 | |||
330 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
331 | filePermissions *filePerm; | ||
332 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | ||
333 | filePerm->showMaximized(); | ||
334 | filePerm->exec(); | ||
335 | if( filePerm) | ||
336 | delete filePerm; | ||
337 | } | ||
338 | if (TabWidget->currentPageIndex() == 0) { | ||
339 | populateLocalView(); | ||
340 | } else { | ||
341 | populateRemoteView(); | ||
342 | } | ||
343 | } | ||
344 | |||
345 | void AdvancedFm::doProperties() { | ||
346 | QStringList curFileList = getPath(); | ||
347 | QString filePath; | ||
348 | if (TabWidget->currentPageIndex() == 0) { | ||
349 | filePath = currentDir.canonicalPath()+"/"; | ||
350 | } else { | ||
351 | filePath= currentRemoteDir.canonicalPath()+"/"; | ||
352 | } | ||
353 | // qDebug("%d",curFileList.count()); | ||
354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
355 | qDebug((filePath+*it)); | ||
356 | DocLnk lnk( (filePath+*it)); | ||
357 | LnkProperties prop( &lnk ); | ||
358 | prop.showMaximized(); | ||
359 | prop.exec(); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | void AdvancedFm::upDir() { | ||
364 | if (TabWidget->currentPageIndex() == 0) { | ||
365 | QString current = currentDir.canonicalPath(); | ||
366 | QDir dir(current); | ||
367 | dir.cdUp(); | ||
368 | current = dir.canonicalPath(); | ||
369 | chdir( current.latin1() ); | ||
370 | currentDir.cd( current, TRUE); | ||
371 | populateLocalView(); | ||
372 | update(); | ||
373 | } else { | ||
374 | QString current = currentRemoteDir.canonicalPath(); | ||
375 | QDir dir(current); | ||
376 | dir.cdUp(); | ||
377 | current = dir.canonicalPath(); | ||
378 | chdir( current.latin1() ); | ||
379 | currentRemoteDir.cd( current, TRUE); | ||
380 | populateRemoteView(); | ||
381 | update(); | ||
382 | } | ||
383 | } | ||
384 | |||
385 | void AdvancedFm::copy() { | ||
386 | qApp->processEvents(); | ||
387 | QStringList curFileList = getPath(); | ||
388 | if( curFileList.count() > 0) { | ||
389 | QString curFile, item, destFile; | ||
390 | if (TabWidget->currentPageIndex() == 0) { | ||
391 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
392 | item=(*it); | ||
393 | |||
394 | if(item.find("->",0,TRUE)) //symlink | ||
395 | item = item.left(item.find("->",0,TRUE)); | ||
396 | |||
397 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; | ||
398 | qDebug("Destination file is "+destFile); | ||
399 | |||
400 | curFile = currentDir.canonicalPath()+"/"+ item; | ||
401 | qDebug("CurrentFile file is " + curFile); | ||
402 | |||
403 | QFile f(destFile); | ||
404 | if( f.exists()) { | ||
405 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
406 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
407 | tr("Yes"),tr("No"),0,0,1) ) { | ||
408 | case 0: | ||
409 | f.remove(); | ||
410 | break; | ||
411 | case 1: | ||
412 | return; | ||
413 | break; | ||
414 | }; | ||
415 | } | ||
416 | if(!copyFile(destFile, curFile) ) { | ||
417 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | ||
418 | return; | ||
419 | } | ||
420 | } | ||
421 | populateRemoteView(); | ||
422 | TabWidget->setCurrentPage(1); | ||
423 | |||
424 | } else { | ||
425 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
426 | item= (*it); | ||
427 | |||
428 | if(item.find("->",0,TRUE)) //symlink | ||
429 | item = item.left(item.find("->",0,TRUE)); | ||
430 | |||
431 | destFile = currentDir.canonicalPath()+"/"+ item; | ||
432 | qDebug("Destination file is "+destFile); | ||
433 | |||
434 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; | ||
435 | qDebug("CurrentFile file is " + curFile); | ||
436 | |||
437 | QFile f(destFile); | ||
438 | if( f.exists()) { | ||
439 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
440 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
441 | tr("Yes"),tr("No"),0,0,1) ) { | ||
442 | case 0: | ||
443 | f.remove(); | ||
444 | break; | ||
445 | case 1: | ||
446 | return; | ||
447 | break; | ||
448 | }; | ||
449 | } | ||
450 | if(!copyFile(destFile, curFile) ) { | ||
451 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | ||
452 | +curFile +tr("to\n")+destFile); | ||
453 | return; | ||
454 | |||
455 | } | ||
456 | } | ||
457 | populateLocalView(); | ||
458 | TabWidget->setCurrentPage(0); | ||
459 | } | ||
460 | |||
461 | } | ||
462 | } | ||
463 | |||
464 | void AdvancedFm::copyAs() { | ||
465 | qApp->processEvents(); | ||
466 | |||
467 | QStringList curFileList = getPath(); | ||
468 | QString curFile; | ||
469 | InputDialog *fileDlg; | ||
470 | if (TabWidget->currentPageIndex() == 0) { | ||
471 | qDebug("tab 1"); | ||
472 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
473 | QString destFile; | ||
474 | curFile = currentDir.canonicalPath()+"/"+(*it); | ||
475 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
476 | |||
477 | fileDlg->setInputText((const QString &) destFile ); | ||
478 | fileDlg->exec(); | ||
479 | |||
480 | if( fileDlg->result() == 1 ) { | ||
481 | QString filename = fileDlg->LineEdit1->text(); | ||
482 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | ||
483 | |||
484 | QFile f(destFile); | ||
485 | if( f.exists()) { | ||
486 | switch (QMessageBox::warning(this,tr("Delete"), | ||
487 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
488 | tr("Yes"),tr("No"),0,0,1) ) { | ||
489 | case 0: | ||
490 | f.remove(); | ||
491 | break; | ||
492 | case 1: | ||
493 | return; | ||
494 | break; | ||
495 | }; | ||
496 | } | ||
497 | if(!copyFile(destFile, curFile) ) { | ||
498 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | ||
499 | +curFile +tr("to\n")+destFile); | ||
500 | return; | ||
501 | } | ||
502 | } | ||
503 | delete fileDlg; | ||
504 | |||
505 | } | ||
506 | populateRemoteView(); | ||
507 | TabWidget->setCurrentPage(1); | ||
508 | |||
509 | } else { | ||
510 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
511 | |||
512 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
513 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
514 | |||
515 | QString destFile; | ||
516 | fileDlg->setInputText((const QString &) destFile); | ||
517 | fileDlg->exec(); | ||
518 | |||
519 | if( fileDlg->result() == 1 ) { | ||
520 | QString filename = fileDlg->LineEdit1->text(); | ||
521 | destFile = currentDir.canonicalPath()+"/"+filename; | ||
522 | |||
523 | QFile f( destFile); | ||
524 | if( f.exists()) { | ||
525 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
526 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
527 | tr("Yes"),tr("No"),0,0,1) ) { | ||
528 | case 0: | ||
529 | f.remove(); | ||
530 | break; | ||
531 | case 1: | ||
532 | return; | ||
533 | break; | ||
534 | }; | ||
535 | } | ||
536 | if(!copyFile(destFile, curFile) ) { | ||
537 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | ||
538 | +curFile +tr("to\n")+destFile); | ||
539 | return; | ||
540 | } | ||
541 | |||
542 | } | ||
543 | delete fileDlg; | ||
544 | |||
545 | } | ||
546 | populateLocalView(); | ||
547 | TabWidget->setCurrentPage(0); | ||
548 | } | ||
549 | } | ||
550 | |||
551 | void AdvancedFm::copySameDir() { | ||
552 | qApp->processEvents(); | ||
553 | QStringList curFileList = getPath(); | ||
554 | QString curFile, item, destFile; | ||
555 | InputDialog *fileDlg; | ||
556 | |||
557 | if (TabWidget->currentPageIndex() == 0) { | ||
558 | |||
559 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
560 | item=(*it); | ||
561 | curFile = currentDir.canonicalPath()+"/"+ item; | ||
562 | |||
563 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | ||
564 | fileDlg->setInputText((const QString &) destFile ); | ||
565 | fileDlg->exec(); | ||
566 | |||
567 | if( fileDlg->result() == 1 ) { | ||
568 | |||
569 | QString filename = fileDlg->LineEdit1->text(); | ||
570 | destFile = currentDir.canonicalPath()+"/"+filename; | ||
571 | |||
572 | QFile f(destFile); | ||
573 | if( f.exists()) { | ||
574 | switch (QMessageBox::warning(this,tr("Delete"), | ||
575 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
576 | tr("Yes"),tr("No"),0,0,1) ) { | ||
577 | case 0: | ||
578 | |||
579 | f.remove(); | ||
580 | break; | ||
581 | case 1: | ||
582 | return; | ||
583 | break; | ||
584 | }; | ||
585 | } | ||
586 | if(!copyFile(destFile, curFile) ) { | ||
587 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | ||
588 | +curFile +tr("to\n")+destFile); | ||
589 | return; | ||
590 | } | ||
591 | |||
592 | qDebug("copy "+curFile+" as "+destFile); | ||
593 | } | ||
594 | delete fileDlg; | ||
595 | } | ||
596 | populateLocalView(); | ||
597 | |||
598 | } else { | ||
599 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
600 | item=(*it); | ||
601 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; | ||
602 | |||
603 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | ||
604 | fileDlg->setInputText((const QString &) destFile); | ||
605 | fileDlg->exec(); | ||
606 | if( fileDlg->result() == 1 ) { | ||
607 | QString filename = fileDlg->LineEdit1->text(); | ||
608 | |||
609 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | ||
610 | |||
611 | QFile f(destFile); | ||
612 | if( f.exists()) { | ||
613 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
614 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
615 | tr("Yes"),tr("No"),0,0,1) ) { | ||
616 | case 0: | ||
617 | f.remove(); | ||
618 | break; | ||
619 | case 1: | ||
620 | return; | ||
621 | break; | ||
622 | }; | ||
623 | } | ||
624 | if(!copyFile(destFile, curFile) ) { | ||
625 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | ||
626 | +curFile +tr("to\n")+destFile); | ||
627 | return; | ||
628 | } | ||
629 | qDebug("copy "+curFile+" as "+destFile); | ||
630 | } | ||
631 | delete fileDlg; | ||
632 | } | ||
633 | populateRemoteView(); | ||
634 | } | ||
635 | } | ||
636 | |||
637 | void AdvancedFm::move() { | ||
638 | qApp->processEvents(); | ||
639 | |||
640 | QStringList curFileList = getPath(); | ||
641 | if( curFileList.count() > 0) { | ||
642 | QString curFile, destFile, item; | ||
643 | |||
644 | if (TabWidget->currentPageIndex() == 0) { | ||
645 | |||
646 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
647 | item=(*it); | ||
648 | QString destFile = currentRemoteDir.canonicalPath(); | ||
649 | |||
650 | if(destFile.right(1).find("/",0,TRUE) == -1) | ||
651 | destFile+="/"; | ||
652 | destFile += item; | ||
653 | curFile = currentDir.canonicalPath(); | ||
654 | |||
655 | qDebug("Destination file is "+destFile); | ||
656 | |||
657 | if(curFile.right(1).find("/",0,TRUE) == -1) | ||
658 | curFile +="/"; | ||
659 | |||
660 | curFile+= item; | ||
661 | qDebug("CurrentFile file is " + curFile); | ||
662 | |||
663 | QFile f( curFile); | ||
664 | if( f.exists()) { | ||
665 | if(!copyFile( destFile, curFile) ) { | ||
666 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | ||
667 | return; | ||
668 | } else | ||
669 | QFile::remove(curFile); | ||
670 | } | ||
671 | } | ||
672 | |||
673 | TabWidget->setCurrentPage(1); | ||
674 | |||
675 | } else { //view 2 | ||
676 | |||
677 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
678 | item = (*it); | ||
679 | QString destFile = currentDir.canonicalPath(); | ||
680 | |||
681 | if(destFile.right(1).find("/",0,TRUE) == -1) | ||
682 | destFile+="/"; | ||
683 | |||
684 | destFile += item; | ||
685 | |||
686 | qDebug("Destination file is "+destFile); | ||
687 | |||
688 | curFile = currentRemoteDir.canonicalPath(); | ||
689 | |||
690 | if(curFile.right(1).find("/",0,TRUE) == -1) | ||
691 | curFile +="/"; | ||
692 | curFile+= item; | ||
693 | qDebug("CurrentFile file is " + curFile); | ||
694 | |||
695 | QFile f( curFile); | ||
696 | if( f.exists()) { | ||
697 | if(!copyFile( destFile, curFile) ) { | ||
698 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | ||
699 | return; | ||
700 | } else | ||
701 | QFile::remove( curFile); | ||
702 | } | ||
703 | TabWidget->setCurrentPage(0); | ||
704 | } | ||
705 | } | ||
706 | populateRemoteView(); | ||
707 | populateLocalView(); | ||
708 | } | ||
709 | } | ||
710 | |||
711 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { | ||
712 | char bf[ 50000 ]; | ||
713 | int bytesRead; | ||
714 | bool success = TRUE; | ||
715 | struct stat status; | ||
716 | |||
717 | QFile s( src ); | ||
718 | QFile d( dest ); | ||
719 | |||
720 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | ||
721 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | ||
722 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | ||
723 | success = FALSE; | ||
724 | break; | ||
725 | } | ||
726 | } | ||
727 | if( success && (bytesRead > 0) ){ | ||
728 | d.writeBlock( bf, bytesRead ); | ||
729 | } | ||
730 | } else { | ||
731 | success = FALSE; | ||
732 | } | ||
733 | |||
734 | // Set file permissions | ||
735 | if( stat( (const char *) src, &status ) == 0 ){ | ||
736 | chmod( (const char *) dest, status.st_mode ); | ||
737 | } | ||
738 | |||
739 | return success; | ||
740 | } | ||
741 | |||
742 | void AdvancedFm::runCommand() { | ||
743 | QString curFile; | ||
744 | if (TabWidget->currentPageIndex() == 0) { | ||
745 | if( Local_View->currentItem()) | ||
746 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | ||
747 | } else { | ||
748 | if(Remote_View->currentItem()) | ||
749 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | ||
750 | } | ||
751 | |||
752 | InputDialog *fileDlg; | ||
753 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | ||
754 | fileDlg->setInputText(curFile); | ||
755 | fileDlg->exec(); | ||
756 | QString command; | ||
757 | if( fileDlg->result() == 1 ) { | ||
758 | command = fileDlg->LineEdit1->text(); | ||
759 | |||
760 | Output *outDlg; | ||
761 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
762 | outDlg->showMaximized(); | ||
763 | outDlg->show(); | ||
764 | qApp->processEvents(); | ||
765 | FILE *fp; | ||
766 | char line[130]; | ||
767 | sleep(1); | ||
768 | command +=" 2>&1"; | ||
769 | fp = popen( (const char *) command, "r"); | ||
770 | if ( !fp ) { | ||
771 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
772 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
773 | pclose(fp); | ||
774 | return; | ||
775 | } else { | ||
776 | while ( fgets( line, sizeof line, fp)) { | ||
777 | QString lineStr = line; | ||
778 | lineStr=lineStr.left(lineStr.length()-1); | ||
779 | outDlg->OutputEdit->append(lineStr); | ||
780 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
781 | } | ||
782 | } | ||
783 | pclose(fp); | ||
784 | |||
785 | } | ||
786 | } | ||
787 | |||
788 | void AdvancedFm::runCommandStd() { | ||
789 | QString curFile; | ||
790 | if (TabWidget->currentPageIndex() == 0) { | ||
791 | if( Local_View->currentItem()) | ||
792 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | ||
793 | } else { | ||
794 | if(Remote_View->currentItem()) | ||
795 | curFile = currentRemoteDir.canonicalPath() +"/" | ||
796 | + Remote_View->currentItem()->text(0); | ||
797 | } | ||
798 | |||
799 | InputDialog *fileDlg; | ||
800 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | ||
801 | fileDlg->setInputText(curFile); | ||
802 | fileDlg->exec(); | ||
803 | QString command; | ||
804 | if( fileDlg->result() == 1 ) { | ||
805 | qApp->processEvents(); | ||
806 | command = fileDlg->LineEdit1->text() + " &"; | ||
807 | system(command.latin1()); | ||
808 | } | ||
809 | } | ||
810 | |||
811 | void AdvancedFm::fileStatus() { | ||
812 | QString curFile; | ||
813 | if (TabWidget->currentPageIndex() == 0) { | ||
814 | curFile = Local_View->currentItem()->text(0); | ||
815 | } else { | ||
816 | curFile = Remote_View->currentItem()->text(0); | ||
817 | } | ||
818 | QString command = " stat -l "+ curFile +" 2>&1"; | ||
819 | Output *outDlg; | ||
820 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
821 | outDlg->showMaximized(); | ||
822 | outDlg->show(); | ||
823 | qApp->processEvents(); | ||
824 | FILE *fp; | ||
825 | char line[130]; | ||
826 | sleep(1); | ||
827 | fp = popen( (const char *) command, "r"); | ||
828 | if ( !fp ) { | ||
829 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
830 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
831 | pclose(fp); | ||
832 | return; | ||
833 | } else { | ||
834 | while ( fgets( line, sizeof line, fp)) { | ||
835 | outDlg->OutputEdit->append(line); | ||
836 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
837 | |||
838 | } | ||
839 | |||
840 | } | ||
841 | pclose(fp); | ||
842 | } | ||
843 | |||
844 | void AdvancedFm::mkDir() { | ||
845 | if (TabWidget->currentPageIndex() == 0) | ||
846 | localMakDir(); | ||
847 | else | ||
848 | remoteMakDir(); | ||
849 | |||
850 | } | ||
851 | |||
852 | void AdvancedFm::rn() { | ||
853 | if (TabWidget->currentPageIndex() == 0) | ||
854 | localRename(); | ||
855 | else | ||
856 | remoteRename(); | ||
857 | |||
858 | } | ||
859 | |||
860 | void AdvancedFm::del() { | ||
861 | if (TabWidget->currentPageIndex() == 0) | ||
862 | localDelete(); | ||
863 | else | ||
864 | remoteDelete(); | ||
865 | } | ||
866 | |||
867 | void AdvancedFm::mkSym() { | ||
868 | QString cmd; | ||
869 | QStringList curFileList = getPath(); | ||
870 | if( curFileList.count() > 0) { | ||
871 | |||
872 | if (TabWidget->currentPageIndex() == 0) { | ||
873 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
874 | |||
875 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
876 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | ||
877 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
878 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
879 | cmd = "ln -s "+curFile+" "+destName; | ||
880 | qDebug(cmd); | ||
881 | system(cmd.latin1() ); | ||
882 | } | ||
883 | populateRemoteView(); | ||
884 | TabWidget->setCurrentPage(1); | ||
885 | } else { | ||
886 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
887 | |||
888 | QString destName = currentDir.canonicalPath()+"/"+(*it); | ||
889 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | ||
890 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
891 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
892 | |||
893 | cmd = "ln -s "+curFile+" "+destName; | ||
894 | qDebug(cmd); | ||
895 | system(cmd.latin1() ); | ||
896 | } | ||
897 | populateLocalView(); | ||
898 | TabWidget->setCurrentPage(0); | ||
899 | } | ||
900 | } | ||
901 | } | ||
902 | |||
903 | void AdvancedFm::doBeam() { | ||
904 | Ir ir; | ||
905 | if(!ir.supported()){ | ||
906 | } else { | ||
907 | |||
908 | QStringList curFileList = getPath(); | ||
909 | if( curFileList.count() > 0) { | ||
910 | |||
911 | if (TabWidget->currentPageIndex() == 0) { | ||
912 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
913 | |||
914 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
915 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
916 | Ir *file = new Ir(this, "IR"); | ||
917 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | ||
918 | file->send( curFile, curFile ); | ||
919 | } | ||
920 | |||
921 | } else { | ||
922 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
923 | |||
924 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
925 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | ||
926 | Ir *file = new Ir(this, "IR"); | ||
927 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | ||
928 | file->send( curFile, curFile ); | ||
929 | |||
930 | } | ||
931 | } | ||
932 | } | ||
933 | } | ||
934 | |||
935 | } | ||
936 | |||
937 | void AdvancedFm::fileBeamFinished( Ir *) { | ||
938 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | ||
939 | |||
940 | } | ||