summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp1452
1 files changed, 685 insertions, 767 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index d8bdff7..74654fc 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -66,65 +66,63 @@
66#include <errno.h> 66#include <errno.h>
67#include <sys/vfs.h> 67#include <sys/vfs.h>
68#include <mntent.h> 68#include <mntent.h>
69#include <sys/utsname.h> 69#include <sys/utsname.h>
70 70
71AdvancedFm::AdvancedFm( ) 71AdvancedFm::AdvancedFm( )
72 : QMainWindow( ) { 72 : QMainWindow( ) {
73 init(); 73 init();
74 renameBox = 0; 74 renameBox = 0;
75 75
76 initConnections(); 76 initConnections();
77 populateLocalView(); 77 populateLocalView();
78 populateRemoteView(); 78 populateRemoteView();
79 currentPathCombo->setFocus(); 79 currentPathCombo->setFocus();
80} 80}
81 81
82AdvancedFm::~AdvancedFm() { 82AdvancedFm::~AdvancedFm() {
83} 83}
84 84
85void AdvancedFm::cleanUp() { 85
86void AdvancedFm::cleanUp()
87{
86 QString sfile=QDir::homeDirPath(); 88 QString sfile=QDir::homeDirPath();
87 if(sfile.right(1) != "/") 89 if(sfile.right(1) != "/")
88 sfile+="/._temp"; 90 sfile+="/._temp";
89 else 91 else
90 sfile+="._temp"; 92 sfile+="._temp";
91 QFile file( sfile); 93 QFile file( sfile);
92 if(file.exists()) 94 if(file.exists())
93 file.remove(); 95 file.remove();
94} 96}
95 97
96void AdvancedFm::tabChanged(QWidget *w) { 98void AdvancedFm::tabChanged(QWidget *w)
97// qDebug("tab changed %d",TabWidget->getCurrentTab()); 99{
98 100 if( w == tab)
99 if ( w == tab) { 101 whichTab = 1;
100// if (TabWidget->getCurrentTab() == 0) { 102 else
101// if (TabWidget->currentPageIndex() == 0) { 103 whichTab = 2;
102 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 104
103 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 105 //qDebug("tab changed %d", whichTab );
104 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 106
105 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 107 QString path = CurrentDir()->canonicalPath();
106 setCaption("AdvancedFm :: "+fs+" :: " 108 currentPathCombo->lineEdit()->setText( path );
107 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 109
108 110 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
109 } 111 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
110 if ( w == tab_2) { 112
111// if (TabWidget->getCurrentTab() == 1) { 113 QString fs= getFileSystemType( (const QString &) path);
112 114
113// if (TabWidget->currentPageIndex() == 1) { 115 setCaption("AdvancedFm :: "+fs+" :: "
114 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 116 +checkDiskSpace( (const QString &) path )+ " kB free" );
115 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 117 chdir( path.latin1());
116 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
117 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
118 setCaption("AdvancedFm :: "+fs+" :: "
119 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
120 }
121} 118}
122 119
123 120
124void AdvancedFm::populateLocalView() { 121void AdvancedFm::populateLocalView()
122{
125 QPixmap pm; 123 QPixmap pm;
126 Local_View->clear(); 124 Local_View->clear();
127 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 125 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
128 currentDir.setMatchAllDirs(TRUE); 126 currentDir.setMatchAllDirs(TRUE);
129 currentDir.setNameFilter(filterStr); 127 currentDir.setNameFilter(filterStr);
130 QString fileL, fileS, fileDate; 128 QString fileL, fileS, fileDate;
@@ -132,96 +130,116 @@ void AdvancedFm::populateLocalView() {
132 setCaption("AdvancedFm :: "+fs+" :: " 130 setCaption("AdvancedFm :: "+fs+" :: "
133 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 131 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
134 bool isDir=FALSE; 132 bool isDir=FALSE;
135 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 133 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
136 QFileInfoListIterator it(*list); 134 QFileInfoListIterator it(*list);
137 QFileInfo *fi; 135 QFileInfo *fi;
138 while ( (fi=it.current()) ) { 136 while ( (fi=it.current()) )
139 if (fi->isSymLink() ) { 137 {
140 QString symLink=fi->readLink(); 138 if (fi->isSymLink() )
141 QFileInfo sym( symLink); 139 {
142 fileS.sprintf( "%10i", sym.size() ); 140 QString symLink=fi->readLink();
143 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 141 QFileInfo sym( symLink);
144 fileDate = sym.lastModified().toString(); 142 fileS.sprintf( "%10i", sym.size() );
145 } else { 143 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
146 fileS.sprintf( "%10i", fi->size() ); 144 fileDate = sym.lastModified().toString();
147 fileL.sprintf( "%s",fi->fileName().data() ); 145 }
148 fileDate= fi->lastModified().toString(); 146 else
149 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 147 {
150 fileL+="/"; 148 fileS.sprintf( "%10i", fi->size() );
151 isDir=TRUE; 149 fileL.sprintf( "%s",fi->fileName().data() );
152 } 150 fileDate= fi->lastModified().toString();
153 } 151 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() )
154 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 152 {
155 if(fileL !="./" && fi->exists()) { 153 fileL+="/";
156 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 154 isDir=TRUE;
157 155 }
158 if(isDir || fileL.find("/",0,TRUE) != -1) { 156 }
159 157 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
160 if( !QDir( fi->filePath() ).isReadable()) //is directory 158 if(fileL !="./" && fi->exists())
161 pm = Resource::loadPixmap( "lockedfolder" ); 159 {
162 else 160 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
163 pm= Resource::loadPixmap( "folder" ); 161
164 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 162 if(isDir || fileL.find("/",0,TRUE) != -1)
165 pm = Resource::loadPixmap( "exec"); 163 {
166 } else if( (fileInfo.permission( QFileInfo::ExeUser) 164
167 | fileInfo.permission( QFileInfo::ExeGroup) 165 if( !QDir( fi->filePath() ).isReadable()) //is directory
168 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 166 pm = Resource::loadPixmap( "lockedfolder" );
169 pm = Resource::loadPixmap( "exec"); 167 else
170 } else if( !fi->isReadable() ) { 168 pm= Resource::loadPixmap( "folder" );
171 pm = Resource::loadPixmap( "locked" ); 169 }
172 } else { //everything else goes by mimetype 170 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
173 MimeType mt(fi->filePath()); 171 {
174 pm=mt.pixmap(); //sets the correct pixmap for mimetype 172 pm = Resource::loadPixmap( "exec");
175 if(pm.isNull()) 173 }
176 pm = Resource::loadPixmap( "UnknownDocument-14" ); 174 else if( (fileInfo.permission( QFileInfo::ExeUser)
177 } 175 | fileInfo.permission( QFileInfo::ExeGroup)
178 item->setPixmap( 0,pm); 176 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
179 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 177 {
180 // overlay link image 178 pm = Resource::loadPixmap( "exec");
181 pm= Resource::loadPixmap( "folder" ); 179 }
182 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 180 else if( !fi->isReadable() )
183 QPainter painter( &pm ); 181 {
184 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 182 pm = Resource::loadPixmap( "locked" );
185 pm.setMask( pm.createHeuristicMask( FALSE ) ); 183 }
186 item->setPixmap( 0, pm); 184 else { //everything else goes by mimetype
187 } 185 MimeType mt(fi->filePath());
188 } 186 pm=mt.pixmap(); //sets the correct pixmap for mimetype
189 isDir=FALSE; 187 if(pm.isNull())
190 ++it; 188 pm = Resource::loadPixmap( "UnknownDocument-14" );
191 } 189 }
192 190 item->setPixmap( 0,pm);
193 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 191 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
194 struct stat buf; 192 {
195 dev_t devT; 193 // overlay link image
196 DIR *dir; 194 pm= Resource::loadPixmap( "folder" );
197 struct dirent *mydirent; 195 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
198 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 196 QPainter painter( &pm );
199 while ((mydirent = readdir(dir)) != NULL) { 197 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
200 lstat( mydirent->d_name, &buf); 198 pm.setMask( pm.createHeuristicMask( FALSE ) );
199 item->setPixmap( 0, pm);
200 }
201 }
202 isDir=FALSE;
203 ++it;
204 }
205
206 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1)
207 {
208 struct stat buf;
209 dev_t devT;
210 DIR *dir;
211 struct dirent *mydirent;
212
213 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
214 while ((mydirent = readdir(dir)) != NULL)
215 {
216 lstat( mydirent->d_name, &buf);
201// qDebug(mydirent->d_name); 217// qDebug(mydirent->d_name);
202 fileL.sprintf("%s", mydirent->d_name); 218 fileL.sprintf("%s", mydirent->d_name);
203 devT = buf.st_dev; 219 devT = buf.st_dev;
204 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 220 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
205 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 221 fileDate.sprintf("%s", ctime( &buf.st_mtime));
206 if( fileL.find(".") == -1 ){ 222 if( fileL.find(".") == -1 )
207 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 223 {
208 pm = Resource::loadPixmap( "UnknownDocument-14" ); 224 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
209 item->setPixmap( 0,pm); 225 pm = Resource::loadPixmap( "UnknownDocument-14" );
210 } 226 item->setPixmap( 0,pm);
211 } 227 }
212 228 }
213 closedir(dir); 229
214 } 230 closedir(dir);
231 }
215 232
216 Local_View->setSorting( 3,FALSE); 233 Local_View->setSorting( 3,FALSE);
217 fillCombo( (const QString &) currentDir.canonicalPath()); 234 fillCombo( (const QString &) currentDir.canonicalPath());
218} 235}
219 236
220 237
221void AdvancedFm::populateRemoteView() { 238void AdvancedFm::populateRemoteView()
239{
222 QPixmap pm; 240 QPixmap pm;
223 Remote_View->clear(); 241 Remote_View->clear();
224 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 242 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
225 currentRemoteDir.setMatchAllDirs(TRUE); 243 currentRemoteDir.setMatchAllDirs(TRUE);
226 currentRemoteDir.setNameFilter(filterStr); 244 currentRemoteDir.setNameFilter(filterStr);
227 QString fileL, fileS, fileDate; 245 QString fileL, fileS, fileDate;
@@ -230,501 +248,426 @@ void AdvancedFm::populateRemoteView() {
230 setCaption("AdvancedFm :: "+fs+" :: " 248 setCaption("AdvancedFm :: "+fs+" :: "
231 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 249 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
232 bool isDir=FALSE; 250 bool isDir=FALSE;
233 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 251 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
234 QFileInfoListIterator it(*list); 252 QFileInfoListIterator it(*list);
235 QFileInfo *fi; 253 QFileInfo *fi;
236 while ( (fi=it.current()) ) { 254 while ( (fi=it.current()) )
237 if (fi->isSymLink() ){ 255 {
238 QString symLink=fi->readLink(); 256 if (fi->isSymLink() )
239 // qDebug("Symlink detected "+symLink); 257 {
240 QFileInfo sym( symLink); 258 QString symLink=fi->readLink();
241 fileS.sprintf( "%10i", sym.size() ); 259 // qDebug("Symlink detected "+symLink);
242 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 260 QFileInfo sym( symLink);
243 fileDate = sym.lastModified().toString(); 261 fileS.sprintf( "%10i", sym.size() );
244 } else { 262 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
245 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 263 fileDate = sym.lastModified().toString();
246 fileS.sprintf( "%10i", fi->size() ); 264 }
247 fileL.sprintf( "%s",fi->fileName().data() ); 265 else
248 fileDate= fi->lastModified().toString(); 266 {
249 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 267 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
250 fileL+="/"; 268 fileS.sprintf( "%10i", fi->size() );
251 isDir=TRUE; 269 fileL.sprintf( "%s",fi->fileName().data() );
252 // qDebug( fileL); 270 fileDate= fi->lastModified().toString();
253 } 271
254 } 272 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() )
255 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 273 {
256 if(fileL !="./" && fi->exists()) { 274 fileL+="/";
257 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 275 isDir=TRUE;
258 QPixmap pm; 276 // qDebug( fileL);
259 277 }
260 if(isDir || fileL.find("/",0,TRUE) != -1) { 278 }
261 if( !QDir( fi->filePath() ).isReadable()) 279
262 pm = Resource::loadPixmap( "lockedfolder" ); 280 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
263 else 281 if(fileL !="./" && fi->exists())
264 pm= Resource::loadPixmap( "folder" ); 282 {
265 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 283 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
266 pm = Resource::loadPixmap( "exec"); 284 QPixmap pm;
267 } else if( (fileInfo.permission( QFileInfo::ExeUser) 285
268 | fileInfo.permission( QFileInfo::ExeGroup) 286 if(isDir || fileL.find("/",0,TRUE) != -1)
269 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 287 {
270 pm = Resource::loadPixmap( "exec"); 288 if( !QDir( fi->filePath() ).isReadable())
271 } else if( !fi->isReadable() ) { 289 pm = Resource::loadPixmap( "lockedfolder" );
272 pm = Resource::loadPixmap( "locked" ); 290 else
273 } else { 291 pm= Resource::loadPixmap( "folder" );
274 MimeType mt(fi->filePath()); 292 }
275 pm=mt.pixmap(); //sets the correct pixmap for mimetype 293 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
276 if(pm.isNull()) 294 {
277 pm = Resource::loadPixmap( "UnknownDocument-14" ); 295 pm = Resource::loadPixmap( "exec");
278 } 296 }
279 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 297 else if( (fileInfo.permission( QFileInfo::ExeUser)
280 // overlay link image 298 | fileInfo.permission( QFileInfo::ExeGroup)
281 pm= Resource::loadPixmap( "folder" ); 299 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
282 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 300 {
283 QPainter painter( &pm ); 301 pm = Resource::loadPixmap( "exec");
284 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 302 }
285 pm.setMask( pm.createHeuristicMask( FALSE ) ); 303 else if( !fi->isReadable() )
286 } 304 {
287 item->setPixmap( 0, pm); 305 pm = Resource::loadPixmap( "locked" );
288 } 306 }
289 isDir=FALSE; 307 else
290 ++it; 308 {
291 } 309 MimeType mt(fi->filePath());
292 310 pm=mt.pixmap(); //sets the correct pixmap for mimetype
293 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 311 if(pm.isNull())
294 struct stat buf; 312 pm = Resource::loadPixmap( "UnknownDocument-14" );
295 DIR *dir; 313 }
296 struct dirent *mydirent; 314 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
297 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 315 {
298 while ((mydirent = readdir(dir)) != NULL) { 316 // overlay link image
299 lstat( mydirent->d_name, &buf); 317 pm= Resource::loadPixmap( "folder" );
318 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
319 QPainter painter( &pm );
320 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
321 pm.setMask( pm.createHeuristicMask( FALSE ) );
322 }
323 item->setPixmap( 0, pm);
324 }
325 isDir=FALSE;
326 ++it;
327 }
328
329 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1)
330 {
331 struct stat buf;
332 DIR *dir;
333 struct dirent *mydirent;
334 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
335
336 while ((mydirent = readdir(dir)) != NULL)
337 {
338 lstat( mydirent->d_name, &buf);
300// qDebug(mydirent->d_name); 339// qDebug(mydirent->d_name);
301 fileL.sprintf("%s", mydirent->d_name); 340 fileL.sprintf("%s", mydirent->d_name);
302 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 341 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
303 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 342 fileDate.sprintf("%s", ctime( &buf.st_mtime));
304 if( fileL.find(".") == -1 ){
305 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
306 pm = Resource::loadPixmap( "UnknownDocument-14" );
307 item->setPixmap( 0,pm);
308 }
309 }
310 343
311 closedir(dir); 344 if( fileL.find(".") == -1 )
312 } 345 {
346 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
347 pm = Resource::loadPixmap( "UnknownDocument-14" );
348 item->setPixmap( 0,pm);
349 }
350 }
351
352 closedir(dir);
353 }
313 354
314 Remote_View->setSorting( 3,FALSE); 355 Remote_View->setSorting( 3,FALSE);
315 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 356 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
316} 357}
317 358
318void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 359void AdvancedFm::ListClicked(QListViewItem *selectedItem)
319 if(selectedItem) { 360{
320 QString strItem=selectedItem->text(0); 361 if(selectedItem)
321 QString strSize=selectedItem->text(1); 362 {
322 strSize=strSize.stripWhiteSpace(); 363 QString strItem=selectedItem->text(0);
323 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 364 QString strSize=selectedItem->text(1);
324 QString strItem2 = dealWithSymName((const QString&)strItem); 365 strSize=strSize.stripWhiteSpace();
325// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 366 bool isDirectory = false;
326 if(QDir(strItem2).exists() ) { 367 QString strItem2;
327 currentDir.cd(strItem2, TRUE); 368
328 populateLocalView(); 369 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink
329 370 {
330 } 371 strItem2 = dealWithSymName((const QString&)strItem);
331 } else { // not a symlink 372 if(QDir(strItem2).exists() )
332 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 373 strItem = strItem2;
333 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 374 }
334 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 375
335 currentDir.cd(strItem,FALSE); 376 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 )
336 populateLocalView(); 377 {
337 Local_View->ensureItemVisible(Local_View->firstChild()); 378
338 379 if(QDir(strItem).exists())
339 } else { 380 isDirectory = true;
340 currentDir.cdUp(); 381 }
341 populateLocalView(); 382
342 Local_View->ensureItemVisible(Local_View->firstChild()); 383 if( isDirectory )
343 } 384 {
344 if(QDir(strItem).exists()){ 385 CurrentDir()->cd( strItem, TRUE);
345 currentDir.cd(strItem, TRUE); 386 PopulateView();
346 Local_View->ensureItemVisible(Local_View->firstChild()); 387 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
347 populateLocalView(); 388 }
348 } 389 chdir( strItem.latin1());
349 } else { 390 }
350 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 391}
351 if( QFile::exists(strItem ) ) { 392
352 // qDebug("clicked item "+strItem); 393void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
353 // DocLnk doc( strItem, FALSE );
354 // doc.execute();
355 // Local_View->clearSelection();
356 }
357 } //end not symlink
358 chdir(strItem.latin1());
359 }
360
361 }
362}
363
364void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
365
366 if(selectedItem) {
367 QString strItem=selectedItem->text(0);
368 QString strSize=selectedItem->text(1);
369 strSize=strSize.stripWhiteSpace();
370 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
371 QString strItem2 = dealWithSymName((const QString&)strItem);
372// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
373 currentRemoteDir.cd(strItem2, TRUE);
374 populateRemoteView();
375 } else { // not a symlink
376 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
377 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
378 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
379 currentRemoteDir.cd(strItem,FALSE);
380 populateRemoteView();
381 Remote_View->ensureItemVisible(Remote_View->firstChild());
382 } else {
383 currentRemoteDir.cdUp();
384 populateRemoteView();
385 Remote_View->ensureItemVisible(Remote_View->firstChild());
386 }
387 if(QDir(strItem).exists()){
388 currentRemoteDir.cd(strItem, TRUE);
389 populateRemoteView();
390 Remote_View->ensureItemVisible(Remote_View->firstChild());
391 }
392 } else {
393 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
394 if( QFile::exists(strItem ) ) {
395 // qDebug("clicked item "+strItem);
396 // DocLnk doc( strItem, FALSE );
397 // doc.execute();
398 // Remote_View->clearSelection();
399 }
400 } //end not symlink
401 chdir(strItem.latin1());
402 }
403 }
404}
405
406
407void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
408// qDebug("list pressed");
409 switch (mouse) { 394 switch (mouse) {
410 case 1: 395 case 1:
411 { 396 {
412 if(renameBox != 0 ) 397 if(renameBox != 0 )
413 { 398 {
414// qDebug("cancel rename");
415 cancelRename(); 399 cancelRename();
416 } 400 }
417 401
418 } 402 }
419 break; 403 break;
420 case 2: 404 case 2:
421 menuTimer.start( 500, TRUE ); 405 menuTimer.start( 500, TRUE );
422// qDebug("Start menu timer\n");
423 break; 406 break;
424 }; 407 };
425} 408}
426 409
427void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 410void AdvancedFm::switchToLocalTab()
428 411{
429 switch (mouse) {
430 case 1:
431 {
432 if(renameBox != 0 )
433 {
434// qDebug("cancel rename");
435 cancelRename();
436 }
437 }
438 break;
439 case 2:
440 menuTimer.start( 500, TRUE );
441// qDebug("Start menu timer");
442 break;
443 };
444}
445
446
447void AdvancedFm::switchToLocalTab() {
448 TabWidget->setCurrentTab(0); 412 TabWidget->setCurrentTab(0);
449 Local_View->setFocus(); 413 Local_View->setFocus();
450} 414}
451 415
452void AdvancedFm::switchToRemoteTab() { 416void AdvancedFm::switchToRemoteTab()
417{
453 TabWidget->setCurrentTab(1); 418 TabWidget->setCurrentTab(1);
454 Remote_View->setFocus(); 419 Remote_View->setFocus();
455} 420}
456 421
457void AdvancedFm::readConfig() { 422void AdvancedFm::readConfig()
423{
458 Config cfg("AdvancedFm"); 424 Config cfg("AdvancedFm");
459} 425}
460 426
461void AdvancedFm::writeConfig() { 427void AdvancedFm::writeConfig()
428{
462 Config cfg("AdvancedFm"); 429 Config cfg("AdvancedFm");
463} 430}
464 431
465void AdvancedFm::currentPathComboChanged() { 432void AdvancedFm::currentPathComboChanged()
466 if (TabWidget->getCurrentTab() == 0) { 433{
467// if (TabWidget->currentPageIndex() == 0) { 434 if(QDir( currentPathCombo->lineEdit()->text()).exists())
468 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 435 {
469 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 436 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
470 populateLocalView(); 437 PopulateView();
471 } else { 438 }
472 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 439 else
473 } 440 {
474 } 441 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
475 if (TabWidget->getCurrentTab() == 0) { 442 }
476// if (TabWidget->currentPageIndex() == 0) { 443}
477 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 444
478 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 445void AdvancedFm::fillCombo(const QString &currentPath)
479 populateRemoteView(); 446{
480 } else {
481 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
482 }
483 }
484}
485
486void AdvancedFm::fillCombo(const QString &currentPath) {
487// qDebug("%d",TabWidget->getCurrentTab()); 447// qDebug("%d",TabWidget->getCurrentTab());
488 if (TabWidget->getCurrentTab() == 0) { 448 if ( whichTab == 1)
489// if (TabWidget->currentPageIndex() == 0) { 449 {
490 currentPathCombo->lineEdit()->setText( currentPath); 450 currentPathCombo->lineEdit()->setText( currentPath);
491 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 451 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() )
492 currentPathCombo->clear(); 452 {
493 localDirPathStringList.prepend( currentPath ); 453 currentPathCombo->clear();
494 currentPathCombo->insertStringList( localDirPathStringList,-1); 454 localDirPathStringList.prepend( currentPath );
495 } 455 currentPathCombo->insertStringList( localDirPathStringList,-1);
496 } else { 456 }
497 currentPathCombo->lineEdit()->setText( currentPath); 457 }
498 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 458 else
499 currentPathCombo->clear(); 459 {
500 remoteDirPathStringList.prepend( currentPath ); 460 currentPathCombo->lineEdit()->setText( currentPath);
501 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 461 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() )
502 } 462 {
503 } 463 currentPathCombo->clear();
504} 464 remoteDirPathStringList.prepend( currentPath );
505 465 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
506void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 466 }
507 if (TabWidget->getCurrentTab() == 0) { 467 }
508// if (TabWidget->currentPageIndex() == 0) { 468}
509 chdir( currentPath.latin1() ); 469
510 currentDir.cd( currentPath, TRUE); 470void AdvancedFm::currentPathComboActivated(const QString & currentPath)
511 populateLocalView(); 471{
512 update();
513 } else {
514 chdir( currentPath.latin1() ); 472 chdir( currentPath.latin1() );
515 currentRemoteDir.cd( currentPath, TRUE); 473 CurrentDir()->cd( currentPath, TRUE);
516 populateRemoteView(); 474 PopulateView();
517 update(); 475 update();
518 }
519} 476}
520 477
521QStringList AdvancedFm::getPath() { 478QStringList AdvancedFm::getPath()
479{
522 QStringList strList; 480 QStringList strList;
523 if (TabWidget->getCurrentTab() == 0) { 481 QListView *thisView=CurrentView();
524// if (TabWidget->currentPageIndex() == 0) { 482 QList<QListViewItem> * getSelectedItems( QListView * thisView );
525 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 483 QListViewItemIterator it( thisView );
526 QListViewItemIterator it( Local_View ); 484 for ( ; it.current(); ++it )
527 for ( ; it.current(); ++it ) { 485 {
528 if ( it.current()->isSelected() ) { 486 if ( it.current()->isSelected() )
529 strList << it.current()->text(0); 487 {
530// qDebug(it.current()->text(0)); 488 strList << it.current()->text(0);
531 }
532 }
533 return strList;
534 } else {
535 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
536 QListViewItemIterator it( Remote_View );
537 for ( ; it.current(); ++it ) {
538 if ( it.current()->isSelected() ) {
539 strList << it.current()->text(0);
540// qDebug(it.current()->text(0)); 489// qDebug(it.current()->text(0));
541 } 490 }
542 } 491 }
543 return strList; 492 return strList;
544 }
545 return "";
546} 493}
547 494
548void AdvancedFm::homeButtonPushed() { 495void AdvancedFm::homeButtonPushed()
496{
549 QString current = QDir::homeDirPath(); 497 QString current = QDir::homeDirPath();
550 chdir( current.latin1() ); 498 chdir( current.latin1() );
551 if (TabWidget->getCurrentTab() == 0) { 499 CurrentDir()->cd( current, TRUE);
552// if (TabWidget->currentPageIndex() == 0) { 500 PopulateView();
553 currentDir.cd( current, TRUE);
554 populateLocalView();
555 } else {
556 currentRemoteDir.cd( current, TRUE);
557 populateRemoteView();
558 }
559 update(); 501 update();
560} 502}
561 503
562void AdvancedFm::docButtonPushed() { 504void AdvancedFm::docButtonPushed()
505{
563 QString current = QPEApplication::documentDir(); 506 QString current = QPEApplication::documentDir();
564 chdir( current.latin1() ); 507 chdir( current.latin1() );
565 508
566 if (TabWidget->getCurrentTab() == 0) { 509 CurrentDir()->cd( current, TRUE);
567//if (TabWidget->currentPageIndex() == 0) { 510 PopulateView();
568 currentDir.cd( current, TRUE);
569 populateLocalView();
570 } else {
571 currentRemoteDir.cd( current, TRUE);
572 populateRemoteView();
573 }
574 update(); 511 update();
575} 512}
576 513
577void AdvancedFm::SDButtonPushed() { 514void AdvancedFm::SDButtonPushed()
578 QString current = "/mnt/card";// this can change so fix 515{
516 QString current = "/mnt/card";// this can change so fix
579 chdir( current.latin1() ); 517 chdir( current.latin1() );
580 if (TabWidget->getCurrentTab() == 0) { 518 CurrentDir()->cd( current, TRUE);
581// if (TabWidget->currentPageIndex() == 0) { 519 PopulateView();
582 currentDir.cd( current, TRUE);
583 populateLocalView();
584 } else {
585 currentRemoteDir.cd( current, TRUE);
586 populateRemoteView();
587 }
588 update(); 520 update();
589
590} 521}
591 522
592void AdvancedFm::CFButtonPushed() { 523void AdvancedFm::CFButtonPushed()
593 QString current; 524{
594 if(zaurusDevice) 525 QString current;
595 current= "/mnt/cf"; //zaurus 526 if(zaurusDevice)
596 else 527 current= "/mnt/cf"; //zaurus
597 current = "/mnt/hda"; //ipaq 528 else
598 529 current = "/mnt/hda"; //ipaq
599 chdir( current.latin1() );
600 if (TabWidget->getCurrentTab() == 0) {
601// if (TabWidget->currentPageIndex() == 0) {
602 currentDir.cd( current, TRUE);
603 populateLocalView();
604 } else {
605 currentRemoteDir.cd( current, TRUE);
606 populateRemoteView();
607 }
608 update();
609}
610 530
531 chdir( current.latin1() );
532 CurrentDir()->cd( current, TRUE);
533 PopulateView();
534 update();
535}
611 536
612 537
613void AdvancedFm::doAbout() { 538void AdvancedFm::doAbout()
539{
614 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 540 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
615 "is copyright 2002 by\n" 541 "is copyright 2002-2003 by\n"
616 "L.J.Potter<llornkcor@handhelds.org>\n" 542 "L.J.Potter<llornkcor@handhelds.org>\n"
617 "and is licensed by the GPL")); 543 "and is licensed by the GPL"));
618} 544}
619 545
620void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 546void AdvancedFm::keyPressEvent( QKeyEvent *e)
621 if( TabWidget->hasFocus()) 547{
622 switch ( e->key() ) { 548// e->accept();
623 case Key_Delete: 549 if( CurrentView()->hasFocus() )
624 del(); 550 {
625 break; 551 switch ( e->key() ) {
626 case Key_H: 552 case Key_Delete:
627 showHidden(); 553 del();
628 break; 554 break;
629 case Key_E: 555 case Key_A:
630 runThis(); 556 copyAs();
631 break; 557 break;
632 case Key_C: 558 case Key_C:
633 copy(); 559 copy();
634 break; 560 break;
635 case Key_A: 561 case Key_E:
636 copyAs(); 562 runThis();
637 break; 563 break;
638 case Key_M: 564 case Key_G:
639 move(); 565 {
640 break; 566 currentPathCombo->lineEdit()->setFocus();
641 case Key_R: 567 }
642 rn();
643 break;
644 case Key_I:
645 fileStatus();
646 break;
647 case Key_U:
648 upDir();
649 break;
650 case Key_P:
651 filePerms();
652 break;
653 case Key_N:
654 mkDir();
655 break;
656 case Key_1:
657 switchToLocalTab();
658 break;
659 case Key_2:
660 switchToRemoteTab();
661 break;
662 case Key_3:
663 CFButtonPushed();
664 break;
665 case Key_4:
666 SDButtonPushed();
667 break;
668 case Key_5:
669 homeButtonPushed();
670 break;
671 case Key_6:
672 docButtonPushed();
673 break;
674 case Key_7:
675 break;
676 case Key_8:
677 break;
678 case Key_9:
679 break;
680 case Key_0:
681 break; 568 break;
569
570 case Key_H:
571 showHidden();
572 break;
573 case Key_I:
574 fileStatus();
575 break;
576 case Key_M:
577 move();
578 break;
579 case Key_N:
580 mkDir();
581 break;
582 case Key_P:
583 filePerms();
584 break;
585 case Key_R:
586 rn();
587 break;
588 case Key_U:
589 upDir();
590 break;
591 case Key_1:
592 switchToLocalTab();
593 break;
594 case Key_2:
595 switchToRemoteTab();
596 break;
597 case Key_3:
598 CFButtonPushed();
599 break;
600 case Key_4:
601 SDButtonPushed();
602 break;
603 case Key_5:
604 homeButtonPushed();
605 break;
606 case Key_6:
607 docButtonPushed();
608 break;
609 case Key_7:
610 break;
611 case Key_8:
612 break;
613 case Key_9:
614 break;
615 case Key_0:
616 break;
617 };
618 e->accept();
682 } 619 }
683} 620}
684 621
622void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
623{
624 if( CurrentView()->hasFocus() )
625 e->ignore();
626}
627
685 628
686void AdvancedFm::QPEButtonPushed() { 629void AdvancedFm::QPEButtonPushed()
630{
687 QString current = QPEApplication::qpeDir(); 631 QString current = QPEApplication::qpeDir();
688 chdir( current.latin1() ); 632 chdir( current.latin1() );
689 if (TabWidget->getCurrentTab() == 0) { 633 CurrentDir()->cd( current, TRUE);
690// if (TabWidget->currentPageIndex() == 0) { 634 PopulateView();
691 currentDir.cd( current, TRUE);
692 populateLocalView();
693 } else {
694 currentRemoteDir.cd( current, TRUE);
695 populateRemoteView();
696 }
697 update(); 635 update();
698} 636}
699 637
700void AdvancedFm::parsetab(const QString &fileName) { 638void AdvancedFm::parsetab(const QString &fileName)
639{
701 640
702 fileSystemTypeList.clear(); 641 fileSystemTypeList.clear();
703 fsList.clear(); 642 fsList.clear();
704 struct mntent *me; 643 struct mntent *me;
705 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 644 FILE *mntfp = setmntent( fileName.latin1(), "r" );
706 if ( mntfp ) { 645 if ( mntfp )
707 while ( (me = getmntent( mntfp )) != 0 ) { 646 {
647 while ( (me = getmntent( mntfp )) != 0 )
648 {
708 QString deviceName = me->mnt_fsname; 649 QString deviceName = me->mnt_fsname;
709 QString filesystemType = me->mnt_type; 650 QString filesystemType = me->mnt_type;
710 QString mountDir = me->mnt_dir; 651 QString mountDir = me->mnt_dir;
711 if(deviceName != "none") { 652 if(deviceName != "none")
653 {
712 if( fsList.contains(filesystemType) == 0 654 if( fsList.contains(filesystemType) == 0
713 & filesystemType.find("proc",0,TRUE) == -1 655 & filesystemType.find("proc",0,TRUE) == -1
714 & filesystemType.find("cramfs",0,TRUE) == -1 656 & filesystemType.find("cramfs",0,TRUE) == -1
715 & filesystemType.find("auto",0,TRUE) == -1) 657 & filesystemType.find("auto",0,TRUE) == -1)
716 fsList << filesystemType; 658 fsList << filesystemType;
717 fileSystemTypeList << mountDir+"::"+filesystemType; 659 fileSystemTypeList << mountDir+"::"+filesystemType;
718 } 660 }
719 } 661 }
720 } 662 }
721 endmntent( mntfp ); 663 endmntent( mntfp );
722} 664}
723 665
724QString AdvancedFm::getFileSystemType(const QString &currentText) { 666QString AdvancedFm::getFileSystemType(const QString &currentText)
667{
725 parsetab("/etc/mtab"); //why did TT forget filesystem type? 668 parsetab("/etc/mtab"); //why did TT forget filesystem type?
726 QString current = currentText;//.right( currentText.length()-1); 669 QString current = currentText;//.right( currentText.length()-1);
727 QString baseFs; 670 QString baseFs;
728 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 671 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
729 QString temp = (*it); 672 QString temp = (*it);
730 QString path = temp.left(temp.find("::",0,TRUE) ); 673 QString path = temp.left(temp.find("::",0,TRUE) );
@@ -734,131 +677,113 @@ QString AdvancedFm::getFileSystemType(const QString &currentText) {
734 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 677 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
735 } 678 }
736 } 679 }
737 return baseFs; 680 return baseFs;
738} 681}
739 682
740QString AdvancedFm::getDiskSpace( const QString &path) { 683QString AdvancedFm::getDiskSpace( const QString &path)
741 struct statfs fss; 684{
742 if ( !statfs( path.latin1(), &fss ) ) { 685 struct statfs fss;
743 int blkSize = fss.f_bsize; 686 if ( !statfs( path.latin1(), &fss ) ) {
744 // int totalBlks = fs.f_blocks; 687 int blkSize = fss.f_bsize;
745 int availBlks = fss.f_bavail; 688 // int totalBlks = fs.f_blocks;
746 689 int availBlks = fss.f_bavail;
747 long mult = blkSize / 1024;
748 long div = 1024 / blkSize;
749 if ( !mult ) mult = 1;
750 if ( !div ) div = 1;
751
752 return QString::number(availBlks * mult / div);
753 }
754 return "";
755}
756 690
691 long mult = blkSize / 1024;
692 long div = 1024 / blkSize;
693 if ( !mult ) mult = 1;
694 if ( !div ) div = 1;
757 695
758void AdvancedFm::showFileMenu() { 696 return QString::number(availBlks * mult / div);
697 }
698 return "";
699}
759 700
760 QString curApp;
761 bool isLocalView = false;
762 if (TabWidget->getCurrentTab() == 0) {
763// if (TabWidget->currentPageIndex() == 0) {
764 isLocalView = TRUE;
765 curApp = Local_View->currentItem()->text(0);
766 } else {
767 curApp = Remote_View->currentItem()->text(0);
768 }
769 701
770 MimeType mt( curApp ); 702void AdvancedFm::showFileMenu()
771 const AppLnk* app = mt.application(); 703{
772 QFile fi(curApp); 704 QString curApp;
773 QPopupMenu *m = new QPopupMenu(0); 705 curApp = CurrentView()->currentItem()->text(0);
774 QPopupMenu *n = new QPopupMenu(0); 706
775 // QPopupMenu *o = new QPopupMenu(0); 707 MimeType mt( curApp );
776 if (TabWidget->getCurrentTab() == 0) 708 const AppLnk* app = mt.application();
777 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 709 QFile fi(curApp);
778 else 710 QPopupMenu *m = new QPopupMenu(0);
779 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); 711 QPopupMenu *n = new QPopupMenu(0);
780 712 // QPopupMenu *o = new QPopupMenu(0);
781 if ( QFileInfo(fi).isDir() ) { 713 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
782 m->insertSeparator(); 714
783 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 715 if ( QFileInfo(fi).isDir() )
784 } else { 716 {
785 717 m->insertSeparator();
786 if ( app ) 718 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
787 m->insertItem( app->pixmap(), tr( "Open in " 719 }
788 + app->name() ), this, SLOT( runThis() ) ); 720 else
789 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 721 {
790 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 722
791 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 723 if ( app )
792 } 724 m->insertItem( app->pixmap(), tr( "Open in "
793 725 + app->name() ), this, SLOT( runThis() ) );
794 m->insertItem(tr("Actions"),n); 726 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
795 if(isLocalView) 727 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
796 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 728 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
797 else 729 }
798 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 730
799 731 m->insertItem(tr("Actions"),n);
800 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 732 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
801 733
802 n->insertSeparator(); 734 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
803 735
804 736 n->insertSeparator();
805 if(isLocalView) 737 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
806 n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 738
807 else 739 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
808 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 740 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
809 741 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
810 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 742 n->insertItem( tr( "Move" ), this, SLOT( move() ));
811 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 743
812 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 744 n->insertSeparator();
813 n->insertItem( tr( "Move" ), this, SLOT( move() )); 745 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
814 746 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
815 n->insertSeparator(); 747
816 748 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
817 if(isLocalView) 749 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
818 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 750
819 else 751 m->insertSeparator();
820 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 752 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
821
822
823 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
824
825 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
826 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
827
828 m->insertSeparator();
829 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
830 753
831#if defined(QT_QWS_OPIE) 754#if defined(QT_QWS_OPIE)
832 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 755 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
833#endif 756#endif
834 m->setCheckable(TRUE); 757 m->setCheckable(TRUE);
835 if (!b) 758 if (!b)
836 m->setItemChecked(m->idAt(0),TRUE); 759 m->setItemChecked(m->idAt(0),TRUE);
837 else 760 else
838 m->setItemChecked(m->idAt(0),FALSE); 761 m->setItemChecked(m->idAt(0),FALSE);
839 762
840 if(Ir::supported()) 763 if(Ir::supported())
841 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 764 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
842 m->setFocus(); 765 m->setFocus();
843 m->exec( QPoint( 4,QCursor::pos().y()) ); 766 m->exec( QPoint( 4,QCursor::pos().y()) );
844
845 if(m) delete m;
846}
847 767
768 if(m) delete m;
769}
848 770
849void AdvancedFm::cancelMenuTimer() {
850 771
772void AdvancedFm::cancelMenuTimer()
773{
851// qDebug("selectionChanged: cancel menu timer"); 774// qDebug("selectionChanged: cancel menu timer");
852 if( menuTimer.isActive() ) 775 if( menuTimer.isActive() )
853 menuTimer.stop(); 776 menuTimer.stop();
854} 777}
855 778
856QString AdvancedFm::checkDiskSpace(const QString &path) { 779QString AdvancedFm::checkDiskSpace(const QString &path)
780{
857 struct statfs fss; 781 struct statfs fss;
858 if ( !statfs( path.latin1(), &fss ) ) { 782 if ( !statfs( path.latin1(), &fss ) )
783 {
859 int blkSize = fss.f_bsize; 784 int blkSize = fss.f_bsize;
860// int totalBlks = fs.f_blocks; 785// int totalBlks = fs.f_blocks;
861 int availBlks = fss.f_bavail; 786 int availBlks = fss.f_bavail;
862 787
863 long mult = blkSize / 1024; 788 long mult = blkSize / 1024;
864 long div = 1024 / blkSize; 789 long div = 1024 / blkSize;
@@ -868,217 +793,210 @@ QString AdvancedFm::checkDiskSpace(const QString &path) {
868 793
869 return QString::number(availBlks * mult / div); 794 return QString::number(availBlks * mult / div);
870 } 795 }
871 return ""; 796 return "";
872} 797}
873 798
874void AdvancedFm::addToDocs() { 799void AdvancedFm::addToDocs()
875 QStringList strListPaths = getPath(); 800{
876 if( strListPaths.count() > 0) { 801 QStringList strListPaths = getPath();
877 QString curFile; 802 QDir *thisDir = CurrentDir();
878 if (TabWidget->getCurrentTab() == 0) { 803
879// if (TabWidget->currentPageIndex() == 0) { 804 if( strListPaths.count() > 0)
880 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 805 {
881 curFile = currentDir.canonicalPath()+"/"+(*it); 806 QString curFile;
882// qDebug(curFile); 807 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it )
883 DocLnk f; 808 {
884// curFile.replace(QRegExp("\\..*"),""); 809 curFile = thisDir->canonicalPath()+"/"+(*it);
885 f.setName((*it));
886 f.setFile( curFile);
887 f.writeLink();
888 }
889 } else {
890 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
891 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
892// qDebug(curFile); 810// qDebug(curFile);
893 811 DocLnk f;
894 DocLnk f;
895// curFile.replace(QRegExp("\\..*"),""); 812// curFile.replace(QRegExp("\\..*"),"");
896 f.setName((*it)); 813 f.setName((*it));
897 f.setFile( curFile); 814 f.setFile( curFile);
898 f.writeLink(); 815 f.writeLink();
899 } 816 }
900 } 817 }
901 }
902} 818}
903 819
904 820
905void AdvancedFm::customDirsToMenu() 821void AdvancedFm::customDirsToMenu()
906{ 822{
907
908 Config cfg("AdvancedFm");
909 cfg.setGroup("Menu");
910 823
911 QStringList list = cfg.readListEntry( "CustomDir", ','); 824 Config cfg("AdvancedFm");
912 menuButton->insertItems(list ); 825 cfg.setGroup("Menu");
826
827 QStringList list = cfg.readListEntry( "CustomDir", ',');
828 menuButton->insertItems(list );
913 829
914// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 830// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
915// { 831// {
916// customDirMenu->insertItem(*it ); 832// customDirMenu->insertItem(*it );
917// } 833// }
918} 834}
919 835
920void AdvancedFm::dirMenuSelected(int item) 836void AdvancedFm::dirMenuSelected(int item)
921{ 837{
922 qDebug("menu item %d", item); 838 qDebug("menu item %d", item);
923 switch(item) 839 switch(item)
924 { 840 {
925 841
926 case -21: 842 case -21:
927 case 0: 843 case 0:
928 addCustomDir(); 844 addCustomDir();
929 break; 845 break;
930 case -22: 846 case -22:
931 case 1: 847 case 1:
932 removeCustomDir(); 848 removeCustomDir();
933 break; 849 break;
934 default: 850 default:
935 { 851 {
936// gotoCustomDir( menuButton->text(item)); 852// gotoCustomDir( menuButton->text(item));
937// gotoCustomDir( customDirMenu->text(item)); 853// gotoCustomDir( customDirMenu->text(item));
938 } 854 }
939 break; 855 break;
940 856
941 }; 857 };
942} 858}
943 859
944void AdvancedFm::addCustomDir() 860void AdvancedFm::addCustomDir()
945{ 861{
946 Config cfg("AdvancedFm"); 862 Config cfg("AdvancedFm");
947 cfg.setGroup("Menu"); 863 cfg.setGroup("Menu");
948 QString dir; 864 QString dir;
949 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 865 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
950 866
951 if (TabWidget->getCurrentTab() == 0) 867 dir = CurrentDir()->canonicalPath();
952 { 868
953 dir = currentDir.canonicalPath(); 869 bool addIt=true;
954 } 870 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
955 else 871 {
956 { 872 if( dir == (*it))
957 dir = currentRemoteDir.canonicalPath(); 873 {
958 } 874 addIt=false;
959 875 }
960 bool addIt=true; 876 }
961 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 877 if(addIt)
962 { 878 {
963 if( dir == (*it)) 879 menuButton->insertItem(dir);
964 {
965 addIt=false;
966 }
967 }
968 if(addIt)
969 {
970 menuButton->insertItem(dir);
971// customDirMenu->insertItem(dir); 880// customDirMenu->insertItem(dir);
972 list << dir; 881 list << dir;
973 } 882 }
974 883
975 cfg.writeEntry("CustomDir", list, ','); 884 cfg.writeEntry("CustomDir", list, ',');
976 cfg.write(); 885 cfg.write();
977} 886}
978 887
979void AdvancedFm::removeCustomDir() 888void AdvancedFm::removeCustomDir()
980{ 889{
981// qDebug("remove custom dir"); 890// qDebug("remove custom dir");
982 Config cfg("AdvancedFm"); 891 Config cfg("AdvancedFm");
983 cfg.setGroup("Menu"); 892 cfg.setGroup("Menu");
984 QString dir; 893 QString dir;
985 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 894 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
986 QStringList list2; 895 QStringList list2;
987 896 dir = CurrentDir()->canonicalPath();
988 if (TabWidget->getCurrentTab() == 0)
989 {
990 dir = currentDir.canonicalPath();
991 }
992 else
993 {
994 dir = currentRemoteDir.canonicalPath();
995 }
996 int ramble=2; 897 int ramble=2;
997// int ramble=-24; 898// int ramble=-24;
998//first remove list 899//first remove list
999 if(list.grep(dir,true).isEmpty()) 900 if(list.grep(dir,true).isEmpty())
1000 { 901 {
1001 QMessageBox::message("AdvancedFm",tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); 902 QMessageBox::message("AdvancedFm",tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!"));
1002 } 903 }
1003 else 904 else
1004 { 905 {
1005 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 906 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
1006 { 907 {
1007 if((*it) != dir)//current item is not our current dir, so add it to temp list 908 if((*it) != dir)//current item is not our current dir, so add it to temp list
1008 { 909 {
1009 list2 <<(*it); 910 list2 <<(*it);
1010 } 911 }
1011 else 912 else
1012 { 913 {
1013// customDirMenu->removeItem( ramble); 914// customDirMenu->removeItem( ramble);
1014 menuButton->remove( ramble); 915 menuButton->remove( ramble);
1015 916
1016 } 917 }
1017 ramble++; 918 ramble++;
1018// ramble--; 919// ramble--;
1019 } 920 }
1020 921
1021 cfg.writeEntry("CustomDir", list2, ','); 922 cfg.writeEntry("CustomDir", list2, ',');
1022 cfg.write(); 923 cfg.write();
1023 } 924 }
1024// customDirsToMenu(); 925// customDirsToMenu();
1025 926
1026} 927}
1027 928
1028void AdvancedFm::gotoCustomDir(const QString &dir) 929void AdvancedFm::gotoCustomDir(const QString &dir)
1029{ 930{
1030// qDebug("gotoCustomDir(const QString &dir) " +dir ); 931// qDebug("gotoCustomDir(const QString &dir) " +dir );
1031 QString curDir = dir; 932 QString curDir = dir;
933 QDir *thisDir = CurrentDir();
1032// if( curDir.isEmpty()) { 934// if( curDir.isEmpty()) {
1033// } 935// }
1034 if( curDir == s_addBookmark) 936 if( curDir == s_addBookmark)
1035 { 937 {
1036 addCustomDir(); 938 addCustomDir();
1037 } 939 }
1038 if( curDir == s_removeBookmark) 940 if( curDir == s_removeBookmark)
1039 { 941 {
1040 removeCustomDir( ); 942 removeCustomDir( );
1041 } 943 }
1042 else 944 else
1043 { 945 {
1044 if(QDir( curDir).exists() ) 946 if(QDir( curDir).exists() )
1045 { 947 {
1046 if (TabWidget->getCurrentTab() == 0) 948 thisDir->setPath( curDir );
1047 { 949 chdir( curDir.latin1() );
1048 currentDir.setPath( curDir ); 950 thisDir->cd( curDir, TRUE);
1049 chdir( curDir.latin1() ); 951 PopulateView();
1050 currentDir.cd( curDir, TRUE); 952 }
1051 populateLocalView(); 953 }
1052 } 954}
1053 else 955
1054 { 956QDir *AdvancedFm::CurrentDir()
1055 currentRemoteDir.setPath( curDir ); 957{
1056 chdir( curDir.latin1() ); 958 if ( whichTab == 1)
1057 currentRemoteDir.cd( curDir, TRUE); 959 {
1058 populateRemoteView(); 960 return &currentDir;
1059 } 961 }
1060 } 962 else
1061 } 963 {
1062// menuButton 964 return &currentRemoteDir;
1063// qDebug("gotoCustomDir(const QString &dir) " +dir ); 965 }
1064// QString curDir = dir; 966}
1065// if(QDir( curDir).exists() ) 967
1066// { 968QDir *AdvancedFm::OtherDir()
1067// if (TabWidget->getCurrentTab() == 0) 969{
1068// { 970 if ( whichTab == 1)
1069// currentDir.setPath( curDir ); 971 {
1070// chdir( curDir.latin1() ); 972 return &currentRemoteDir;
1071// currentDir.cd( curDir, TRUE); 973 }
1072// populateLocalView(); 974 else
1073// } 975 {
1074// else 976 return &currentDir;
1075// { 977 }
1076// currentRemoteDir.setPath( curDir ); 978}
1077// chdir( curDir.latin1() ); 979
1078// currentRemoteDir.cd( curDir, TRUE); 980void AdvancedFm::PopulateView()
1079// populateRemoteView(); 981{
1080// } 982 if ( whichTab == 1)
1081// } 983 populateLocalView();
1082// menuButton->setLabel(" "); 984 else
1083// menuButton 985 populateRemoteView();
986}
987
988QListView * AdvancedFm::CurrentView()
989{
990 if ( whichTab == 1)
991 return Local_View;
992 else
993 return Remote_View;
994}
995
996QListView * AdvancedFm::OtherView()
997{
998 if ( whichTab == 1)
999 return Remote_View;
1000 else
1001 return Local_View;
1084} 1002}