author | llornkcor <llornkcor> | 2004-09-25 04:52:52 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-09-25 04:52:52 (UTC) |
commit | 2b31930ef559a2893f47aa866a706ea13d99a6f5 (patch) (unidiff) | |
tree | 2796ab2ebd826b2167a31cc3f8ca8ccb8c4900d1 | |
parent | 688bd5382ab60c2146050fc2ff36850ef08a79b9 (diff) | |
download | opie-2b31930ef559a2893f47aa866a706ea13d99a6f5.zip opie-2b31930ef559a2893f47aa866a706ea13d99a6f5.tar.gz opie-2b31930ef559a2893f47aa866a706ea13d99a6f5.tar.bz2 |
more redundant code
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 48332b7..9cb9aba 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -115,580 +115,575 @@ void AdvancedFm::populateView() { | |||
115 | QFileInfoListIterator it(*list); | 115 | QFileInfoListIterator it(*list); |
116 | QFileInfo *fi; | 116 | QFileInfo *fi; |
117 | while ( (fi=it.current()) ) { | 117 | while ( (fi=it.current()) ) { |
118 | if (fi->isSymLink() ) { | 118 | if (fi->isSymLink() ) { |
119 | QString symLink=fi->readLink(); | 119 | QString symLink=fi->readLink(); |
120 | QFileInfo sym( symLink); | 120 | QFileInfo sym( symLink); |
121 | fileS.sprintf( "%10i", sym.size() ); | 121 | fileS.sprintf( "%10i", sym.size() ); |
122 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 122 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
123 | fileDate = sym.lastModified().toString(); | 123 | fileDate = sym.lastModified().toString(); |
124 | } else { | 124 | } else { |
125 | fileS.sprintf( "%10i", fi->size() ); | 125 | fileS.sprintf( "%10i", fi->size() ); |
126 | fileL = fi->fileName(); | 126 | fileL = fi->fileName(); |
127 | fileDate= fi->lastModified().toString(); | 127 | fileDate= fi->lastModified().toString(); |
128 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 128 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
129 | // if(fileL == "..") | 129 | // if(fileL == "..") |
130 | fileL += "/"; | 130 | fileL += "/"; |
131 | isDir=TRUE; | 131 | isDir=TRUE; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | QFileInfo fileInfo( path + "/" + fileL); | 134 | QFileInfo fileInfo( path + "/" + fileL); |
135 | 135 | ||
136 | if(fileL !="./" && fi->exists()) { | 136 | if(fileL !="./" && fi->exists()) { |
137 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 137 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
138 | 138 | ||
139 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 139 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
140 | 140 | ||
141 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 141 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
142 | pm = Resource::loadPixmap( "lockedfolder" ); | 142 | pm = Resource::loadPixmap( "lockedfolder" ); |
143 | else | 143 | else |
144 | pm= Resource::loadPixmap( "folder" ); | 144 | pm= Resource::loadPixmap( "folder" ); |
145 | } | 145 | } |
146 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 146 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
147 | pm = Resource::loadPixmap( "exec"); | 147 | pm = Resource::loadPixmap( "exec"); |
148 | } | 148 | } |
149 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 149 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
150 | | fileInfo.permission( QFileInfo::ExeGroup) | 150 | | fileInfo.permission( QFileInfo::ExeGroup) |
151 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 151 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
152 | pm = Resource::loadPixmap( "exec"); | 152 | pm = Resource::loadPixmap( "exec"); |
153 | } | 153 | } |
154 | else if( !fi->isReadable() ) { | 154 | else if( !fi->isReadable() ) { |
155 | pm = Resource::loadPixmap( "locked" ); | 155 | pm = Resource::loadPixmap( "locked" ); |
156 | } | 156 | } |
157 | else { //everything else goes by mimetype | 157 | else { //everything else goes by mimetype |
158 | MimeType mt(fi->filePath()); | 158 | MimeType mt(fi->filePath()); |
159 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 159 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
160 | if(pm.isNull()) { | 160 | if(pm.isNull()) { |
161 | pm = unknownXpm; | 161 | pm = unknownXpm; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 164 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
165 | // odebug << " overlay link image" << oendl; | 165 | // odebug << " overlay link image" << oendl; |
166 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 166 | pm= Resource::loadPixmap( "advancedfm/symlink" ); |
167 | // pm= Resource::loadPixmap( "folder" ); | 167 | // pm= Resource::loadPixmap( "folder" ); |
168 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 168 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
169 | // QPainter painter( &pm ); | 169 | // QPainter painter( &pm ); |
170 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 170 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
171 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 171 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
172 | } | 172 | } |
173 | item->setPixmap( 0,pm); | 173 | item->setPixmap( 0,pm); |
174 | 174 | ||
175 | } | 175 | } |
176 | isDir=FALSE; | 176 | isDir=FALSE; |
177 | ++it; | 177 | ++it; |
178 | } | 178 | } |
179 | 179 | ||
180 | if( path.find("dev",0,TRUE) != -1) { | 180 | if( path.find("dev",0,TRUE) != -1) { |
181 | struct stat buf; | 181 | struct stat buf; |
182 | dev_t devT; | 182 | dev_t devT; |
183 | DIR *dir; | 183 | DIR *dir; |
184 | struct dirent *mydirent; | 184 | struct dirent *mydirent; |
185 | 185 | ||
186 | if((dir = opendir( path.latin1())) != NULL) | 186 | if((dir = opendir( path.latin1())) != NULL) |
187 | while ((mydirent = readdir(dir)) != NULL) { | 187 | while ((mydirent = readdir(dir)) != NULL) { |
188 | lstat( mydirent->d_name, &buf); | 188 | lstat( mydirent->d_name, &buf); |
189 | // odebug << mydirent->d_name << oendl; | 189 | // odebug << mydirent->d_name << oendl; |
190 | fileL.sprintf("%s", mydirent->d_name); | 190 | fileL.sprintf("%s", mydirent->d_name); |
191 | devT = buf.st_dev; | 191 | devT = buf.st_dev; |
192 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 192 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
193 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 193 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
194 | if( fileL.find(".") == -1 ) { | 194 | if( fileL.find(".") == -1 ) { |
195 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 195 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
196 | pm = unknownXpm; | 196 | pm = unknownXpm; |
197 | item->setPixmap( 0,pm); | 197 | item->setPixmap( 0,pm); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | closedir(dir); | 201 | closedir(dir); |
202 | } | 202 | } |
203 | 203 | ||
204 | thisView->setSorting( 3,FALSE); | 204 | thisView->setSorting( 3,FALSE); |
205 | fillCombo( (const QString &) path ); | 205 | fillCombo( (const QString &) path ); |
206 | } | 206 | } |
207 | 207 | ||
208 | void AdvancedFm::rePopulate() { | 208 | void AdvancedFm::rePopulate() { |
209 | // qDebug("repopulate views"); | 209 | // qDebug("repopulate views"); |
210 | populateView(); | 210 | populateView(); |
211 | setOtherTabCurrent(); | 211 | setOtherTabCurrent(); |
212 | populateView(); | 212 | populateView(); |
213 | 213 | ||
214 | // int tmpTab = whichTab; | 214 | // int tmpTab = whichTab; |
215 | // // odebug << "" << tmpTab << "" << oendl; | 215 | // // odebug << "" << tmpTab << "" << oendl; |
216 | 216 | ||
217 | // for(int i =1; i < 3; i++) { | 217 | // for(int i =1; i < 3; i++) { |
218 | // TabWidget->setCurrentWidget(i - 1); | 218 | // TabWidget->setCurrentWidget(i - 1); |
219 | // populateView(); | 219 | // populateView(); |
220 | // } | 220 | // } |
221 | // TabWidget->setCurrentWidget( tmpTab - 1); | 221 | // TabWidget->setCurrentWidget( tmpTab - 1); |
222 | } | 222 | } |
223 | 223 | ||
224 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 224 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
225 | // if ( TabWidget->currentWidget() == tab) | 225 | // if ( TabWidget->currentWidget() == tab) |
226 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); | 226 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); |
227 | // else | 227 | // else |
228 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); | 228 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); |
229 | 229 | ||
230 | 230 | ||
231 | if(selectedItem) { | 231 | if(selectedItem) { |
232 | QString strItem=selectedItem->text(0); | 232 | QString strItem=selectedItem->text(0); |
233 | // owarn << strItem << oendl; | 233 | // owarn << strItem << oendl; |
234 | QString strSize=selectedItem->text(1); | 234 | QString strSize=selectedItem->text(1); |
235 | strSize=strSize.stripWhiteSpace(); | 235 | strSize=strSize.stripWhiteSpace(); |
236 | bool isDirectory = false; | 236 | bool isDirectory = false; |
237 | QString strItem2; | 237 | QString strItem2; |
238 | 238 | ||
239 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink | 239 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink |
240 | strItem2 = dealWithSymName((const QString&)strItem); | 240 | strItem2 = dealWithSymName((const QString&)strItem); |
241 | if(QDir(strItem2).exists() ) | 241 | if(QDir(strItem2).exists() ) |
242 | strItem = strItem2; | 242 | strItem = strItem2; |
243 | } | 243 | } |
244 | 244 | ||
245 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 245 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
246 | 246 | ||
247 | if(QDir(strItem).exists()) | 247 | if(QDir(strItem).exists()) |
248 | isDirectory = true; | 248 | isDirectory = true; |
249 | } | 249 | } |
250 | 250 | ||
251 | if( isDirectory ) { | 251 | if( isDirectory ) { |
252 | CurrentDir()->cd( strItem, TRUE); | 252 | CurrentDir()->cd( strItem, TRUE); |
253 | populateView(); | 253 | populateView(); |
254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
255 | } | 255 | } |
256 | chdir( strItem.latin1()); | 256 | chdir( strItem.latin1()); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 260 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
261 | Q_UNUSED(item); | 261 | Q_UNUSED(item); |
262 | switch (mouse) { | 262 | switch (mouse) { |
263 | case 1: | 263 | case 1: |
264 | { | 264 | { |
265 | if(renameBox != 0 ) { | 265 | if(renameBox != 0 ) { |
266 | cancelRename(); | 266 | cancelRename(); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | break; | 269 | break; |
270 | // case 2: | 270 | // case 2: |
271 | // menuTimer.start( 50, TRUE ); | 271 | // menuTimer.start( 50, TRUE ); |
272 | // break; | 272 | // break; |
273 | }; | 273 | }; |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void AdvancedFm::refreshCurrentTab() { | 277 | void AdvancedFm::refreshCurrentTab() { |
278 | populateView(); | 278 | populateView(); |
279 | // if ( TabWidget->currentWidget() == tab) { | 279 | // if ( TabWidget->currentWidget() == tab) { |
280 | 280 | ||
281 | } | 281 | } |
282 | 282 | ||
283 | void AdvancedFm::switchToLocalTab() { | 283 | void AdvancedFm::switchToLocalTab() { |
284 | TabWidget->setCurrentWidget(0); | 284 | TabWidget->setCurrentWidget(0); |
285 | Local_View->setFocus(); | 285 | Local_View->setFocus(); |
286 | whichTab = 1; | 286 | whichTab = 1; |
287 | } | 287 | } |
288 | 288 | ||
289 | void AdvancedFm::switchToRemoteTab() { | 289 | void AdvancedFm::switchToRemoteTab() { |
290 | TabWidget->setCurrentWidget(1); | 290 | TabWidget->setCurrentWidget(1); |
291 | Remote_View->setFocus(); | 291 | Remote_View->setFocus(); |
292 | whichTab = 2; | 292 | whichTab = 2; |
293 | } | 293 | } |
294 | 294 | ||
295 | void AdvancedFm::currentPathComboChanged() { | 295 | void AdvancedFm::currentPathComboChanged() { |
296 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 296 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
297 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 297 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
298 | populateView(); | 298 | populateView(); |
299 | } else { | 299 | } else { |
300 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 300 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 304 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
305 | 305 | ||
306 | if ( TabWidget->currentWidget() == tab) { | 306 | if ( TabWidget->currentWidget() == tab) { |
307 | // if ( whichTab == 1) { | 307 | // if ( whichTab == 1) { |
308 | currentPathCombo->lineEdit()->setText( currentPath); | 308 | currentPathCombo->lineEdit()->setText( currentPath); |
309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
310 | currentPathCombo->clear(); | 310 | currentPathCombo->clear(); |
311 | localDirPathStringList.prepend( currentPath ); | 311 | localDirPathStringList.prepend( currentPath ); |
312 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 312 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
313 | } | 313 | } |
314 | } else { | 314 | } else { |
315 | currentPathCombo->lineEdit()->setText( currentPath); | 315 | currentPathCombo->lineEdit()->setText( currentPath); |
316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
317 | currentPathCombo->clear(); | 317 | currentPathCombo->clear(); |
318 | remoteDirPathStringList.prepend( currentPath ); | 318 | remoteDirPathStringList.prepend( currentPath ); |
319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
325 | chdir( currentPath.latin1() ); | 325 | chdir( currentPath.latin1() ); |
326 | CurrentDir()->cd( currentPath, TRUE); | 326 | CurrentDir()->cd( currentPath, TRUE); |
327 | populateView(); | 327 | populateView(); |
328 | update(); | 328 | update(); |
329 | } | 329 | } |
330 | 330 | ||
331 | QStringList AdvancedFm::getPath() { | 331 | QStringList AdvancedFm::getPath() { |
332 | QStringList strList; | 332 | QStringList strList; |
333 | QListView *thisView=CurrentView(); | 333 | QListView *thisView=CurrentView(); |
334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
335 | QListViewItemIterator it( thisView ); | 335 | QListViewItemIterator it( thisView ); |
336 | for ( ; it.current(); ++it ) { | 336 | for ( ; it.current(); ++it ) { |
337 | if ( it.current()->isSelected() ) { | 337 | if ( it.current()->isSelected() ) { |
338 | strList << it.current()->text(0); | 338 | strList << it.current()->text(0); |
339 | // odebug << it.current()->text(0) << oendl; | 339 | // odebug << it.current()->text(0) << oendl; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | return strList; | 342 | return strList; |
343 | } | 343 | } |
344 | 344 | ||
345 | void AdvancedFm::changeTo(QString dir) { | 345 | void AdvancedFm::changeTo(QString dir) { |
346 | chdir( dir.latin1()); | 346 | chdir( dir.latin1()); |
347 | CurrentDir()->cd(dir, TRUE); | 347 | CurrentDir()->cd(dir, TRUE); |
348 | populateView(); | 348 | populateView(); |
349 | update(); | 349 | update(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void AdvancedFm::homeButtonPushed() { | 352 | void AdvancedFm::homeButtonPushed() { |
353 | changeTo(QDir::homeDirPath()); | 353 | changeTo(QDir::homeDirPath()); |
354 | } | 354 | } |
355 | 355 | ||
356 | void AdvancedFm::docButtonPushed() { | 356 | void AdvancedFm::docButtonPushed() { |
357 | changeTo(QPEApplication::documentDir()); | 357 | changeTo(QPEApplication::documentDir()); |
358 | } | 358 | } |
359 | 359 | ||
360 | void AdvancedFm::SDButtonPushed() { | 360 | void AdvancedFm::SDButtonPushed() { |
361 | changeTo("/mnt/card");// this can change so fix | 361 | changeTo("/mnt/card");// this can change so fix |
362 | } | 362 | } |
363 | 363 | ||
364 | void AdvancedFm::CFButtonPushed() { | 364 | void AdvancedFm::CFButtonPushed() { |
365 | if(zaurusDevice) | 365 | if(zaurusDevice) |
366 | changeTo("/mnt/cf"); //zaurus | 366 | changeTo("/mnt/cf"); //zaurus |
367 | else | 367 | else |
368 | changeTo("/mnt/hda"); //ipaq | 368 | changeTo("/mnt/hda"); //ipaq |
369 | } | 369 | } |
370 | 370 | ||
371 | void AdvancedFm::QPEButtonPushed() { | ||
372 | changeTo(QPEApplication::qpeDir()); | ||
373 | } | ||
371 | 374 | ||
372 | void AdvancedFm::doAbout() { | 375 | void AdvancedFm::doAbout() { |
373 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); | 376 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); |
374 | } | 377 | } |
375 | 378 | ||
376 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 379 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
377 | qDebug("keypressevent"); | 380 | qDebug("keypressevent"); |
378 | } | 381 | } |
379 | 382 | ||
380 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 383 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
381 | qDebug("key release"); | 384 | qDebug("key release"); |
382 | if( CurrentView()->hasFocus() ) | 385 | if( CurrentView()->hasFocus() ) |
383 | e->ignore(); | 386 | e->ignore(); |
384 | if( e->key() == Key_Left ) | 387 | if( e->key() == Key_Left ) |
385 | upDir(); | 388 | upDir(); |
386 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 389 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
387 | navigateToSelected(); | 390 | navigateToSelected(); |
388 | else if( e->key() == Key_Tab) | 391 | else if( e->key() == Key_Tab) |
389 | setOtherTabCurrent(); | 392 | setOtherTabCurrent(); |
390 | else if( e->key() == Key_Delete ) | 393 | else if( e->key() == Key_Delete ) |
391 | del(); | 394 | del(); |
392 | else if( e->key() == Key_A) | 395 | else if( e->key() == Key_A) |
393 | copyAs(); | 396 | copyAs(); |
394 | else if( e->key() == Key_C) | 397 | else if( e->key() == Key_C) |
395 | copy(); | 398 | copy(); |
396 | else if( e->key() == Key_E) | 399 | else if( e->key() == Key_E) |
397 | runThis(); | 400 | runThis(); |
398 | else if( e->key() == Key_G) | 401 | else if( e->key() == Key_G) |
399 | currentPathCombo->lineEdit()->setFocus(); | 402 | currentPathCombo->lineEdit()->setFocus(); |
400 | else if( e->key() == Key_H ) | 403 | else if( e->key() == Key_H ) |
401 | showHidden(); | 404 | showHidden(); |
402 | else if( e->key() == Key_I) | 405 | else if( e->key() == Key_I) |
403 | fileStatus(); | 406 | fileStatus(); |
404 | else if( e->key() == Key_M) | 407 | else if( e->key() == Key_M) |
405 | move(); | 408 | move(); |
406 | else if( e->key() == Key_N ) | 409 | else if( e->key() == Key_N ) |
407 | mkDir(); | 410 | mkDir(); |
408 | else if( e->key() == Key_P) | 411 | else if( e->key() == Key_P) |
409 | filePerms(); | 412 | filePerms(); |
410 | else if( e->key() == Key_R ) | 413 | else if( e->key() == Key_R ) |
411 | rn(); | 414 | rn(); |
412 | else if( e->key() == Key_U ) | 415 | else if( e->key() == Key_U ) |
413 | upDir(); | 416 | upDir(); |
414 | else if( e->key() == Key_1) | 417 | else if( e->key() == Key_1) |
415 | switchToLocalTab(); | 418 | switchToLocalTab(); |
416 | else if( e->key() == Key_2) | 419 | else if( e->key() == Key_2) |
417 | switchToRemoteTab(); | 420 | switchToRemoteTab(); |
418 | else if( e->key() == Key_3) | 421 | else if( e->key() == Key_3) |
419 | CFButtonPushed(); | 422 | CFButtonPushed(); |
420 | else if( e->key() == Key_4) | 423 | else if( e->key() == Key_4) |
421 | SDButtonPushed(); | 424 | SDButtonPushed(); |
422 | else if( e->key() == Key_5 ) | 425 | else if( e->key() == Key_5 ) |
423 | homeButtonPushed(); | 426 | homeButtonPushed(); |
424 | else if( e->key() == Key_6 ) | 427 | else if( e->key() == Key_6 ) |
425 | docButtonPushed(); | 428 | docButtonPushed(); |
426 | else | 429 | else |
427 | e->accept(); | 430 | e->accept(); |
428 | } | 431 | } |
429 | 432 | ||
430 | 433 | ||
431 | void AdvancedFm::QPEButtonPushed() { | ||
432 | QString current = QPEApplication::qpeDir(); | ||
433 | chdir( current.latin1() ); | ||
434 | CurrentDir()->cd( current, TRUE); | ||
435 | populateView(); | ||
436 | update(); | ||
437 | } | ||
438 | |||
439 | void AdvancedFm::parsetab(const QString &fileName) { | 434 | void AdvancedFm::parsetab(const QString &fileName) { |
440 | 435 | ||
441 | fileSystemTypeList.clear(); | 436 | fileSystemTypeList.clear(); |
442 | fsList.clear(); | 437 | fsList.clear(); |
443 | struct mntent *me; | 438 | struct mntent *me; |
444 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 439 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
445 | if ( mntfp ) { | 440 | if ( mntfp ) { |
446 | while ( (me = getmntent( mntfp )) != 0 ) { | 441 | while ( (me = getmntent( mntfp )) != 0 ) { |
447 | QString deviceName = me->mnt_fsname; | 442 | QString deviceName = me->mnt_fsname; |
448 | QString filesystemType = me->mnt_type; | 443 | QString filesystemType = me->mnt_type; |
449 | QString mountDir = me->mnt_dir; | 444 | QString mountDir = me->mnt_dir; |
450 | if(deviceName != "none") { | 445 | if(deviceName != "none") { |
451 | if( fsList.contains(filesystemType) == 0 | 446 | if( fsList.contains(filesystemType) == 0 |
452 | & filesystemType.find("proc",0,TRUE) == -1 | 447 | & filesystemType.find("proc",0,TRUE) == -1 |
453 | & filesystemType.find("cramfs",0,TRUE) == -1 | 448 | & filesystemType.find("cramfs",0,TRUE) == -1 |
454 | & filesystemType.find("auto",0,TRUE) == -1) | 449 | & filesystemType.find("auto",0,TRUE) == -1) |
455 | fsList << filesystemType; | 450 | fsList << filesystemType; |
456 | fileSystemTypeList << mountDir+"::"+filesystemType; | 451 | fileSystemTypeList << mountDir+"::"+filesystemType; |
457 | } | 452 | } |
458 | } | 453 | } |
459 | } | 454 | } |
460 | endmntent( mntfp ); | 455 | endmntent( mntfp ); |
461 | } | 456 | } |
462 | 457 | ||
463 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 458 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
464 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 459 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
465 | QString current = currentText;//.right( currentText.length()-1); | 460 | QString current = currentText;//.right( currentText.length()-1); |
466 | QString baseFs; | 461 | QString baseFs; |
467 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 462 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
468 | QString temp = (*it); | 463 | QString temp = (*it); |
469 | QString path = temp.left(temp.find("::",0,TRUE) ); | 464 | QString path = temp.left(temp.find("::",0,TRUE) ); |
470 | path = path.right( path.length()-1); | 465 | path = path.right( path.length()-1); |
471 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 466 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
472 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 467 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
473 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 468 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
474 | } | 469 | } |
475 | } | 470 | } |
476 | return baseFs; | 471 | return baseFs; |
477 | } | 472 | } |
478 | 473 | ||
479 | QString AdvancedFm::getDiskSpace( const QString &path) { | 474 | QString AdvancedFm::getDiskSpace( const QString &path) { |
480 | struct statfs fss; | 475 | struct statfs fss; |
481 | if ( !statfs( path.latin1(), &fss ) ) { | 476 | if ( !statfs( path.latin1(), &fss ) ) { |
482 | int blkSize = fss.f_bsize; | 477 | int blkSize = fss.f_bsize; |
483 | // int totalBlks = fs.f_blocks; | 478 | // int totalBlks = fs.f_blocks; |
484 | int availBlks = fss.f_bavail; | 479 | int availBlks = fss.f_bavail; |
485 | 480 | ||
486 | long mult = blkSize / 1024; | 481 | long mult = blkSize / 1024; |
487 | long div = 1024 / blkSize; | 482 | long div = 1024 / blkSize; |
488 | if ( !mult ) mult = 1; | 483 | if ( !mult ) mult = 1; |
489 | if ( !div ) div = 1; | 484 | if ( !div ) div = 1; |
490 | 485 | ||
491 | return QString::number(availBlks * mult / div); | 486 | return QString::number(availBlks * mult / div); |
492 | } | 487 | } |
493 | return ""; | 488 | return ""; |
494 | } | 489 | } |
495 | 490 | ||
496 | 491 | ||
497 | void AdvancedFm::showFileMenu() { | 492 | void AdvancedFm::showFileMenu() { |
498 | QString curApp; | 493 | QString curApp; |
499 | curApp = CurrentView()->currentItem()->text(0); | 494 | curApp = CurrentView()->currentItem()->text(0); |
500 | 495 | ||
501 | MimeType mt(curApp); | 496 | MimeType mt(curApp); |
502 | const AppLnk* app = mt.application(); | 497 | const AppLnk* app = mt.application(); |
503 | QFile fi(curApp); | 498 | QFile fi(curApp); |
504 | QPopupMenu *m = new QPopupMenu(0); | 499 | QPopupMenu *m = new QPopupMenu(0); |
505 | QPopupMenu *n = new QPopupMenu(0); | 500 | QPopupMenu *n = new QPopupMenu(0); |
506 | // QPopupMenu *o = new QPopupMenu(0); | 501 | // QPopupMenu *o = new QPopupMenu(0); |
507 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); | 502 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); |
508 | 503 | ||
509 | if ( QFileInfo(fi).isDir()) { | 504 | if ( QFileInfo(fi).isDir()) { |
510 | m->insertSeparator(); | 505 | m->insertSeparator(); |
511 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); | 506 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); |
512 | } else { | 507 | } else { |
513 | 508 | ||
514 | if (app) | 509 | if (app) |
515 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 510 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
516 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 511 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
517 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 512 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
518 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); | 513 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); |
519 | } | 514 | } |
520 | 515 | ||
521 | m->insertItem(tr("Actions"),n); | 516 | m->insertItem(tr("Actions"),n); |
522 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); | 517 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); |
523 | 518 | ||
524 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); | 519 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); |
525 | 520 | ||
526 | n->insertSeparator(); | 521 | n->insertSeparator(); |
527 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); | 522 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); |
528 | 523 | ||
529 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); | 524 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); |
530 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); | 525 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); |
531 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); | 526 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); |
532 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); | 527 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); |
533 | 528 | ||
534 | n->insertSeparator(); | 529 | n->insertSeparator(); |
535 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); | 530 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); |
536 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); | 531 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); |
537 | 532 | ||
538 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); | 533 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); |
539 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); | 534 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); |
540 | 535 | ||
541 | m->insertSeparator(); | 536 | m->insertSeparator(); |
542 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); | 537 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); |
543 | 538 | ||
544 | #if defined(QT_QWS_OPIE) | 539 | #if defined(QT_QWS_OPIE) |
545 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); | 540 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); |
546 | #endif | 541 | #endif |
547 | m->setCheckable(TRUE); | 542 | m->setCheckable(TRUE); |
548 | if (!b) | 543 | if (!b) |
549 | m->setItemChecked(m->idAt(0),TRUE); | 544 | m->setItemChecked(m->idAt(0),TRUE); |
550 | else | 545 | else |
551 | m->setItemChecked(m->idAt(0),FALSE); | 546 | m->setItemChecked(m->idAt(0),FALSE); |
552 | 547 | ||
553 | if(Ir::supported()) | 548 | if(Ir::supported()) |
554 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); | 549 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); |
555 | m->setFocus(); | 550 | m->setFocus(); |
556 | 551 | ||
557 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); | 552 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); |
558 | 553 | ||
559 | if(m) delete m; | 554 | if(m) delete m; |
560 | } | 555 | } |
561 | 556 | ||
562 | 557 | ||
563 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 558 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
564 | struct statfs fss; | 559 | struct statfs fss; |
565 | if ( !statfs( path.latin1(), &fss ) ) { | 560 | if ( !statfs( path.latin1(), &fss ) ) { |
566 | int blkSize = fss.f_bsize; | 561 | int blkSize = fss.f_bsize; |
567 | // int totalBlks = fs.f_blocks; | 562 | // int totalBlks = fs.f_blocks; |
568 | int availBlks = fss.f_bavail; | 563 | int availBlks = fss.f_bavail; |
569 | 564 | ||
570 | long mult = blkSize / 1024; | 565 | long mult = blkSize / 1024; |
571 | long div = 1024 / blkSize; | 566 | long div = 1024 / blkSize; |
572 | if ( !mult ) mult = 1; | 567 | if ( !mult ) mult = 1; |
573 | if ( !div ) div = 1; | 568 | if ( !div ) div = 1; |
574 | 569 | ||
575 | 570 | ||
576 | return QString::number(availBlks * mult / div); | 571 | return QString::number(availBlks * mult / div); |
577 | } | 572 | } |
578 | return ""; | 573 | return ""; |
579 | } | 574 | } |
580 | 575 | ||
581 | void AdvancedFm::addToDocs() { | 576 | void AdvancedFm::addToDocs() { |
582 | QStringList strListPaths = getPath(); | 577 | QStringList strListPaths = getPath(); |
583 | QDir *thisDir = CurrentDir(); | 578 | QDir *thisDir = CurrentDir(); |
584 | 579 | ||
585 | if( strListPaths.count() > 0) { | 580 | if( strListPaths.count() > 0) { |
586 | QString curFile; | 581 | QString curFile; |
587 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 582 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
588 | curFile = thisDir->canonicalPath()+"/"+(*it); | 583 | curFile = thisDir->canonicalPath()+"/"+(*it); |
589 | // odebug << curFile << oendl; | 584 | // odebug << curFile << oendl; |
590 | QFileInfo fi(curFile); | 585 | QFileInfo fi(curFile); |
591 | DocLnk f; | 586 | DocLnk f; |
592 | // curFile.replace(QRegExp("\\..*"),""); | 587 | // curFile.replace(QRegExp("\\..*"),""); |
593 | f.setName(fi.baseName() ); | 588 | f.setName(fi.baseName() ); |
594 | f.setFile( curFile); | 589 | f.setFile( curFile); |
595 | f.writeLink(); | 590 | f.writeLink(); |
596 | } | 591 | } |
597 | } | 592 | } |
598 | } | 593 | } |
599 | 594 | ||
600 | 595 | ||
601 | void AdvancedFm::customDirsToMenu() { | 596 | void AdvancedFm::customDirsToMenu() { |
602 | 597 | ||
603 | Config cfg("AdvancedFm"); | 598 | Config cfg("AdvancedFm"); |
604 | cfg.setGroup("Menu"); | 599 | cfg.setGroup("Menu"); |
605 | 600 | ||
606 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 601 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
607 | menuButton->insertItems(list ); | 602 | menuButton->insertItems(list ); |
608 | 603 | ||
609 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 604 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
610 | // { | 605 | // { |
611 | // customDirMenu->insertItem(*it ); | 606 | // customDirMenu->insertItem(*it ); |
612 | // } | 607 | // } |
613 | } | 608 | } |
614 | 609 | ||
615 | void AdvancedFm::dirMenuSelected(int item) { | 610 | void AdvancedFm::dirMenuSelected(int item) { |
616 | switch(item) | 611 | switch(item) |
617 | { | 612 | { |
618 | 613 | ||
619 | case -21: | 614 | case -21: |
620 | case 0: | 615 | case 0: |
621 | addCustomDir(); | 616 | addCustomDir(); |
622 | break; | 617 | break; |
623 | case -22: | 618 | case -22: |
624 | case 1: | 619 | case 1: |
625 | removeCustomDir(); | 620 | removeCustomDir(); |
626 | break; | 621 | break; |
627 | default: | 622 | default: |
628 | { | 623 | { |
629 | // gotoCustomDir( menuButton->text(item)); | 624 | // gotoCustomDir( menuButton->text(item)); |
630 | // gotoCustomDir( customDirMenu->text(item)); | 625 | // gotoCustomDir( customDirMenu->text(item)); |
631 | } | 626 | } |
632 | break; | 627 | break; |
633 | 628 | ||
634 | }; | 629 | }; |
635 | } | 630 | } |
636 | 631 | ||
637 | void AdvancedFm::addCustomDir() { | 632 | void AdvancedFm::addCustomDir() { |
638 | Config cfg("AdvancedFm"); | 633 | Config cfg("AdvancedFm"); |
639 | cfg.setGroup("Menu"); | 634 | cfg.setGroup("Menu"); |
640 | QString dir; | 635 | QString dir; |
641 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 636 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
642 | 637 | ||
643 | dir = CurrentDir()->canonicalPath(); | 638 | dir = CurrentDir()->canonicalPath(); |
644 | 639 | ||
645 | bool addIt=true; | 640 | bool addIt=true; |
646 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 641 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
647 | if( dir == (*it)) { | 642 | if( dir == (*it)) { |
648 | addIt=false; | 643 | addIt=false; |
649 | } | 644 | } |
650 | } | 645 | } |
651 | if(addIt) { | 646 | if(addIt) { |
652 | menuButton->insertItem(dir); | 647 | menuButton->insertItem(dir); |
653 | // customDirMenu->insertItem(dir); | 648 | // customDirMenu->insertItem(dir); |
654 | list << dir; | 649 | list << dir; |
655 | } | 650 | } |
656 | 651 | ||
657 | cfg.writeEntry("CustomDir", list, ','); | 652 | cfg.writeEntry("CustomDir", list, ','); |
658 | cfg.write(); | 653 | cfg.write(); |
659 | } | 654 | } |
660 | 655 | ||
661 | void AdvancedFm::removeCustomDir() { | 656 | void AdvancedFm::removeCustomDir() { |
662 | // odebug << "remove custom dir" << oendl; | 657 | // odebug << "remove custom dir" << oendl; |
663 | Config cfg("AdvancedFm"); | 658 | Config cfg("AdvancedFm"); |
664 | cfg.setGroup("Menu"); | 659 | cfg.setGroup("Menu"); |
665 | QString dir; | 660 | QString dir; |
666 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 661 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
667 | QStringList list2; | 662 | QStringList list2; |
668 | dir = CurrentDir()->canonicalPath(); | 663 | dir = CurrentDir()->canonicalPath(); |
669 | int ramble=2; | 664 | int ramble=2; |
670 | // int ramble=-24; | 665 | // int ramble=-24; |
671 | //first remove list | 666 | //first remove list |
672 | if(list.grep(dir,true).isEmpty()) { | 667 | if(list.grep(dir,true).isEmpty()) { |
673 | QMessageBox::message(tr( "AdvancedFm" ), | 668 | QMessageBox::message(tr( "AdvancedFm" ), |
674 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); | 669 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); |
675 | } else { | 670 | } else { |
676 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 671 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
677 | if((*it) != dir) { | 672 | if((*it) != dir) { |
678 | //current item is not our current dir, so add it to temp list | 673 | //current item is not our current dir, so add it to temp list |
679 | list2 <<(*it); | 674 | list2 <<(*it); |
680 | } else { | 675 | } else { |
681 | // customDirMenu->removeItem( ramble); | 676 | // customDirMenu->removeItem( ramble); |
682 | menuButton->remove( ramble); | 677 | menuButton->remove( ramble); |
683 | 678 | ||
684 | } | 679 | } |
685 | ramble++; | 680 | ramble++; |
686 | // ramble--; | 681 | // ramble--; |
687 | } | 682 | } |
688 | 683 | ||
689 | cfg.writeEntry("CustomDir", list2, ','); | 684 | cfg.writeEntry("CustomDir", list2, ','); |
690 | cfg.write(); | 685 | cfg.write(); |
691 | } | 686 | } |
692 | // customDirsToMenu(); | 687 | // customDirsToMenu(); |
693 | 688 | ||
694 | } | 689 | } |