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