summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 7cd8644..b224deb 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -131,507 +131,509 @@ AdvancedFm::AdvancedFm( )
131 fileMenu->insertSeparator(); 131 fileMenu->insertSeparator();
132 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); 132 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ));
133 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); 133 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ));
134 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); 134 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
135 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); 135 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
136 fileMenu->insertSeparator(); 136 fileMenu->insertSeparator();
137 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); 137 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
138 fileMenu->setCheckable(TRUE); 138 fileMenu->setCheckable(TRUE);
139 139
140 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 140 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
141 viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 141 viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
142 viewMenu->insertSeparator(); 142 viewMenu->insertSeparator();
143 viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); 143 viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
144 viewMenu->setCheckable(TRUE); 144 viewMenu->setCheckable(TRUE);
145 145
146 TabWidget = new QTabWidget( this, "TabWidget" ); 146 TabWidget = new QTabWidget( this, "TabWidget" );
147 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 7); 147 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 7);
148 148
149 tab = new QWidget( TabWidget, "tab" ); 149 tab = new QWidget( TabWidget, "tab" );
150 tabLayout = new QGridLayout( tab ); 150 tabLayout = new QGridLayout( tab );
151 tabLayout->setSpacing( 2); 151 tabLayout->setSpacing( 2);
152 tabLayout->setMargin( 2); 152 tabLayout->setMargin( 2);
153 153
154 Local_View = new QListView( tab, "Local_View" ); 154 Local_View = new QListView( tab, "Local_View" );
155// Local_View->setResizePolicy( QListView::AutoOneFit ); 155// Local_View->setResizePolicy( QListView::AutoOneFit );
156 Local_View->addColumn( tr("File"),130); 156 Local_View->addColumn( tr("File"),130);
157 Local_View->addColumn( tr("Size"),-1); 157 Local_View->addColumn( tr("Size"),-1);
158 Local_View->setColumnAlignment(1,QListView::AlignRight); 158 Local_View->setColumnAlignment(1,QListView::AlignRight);
159 Local_View->addColumn( tr("Date"),-1); 159 Local_View->addColumn( tr("Date"),-1);
160 Local_View->setColumnAlignment(2,QListView::AlignRight); 160 Local_View->setColumnAlignment(2,QListView::AlignRight);
161 Local_View->setAllColumnsShowFocus(TRUE); 161 Local_View->setAllColumnsShowFocus(TRUE);
162 Local_View->setMultiSelection( TRUE ); 162 Local_View->setMultiSelection( TRUE );
163 Local_View->setSelectionMode(QListView::Extended); 163 Local_View->setSelectionMode(QListView::Extended);
164 164
165 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 165 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
166 166
167 tabLayout->addWidget( Local_View, 0, 0 ); 167 tabLayout->addWidget( Local_View, 0, 0 );
168 168
169 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 169 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
170 this,SLOT( localListClicked(QListViewItem *)) ); 170 this,SLOT( localListClicked(QListViewItem *)) );
171 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 171 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
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
244AdvancedFm::~AdvancedFm() 244AdvancedFm::~AdvancedFm()
245{ 245{
246} 246}
247 247
248void AdvancedFm::cleanUp() 248void 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
260void AdvancedFm::tabChanged(QWidget *w) 260void 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
275void AdvancedFm::populateLocalView() 275void 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( (fileInfo.permission( QFileInfo::ExeUser) 321 } else if( (fileInfo.permission( QFileInfo::ExeUser)
322 | fileInfo.permission( QFileInfo::ExeGroup) 322 | fileInfo.permission( QFileInfo::ExeGroup)
323 | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { 323 | fileInfo.permission( QFileInfo::ExeOther))
324 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
324 pm = Resource::loadPixmap( "exec"); 325 pm = Resource::loadPixmap( "exec");
325// else { //is exec 326// else { //is exec
326// pm = Resource::loadPixmap( "exec"); 327// pm = Resource::loadPixmap( "exec");
327// } 328// }
328// // item->setPixmap( 0,pm); 329// // item->setPixmap( 0,pm);
329 } else if( !fi->isReadable() ) { 330 } else if( !fi->isReadable() ) {
330 pm = Resource::loadPixmap( "locked" ); 331 pm = Resource::loadPixmap( "locked" );
331// item->setPixmap( 0,pm); 332// item->setPixmap( 0,pm);
332 } else { //everything else goes by mimetype 333 } else { //everything else goes by mimetype
333 MimeType mt(fi->filePath()); 334 MimeType mt(fi->filePath());
334 pm=mt.pixmap(); //sets the correct pixmap for mimetype 335 pm=mt.pixmap(); //sets the correct pixmap for mimetype
335 if(pm.isNull()) 336 if(pm.isNull())
336 pm = Resource::loadPixmap( "UnknownDocument-14" ); 337 pm = Resource::loadPixmap( "UnknownDocument-14" );
337// item->setPixmap( 0,pm); 338// item->setPixmap( 0,pm);
338 } 339 }
339 item->setPixmap( 0,pm); 340 item->setPixmap( 0,pm);
340 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 341 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
341 // overlay link image 342 // overlay link image
342 pm= Resource::loadPixmap( "folder" ); 343 pm= Resource::loadPixmap( "folder" );
343 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 344 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
344 QPainter painter( &pm ); 345 QPainter painter( &pm );
345 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 346 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
346 pm.setMask( pm.createHeuristicMask( FALSE ) ); 347 pm.setMask( pm.createHeuristicMask( FALSE ) );
347 item->setPixmap( 0, pm); 348 item->setPixmap( 0, pm);
348 } 349 }
349 } 350 }
350 isDir=FALSE; 351 isDir=FALSE;
351 ++it; 352 ++it;
352 } 353 }
353 354
354 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 355 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
355 struct stat buf; 356 struct stat buf;
356// struct stat st; 357// struct stat st;
357 dev_t devT; 358 dev_t devT;
358// mode_t mode; 359// mode_t mode;
359 DIR *dir; 360 DIR *dir;
360// int fd = 0; 361// int fd = 0;
361 struct dirent *mydirent; 362 struct dirent *mydirent;
362// int i = 1; 363// int i = 1;
363 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 364 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
364 while ((mydirent = readdir(dir)) != NULL) { 365 while ((mydirent = readdir(dir)) != NULL) {
365 lstat( mydirent->d_name, &buf); 366 lstat( mydirent->d_name, &buf);
366 qDebug(mydirent->d_name); 367 qDebug(mydirent->d_name);
367// mode = buf.st_mode; 368// mode = buf.st_mode;
368 fileL.sprintf("%s", mydirent->d_name); 369 fileL.sprintf("%s", mydirent->d_name);
369// fileS.sprintf("%d, %d", ); //this isn't correct 370// fileS.sprintf("%d, %d", ); //this isn't correct
370 devT = buf.st_dev; 371 devT = buf.st_dev;
371 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 372 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
372// fileS.sprintf("%d,%d", devT, devT); 373// fileS.sprintf("%d,%d", devT, devT);
373 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 374 fileDate.sprintf("%s", ctime( &buf.st_mtime));
374 if( fileL.find(".") == -1 ){ 375 if( fileL.find(".") == -1 ){
375 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 376 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
376 pm = Resource::loadPixmap( "UnknownDocument-14" ); 377 pm = Resource::loadPixmap( "UnknownDocument-14" );
377 item->setPixmap( 0,pm); 378 item->setPixmap( 0,pm);
378 } 379 }
379 } 380 }
380 381
381 closedir(dir); 382 closedir(dir);
382 } 383 }
383 384
384 Local_View->setSorting( 3,FALSE); 385 Local_View->setSorting( 3,FALSE);
385 fillCombo( (const QString &) currentDir.canonicalPath()); 386 fillCombo( (const QString &) currentDir.canonicalPath());
386} 387}
387 388
388 389
389void AdvancedFm::populateRemoteView() 390void AdvancedFm::populateRemoteView()
390{ 391{
391// QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 392// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
392// QListViewItemIterator it( Remote_View ); 393// QListViewItemIterator it( Remote_View );
393// for ( ; it.current(); ++it ) { 394// for ( ; it.current(); ++it ) {
394// if ( it.current()->isSelected() ) { 395// if ( it.current()->isSelected() ) {
395// QString strItem = it.current()->text(0); 396// QString strItem = it.current()->text(0);
396// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; 397// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem;
397// QFileInfo fi(localFile); 398// QFileInfo fi(localFile);
398// } 399// }
399// } 400// }
400 QPixmap pm; 401 QPixmap pm;
401 Remote_View->clear(); 402 Remote_View->clear();
402 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 403 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
403 currentRemoteDir.setMatchAllDirs(TRUE); 404 currentRemoteDir.setMatchAllDirs(TRUE);
404 currentRemoteDir.setNameFilter(filterStr); 405 currentRemoteDir.setNameFilter(filterStr);
405 QString fileL, fileS, fileDate; 406 QString fileL, fileS, fileDate;
406 407
407 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 408 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
408 setCaption("AdvancedFm :: "+fs); 409 setCaption("AdvancedFm :: "+fs);
409 bool isDir=FALSE; 410 bool isDir=FALSE;
410 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 411 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
411 QFileInfoListIterator it(*list); 412 QFileInfoListIterator it(*list);
412 QFileInfo *fi; 413 QFileInfo *fi;
413 while ( (fi=it.current()) ) { 414 while ( (fi=it.current()) ) {
414 if (fi->isSymLink() ){ 415 if (fi->isSymLink() ){
415 QString symLink=fi->readLink(); 416 QString symLink=fi->readLink();
416// qDebug("Symlink detected "+symLink); 417// qDebug("Symlink detected "+symLink);
417 QFileInfo sym( symLink); 418 QFileInfo sym( symLink);
418 fileS.sprintf( "%10li", sym.size() ); 419 fileS.sprintf( "%10li", sym.size() );
419 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 420 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
420 fileDate = sym.lastModified().toString(); 421 fileDate = sym.lastModified().toString();
421 } else { 422 } else {
422// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 423// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
423 fileS.sprintf( "%10li", fi->size() ); 424 fileS.sprintf( "%10li", fi->size() );
424 fileL.sprintf( "%s",fi->fileName().data() ); 425 fileL.sprintf( "%s",fi->fileName().data() );
425 fileDate= fi->lastModified().toString(); 426 fileDate= fi->lastModified().toString();
426 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 427 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
427 fileL+="/"; 428 fileL+="/";
428 isDir=TRUE; 429 isDir=TRUE;
429// qDebug( fileL); 430// qDebug( fileL);
430 } 431 }
431 } 432 }
432 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 433 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
433 if(fileL !="./" && fi->exists()) { 434 if(fileL !="./" && fi->exists()) {
434 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 435 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
435 QPixmap pm; 436 QPixmap pm;
436 437
437 if(isDir || fileL.find("/",0,TRUE) != -1) { 438 if(isDir || fileL.find("/",0,TRUE) != -1) {
438 if( !QDir( fi->filePath() ).isReadable()) 439 if( !QDir( fi->filePath() ).isReadable())
439 pm = Resource::loadPixmap( "lockedfolder" ); 440 pm = Resource::loadPixmap( "lockedfolder" );
440 else 441 else
441 pm= Resource::loadPixmap( "folder" ); 442 pm= Resource::loadPixmap( "folder" );
442// item->setPixmap( 0,pm ); 443// item->setPixmap( 0,pm );
443 } else if( (fileInfo.permission( QFileInfo::ExeUser) 444 } else if( (fileInfo.permission( QFileInfo::ExeUser)
444 | fileInfo.permission( QFileInfo::ExeGroup) 445 | fileInfo.permission( QFileInfo::ExeGroup)
445 | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { 446 | fileInfo.permission( QFileInfo::ExeOther))
447 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
446///// } else if(fileInfo.isExecutable()){ //is exec <<<< BROKEN!! 448///// } else if(fileInfo.isExecutable()){ //is exec <<<< BROKEN!!
447 pm = Resource::loadPixmap( "exec"); 449 pm = Resource::loadPixmap( "exec");
448// item->setPixmap( 0,pm); 450// item->setPixmap( 0,pm);
449 } else if( !fi->isReadable() ) { 451 } else if( !fi->isReadable() ) {
450 pm = Resource::loadPixmap( "locked" ); 452 pm = Resource::loadPixmap( "locked" );
451// item->setPixmap( 0,pm); 453// item->setPixmap( 0,pm);
452 } else { 454 } else {
453 MimeType mt(fi->filePath()); 455 MimeType mt(fi->filePath());
454 pm=mt.pixmap(); //sets the correct pixmap for mimetype 456 pm=mt.pixmap(); //sets the correct pixmap for mimetype
455 if(pm.isNull()) 457 if(pm.isNull())
456 pm = Resource::loadPixmap( "UnknownDocument-14" ); 458 pm = Resource::loadPixmap( "UnknownDocument-14" );
457// item->setPixmap( 0,pm); 459// item->setPixmap( 0,pm);
458 } 460 }
459 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 461 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
460 // overlay link image 462 // overlay link image
461 pm= Resource::loadPixmap( "folder" ); 463 pm= Resource::loadPixmap( "folder" );
462 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 464 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
463 QPainter painter( &pm ); 465 QPainter painter( &pm );
464 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 466 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
465 pm.setMask( pm.createHeuristicMask( FALSE ) ); 467 pm.setMask( pm.createHeuristicMask( FALSE ) );
466// item->setPixmap( 0, pm); 468// item->setPixmap( 0, pm);
467 } 469 }
468 item->setPixmap( 0, pm); 470 item->setPixmap( 0, pm);
469 } 471 }
470 isDir=FALSE; 472 isDir=FALSE;
471 ++it; 473 ++it;
472 } 474 }
473 475
474 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 476 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
475 struct stat buf; 477 struct stat buf;
476// struct stat st; 478// struct stat st;
477// mode_t mode; 479// mode_t mode;
478 DIR *dir; 480 DIR *dir;
479// int fd = 0; 481// int fd = 0;
480 struct dirent *mydirent; 482 struct dirent *mydirent;
481// int i = 1; 483// int i = 1;
482 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 484 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
483 while ((mydirent = readdir(dir)) != NULL) { 485 while ((mydirent = readdir(dir)) != NULL) {
484 lstat( mydirent->d_name, &buf); 486 lstat( mydirent->d_name, &buf);
485 qDebug(mydirent->d_name); 487 qDebug(mydirent->d_name);
486// mode = buf.st_mode; 488// mode = buf.st_mode;
487 fileL.sprintf("%s", mydirent->d_name); 489 fileL.sprintf("%s", mydirent->d_name);
488// fileS.sprintf("%d, %d", ); //this isn't correct 490// fileS.sprintf("%d, %d", ); //this isn't correct
489 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 491 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
490 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 492 fileDate.sprintf("%s", ctime( &buf.st_mtime));
491 if( fileL.find(".") == -1 ){ 493 if( fileL.find(".") == -1 ){
492 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 494 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
493 pm = Resource::loadPixmap( "UnknownDocument-14" ); 495 pm = Resource::loadPixmap( "UnknownDocument-14" );
494 item->setPixmap( 0,pm); 496 item->setPixmap( 0,pm);
495 } 497 }
496 } 498 }
497 499
498 closedir(dir); 500 closedir(dir);
499 } 501 }
500 502
501 Remote_View->setSorting( 3,FALSE); 503 Remote_View->setSorting( 3,FALSE);
502 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 504 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
503} 505}
504 506
505void AdvancedFm::localListClicked(QListViewItem *selectedItem) 507void AdvancedFm::localListClicked(QListViewItem *selectedItem)
506{ 508{
507 if(selectedItem) { 509 if(selectedItem) {
508 QString strItem=selectedItem->text(0); 510 QString strItem=selectedItem->text(0);
509 QString strSize=selectedItem->text(1); 511 QString strSize=selectedItem->text(1);
510 strSize=strSize.stripWhiteSpace(); 512 strSize=strSize.stripWhiteSpace();
511 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 513 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
512 // is symlink 514 // is symlink
513 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 515 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
514 if(QDir(strItem2).exists() ) { 516 if(QDir(strItem2).exists() ) {
515 currentDir.cd(strItem2, TRUE); 517 currentDir.cd(strItem2, TRUE);
516 populateLocalView(); 518 populateLocalView();
517 } 519 }
518 } else { // not a symlink 520 } else { // not a symlink
519 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 521 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
520 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 522 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
521 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 523 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
522 currentDir.cd(strItem,FALSE); 524 currentDir.cd(strItem,FALSE);
523 populateLocalView(); 525 populateLocalView();
524 } else { 526 } else {
525 currentDir.cdUp(); 527 currentDir.cdUp();
526 populateLocalView(); 528 populateLocalView();
527 } 529 }
528 if(QDir(strItem).exists()){ 530 if(QDir(strItem).exists()){
529 currentDir.cd(strItem, TRUE); 531 currentDir.cd(strItem, TRUE);
530 populateLocalView(); 532 populateLocalView();
531 } 533 }
532 } else { 534 } else {
533 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 535 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
534 if( QFile::exists(strItem ) ) { 536 if( QFile::exists(strItem ) ) {
535// qDebug("upload "+strItem); 537// qDebug("upload "+strItem);
536 } 538 }
537 } //end not symlink 539 } //end not symlink
538 chdir(strItem.latin1()); 540 chdir(strItem.latin1());
539 } 541 }
540 } 542 }
541} 543}
542 544
543void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) 545void AdvancedFm::remoteListClicked(QListViewItem *selectedItem)
544{ 546{
545 if(selectedItem) { 547 if(selectedItem) {
546 QString strItem=selectedItem->text(0); 548 QString strItem=selectedItem->text(0);
547 QString strSize=selectedItem->text(1); 549 QString strSize=selectedItem->text(1);
548 strSize=strSize.stripWhiteSpace(); 550 strSize=strSize.stripWhiteSpace();
549 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 551 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
550 // is symlink 552 // is symlink
551 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 553 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
552 if(QDir(strItem2).exists() ) { 554 if(QDir(strItem2).exists() ) {
553 currentRemoteDir.cd(strItem2, TRUE); 555 currentRemoteDir.cd(strItem2, TRUE);
554 populateRemoteView(); 556 populateRemoteView();
555 } 557 }
556 } else { // not a symlink 558 } else { // not a symlink
557 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 559 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
558 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 560 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
559 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 561 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
560 currentRemoteDir.cd(strItem,FALSE); 562 currentRemoteDir.cd(strItem,FALSE);
561 populateRemoteView(); 563 populateRemoteView();
562 } else { 564 } else {
563 currentRemoteDir.cdUp(); 565 currentRemoteDir.cdUp();
564 populateRemoteView(); 566 populateRemoteView();
565 } 567 }
566 if(QDir(strItem).exists()){ 568 if(QDir(strItem).exists()){
567 currentRemoteDir.cd(strItem, TRUE); 569 currentRemoteDir.cd(strItem, TRUE);
568 populateRemoteView(); 570 populateRemoteView();
569 } 571 }
570 } else { 572 } else {
571 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 573 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
572 if( QFile::exists(strItem ) ) { 574 if( QFile::exists(strItem ) ) {
573// qDebug("upload "+strItem); 575// qDebug("upload "+strItem);
574 } 576 }
575 } //end not symlink 577 } //end not symlink
576 chdir(strItem.latin1()); 578 chdir(strItem.latin1());
577 } 579 }
578 } 580 }
579} 581}
580 582
581void AdvancedFm::doLocalCd() 583void AdvancedFm::doLocalCd()
582{ 584{
583 localListClicked( Local_View->currentItem()); 585 localListClicked( Local_View->currentItem());
584} 586}
585 587
586void AdvancedFm::doRemoteCd() 588void AdvancedFm::doRemoteCd()
587{ 589{
588 localListClicked( Remote_View->currentItem()); 590 localListClicked( Remote_View->currentItem());
589} 591}
590 592
591void AdvancedFm::showHidden() 593void AdvancedFm::showHidden()
592{ 594{
593 if (b) { 595 if (b) {
594 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 596 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
595 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 597 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
596// localMenu->setItemChecked(localMenu->idAt(0),TRUE); 598// localMenu->setItemChecked(localMenu->idAt(0),TRUE);
597// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 599// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
598 b=FALSE; 600 b=FALSE;
599 601
600 } else { 602 } else {
601 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 603 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
602 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 604 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
603// localMenu->setItemChecked(localMenu->idAt(0),FALSE); 605// localMenu->setItemChecked(localMenu->idAt(0),FALSE);
604// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 606// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
605 b=TRUE; 607 b=TRUE;
606 } 608 }
607 populateLocalView(); 609 populateLocalView();
608 610
609} 611}
610 612
611void AdvancedFm::showRemoteHidden() 613void AdvancedFm::showRemoteHidden()
612{ 614{
613 if (b) { 615 if (b) {
614 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 616 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
615// viewMenu->setItemChecked(localMenu->idAt(0),TRUE); 617// viewMenu->setItemChecked(localMenu->idAt(0),TRUE);
616// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 618// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
617 b=TRUE; 619 b=TRUE;
618 620
619 } else { 621 } else {
620 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 622 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
621// localMenu->setItemChecked(localMenu->idAt(0),FALSE); 623// localMenu->setItemChecked(localMenu->idAt(0),FALSE);
622// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 624// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
623 b=FALSE; 625 b=FALSE;
624 } 626 }
625 populateRemoteView(); 627 populateRemoteView();
626} 628}
627 629
628void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 630void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
629{ 631{
630 switch (mouse) { 632 switch (mouse) {
631 case 1: 633 case 1:
632 break; 634 break;
633 case 2: 635 case 2:
634 showLocalMenu(item); 636 showLocalMenu(item);
635 Local_View->clearSelection(); 637 Local_View->clearSelection();
636 break; 638 break;
637 }; 639 };