-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 39 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 5 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 82 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 4 |
4 files changed, 47 insertions, 83 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 41e83c7..66353bb 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,904 +1,879 @@ | |||
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 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
14 | 14 | ||
15 | #include <opie/otabwidget.h> | 15 | |
16 | // #include <opie/ofileselector.h> | 16 | // #include <opie/ofileselector.h> |
17 | // #include <opie/ofiledialog.h> | 17 | // #include <opie/ofiledialog.h> |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <opie/otabwidget.h> |
20 | |||
20 | #include <qpe/filemanager.h> | 21 | #include <qpe/filemanager.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpemenubar.h> | ||
23 | #include <qpe/qpetoolbar.h> | ||
24 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/qcopenvelope_qws.h> | ||
26 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
27 | #include <qpe/mimetype.h> | 25 | #include <qpe/mimetype.h> |
28 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
29 | #include <qpe/ir.h> | 27 | #include <qpe/ir.h> |
30 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
31 | #include <qpe/menubutton.h> | 29 | #include <qpe/menubutton.h> |
32 | 30 | ||
33 | |||
34 | #include <qwmatrix.h> | ||
35 | #include <qregexp.h> | ||
36 | #include <qtabwidget.h> | ||
37 | #include <qtextstream.h> | ||
38 | #include <qpushbutton.h> | ||
39 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
40 | #include <qdir.h> | ||
41 | #include <qfile.h> | 32 | #include <qfile.h> |
42 | #include <qstring.h> | ||
43 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
44 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
45 | #include <qlistview.h> | 35 | #include <qlistview.h> |
46 | #include <qmainwindow.h> | ||
47 | #include <qlabel.h> | 36 | #include <qlabel.h> |
48 | #include <qprogressbar.h> | ||
49 | #include <qspinbox.h> | ||
50 | #include <qwidget.h> | 37 | #include <qwidget.h> |
51 | #include <qlayout.h> | 38 | #include <qlayout.h> |
52 | #include <qimage.h> | 39 | #include <qimage.h> |
53 | #include <qpixmap.h> | ||
54 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
55 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
56 | #include <qregexp.h> | ||
57 | 42 | ||
58 | #include <unistd.h> | ||
59 | #include <stdlib.h> | ||
60 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
61 | #include <dirent.h> | ||
62 | #include <stdio.h> | ||
63 | #include <time.h> | 44 | #include <time.h> |
45 | #include <dirent.h> | ||
64 | #include <fcntl.h> | 46 | #include <fcntl.h> |
65 | #include <mntent.h> | ||
66 | #include <string.h> | ||
67 | #include <errno.h> | ||
68 | #include <sys/vfs.h> | 47 | #include <sys/vfs.h> |
69 | #include <mntent.h> | 48 | #include <mntent.h> |
70 | #include <sys/utsname.h> | ||
71 | 49 | ||
72 | AdvancedFm::AdvancedFm( ) | 50 | AdvancedFm::AdvancedFm( ) |
73 | : QMainWindow( ) { | 51 | : QMainWindow( ) { |
74 | init(); | 52 | init(); |
75 | renameBox = 0; | 53 | renameBox = 0; |
76 | 54 | ||
77 | QWMatrix matrix; | 55 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
78 | QPixmap pix(Resource::loadPixmap( "UnknownDocument" )); | 56 | |
79 | matrix.scale( .4, .4); | ||
80 | unknownXpm = pix.xForm(matrix); | ||
81 | |||
82 | initConnections(); | 57 | initConnections(); |
83 | whichTab=1; | 58 | whichTab=1; |
84 | rePopulate(); | 59 | rePopulate(); |
85 | currentPathCombo->setFocus(); | 60 | currentPathCombo->setFocus(); |
86 | } | 61 | } |
87 | 62 | ||
88 | AdvancedFm::~AdvancedFm() { | 63 | AdvancedFm::~AdvancedFm() { |
89 | } | 64 | } |
90 | 65 | ||
91 | 66 | ||
92 | void AdvancedFm::cleanUp() | 67 | void AdvancedFm::cleanUp() |
93 | { | 68 | { |
94 | QString sfile=QDir::homeDirPath(); | 69 | QString sfile=QDir::homeDirPath(); |
95 | if(sfile.right(1) != "/") | 70 | if(sfile.right(1) != "/") |
96 | sfile+="/._temp"; | 71 | sfile+="/._temp"; |
97 | else | 72 | else |
98 | sfile+="._temp"; | 73 | sfile+="._temp"; |
99 | QFile file( sfile); | 74 | QFile file( sfile); |
100 | if(file.exists()) | 75 | if(file.exists()) |
101 | file.remove(); | 76 | file.remove(); |
102 | } | 77 | } |
103 | 78 | ||
104 | void AdvancedFm::tabChanged(QWidget *w) | 79 | void AdvancedFm::tabChanged(QWidget *w) |
105 | { | 80 | { |
106 | if( w == tab) | 81 | if( w == tab) |
107 | whichTab = 1; | 82 | whichTab = 1; |
108 | else | 83 | else |
109 | whichTab = 2; | 84 | whichTab = 2; |
110 | 85 | ||
111 | // qDebug("tab changed %d", whichTab ); | 86 | // qDebug("tab changed %d", whichTab ); |
112 | 87 | ||
113 | QString path = CurrentDir()->canonicalPath(); | 88 | QString path = CurrentDir()->canonicalPath(); |
114 | currentPathCombo->lineEdit()->setText( path ); | 89 | currentPathCombo->lineEdit()->setText( path ); |
115 | 90 | ||
116 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 91 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
117 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 92 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
118 | 93 | ||
119 | QString fs= getFileSystemType( (const QString &) path); | 94 | QString fs= getFileSystemType( (const QString &) path); |
120 | 95 | ||
121 | setCaption("AdvancedFm :: "+fs+" :: " | 96 | setCaption("AdvancedFm :: "+fs+" :: " |
122 | +checkDiskSpace( (const QString &) path )+ " kB free" ); | 97 | +checkDiskSpace( (const QString &) path )+ " kB free" ); |
123 | chdir( path.latin1()); | 98 | chdir( path.latin1()); |
124 | } | 99 | } |
125 | 100 | ||
126 | 101 | ||
127 | void AdvancedFm::populateView() | 102 | void AdvancedFm::populateView() |
128 | { | 103 | { |
129 | QPixmap pm; | 104 | QPixmap pm; |
130 | QListView *thisView = CurrentView(); | 105 | QListView *thisView = CurrentView(); |
131 | QDir *thisDir = CurrentDir(); | 106 | QDir *thisDir = CurrentDir(); |
132 | QString path = thisDir->canonicalPath(); | 107 | QString path = thisDir->canonicalPath(); |
133 | 108 | ||
134 | thisView->clear(); | 109 | thisView->clear(); |
135 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 110 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
136 | thisDir->setMatchAllDirs(TRUE); | 111 | thisDir->setMatchAllDirs(TRUE); |
137 | thisDir->setNameFilter(filterStr); | 112 | thisDir->setNameFilter(filterStr); |
138 | QString fileL, fileS, fileDate; | 113 | QString fileL, fileS, fileDate; |
139 | QString fs= getFileSystemType((const QString &) path); | 114 | QString fs= getFileSystemType((const QString &) path); |
140 | setCaption("AdvancedFm :: "+fs+" :: " | 115 | setCaption("AdvancedFm :: "+fs+" :: " |
141 | +checkDiskSpace((const QString &) path)+" kB free" ); | 116 | +checkDiskSpace((const QString &) path)+" kB free" ); |
142 | bool isDir=FALSE; | 117 | bool isDir=FALSE; |
143 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 118 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
144 | QFileInfoListIterator it(*list); | 119 | QFileInfoListIterator it(*list); |
145 | QFileInfo *fi; | 120 | QFileInfo *fi; |
146 | while ( (fi=it.current()) ) | 121 | while ( (fi=it.current()) ) |
147 | { | 122 | { |
148 | if (fi->isSymLink() ) | 123 | if (fi->isSymLink() ) |
149 | { | 124 | { |
150 | QString symLink=fi->readLink(); | 125 | QString symLink=fi->readLink(); |
151 | QFileInfo sym( symLink); | 126 | QFileInfo sym( symLink); |
152 | fileS.sprintf( "%10i", sym.size() ); | 127 | fileS.sprintf( "%10i", sym.size() ); |
153 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 128 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
154 | fileDate = sym.lastModified().toString(); | 129 | fileDate = sym.lastModified().toString(); |
155 | } | 130 | } |
156 | else | 131 | else |
157 | { | 132 | { |
158 | fileS.sprintf( "%10i", fi->size() ); | 133 | fileS.sprintf( "%10i", fi->size() ); |
159 | fileL.sprintf( "%s",fi->fileName().data() ); | 134 | fileL.sprintf( "%s",fi->fileName().data() ); |
160 | fileDate= fi->lastModified().toString(); | 135 | fileDate= fi->lastModified().toString(); |
161 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) | 136 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) |
162 | { | 137 | { |
163 | fileL+="/"; | 138 | fileL+="/"; |
164 | isDir=TRUE; | 139 | isDir=TRUE; |
165 | } | 140 | } |
166 | } | 141 | } |
167 | 142 | ||
168 | QFileInfo fileInfo( path + "/" + fileL); | 143 | QFileInfo fileInfo( path + "/" + fileL); |
169 | 144 | ||
170 | if(fileL !="./" && fi->exists()) | 145 | if(fileL !="./" && fi->exists()) |
171 | { | 146 | { |
172 | item= new QListViewItem( thisView, fileL, fileS , fileDate); | 147 | item= new QListViewItem( thisView, fileL, fileS , fileDate); |
173 | 148 | ||
174 | if(isDir || fileL.find("/",0,TRUE) != -1) | 149 | if(isDir || fileL.find("/",0,TRUE) != -1) |
175 | { | 150 | { |
176 | 151 | ||
177 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 152 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
178 | pm = Resource::loadPixmap( "lockedfolder" ); | 153 | pm = Resource::loadPixmap( "lockedfolder" ); |
179 | else | 154 | else |
180 | pm= Resource::loadPixmap( "folder" ); | 155 | pm= Resource::loadPixmap( "folder" ); |
181 | } | 156 | } |
182 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) | 157 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) |
183 | { | 158 | { |
184 | pm = Resource::loadPixmap( "exec"); | 159 | pm = Resource::loadPixmap( "exec"); |
185 | } | 160 | } |
186 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 161 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
187 | | fileInfo.permission( QFileInfo::ExeGroup) | 162 | | fileInfo.permission( QFileInfo::ExeGroup) |
188 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) | 163 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) |
189 | { | 164 | { |
190 | pm = Resource::loadPixmap( "exec"); | 165 | pm = Resource::loadPixmap( "exec"); |
191 | } | 166 | } |
192 | else if( !fi->isReadable() ) | 167 | else if( !fi->isReadable() ) |
193 | { | 168 | { |
194 | pm = Resource::loadPixmap( "locked" ); | 169 | pm = Resource::loadPixmap( "locked" ); |
195 | } | 170 | } |
196 | else { //everything else goes by mimetype | 171 | else { //everything else goes by mimetype |
197 | MimeType mt(fi->filePath()); | 172 | MimeType mt(fi->filePath()); |
198 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 173 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
199 | if(pm.isNull()) { | 174 | if(pm.isNull()) { |
200 | pm = unknownXpm; | 175 | pm = unknownXpm; |
201 | } | 176 | } |
202 | } | 177 | } |
203 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) | 178 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) |
204 | { | 179 | { |
205 | // overlay link image | 180 | // overlay link image |
206 | pm= Resource::loadPixmap( "folder" ); | 181 | pm= Resource::loadPixmap( "folder" ); |
207 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 182 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
208 | QPainter painter( &pm ); | 183 | QPainter painter( &pm ); |
209 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 184 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
210 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 185 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
211 | } | 186 | } |
212 | item->setPixmap( 0,pm); | 187 | item->setPixmap( 0,pm); |
213 | 188 | ||
214 | } | 189 | } |
215 | isDir=FALSE; | 190 | isDir=FALSE; |
216 | ++it; | 191 | ++it; |
217 | } | 192 | } |
218 | 193 | ||
219 | if( path.find("dev",0,TRUE) != -1) | 194 | if( path.find("dev",0,TRUE) != -1) |
220 | { | 195 | { |
221 | struct stat buf; | 196 | struct stat buf; |
222 | dev_t devT; | 197 | dev_t devT; |
223 | DIR *dir; | 198 | DIR *dir; |
224 | struct dirent *mydirent; | 199 | struct dirent *mydirent; |
225 | 200 | ||
226 | if((dir = opendir( path.latin1())) != NULL) | 201 | if((dir = opendir( path.latin1())) != NULL) |
227 | while ((mydirent = readdir(dir)) != NULL) | 202 | while ((mydirent = readdir(dir)) != NULL) |
228 | { | 203 | { |
229 | lstat( mydirent->d_name, &buf); | 204 | lstat( mydirent->d_name, &buf); |
230 | // qDebug(mydirent->d_name); | 205 | // qDebug(mydirent->d_name); |
231 | fileL.sprintf("%s", mydirent->d_name); | 206 | fileL.sprintf("%s", mydirent->d_name); |
232 | devT = buf.st_dev; | 207 | devT = buf.st_dev; |
233 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 208 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
234 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 209 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
235 | if( fileL.find(".") == -1 ) | 210 | if( fileL.find(".") == -1 ) |
236 | { | 211 | { |
237 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 212 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
238 | pm = unknownXpm; | 213 | pm = unknownXpm; |
239 | item->setPixmap( 0,pm); | 214 | item->setPixmap( 0,pm); |
240 | } | 215 | } |
241 | } | 216 | } |
242 | 217 | ||
243 | closedir(dir); | 218 | closedir(dir); |
244 | } | 219 | } |
245 | 220 | ||
246 | thisView->setSorting( 3,FALSE); | 221 | thisView->setSorting( 3,FALSE); |
247 | fillCombo( (const QString &) path ); | 222 | fillCombo( (const QString &) path ); |
248 | } | 223 | } |
249 | 224 | ||
250 | void AdvancedFm::rePopulate() | 225 | void AdvancedFm::rePopulate() |
251 | { | 226 | { |
252 | int tmpTab = whichTab; | 227 | int tmpTab = whichTab; |
253 | qDebug("%d", tmpTab); | 228 | qDebug("%d", tmpTab); |
254 | 229 | ||
255 | for(int i =1; i < 3; i++) | 230 | for(int i =1; i < 3; i++) |
256 | { | 231 | { |
257 | TabWidget->setCurrentTab(i - 1); | 232 | TabWidget->setCurrentTab(i - 1); |
258 | populateView(); | 233 | populateView(); |
259 | } | 234 | } |
260 | TabWidget->setCurrentTab( tmpTab - 1); | 235 | TabWidget->setCurrentTab( tmpTab - 1); |
261 | } | 236 | } |
262 | 237 | ||
263 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) | 238 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) |
264 | { | 239 | { |
265 | if(selectedItem) | 240 | if(selectedItem) |
266 | { | 241 | { |
267 | QString strItem=selectedItem->text(0); | 242 | QString strItem=selectedItem->text(0); |
268 | QString strSize=selectedItem->text(1); | 243 | QString strSize=selectedItem->text(1); |
269 | strSize=strSize.stripWhiteSpace(); | 244 | strSize=strSize.stripWhiteSpace(); |
270 | bool isDirectory = false; | 245 | bool isDirectory = false; |
271 | QString strItem2; | 246 | QString strItem2; |
272 | 247 | ||
273 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink | 248 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink |
274 | { | 249 | { |
275 | strItem2 = dealWithSymName((const QString&)strItem); | 250 | strItem2 = dealWithSymName((const QString&)strItem); |
276 | if(QDir(strItem2).exists() ) | 251 | if(QDir(strItem2).exists() ) |
277 | strItem = strItem2; | 252 | strItem = strItem2; |
278 | } | 253 | } |
279 | 254 | ||
280 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) | 255 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) |
281 | { | 256 | { |
282 | 257 | ||
283 | if(QDir(strItem).exists()) | 258 | if(QDir(strItem).exists()) |
284 | isDirectory = true; | 259 | isDirectory = true; |
285 | } | 260 | } |
286 | 261 | ||
287 | if( isDirectory ) | 262 | if( isDirectory ) |
288 | { | 263 | { |
289 | CurrentDir()->cd( strItem, TRUE); | 264 | CurrentDir()->cd( strItem, TRUE); |
290 | populateView(); | 265 | populateView(); |
291 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 266 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
292 | } | 267 | } |
293 | chdir( strItem.latin1()); | 268 | chdir( strItem.latin1()); |
294 | } | 269 | } |
295 | } | 270 | } |
296 | 271 | ||
297 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 272 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
298 | switch (mouse) { | 273 | switch (mouse) { |
299 | case 1: | 274 | case 1: |
300 | { | 275 | { |
301 | if(renameBox != 0 ) | 276 | if(renameBox != 0 ) |
302 | { | 277 | { |
303 | cancelRename(); | 278 | cancelRename(); |
304 | } | 279 | } |
305 | } | 280 | } |
306 | break; | 281 | break; |
307 | case 2: | 282 | case 2: |
308 | menuTimer.start( 500, TRUE ); | 283 | menuTimer.start( 500, TRUE ); |
309 | break; | 284 | break; |
310 | }; | 285 | }; |
311 | } | 286 | } |
312 | 287 | ||
313 | void AdvancedFm::switchToLocalTab() | 288 | void AdvancedFm::switchToLocalTab() |
314 | { | 289 | { |
315 | TabWidget->setCurrentTab(0); | 290 | TabWidget->setCurrentTab(0); |
316 | Local_View->setFocus(); | 291 | Local_View->setFocus(); |
317 | } | 292 | } |
318 | 293 | ||
319 | void AdvancedFm::switchToRemoteTab() | 294 | void AdvancedFm::switchToRemoteTab() |
320 | { | 295 | { |
321 | TabWidget->setCurrentTab(1); | 296 | TabWidget->setCurrentTab(1); |
322 | Remote_View->setFocus(); | 297 | Remote_View->setFocus(); |
323 | } | 298 | } |
324 | 299 | ||
325 | void AdvancedFm::readConfig() | 300 | void AdvancedFm::readConfig() |
326 | { | 301 | { |
327 | Config cfg("AdvancedFm"); | 302 | Config cfg("AdvancedFm"); |
328 | } | 303 | } |
329 | 304 | ||
330 | void AdvancedFm::writeConfig() | 305 | void AdvancedFm::writeConfig() |
331 | { | 306 | { |
332 | Config cfg("AdvancedFm"); | 307 | Config cfg("AdvancedFm"); |
333 | } | 308 | } |
334 | 309 | ||
335 | void AdvancedFm::currentPathComboChanged() | 310 | void AdvancedFm::currentPathComboChanged() |
336 | { | 311 | { |
337 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) | 312 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) |
338 | { | 313 | { |
339 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 314 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
340 | populateView(); | 315 | populateView(); |
341 | } | 316 | } |
342 | else | 317 | else |
343 | { | 318 | { |
344 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 319 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
345 | } | 320 | } |
346 | } | 321 | } |
347 | 322 | ||
348 | void AdvancedFm::fillCombo(const QString ¤tPath) | 323 | void AdvancedFm::fillCombo(const QString ¤tPath) |
349 | { | 324 | { |
350 | // qDebug("%d",TabWidget->currentTab()); | 325 | // qDebug("%d",TabWidget->currentTab()); |
351 | if ( whichTab == 1) | 326 | if ( whichTab == 1) |
352 | { | 327 | { |
353 | currentPathCombo->lineEdit()->setText( currentPath); | 328 | currentPathCombo->lineEdit()->setText( currentPath); |
354 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 329 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) |
355 | { | 330 | { |
356 | currentPathCombo->clear(); | 331 | currentPathCombo->clear(); |
357 | localDirPathStringList.prepend( currentPath ); | 332 | localDirPathStringList.prepend( currentPath ); |
358 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 333 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
359 | } | 334 | } |
360 | } | 335 | } |
361 | else | 336 | else |
362 | { | 337 | { |
363 | currentPathCombo->lineEdit()->setText( currentPath); | 338 | currentPathCombo->lineEdit()->setText( currentPath); |
364 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 339 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) |
365 | { | 340 | { |
366 | currentPathCombo->clear(); | 341 | currentPathCombo->clear(); |
367 | remoteDirPathStringList.prepend( currentPath ); | 342 | remoteDirPathStringList.prepend( currentPath ); |
368 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 343 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
369 | } | 344 | } |
370 | } | 345 | } |
371 | } | 346 | } |
372 | 347 | ||
373 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) | 348 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) |
374 | { | 349 | { |
375 | chdir( currentPath.latin1() ); | 350 | chdir( currentPath.latin1() ); |
376 | CurrentDir()->cd( currentPath, TRUE); | 351 | CurrentDir()->cd( currentPath, TRUE); |
377 | populateView(); | 352 | populateView(); |
378 | update(); | 353 | update(); |
379 | } | 354 | } |
380 | 355 | ||
381 | QStringList AdvancedFm::getPath() | 356 | QStringList AdvancedFm::getPath() |
382 | { | 357 | { |
383 | QStringList strList; | 358 | QStringList strList; |
384 | QListView *thisView=CurrentView(); | 359 | QListView *thisView=CurrentView(); |
385 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 360 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
386 | QListViewItemIterator it( thisView ); | 361 | QListViewItemIterator it( thisView ); |
387 | for ( ; it.current(); ++it ) | 362 | for ( ; it.current(); ++it ) |
388 | { | 363 | { |
389 | if ( it.current()->isSelected() ) | 364 | if ( it.current()->isSelected() ) |
390 | { | 365 | { |
391 | strList << it.current()->text(0); | 366 | strList << it.current()->text(0); |
392 | // qDebug(it.current()->text(0)); | 367 | // qDebug(it.current()->text(0)); |
393 | } | 368 | } |
394 | } | 369 | } |
395 | return strList; | 370 | return strList; |
396 | } | 371 | } |
397 | 372 | ||
398 | void AdvancedFm::homeButtonPushed() | 373 | void AdvancedFm::homeButtonPushed() |
399 | { | 374 | { |
400 | QString current = QDir::homeDirPath(); | 375 | QString current = QDir::homeDirPath(); |
401 | chdir( current.latin1() ); | 376 | chdir( current.latin1() ); |
402 | CurrentDir()->cd( current, TRUE); | 377 | CurrentDir()->cd( current, TRUE); |
403 | populateView(); | 378 | populateView(); |
404 | update(); | 379 | update(); |
405 | } | 380 | } |
406 | 381 | ||
407 | void AdvancedFm::docButtonPushed() | 382 | void AdvancedFm::docButtonPushed() |
408 | { | 383 | { |
409 | QString current = QPEApplication::documentDir(); | 384 | QString current = QPEApplication::documentDir(); |
410 | chdir( current.latin1() ); | 385 | chdir( current.latin1() ); |
411 | CurrentDir()->cd( current, TRUE); | 386 | CurrentDir()->cd( current, TRUE); |
412 | populateView(); | 387 | populateView(); |
413 | update(); | 388 | update(); |
414 | } | 389 | } |
415 | 390 | ||
416 | void AdvancedFm::SDButtonPushed() | 391 | void AdvancedFm::SDButtonPushed() |
417 | { | 392 | { |
418 | QString current = "/mnt/card";// this can change so fix | 393 | QString current = "/mnt/card";// this can change so fix |
419 | chdir( current.latin1() ); | 394 | chdir( current.latin1() ); |
420 | CurrentDir()->cd( current, TRUE); | 395 | CurrentDir()->cd( current, TRUE); |
421 | populateView(); | 396 | populateView(); |
422 | update(); | 397 | update(); |
423 | } | 398 | } |
424 | 399 | ||
425 | void AdvancedFm::CFButtonPushed() | 400 | void AdvancedFm::CFButtonPushed() |
426 | { | 401 | { |
427 | QString current; | 402 | QString current; |
428 | if(zaurusDevice) | 403 | if(zaurusDevice) |
429 | current= "/mnt/cf"; //zaurus | 404 | current= "/mnt/cf"; //zaurus |
430 | else | 405 | else |
431 | current = "/mnt/hda"; //ipaq | 406 | current = "/mnt/hda"; //ipaq |
432 | chdir( current.latin1() ); | 407 | chdir( current.latin1() ); |
433 | CurrentDir()->cd( current, TRUE); | 408 | CurrentDir()->cd( current, TRUE); |
434 | populateView(); | 409 | populateView(); |
435 | update(); | 410 | update(); |
436 | } | 411 | } |
437 | 412 | ||
438 | 413 | ||
439 | void AdvancedFm::doAbout() | 414 | void AdvancedFm::doAbout() |
440 | { | 415 | { |
441 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 416 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
442 | "is copyright 2002-2003 by\n" | 417 | "is copyright 2002-2003 by\n" |
443 | "L.J.Potter<llornkcor@handhelds.org>\n" | 418 | "L.J.Potter<llornkcor@handhelds.org>\n" |
444 | "and is licensed by the GPL")); | 419 | "and is licensed by the GPL")); |
445 | } | 420 | } |
446 | 421 | ||
447 | void AdvancedFm::keyPressEvent( QKeyEvent *e) | 422 | void AdvancedFm::keyPressEvent( QKeyEvent *e) |
448 | { | 423 | { |
449 | // e->accept(); | 424 | // e->accept(); |
450 | if( CurrentView()->hasFocus() ) | 425 | if( CurrentView()->hasFocus() ) |
451 | { | 426 | { |
452 | switch ( e->key() ) { | 427 | switch ( e->key() ) { |
453 | case Key_Delete: | 428 | case Key_Delete: |
454 | del(); | 429 | del(); |
455 | break; | 430 | break; |
456 | case Key_A: | 431 | case Key_A: |
457 | copyAs(); | 432 | copyAs(); |
458 | break; | 433 | break; |
459 | case Key_C: | 434 | case Key_C: |
460 | copy(); | 435 | copy(); |
461 | break; | 436 | break; |
462 | case Key_E: | 437 | case Key_E: |
463 | runThis(); | 438 | runThis(); |
464 | break; | 439 | break; |
465 | case Key_G: | 440 | case Key_G: |
466 | { | 441 | { |
467 | currentPathCombo->lineEdit()->setFocus(); | 442 | currentPathCombo->lineEdit()->setFocus(); |
468 | } | 443 | } |
469 | break; | 444 | break; |
470 | 445 | ||
471 | case Key_H: | 446 | case Key_H: |
472 | showHidden(); | 447 | showHidden(); |
473 | break; | 448 | break; |
474 | case Key_I: | 449 | case Key_I: |
475 | fileStatus(); | 450 | fileStatus(); |
476 | break; | 451 | break; |
477 | case Key_M: | 452 | case Key_M: |
478 | move(); | 453 | move(); |
479 | break; | 454 | break; |
480 | case Key_N: | 455 | case Key_N: |
481 | mkDir(); | 456 | mkDir(); |
482 | break; | 457 | break; |
483 | case Key_P: | 458 | case Key_P: |
484 | filePerms(); | 459 | filePerms(); |
485 | break; | 460 | break; |
486 | case Key_R: | 461 | case Key_R: |
487 | rn(); | 462 | rn(); |
488 | break; | 463 | break; |
489 | case Key_U: | 464 | case Key_U: |
490 | upDir(); | 465 | upDir(); |
491 | break; | 466 | break; |
492 | case Key_1: | 467 | case Key_1: |
493 | switchToLocalTab(); | 468 | switchToLocalTab(); |
494 | break; | 469 | break; |
495 | case Key_2: | 470 | case Key_2: |
496 | switchToRemoteTab(); | 471 | switchToRemoteTab(); |
497 | break; | 472 | break; |
498 | case Key_3: | 473 | case Key_3: |
499 | CFButtonPushed(); | 474 | CFButtonPushed(); |
500 | break; | 475 | break; |
501 | case Key_4: | 476 | case Key_4: |
502 | SDButtonPushed(); | 477 | SDButtonPushed(); |
503 | break; | 478 | break; |
504 | case Key_5: | 479 | case Key_5: |
505 | homeButtonPushed(); | 480 | homeButtonPushed(); |
506 | break; | 481 | break; |
507 | case Key_6: | 482 | case Key_6: |
508 | docButtonPushed(); | 483 | docButtonPushed(); |
509 | break; | 484 | break; |
510 | case Key_7: | 485 | case Key_7: |
511 | break; | 486 | break; |
512 | case Key_8: | 487 | case Key_8: |
513 | break; | 488 | break; |
514 | case Key_9: | 489 | case Key_9: |
515 | break; | 490 | break; |
516 | case Key_0: | 491 | case Key_0: |
517 | break; | 492 | break; |
518 | }; | 493 | }; |
519 | e->accept(); | 494 | e->accept(); |
520 | } | 495 | } |
521 | } | 496 | } |
522 | 497 | ||
523 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 498 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
524 | { | 499 | { |
525 | if( CurrentView()->hasFocus() ) | 500 | if( CurrentView()->hasFocus() ) |
526 | e->ignore(); | 501 | e->ignore(); |
527 | } | 502 | } |
528 | 503 | ||
529 | 504 | ||
530 | void AdvancedFm::QPEButtonPushed() | 505 | void AdvancedFm::QPEButtonPushed() |
531 | { | 506 | { |
532 | QString current = QPEApplication::qpeDir(); | 507 | QString current = QPEApplication::qpeDir(); |
533 | chdir( current.latin1() ); | 508 | chdir( current.latin1() ); |
534 | CurrentDir()->cd( current, TRUE); | 509 | CurrentDir()->cd( current, TRUE); |
535 | populateView(); | 510 | populateView(); |
536 | update(); | 511 | update(); |
537 | } | 512 | } |
538 | 513 | ||
539 | void AdvancedFm::parsetab(const QString &fileName) | 514 | void AdvancedFm::parsetab(const QString &fileName) |
540 | { | 515 | { |
541 | 516 | ||
542 | fileSystemTypeList.clear(); | 517 | fileSystemTypeList.clear(); |
543 | fsList.clear(); | 518 | fsList.clear(); |
544 | struct mntent *me; | 519 | struct mntent *me; |
545 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 520 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
546 | if ( mntfp ) | 521 | if ( mntfp ) |
547 | { | 522 | { |
548 | while ( (me = getmntent( mntfp )) != 0 ) | 523 | while ( (me = getmntent( mntfp )) != 0 ) |
549 | { | 524 | { |
550 | QString deviceName = me->mnt_fsname; | 525 | QString deviceName = me->mnt_fsname; |
551 | QString filesystemType = me->mnt_type; | 526 | QString filesystemType = me->mnt_type; |
552 | QString mountDir = me->mnt_dir; | 527 | QString mountDir = me->mnt_dir; |
553 | if(deviceName != "none") | 528 | if(deviceName != "none") |
554 | { | 529 | { |
555 | if( fsList.contains(filesystemType) == 0 | 530 | if( fsList.contains(filesystemType) == 0 |
556 | & filesystemType.find("proc",0,TRUE) == -1 | 531 | & filesystemType.find("proc",0,TRUE) == -1 |
557 | & filesystemType.find("cramfs",0,TRUE) == -1 | 532 | & filesystemType.find("cramfs",0,TRUE) == -1 |
558 | & filesystemType.find("auto",0,TRUE) == -1) | 533 | & filesystemType.find("auto",0,TRUE) == -1) |
559 | fsList << filesystemType; | 534 | fsList << filesystemType; |
560 | fileSystemTypeList << mountDir+"::"+filesystemType; | 535 | fileSystemTypeList << mountDir+"::"+filesystemType; |
561 | } | 536 | } |
562 | } | 537 | } |
563 | } | 538 | } |
564 | endmntent( mntfp ); | 539 | endmntent( mntfp ); |
565 | } | 540 | } |
566 | 541 | ||
567 | QString AdvancedFm::getFileSystemType(const QString ¤tText) | 542 | QString AdvancedFm::getFileSystemType(const QString ¤tText) |
568 | { | 543 | { |
569 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 544 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
570 | QString current = currentText;//.right( currentText.length()-1); | 545 | QString current = currentText;//.right( currentText.length()-1); |
571 | QString baseFs; | 546 | QString baseFs; |
572 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 547 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
573 | QString temp = (*it); | 548 | QString temp = (*it); |
574 | QString path = temp.left(temp.find("::",0,TRUE) ); | 549 | QString path = temp.left(temp.find("::",0,TRUE) ); |
575 | path = path.right( path.length()-1); | 550 | path = path.right( path.length()-1); |
576 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 551 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
577 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 552 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
578 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 553 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
579 | } | 554 | } |
580 | } | 555 | } |
581 | return baseFs; | 556 | return baseFs; |
582 | } | 557 | } |
583 | 558 | ||
584 | QString AdvancedFm::getDiskSpace( const QString &path) | 559 | QString AdvancedFm::getDiskSpace( const QString &path) |
585 | { | 560 | { |
586 | struct statfs fss; | 561 | struct statfs fss; |
587 | if ( !statfs( path.latin1(), &fss ) ) { | 562 | if ( !statfs( path.latin1(), &fss ) ) { |
588 | int blkSize = fss.f_bsize; | 563 | int blkSize = fss.f_bsize; |
589 | // int totalBlks = fs.f_blocks; | 564 | // int totalBlks = fs.f_blocks; |
590 | int availBlks = fss.f_bavail; | 565 | int availBlks = fss.f_bavail; |
591 | 566 | ||
592 | long mult = blkSize / 1024; | 567 | long mult = blkSize / 1024; |
593 | long div = 1024 / blkSize; | 568 | long div = 1024 / blkSize; |
594 | if ( !mult ) mult = 1; | 569 | if ( !mult ) mult = 1; |
595 | if ( !div ) div = 1; | 570 | if ( !div ) div = 1; |
596 | 571 | ||
597 | return QString::number(availBlks * mult / div); | 572 | return QString::number(availBlks * mult / div); |
598 | } | 573 | } |
599 | return ""; | 574 | return ""; |
600 | } | 575 | } |
601 | 576 | ||
602 | 577 | ||
603 | void AdvancedFm::showFileMenu() | 578 | void AdvancedFm::showFileMenu() |
604 | { | 579 | { |
605 | QString curApp; | 580 | QString curApp; |
606 | curApp = CurrentView()->currentItem()->text(0); | 581 | curApp = CurrentView()->currentItem()->text(0); |
607 | 582 | ||
608 | MimeType mt( curApp ); | 583 | MimeType mt( curApp ); |
609 | const AppLnk* app = mt.application(); | 584 | const AppLnk* app = mt.application(); |
610 | QFile fi(curApp); | 585 | QFile fi(curApp); |
611 | QPopupMenu *m = new QPopupMenu(0); | 586 | QPopupMenu *m = new QPopupMenu(0); |
612 | QPopupMenu *n = new QPopupMenu(0); | 587 | QPopupMenu *n = new QPopupMenu(0); |
613 | // QPopupMenu *o = new QPopupMenu(0); | 588 | // QPopupMenu *o = new QPopupMenu(0); |
614 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 589 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
615 | 590 | ||
616 | if ( QFileInfo(fi).isDir() ) | 591 | if ( QFileInfo(fi).isDir() ) |
617 | { | 592 | { |
618 | m->insertSeparator(); | 593 | m->insertSeparator(); |
619 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); | 594 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); |
620 | } | 595 | } |
621 | else | 596 | else |
622 | { | 597 | { |
623 | 598 | ||
624 | if ( app ) | 599 | if ( app ) |
625 | m->insertItem( app->pixmap(), tr( "Open in " | 600 | m->insertItem( app->pixmap(), tr( "Open in " |
626 | + app->name() ), this, SLOT( runThis() ) ); | 601 | + app->name() ), this, SLOT( runThis() ) ); |
627 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 602 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
628 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 603 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
629 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 604 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
630 | } | 605 | } |
631 | 606 | ||
632 | m->insertItem(tr("Actions"),n); | 607 | m->insertItem(tr("Actions"),n); |
633 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); | 608 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); |
634 | 609 | ||
635 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 610 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
636 | 611 | ||
637 | n->insertSeparator(); | 612 | n->insertSeparator(); |
638 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); | 613 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); |
639 | 614 | ||
640 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 615 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
641 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 616 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
642 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 617 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
643 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 618 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
644 | 619 | ||
645 | n->insertSeparator(); | 620 | n->insertSeparator(); |
646 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); | 621 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); |
647 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 622 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
648 | 623 | ||
649 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 624 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
650 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 625 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
651 | 626 | ||
652 | m->insertSeparator(); | 627 | m->insertSeparator(); |
653 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 628 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
654 | 629 | ||
655 | #if defined(QT_QWS_OPIE) | 630 | #if defined(QT_QWS_OPIE) |
656 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 631 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
657 | #endif | 632 | #endif |
658 | m->setCheckable(TRUE); | 633 | m->setCheckable(TRUE); |
659 | if (!b) | 634 | if (!b) |
660 | m->setItemChecked(m->idAt(0),TRUE); | 635 | m->setItemChecked(m->idAt(0),TRUE); |
661 | else | 636 | else |
662 | m->setItemChecked(m->idAt(0),FALSE); | 637 | m->setItemChecked(m->idAt(0),FALSE); |
663 | 638 | ||
664 | if(Ir::supported()) | 639 | if(Ir::supported()) |
665 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 640 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
666 | m->setFocus(); | 641 | m->setFocus(); |
667 | m->exec( QPoint( 4,QCursor::pos().y()) ); | 642 | m->exec( QPoint( 4,QCursor::pos().y()) ); |
668 | 643 | ||
669 | if(m) delete m; | 644 | if(m) delete m; |
670 | } | 645 | } |
671 | 646 | ||
672 | 647 | ||
673 | void AdvancedFm::cancelMenuTimer() | 648 | void AdvancedFm::cancelMenuTimer() |
674 | { | 649 | { |
675 | // qDebug("selectionChanged: cancel menu timer"); | 650 | // qDebug("selectionChanged: cancel menu timer"); |
676 | if( menuTimer.isActive() ) | 651 | if( menuTimer.isActive() ) |
677 | menuTimer.stop(); | 652 | menuTimer.stop(); |
678 | } | 653 | } |
679 | 654 | ||
680 | QString AdvancedFm::checkDiskSpace(const QString &path) | 655 | QString AdvancedFm::checkDiskSpace(const QString &path) |
681 | { | 656 | { |
682 | struct statfs fss; | 657 | struct statfs fss; |
683 | if ( !statfs( path.latin1(), &fss ) ) | 658 | if ( !statfs( path.latin1(), &fss ) ) |
684 | { | 659 | { |
685 | int blkSize = fss.f_bsize; | 660 | int blkSize = fss.f_bsize; |
686 | // int totalBlks = fs.f_blocks; | 661 | // int totalBlks = fs.f_blocks; |
687 | int availBlks = fss.f_bavail; | 662 | int availBlks = fss.f_bavail; |
688 | 663 | ||
689 | long mult = blkSize / 1024; | 664 | long mult = blkSize / 1024; |
690 | long div = 1024 / blkSize; | 665 | long div = 1024 / blkSize; |
691 | if ( !mult ) mult = 1; | 666 | if ( !mult ) mult = 1; |
692 | if ( !div ) div = 1; | 667 | if ( !div ) div = 1; |
693 | 668 | ||
694 | 669 | ||
695 | return QString::number(availBlks * mult / div); | 670 | return QString::number(availBlks * mult / div); |
696 | } | 671 | } |
697 | return ""; | 672 | return ""; |
698 | } | 673 | } |
699 | 674 | ||
700 | void AdvancedFm::addToDocs() | 675 | void AdvancedFm::addToDocs() |
701 | { | 676 | { |
702 | QStringList strListPaths = getPath(); | 677 | QStringList strListPaths = getPath(); |
703 | QDir *thisDir = CurrentDir(); | 678 | QDir *thisDir = CurrentDir(); |
704 | 679 | ||
705 | if( strListPaths.count() > 0) | 680 | if( strListPaths.count() > 0) |
706 | { | 681 | { |
707 | QString curFile; | 682 | QString curFile; |
708 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) | 683 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) |
709 | { | 684 | { |
710 | curFile = thisDir->canonicalPath()+"/"+(*it); | 685 | curFile = thisDir->canonicalPath()+"/"+(*it); |
711 | // qDebug(curFile); | 686 | // qDebug(curFile); |
712 | DocLnk f; | 687 | DocLnk f; |
713 | // curFile.replace(QRegExp("\\..*"),""); | 688 | // curFile.replace(QRegExp("\\..*"),""); |
714 | f.setName((*it)); | 689 | f.setName((*it)); |
715 | f.setFile( curFile); | 690 | f.setFile( curFile); |
716 | f.writeLink(); | 691 | f.writeLink(); |
717 | } | 692 | } |
718 | } | 693 | } |
719 | } | 694 | } |
720 | 695 | ||
721 | 696 | ||
722 | void AdvancedFm::customDirsToMenu() | 697 | void AdvancedFm::customDirsToMenu() |
723 | { | 698 | { |
724 | 699 | ||
725 | Config cfg("AdvancedFm"); | 700 | Config cfg("AdvancedFm"); |
726 | cfg.setGroup("Menu"); | 701 | cfg.setGroup("Menu"); |
727 | 702 | ||
728 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 703 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
729 | menuButton->insertItems(list ); | 704 | menuButton->insertItems(list ); |
730 | 705 | ||
731 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 706 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
732 | // { | 707 | // { |
733 | // customDirMenu->insertItem(*it ); | 708 | // customDirMenu->insertItem(*it ); |
734 | // } | 709 | // } |
735 | } | 710 | } |
736 | 711 | ||
737 | void AdvancedFm::dirMenuSelected(int item) | 712 | void AdvancedFm::dirMenuSelected(int item) |
738 | { | 713 | { |
739 | qDebug("menu item %d", item); | 714 | qDebug("menu item %d", item); |
740 | switch(item) | 715 | switch(item) |
741 | { | 716 | { |
742 | 717 | ||
743 | case -21: | 718 | case -21: |
744 | case 0: | 719 | case 0: |
745 | addCustomDir(); | 720 | addCustomDir(); |
746 | break; | 721 | break; |
747 | case -22: | 722 | case -22: |
748 | case 1: | 723 | case 1: |
749 | removeCustomDir(); | 724 | removeCustomDir(); |
750 | break; | 725 | break; |
751 | default: | 726 | default: |
752 | { | 727 | { |
753 | // gotoCustomDir( menuButton->text(item)); | 728 | // gotoCustomDir( menuButton->text(item)); |
754 | // gotoCustomDir( customDirMenu->text(item)); | 729 | // gotoCustomDir( customDirMenu->text(item)); |
755 | } | 730 | } |
756 | break; | 731 | break; |
757 | 732 | ||
758 | }; | 733 | }; |
759 | } | 734 | } |
760 | 735 | ||
761 | void AdvancedFm::addCustomDir() | 736 | void AdvancedFm::addCustomDir() |
762 | { | 737 | { |
763 | Config cfg("AdvancedFm"); | 738 | Config cfg("AdvancedFm"); |
764 | cfg.setGroup("Menu"); | 739 | cfg.setGroup("Menu"); |
765 | QString dir; | 740 | QString dir; |
766 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 741 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
767 | 742 | ||
768 | dir = CurrentDir()->canonicalPath(); | 743 | dir = CurrentDir()->canonicalPath(); |
769 | 744 | ||
770 | bool addIt=true; | 745 | bool addIt=true; |
771 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 746 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
772 | { | 747 | { |
773 | if( dir == (*it)) | 748 | if( dir == (*it)) |
774 | { | 749 | { |
775 | addIt=false; | 750 | addIt=false; |
776 | } | 751 | } |
777 | } | 752 | } |
778 | if(addIt) | 753 | if(addIt) |
779 | { | 754 | { |
780 | menuButton->insertItem(dir); | 755 | menuButton->insertItem(dir); |
781 | // customDirMenu->insertItem(dir); | 756 | // customDirMenu->insertItem(dir); |
782 | list << dir; | 757 | list << dir; |
783 | } | 758 | } |
784 | 759 | ||
785 | cfg.writeEntry("CustomDir", list, ','); | 760 | cfg.writeEntry("CustomDir", list, ','); |
786 | cfg.write(); | 761 | cfg.write(); |
787 | } | 762 | } |
788 | 763 | ||
789 | void AdvancedFm::removeCustomDir() | 764 | void AdvancedFm::removeCustomDir() |
790 | { | 765 | { |
791 | // qDebug("remove custom dir"); | 766 | // qDebug("remove custom dir"); |
792 | Config cfg("AdvancedFm"); | 767 | Config cfg("AdvancedFm"); |
793 | cfg.setGroup("Menu"); | 768 | cfg.setGroup("Menu"); |
794 | QString dir; | 769 | QString dir; |
795 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 770 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
796 | QStringList list2; | 771 | QStringList list2; |
797 | dir = CurrentDir()->canonicalPath(); | 772 | dir = CurrentDir()->canonicalPath(); |
798 | int ramble=2; | 773 | int ramble=2; |
799 | // int ramble=-24; | 774 | // int ramble=-24; |
800 | //first remove list | 775 | //first remove list |
801 | if(list.grep(dir,true).isEmpty()) | 776 | if(list.grep(dir,true).isEmpty()) |
802 | { | 777 | { |
803 | QMessageBox::message("AdvancedFm", | 778 | QMessageBox::message("AdvancedFm", |
804 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); | 779 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); |
805 | } | 780 | } |
806 | else | 781 | else |
807 | { | 782 | { |
808 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 783 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
809 | { | 784 | { |
810 | if((*it) != dir)//current item is not our current dir, so add it to temp list | 785 | if((*it) != dir)//current item is not our current dir, so add it to temp list |
811 | { | 786 | { |
812 | list2 <<(*it); | 787 | list2 <<(*it); |
813 | } | 788 | } |
814 | else | 789 | else |
815 | { | 790 | { |
816 | // customDirMenu->removeItem( ramble); | 791 | // customDirMenu->removeItem( ramble); |
817 | menuButton->remove( ramble); | 792 | menuButton->remove( ramble); |
818 | 793 | ||
819 | } | 794 | } |
820 | ramble++; | 795 | ramble++; |
821 | // ramble--; | 796 | // ramble--; |
822 | } | 797 | } |
823 | 798 | ||
824 | cfg.writeEntry("CustomDir", list2, ','); | 799 | cfg.writeEntry("CustomDir", list2, ','); |
825 | cfg.write(); | 800 | cfg.write(); |
826 | } | 801 | } |
827 | // customDirsToMenu(); | 802 | // customDirsToMenu(); |
828 | 803 | ||
829 | } | 804 | } |
830 | 805 | ||
831 | void AdvancedFm::gotoCustomDir(const QString &dir) | 806 | void AdvancedFm::gotoCustomDir(const QString &dir) |
832 | { | 807 | { |
833 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); | 808 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); |
834 | QString curDir = dir; | 809 | QString curDir = dir; |
835 | QDir *thisDir = CurrentDir(); | 810 | QDir *thisDir = CurrentDir(); |
836 | // if( curDir.isEmpty()) { | 811 | // if( curDir.isEmpty()) { |
837 | // } | 812 | // } |
838 | if( curDir == s_addBookmark) | 813 | if( curDir == s_addBookmark) |
839 | { | 814 | { |
840 | addCustomDir(); | 815 | addCustomDir(); |
841 | } | 816 | } |
842 | if( curDir == s_removeBookmark) | 817 | if( curDir == s_removeBookmark) |
843 | { | 818 | { |
844 | removeCustomDir( ); | 819 | removeCustomDir( ); |
845 | } | 820 | } |
846 | else | 821 | else |
847 | { | 822 | { |
848 | if(QDir( curDir).exists() ) | 823 | if(QDir( curDir).exists() ) |
849 | { | 824 | { |
850 | thisDir->setPath( curDir ); | 825 | thisDir->setPath( curDir ); |
851 | chdir( curDir.latin1() ); | 826 | chdir( curDir.latin1() ); |
852 | thisDir->cd( curDir, TRUE); | 827 | thisDir->cd( curDir, TRUE); |
853 | populateView(); | 828 | populateView(); |
854 | } | 829 | } |
855 | } | 830 | } |
856 | } | 831 | } |
857 | 832 | ||
858 | QDir *AdvancedFm::CurrentDir() | 833 | QDir *AdvancedFm::CurrentDir() |
859 | { | 834 | { |
860 | if ( whichTab == 1) | 835 | if ( whichTab == 1) |
861 | { | 836 | { |
862 | return ¤tDir; | 837 | return ¤tDir; |
863 | } | 838 | } |
864 | else | 839 | else |
865 | { | 840 | { |
866 | return ¤tRemoteDir; | 841 | return ¤tRemoteDir; |
867 | } | 842 | } |
868 | } | 843 | } |
869 | 844 | ||
870 | QDir *AdvancedFm::OtherDir() | 845 | QDir *AdvancedFm::OtherDir() |
871 | { | 846 | { |
872 | if ( whichTab == 1) | 847 | if ( whichTab == 1) |
873 | { | 848 | { |
874 | return ¤tRemoteDir; | 849 | return ¤tRemoteDir; |
875 | } | 850 | } |
876 | else | 851 | else |
877 | { | 852 | { |
878 | return ¤tDir; | 853 | return ¤tDir; |
879 | } | 854 | } |
880 | } | 855 | } |
881 | 856 | ||
882 | QListView * AdvancedFm::CurrentView() | 857 | QListView * AdvancedFm::CurrentView() |
883 | { | 858 | { |
884 | if ( whichTab == 1) | 859 | if ( whichTab == 1) |
885 | return Local_View; | 860 | return Local_View; |
886 | else | 861 | else |
887 | return Remote_View; | 862 | return Remote_View; |
888 | } | 863 | } |
889 | 864 | ||
890 | QListView * AdvancedFm::OtherView() | 865 | QListView * AdvancedFm::OtherView() |
891 | { | 866 | { |
892 | if ( whichTab == 1) | 867 | if ( whichTab == 1) |
893 | return Remote_View; | 868 | return Remote_View; |
894 | else | 869 | else |
895 | return Local_View; | 870 | return Local_View; |
896 | } | 871 | } |
897 | 872 | ||
898 | void AdvancedFm::setOtherTabCurrent() | 873 | void AdvancedFm::setOtherTabCurrent() |
899 | { | 874 | { |
900 | if ( whichTab == 1) | 875 | if ( whichTab == 1) |
901 | TabWidget->setCurrentTab(1); | 876 | TabWidget->setCurrentTab(1); |
902 | else | 877 | else |
903 | TabWidget->setCurrentTab(0); | 878 | TabWidget->setCurrentTab(0); |
904 | } | 879 | } |
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index c30d8e0..4480051 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -1,174 +1,171 @@ | |||
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 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties |
15 | #define QT_QWS_OPIE | 15 | #define QT_QWS_OPIE |
16 | 16 | ||
17 | //#include <opie/otabwidget.h> | 17 | //#include <opie/otabwidget.h> |
18 | #include <opie/oprocess.h> | 18 | #include <opie/oprocess.h> |
19 | #include <qpe/ir.h> | 19 | #include <qpe/ir.h> |
20 | 20 | ||
21 | #include <qvariant.h> | 21 | #include <qvariant.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qstringlist.h> | 24 | #include <qstringlist.h> |
25 | #include <qdir.h> | 25 | #include <qdir.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
30 | 30 | ||
31 | class OTabWidget; | 31 | class OTabWidget; |
32 | class QVBoxLayout; | 32 | class QVBoxLayout; |
33 | class QHBoxLayout; | 33 | class QHBoxLayout; |
34 | class QGridLayout; | 34 | class QGridLayout; |
35 | class QComboBox; | 35 | class QComboBox; |
36 | class QListView; | 36 | class QListView; |
37 | class QListviewItem; | 37 | class QListviewItem; |
38 | class QLabel; | 38 | class QLabel; |
39 | class QProgressBar; | 39 | class QProgressBar; |
40 | class QSpinBox; | 40 | class QSpinBox; |
41 | class QTabWidget; | 41 | class QTabWidget; |
42 | class QWidget; | 42 | class QWidget; |
43 | class QPEToolBar; | ||
44 | class QPEMenuBar; | ||
45 | class QPopupMenu; | 43 | class QPopupMenu; |
46 | class QFile; | 44 | class QFile; |
47 | class QListViewItem; | 45 | class QListViewItem; |
48 | class QLineEdit; | 46 | class QLineEdit; |
49 | class MenuButton; | 47 | class MenuButton; |
50 | 48 | ||
51 | //class QPushButton; | ||
52 | class QToolButton; | 49 | class QToolButton; |
53 | class Ir; | 50 | class Ir; |
54 | 51 | ||
55 | class AdvancedFm : public QMainWindow | 52 | class AdvancedFm : public QMainWindow |
56 | { | 53 | { |
57 | Q_OBJECT | 54 | Q_OBJECT |
58 | public: | 55 | public: |
59 | AdvancedFm(); | 56 | AdvancedFm(); |
60 | ~AdvancedFm(); | 57 | ~AdvancedFm(); |
61 | protected slots: | 58 | protected slots: |
62 | void selectAll(); | 59 | void selectAll(); |
63 | void addToDocs(); | 60 | void addToDocs(); |
64 | void doDirChange(); | 61 | void doDirChange(); |
65 | void mkDir(); | 62 | void mkDir(); |
66 | void del(); | 63 | void del(); |
67 | void rn(); | 64 | void rn(); |
68 | void populateView(); | 65 | void populateView(); |
69 | void rePopulate(); | 66 | void rePopulate(); |
70 | void showHidden(); | 67 | void showHidden(); |
71 | void showMenuHidden(); | 68 | void showMenuHidden(); |
72 | void writeConfig(); | 69 | void writeConfig(); |
73 | void readConfig(); | 70 | void readConfig(); |
74 | void ListClicked(QListViewItem *); | 71 | void ListClicked(QListViewItem *); |
75 | void ListPressed( int, QListViewItem *, const QPoint&, int); | 72 | void ListPressed( int, QListViewItem *, const QPoint&, int); |
76 | void makeDir(); | 73 | void makeDir(); |
77 | void doDelete(); | 74 | void doDelete(); |
78 | void tabChanged(QWidget*); | 75 | void tabChanged(QWidget*); |
79 | void cleanUp(); | 76 | void cleanUp(); |
80 | void renameIt(); | 77 | void renameIt(); |
81 | void runThis(); | 78 | void runThis(); |
82 | void runText(); | 79 | void runText(); |
83 | void filePerms(); | 80 | void filePerms(); |
84 | void doProperties(); | 81 | void doProperties(); |
85 | void runCommand(); | 82 | void runCommand(); |
86 | void runCommandStd(); | 83 | void runCommandStd(); |
87 | QStringList getPath(); | 84 | QStringList getPath(); |
88 | void mkSym(); | 85 | void mkSym(); |
89 | void switchToLocalTab(); | 86 | void switchToLocalTab(); |
90 | void switchToRemoteTab(); | 87 | void switchToRemoteTab(); |
91 | 88 | ||
92 | protected: | 89 | protected: |
93 | 90 | ||
94 | OTabWidget *TabWidget; | 91 | OTabWidget *TabWidget; |
95 | QPixmap unknownXpm; | 92 | QPixmap unknownXpm; |
96 | int whichTab; | 93 | int whichTab; |
97 | // QTabWidget *TabWidget; | 94 | // QTabWidget *TabWidget; |
98 | QWidget *tab, *tab_2, *tab_3; | 95 | QWidget *tab, *tab_2, *tab_3; |
99 | QListView *Local_View, *Remote_View; | 96 | QListView *Local_View, *Remote_View; |
100 | 97 | ||
101 | QLineEdit *currentPathEdit; | 98 | QLineEdit *currentPathEdit; |
102 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; | 99 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; |
103 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 100 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
104 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 101 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
105 | QDir currentDir, currentRemoteDir; | 102 | QDir currentDir, currentRemoteDir; |
106 | QComboBox *currentPathCombo; | 103 | QComboBox *currentPathCombo; |
107 | QString filterStr, s_addBookmark, s_removeBookmark; | 104 | QString filterStr, s_addBookmark, s_removeBookmark; |
108 | QListViewItem * item; | 105 | QListViewItem * item; |
109 | bool b; | 106 | bool b; |
110 | QStringList fileSystemTypeList, fsList; | 107 | QStringList fileSystemTypeList, fsList; |
111 | int currentServerConfig; | 108 | int currentServerConfig; |
112 | bool zaurusDevice; | 109 | bool zaurusDevice; |
113 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; | 110 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; |
114 | QStringList remoteDirPathStringList, localDirPathStringList; | 111 | QStringList remoteDirPathStringList, localDirPathStringList; |
115 | QLineEdit *renameBox; | 112 | QLineEdit *renameBox; |
116 | 113 | ||
117 | void init(); | 114 | void init(); |
118 | void initConnections(); | 115 | void initConnections(); |
119 | void keyReleaseEvent( QKeyEvent *); | 116 | void keyReleaseEvent( QKeyEvent *); |
120 | void keyPressEvent( QKeyEvent *); | 117 | void keyPressEvent( QKeyEvent *); |
121 | QString getFileSystemType(const QString &); | 118 | QString getFileSystemType(const QString &); |
122 | QString getDiskSpace(const QString &); | 119 | QString getDiskSpace(const QString &); |
123 | void parsetab(const QString &fileName); | 120 | void parsetab(const QString &fileName); |
124 | QString checkDiskSpace(const QString &); | 121 | QString checkDiskSpace(const QString &); |
125 | QString dealWithSymName(const QString &); | 122 | QString dealWithSymName(const QString &); |
126 | QDir *CurrentDir(); | 123 | QDir *CurrentDir(); |
127 | QDir *OtherDir(); | 124 | QDir *OtherDir(); |
128 | QListView *CurrentView(); | 125 | QListView *CurrentView(); |
129 | QListView *OtherView(); | 126 | QListView *OtherView(); |
130 | void setOtherTabCurrent(); | 127 | void setOtherTabCurrent(); |
131 | 128 | ||
132 | protected slots: | 129 | protected slots: |
133 | void dirMenuSelected(int); | 130 | void dirMenuSelected(int); |
134 | void showFileMenu(); | 131 | void showFileMenu(); |
135 | void cancelMenuTimer(); | 132 | void cancelMenuTimer(); |
136 | void homeButtonPushed(); | 133 | void homeButtonPushed(); |
137 | void docButtonPushed(); | 134 | void docButtonPushed(); |
138 | void SDButtonPushed(); | 135 | void SDButtonPushed(); |
139 | void CFButtonPushed(); | 136 | void CFButtonPushed(); |
140 | void QPEButtonPushed(); | 137 | void QPEButtonPushed(); |
141 | void upDir(); | 138 | void upDir(); |
142 | void currentPathComboChanged(); | 139 | void currentPathComboChanged(); |
143 | void copy(); | 140 | void copy(); |
144 | void copyAs(); | 141 | void copyAs(); |
145 | void copySameDir(); | 142 | void copySameDir(); |
146 | void currentPathComboActivated(const QString &); | 143 | void currentPathComboActivated(const QString &); |
147 | void fillCombo(const QString &); | 144 | void fillCombo(const QString &); |
148 | bool copyFile( const QString & , const QString & ); | 145 | bool copyFile( const QString & , const QString & ); |
149 | void move(); | 146 | void move(); |
150 | void fileStatus(); | 147 | void fileStatus(); |
151 | void doAbout(); | 148 | void doAbout(); |
152 | void doBeam(); | 149 | void doBeam(); |
153 | void fileBeamFinished( Ir *); | 150 | void fileBeamFinished( Ir *); |
154 | 151 | ||
155 | private: | 152 | private: |
156 | MenuButton *menuButton; | 153 | MenuButton *menuButton; |
157 | QString oldName; | 154 | QString oldName; |
158 | QTimer menuTimer; | 155 | QTimer menuTimer; |
159 | void startProcess(const QString &); | 156 | void startProcess(const QString &); |
160 | bool eventFilter( QObject * , QEvent * ); | 157 | bool eventFilter( QObject * , QEvent * ); |
161 | void cancelRename(); | 158 | void cancelRename(); |
162 | void doRename(QListView *); | 159 | void doRename(QListView *); |
163 | void okRename(); | 160 | void okRename(); |
164 | void customDirsToMenu(); | 161 | void customDirsToMenu(); |
165 | void addCustomDir(); | 162 | void addCustomDir(); |
166 | void removeCustomDir(); | 163 | void removeCustomDir(); |
167 | 164 | ||
168 | private slots: | 165 | private slots: |
169 | void processEnded(OProcess *); | 166 | void processEnded(OProcess *); |
170 | void oprocessStderr(OProcess *, char *, int); | 167 | void oprocessStderr(OProcess *, char *, int); |
171 | void gotoCustomDir(const QString &); | 168 | void gotoCustomDir(const QString &); |
172 | }; | 169 | }; |
173 | 170 | ||
174 | #endif // ADVANCEDFM_H | 171 | #endif // ADVANCEDFM_H |
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index 1a7a6d7..eb2bcd8 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -1,278 +1,272 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfmData.cpp | 2 | advancedfmData.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Mon 09-23-2002 13:24:11 | 4 | ** Created: Mon 09-23-2002 13:24:11 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | 13 | ||
14 | #include <opie/otabwidget.h> | 14 | #include <opie/otabwidget.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/qpemenubar.h> | ||
17 | #include <qpe/qpetoolbar.h> | ||
18 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
19 | #include <qpe/menubutton.h> | 17 | #include <qpe/menubutton.h> |
20 | #include <qpe/config.h> | ||
21 | 18 | ||
22 | #include <qlayout.h> | 19 | #include <qlayout.h> |
23 | #include <qpixmap.h> | 20 | #include <qhbox.h> |
21 | #include <qmenubar.h> | ||
24 | #include <qcombobox.h> | 22 | #include <qcombobox.h> |
25 | #include <qpopupmenu.h> | ||
26 | #include <qtabwidget.h> | ||
27 | #include <qtoolbutton.h> | 23 | #include <qtoolbutton.h> |
28 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
29 | #include <qlistview.h> | 25 | #include <qlistview.h> |
30 | 26 | ||
31 | #include <sys/utsname.h> | 27 | #include <sys/utsname.h> |
32 | 28 | ||
33 | 29 | ||
34 | void AdvancedFm::init() { | 30 | void AdvancedFm::init() { |
35 | #if defined(QT_QWS_OPIE) | 31 | #if defined(QT_QWS_OPIE) |
36 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); | 32 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); |
37 | #endif | 33 | #endif |
38 | setCaption( tr( "AdvancedFm" ) ); | 34 | setCaption( tr( "AdvancedFm" ) ); |
39 | 35 | ||
40 | QGridLayout *layout = new QGridLayout( this ); | 36 | QVBoxLayout *layout = new QVBoxLayout( this ); |
41 | layout->setSpacing( 2); | 37 | layout->setSpacing( 2); |
42 | layout->setMargin( 2); | 38 | layout->setMargin( 2); |
43 | 39 | ||
44 | 40 | ||
45 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 41 | QMenuBar *menuBar = new QMenuBar(this); |
46 | fileMenu = new QPopupMenu( this ); | 42 | fileMenu = new QPopupMenu( this ); |
47 | viewMenu = new QPopupMenu( this ); | 43 | viewMenu = new QPopupMenu( this ); |
48 | // customDirMenu = new QPopupMenu( this ); | 44 | // customDirMenu = new QPopupMenu( this ); |
49 | 45 | ||
50 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); | 46 | layout->addWidget( menuBar ); |
51 | 47 | ||
52 | menuBar->insertItem( tr( "File" ), fileMenu); | 48 | menuBar->insertItem( tr( "File" ), fileMenu); |
53 | menuBar->insertItem( tr( "View" ), viewMenu); | 49 | menuBar->insertItem( tr( "View" ), viewMenu); |
54 | // menuBar->insertItem( tr( "^" ), customDirMenu); | ||
55 | 50 | ||
56 | cdUpButton = new QToolButton( this,"cdUpButton"); | 51 | cdUpButton = new QToolButton( 0,"cdUpButton"); |
57 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 52 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
58 | cdUpButton->setFixedSize( QSize( 20, 20 ) ); | 53 | cdUpButton->setAutoRaise( true ); |
59 | layout->addMultiCellWidget( cdUpButton , 0, 0, 2, 2); | 54 | menuBar->insertItem( cdUpButton ); |
60 | 55 | ||
61 | menuButton = new MenuButton(this); | ||
62 | menuButton->setFixedSize( QSize( 20, 20 ) ); | ||
63 | layout->addMultiCellWidget( menuButton , 0, 0, 3, 3); | ||
64 | 56 | ||
65 | qpeDirButton= new QToolButton(this,"QPEButton"); | 57 | QHBox *lineBox = new QHBox( this ); |
58 | |||
59 | qpeDirButton= new QToolButton( 0,"QPEButton"); | ||
66 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); | 60 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); |
67 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); | 61 | qpeDirButton->setAutoRaise( true ); |
68 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 4, 4); | 62 | menuBar->insertItem( qpeDirButton ); |
69 | 63 | ||
70 | cfButton = new QToolButton( this,"CFButton"); | 64 | cfButton = new QToolButton( 0, "CFButton"); |
71 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); | 65 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); |
72 | cfButton ->setFixedSize( QSize( 20, 20 ) ); | 66 | cfButton->setAutoRaise( true ); |
73 | layout->addMultiCellWidget( cfButton , 0, 0, 5, 5); | 67 | menuBar->insertItem( cfButton ); |
74 | 68 | ||
75 | sdButton = new QToolButton( this,"SDButton"); | 69 | sdButton = new QToolButton( 0, "SDButton"); |
76 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); | 70 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); |
77 | sdButton->setFixedSize( QSize( 20, 20 ) ); | 71 | sdButton->setAutoRaise( true ); |
78 | layout->addMultiCellWidget( sdButton , 0, 0, 6, 6); | 72 | menuBar->insertItem( sdButton ); |
79 | |||
80 | 73 | ||
81 | docButton = new QToolButton( this,"docsButton"); | 74 | docButton = new QToolButton( 0,"docsButton"); |
82 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); | 75 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); |
83 | docButton->setFixedSize( QSize( 20, 20 ) ); | 76 | docButton->setAutoRaise( true ); |
84 | layout->addMultiCellWidget( docButton, 0, 0, 7, 7); | 77 | menuBar->insertItem( docButton ); |
85 | 78 | ||
86 | homeButton = new QToolButton( this,"homeButton"); | 79 | homeButton = new QToolButton( 0, "homeButton"); |
87 | homeButton->setPixmap(Resource::loadPixmap("home")); | 80 | homeButton->setPixmap(Resource::loadPixmap("home")); |
88 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 81 | homeButton->setAutoRaise( true ); |
89 | layout->addMultiCellWidget( homeButton, 0, 0, 8, 8); | 82 | menuBar->insertItem( homeButton ); |
90 | 83 | ||
91 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); | 84 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); |
92 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 85 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
93 | fileMenu->insertSeparator(); | 86 | fileMenu->insertSeparator(); |
94 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 87 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
95 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 88 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
96 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 89 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
97 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 90 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
98 | fileMenu->insertSeparator(); | 91 | fileMenu->insertSeparator(); |
99 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 92 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
100 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); | 93 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); |
101 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 94 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
102 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 95 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
103 | fileMenu->setCheckable(TRUE); | 96 | fileMenu->setCheckable(TRUE); |
104 | 97 | ||
105 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 98 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
106 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 99 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
107 | // viewMenu->insertSeparator(); | 100 | // viewMenu->insertSeparator(); |
108 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 101 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
109 | viewMenu->setCheckable(TRUE); | 102 | viewMenu->setCheckable(TRUE); |
110 | 103 | ||
111 | s_addBookmark = tr("Bookmark Directory"); | 104 | s_addBookmark = tr("Bookmark Directory"); |
112 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); | 105 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); |
113 | 106 | ||
114 | menuButton->setUseLabel(false); | ||
115 | menuButton->insertItem( s_addBookmark); | ||
116 | menuButton->insertItem( s_removeBookmark); | ||
117 | menuButton->insertSeparator(); | ||
118 | // menuButton->insertItem(""); | 107 | // menuButton->insertItem(""); |
119 | 108 | ||
120 | // customDirMenu->insertItem(tr("Add This Directory")); | 109 | // customDirMenu->insertItem(tr("Add This Directory")); |
121 | // customDirMenu->insertItem(tr("Remove This Directory")); | 110 | // customDirMenu->insertItem(tr("Remove This Directory")); |
122 | // customDirMenu->insertSeparator(); | 111 | // customDirMenu->insertSeparator(); |
123 | 112 | ||
124 | customDirsToMenu(); | 113 | customDirsToMenu(); |
125 | 114 | ||
126 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 115 | menuButton = new MenuButton( lineBox ); |
127 | currentPathCombo->setEditable(TRUE); | ||
128 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 8); | ||
129 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | ||
130 | 116 | ||
117 | menuButton->setUseLabel(false); | ||
118 | menuButton->setMaximumWidth( 20 ); | ||
119 | menuButton->insertItem( s_addBookmark); | ||
120 | menuButton->insertItem( s_removeBookmark); | ||
121 | menuButton->insertSeparator(); | ||
122 | |||
123 | currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" ); | ||
124 | currentPathCombo->setEditable(TRUE); | ||
131 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 125 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
132 | 126 | ||
133 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 8); | 127 | layout->addWidget( lineBox ); |
134 | 128 | ||
135 | 129 | ||
136 | TabWidget = new OTabWidget( this, "TabWidget",/* OTabWidget::Global | */OTabWidget::IconTab); | 130 | TabWidget = new OTabWidget( this, "TabWidget",/* OTabWidget::Global | */OTabWidget::IconTab); |
137 | // TabWidget = new QTabWidget( this, "TabWidget" ); | 131 | // TabWidget = new QTabWidget( this, "TabWidget" ); |
138 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 8); | 132 | layout->addWidget( TabWidget, 4 ); |
139 | 133 | ||
140 | tab = new QWidget( TabWidget, "tab" ); | 134 | tab = new QWidget( TabWidget, "tab" ); |
141 | tabLayout = new QGridLayout( tab ); | 135 | tabLayout = new QGridLayout( tab ); |
142 | tabLayout->setSpacing( 2); | 136 | tabLayout->setSpacing( 2); |
143 | tabLayout->setMargin( 2); | 137 | tabLayout->setMargin( 2); |
144 | 138 | ||
145 | Local_View = new QListView( tab, "Local_View" ); | 139 | Local_View = new QListView( tab, "Local_View" ); |
146 | Local_View->addColumn( tr("File"),130); | 140 | Local_View->addColumn( tr("File"),130); |
147 | Local_View->addColumn( tr("Size"),-1); | 141 | Local_View->addColumn( tr("Size"),-1); |
148 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 142 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
149 | Local_View->addColumn( tr("Date"),-1); | 143 | Local_View->addColumn( tr("Date"),-1); |
150 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 144 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
151 | Local_View->setAllColumnsShowFocus(TRUE); | 145 | Local_View->setAllColumnsShowFocus(TRUE); |
152 | Local_View->setMultiSelection( TRUE ); | 146 | Local_View->setMultiSelection( TRUE ); |
153 | Local_View->setSelectionMode(QListView::Extended); | 147 | Local_View->setSelectionMode(QListView::Extended); |
154 | 148 | ||
155 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 149 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
156 | 150 | ||
157 | tabLayout->addWidget( Local_View, 0, 0 ); | 151 | tabLayout->addWidget( Local_View, 0, 0 ); |
158 | 152 | ||
159 | TabWidget->addTab( tab,"advancedfm/smFileBrowser.png", tr("1")); | 153 | TabWidget->addTab( tab,"advancedfm/smFileBrowser.png", tr("1")); |
160 | // TabWidget->insertTab( tab, tr("1")); | 154 | // TabWidget->insertTab( tab, tr("1")); |
161 | 155 | ||
162 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 156 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
163 | tabLayout_2 = new QGridLayout( tab_2 ); | 157 | tabLayout_2 = new QGridLayout( tab_2 ); |
164 | tabLayout_2->setSpacing( 2); | 158 | tabLayout_2->setSpacing( 2); |
165 | tabLayout_2->setMargin( 2); | 159 | tabLayout_2->setMargin( 2); |
166 | 160 | ||
167 | Remote_View = new QListView( tab_2, "Remote_View" ); | 161 | Remote_View = new QListView( tab_2, "Remote_View" ); |
168 | Remote_View->addColumn( tr("File"),130); | 162 | Remote_View->addColumn( tr("File"),130); |
169 | Remote_View->addColumn( tr("Size"),-1); | 163 | Remote_View->addColumn( tr("Size"),-1); |
170 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 164 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
171 | Remote_View->addColumn( tr("Date"),-1); | 165 | Remote_View->addColumn( tr("Date"),-1); |
172 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 166 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
173 | Remote_View->setAllColumnsShowFocus(TRUE); | 167 | Remote_View->setAllColumnsShowFocus(TRUE); |
174 | Remote_View->setMultiSelection( TRUE ); | 168 | Remote_View->setMultiSelection( TRUE ); |
175 | Remote_View->setSelectionMode(QListView::Extended); | 169 | Remote_View->setSelectionMode(QListView::Extended); |
176 | 170 | ||
177 | 171 | ||
178 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 172 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
179 | 173 | ||
180 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 174 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
181 | 175 | ||
182 | TabWidget->addTab( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); | 176 | TabWidget->addTab( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); |
183 | // TabWidget->insertTab( tab_2, tr( "2")); | 177 | // TabWidget->insertTab( tab_2, tr( "2")); |
184 | 178 | ||
185 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 179 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
186 | tabLayout_3 = new QGridLayout( tab_3 ); | 180 | tabLayout_3 = new QGridLayout( tab_3 ); |
187 | tabLayout_3->setSpacing( 2); | 181 | tabLayout_3->setSpacing( 2); |
188 | tabLayout_3->setMargin( 2); | 182 | tabLayout_3->setMargin( 2); |
189 | 183 | ||
190 | 184 | ||
191 | // OFileDialog fileDialog; | 185 | // OFileDialog fileDialog; |
192 | // fileDialog; | 186 | // fileDialog; |
193 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 187 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
194 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 188 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
195 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 189 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
196 | 190 | ||
197 | QListView *fileTree; | 191 | QListView *fileTree; |
198 | fileTree = new QListView( tab_3, "tree" ); | 192 | fileTree = new QListView( tab_3, "tree" ); |
199 | 193 | ||
200 | 194 | ||
201 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 195 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
202 | 196 | ||
203 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 197 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
204 | */ | 198 | */ |
205 | 199 | ||
206 | /////////////// | 200 | /////////////// |
207 | 201 | ||
208 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 202 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
209 | if (uname(&name) != -1) { | 203 | if (uname(&name) != -1) { |
210 | QString release=name.release; | 204 | QString release=name.release; |
211 | if(release.find("embedix",0,TRUE) !=-1) { | 205 | if(release.find("embedix",0,TRUE) !=-1) { |
212 | zaurusDevice=TRUE; | 206 | zaurusDevice=TRUE; |
213 | } else { | 207 | } else { |
214 | zaurusDevice=FALSE; | 208 | zaurusDevice=FALSE; |
215 | sdButton->hide(); | 209 | sdButton->hide(); |
216 | } | 210 | } |
217 | } | 211 | } |
218 | 212 | ||
219 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 213 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
220 | currentDir.setPath( QDir::currentDirPath()); | 214 | currentDir.setPath( QDir::currentDirPath()); |
221 | 215 | ||
222 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 216 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
223 | currentRemoteDir.setPath( QDir::currentDirPath()); | 217 | currentRemoteDir.setPath( QDir::currentDirPath()); |
224 | 218 | ||
225 | b = TRUE; | 219 | b = TRUE; |
226 | 220 | ||
227 | filterStr="*"; | 221 | filterStr="*"; |
228 | b=FALSE; | 222 | b=FALSE; |
229 | TabWidget->setCurrentTab(0); | 223 | TabWidget->setCurrentTab(0); |
230 | 224 | ||
231 | } | 225 | } |
232 | 226 | ||
233 | void AdvancedFm::initConnections() | 227 | void AdvancedFm::initConnections() |
234 | { | 228 | { |
235 | 229 | ||
236 | connect( qApp,SIGNAL( aboutToQuit()), | 230 | connect( qApp,SIGNAL( aboutToQuit()), |
237 | this, SLOT( cleanUp()) ); | 231 | this, SLOT( cleanUp()) ); |
238 | connect( qpeDirButton ,SIGNAL(released()), | 232 | connect( qpeDirButton ,SIGNAL(released()), |
239 | this,SLOT( QPEButtonPushed()) ); | 233 | this,SLOT( QPEButtonPushed()) ); |
240 | connect( cfButton ,SIGNAL(released()), | 234 | connect( cfButton ,SIGNAL(released()), |
241 | this,SLOT( CFButtonPushed()) ); | 235 | this,SLOT( CFButtonPushed()) ); |
242 | connect( sdButton ,SIGNAL(released()), | 236 | connect( sdButton ,SIGNAL(released()), |
243 | this,SLOT( SDButtonPushed()) ); | 237 | this,SLOT( SDButtonPushed()) ); |
244 | connect( cdUpButton ,SIGNAL(released()), | 238 | connect( cdUpButton ,SIGNAL(released()), |
245 | this,SLOT( upDir()) ); | 239 | this,SLOT( upDir()) ); |
246 | connect( docButton,SIGNAL(released()), | 240 | connect( docButton,SIGNAL(released()), |
247 | this,SLOT( docButtonPushed()) ); | 241 | this,SLOT( docButtonPushed()) ); |
248 | connect( homeButton,SIGNAL(released()), | 242 | connect( homeButton,SIGNAL(released()), |
249 | this,SLOT( homeButtonPushed()) ); | 243 | this,SLOT( homeButtonPushed()) ); |
250 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 244 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
251 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 245 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
252 | 246 | ||
253 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 247 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
254 | this,SLOT(currentPathComboChanged())); | 248 | this,SLOT(currentPathComboChanged())); |
255 | 249 | ||
256 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 250 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
257 | this,SLOT( ListClicked(QListViewItem *)) ); | 251 | this,SLOT( ListClicked(QListViewItem *)) ); |
258 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 252 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
259 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 253 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
260 | 254 | ||
261 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 255 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
262 | 256 | ||
263 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 257 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
264 | this,SLOT( ListClicked(QListViewItem *)) ); | 258 | this,SLOT( ListClicked(QListViewItem *)) ); |
265 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 259 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
266 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 260 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
267 | 261 | ||
268 | connect( TabWidget,SIGNAL(currentChanged(QWidget *)), | 262 | connect( TabWidget,SIGNAL(currentChanged(QWidget *)), |
269 | this,SLOT(tabChanged(QWidget*))); | 263 | this,SLOT(tabChanged(QWidget*))); |
270 | 264 | ||
271 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 265 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
272 | 266 | ||
273 | connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); | 267 | connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); |
274 | // connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); | 268 | // connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); |
275 | 269 | ||
276 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); | 270 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); |
277 | 271 | ||
278 | } | 272 | } |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index eae86a4..575833a 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,889 +1,887 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qpemenubar.h> | ||
22 | #include <qpe/qpetoolbar.h> | ||
23 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
26 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
27 | 25 | ||
28 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
29 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
30 | 28 | ||
31 | #include <qstring.h> | 29 | #include <qstring.h> |
32 | 30 | ||
33 | #include <qlayout.h> | 31 | #include <qlayout.h> |
34 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
35 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
36 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
37 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
38 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
40 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
41 | #include <qlistview.h> | 39 | #include <qlistview.h> |
42 | 40 | ||
43 | #include <stdlib.h> | 41 | #include <stdlib.h> |
44 | #include <unistd.h> | 42 | #include <unistd.h> |
45 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
46 | #include <dirent.h> | 44 | #include <dirent.h> |
47 | #include <sys/sendfile.h> | 45 | #include <sys/sendfile.h> |
48 | #include <fcntl.h> | 46 | #include <fcntl.h> |
49 | 47 | ||
50 | void AdvancedFm::doDirChange() | 48 | void AdvancedFm::doDirChange() |
51 | { | 49 | { |
52 | ListClicked( CurrentView()->currentItem()); | 50 | ListClicked( CurrentView()->currentItem()); |
53 | } | 51 | } |
54 | 52 | ||
55 | void AdvancedFm::showMenuHidden() | 53 | void AdvancedFm::showMenuHidden() |
56 | { | 54 | { |
57 | if (b) | 55 | if (b) |
58 | { | 56 | { |
59 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 57 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 58 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
61 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 59 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
62 | // b=FALSE; | 60 | // b=FALSE; |
63 | 61 | ||
64 | } | 62 | } |
65 | else | 63 | else |
66 | { | 64 | { |
67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 65 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 66 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 67 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
70 | // b=TRUE; | 68 | // b=TRUE; |
71 | } | 69 | } |
72 | rePopulate(); | 70 | rePopulate(); |
73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 71 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
74 | if(b) b = false; else b = true; | 72 | if(b) b = false; else b = true; |
75 | } | 73 | } |
76 | 74 | ||
77 | void AdvancedFm::showHidden() | 75 | void AdvancedFm::showHidden() |
78 | { | 76 | { |
79 | if (b) | 77 | if (b) |
80 | { | 78 | { |
81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 79 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
82 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 80 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
83 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 81 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
84 | // b=FALSE; | 82 | // b=FALSE; |
85 | 83 | ||
86 | } | 84 | } |
87 | else | 85 | else |
88 | { | 86 | { |
89 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 87 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
90 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 88 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
91 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
92 | // b=TRUE; | 90 | // b=TRUE; |
93 | } | 91 | } |
94 | rePopulate(); | 92 | rePopulate(); |
95 | } | 93 | } |
96 | 94 | ||
97 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 95 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
98 | { | 96 | { |
99 | QString strItem = fileName; | 97 | QString strItem = fileName; |
100 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
101 | } | 99 | } |
102 | 100 | ||
103 | void AdvancedFm::runThis() | 101 | void AdvancedFm::runThis() |
104 | { | 102 | { |
105 | QString fs; | 103 | QString fs; |
106 | QDir *thisDir = CurrentDir(); | 104 | QDir *thisDir = CurrentDir(); |
107 | 105 | ||
108 | QString curFile = CurrentView()->currentItem()->text(0); | 106 | QString curFile = CurrentView()->currentItem()->text(0); |
109 | QString path = thisDir->canonicalPath(); | 107 | QString path = thisDir->canonicalPath(); |
110 | 108 | ||
111 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
112 | 110 | ||
113 | curFile = dealWithSymName((const QString&)curFile); | 111 | curFile = dealWithSymName((const QString&)curFile); |
114 | 112 | ||
115 | if(curFile != "../") | 113 | if(curFile != "../") |
116 | { | 114 | { |
117 | 115 | ||
118 | fs = getFileSystemType((const QString &) path); | 116 | fs = getFileSystemType((const QString &) path); |
119 | QFileInfo fileInfo( path + "/" + curFile); | 117 | QFileInfo fileInfo( path + "/" + curFile); |
120 | qDebug( fileInfo.owner()); | 118 | qDebug( fileInfo.owner()); |
121 | 119 | ||
122 | if( (fileInfo.permission( QFileInfo::ExeUser) | 120 | if( (fileInfo.permission( QFileInfo::ExeUser) |
123 | | fileInfo.permission( QFileInfo::ExeGroup) | 121 | | fileInfo.permission( QFileInfo::ExeGroup) |
124 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 122 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
125 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 123 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
126 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 124 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
127 | e << curFile; | 125 | e << curFile; |
128 | } | 126 | } |
129 | else | 127 | else |
130 | { | 128 | { |
131 | curFile = path + "/" + curFile; | 129 | curFile = path + "/" + curFile; |
132 | DocLnk nf(curFile); | 130 | DocLnk nf(curFile); |
133 | QString execStr = nf.exec(); | 131 | QString execStr = nf.exec(); |
134 | qDebug( execStr); | 132 | qDebug( execStr); |
135 | if( execStr.isEmpty() ) | 133 | if( execStr.isEmpty() ) |
136 | { | 134 | { |
137 | } | 135 | } |
138 | else | 136 | else |
139 | { | 137 | { |
140 | nf.execute(); | 138 | nf.execute(); |
141 | } | 139 | } |
142 | } | 140 | } |
143 | } | 141 | } |
144 | } | 142 | } |
145 | 143 | ||
146 | void AdvancedFm::runText() | 144 | void AdvancedFm::runText() |
147 | { | 145 | { |
148 | QString curFile = CurrentView()->currentItem()->text(0); | 146 | QString curFile = CurrentView()->currentItem()->text(0); |
149 | if(curFile != "../") | 147 | if(curFile != "../") |
150 | { | 148 | { |
151 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
152 | curFile = dealWithSymName((const QString&)curFile); | 150 | curFile = dealWithSymName((const QString&)curFile); |
153 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
155 | e << curFile; | 153 | e << curFile; |
156 | } | 154 | } |
157 | } | 155 | } |
158 | 156 | ||
159 | void AdvancedFm::makeDir() | 157 | void AdvancedFm::makeDir() |
160 | { | 158 | { |
161 | InputDialog *fileDlg; | 159 | InputDialog *fileDlg; |
162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
163 | fileDlg->exec(); | 161 | fileDlg->exec(); |
164 | if( fileDlg->result() == 1 ) | 162 | if( fileDlg->result() == 1 ) |
165 | { | 163 | { |
166 | QDir *thisDir = CurrentDir(); | 164 | QDir *thisDir = CurrentDir(); |
167 | QString filename = fileDlg->LineEdit1->text(); | 165 | QString filename = fileDlg->LineEdit1->text(); |
168 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
169 | } | 167 | } |
170 | populateView(); | 168 | populateView(); |
171 | } | 169 | } |
172 | 170 | ||
173 | void AdvancedFm::doDelete() | 171 | void AdvancedFm::doDelete() |
174 | { | 172 | { |
175 | 173 | ||
176 | QStringList curFileList = getPath(); | 174 | QStringList curFileList = getPath(); |
177 | bool doMsg=true; | 175 | bool doMsg=true; |
178 | int count = curFileList.count(); | 176 | int count = curFileList.count(); |
179 | if( count > 0) | 177 | if( count > 0) |
180 | { | 178 | { |
181 | if(count > 1 ) | 179 | if(count > 1 ) |
182 | { | 180 | { |
183 | QString msg; | 181 | QString msg; |
184 | msg=tr("Really delete\n%1 files?").arg(count); | 182 | msg=tr("Really delete\n%1 files?").arg(count); |
185 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 183 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
186 | ,tr("Yes"),tr("No"),0,0,1) ) | 184 | ,tr("Yes"),tr("No"),0,0,1) ) |
187 | { | 185 | { |
188 | case 0: | 186 | case 0: |
189 | doMsg=false; | 187 | doMsg=false; |
190 | break; | 188 | break; |
191 | case 1: | 189 | case 1: |
192 | return; | 190 | return; |
193 | break; | 191 | break; |
194 | }; | 192 | }; |
195 | } | 193 | } |
196 | 194 | ||
197 | QString myFile; | 195 | QString myFile; |
198 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
199 | { | 197 | { |
200 | myFile = (*it); | 198 | myFile = (*it); |
201 | if( myFile.find(" -> ",0,TRUE) != -1) | 199 | if( myFile.find(" -> ",0,TRUE) != -1) |
202 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
203 | 201 | ||
204 | QString f = CurrentDir()->canonicalPath(); | 202 | QString f = CurrentDir()->canonicalPath(); |
205 | if(f.right(1).find("/",0,TRUE) == -1) | 203 | if(f.right(1).find("/",0,TRUE) == -1) |
206 | f += "/"; | 204 | f += "/"; |
207 | f += myFile; | 205 | f += myFile; |
208 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) | 206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) |
209 | { | 207 | { |
210 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + | 208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + |
211 | "\nand all it's contents ?" | 209 | "\nand all it's contents ?" |
212 | ,tr("Yes"),tr("No"),0,0,1) ) | 210 | ,tr("Yes"),tr("No"),0,0,1) ) |
213 | { | 211 | { |
214 | case 0: | 212 | case 0: |
215 | { | 213 | { |
216 | f=f.left(f.length()-1); | 214 | f=f.left(f.length()-1); |
217 | QString cmd="rm -rf "+f; | 215 | QString cmd="rm -rf "+f; |
218 | startProcess( (const QString)cmd.latin1() ); | 216 | startProcess( (const QString)cmd.latin1() ); |
219 | populateView(); | 217 | populateView(); |
220 | } | 218 | } |
221 | break; | 219 | break; |
222 | case 1: | 220 | case 1: |
223 | // exit | 221 | // exit |
224 | break; | 222 | break; |
225 | }; | 223 | }; |
226 | 224 | ||
227 | } else { | 225 | } else { |
228 | if(doMsg) { | 226 | if(doMsg) { |
229 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 227 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
230 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 228 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
231 | case 1: | 229 | case 1: |
232 | return; | 230 | return; |
233 | break; | 231 | break; |
234 | }; | 232 | }; |
235 | } | 233 | } |
236 | QString cmd="rm "+f; | 234 | QString cmd="rm "+f; |
237 | QFile file(f); | 235 | QFile file(f); |
238 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 236 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
239 | file.remove(); | 237 | file.remove(); |
240 | } | 238 | } |
241 | } | 239 | } |
242 | } | 240 | } |
243 | populateView(); | 241 | populateView(); |
244 | } | 242 | } |
245 | 243 | ||
246 | void AdvancedFm::filePerms() | 244 | void AdvancedFm::filePerms() |
247 | { | 245 | { |
248 | QStringList curFileList = getPath(); | 246 | QStringList curFileList = getPath(); |
249 | QString filePath; | 247 | QString filePath; |
250 | 248 | ||
251 | filePath = CurrentDir()->canonicalPath()+"/"; | 249 | filePath = CurrentDir()->canonicalPath()+"/"; |
252 | 250 | ||
253 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 251 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
254 | { | 252 | { |
255 | filePermissions *filePerm; | 253 | filePermissions *filePerm; |
256 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 254 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
257 | filePerm->showMaximized(); | 255 | filePerm->showMaximized(); |
258 | filePerm->exec(); | 256 | filePerm->exec(); |
259 | if( filePerm) | 257 | if( filePerm) |
260 | delete filePerm; | 258 | delete filePerm; |
261 | } | 259 | } |
262 | populateView(); | 260 | populateView(); |
263 | } | 261 | } |
264 | 262 | ||
265 | void AdvancedFm::doProperties() | 263 | void AdvancedFm::doProperties() |
266 | { | 264 | { |
267 | #if defined(QT_QWS_OPIE) | 265 | #if defined(QT_QWS_OPIE) |
268 | 266 | ||
269 | QStringList curFileList = getPath(); | 267 | QStringList curFileList = getPath(); |
270 | 268 | ||
271 | QString filePath; | 269 | QString filePath; |
272 | filePath = CurrentDir()->canonicalPath()+"/"; | 270 | filePath = CurrentDir()->canonicalPath()+"/"; |
273 | 271 | ||
274 | qDebug("%d",curFileList.count()); | 272 | qDebug("%d",curFileList.count()); |
275 | 273 | ||
276 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 274 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
277 | { | 275 | { |
278 | qDebug((filePath+*it)); | 276 | qDebug((filePath+*it)); |
279 | DocLnk lnk( (filePath+*it)); | 277 | DocLnk lnk( (filePath+*it)); |
280 | LnkProperties prop( &lnk ); | 278 | LnkProperties prop( &lnk ); |
281 | prop.showMaximized(); | 279 | prop.showMaximized(); |
282 | prop.exec(); | 280 | prop.exec(); |
283 | } | 281 | } |
284 | #endif | 282 | #endif |
285 | 283 | ||
286 | } | 284 | } |
287 | 285 | ||
288 | void AdvancedFm::upDir() | 286 | void AdvancedFm::upDir() |
289 | { | 287 | { |
290 | QDir *thisDir = CurrentDir(); | 288 | QDir *thisDir = CurrentDir(); |
291 | QString current = thisDir->canonicalPath(); | 289 | QString current = thisDir->canonicalPath(); |
292 | QDir dir(current); | 290 | QDir dir(current); |
293 | dir.cdUp(); | 291 | dir.cdUp(); |
294 | current = dir.canonicalPath(); | 292 | current = dir.canonicalPath(); |
295 | chdir( current.latin1() ); | 293 | chdir( current.latin1() ); |
296 | thisDir->cd( current, TRUE); | 294 | thisDir->cd( current, TRUE); |
297 | 295 | ||
298 | populateView(); | 296 | populateView(); |
299 | update(); | 297 | update(); |
300 | } | 298 | } |
301 | 299 | ||
302 | void AdvancedFm::copy() | 300 | void AdvancedFm::copy() |
303 | { | 301 | { |
304 | qApp->processEvents(); | 302 | qApp->processEvents(); |
305 | QStringList curFileList = getPath(); | 303 | QStringList curFileList = getPath(); |
306 | 304 | ||
307 | QDir *thisDir = CurrentDir(); | 305 | QDir *thisDir = CurrentDir(); |
308 | QDir *thatDir = OtherDir(); | 306 | QDir *thatDir = OtherDir(); |
309 | 307 | ||
310 | bool doMsg=true; | 308 | bool doMsg=true; |
311 | int count=curFileList.count(); | 309 | int count=curFileList.count(); |
312 | if( count > 0) { | 310 | if( count > 0) { |
313 | if(count > 1 ){ | 311 | if(count > 1 ){ |
314 | QString msg; | 312 | QString msg; |
315 | msg=tr("Really copy\n%1 files?").arg(count); | 313 | msg=tr("Really copy\n%1 files?").arg(count); |
316 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 314 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
317 | ,tr("Yes"),tr("No"),0,0,1) ) | 315 | ,tr("Yes"),tr("No"),0,0,1) ) |
318 | { | 316 | { |
319 | case 0: | 317 | case 0: |
320 | doMsg=false; | 318 | doMsg=false; |
321 | break; | 319 | break; |
322 | case 1: | 320 | case 1: |
323 | return; | 321 | return; |
324 | break; | 322 | break; |
325 | }; | 323 | }; |
326 | } | 324 | } |
327 | 325 | ||
328 | QString curFile, item, destFile; | 326 | QString curFile, item, destFile; |
329 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 327 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
330 | { | 328 | { |
331 | item=(*it); | 329 | item=(*it); |
332 | if(item.find("->",0,TRUE)) //symlink | 330 | if(item.find("->",0,TRUE)) //symlink |
333 | item = item.left(item.find("->",0,TRUE)); | 331 | item = item.left(item.find("->",0,TRUE)); |
334 | 332 | ||
335 | curFile = thisDir->canonicalPath()+"/"+ item; | 333 | curFile = thisDir->canonicalPath()+"/"+ item; |
336 | destFile = thatDir->canonicalPath()+"/"+ item; | 334 | destFile = thatDir->canonicalPath()+"/"+ item; |
337 | 335 | ||
338 | qDebug("Destination file is "+destFile); | 336 | qDebug("Destination file is "+destFile); |
339 | qDebug("CurrentFile file is " + curFile); | 337 | qDebug("CurrentFile file is " + curFile); |
340 | 338 | ||
341 | QFile f(destFile); | 339 | QFile f(destFile); |
342 | if( f.exists()) | 340 | if( f.exists()) |
343 | { | 341 | { |
344 | if(doMsg) | 342 | if(doMsg) |
345 | { | 343 | { |
346 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 344 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
347 | tr("%1 exists. Ok to overwrite?").arg( item ), | 345 | tr("%1 exists. Ok to overwrite?").arg( item ), |
348 | tr("Yes"),tr("No"),0,0,1) ) | 346 | tr("Yes"),tr("No"),0,0,1) ) |
349 | { | 347 | { |
350 | case 1: | 348 | case 1: |
351 | return; | 349 | return; |
352 | break; | 350 | break; |
353 | }; | 351 | }; |
354 | } | 352 | } |
355 | f.remove(); | 353 | f.remove(); |
356 | } | 354 | } |
357 | 355 | ||
358 | if( !copyFile( curFile, destFile) ) | 356 | if( !copyFile( curFile, destFile) ) |
359 | { | 357 | { |
360 | QMessageBox::message("AdvancedFm", | 358 | QMessageBox::message("AdvancedFm", |
361 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 359 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
362 | return; | 360 | return; |
363 | } | 361 | } |
364 | } | 362 | } |
365 | setOtherTabCurrent(); | 363 | setOtherTabCurrent(); |
366 | populateView(); | 364 | populateView(); |
367 | } | 365 | } |
368 | } | 366 | } |
369 | 367 | ||
370 | void AdvancedFm::copyAs() | 368 | void AdvancedFm::copyAs() |
371 | { | 369 | { |
372 | qApp->processEvents(); | 370 | qApp->processEvents(); |
373 | 371 | ||
374 | QStringList curFileList = getPath(); | 372 | QStringList curFileList = getPath(); |
375 | QString curFile, item; | 373 | QString curFile, item; |
376 | InputDialog *fileDlg; | 374 | InputDialog *fileDlg; |
377 | 375 | ||
378 | QDir *thisDir = CurrentDir(); | 376 | QDir *thisDir = CurrentDir(); |
379 | QDir *thatDir = OtherDir(); | 377 | QDir *thatDir = OtherDir(); |
380 | 378 | ||
381 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 379 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
382 | { | 380 | { |
383 | QString destFile; | 381 | QString destFile; |
384 | item=(*it); | 382 | item=(*it); |
385 | curFile = thisDir->canonicalPath()+"/"+(*it); | 383 | curFile = thisDir->canonicalPath()+"/"+(*it); |
386 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 384 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
387 | 385 | ||
388 | fileDlg->setInputText((const QString &) destFile ); | 386 | fileDlg->setInputText((const QString &) destFile ); |
389 | fileDlg->exec(); | 387 | fileDlg->exec(); |
390 | 388 | ||
391 | if( fileDlg->result() == 1 ) | 389 | if( fileDlg->result() == 1 ) |
392 | { | 390 | { |
393 | QString filename = fileDlg->LineEdit1->text(); | 391 | QString filename = fileDlg->LineEdit1->text(); |
394 | destFile = thatDir->canonicalPath()+"/"+filename; | 392 | destFile = thatDir->canonicalPath()+"/"+filename; |
395 | 393 | ||
396 | QFile f( destFile); | 394 | QFile f( destFile); |
397 | if( f.exists()) | 395 | if( f.exists()) |
398 | { | 396 | { |
399 | switch (QMessageBox::warning(this,tr("File Exists!"), | 397 | switch (QMessageBox::warning(this,tr("File Exists!"), |
400 | item+tr("\nexists. Ok to overwrite?"), | 398 | item+tr("\nexists. Ok to overwrite?"), |
401 | tr("Yes"),tr("No"),0,0,1) ) | 399 | tr("Yes"),tr("No"),0,0,1) ) |
402 | { | 400 | { |
403 | case 0: | 401 | case 0: |
404 | f.remove(); | 402 | f.remove(); |
405 | break; | 403 | break; |
406 | case 1: | 404 | case 1: |
407 | return; | 405 | return; |
408 | break; | 406 | break; |
409 | }; | 407 | }; |
410 | } | 408 | } |
411 | if( !copyFile( curFile, destFile) ) | 409 | if( !copyFile( curFile, destFile) ) |
412 | { | 410 | { |
413 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 411 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
414 | +curFile +tr("to\n")+destFile); | 412 | +curFile +tr("to\n")+destFile); |
415 | return; | 413 | return; |
416 | } | 414 | } |
417 | } | 415 | } |
418 | delete fileDlg; | 416 | delete fileDlg; |
419 | 417 | ||
420 | } | 418 | } |
421 | setOtherTabCurrent(); | 419 | setOtherTabCurrent(); |
422 | populateView(); | 420 | populateView(); |
423 | } | 421 | } |
424 | 422 | ||
425 | void AdvancedFm::copySameDir() | 423 | void AdvancedFm::copySameDir() |
426 | { | 424 | { |
427 | qApp->processEvents(); | 425 | qApp->processEvents(); |
428 | QStringList curFileList = getPath(); | 426 | QStringList curFileList = getPath(); |
429 | QString curFile, item, destFile; | 427 | QString curFile, item, destFile; |
430 | InputDialog *fileDlg; | 428 | InputDialog *fileDlg; |
431 | 429 | ||
432 | QDir *thisDir = CurrentDir(); | 430 | QDir *thisDir = CurrentDir(); |
433 | 431 | ||
434 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 432 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
435 | { | 433 | { |
436 | item=(*it); | 434 | item=(*it); |
437 | curFile = thisDir->canonicalPath()+"/"+ item; | 435 | curFile = thisDir->canonicalPath()+"/"+ item; |
438 | 436 | ||
439 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 437 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
440 | fileDlg->setInputText((const QString &) destFile ); | 438 | fileDlg->setInputText((const QString &) destFile ); |
441 | fileDlg->exec(); | 439 | fileDlg->exec(); |
442 | 440 | ||
443 | if( fileDlg->result() == 1 ) | 441 | if( fileDlg->result() == 1 ) |
444 | { | 442 | { |
445 | 443 | ||
446 | QString filename = fileDlg->LineEdit1->text(); | 444 | QString filename = fileDlg->LineEdit1->text(); |
447 | destFile = thisDir->canonicalPath()+"/"+filename; | 445 | destFile = thisDir->canonicalPath()+"/"+filename; |
448 | 446 | ||
449 | QFile f(destFile); | 447 | QFile f(destFile); |
450 | if( f.exists()) | 448 | if( f.exists()) |
451 | { | 449 | { |
452 | switch (QMessageBox::warning(this,tr("Delete"), | 450 | switch (QMessageBox::warning(this,tr("Delete"), |
453 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 451 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
454 | tr("Yes"),tr("No"),0,0,1) ) { | 452 | tr("Yes"),tr("No"),0,0,1) ) { |
455 | case 0: | 453 | case 0: |
456 | 454 | ||
457 | f.remove(); | 455 | f.remove(); |
458 | break; | 456 | break; |
459 | case 1: | 457 | case 1: |
460 | return; | 458 | return; |
461 | break; | 459 | break; |
462 | }; | 460 | }; |
463 | } | 461 | } |
464 | if(!copyFile( curFile,destFile) ) | 462 | if(!copyFile( curFile,destFile) ) |
465 | { | 463 | { |
466 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 464 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
467 | +curFile +tr("to\n")+destFile); | 465 | +curFile +tr("to\n")+destFile); |
468 | return; | 466 | return; |
469 | } | 467 | } |
470 | 468 | ||
471 | qDebug("copy "+curFile+" as "+destFile); | 469 | qDebug("copy "+curFile+" as "+destFile); |
472 | } | 470 | } |
473 | delete fileDlg; | 471 | delete fileDlg; |
474 | } | 472 | } |
475 | populateView(); | 473 | populateView(); |
476 | } | 474 | } |
477 | 475 | ||
478 | void AdvancedFm::move() | 476 | void AdvancedFm::move() |
479 | { | 477 | { |
480 | qApp->processEvents(); | 478 | qApp->processEvents(); |
481 | 479 | ||
482 | QStringList curFileList = getPath(); | 480 | QStringList curFileList = getPath(); |
483 | if( curFileList.count() > 0) | 481 | if( curFileList.count() > 0) |
484 | { | 482 | { |
485 | QString curFile, destFile, item; | 483 | QString curFile, destFile, item; |
486 | 484 | ||
487 | QDir *thisDir = CurrentDir(); | 485 | QDir *thisDir = CurrentDir(); |
488 | QDir *thatDir = OtherDir(); | 486 | QDir *thatDir = OtherDir(); |
489 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 487 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
490 | { | 488 | { |
491 | item=(*it); | 489 | item=(*it); |
492 | QString destFile = thatDir->canonicalPath(); | 490 | QString destFile = thatDir->canonicalPath(); |
493 | 491 | ||
494 | if(destFile.right(1).find("/",0,TRUE) == -1) | 492 | if(destFile.right(1).find("/",0,TRUE) == -1) |
495 | destFile+="/"; | 493 | destFile+="/"; |
496 | destFile += item; | 494 | destFile += item; |
497 | qDebug("Destination file is "+destFile); | 495 | qDebug("Destination file is "+destFile); |
498 | 496 | ||
499 | curFile = thisDir->canonicalPath(); | 497 | curFile = thisDir->canonicalPath(); |
500 | if(curFile.right(1).find("/",0,TRUE) == -1) | 498 | if(curFile.right(1).find("/",0,TRUE) == -1) |
501 | curFile +="/"; | 499 | curFile +="/"; |
502 | curFile+= item; | 500 | curFile+= item; |
503 | qDebug("CurrentFile file is " + curFile); | 501 | qDebug("CurrentFile file is " + curFile); |
504 | 502 | ||
505 | QFile f( curFile); | 503 | QFile f( curFile); |
506 | if( f.exists()) { | 504 | if( f.exists()) { |
507 | if( !copyFile( curFile, destFile) ) | 505 | if( !copyFile( curFile, destFile) ) |
508 | { | 506 | { |
509 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 507 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
510 | return; | 508 | return; |
511 | } else | 509 | } else |
512 | QFile::remove(curFile); | 510 | QFile::remove(curFile); |
513 | } | 511 | } |
514 | } | 512 | } |
515 | 513 | ||
516 | } | 514 | } |
517 | setOtherTabCurrent(); | 515 | setOtherTabCurrent(); |
518 | populateView(); | 516 | populateView(); |
519 | // populateLocalView(); | 517 | // populateLocalView(); |
520 | } | 518 | } |
521 | 519 | ||
522 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 520 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) |
523 | { | 521 | { |
524 | // char bf[ 50000 ]; | 522 | // char bf[ 50000 ]; |
525 | // int bytesRead; | 523 | // int bytesRead; |
526 | bool success = true; | 524 | bool success = true; |
527 | struct stat status; | 525 | struct stat status; |
528 | 526 | ||
529 | // QFile s( src ); | 527 | // QFile s( src ); |
530 | // QFile d( dest ); | 528 | // QFile d( dest ); |
531 | 529 | ||
532 | int read_fd=0; | 530 | int read_fd=0; |
533 | int write_fd=0; | 531 | int write_fd=0; |
534 | struct stat stat_buf; | 532 | struct stat stat_buf; |
535 | off_t offset = 0; | 533 | off_t offset = 0; |
536 | read_fd = ::open(src.latin1(), O_RDONLY); | 534 | read_fd = ::open(src.latin1(), O_RDONLY); |
537 | if(read_fd != -1) { | 535 | if(read_fd != -1) { |
538 | fstat (read_fd, &stat_buf); | 536 | fstat (read_fd, &stat_buf); |
539 | write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode); | 537 | write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode); |
540 | if(write_fd != -1) { | 538 | if(write_fd != -1) { |
541 | if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) { | 539 | if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) { |
542 | success = false; | 540 | success = false; |
543 | } | 541 | } |
544 | } else { | 542 | } else { |
545 | success = false; | 543 | success = false; |
546 | } | 544 | } |
547 | } else { | 545 | } else { |
548 | success = false; | 546 | success = false; |
549 | } | 547 | } |
550 | 548 | ||
551 | ::close (read_fd); | 549 | ::close (read_fd); |
552 | ::close (write_fd); | 550 | ::close (write_fd); |
553 | 551 | ||
554 | 552 | ||
555 | // if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) | 553 | // if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) |
556 | // { | 554 | // { |
557 | // while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) | 555 | // while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) |
558 | // { | 556 | // { |
559 | // if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 557 | // if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
560 | // success = FALSE; | 558 | // success = FALSE; |
561 | // break; | 559 | // break; |
562 | // } | 560 | // } |
563 | // } | 561 | // } |
564 | // if( success && (bytesRead > 0) ) | 562 | // if( success && (bytesRead > 0) ) |
565 | // { | 563 | // { |
566 | // d.writeBlock( bf, bytesRead ); | 564 | // d.writeBlock( bf, bytesRead ); |
567 | // } | 565 | // } |
568 | 566 | ||
569 | // } | 567 | // } |
570 | // else | 568 | // else |
571 | // { | 569 | // { |
572 | // success = FALSE; | 570 | // success = FALSE; |
573 | // } | 571 | // } |
574 | 572 | ||
575 | // Set file permissions | 573 | // Set file permissions |
576 | if( stat( (const char *) src, &status ) == 0 ) | 574 | if( stat( (const char *) src, &status ) == 0 ) |
577 | { | 575 | { |
578 | chmod( (const char *) dest, status.st_mode ); | 576 | chmod( (const char *) dest, status.st_mode ); |
579 | } | 577 | } |
580 | 578 | ||
581 | return success; | 579 | return success; |
582 | } | 580 | } |
583 | 581 | ||
584 | void AdvancedFm::runCommand() | 582 | void AdvancedFm::runCommand() |
585 | { | 583 | { |
586 | QDir *thisDir = CurrentDir(); | 584 | QDir *thisDir = CurrentDir(); |
587 | 585 | ||
588 | QString curFile; | 586 | QString curFile; |
589 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 587 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
590 | 588 | ||
591 | InputDialog *fileDlg; | 589 | InputDialog *fileDlg; |
592 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 590 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
593 | fileDlg->setInputText(curFile); | 591 | fileDlg->setInputText(curFile); |
594 | fileDlg->exec(); | 592 | fileDlg->exec(); |
595 | //QString command; | 593 | //QString command; |
596 | 594 | ||
597 | if( fileDlg->result() == 1 ) | 595 | if( fileDlg->result() == 1 ) |
598 | { | 596 | { |
599 | qDebug(fileDlg->LineEdit1->text()); | 597 | qDebug(fileDlg->LineEdit1->text()); |
600 | QStringList command; | 598 | QStringList command; |
601 | 599 | ||
602 | command << "/bin/sh"; | 600 | command << "/bin/sh"; |
603 | command << "-c"; | 601 | command << "-c"; |
604 | command << fileDlg->LineEdit1->text(); | 602 | command << fileDlg->LineEdit1->text(); |
605 | Output *outDlg; | 603 | Output *outDlg; |
606 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 604 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
607 | outDlg->showMaximized(); | 605 | outDlg->showMaximized(); |
608 | outDlg->exec(); | 606 | outDlg->exec(); |
609 | qApp->processEvents(); | 607 | qApp->processEvents(); |
610 | 608 | ||
611 | } | 609 | } |
612 | } | 610 | } |
613 | 611 | ||
614 | void AdvancedFm::runCommandStd() | 612 | void AdvancedFm::runCommandStd() |
615 | { | 613 | { |
616 | QString curFile; | 614 | QString curFile; |
617 | QDir *thisDir = CurrentDir(); | 615 | QDir *thisDir = CurrentDir(); |
618 | QListView *thisView = CurrentView(); | 616 | QListView *thisView = CurrentView(); |
619 | if( thisView->currentItem()) | 617 | if( thisView->currentItem()) |
620 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 618 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
621 | 619 | ||
622 | InputDialog *fileDlg; | 620 | InputDialog *fileDlg; |
623 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 621 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
624 | fileDlg->setInputText(curFile); | 622 | fileDlg->setInputText(curFile); |
625 | fileDlg->exec(); | 623 | fileDlg->exec(); |
626 | 624 | ||
627 | if( fileDlg->result() == 1 ) | 625 | if( fileDlg->result() == 1 ) |
628 | { | 626 | { |
629 | qApp->processEvents(); | 627 | qApp->processEvents(); |
630 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 628 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
631 | } | 629 | } |
632 | } | 630 | } |
633 | 631 | ||
634 | void AdvancedFm::fileStatus() | 632 | void AdvancedFm::fileStatus() |
635 | { | 633 | { |
636 | QString curFile; | 634 | QString curFile; |
637 | curFile = CurrentView()->currentItem()->text(0); | 635 | curFile = CurrentView()->currentItem()->text(0); |
638 | 636 | ||
639 | QStringList command; | 637 | QStringList command; |
640 | command << "/bin/sh"; | 638 | command << "/bin/sh"; |
641 | command << "-c"; | 639 | command << "-c"; |
642 | command << "stat -l "+ curFile; | 640 | command << "stat -l "+ curFile; |
643 | 641 | ||
644 | Output *outDlg; | 642 | Output *outDlg; |
645 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 643 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
646 | outDlg->showMaximized(); | 644 | outDlg->showMaximized(); |
647 | outDlg->exec(); | 645 | outDlg->exec(); |
648 | qApp->processEvents(); | 646 | qApp->processEvents(); |
649 | } | 647 | } |
650 | 648 | ||
651 | 649 | ||
652 | void AdvancedFm::mkDir() | 650 | void AdvancedFm::mkDir() |
653 | { | 651 | { |
654 | makeDir(); | 652 | makeDir(); |
655 | } | 653 | } |
656 | 654 | ||
657 | void AdvancedFm::rn() | 655 | void AdvancedFm::rn() |
658 | { | 656 | { |
659 | renameIt(); | 657 | renameIt(); |
660 | } | 658 | } |
661 | 659 | ||
662 | void AdvancedFm::del() | 660 | void AdvancedFm::del() |
663 | { | 661 | { |
664 | doDelete(); | 662 | doDelete(); |
665 | } | 663 | } |
666 | 664 | ||
667 | void AdvancedFm::mkSym() | 665 | void AdvancedFm::mkSym() |
668 | { | 666 | { |
669 | QString cmd; | 667 | QString cmd; |
670 | QStringList curFileList = getPath(); | 668 | QStringList curFileList = getPath(); |
671 | if( curFileList.count() > 0) | 669 | if( curFileList.count() > 0) |
672 | { | 670 | { |
673 | QDir *thisDir = CurrentDir(); | 671 | QDir *thisDir = CurrentDir(); |
674 | QDir * thatDir = OtherDir(); | 672 | QDir * thatDir = OtherDir(); |
675 | 673 | ||
676 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 674 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
677 | { | 675 | { |
678 | 676 | ||
679 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 677 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
680 | if(destName.right(1) == "/") | 678 | if(destName.right(1) == "/") |
681 | { | 679 | { |
682 | destName = destName.left( destName.length() -1); | 680 | destName = destName.left( destName.length() -1); |
683 | } | 681 | } |
684 | 682 | ||
685 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 683 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
686 | 684 | ||
687 | if( curFile.right(1) == "/") | 685 | if( curFile.right(1) == "/") |
688 | { | 686 | { |
689 | curFile = curFile.left( curFile.length() -1); | 687 | curFile = curFile.left( curFile.length() -1); |
690 | } | 688 | } |
691 | 689 | ||
692 | cmd = "ln -s "+curFile+" "+destName; | 690 | cmd = "ln -s "+curFile+" "+destName; |
693 | qDebug(cmd); | 691 | qDebug(cmd); |
694 | startProcess( (const QString)cmd ); | 692 | startProcess( (const QString)cmd ); |
695 | } | 693 | } |
696 | setOtherTabCurrent(); | 694 | setOtherTabCurrent(); |
697 | populateView(); | 695 | populateView(); |
698 | } | 696 | } |
699 | } | 697 | } |
700 | 698 | ||
701 | void AdvancedFm::doBeam() | 699 | void AdvancedFm::doBeam() |
702 | { | 700 | { |
703 | Ir ir; | 701 | Ir ir; |
704 | if(!ir.supported()) | 702 | if(!ir.supported()) |
705 | { | 703 | { |
706 | } | 704 | } |
707 | else | 705 | else |
708 | { | 706 | { |
709 | QStringList curFileList = getPath(); | 707 | QStringList curFileList = getPath(); |
710 | if( curFileList.count() > 0) | 708 | if( curFileList.count() > 0) |
711 | { | 709 | { |
712 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 710 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
713 | { | 711 | { |
714 | 712 | ||
715 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); | 713 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); |
716 | if( curFile.right(1) == "/") | 714 | if( curFile.right(1) == "/") |
717 | { | 715 | { |
718 | curFile = curFile.left( curFile.length() -1); | 716 | curFile = curFile.left( curFile.length() -1); |
719 | } | 717 | } |
720 | Ir *file = new Ir(this, "IR"); | 718 | Ir *file = new Ir(this, "IR"); |
721 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 719 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
722 | file->send( curFile, curFile ); | 720 | file->send( curFile, curFile ); |
723 | } | 721 | } |
724 | } | 722 | } |
725 | } | 723 | } |
726 | 724 | ||
727 | } | 725 | } |
728 | 726 | ||
729 | void AdvancedFm::fileBeamFinished( Ir *) | 727 | void AdvancedFm::fileBeamFinished( Ir *) |
730 | { | 728 | { |
731 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 729 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
732 | } | 730 | } |
733 | 731 | ||
734 | void AdvancedFm::selectAll() | 732 | void AdvancedFm::selectAll() |
735 | { | 733 | { |
736 | // if (TabWidget->currentTab() == 0) { | 734 | // if (TabWidget->currentTab() == 0) { |
737 | QListView *thisView = CurrentView(); | 735 | QListView *thisView = CurrentView(); |
738 | thisView->selectAll(true); | 736 | thisView->selectAll(true); |
739 | thisView->setSelected( thisView->firstChild(),false); | 737 | thisView->setSelected( thisView->firstChild(),false); |
740 | // } else { | 738 | // } else { |
741 | // Remote_View->selectAll(true); | 739 | // Remote_View->selectAll(true); |
742 | // Remote_View->setSelected( Remote_View->firstChild(),false); | 740 | // Remote_View->setSelected( Remote_View->firstChild(),false); |
743 | // } | 741 | // } |
744 | } | 742 | } |
745 | 743 | ||
746 | void AdvancedFm::startProcess(const QString & cmd) | 744 | void AdvancedFm::startProcess(const QString & cmd) |
747 | { | 745 | { |
748 | QStringList command; | 746 | QStringList command; |
749 | OProcess *process; | 747 | OProcess *process; |
750 | process = new OProcess(); | 748 | process = new OProcess(); |
751 | connect(process, SIGNAL(processExited(OProcess *)), | 749 | connect(process, SIGNAL(processExited(OProcess *)), |
752 | this, SLOT( processEnded(OProcess *))); | 750 | this, SLOT( processEnded(OProcess *))); |
753 | 751 | ||
754 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 752 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), |
755 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 753 | this, SLOT( oprocessStderr(OProcess *, char *, int))); |
756 | 754 | ||
757 | command << "/bin/sh"; | 755 | command << "/bin/sh"; |
758 | command << "-c"; | 756 | command << "-c"; |
759 | command << cmd.latin1(); | 757 | command << cmd.latin1(); |
760 | *process << command; | 758 | *process << command; |
761 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 759 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
762 | qDebug("could not start process"); | 760 | qDebug("could not start process"); |
763 | } | 761 | } |
764 | 762 | ||
765 | void AdvancedFm::processEnded(OProcess *) | 763 | void AdvancedFm::processEnded(OProcess *) |
766 | { | 764 | { |
767 | // populateLocalView(); | 765 | // populateLocalView(); |
768 | populateView(); | 766 | populateView(); |
769 | } | 767 | } |
770 | 768 | ||
771 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { | 769 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { |
772 | qWarning("received stderrt %d bytes", buflen); | 770 | qWarning("received stderrt %d bytes", buflen); |
773 | 771 | ||
774 | QString lineStr = buffer; | 772 | QString lineStr = buffer; |
775 | // lineStr=lineStr.left(lineStr.length()-1); | 773 | // lineStr=lineStr.left(lineStr.length()-1); |
776 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 774 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
777 | 775 | ||
778 | // OutputEdit->append(lineStr); | 776 | // OutputEdit->append(lineStr); |
779 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 777 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
780 | } | 778 | } |
781 | 779 | ||
782 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 780 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) |
783 | { | 781 | { |
784 | if ( o->inherits( "QLineEdit" ) ) | 782 | if ( o->inherits( "QLineEdit" ) ) |
785 | { | 783 | { |
786 | if ( e->type() == QEvent::KeyPress ) | 784 | if ( e->type() == QEvent::KeyPress ) |
787 | { | 785 | { |
788 | QKeyEvent *ke = (QKeyEvent*)e; | 786 | QKeyEvent *ke = (QKeyEvent*)e; |
789 | if ( ke->key() == Key_Return || | 787 | if ( ke->key() == Key_Return || |
790 | ke->key() == Key_Enter ) | 788 | ke->key() == Key_Enter ) |
791 | { | 789 | { |
792 | okRename(); | 790 | okRename(); |
793 | return true; | 791 | return true; |
794 | } | 792 | } |
795 | else if ( ke->key() == Key_Escape ) | 793 | else if ( ke->key() == Key_Escape ) |
796 | { | 794 | { |
797 | cancelRename(); | 795 | cancelRename(); |
798 | return true; | 796 | return true; |
799 | } | 797 | } |
800 | } | 798 | } |
801 | else if ( e->type() == QEvent::FocusOut ) | 799 | else if ( e->type() == QEvent::FocusOut ) |
802 | { | 800 | { |
803 | cancelRename(); | 801 | cancelRename(); |
804 | return true; | 802 | return true; |
805 | } | 803 | } |
806 | } | 804 | } |
807 | if ( o->inherits( "QListView" ) ) | 805 | if ( o->inherits( "QListView" ) ) |
808 | { | 806 | { |
809 | if ( e->type() == QEvent::FocusOut ) | 807 | if ( e->type() == QEvent::FocusOut ) |
810 | { | 808 | { |
811 | printf("focusIn\n"); | 809 | printf("focusIn\n"); |
812 | 810 | ||
813 | } | 811 | } |
814 | } | 812 | } |
815 | 813 | ||
816 | return QWidget::eventFilter( o, e ); | 814 | return QWidget::eventFilter( o, e ); |
817 | } | 815 | } |
818 | 816 | ||
819 | 817 | ||
820 | void AdvancedFm::cancelRename() | 818 | void AdvancedFm::cancelRename() |
821 | { | 819 | { |
822 | qDebug("cancel rename"); | 820 | qDebug("cancel rename"); |
823 | QListView * view; | 821 | QListView * view; |
824 | view = CurrentView(); | 822 | view = CurrentView(); |
825 | 823 | ||
826 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 824 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
827 | delete renameBox; | 825 | delete renameBox; |
828 | renameBox = 0; | 826 | renameBox = 0; |
829 | if ( resetFocus ) | 827 | if ( resetFocus ) |
830 | { | 828 | { |
831 | view->viewport()->setFocusProxy( view); | 829 | view->viewport()->setFocusProxy( view); |
832 | view->setFocus(); | 830 | view->setFocus(); |
833 | } | 831 | } |
834 | } | 832 | } |
835 | 833 | ||
836 | void AdvancedFm::doRename(QListView * view) | 834 | void AdvancedFm::doRename(QListView * view) |
837 | { | 835 | { |
838 | 836 | ||
839 | QRect r = view->itemRect( view->currentItem( )); | 837 | QRect r = view->itemRect( view->currentItem( )); |
840 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 838 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
841 | r.setX( view->contentsX() ); | 839 | r.setX( view->contentsX() ); |
842 | if ( r.width() > view->visibleWidth() ) | 840 | if ( r.width() > view->visibleWidth() ) |
843 | r.setWidth( view->visibleWidth() ); | 841 | r.setWidth( view->visibleWidth() ); |
844 | 842 | ||
845 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 843 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
846 | renameBox->setFrame(true); | 844 | renameBox->setFrame(true); |
847 | 845 | ||
848 | renameBox->setText( view->currentItem()->text(0) ); | 846 | renameBox->setText( view->currentItem()->text(0) ); |
849 | 847 | ||
850 | renameBox->selectAll(); | 848 | renameBox->selectAll(); |
851 | renameBox->installEventFilter( this ); | 849 | renameBox->installEventFilter( this ); |
852 | view->addChild( renameBox, r.x(), r.y() ); | 850 | view->addChild( renameBox, r.x(), r.y() ); |
853 | renameBox->resize( r.size() ); | 851 | renameBox->resize( r.size() ); |
854 | view->viewport()->setFocusProxy( renameBox ); | 852 | view->viewport()->setFocusProxy( renameBox ); |
855 | renameBox->setFocus(); | 853 | renameBox->setFocus(); |
856 | renameBox->show(); | 854 | renameBox->show(); |
857 | 855 | ||
858 | } | 856 | } |
859 | 857 | ||
860 | 858 | ||
861 | void AdvancedFm::renameIt() | 859 | void AdvancedFm::renameIt() |
862 | { | 860 | { |
863 | QListView *thisView = CurrentView(); | 861 | QListView *thisView = CurrentView(); |
864 | oldName = thisView->currentItem()->text(0); | 862 | oldName = thisView->currentItem()->text(0); |
865 | doRename( thisView ); | 863 | doRename( thisView ); |
866 | populateView(); | 864 | populateView(); |
867 | } | 865 | } |
868 | 866 | ||
869 | void AdvancedFm::okRename() | 867 | void AdvancedFm::okRename() |
870 | { | 868 | { |
871 | QString newName = renameBox->text(); | 869 | QString newName = renameBox->text(); |
872 | cancelRename(); | 870 | cancelRename(); |
873 | // int tabs=0; | 871 | // int tabs=0; |
874 | QListView * view = CurrentView(); | 872 | QListView * view = CurrentView(); |
875 | QString path = CurrentDir()->canonicalPath() + "/"; | 873 | QString path = CurrentDir()->canonicalPath() + "/"; |
876 | oldName = path + oldName; | 874 | oldName = path + oldName; |
877 | newName = path + newName; | 875 | newName = path + newName; |
878 | 876 | ||
879 | if( view->currentItem() == NULL) | 877 | if( view->currentItem() == NULL) |
880 | return; | 878 | return; |
881 | if( rename( oldName.latin1(), newName.latin1())== -1) | 879 | if( rename( oldName.latin1(), newName.latin1())== -1) |
882 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 880 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
883 | else | 881 | else |
884 | oldName = ""; | 882 | oldName = ""; |
885 | 883 | ||
886 | view->takeItem( view->currentItem() ); | 884 | view->takeItem( view->currentItem() ); |
887 | delete view->currentItem(); | 885 | delete view->currentItem(); |
888 | populateView(); | 886 | populateView(); |
889 | } | 887 | } |