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