-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 9606269..3a8c22d 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -172,1497 +172,1497 @@ AdvancedFm::AdvancedFm( ) | |||
172 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); | 172 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); |
173 | 173 | ||
174 | TabWidget->insertTab( tab, tr("1")); | 174 | TabWidget->insertTab( tab, tr("1")); |
175 | 175 | ||
176 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 176 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
177 | tabLayout_2 = new QGridLayout( tab_2 ); | 177 | tabLayout_2 = new QGridLayout( tab_2 ); |
178 | tabLayout_2->setSpacing( 2); | 178 | tabLayout_2->setSpacing( 2); |
179 | tabLayout_2->setMargin( 2); | 179 | tabLayout_2->setMargin( 2); |
180 | 180 | ||
181 | Remote_View = new QListView( tab_2, "Remote_View" ); | 181 | Remote_View = new QListView( tab_2, "Remote_View" ); |
182 | Remote_View->addColumn( tr("File"),130); | 182 | Remote_View->addColumn( tr("File"),130); |
183 | Remote_View->addColumn( tr("Size"),-1); | 183 | Remote_View->addColumn( tr("Size"),-1); |
184 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 184 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
185 | Remote_View->addColumn( tr("Date"),-1); | 185 | Remote_View->addColumn( tr("Date"),-1); |
186 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 186 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
187 | Remote_View->setAllColumnsShowFocus(TRUE); | 187 | Remote_View->setAllColumnsShowFocus(TRUE); |
188 | Remote_View->setMultiSelection( TRUE ); | 188 | Remote_View->setMultiSelection( TRUE ); |
189 | Remote_View->setSelectionMode(QListView::Extended); | 189 | Remote_View->setSelectionMode(QListView::Extended); |
190 | 190 | ||
191 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 191 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
192 | 192 | ||
193 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 193 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
194 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 194 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
195 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 195 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
196 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 196 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
197 | 197 | ||
198 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 198 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
199 | 199 | ||
200 | TabWidget->insertTab( tab_2, tr( "2")); | 200 | TabWidget->insertTab( tab_2, tr( "2")); |
201 | 201 | ||
202 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 202 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
203 | this,SLOT(tabChanged(QWidget*))); | 203 | this,SLOT(tabChanged(QWidget*))); |
204 | 204 | ||
205 | // tab_3 = new QWidget( TabWidget, "tab_3" ); | 205 | // tab_3 = new QWidget( TabWidget, "tab_3" ); |
206 | // tabLayout_3 = new QGridLayout( tab_3 ); | 206 | // tabLayout_3 = new QGridLayout( tab_3 ); |
207 | // tabLayout_3->setSpacing( 2); | 207 | // tabLayout_3->setSpacing( 2); |
208 | // tabLayout_3->setMargin( 2); | 208 | // tabLayout_3->setMargin( 2); |
209 | 209 | ||
210 | // OFileSelector *fileSelector; | 210 | // OFileSelector *fileSelector; |
211 | // fileSelector = new OFileSelector(tab_3,0,0,"/","","*"); | 211 | // fileSelector = new OFileSelector(tab_3,0,0,"/","","*"); |
212 | // tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 ); | 212 | // tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 ); |
213 | 213 | ||
214 | // TabWidget->insertTab( tab_3, tr( "Files" ) ); | 214 | // TabWidget->insertTab( tab_3, tr( "Files" ) ); |
215 | 215 | ||
216 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 216 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
217 | currentDir.setPath( QDir::currentDirPath()); | 217 | currentDir.setPath( QDir::currentDirPath()); |
218 | 218 | ||
219 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 219 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
220 | currentRemoteDir.setPath( QDir::currentDirPath()); | 220 | currentRemoteDir.setPath( QDir::currentDirPath()); |
221 | 221 | ||
222 | b = TRUE; | 222 | b = TRUE; |
223 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 223 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
224 | currentPathCombo->setEditable(TRUE); | 224 | currentPathCombo->setEditable(TRUE); |
225 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); | 225 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); |
226 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 226 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
227 | 227 | ||
228 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 228 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
229 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 229 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
230 | 230 | ||
231 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 231 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
232 | this,SLOT(currentPathComboChanged())); | 232 | this,SLOT(currentPathComboChanged())); |
233 | 233 | ||
234 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 234 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
235 | 235 | ||
236 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); | 236 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7); |
237 | 237 | ||
238 | filterStr="*"; | 238 | filterStr="*"; |
239 | b=FALSE; | 239 | b=FALSE; |
240 | populateLocalView(); | 240 | populateLocalView(); |
241 | populateRemoteView(); | 241 | populateRemoteView(); |
242 | } | 242 | } |
243 | 243 | ||
244 | AdvancedFm::~AdvancedFm() | 244 | AdvancedFm::~AdvancedFm() |
245 | { | 245 | { |
246 | } | 246 | } |
247 | 247 | ||
248 | void AdvancedFm::cleanUp() | 248 | void AdvancedFm::cleanUp() |
249 | { | 249 | { |
250 | QString sfile=QDir::homeDirPath(); | 250 | QString sfile=QDir::homeDirPath(); |
251 | if(sfile.right(1) != "/") | 251 | if(sfile.right(1) != "/") |
252 | sfile+="/._temp"; | 252 | sfile+="/._temp"; |
253 | else | 253 | else |
254 | sfile+="._temp"; | 254 | sfile+="._temp"; |
255 | QFile file( sfile); | 255 | QFile file( sfile); |
256 | if(file.exists()) | 256 | if(file.exists()) |
257 | file.remove(); | 257 | file.remove(); |
258 | } | 258 | } |
259 | 259 | ||
260 | void AdvancedFm::tabChanged(QWidget *w) | 260 | void AdvancedFm::tabChanged(QWidget *w) |
261 | { | 261 | { |
262 | if (TabWidget->currentPageIndex() == 0) { | 262 | if (TabWidget->currentPageIndex() == 0) { |
263 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 263 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
264 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 264 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
265 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 265 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
266 | } | 266 | } |
267 | if (TabWidget->currentPageIndex() == 1) { | 267 | if (TabWidget->currentPageIndex() == 1) { |
268 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 268 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
269 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 269 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
270 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 270 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | void AdvancedFm::populateLocalView() | 275 | void AdvancedFm::populateLocalView() |
276 | { | 276 | { |
277 | QPixmap pm; | 277 | QPixmap pm; |
278 | Local_View->clear(); | 278 | Local_View->clear(); |
279 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 279 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
280 | currentDir.setMatchAllDirs(TRUE); | 280 | currentDir.setMatchAllDirs(TRUE); |
281 | currentDir.setNameFilter(filterStr); | 281 | currentDir.setNameFilter(filterStr); |
282 | QString fileL, fileS, fileDate; | 282 | QString fileL, fileS, fileDate; |
283 | // qDebug(currentDir.canonicalPath()); | 283 | // qDebug(currentDir.canonicalPath()); |
284 | // struct stat buf; | 284 | // struct stat buf; |
285 | // mode_t mode; | 285 | // mode_t mode; |
286 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 286 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
287 | setCaption("AdvancedFm :: "+fs); | 287 | setCaption("AdvancedFm :: "+fs); |
288 | bool isDir=FALSE; | 288 | bool isDir=FALSE; |
289 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 289 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
290 | QFileInfoListIterator it(*list); | 290 | QFileInfoListIterator it(*list); |
291 | QFileInfo *fi; | 291 | QFileInfo *fi; |
292 | while ( (fi=it.current()) ) { | 292 | while ( (fi=it.current()) ) { |
293 | if (fi->isSymLink() ) { | 293 | if (fi->isSymLink() ) { |
294 | QString symLink=fi->readLink(); | 294 | QString symLink=fi->readLink(); |
295 | // qDebug("Symlink detected "+symLink); | 295 | // qDebug("Symlink detected "+symLink); |
296 | QFileInfo sym( symLink); | 296 | QFileInfo sym( symLink); |
297 | fileS.sprintf( "%10li", sym.size() ); | 297 | fileS.sprintf( "%10li", sym.size() ); |
298 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 298 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
299 | fileDate = sym.lastModified().toString(); | 299 | fileDate = sym.lastModified().toString(); |
300 | } else { | 300 | } else { |
301 | fileS.sprintf( "%10li", fi->size() ); | 301 | fileS.sprintf( "%10li", fi->size() ); |
302 | fileL.sprintf( "%s",fi->fileName().data() ); | 302 | fileL.sprintf( "%s",fi->fileName().data() ); |
303 | fileDate= fi->lastModified().toString(); | 303 | fileDate= fi->lastModified().toString(); |
304 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 304 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
305 | fileL+="/"; | 305 | fileL+="/"; |
306 | isDir=TRUE; | 306 | isDir=TRUE; |
307 | // qDebug( fileL); | 307 | // qDebug( fileL); |
308 | } | 308 | } |
309 | } | 309 | } |
310 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 310 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
311 | if(fileL !="./" && fi->exists()) { | 311 | if(fileL !="./" && fi->exists()) { |
312 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 312 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
313 | 313 | ||
314 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 314 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
315 | 315 | ||
316 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 316 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
317 | pm = Resource::loadPixmap( "lockedfolder" ); | 317 | pm = Resource::loadPixmap( "lockedfolder" ); |
318 | else | 318 | else |
319 | pm= Resource::loadPixmap( "folder" ); | 319 | pm= Resource::loadPixmap( "folder" ); |
320 | // item->setPixmap( 0,pm ); | 320 | // item->setPixmap( 0,pm ); |
321 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 321 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
322 | pm = Resource::loadPixmap( "exec"); | 322 | pm = Resource::loadPixmap( "exec"); |
323 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 323 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
324 | | fileInfo.permission( QFileInfo::ExeGroup) | 324 | | fileInfo.permission( QFileInfo::ExeGroup) |
325 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 325 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
326 | pm = Resource::loadPixmap( "exec"); | 326 | pm = Resource::loadPixmap( "exec"); |
327 | // else { //is exec | 327 | // else { //is exec |
328 | // pm = Resource::loadPixmap( "exec"); | 328 | // pm = Resource::loadPixmap( "exec"); |
329 | // } | 329 | // } |
330 | // // item->setPixmap( 0,pm); | 330 | // // item->setPixmap( 0,pm); |
331 | } else if( !fi->isReadable() ) { | 331 | } else if( !fi->isReadable() ) { |
332 | pm = Resource::loadPixmap( "locked" ); | 332 | pm = Resource::loadPixmap( "locked" ); |
333 | // item->setPixmap( 0,pm); | 333 | // item->setPixmap( 0,pm); |
334 | } else { //everything else goes by mimetype | 334 | } else { //everything else goes by mimetype |
335 | MimeType mt(fi->filePath()); | 335 | MimeType mt(fi->filePath()); |
336 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 336 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
337 | if(pm.isNull()) | 337 | if(pm.isNull()) |
338 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 338 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
339 | // item->setPixmap( 0,pm); | 339 | // item->setPixmap( 0,pm); |
340 | } | 340 | } |
341 | item->setPixmap( 0,pm); | 341 | item->setPixmap( 0,pm); |
342 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 342 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
343 | // overlay link image | 343 | // overlay link image |
344 | pm= Resource::loadPixmap( "folder" ); | 344 | pm= Resource::loadPixmap( "folder" ); |
345 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 345 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
346 | QPainter painter( &pm ); | 346 | QPainter painter( &pm ); |
347 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 347 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
348 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 348 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
349 | item->setPixmap( 0, pm); | 349 | item->setPixmap( 0, pm); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | isDir=FALSE; | 352 | isDir=FALSE; |
353 | ++it; | 353 | ++it; |
354 | } | 354 | } |
355 | 355 | ||
356 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 356 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
357 | struct stat buf; | 357 | struct stat buf; |
358 | // struct stat st; | 358 | // struct stat st; |
359 | dev_t devT; | 359 | dev_t devT; |
360 | // mode_t mode; | 360 | // mode_t mode; |
361 | DIR *dir; | 361 | DIR *dir; |
362 | // int fd = 0; | 362 | // int fd = 0; |
363 | struct dirent *mydirent; | 363 | struct dirent *mydirent; |
364 | // int i = 1; | 364 | // int i = 1; |
365 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 365 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
366 | while ((mydirent = readdir(dir)) != NULL) { | 366 | while ((mydirent = readdir(dir)) != NULL) { |
367 | lstat( mydirent->d_name, &buf); | 367 | lstat( mydirent->d_name, &buf); |
368 | qDebug(mydirent->d_name); | 368 | qDebug(mydirent->d_name); |
369 | // mode = buf.st_mode; | 369 | // mode = buf.st_mode; |
370 | fileL.sprintf("%s", mydirent->d_name); | 370 | fileL.sprintf("%s", mydirent->d_name); |
371 | // fileS.sprintf("%d, %d", ); //this isn't correct | 371 | // fileS.sprintf("%d, %d", ); //this isn't correct |
372 | devT = buf.st_dev; | 372 | devT = buf.st_dev; |
373 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 373 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
374 | // fileS.sprintf("%d,%d", devT, devT); | 374 | // fileS.sprintf("%d,%d", devT, devT); |
375 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 375 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
376 | if( fileL.find(".") == -1 ){ | 376 | if( fileL.find(".") == -1 ){ |
377 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 377 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
378 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 378 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
379 | item->setPixmap( 0,pm); | 379 | item->setPixmap( 0,pm); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | closedir(dir); | 383 | closedir(dir); |
384 | } | 384 | } |
385 | 385 | ||
386 | Local_View->setSorting( 3,FALSE); | 386 | Local_View->setSorting( 3,FALSE); |
387 | fillCombo( (const QString &) currentDir.canonicalPath()); | 387 | fillCombo( (const QString &) currentDir.canonicalPath()); |
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | void AdvancedFm::populateRemoteView() | 391 | void AdvancedFm::populateRemoteView() |
392 | { | 392 | { |
393 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 393 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
394 | // QListViewItemIterator it( Remote_View ); | 394 | // QListViewItemIterator it( Remote_View ); |
395 | // for ( ; it.current(); ++it ) { | 395 | // for ( ; it.current(); ++it ) { |
396 | // if ( it.current()->isSelected() ) { | 396 | // if ( it.current()->isSelected() ) { |
397 | // QString strItem = it.current()->text(0); | 397 | // QString strItem = it.current()->text(0); |
398 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; | 398 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; |
399 | // QFileInfo fi(localFile); | 399 | // QFileInfo fi(localFile); |
400 | // } | 400 | // } |
401 | // } | 401 | // } |
402 | QPixmap pm; | 402 | QPixmap pm; |
403 | Remote_View->clear(); | 403 | Remote_View->clear(); |
404 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 404 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
405 | currentRemoteDir.setMatchAllDirs(TRUE); | 405 | currentRemoteDir.setMatchAllDirs(TRUE); |
406 | currentRemoteDir.setNameFilter(filterStr); | 406 | currentRemoteDir.setNameFilter(filterStr); |
407 | QString fileL, fileS, fileDate; | 407 | QString fileL, fileS, fileDate; |
408 | 408 | ||
409 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 409 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
410 | setCaption("AdvancedFm :: "+fs); | 410 | setCaption("AdvancedFm :: "+fs); |
411 | bool isDir=FALSE; | 411 | bool isDir=FALSE; |
412 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 412 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
413 | QFileInfoListIterator it(*list); | 413 | QFileInfoListIterator it(*list); |
414 | QFileInfo *fi; | 414 | QFileInfo *fi; |
415 | while ( (fi=it.current()) ) { | 415 | while ( (fi=it.current()) ) { |
416 | if (fi->isSymLink() ){ | 416 | if (fi->isSymLink() ){ |
417 | QString symLink=fi->readLink(); | 417 | QString symLink=fi->readLink(); |
418 | // qDebug("Symlink detected "+symLink); | 418 | // qDebug("Symlink detected "+symLink); |
419 | QFileInfo sym( symLink); | 419 | QFileInfo sym( symLink); |
420 | fileS.sprintf( "%10li", sym.size() ); | 420 | fileS.sprintf( "%10li", sym.size() ); |
421 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 421 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
422 | fileDate = sym.lastModified().toString(); | 422 | fileDate = sym.lastModified().toString(); |
423 | } else { | 423 | } else { |
424 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 424 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
425 | fileS.sprintf( "%10li", fi->size() ); | 425 | fileS.sprintf( "%10li", fi->size() ); |
426 | fileL.sprintf( "%s",fi->fileName().data() ); | 426 | fileL.sprintf( "%s",fi->fileName().data() ); |
427 | fileDate= fi->lastModified().toString(); | 427 | fileDate= fi->lastModified().toString(); |
428 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 428 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
429 | fileL+="/"; | 429 | fileL+="/"; |
430 | isDir=TRUE; | 430 | isDir=TRUE; |
431 | // qDebug( fileL); | 431 | // qDebug( fileL); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); | 434 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); |
435 | if(fileL !="./" && fi->exists()) { | 435 | if(fileL !="./" && fi->exists()) { |
436 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 436 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
437 | QPixmap pm; | 437 | QPixmap pm; |
438 | 438 | ||
439 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 439 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
440 | if( !QDir( fi->filePath() ).isReadable()) | 440 | if( !QDir( fi->filePath() ).isReadable()) |
441 | pm = Resource::loadPixmap( "lockedfolder" ); | 441 | pm = Resource::loadPixmap( "lockedfolder" ); |
442 | else | 442 | else |
443 | pm= Resource::loadPixmap( "folder" ); | 443 | pm= Resource::loadPixmap( "folder" ); |
444 | // item->setPixmap( 0,pm ); | 444 | // item->setPixmap( 0,pm ); |
445 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 445 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
446 | pm = Resource::loadPixmap( "exec"); | 446 | pm = Resource::loadPixmap( "exec"); |
447 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 447 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
448 | | fileInfo.permission( QFileInfo::ExeGroup) | 448 | | fileInfo.permission( QFileInfo::ExeGroup) |
449 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 449 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
450 | pm = Resource::loadPixmap( "exec"); | 450 | pm = Resource::loadPixmap( "exec"); |
451 | // item->setPixmap( 0,pm); | 451 | // item->setPixmap( 0,pm); |
452 | } else if( !fi->isReadable() ) { | 452 | } else if( !fi->isReadable() ) { |
453 | pm = Resource::loadPixmap( "locked" ); | 453 | pm = Resource::loadPixmap( "locked" ); |
454 | // item->setPixmap( 0,pm); | 454 | // item->setPixmap( 0,pm); |
455 | } else { | 455 | } else { |
456 | MimeType mt(fi->filePath()); | 456 | MimeType mt(fi->filePath()); |
457 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 457 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
458 | if(pm.isNull()) | 458 | if(pm.isNull()) |
459 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 459 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
460 | // item->setPixmap( 0,pm); | 460 | // item->setPixmap( 0,pm); |
461 | } | 461 | } |
462 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 462 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
463 | // overlay link image | 463 | // overlay link image |
464 | pm= Resource::loadPixmap( "folder" ); | 464 | pm= Resource::loadPixmap( "folder" ); |
465 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 465 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
466 | QPainter painter( &pm ); | 466 | QPainter painter( &pm ); |
467 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 467 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
468 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 468 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
469 | // item->setPixmap( 0, pm); | 469 | // item->setPixmap( 0, pm); |
470 | } | 470 | } |
471 | item->setPixmap( 0, pm); | 471 | item->setPixmap( 0, pm); |
472 | } | 472 | } |
473 | isDir=FALSE; | 473 | isDir=FALSE; |
474 | ++it; | 474 | ++it; |
475 | } | 475 | } |
476 | 476 | ||
477 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 477 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
478 | struct stat buf; | 478 | struct stat buf; |
479 | // struct stat st; | 479 | // struct stat st; |
480 | // mode_t mode; | 480 | // mode_t mode; |
481 | DIR *dir; | 481 | DIR *dir; |
482 | // int fd = 0; | 482 | // int fd = 0; |
483 | struct dirent *mydirent; | 483 | struct dirent *mydirent; |
484 | // int i = 1; | 484 | // int i = 1; |
485 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 485 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
486 | while ((mydirent = readdir(dir)) != NULL) { | 486 | while ((mydirent = readdir(dir)) != NULL) { |
487 | lstat( mydirent->d_name, &buf); | 487 | lstat( mydirent->d_name, &buf); |
488 | qDebug(mydirent->d_name); | 488 | qDebug(mydirent->d_name); |
489 | // mode = buf.st_mode; | 489 | // mode = buf.st_mode; |
490 | fileL.sprintf("%s", mydirent->d_name); | 490 | fileL.sprintf("%s", mydirent->d_name); |
491 | // fileS.sprintf("%d, %d", ); //this isn't correct | 491 | // fileS.sprintf("%d, %d", ); //this isn't correct |
492 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 492 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
493 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 493 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
494 | if( fileL.find(".") == -1 ){ | 494 | if( fileL.find(".") == -1 ){ |
495 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 495 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
496 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 496 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
497 | item->setPixmap( 0,pm); | 497 | item->setPixmap( 0,pm); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | closedir(dir); | 501 | closedir(dir); |
502 | } | 502 | } |
503 | 503 | ||
504 | Remote_View->setSorting( 3,FALSE); | 504 | Remote_View->setSorting( 3,FALSE); |
505 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 505 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
506 | } | 506 | } |
507 | 507 | ||
508 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) | 508 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) |
509 | { | 509 | { |
510 | if(selectedItem) { | 510 | if(selectedItem) { |
511 | QString strItem=selectedItem->text(0); | 511 | QString strItem=selectedItem->text(0); |
512 | QString strSize=selectedItem->text(1); | 512 | QString strSize=selectedItem->text(1); |
513 | strSize=strSize.stripWhiteSpace(); | 513 | strSize=strSize.stripWhiteSpace(); |
514 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 514 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
515 | // is symlink | 515 | // is symlink |
516 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 516 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
517 | if(QDir(strItem2).exists() ) { | 517 | if(QDir(strItem2).exists() ) { |
518 | currentDir.cd(strItem2, TRUE); | 518 | currentDir.cd(strItem2, TRUE); |
519 | populateLocalView(); | 519 | populateLocalView(); |
520 | } | 520 | } |
521 | } else { // not a symlink | 521 | } else { // not a symlink |
522 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 522 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
523 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 523 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
524 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 524 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
525 | currentDir.cd(strItem,FALSE); | 525 | currentDir.cd(strItem,FALSE); |
526 | populateLocalView(); | 526 | populateLocalView(); |
527 | } else { | 527 | } else { |
528 | currentDir.cdUp(); | 528 | currentDir.cdUp(); |
529 | populateLocalView(); | 529 | populateLocalView(); |
530 | } | 530 | } |
531 | if(QDir(strItem).exists()){ | 531 | if(QDir(strItem).exists()){ |
532 | currentDir.cd(strItem, TRUE); | 532 | currentDir.cd(strItem, TRUE); |
533 | populateLocalView(); | 533 | populateLocalView(); |
534 | } | 534 | } |
535 | } else { | 535 | } else { |
536 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 536 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
537 | if( QFile::exists(strItem ) ) { | 537 | if( QFile::exists(strItem ) ) { |
538 | qDebug("clicked item "+strItem); | 538 | qDebug("clicked item "+strItem); |
539 | DocLnk doc( strItem, FALSE ); | 539 | DocLnk doc( strItem, FALSE ); |
540 | doc.execute(); | 540 | doc.execute(); |
541 | // Local_View->clearSelection(); | 541 | // Local_View->clearSelection(); |
542 | } | 542 | } |
543 | } //end not symlink | 543 | } //end not symlink |
544 | chdir(strItem.latin1()); | 544 | chdir(strItem.latin1()); |
545 | } | 545 | } |
546 | } | 546 | } |
547 | } | 547 | } |
548 | 548 | ||
549 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) | 549 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) |
550 | { | 550 | { |
551 | if(selectedItem) { | 551 | if(selectedItem) { |
552 | QString strItem=selectedItem->text(0); | 552 | QString strItem=selectedItem->text(0); |
553 | QString strSize=selectedItem->text(1); | 553 | QString strSize=selectedItem->text(1); |
554 | strSize=strSize.stripWhiteSpace(); | 554 | strSize=strSize.stripWhiteSpace(); |
555 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 555 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
556 | // is symlink | 556 | // is symlink |
557 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 557 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
558 | if(QDir(strItem2).exists() ) { | 558 | if(QDir(strItem2).exists() ) { |
559 | currentRemoteDir.cd(strItem2, TRUE); | 559 | currentRemoteDir.cd(strItem2, TRUE); |
560 | populateRemoteView(); | 560 | populateRemoteView(); |
561 | } | 561 | } |
562 | } else { // not a symlink | 562 | } else { // not a symlink |
563 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 563 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
564 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 564 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
565 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 565 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
566 | currentRemoteDir.cd(strItem,FALSE); | 566 | currentRemoteDir.cd(strItem,FALSE); |
567 | populateRemoteView(); | 567 | populateRemoteView(); |
568 | } else { | 568 | } else { |
569 | currentRemoteDir.cdUp(); | 569 | currentRemoteDir.cdUp(); |
570 | populateRemoteView(); | 570 | populateRemoteView(); |
571 | } | 571 | } |
572 | if(QDir(strItem).exists()){ | 572 | if(QDir(strItem).exists()){ |
573 | currentRemoteDir.cd(strItem, TRUE); | 573 | currentRemoteDir.cd(strItem, TRUE); |
574 | populateRemoteView(); | 574 | populateRemoteView(); |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 577 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
578 | if( QFile::exists(strItem ) ) { | 578 | if( QFile::exists(strItem ) ) { |
579 | qDebug("clicked item "+strItem); | 579 | qDebug("clicked item "+strItem); |
580 | DocLnk doc( strItem, FALSE ); | 580 | DocLnk doc( strItem, FALSE ); |
581 | doc.execute(); | 581 | doc.execute(); |
582 | // Remote_View->clearSelection(); | 582 | // Remote_View->clearSelection(); |
583 | } | 583 | } |
584 | } //end not symlink | 584 | } //end not symlink |
585 | chdir(strItem.latin1()); | 585 | chdir(strItem.latin1()); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | 589 | ||
590 | void AdvancedFm::doLocalCd() | 590 | void AdvancedFm::doLocalCd() |
591 | { | 591 | { |
592 | localListClicked( Local_View->currentItem()); | 592 | localListClicked( Local_View->currentItem()); |
593 | } | 593 | } |
594 | 594 | ||
595 | void AdvancedFm::doRemoteCd() | 595 | void AdvancedFm::doRemoteCd() |
596 | { | 596 | { |
597 | localListClicked( Remote_View->currentItem()); | 597 | localListClicked( Remote_View->currentItem()); |
598 | } | 598 | } |
599 | 599 | ||
600 | void AdvancedFm::showHidden() | 600 | void AdvancedFm::showHidden() |
601 | { | 601 | { |
602 | if (b) { | 602 | if (b) { |
603 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 603 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
604 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 604 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
605 | // localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 605 | // localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
606 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 606 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
607 | b=FALSE; | 607 | b=FALSE; |
608 | 608 | ||
609 | } else { | 609 | } else { |
610 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 610 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
611 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 611 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
612 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 612 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
613 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 613 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
614 | b=TRUE; | 614 | b=TRUE; |
615 | } | 615 | } |
616 | populateLocalView(); | 616 | populateLocalView(); |
617 | 617 | ||
618 | } | 618 | } |
619 | 619 | ||
620 | void AdvancedFm::showRemoteHidden() | 620 | void AdvancedFm::showRemoteHidden() |
621 | { | 621 | { |
622 | if (b) { | 622 | if (b) { |
623 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 623 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
624 | // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); | 624 | // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); |
625 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 625 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
626 | b=TRUE; | 626 | b=TRUE; |
627 | 627 | ||
628 | } else { | 628 | } else { |
629 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 629 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
630 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 630 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
631 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 631 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
632 | b=FALSE; | 632 | b=FALSE; |
633 | } | 633 | } |
634 | populateRemoteView(); | 634 | populateRemoteView(); |
635 | } | 635 | } |
636 | 636 | ||
637 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 637 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
638 | { | 638 | { |
639 | switch (mouse) { | 639 | switch (mouse) { |
640 | case 1: | 640 | case 1: |
641 | break; | 641 | break; |
642 | case 2: | 642 | case 2: |
643 | showLocalMenu(item); | 643 | showLocalMenu(item); |
644 | Local_View->clearSelection(); | 644 | Local_View->clearSelection(); |
645 | break; | 645 | break; |
646 | }; | 646 | }; |
647 | } | 647 | } |
648 | 648 | ||
649 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 649 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
650 | { | 650 | { |
651 | switch (mouse) { | 651 | switch (mouse) { |
652 | case 1: | 652 | case 1: |
653 | break; | 653 | break; |
654 | case 2: | 654 | case 2: |
655 | showRemoteMenu(item); | 655 | showRemoteMenu(item); |
656 | Remote_View->clearSelection(); | 656 | Remote_View->clearSelection(); |
657 | break; | 657 | break; |
658 | }; | 658 | }; |
659 | } | 659 | } |
660 | 660 | ||
661 | void AdvancedFm::showLocalMenu(QListViewItem * item) | 661 | void AdvancedFm::showLocalMenu(QListViewItem * item) |
662 | { | 662 | { |
663 | if(item) { | 663 | if(item) { |
664 | QPopupMenu m; | 664 | QPopupMenu m; |
665 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 665 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
666 | m.insertSeparator(); | 666 | m.insertSeparator(); |
667 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 667 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
668 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 668 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
669 | else | 669 | else |
670 | m.insertItem( tr( "Open / Execute" ), this, SLOT( runThis() )); | 670 | m.insertItem( tr( "Open / Execute" ), this, SLOT( runThis() )); |
671 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 671 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
672 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 672 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
673 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 673 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
674 | m.insertSeparator(); | 674 | m.insertSeparator(); |
675 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 675 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
676 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 676 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
677 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 677 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
678 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 678 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
679 | m.insertSeparator(); | 679 | m.insertSeparator(); |
680 | m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); | 680 | m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); |
681 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 681 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
682 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 682 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
683 | m.insertSeparator(); | 683 | m.insertSeparator(); |
684 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 684 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
685 | m.insertSeparator(); | 685 | m.insertSeparator(); |
686 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 686 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
687 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings | 687 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings |
688 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 688 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
689 | m.setCheckable(TRUE); | 689 | m.setCheckable(TRUE); |
690 | if (!b) | 690 | if (!b) |
691 | m.setItemChecked(m.idAt(0),TRUE); | 691 | m.setItemChecked(m.idAt(0),TRUE); |
692 | else | 692 | else |
693 | m.setItemChecked(m.idAt(0),FALSE); | 693 | m.setItemChecked(m.idAt(0),FALSE); |
694 | m.exec( QCursor::pos() ); | 694 | m.exec( QCursor::pos() ); |
695 | } | 695 | } |
696 | } | 696 | } |
697 | 697 | ||
698 | void AdvancedFm::showRemoteMenu(QListViewItem * item) | 698 | void AdvancedFm::showRemoteMenu(QListViewItem * item) |
699 | { | 699 | { |
700 | if(item) { | 700 | if(item) { |
701 | QPopupMenu m; | 701 | QPopupMenu m; |
702 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); | 702 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); |
703 | m.insertSeparator(); | 703 | m.insertSeparator(); |
704 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 704 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
705 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 705 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
706 | else | 706 | else |
707 | m.insertItem( tr( "Open / Execute" ), this, SLOT( runThis() )); | 707 | m.insertItem( tr( "Open / Execute" ), this, SLOT( runThis() )); |
708 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 708 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
709 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 709 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
710 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 710 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
711 | m.insertSeparator(); | 711 | m.insertSeparator(); |
712 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 712 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
713 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 713 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
714 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 714 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
715 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 715 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
716 | m.insertSeparator(); | 716 | m.insertSeparator(); |
717 | m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); | 717 | m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); |
718 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 718 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
719 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 719 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
720 | m.insertSeparator(); | 720 | m.insertSeparator(); |
721 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 721 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
722 | m.insertSeparator(); | 722 | m.insertSeparator(); |
723 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 723 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
724 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings | 724 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings |
725 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 725 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
726 | m.setCheckable(TRUE); | 726 | m.setCheckable(TRUE); |
727 | if (!b) | 727 | if (!b) |
728 | m.setItemChecked(m.idAt(0),TRUE); | 728 | m.setItemChecked(m.idAt(0),TRUE); |
729 | else | 729 | else |
730 | m.setItemChecked(m.idAt(0),FALSE); | 730 | m.setItemChecked(m.idAt(0),FALSE); |
731 | m.exec( QCursor::pos() ); | 731 | m.exec( QCursor::pos() ); |
732 | } | 732 | } |
733 | } | 733 | } |
734 | 734 | ||
735 | void AdvancedFm::runThis() { | 735 | void AdvancedFm::runThis() { |
736 | // QFileInfo *fi; | 736 | // QFileInfo *fi; |
737 | QString fs; | 737 | QString fs; |
738 | if (TabWidget->currentPageIndex() == 0) { | 738 | if (TabWidget->currentPageIndex() == 0) { |
739 | QString curFile = Local_View->currentItem()->text(0); | 739 | QString curFile = Local_View->currentItem()->text(0); |
740 | 740 | ||
741 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 741 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
742 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | 742 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); |
743 | qDebug( fileInfo.owner()); | 743 | qDebug( fileInfo.owner()); |
744 | if( (fileInfo.permission( QFileInfo::ExeUser) | 744 | if( (fileInfo.permission( QFileInfo::ExeUser) |
745 | | fileInfo.permission( QFileInfo::ExeGroup) | 745 | | fileInfo.permission( QFileInfo::ExeGroup) |
746 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 746 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
747 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 747 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
748 | // if( fileInfo.isExecutable() | | 748 | // if( fileInfo.isExecutable() | |
749 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 749 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
750 | e << curFile; | 750 | e << curFile; |
751 | } else { | 751 | } else { |
752 | curFile = currentDir.canonicalPath()+"/"+curFile; | 752 | curFile = currentDir.canonicalPath()+"/"+curFile; |
753 | DocLnk nf(curFile); | 753 | DocLnk nf(curFile); |
754 | QString execStr = nf.exec(); | 754 | QString execStr = nf.exec(); |
755 | qDebug( execStr); | 755 | qDebug( execStr); |
756 | if( execStr.isEmpty() ) { | 756 | if( execStr.isEmpty() ) { |
757 | } else { | 757 | } else { |
758 | nf.execute(); | 758 | nf.execute(); |
759 | } | 759 | } |
760 | } | 760 | } |
761 | // MimeType mt( curFile); | 761 | // MimeType mt( curFile); |
762 | } else { | 762 | } else { |
763 | QString curFile = Remote_View->currentItem()->text(0); | 763 | QString curFile = Remote_View->currentItem()->text(0); |
764 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 764 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
765 | qDebug("Filesystemtype is "+fs); | 765 | qDebug("Filesystemtype is "+fs); |
766 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | 766 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); |
767 | if( (fileInfo.permission( QFileInfo::ExeUser) | 767 | if( (fileInfo.permission( QFileInfo::ExeUser) |
768 | | fileInfo.permission( QFileInfo::ExeGroup) | 768 | | fileInfo.permission( QFileInfo::ExeGroup) |
769 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 769 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
770 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 770 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
771 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 771 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
772 | e << curFile; | 772 | e << curFile; |
773 | } else { | 773 | } else { |
774 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 774 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
775 | DocLnk nf(curFile); | 775 | DocLnk nf(curFile); |
776 | QString execStr = nf.exec(); | 776 | QString execStr = nf.exec(); |
777 | qDebug(execStr); | 777 | qDebug(execStr); |
778 | if( execStr.isEmpty() ) { | 778 | if( execStr.isEmpty() ) { |
779 | } else { | 779 | } else { |
780 | nf.execute(); | 780 | nf.execute(); |
781 | } | 781 | } |
782 | } | 782 | } |
783 | // MimeType mt( curFile); | 783 | // MimeType mt( curFile); |
784 | } | 784 | } |
785 | } | 785 | } |
786 | 786 | ||
787 | void AdvancedFm::runText() { | 787 | void AdvancedFm::runText() { |
788 | if (TabWidget->currentPageIndex() == 0) { | 788 | if (TabWidget->currentPageIndex() == 0) { |
789 | QString curFile = Local_View->currentItem()->text(0); | 789 | QString curFile = Local_View->currentItem()->text(0); |
790 | curFile = currentDir.canonicalPath()+"/"+curFile; | 790 | curFile = currentDir.canonicalPath()+"/"+curFile; |
791 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 791 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
792 | e << curFile; | 792 | e << curFile; |
793 | } else { | 793 | } else { |
794 | QString curFile = Remote_View->currentItem()->text(0); | 794 | QString curFile = Remote_View->currentItem()->text(0); |
795 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 795 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
796 | DocLnk nf(curFile); | 796 | DocLnk nf(curFile); |
797 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 797 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
798 | e << curFile; | 798 | e << curFile; |
799 | } | 799 | } |
800 | } | 800 | } |
801 | 801 | ||
802 | void AdvancedFm::localMakDir() | 802 | void AdvancedFm::localMakDir() |
803 | { | 803 | { |
804 | InputDialog *fileDlg; | 804 | InputDialog *fileDlg; |
805 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 805 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
806 | fileDlg->exec(); | 806 | fileDlg->exec(); |
807 | if( fileDlg->result() == 1 ) { | 807 | if( fileDlg->result() == 1 ) { |
808 | QString filename = fileDlg->LineEdit1->text(); | 808 | QString filename = fileDlg->LineEdit1->text(); |
809 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 809 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
810 | } | 810 | } |
811 | populateLocalView(); | 811 | populateLocalView(); |
812 | } | 812 | } |
813 | 813 | ||
814 | void AdvancedFm::remoteMakDir() | 814 | void AdvancedFm::remoteMakDir() |
815 | { | 815 | { |
816 | InputDialog *fileDlg; | 816 | InputDialog *fileDlg; |
817 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 817 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
818 | fileDlg->exec(); | 818 | fileDlg->exec(); |
819 | if( fileDlg->result() == 1 ) { | 819 | if( fileDlg->result() == 1 ) { |
820 | QString filename = fileDlg->LineEdit1->text(); | 820 | QString filename = fileDlg->LineEdit1->text(); |
821 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | 821 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); |
822 | } | 822 | } |
823 | populateRemoteView(); | 823 | populateRemoteView(); |
824 | } | 824 | } |
825 | 825 | ||
826 | void AdvancedFm::localDelete() | 826 | void AdvancedFm::localDelete() |
827 | { | 827 | { |
828 | QStringList curFileList = getPath(); | 828 | QStringList curFileList = getPath(); |
829 | QString myFile; | 829 | QString myFile; |
830 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 830 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
831 | myFile = (*it); | 831 | myFile = (*it); |
832 | if( myFile.find(" -> ",0,TRUE) != -1) | 832 | if( myFile.find(" -> ",0,TRUE) != -1) |
833 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 833 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
834 | 834 | ||
835 | QString f = currentDir.canonicalPath(); | 835 | QString f = currentDir.canonicalPath(); |
836 | if(f.right(1).find("/",0,TRUE) == -1) | 836 | if(f.right(1).find("/",0,TRUE) == -1) |
837 | f+="/"; | 837 | f+="/"; |
838 | f+=myFile; | 838 | f+=myFile; |
839 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 839 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
840 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 840 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
841 | "\nand all it's contents ?" | 841 | "\nand all it's contents ?" |
842 | ,tr("Yes"),tr("No"),0,0,1) ) { | 842 | ,tr("Yes"),tr("No"),0,0,1) ) { |
843 | case 0: { | 843 | case 0: { |
844 | f=f.left(f.length()-1); | 844 | f=f.left(f.length()-1); |
845 | QString cmd="rm -rf "+f; | 845 | QString cmd="rm -rf "+f; |
846 | system( cmd.latin1()); | 846 | system( cmd.latin1()); |
847 | populateLocalView(); | 847 | populateLocalView(); |
848 | } | 848 | } |
849 | break; | 849 | break; |
850 | case 1: | 850 | case 1: |
851 | // exit | 851 | // exit |
852 | break; | 852 | break; |
853 | }; | 853 | }; |
854 | 854 | ||
855 | } else { | 855 | } else { |
856 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 856 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
857 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 857 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
858 | case 0: { | 858 | case 0: { |
859 | QString cmd="rm "+f; | 859 | QString cmd="rm "+f; |
860 | QFile file(f); | 860 | QFile file(f); |
861 | file.remove(); | 861 | file.remove(); |
862 | // system( cmd.latin1()); | 862 | // system( cmd.latin1()); |
863 | populateLocalView(); | 863 | populateLocalView(); |
864 | } | 864 | } |
865 | break; | 865 | break; |
866 | case 1: | 866 | case 1: |
867 | // exit | 867 | // exit |
868 | break; | 868 | break; |
869 | }; | 869 | }; |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | void AdvancedFm::remoteDelete() | 874 | void AdvancedFm::remoteDelete() |
875 | { | 875 | { |
876 | QStringList curFileList = getPath(); | 876 | QStringList curFileList = getPath(); |
877 | QString myFile; | 877 | QString myFile; |
878 | 878 | ||
879 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 879 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
880 | myFile = (*it); | 880 | myFile = (*it); |
881 | if(myFile.find(" -> ",0,TRUE) != -1) | 881 | if(myFile.find(" -> ",0,TRUE) != -1) |
882 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 882 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
883 | QString f = currentRemoteDir.canonicalPath(); | 883 | QString f = currentRemoteDir.canonicalPath(); |
884 | if(f.right(1).find("/",0,TRUE) == -1) | 884 | if(f.right(1).find("/",0,TRUE) == -1) |
885 | f+="/"; | 885 | f+="/"; |
886 | f+=myFile; | 886 | f+=myFile; |
887 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 887 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
888 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 888 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
889 | "\nand all it's contents ?", | 889 | "\nand all it's contents ?", |
890 | tr("Yes"),tr("No"),0,0,1) ) { | 890 | tr("Yes"),tr("No"),0,0,1) ) { |
891 | case 0: { | 891 | case 0: { |
892 | f=f.left(f.length()-1); | 892 | f=f.left(f.length()-1); |
893 | QString cmd="rm -rf "+f; | 893 | QString cmd="rm -rf "+f; |
894 | system( cmd.latin1()); | 894 | system( cmd.latin1()); |
895 | populateRemoteView(); | 895 | populateRemoteView(); |
896 | } | 896 | } |
897 | break; | 897 | break; |
898 | case 1: | 898 | case 1: |
899 | // exit | 899 | // exit |
900 | break; | 900 | break; |
901 | }; | 901 | }; |
902 | 902 | ||
903 | } else { | 903 | } else { |
904 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 904 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
905 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 905 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
906 | case 0: { | 906 | case 0: { |
907 | QString cmd="rm "+f; | 907 | QString cmd="rm "+f; |
908 | QFile file(f); | 908 | QFile file(f); |
909 | file.remove(); | 909 | file.remove(); |
910 | // system( cmd.latin1()); | 910 | // system( cmd.latin1()); |
911 | populateRemoteView(); | 911 | populateRemoteView(); |
912 | } | 912 | } |
913 | break; | 913 | break; |
914 | case 1: | 914 | case 1: |
915 | // exit | 915 | // exit |
916 | break; | 916 | break; |
917 | }; | 917 | }; |
918 | } | 918 | } |
919 | } | 919 | } |
920 | } | 920 | } |
921 | 921 | ||
922 | void AdvancedFm::localRename() | 922 | void AdvancedFm::localRename() |
923 | { | 923 | { |
924 | QString curFile = Local_View->currentItem()->text(0); | 924 | QString curFile = Local_View->currentItem()->text(0); |
925 | InputDialog *fileDlg; | 925 | InputDialog *fileDlg; |
926 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 926 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
927 | fileDlg->setInputText((const QString &)curFile); | 927 | fileDlg->setInputText((const QString &)curFile); |
928 | fileDlg->exec(); | 928 | fileDlg->exec(); |
929 | if( fileDlg->result() == 1 ) { | 929 | if( fileDlg->result() == 1 ) { |
930 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 930 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
931 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 931 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
932 | if( rename(oldname.latin1(), newName.latin1())== -1) | 932 | if( rename(oldname.latin1(), newName.latin1())== -1) |
933 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 933 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
934 | } | 934 | } |
935 | populateLocalView(); | 935 | populateLocalView(); |
936 | } | 936 | } |
937 | 937 | ||
938 | void AdvancedFm::remoteRename() | 938 | void AdvancedFm::remoteRename() |
939 | { | 939 | { |
940 | QString curFile = remote_View->currentItem()->text(0); | 940 | QString curFile = Remote_View->currentItem()->text(0); |
941 | InputDialog *fileDlg; | 941 | InputDialog *fileDlg; |
942 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 942 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
943 | fileDlg->setInputText((const QString &)curFile); | 943 | fileDlg->setInputText((const QString &)curFile); |
944 | fileDlg->exec(); | 944 | fileDlg->exec(); |
945 | if( fileDlg->result() == 1 ) { | 945 | if( fileDlg->result() == 1 ) { |
946 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | 946 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; |
947 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 947 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
948 | if( rename(oldname.latin1(), newName.latin1())== -1) | 948 | if( rename(oldname.latin1(), newName.latin1())== -1) |
949 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 949 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
950 | } | 950 | } |
951 | populateRemoteView(); | 951 | populateRemoteView(); |
952 | } | 952 | } |
953 | 953 | ||
954 | void AdvancedFm::switchToLocalTab() | 954 | void AdvancedFm::switchToLocalTab() |
955 | { | 955 | { |
956 | TabWidget->setCurrentPage(0); | 956 | TabWidget->setCurrentPage(0); |
957 | Local_View->setFocus(); | 957 | Local_View->setFocus(); |
958 | } | 958 | } |
959 | 959 | ||
960 | void AdvancedFm::switchToRemoteTab() | 960 | void AdvancedFm::switchToRemoteTab() |
961 | { | 961 | { |
962 | TabWidget->setCurrentPage(1); | 962 | TabWidget->setCurrentPage(1); |
963 | Remote_View->setFocus(); | 963 | Remote_View->setFocus(); |
964 | } | 964 | } |
965 | 965 | ||
966 | void AdvancedFm::readConfig() | 966 | void AdvancedFm::readConfig() |
967 | { | 967 | { |
968 | Config cfg("AdvancedFm"); | 968 | Config cfg("AdvancedFm"); |
969 | } | 969 | } |
970 | 970 | ||
971 | void AdvancedFm::writeConfig() | 971 | void AdvancedFm::writeConfig() |
972 | { | 972 | { |
973 | Config cfg("AdvancedFm"); | 973 | Config cfg("AdvancedFm"); |
974 | } | 974 | } |
975 | 975 | ||
976 | void AdvancedFm::currentPathComboChanged() | 976 | void AdvancedFm::currentPathComboChanged() |
977 | { | 977 | { |
978 | if (TabWidget->currentPageIndex() == 0) { | 978 | if (TabWidget->currentPageIndex() == 0) { |
979 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 979 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
980 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 980 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
981 | populateLocalView(); | 981 | populateLocalView(); |
982 | } else { | 982 | } else { |
983 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 983 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
984 | } | 984 | } |
985 | } | 985 | } |
986 | if (TabWidget->currentPageIndex() == 0) { | 986 | if (TabWidget->currentPageIndex() == 0) { |
987 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 987 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
988 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 988 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
989 | populateRemoteView(); | 989 | populateRemoteView(); |
990 | } else { | 990 | } else { |
991 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 991 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
992 | } | 992 | } |
993 | } | 993 | } |
994 | } | 994 | } |
995 | 995 | ||
996 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 996 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
997 | 997 | ||
998 | if (TabWidget->currentPageIndex() == 0) { | 998 | if (TabWidget->currentPageIndex() == 0) { |
999 | currentPathCombo->lineEdit()->setText( currentPath); | 999 | currentPathCombo->lineEdit()->setText( currentPath); |
1000 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1000 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1001 | currentPathCombo->clear(); | 1001 | currentPathCombo->clear(); |
1002 | localDirPathStringList.prepend( currentPath ); | 1002 | localDirPathStringList.prepend( currentPath ); |
1003 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 1003 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
1004 | } | 1004 | } |
1005 | } else { | 1005 | } else { |
1006 | currentPathCombo->lineEdit()->setText( currentPath); | 1006 | currentPathCombo->lineEdit()->setText( currentPath); |
1007 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 1007 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
1008 | currentPathCombo->clear(); | 1008 | currentPathCombo->clear(); |
1009 | remoteDirPathStringList.prepend( currentPath ); | 1009 | remoteDirPathStringList.prepend( currentPath ); |
1010 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1010 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1011 | } | 1011 | } |
1012 | } | 1012 | } |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 1015 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
1016 | if (TabWidget->currentPageIndex() == 0) { | 1016 | if (TabWidget->currentPageIndex() == 0) { |
1017 | chdir( currentPath.latin1() ); | 1017 | chdir( currentPath.latin1() ); |
1018 | currentDir.cd( currentPath, TRUE); | 1018 | currentDir.cd( currentPath, TRUE); |
1019 | populateLocalView(); | 1019 | populateLocalView(); |
1020 | update(); | 1020 | update(); |
1021 | } else { | 1021 | } else { |
1022 | chdir( currentPath.latin1() ); | 1022 | chdir( currentPath.latin1() ); |
1023 | currentRemoteDir.cd( currentPath, TRUE); | 1023 | currentRemoteDir.cd( currentPath, TRUE); |
1024 | populateRemoteView(); | 1024 | populateRemoteView(); |
1025 | update(); | 1025 | update(); |
1026 | } | 1026 | } |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void AdvancedFm::filePerms() { | 1029 | void AdvancedFm::filePerms() { |
1030 | 1030 | ||
1031 | QStringList curFileList = getPath(); | 1031 | QStringList curFileList = getPath(); |
1032 | QString filePath; | 1032 | QString filePath; |
1033 | 1033 | ||
1034 | if (TabWidget->currentPageIndex() == 0) { | 1034 | if (TabWidget->currentPageIndex() == 0) { |
1035 | filePath = currentDir.canonicalPath()+"/"; | 1035 | filePath = currentDir.canonicalPath()+"/"; |
1036 | } else { | 1036 | } else { |
1037 | filePath= currentRemoteDir.canonicalPath()+"/"; | 1037 | filePath= currentRemoteDir.canonicalPath()+"/"; |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1040 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1041 | filePermissions *filePerm; | 1041 | filePermissions *filePerm; |
1042 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 1042 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
1043 | filePerm->showMaximized(); | 1043 | filePerm->showMaximized(); |
1044 | filePerm->exec(); | 1044 | filePerm->exec(); |
1045 | if( filePerm) | 1045 | if( filePerm) |
1046 | delete filePerm; | 1046 | delete filePerm; |
1047 | } | 1047 | } |
1048 | if (TabWidget->currentPageIndex() == 0) { | 1048 | if (TabWidget->currentPageIndex() == 0) { |
1049 | populateLocalView(); | 1049 | populateLocalView(); |
1050 | } else { | 1050 | } else { |
1051 | populateRemoteView(); | 1051 | populateRemoteView(); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | 1054 | ||
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | void AdvancedFm::doProperties() { | 1057 | void AdvancedFm::doProperties() { |
1058 | QStringList curFileList = getPath(); | 1058 | QStringList curFileList = getPath(); |
1059 | QString filePath; | 1059 | QString filePath; |
1060 | if (TabWidget->currentPageIndex() == 0) { | 1060 | if (TabWidget->currentPageIndex() == 0) { |
1061 | 1061 | ||
1062 | filePath = currentDir.canonicalPath()+"/"; | 1062 | filePath = currentDir.canonicalPath()+"/"; |
1063 | } else { | 1063 | } else { |
1064 | filePath= currentRemoteDir.canonicalPath()+"/"; | 1064 | filePath= currentRemoteDir.canonicalPath()+"/"; |
1065 | } | 1065 | } |
1066 | // qDebug("%d",curFileList.count()); | 1066 | // qDebug("%d",curFileList.count()); |
1067 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1067 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1068 | qDebug((filePath+*it)); | 1068 | qDebug((filePath+*it)); |
1069 | DocLnk lnk( (filePath+*it)); | 1069 | DocLnk lnk( (filePath+*it)); |
1070 | LnkProperties prop( &lnk ); | 1070 | LnkProperties prop( &lnk ); |
1071 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 1071 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
1072 | prop.showMaximized(); | 1072 | prop.showMaximized(); |
1073 | prop.exec(); | 1073 | prop.exec(); |
1074 | } | 1074 | } |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | QStringList AdvancedFm::getPath() { | 1077 | QStringList AdvancedFm::getPath() { |
1078 | QStringList strList; | 1078 | QStringList strList; |
1079 | if (TabWidget->currentPageIndex() == 0) { | 1079 | if (TabWidget->currentPageIndex() == 0) { |
1080 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 1080 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
1081 | QListViewItemIterator it( Local_View ); | 1081 | QListViewItemIterator it( Local_View ); |
1082 | for ( ; it.current(); ++it ) { | 1082 | for ( ; it.current(); ++it ) { |
1083 | if ( it.current()->isSelected() ) { | 1083 | if ( it.current()->isSelected() ) { |
1084 | strList << it.current()->text(0); | 1084 | strList << it.current()->text(0); |
1085 | } | 1085 | } |
1086 | } | 1086 | } |
1087 | return strList; | 1087 | return strList; |
1088 | } else { | 1088 | } else { |
1089 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1089 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1090 | QListViewItemIterator it( Remote_View ); | 1090 | QListViewItemIterator it( Remote_View ); |
1091 | for ( ; it.current(); ++it ) { | 1091 | for ( ; it.current(); ++it ) { |
1092 | if ( it.current()->isSelected() ) { | 1092 | if ( it.current()->isSelected() ) { |
1093 | strList << it.current()->text(0); | 1093 | strList << it.current()->text(0); |
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | return strList; | 1096 | return strList; |
1097 | } | 1097 | } |
1098 | return ""; | 1098 | return ""; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void AdvancedFm::homeButtonPushed() { | 1101 | void AdvancedFm::homeButtonPushed() { |
1102 | QString current = QDir::homeDirPath(); | 1102 | QString current = QDir::homeDirPath(); |
1103 | chdir( current.latin1() ); | 1103 | chdir( current.latin1() ); |
1104 | if (TabWidget->currentPageIndex() == 0) { | 1104 | if (TabWidget->currentPageIndex() == 0) { |
1105 | currentDir.cd( current, TRUE); | 1105 | currentDir.cd( current, TRUE); |
1106 | populateLocalView(); | 1106 | populateLocalView(); |
1107 | } else { | 1107 | } else { |
1108 | currentRemoteDir.cd( current, TRUE); | 1108 | currentRemoteDir.cd( current, TRUE); |
1109 | populateRemoteView(); | 1109 | populateRemoteView(); |
1110 | } | 1110 | } |
1111 | update(); | 1111 | update(); |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | void AdvancedFm::docButtonPushed() { | 1114 | void AdvancedFm::docButtonPushed() { |
1115 | QString current = QPEApplication::documentDir(); | 1115 | QString current = QPEApplication::documentDir(); |
1116 | chdir( current.latin1() ); | 1116 | chdir( current.latin1() ); |
1117 | if (TabWidget->currentPageIndex() == 0) { | 1117 | if (TabWidget->currentPageIndex() == 0) { |
1118 | currentDir.cd( current, TRUE); | 1118 | currentDir.cd( current, TRUE); |
1119 | populateLocalView(); | 1119 | populateLocalView(); |
1120 | } else { | 1120 | } else { |
1121 | currentRemoteDir.cd( current, TRUE); | 1121 | currentRemoteDir.cd( current, TRUE); |
1122 | populateRemoteView(); | 1122 | populateRemoteView(); |
1123 | } | 1123 | } |
1124 | update(); | 1124 | update(); |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | void AdvancedFm::SDButtonPushed() { | 1127 | void AdvancedFm::SDButtonPushed() { |
1128 | QString current = "/mnt/card"; | 1128 | QString current = "/mnt/card"; |
1129 | chdir( current.latin1() ); | 1129 | chdir( current.latin1() ); |
1130 | if (TabWidget->currentPageIndex() == 0) { | 1130 | if (TabWidget->currentPageIndex() == 0) { |
1131 | currentDir.cd( current, TRUE); | 1131 | currentDir.cd( current, TRUE); |
1132 | populateLocalView(); | 1132 | populateLocalView(); |
1133 | } else { | 1133 | } else { |
1134 | currentRemoteDir.cd( current, TRUE); | 1134 | currentRemoteDir.cd( current, TRUE); |
1135 | populateRemoteView(); | 1135 | populateRemoteView(); |
1136 | } | 1136 | } |
1137 | update(); | 1137 | update(); |
1138 | 1138 | ||
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | void AdvancedFm::CFButtonPushed() { | 1141 | void AdvancedFm::CFButtonPushed() { |
1142 | QString current = "/mnt/cf"; | 1142 | QString current = "/mnt/cf"; |
1143 | chdir( current.latin1() ); | 1143 | chdir( current.latin1() ); |
1144 | if (TabWidget->currentPageIndex() == 0) { | 1144 | if (TabWidget->currentPageIndex() == 0) { |
1145 | currentDir.cd( current, TRUE); | 1145 | currentDir.cd( current, TRUE); |
1146 | populateLocalView(); | 1146 | populateLocalView(); |
1147 | } else { | 1147 | } else { |
1148 | currentRemoteDir.cd( current, TRUE); | 1148 | currentRemoteDir.cd( current, TRUE); |
1149 | populateRemoteView(); | 1149 | populateRemoteView(); |
1150 | } | 1150 | } |
1151 | update(); | 1151 | update(); |
1152 | 1152 | ||
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | 1155 | ||
1156 | void AdvancedFm::upDir() | 1156 | void AdvancedFm::upDir() |
1157 | { | 1157 | { |
1158 | if (TabWidget->currentPageIndex() == 0) { | 1158 | if (TabWidget->currentPageIndex() == 0) { |
1159 | QString current = currentDir.canonicalPath(); | 1159 | QString current = currentDir.canonicalPath(); |
1160 | QDir dir(current); | 1160 | QDir dir(current); |
1161 | dir.cdUp(); | 1161 | dir.cdUp(); |
1162 | current = dir.canonicalPath(); | 1162 | current = dir.canonicalPath(); |
1163 | chdir( current.latin1() ); | 1163 | chdir( current.latin1() ); |
1164 | currentDir.cd( current, TRUE); | 1164 | currentDir.cd( current, TRUE); |
1165 | populateLocalView(); | 1165 | populateLocalView(); |
1166 | update(); | 1166 | update(); |
1167 | } else { | 1167 | } else { |
1168 | QString current = currentRemoteDir.canonicalPath(); | 1168 | QString current = currentRemoteDir.canonicalPath(); |
1169 | QDir dir(current); | 1169 | QDir dir(current); |
1170 | dir.cdUp(); | 1170 | dir.cdUp(); |
1171 | current = dir.canonicalPath(); | 1171 | current = dir.canonicalPath(); |
1172 | chdir( current.latin1() ); | 1172 | chdir( current.latin1() ); |
1173 | currentRemoteDir.cd( current, TRUE); | 1173 | currentRemoteDir.cd( current, TRUE); |
1174 | populateRemoteView(); | 1174 | populateRemoteView(); |
1175 | update(); | 1175 | update(); |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | void AdvancedFm::copy() | 1179 | void AdvancedFm::copy() |
1180 | { | 1180 | { |
1181 | QStringList curFileList = getPath(); | 1181 | QStringList curFileList = getPath(); |
1182 | QString curFile; | 1182 | QString curFile; |
1183 | if (TabWidget->currentPageIndex() == 0) { | 1183 | if (TabWidget->currentPageIndex() == 0) { |
1184 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1184 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1185 | 1185 | ||
1186 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1186 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1187 | // if(destFile.right(1).find("/",0,TRUE) == -1) | 1187 | // if(destFile.right(1).find("/",0,TRUE) == -1) |
1188 | // destFile+="/"; | 1188 | // destFile+="/"; |
1189 | // destFile +=(*it); | 1189 | // destFile +=(*it); |
1190 | 1190 | ||
1191 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1191 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1192 | // if(curFile.right(1).find("/",0,TRUE) == -1) | 1192 | // if(curFile.right(1).find("/",0,TRUE) == -1) |
1193 | // curFile +="/"; | 1193 | // curFile +="/"; |
1194 | // curFile +=(*it); | 1194 | // curFile +=(*it); |
1195 | 1195 | ||
1196 | QFile f(destFile); | 1196 | QFile f(destFile); |
1197 | if( f.exists()) | 1197 | if( f.exists()) |
1198 | f.remove(); | 1198 | f.remove(); |
1199 | if(!copyFile(destFile, curFile) ) { | 1199 | if(!copyFile(destFile, curFile) ) { |
1200 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1200 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1201 | qWarning("nothin doing"); | 1201 | qWarning("nothin doing"); |
1202 | } | 1202 | } |
1203 | } | 1203 | } |
1204 | populateRemoteView(); | 1204 | populateRemoteView(); |
1205 | TabWidget->setCurrentPage(1); | 1205 | TabWidget->setCurrentPage(1); |
1206 | 1206 | ||
1207 | } else { | 1207 | } else { |
1208 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1208 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1209 | 1209 | ||
1210 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | 1210 | QString destFile = currentDir.canonicalPath()+"/"+(*it); |
1211 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1211 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1212 | 1212 | ||
1213 | QFile f(destFile); | 1213 | QFile f(destFile); |
1214 | if( f.exists()) | 1214 | if( f.exists()) |
1215 | f.remove(); | 1215 | f.remove(); |
1216 | if(!copyFile(destFile, curFile) ) { | 1216 | if(!copyFile(destFile, curFile) ) { |
1217 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1217 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1218 | 1218 | ||
1219 | qWarning("nothin doing"); | 1219 | qWarning("nothin doing"); |
1220 | } | 1220 | } |
1221 | } | 1221 | } |
1222 | populateLocalView(); | 1222 | populateLocalView(); |
1223 | TabWidget->setCurrentPage(0); | 1223 | TabWidget->setCurrentPage(0); |
1224 | } | 1224 | } |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | void AdvancedFm::copyAs() | 1227 | void AdvancedFm::copyAs() |
1228 | { | 1228 | { |
1229 | QStringList curFileList = getPath(); | 1229 | QStringList curFileList = getPath(); |
1230 | QString curFile; | 1230 | QString curFile; |
1231 | InputDialog *fileDlg; | 1231 | InputDialog *fileDlg; |
1232 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1232 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); |
1233 | 1233 | ||
1234 | if (TabWidget->currentPageIndex() == 0) { | 1234 | if (TabWidget->currentPageIndex() == 0) { |
1235 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1235 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1236 | QString destFile; | 1236 | QString destFile; |
1237 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1237 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1238 | // InputDialog *fileDlg; | 1238 | // InputDialog *fileDlg; |
1239 | // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1239 | // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); |
1240 | fileDlg->setInputText((const QString &) destFile ); | 1240 | fileDlg->setInputText((const QString &) destFile ); |
1241 | fileDlg->exec(); | 1241 | fileDlg->exec(); |
1242 | if( fileDlg->result() == 1 ) { | 1242 | if( fileDlg->result() == 1 ) { |
1243 | QString filename = fileDlg->LineEdit1->text(); | 1243 | QString filename = fileDlg->LineEdit1->text(); |
1244 | destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1244 | destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1245 | 1245 | ||
1246 | QFile f(destFile); | 1246 | QFile f(destFile); |
1247 | if( f.exists()) | 1247 | if( f.exists()) |
1248 | f.remove(); | 1248 | f.remove(); |
1249 | if(!copyFile(destFile, curFile) ) { | 1249 | if(!copyFile(destFile, curFile) ) { |
1250 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1250 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1251 | qWarning("nothin doing"); | 1251 | qWarning("nothin doing"); |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | populateRemoteView(); | 1256 | populateRemoteView(); |
1257 | TabWidget->setCurrentPage(1); | 1257 | TabWidget->setCurrentPage(1); |
1258 | } else { | 1258 | } else { |
1259 | if (TabWidget->currentPageIndex() == 0) { | 1259 | if (TabWidget->currentPageIndex() == 0) { |
1260 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1260 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1261 | 1261 | ||
1262 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1262 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1263 | QString destFile; | 1263 | QString destFile; |
1264 | fileDlg->setInputText((const QString &) destFile); | 1264 | fileDlg->setInputText((const QString &) destFile); |
1265 | fileDlg->exec(); | 1265 | fileDlg->exec(); |
1266 | if( fileDlg->result() == 1 ) { | 1266 | if( fileDlg->result() == 1 ) { |
1267 | QString filename = fileDlg->LineEdit1->text(); | 1267 | QString filename = fileDlg->LineEdit1->text(); |
1268 | destFile = currentDir.canonicalPath()+"/"+(*it); | 1268 | destFile = currentDir.canonicalPath()+"/"+(*it); |
1269 | 1269 | ||
1270 | QFile f(destFile); | 1270 | QFile f(destFile); |
1271 | if( f.exists()) | 1271 | if( f.exists()) |
1272 | f.remove(); | 1272 | f.remove(); |
1273 | if(!copyFile(destFile, curFile) ) { | 1273 | if(!copyFile(destFile, curFile) ) { |
1274 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1274 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1275 | qWarning("nothin doing"); | 1275 | qWarning("nothin doing"); |
1276 | } | 1276 | } |
1277 | } | 1277 | } |
1278 | } | 1278 | } |
1279 | populateLocalView(); | 1279 | populateLocalView(); |
1280 | TabWidget->setCurrentPage(0); | 1280 | TabWidget->setCurrentPage(0); |
1281 | } | 1281 | } |
1282 | } | 1282 | } |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | void AdvancedFm::move() { | 1285 | void AdvancedFm::move() { |
1286 | 1286 | ||
1287 | QStringList curFileList = getPath(); | 1287 | QStringList curFileList = getPath(); |
1288 | QString curFile; | 1288 | QString curFile; |
1289 | // qDebug(curFile); | 1289 | // qDebug(curFile); |
1290 | QString destFile; | 1290 | QString destFile; |
1291 | 1291 | ||
1292 | if (TabWidget->currentPageIndex() == 0) { | 1292 | if (TabWidget->currentPageIndex() == 0) { |
1293 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1293 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1294 | QString destFile = currentRemoteDir.canonicalPath(); | 1294 | QString destFile = currentRemoteDir.canonicalPath(); |
1295 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1295 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1296 | destFile+="/"; | 1296 | destFile+="/"; |
1297 | destFile +=(*it); | 1297 | destFile +=(*it); |
1298 | curFile = currentDir.canonicalPath(); | 1298 | curFile = currentDir.canonicalPath(); |
1299 | qDebug("Destination file is "+destFile); | 1299 | qDebug("Destination file is "+destFile); |
1300 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1300 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1301 | curFile +="/"; | 1301 | curFile +="/"; |
1302 | curFile+=(*it); | 1302 | curFile+=(*it); |
1303 | 1303 | ||
1304 | QFile f(destFile); | 1304 | QFile f(destFile); |
1305 | if( f.exists()) | 1305 | if( f.exists()) |
1306 | f.remove(); | 1306 | f.remove(); |
1307 | if(!copyFile( destFile, curFile) ) { | 1307 | if(!copyFile( destFile, curFile) ) { |
1308 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1308 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1309 | return; | 1309 | return; |
1310 | } | 1310 | } |
1311 | QFile::remove(curFile); | 1311 | QFile::remove(curFile); |
1312 | } | 1312 | } |
1313 | TabWidget->setCurrentPage(1); | 1313 | TabWidget->setCurrentPage(1); |
1314 | } else { | 1314 | } else { |
1315 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1315 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1316 | QString destFile = currentRemoteDir.canonicalPath(); | 1316 | QString destFile = currentRemoteDir.canonicalPath(); |
1317 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1317 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1318 | destFile+="/"; | 1318 | destFile+="/"; |
1319 | destFile +=(*it); | 1319 | destFile +=(*it); |
1320 | qDebug("Destination file is "+destFile); | 1320 | qDebug("Destination file is "+destFile); |
1321 | curFile = currentDir.canonicalPath(); | 1321 | curFile = currentDir.canonicalPath(); |
1322 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1322 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1323 | curFile +="/"; | 1323 | curFile +="/"; |
1324 | curFile+=(*it); | 1324 | curFile+=(*it); |
1325 | 1325 | ||
1326 | QFile f(destFile); | 1326 | QFile f(destFile); |
1327 | if( f.exists()) | 1327 | if( f.exists()) |
1328 | f.remove(); | 1328 | f.remove(); |
1329 | if(!copyFile(destFile, curFile) ) { | 1329 | if(!copyFile(destFile, curFile) ) { |
1330 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1330 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1331 | return; | 1331 | return; |
1332 | } | 1332 | } |
1333 | QFile::remove(curFile); | 1333 | QFile::remove(curFile); |
1334 | TabWidget->setCurrentPage(0); | 1334 | TabWidget->setCurrentPage(0); |
1335 | } | 1335 | } |
1336 | } | 1336 | } |
1337 | populateRemoteView(); | 1337 | populateRemoteView(); |
1338 | populateLocalView(); | 1338 | populateLocalView(); |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1341 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) |
1342 | { | 1342 | { |
1343 | char bf[ 50000 ]; | 1343 | char bf[ 50000 ]; |
1344 | int bytesRead; | 1344 | int bytesRead; |
1345 | bool success = TRUE; | 1345 | bool success = TRUE; |
1346 | struct stat status; | 1346 | struct stat status; |
1347 | 1347 | ||
1348 | QFile s( src ); | 1348 | QFile s( src ); |
1349 | QFile d( dest ); | 1349 | QFile d( dest ); |
1350 | 1350 | ||
1351 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 1351 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
1352 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 1352 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
1353 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 1353 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
1354 | success = FALSE; | 1354 | success = FALSE; |
1355 | break; | 1355 | break; |
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | if( success && (bytesRead > 0) ){ | 1358 | if( success && (bytesRead > 0) ){ |
1359 | d.writeBlock( bf, bytesRead ); | 1359 | d.writeBlock( bf, bytesRead ); |
1360 | } | 1360 | } |
1361 | } else { | 1361 | } else { |
1362 | success = FALSE; | 1362 | success = FALSE; |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | // Set file permissions | 1365 | // Set file permissions |
1366 | if( stat( (const char *) src, &status ) == 0 ){ | 1366 | if( stat( (const char *) src, &status ) == 0 ){ |
1367 | chmod( (const char *) dest, status.st_mode ); | 1367 | chmod( (const char *) dest, status.st_mode ); |
1368 | } | 1368 | } |
1369 | 1369 | ||
1370 | return success; | 1370 | return success; |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | void AdvancedFm::runCommand() { | 1373 | void AdvancedFm::runCommand() { |
1374 | QString curFile; | 1374 | QString curFile; |
1375 | if (TabWidget->currentPageIndex() == 0) { | 1375 | if (TabWidget->currentPageIndex() == 0) { |
1376 | if( Local_View->currentItem()) | 1376 | if( Local_View->currentItem()) |
1377 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 1377 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1378 | } else { | 1378 | } else { |
1379 | if(Remote_View->currentItem()) | 1379 | if(Remote_View->currentItem()) |
1380 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 1380 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | InputDialog *fileDlg; | 1383 | InputDialog *fileDlg; |
1384 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1384 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1385 | fileDlg->setInputText(curFile); | 1385 | fileDlg->setInputText(curFile); |
1386 | fileDlg->exec(); | 1386 | fileDlg->exec(); |
1387 | QString command; | 1387 | QString command; |
1388 | if( fileDlg->result() == 1 ) { | 1388 | if( fileDlg->result() == 1 ) { |
1389 | command = fileDlg->LineEdit1->text(); | 1389 | command = fileDlg->LineEdit1->text(); |
1390 | 1390 | ||
1391 | // int err=0; | 1391 | // int err=0; |
1392 | Output *outDlg; | 1392 | Output *outDlg; |
1393 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1393 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1394 | outDlg->showMaximized(); | 1394 | outDlg->showMaximized(); |
1395 | outDlg->show(); | 1395 | outDlg->show(); |
1396 | qApp->processEvents(); | 1396 | qApp->processEvents(); |
1397 | FILE *fp; | 1397 | FILE *fp; |
1398 | char line[130]; | 1398 | char line[130]; |
1399 | sleep(1); | 1399 | sleep(1); |
1400 | // if(command.find("2>",0,TRUE) != -1) | 1400 | // if(command.find("2>",0,TRUE) != -1) |
1401 | command +=" 2>&1"; | 1401 | command +=" 2>&1"; |
1402 | fp = popen( (const char *) command, "r"); | 1402 | fp = popen( (const char *) command, "r"); |
1403 | if ( !fp ) { | 1403 | if ( !fp ) { |
1404 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1404 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1405 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); | 1405 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); |
1406 | pclose(fp); | 1406 | pclose(fp); |
1407 | return; | 1407 | return; |
1408 | } else { | 1408 | } else { |
1409 | while ( fgets( line, sizeof line, fp)) { | 1409 | while ( fgets( line, sizeof line, fp)) { |
1410 | QString lineStr = line; | 1410 | QString lineStr = line; |
1411 | lineStr=lineStr.left(lineStr.length()-1); | 1411 | lineStr=lineStr.left(lineStr.length()-1); |
1412 | outDlg->OutputEdit->append(lineStr); | 1412 | outDlg->OutputEdit->append(lineStr); |
1413 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1413 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1414 | } | 1414 | } |
1415 | } | 1415 | } |
1416 | } | 1416 | } |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void AdvancedFm::runCommandStd() { | 1419 | void AdvancedFm::runCommandStd() { |
1420 | QString curFile; | 1420 | QString curFile; |
1421 | if (TabWidget->currentPageIndex() == 0) { | 1421 | if (TabWidget->currentPageIndex() == 0) { |
1422 | if( Local_View->currentItem()) | 1422 | if( Local_View->currentItem()) |
1423 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 1423 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1424 | } else { | 1424 | } else { |
1425 | if(Remote_View->currentItem()) | 1425 | if(Remote_View->currentItem()) |
1426 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); | 1426 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); |
1427 | } | 1427 | } |
1428 | 1428 | ||
1429 | InputDialog *fileDlg; | 1429 | InputDialog *fileDlg; |
1430 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1430 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1431 | fileDlg->setInputText(curFile); | 1431 | fileDlg->setInputText(curFile); |
1432 | fileDlg->exec(); | 1432 | fileDlg->exec(); |
1433 | QString command; | 1433 | QString command; |
1434 | if( fileDlg->result() == 1 ) { | 1434 | if( fileDlg->result() == 1 ) { |
1435 | qApp->processEvents(); | 1435 | qApp->processEvents(); |
1436 | command = fileDlg->LineEdit1->text() + " &"; | 1436 | command = fileDlg->LineEdit1->text() + " &"; |
1437 | system(command.latin1()); | 1437 | system(command.latin1()); |
1438 | } | 1438 | } |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | void AdvancedFm::fileStatus() { | 1441 | void AdvancedFm::fileStatus() { |
1442 | QString curFile; | 1442 | QString curFile; |
1443 | if (TabWidget->currentPageIndex() == 0) { | 1443 | if (TabWidget->currentPageIndex() == 0) { |
1444 | curFile = Local_View->currentItem()->text(0); | 1444 | curFile = Local_View->currentItem()->text(0); |
1445 | } else { | 1445 | } else { |
1446 | curFile = Remote_View->currentItem()->text(0); | 1446 | curFile = Remote_View->currentItem()->text(0); |
1447 | } | 1447 | } |
1448 | QString command = " stat -l "+ curFile +" 2>&1"; | 1448 | QString command = " stat -l "+ curFile +" 2>&1"; |
1449 | // int err=0; | 1449 | // int err=0; |
1450 | Output *outDlg; | 1450 | Output *outDlg; |
1451 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1451 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1452 | outDlg->showMaximized(); | 1452 | outDlg->showMaximized(); |
1453 | outDlg->show(); | 1453 | outDlg->show(); |
1454 | qApp->processEvents(); | 1454 | qApp->processEvents(); |
1455 | FILE *fp; | 1455 | FILE *fp; |
1456 | char line[130]; | 1456 | char line[130]; |
1457 | sleep(1); | 1457 | sleep(1); |
1458 | fp = popen( (const char *) command, "r"); | 1458 | fp = popen( (const char *) command, "r"); |
1459 | if ( !fp ) { | 1459 | if ( !fp ) { |
1460 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1460 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1461 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); | 1461 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); |
1462 | pclose(fp); | 1462 | pclose(fp); |
1463 | return; | 1463 | return; |
1464 | } else { | 1464 | } else { |
1465 | while ( fgets( line, sizeof line, fp)) { | 1465 | while ( fgets( line, sizeof line, fp)) { |
1466 | outDlg->OutputEdit->append(line); | 1466 | outDlg->OutputEdit->append(line); |
1467 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1467 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1468 | 1468 | ||
1469 | } | 1469 | } |
1470 | 1470 | ||
1471 | } | 1471 | } |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void AdvancedFm::mkDir() { | 1474 | void AdvancedFm::mkDir() { |
1475 | if (TabWidget->currentPageIndex() == 0) | 1475 | if (TabWidget->currentPageIndex() == 0) |
1476 | localMakDir(); | 1476 | localMakDir(); |
1477 | else | 1477 | else |
1478 | remoteMakDir(); | 1478 | remoteMakDir(); |
1479 | 1479 | ||
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | void AdvancedFm::rn() { | 1482 | void AdvancedFm::rn() { |
1483 | if (TabWidget->currentPageIndex() == 0) | 1483 | if (TabWidget->currentPageIndex() == 0) |
1484 | localRename(); | 1484 | localRename(); |
1485 | else | 1485 | else |
1486 | remoteRename(); | 1486 | remoteRename(); |
1487 | 1487 | ||
1488 | } | 1488 | } |
1489 | 1489 | ||
1490 | void AdvancedFm::del() { | 1490 | void AdvancedFm::del() { |
1491 | if (TabWidget->currentPageIndex() == 0) | 1491 | if (TabWidget->currentPageIndex() == 0) |
1492 | localDelete(); | 1492 | localDelete(); |
1493 | else | 1493 | else |
1494 | remoteDelete(); | 1494 | remoteDelete(); |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | void AdvancedFm::doAbout() { | 1497 | void AdvancedFm::doAbout() { |
1498 | QMessageBox::message("AdvancedFm","Advanced FileManager\n" | 1498 | QMessageBox::message("AdvancedFm","Advanced FileManager\n" |
1499 | "is copyright 2002 by\n" | 1499 | "is copyright 2002 by\n" |
1500 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1500 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1501 | "and is licensed by the GPL"); | 1501 | "and is licensed by the GPL"); |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 1504 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
1505 | { | 1505 | { |
1506 | switch ( e->key() ) { | 1506 | switch ( e->key() ) { |
1507 | case Key_Delete: | 1507 | case Key_Delete: |
1508 | del(); | 1508 | del(); |
1509 | break; | 1509 | break; |
1510 | case Key_H: | 1510 | case Key_H: |
1511 | showHidden(); | 1511 | showHidden(); |
1512 | break; | 1512 | break; |
1513 | case Key_E: | 1513 | case Key_E: |
1514 | runThis(); | 1514 | runThis(); |
1515 | break; | 1515 | break; |
1516 | case Key_C: | 1516 | case Key_C: |
1517 | copy(); | 1517 | copy(); |
1518 | break; | 1518 | break; |
1519 | case Key_A: | 1519 | case Key_A: |
1520 | copyAs(); | 1520 | copyAs(); |
1521 | break; | 1521 | break; |
1522 | case Key_M: | 1522 | case Key_M: |
1523 | move(); | 1523 | move(); |
1524 | break; | 1524 | break; |
1525 | case Key_R: | 1525 | case Key_R: |
1526 | rn(); | 1526 | rn(); |
1527 | break; | 1527 | break; |
1528 | case Key_I: | 1528 | case Key_I: |
1529 | fileStatus(); | 1529 | fileStatus(); |
1530 | break; | 1530 | break; |
1531 | case Key_U: | 1531 | case Key_U: |
1532 | upDir(); | 1532 | upDir(); |
1533 | break; | 1533 | break; |
1534 | case Key_P: | 1534 | case Key_P: |
1535 | filePerms(); | 1535 | filePerms(); |
1536 | break; | 1536 | break; |
1537 | case Key_N: | 1537 | case Key_N: |
1538 | mkDir(); | 1538 | mkDir(); |
1539 | break; | 1539 | break; |
1540 | case Key_1: | 1540 | case Key_1: |
1541 | switchToLocalTab(); | 1541 | switchToLocalTab(); |
1542 | break; | 1542 | break; |
1543 | case Key_2: | 1543 | case Key_2: |
1544 | switchToRemoteTab(); | 1544 | switchToRemoteTab(); |
1545 | break; | 1545 | break; |
1546 | case Key_3: | 1546 | case Key_3: |
1547 | CFButtonPushed(); | 1547 | CFButtonPushed(); |
1548 | break; | 1548 | break; |
1549 | case Key_4: | 1549 | case Key_4: |
1550 | SDButtonPushed(); | 1550 | SDButtonPushed(); |
1551 | break; | 1551 | break; |
1552 | case Key_5: | 1552 | case Key_5: |
1553 | homeButtonPushed(); | 1553 | homeButtonPushed(); |
1554 | break; | 1554 | break; |
1555 | case Key_6: | 1555 | case Key_6: |
1556 | docButtonPushed(); | 1556 | docButtonPushed(); |
1557 | break; | 1557 | break; |
1558 | case Key_7: | 1558 | case Key_7: |
1559 | break; | 1559 | break; |
1560 | case Key_8: | 1560 | case Key_8: |
1561 | break; | 1561 | break; |
1562 | case Key_9: | 1562 | case Key_9: |
1563 | break; | 1563 | break; |
1564 | case Key_0: | 1564 | case Key_0: |
1565 | break; | 1565 | break; |
1566 | } | 1566 | } |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | void AdvancedFm::mkSym() { | 1569 | void AdvancedFm::mkSym() { |
1570 | QString cmd; | 1570 | QString cmd; |
1571 | QStringList curFileList = getPath(); | 1571 | QStringList curFileList = getPath(); |
1572 | 1572 | ||
1573 | if (TabWidget->currentPageIndex() == 0) { | 1573 | if (TabWidget->currentPageIndex() == 0) { |
1574 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1574 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1575 | 1575 | ||
1576 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 1576 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
1577 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 1577 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
1578 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 1578 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
1579 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1579 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1580 | cmd = "ln -s "+curFile+" "+destName; | 1580 | cmd = "ln -s "+curFile+" "+destName; |
1581 | qDebug(cmd); | 1581 | qDebug(cmd); |
1582 | system(cmd.latin1() ); | 1582 | system(cmd.latin1() ); |
1583 | } | 1583 | } |
1584 | populateRemoteView(); | 1584 | populateRemoteView(); |
1585 | TabWidget->setCurrentPage(1); | 1585 | TabWidget->setCurrentPage(1); |
1586 | } else { | 1586 | } else { |
1587 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1587 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1588 | 1588 | ||
1589 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 1589 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
1590 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 1590 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
1591 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1591 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1592 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1592 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1593 | 1593 | ||
1594 | cmd = "ln -s "+curFile+" "+destName; | 1594 | cmd = "ln -s "+curFile+" "+destName; |
1595 | qDebug(cmd); | 1595 | qDebug(cmd); |
1596 | system(cmd.latin1() ); | 1596 | system(cmd.latin1() ); |
1597 | } | 1597 | } |
1598 | populateLocalView(); | 1598 | populateLocalView(); |
1599 | TabWidget->setCurrentPage(0); | 1599 | TabWidget->setCurrentPage(0); |
1600 | } | 1600 | } |
1601 | } | 1601 | } |
1602 | 1602 | ||
1603 | void AdvancedFm::QPEButtonPushed() { | 1603 | void AdvancedFm::QPEButtonPushed() { |
1604 | QString current = QPEApplication::qpeDir(); | 1604 | QString current = QPEApplication::qpeDir(); |
1605 | chdir( current.latin1() ); | 1605 | chdir( current.latin1() ); |
1606 | if (TabWidget->currentPageIndex() == 0) { | 1606 | if (TabWidget->currentPageIndex() == 0) { |
1607 | currentDir.cd( current, TRUE); | 1607 | currentDir.cd( current, TRUE); |
1608 | populateLocalView(); | 1608 | populateLocalView(); |
1609 | } else { | 1609 | } else { |
1610 | currentRemoteDir.cd( current, TRUE); | 1610 | currentRemoteDir.cd( current, TRUE); |
1611 | populateRemoteView(); | 1611 | populateRemoteView(); |
1612 | } | 1612 | } |
1613 | update(); | 1613 | update(); |
1614 | } | 1614 | } |
1615 | 1615 | ||
1616 | void AdvancedFm::parsetab(const QString &fileName) { | 1616 | void AdvancedFm::parsetab(const QString &fileName) { |
1617 | 1617 | ||
1618 | fileSystemTypeList.clear(); | 1618 | fileSystemTypeList.clear(); |
1619 | fsList.clear(); | 1619 | fsList.clear(); |
1620 | struct mntent *me; | 1620 | struct mntent *me; |
1621 | // if(fileName == "/etc/mtab") { | 1621 | // if(fileName == "/etc/mtab") { |
1622 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 1622 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
1623 | if ( mntfp ) { | 1623 | if ( mntfp ) { |
1624 | while ( (me = getmntent( mntfp )) != 0 ) { | 1624 | while ( (me = getmntent( mntfp )) != 0 ) { |
1625 | QString deviceName = me->mnt_fsname; | 1625 | QString deviceName = me->mnt_fsname; |
1626 | QString filesystemType = me->mnt_type; | 1626 | QString filesystemType = me->mnt_type; |
1627 | QString mountDir = me->mnt_dir; | 1627 | QString mountDir = me->mnt_dir; |
1628 | if(deviceName != "none") { | 1628 | if(deviceName != "none") { |
1629 | if( fsList.contains(filesystemType) == 0 | 1629 | if( fsList.contains(filesystemType) == 0 |
1630 | & filesystemType.find("proc",0,TRUE) == -1 | 1630 | & filesystemType.find("proc",0,TRUE) == -1 |
1631 | & filesystemType.find("cramfs",0,TRUE) == -1 | 1631 | & filesystemType.find("cramfs",0,TRUE) == -1 |
1632 | & filesystemType.find("auto",0,TRUE) == -1) | 1632 | & filesystemType.find("auto",0,TRUE) == -1) |
1633 | fsList << filesystemType; | 1633 | fsList << filesystemType; |
1634 | // deviceList << deviceName; | 1634 | // deviceList << deviceName; |
1635 | // qDebug(mountDir+"::"+filesystemType); | 1635 | // qDebug(mountDir+"::"+filesystemType); |
1636 | fileSystemTypeList << mountDir+"::"+filesystemType; | 1636 | fileSystemTypeList << mountDir+"::"+filesystemType; |
1637 | } | 1637 | } |
1638 | } | 1638 | } |
1639 | } | 1639 | } |
1640 | endmntent( mntfp ); | 1640 | endmntent( mntfp ); |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 1643 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
1644 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 1644 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
1645 | QString current = currentText;//.right( currentText.length()-1); | 1645 | QString current = currentText;//.right( currentText.length()-1); |
1646 | QString baseFs; | 1646 | QString baseFs; |
1647 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 1647 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
1648 | QString temp = (*it); | 1648 | QString temp = (*it); |
1649 | QString path = temp.left(temp.find("::",0,TRUE) ); | 1649 | QString path = temp.left(temp.find("::",0,TRUE) ); |
1650 | path = path.right( path.length()-1); | 1650 | path = path.right( path.length()-1); |
1651 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 1651 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
1652 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 1652 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
1653 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 1653 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
1654 | } | 1654 | } |
1655 | } | 1655 | } |
1656 | return baseFs; | 1656 | return baseFs; |
1657 | } | 1657 | } |
1658 | 1658 | ||
1659 | 1659 | ||
1660 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 1660 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
1661 | // QListViewItemIterator it( Local_View ); | 1661 | // QListViewItemIterator it( Local_View ); |
1662 | // for ( ; it.current(); ++it ) { | 1662 | // for ( ; it.current(); ++it ) { |
1663 | // if ( it.current()->isSelected() ) { | 1663 | // if ( it.current()->isSelected() ) { |
1664 | // QString strItem = it.current()->text(0); | 1664 | // QString strItem = it.current()->text(0); |
1665 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 1665 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
1666 | // QFileInfo fi(localFile); | 1666 | // QFileInfo fi(localFile); |
1667 | // } | 1667 | // } |
1668 | // } | 1668 | // } |