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