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