summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-23 13:38:57 (UTC)
committer llornkcor <llornkcor>2002-09-23 13:38:57 (UTC)
commit7c3194a651beca5ba43bc29d87cc96b55761b7bc (patch) (unidiff)
treec2860d2c826b62ce6737681ac43c78197448931b
parentcfeb1373faa2b46011ecdb294d0ce4e557ea988f (diff)
downloadopie-7c3194a651beca5ba43bc29d87cc96b55761b7bc.zip
opie-7c3194a651beca5ba43bc29d87cc96b55761b7bc.tar.gz
opie-7c3194a651beca5ba43bc29d87cc96b55761b7bc.tar.bz2
start changing things around
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp413
-rw-r--r--noncore/apps/advancedfm/advancedfm.h8
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro2
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp236
4 files changed, 337 insertions, 322 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index c054465..8f49a53 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,963 +1,743 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties 13#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties
14 14
15#include "advancedfm.h" 15#include "advancedfm.h"
16#include "inputDialog.h" 16#include "inputDialog.h"
17#include "filePermissions.h" 17#include "filePermissions.h"
18#include "output.h" 18#include "output.h"
19 19
20// #include <opie/ofileselector.h> 20// #include <opie/ofileselector.h>
21// #include <opie/ofiledialog.h> 21// #include <opie/ofiledialog.h>
22 22
23
24#include <qpe/lnkproperties.h> 23#include <qpe/lnkproperties.h>
25#include <qpe/filemanager.h> 24#include <qpe/filemanager.h>
26#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
27#include <qpe/qpemenubar.h> 26#include <qpe/qpemenubar.h>
28#include <qpe/qpetoolbar.h> 27#include <qpe/qpetoolbar.h>
29#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
30#include <qpe/resource.h>
31#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
32#include <qpe/config.h> 30#include <qpe/config.h>
33#include <qpe/mimetype.h> 31#include <qpe/mimetype.h>
34#include <qpe/applnk.h> 32#include <qpe/applnk.h>
35#include <qpe/ir.h> 33#include <qpe/ir.h>
34#include <qpe/resource.h>
36 35
37//#include <opie/ofileselector.h> 36//#include <opie/ofileselector.h>
38#include <qmultilineedit.h> 37#include <qmultilineedit.h>
39 38
39#include <qtabwidget.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qtoolbutton.h>
43#include <qdatetime.h> 42#include <qdatetime.h>
44#include <qdir.h> 43#include <qdir.h>
45#include <qfile.h> 44#include <qfile.h>
46#include <qstring.h> 45#include <qstring.h>
47#include <qcombobox.h> 46#include <qcombobox.h>
48#include <qpopupmenu.h> 47#include <qpopupmenu.h>
49#include <qlistview.h> 48#include <qlistview.h>
50#include <qmainwindow.h> 49#include <qmainwindow.h>
51#include <qlabel.h> 50#include <qlabel.h>
52#include <qprogressbar.h> 51#include <qprogressbar.h>
53#include <qspinbox.h> 52#include <qspinbox.h>
54#include <qtabwidget.h>
55#include <qwidget.h> 53#include <qwidget.h>
56#include <qlayout.h> 54#include <qlayout.h>
57#include <qimage.h> 55#include <qimage.h>
58#include <qpixmap.h> 56#include <qpixmap.h>
59#include <qmessagebox.h> 57#include <qmessagebox.h>
60#include <qlineedit.h> 58#include <qlineedit.h>
61#include <qregexp.h> 59#include <qregexp.h>
62 60
63#include <unistd.h> 61#include <unistd.h>
64#include <stdlib.h> 62#include <stdlib.h>
65#include <sys/stat.h> 63#include <sys/stat.h>
66#include <dirent.h> 64#include <dirent.h>
67#include <stdio.h> 65#include <stdio.h>
68#include <time.h> 66#include <time.h>
69#include <fcntl.h> 67#include <fcntl.h>
70#include <mntent.h> 68#include <mntent.h>
71#include <string.h> 69#include <string.h>
72#include <errno.h> 70#include <errno.h>
73#include <sys/vfs.h> 71#include <sys/vfs.h>
74#include <mntent.h> 72#include <mntent.h>
75#include <sys/utsname.h> 73#include <sys/utsname.h>
76 74
77AdvancedFm::AdvancedFm( ) 75AdvancedFm::AdvancedFm( )
78 : QMainWindow( ) 76 : QMainWindow( ) {
79{ 77 init();
80 setCaption( tr( "AdvancedFm" ) );
81
82 QGridLayout *layout = new QGridLayout( this );
83 layout->setSpacing( 2);
84 layout->setMargin( 2);
85
86 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
87
88 QPEMenuBar *menuBar = new QPEMenuBar(this);
89 fileMenu = new QPopupMenu( this );
90 viewMenu = new QPopupMenu( this );
91
92 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 );
93
94 menuBar->insertItem( tr( "File" ), fileMenu);
95 menuBar->insertItem( tr( "View" ), viewMenu);
96
97 qpeDirButton= new QToolButton(this,"QPEButton");
98 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton");
99 qpeDirButton ->setFixedSize( QSize( 20, 20 ) );
100 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) );
101 layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2);
102
103 cfButton = new QToolButton( this,"CFButton");
104 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia"));
105 cfButton ->setFixedSize( QSize( 20, 20 ) );
106 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) );
107 layout->addMultiCellWidget( cfButton , 0, 0, 3, 3);
108
109 sdButton = new QToolButton( this,"SDButton");
110 sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard"));
111 sdButton->setFixedSize( QSize( 20, 20 ) );
112 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) );
113 layout->addMultiCellWidget( sdButton , 0, 0, 4, 4);
114
115 cdUpButton = new QToolButton( this,"cdUpButton");
116 cdUpButton->setPixmap(Resource::loadPixmap("up"));
117 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
118 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
119 layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5);
120
121 docButton = new QToolButton( this,"docsButton");
122 docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
123 docButton->setFixedSize( QSize( 20, 20 ) );
124 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
125 layout->addMultiCellWidget( docButton, 0, 0, 6, 6);
126
127 homeButton = new QToolButton( this,"homeButton");
128 homeButton->setPixmap(Resource::loadPixmap("home"));
129 homeButton->setFixedSize( QSize( 20, 20 ) );
130 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
131 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7);
132
133 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
134 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
135 fileMenu->insertSeparator();
136 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ));
137 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ));
138 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
139 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
140 fileMenu->insertSeparator();
141 fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
142 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
143 fileMenu->setCheckable(TRUE);
144
145 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
146 viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
147 viewMenu->insertSeparator();
148 viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
149 viewMenu->setCheckable(TRUE);
150
151
152 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
153 currentPathCombo->setEditable(TRUE);
154 layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7);
155 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
156
157 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
158 this, SLOT( currentPathComboActivated( const QString & ) ) );
159
160 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
161 this,SLOT(currentPathComboChanged()));
162
163 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
164
165 layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7);
166
167
168 TabWidget = new QTabWidget( this, "TabWidget" );
169 layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7);
170
171 tab = new QWidget( TabWidget, "tab" );
172 tabLayout = new QGridLayout( tab );
173 tabLayout->setSpacing( 2);
174 tabLayout->setMargin( 2);
175
176 Local_View = new QListView( tab, "Local_View" );
177 Local_View->addColumn( tr("File"),130);
178 Local_View->addColumn( tr("Size"),-1);
179 Local_View->setColumnAlignment(1,QListView::AlignRight);
180 Local_View->addColumn( tr("Date"),-1);
181 Local_View->setColumnAlignment(2,QListView::AlignRight);
182 Local_View->setAllColumnsShowFocus(TRUE);
183 Local_View->setMultiSelection( TRUE );
184 Local_View->setSelectionMode(QListView::Extended);
185
186 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
187
188 tabLayout->addWidget( Local_View, 0, 0 );
189
190 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
191 this,SLOT( localListClicked(QListViewItem *)) );
192 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
193 this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) );
194
195 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
196
197 TabWidget->insertTab( tab, tr("1"));
198
199 tab_2 = new QWidget( TabWidget, "tab_2" );
200 tabLayout_2 = new QGridLayout( tab_2 );
201 tabLayout_2->setSpacing( 2);
202 tabLayout_2->setMargin( 2);
203
204 Remote_View = new QListView( tab_2, "Remote_View" );
205 Remote_View->addColumn( tr("File"),130);
206 Remote_View->addColumn( tr("Size"),-1);
207 Remote_View->setColumnAlignment(1,QListView::AlignRight);
208 Remote_View->addColumn( tr("Date"),-1);
209 Remote_View->setColumnAlignment(2,QListView::AlignRight);
210 Remote_View->setAllColumnsShowFocus(TRUE);
211 Remote_View->setMultiSelection( TRUE );
212 Remote_View->setSelectionMode(QListView::Extended);
213
214
215 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
216
217 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
218 this,SLOT( remoteListClicked(QListViewItem *)) );
219 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
220 this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) );
221
222 tabLayout_2->addWidget( Remote_View, 0, 0 );
223
224
225 TabWidget->insertTab( tab_2, tr( "2"));
226
227 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
228 this,SLOT(tabChanged(QWidget*)));
229
230 /* tab_3 = new QWidget( TabWidget, "tab_3" );
231 tabLayout_3 = new QGridLayout( tab_3 );
232 tabLayout_3->setSpacing( 2);
233 tabLayout_3->setMargin( 2);
234
235
236 // OFileDialog fileDialog;
237 // fileDialog;
238 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
239 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
240 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");
241
242 QListView *fileTree;
243 fileTree = new QListView( tab_3, "tree" );
244
245
246 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
247
248 TabWidget->insertTab( tab_3, tr( "Remote" ) );
249 */
250
251 ///////////////
252
253 struct utsname name; /* check for embedix kernel running on the zaurus*/
254 if (uname(&name) != -1) {
255 QString release=name.release;
256 if(release.find("embedix",0,TRUE) !=-1) {
257 zaurusDevice=TRUE;
258 } else {
259 zaurusDevice=FALSE;
260 sdButton->hide();
261 }
262 }
263
264 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
265 currentDir.setPath( QDir::currentDirPath());
266
267 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
268 currentRemoteDir.setPath( QDir::currentDirPath());
269
270 b = TRUE;
271
272 filterStr="*";
273 b=FALSE;
274
275 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
276 78
277 populateLocalView(); 79 populateLocalView();
278 populateRemoteView(); 80 populateRemoteView();
279 currentPathCombo->setFocus(); 81 currentPathCombo->setFocus();
280} 82}
281 83
282AdvancedFm::~AdvancedFm() 84AdvancedFm::~AdvancedFm() {
283{
284} 85}
285 86
286void AdvancedFm::cleanUp() 87void AdvancedFm::cleanUp() {
287{
288 QString sfile=QDir::homeDirPath(); 88 QString sfile=QDir::homeDirPath();
289 if(sfile.right(1) != "/") 89 if(sfile.right(1) != "/")
290 sfile+="/._temp"; 90 sfile+="/._temp";
291 else 91 else
292 sfile+="._temp"; 92 sfile+="._temp";
293 QFile file( sfile); 93 QFile file( sfile);
294 if(file.exists()) 94 if(file.exists())
295 file.remove(); 95 file.remove();
296} 96}
297 97
298void AdvancedFm::tabChanged(QWidget *) 98void AdvancedFm::tabChanged(QWidget *) {
299{
300 if (TabWidget->currentPageIndex() == 0) { 99 if (TabWidget->currentPageIndex() == 0) {
301 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 100 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
302 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 101 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
303 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 102 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
304 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 103 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
305 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 104 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
306 105
307 } 106 }
308 if (TabWidget->currentPageIndex() == 1) { 107 if (TabWidget->currentPageIndex() == 1) {
309 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 108 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
310 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 109 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
311 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 110 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
312 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 111 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
313 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 112 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
314 } 113 }
315} 114}
316 115
317 116
318void AdvancedFm::populateLocalView() 117void AdvancedFm::populateLocalView() {
319{
320 QPixmap pm; 118 QPixmap pm;
321 Local_View->clear(); 119 Local_View->clear();
322 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 120 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
323 currentDir.setMatchAllDirs(TRUE); 121 currentDir.setMatchAllDirs(TRUE);
324 currentDir.setNameFilter(filterStr); 122 currentDir.setNameFilter(filterStr);
325 QString fileL, fileS, fileDate; 123 QString fileL, fileS, fileDate;
326 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 124 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
327 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 125 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
328 bool isDir=FALSE; 126 bool isDir=FALSE;
329 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 127 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
330 QFileInfoListIterator it(*list); 128 QFileInfoListIterator it(*list);
331 QFileInfo *fi; 129 QFileInfo *fi;
332 while ( (fi=it.current()) ) { 130 while ( (fi=it.current()) ) {
333 if (fi->isSymLink() ) { 131 if (fi->isSymLink() ) {
334 QString symLink=fi->readLink(); 132 QString symLink=fi->readLink();
335 QFileInfo sym( symLink); 133 QFileInfo sym( symLink);
336 fileS.sprintf( "%10i", sym.size() ); 134 fileS.sprintf( "%10i", sym.size() );
337 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 135 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
338 fileDate = sym.lastModified().toString(); 136 fileDate = sym.lastModified().toString();
339 } else { 137 } else {
340 fileS.sprintf( "%10i", fi->size() ); 138 fileS.sprintf( "%10i", fi->size() );
341 fileL.sprintf( "%s",fi->fileName().data() ); 139 fileL.sprintf( "%s",fi->fileName().data() );
342 fileDate= fi->lastModified().toString(); 140 fileDate= fi->lastModified().toString();
343 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 141 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
344 fileL+="/"; 142 fileL+="/";
345 isDir=TRUE; 143 isDir=TRUE;
346 } 144 }
347 } 145 }
348 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 146 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
349 if(fileL !="./" && fi->exists()) { 147 if(fileL !="./" && fi->exists()) {
350 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 148 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
351 149
352 if(isDir || fileL.find("/",0,TRUE) != -1) { 150 if(isDir || fileL.find("/",0,TRUE) != -1) {
353 151
354 if( !QDir( fi->filePath() ).isReadable()) //is directory 152 if( !QDir( fi->filePath() ).isReadable()) //is directory
355 pm = Resource::loadPixmap( "lockedfolder" ); 153 pm = Resource::loadPixmap( "lockedfolder" );
356 else 154 else
357 pm= Resource::loadPixmap( "folder" ); 155 pm= Resource::loadPixmap( "folder" );
358 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 156 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
359 pm = Resource::loadPixmap( "exec"); 157 pm = Resource::loadPixmap( "exec");
360 } else if( (fileInfo.permission( QFileInfo::ExeUser) 158 } else if( (fileInfo.permission( QFileInfo::ExeUser)
361 | fileInfo.permission( QFileInfo::ExeGroup) 159 | fileInfo.permission( QFileInfo::ExeGroup)
362 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 160 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
363 pm = Resource::loadPixmap( "exec"); 161 pm = Resource::loadPixmap( "exec");
364 } else if( !fi->isReadable() ) { 162 } else if( !fi->isReadable() ) {
365 pm = Resource::loadPixmap( "locked" ); 163 pm = Resource::loadPixmap( "locked" );
366 } else { //everything else goes by mimetype 164 } else { //everything else goes by mimetype
367 MimeType mt(fi->filePath()); 165 MimeType mt(fi->filePath());
368 pm=mt.pixmap(); //sets the correct pixmap for mimetype 166 pm=mt.pixmap(); //sets the correct pixmap for mimetype
369 if(pm.isNull()) 167 if(pm.isNull())
370 pm = Resource::loadPixmap( "UnknownDocument-14" ); 168 pm = Resource::loadPixmap( "UnknownDocument-14" );
371 } 169 }
372 item->setPixmap( 0,pm); 170 item->setPixmap( 0,pm);
373 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 171 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
374 // overlay link image 172 // overlay link image
375 pm= Resource::loadPixmap( "folder" ); 173 pm= Resource::loadPixmap( "folder" );
376 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 174 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
377 QPainter painter( &pm ); 175 QPainter painter( &pm );
378 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 176 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
379 pm.setMask( pm.createHeuristicMask( FALSE ) ); 177 pm.setMask( pm.createHeuristicMask( FALSE ) );
380 item->setPixmap( 0, pm); 178 item->setPixmap( 0, pm);
381 } 179 }
382 } 180 }
383 isDir=FALSE; 181 isDir=FALSE;
384 ++it; 182 ++it;
385 } 183 }
386 184
387 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 185 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
388 struct stat buf; 186 struct stat buf;
389 dev_t devT; 187 dev_t devT;
390 DIR *dir; 188 DIR *dir;
391 struct dirent *mydirent; 189 struct dirent *mydirent;
392 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 190 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
393 while ((mydirent = readdir(dir)) != NULL) { 191 while ((mydirent = readdir(dir)) != NULL) {
394 lstat( mydirent->d_name, &buf); 192 lstat( mydirent->d_name, &buf);
395 qDebug(mydirent->d_name); 193 qDebug(mydirent->d_name);
396 fileL.sprintf("%s", mydirent->d_name); 194 fileL.sprintf("%s", mydirent->d_name);
397 devT = buf.st_dev; 195 devT = buf.st_dev;
398 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 196 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
399 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 197 fileDate.sprintf("%s", ctime( &buf.st_mtime));
400 if( fileL.find(".") == -1 ){ 198 if( fileL.find(".") == -1 ){
401 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 199 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
402 pm = Resource::loadPixmap( "UnknownDocument-14" ); 200 pm = Resource::loadPixmap( "UnknownDocument-14" );
403 item->setPixmap( 0,pm); 201 item->setPixmap( 0,pm);
404 } 202 }
405 } 203 }
406 204
407 closedir(dir); 205 closedir(dir);
408 } 206 }
409 207
410 Local_View->setSorting( 3,FALSE); 208 Local_View->setSorting( 3,FALSE);
411 fillCombo( (const QString &) currentDir.canonicalPath()); 209 fillCombo( (const QString &) currentDir.canonicalPath());
412} 210}
413 211
414 212
415void AdvancedFm::populateRemoteView() 213void AdvancedFm::populateRemoteView() {
416{
417 QPixmap pm; 214 QPixmap pm;
418 Remote_View->clear(); 215 Remote_View->clear();
419 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 216 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
420 currentRemoteDir.setMatchAllDirs(TRUE); 217 currentRemoteDir.setMatchAllDirs(TRUE);
421 currentRemoteDir.setNameFilter(filterStr); 218 currentRemoteDir.setNameFilter(filterStr);
422 QString fileL, fileS, fileDate; 219 QString fileL, fileS, fileDate;
423 220
424 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 221 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
425 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 222 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
426 bool isDir=FALSE; 223 bool isDir=FALSE;
427 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 224 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
428 QFileInfoListIterator it(*list); 225 QFileInfoListIterator it(*list);
429 QFileInfo *fi; 226 QFileInfo *fi;
430 while ( (fi=it.current()) ) { 227 while ( (fi=it.current()) ) {
431 if (fi->isSymLink() ){ 228 if (fi->isSymLink() ){
432 QString symLink=fi->readLink(); 229 QString symLink=fi->readLink();
433 // qDebug("Symlink detected "+symLink); 230 // qDebug("Symlink detected "+symLink);
434 QFileInfo sym( symLink); 231 QFileInfo sym( symLink);
435 fileS.sprintf( "%10i", sym.size() ); 232 fileS.sprintf( "%10i", sym.size() );
436 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 233 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
437 fileDate = sym.lastModified().toString(); 234 fileDate = sym.lastModified().toString();
438 } else { 235 } else {
439 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 236 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
440 fileS.sprintf( "%10i", fi->size() ); 237 fileS.sprintf( "%10i", fi->size() );
441 fileL.sprintf( "%s",fi->fileName().data() ); 238 fileL.sprintf( "%s",fi->fileName().data() );
442 fileDate= fi->lastModified().toString(); 239 fileDate= fi->lastModified().toString();
443 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 240 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
444 fileL+="/"; 241 fileL+="/";
445 isDir=TRUE; 242 isDir=TRUE;
446 // qDebug( fileL); 243 // qDebug( fileL);
447 } 244 }
448 } 245 }
449 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 246 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
450 if(fileL !="./" && fi->exists()) { 247 if(fileL !="./" && fi->exists()) {
451 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 248 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
452 QPixmap pm; 249 QPixmap pm;
453 250
454 if(isDir || fileL.find("/",0,TRUE) != -1) { 251 if(isDir || fileL.find("/",0,TRUE) != -1) {
455 if( !QDir( fi->filePath() ).isReadable()) 252 if( !QDir( fi->filePath() ).isReadable())
456 pm = Resource::loadPixmap( "lockedfolder" ); 253 pm = Resource::loadPixmap( "lockedfolder" );
457 else 254 else
458 pm= Resource::loadPixmap( "folder" ); 255 pm= Resource::loadPixmap( "folder" );
459 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 256 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
460 pm = Resource::loadPixmap( "exec"); 257 pm = Resource::loadPixmap( "exec");
461 } else if( (fileInfo.permission( QFileInfo::ExeUser) 258 } else if( (fileInfo.permission( QFileInfo::ExeUser)
462 | fileInfo.permission( QFileInfo::ExeGroup) 259 | fileInfo.permission( QFileInfo::ExeGroup)
463 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 260 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
464 pm = Resource::loadPixmap( "exec"); 261 pm = Resource::loadPixmap( "exec");
465 } else if( !fi->isReadable() ) { 262 } else if( !fi->isReadable() ) {
466 pm = Resource::loadPixmap( "locked" ); 263 pm = Resource::loadPixmap( "locked" );
467 } else { 264 } else {
468 MimeType mt(fi->filePath()); 265 MimeType mt(fi->filePath());
469 pm=mt.pixmap(); //sets the correct pixmap for mimetype 266 pm=mt.pixmap(); //sets the correct pixmap for mimetype
470 if(pm.isNull()) 267 if(pm.isNull())
471 pm = Resource::loadPixmap( "UnknownDocument-14" ); 268 pm = Resource::loadPixmap( "UnknownDocument-14" );
472 } 269 }
473 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 270 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
474 // overlay link image 271 // overlay link image
475 pm= Resource::loadPixmap( "folder" ); 272 pm= Resource::loadPixmap( "folder" );
476 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 273 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
477 QPainter painter( &pm ); 274 QPainter painter( &pm );
478 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 275 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
479 pm.setMask( pm.createHeuristicMask( FALSE ) ); 276 pm.setMask( pm.createHeuristicMask( FALSE ) );
480 } 277 }
481 item->setPixmap( 0, pm); 278 item->setPixmap( 0, pm);
482 } 279 }
483 isDir=FALSE; 280 isDir=FALSE;
484 ++it; 281 ++it;
485 } 282 }
486 283
487 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 284 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
488 struct stat buf; 285 struct stat buf;
489 DIR *dir; 286 DIR *dir;
490 struct dirent *mydirent; 287 struct dirent *mydirent;
491 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 288 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
492 while ((mydirent = readdir(dir)) != NULL) { 289 while ((mydirent = readdir(dir)) != NULL) {
493 lstat( mydirent->d_name, &buf); 290 lstat( mydirent->d_name, &buf);
494 qDebug(mydirent->d_name); 291 qDebug(mydirent->d_name);
495 fileL.sprintf("%s", mydirent->d_name); 292 fileL.sprintf("%s", mydirent->d_name);
496 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 293 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
497 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 294 fileDate.sprintf("%s", ctime( &buf.st_mtime));
498 if( fileL.find(".") == -1 ){ 295 if( fileL.find(".") == -1 ){
499 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 296 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
500 pm = Resource::loadPixmap( "UnknownDocument-14" ); 297 pm = Resource::loadPixmap( "UnknownDocument-14" );
501 item->setPixmap( 0,pm); 298 item->setPixmap( 0,pm);
502 } 299 }
503 } 300 }
504 301
505 closedir(dir); 302 closedir(dir);
506 } 303 }
507 304
508 Remote_View->setSorting( 3,FALSE); 305 Remote_View->setSorting( 3,FALSE);
509 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 306 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
510} 307}
511 308
512void AdvancedFm::localListClicked(QListViewItem *selectedItem) 309void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
513{
514 if(selectedItem) { 310 if(selectedItem) {
515 QString strItem=selectedItem->text(0); 311 QString strItem=selectedItem->text(0);
516 QString strSize=selectedItem->text(1); 312 QString strSize=selectedItem->text(1);
517 strSize=strSize.stripWhiteSpace(); 313 strSize=strSize.stripWhiteSpace();
518 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 314 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
519 // is symlink 315 // is symlink
520 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 316 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
521 if(QDir(strItem2).exists() ) { 317 if(QDir(strItem2).exists() ) {
522 currentDir.cd(strItem2, TRUE); 318 currentDir.cd(strItem2, TRUE);
523 populateLocalView(); 319 populateLocalView();
524 } 320 }
525 } else { // not a symlink 321 } else { // not a symlink
526 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 322 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
527 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 323 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
528 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 324 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
529 currentDir.cd(strItem,FALSE); 325 currentDir.cd(strItem,FALSE);
530 populateLocalView(); 326 populateLocalView();
531 } else { 327 } else {
532 currentDir.cdUp(); 328 currentDir.cdUp();
533 populateLocalView(); 329 populateLocalView();
534 } 330 }
535 if(QDir(strItem).exists()){ 331 if(QDir(strItem).exists()){
536 currentDir.cd(strItem, TRUE); 332 currentDir.cd(strItem, TRUE);
537 populateLocalView(); 333 populateLocalView();
538 } 334 }
539 } else { 335 } else {
540 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 336 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
541 if( QFile::exists(strItem ) ) { 337 if( QFile::exists(strItem ) ) {
542 // qDebug("clicked item "+strItem); 338 // qDebug("clicked item "+strItem);
543 // DocLnk doc( strItem, FALSE ); 339 // DocLnk doc( strItem, FALSE );
544 // doc.execute(); 340 // doc.execute();
545 // Local_View->clearSelection(); 341 // Local_View->clearSelection();
546 } 342 }
547 } //end not symlink 343 } //end not symlink
548 chdir(strItem.latin1()); 344 chdir(strItem.latin1());
549 } 345 }
550 } 346 }
551} 347}
552 348
553void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) 349void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
554{ 350
555 if(selectedItem) { 351 if(selectedItem) {
556 QString strItem=selectedItem->text(0); 352 QString strItem=selectedItem->text(0);
557 QString strSize=selectedItem->text(1); 353 QString strSize=selectedItem->text(1);
558 strSize=strSize.stripWhiteSpace(); 354 strSize=strSize.stripWhiteSpace();
559 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 355 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
560 // is symlink 356 // is symlink
561 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 357 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
562 if(QDir(strItem2).exists() ) { 358 if(QDir(strItem2).exists() ) {
563 currentRemoteDir.cd(strItem2, TRUE); 359 currentRemoteDir.cd(strItem2, TRUE);
564 populateRemoteView(); 360 populateRemoteView();
565 } 361 }
566 } else { // not a symlink 362 } else { // not a symlink
567 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 363 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
568 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 364 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
569 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 365 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
570 currentRemoteDir.cd(strItem,FALSE); 366 currentRemoteDir.cd(strItem,FALSE);
571 populateRemoteView(); 367 populateRemoteView();
572 } else { 368 } else {
573 currentRemoteDir.cdUp(); 369 currentRemoteDir.cdUp();
574 populateRemoteView(); 370 populateRemoteView();
575 } 371 }
576 if(QDir(strItem).exists()){ 372 if(QDir(strItem).exists()){
577 currentRemoteDir.cd(strItem, TRUE); 373 currentRemoteDir.cd(strItem, TRUE);
578 populateRemoteView(); 374 populateRemoteView();
579 } 375 }
580 } else { 376 } else {
581 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 377 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
582 if( QFile::exists(strItem ) ) { 378 if( QFile::exists(strItem ) ) {
583 // qDebug("clicked item "+strItem); 379 // qDebug("clicked item "+strItem);
584 // DocLnk doc( strItem, FALSE ); 380 // DocLnk doc( strItem, FALSE );
585 // doc.execute(); 381 // doc.execute();
586 // Remote_View->clearSelection(); 382 // Remote_View->clearSelection();
587 } 383 }
588 } //end not symlink 384 } //end not symlink
589 chdir(strItem.latin1()); 385 chdir(strItem.latin1());
590 } 386 }
591 } 387 }
592} 388}
593 389
594void AdvancedFm::doLocalCd() 390void AdvancedFm::doLocalCd() {
595{
596 localListClicked( Local_View->currentItem()); 391 localListClicked( Local_View->currentItem());
597} 392}
598 393
599void AdvancedFm::doRemoteCd() 394void AdvancedFm::doRemoteCd() {
600{
601 localListClicked( Remote_View->currentItem()); 395 localListClicked( Remote_View->currentItem());
602} 396}
603 397
604void AdvancedFm::showHidden() 398void AdvancedFm::showHidden() {
605{
606 if (b) { 399 if (b) {
607 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 400 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
608 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 401 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
609 b=FALSE; 402 b=FALSE;
610 403
611 } else { 404 } else {
612 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 405 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
613 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 406 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
614 b=TRUE; 407 b=TRUE;
615 } 408 }
616 populateLocalView(); 409 populateLocalView();
617 410
618} 411}
619 412
620void AdvancedFm::showRemoteHidden() 413void AdvancedFm::showRemoteHidden() {
621{
622 if (b) { 414 if (b) {
623 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 415 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
624 b=TRUE; 416 b=TRUE;
625 417
626 } else { 418 } else {
627 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 419 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
628 b=FALSE; 420 b=FALSE;
629 } 421 }
630 populateRemoteView(); 422 populateRemoteView();
631} 423}
632 424
633void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) 425void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
634{
635 qDebug("list pressed"); 426 qDebug("list pressed");
636 switch (mouse) { 427 switch (mouse) {
637 case 1: 428 case 1:
638 break; 429 break;
639 case 2: 430 case 2:
640 menuTimer.start( 750, TRUE ); 431 menuTimer.start( 750, TRUE );
641 qDebug("Start menu timer\n"); 432 qDebug("Start menu timer\n");
642 break; 433 break;
643 }; 434 };
644} 435}
645 436
646void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) 437void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) {
647{
648 438
649 switch (mouse) { 439 switch (mouse) {
650 case 1: 440 case 1:
651 break; 441 break;
652 case 2: 442 case 2:
653 menuTimer.start( 750, TRUE ); 443 menuTimer.start( 750, TRUE );
654 qDebug("Start menu timer"); 444 qDebug("Start menu timer");
655 break; 445 break;
656 }; 446 };
657} 447}
658 448
659void AdvancedFm::runThis() { 449void AdvancedFm::runThis() {
660 QString fs; 450 QString fs;
661 if (TabWidget->currentPageIndex() == 0) { 451 if (TabWidget->currentPageIndex() == 0) {
662 QString curFile = Local_View->currentItem()->text(0); 452 QString curFile = Local_View->currentItem()->text(0);
663 if(curFile != "../") { 453 if(curFile != "../") {
664 454
665 fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 455 fs= getFileSystemType((const QString &) currentDir.canonicalPath());
666 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 456 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
667 qDebug( fileInfo.owner()); 457 qDebug( fileInfo.owner());
668 if( (fileInfo.permission( QFileInfo::ExeUser) 458 if( (fileInfo.permission( QFileInfo::ExeUser)
669 | fileInfo.permission( QFileInfo::ExeGroup) 459 | fileInfo.permission( QFileInfo::ExeGroup)
670 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 460 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
671 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 461 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
672 QCopEnvelope e("QPE/System", "execute(QString)" ); 462 QCopEnvelope e("QPE/System", "execute(QString)" );
673 e << curFile; 463 e << curFile;
674 } else { 464 } else {
675 curFile = currentDir.canonicalPath()+"/"+curFile; 465 curFile = currentDir.canonicalPath()+"/"+curFile;
676 DocLnk nf(curFile); 466 DocLnk nf(curFile);
677 QString execStr = nf.exec(); 467 QString execStr = nf.exec();
678 qDebug( execStr); 468 qDebug( execStr);
679 if( execStr.isEmpty() ) { 469 if( execStr.isEmpty() ) {
680 } else { 470 } else {
681 nf.execute(); 471 nf.execute();
682 } 472 }
683 } 473 }
684 } 474 }
685 } else { 475 } else {
686 QString curFile = Remote_View->currentItem()->text(0); 476 QString curFile = Remote_View->currentItem()->text(0);
687 if(curFile != "../") { 477 if(curFile != "../") {
688 478
689 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 479 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
690 qDebug("Filesystemtype is "+fs); 480 qDebug("Filesystemtype is "+fs);
691 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); 481 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
692 if( (fileInfo.permission( QFileInfo::ExeUser) 482 if( (fileInfo.permission( QFileInfo::ExeUser)
693 | fileInfo.permission( QFileInfo::ExeGroup) 483 | fileInfo.permission( QFileInfo::ExeGroup)
694 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 484 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
695 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 485 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
696 QCopEnvelope e("QPE/System", "execute(QString)" ); 486 QCopEnvelope e("QPE/System", "execute(QString)" );
697 e << curFile; 487 e << curFile;
698 } else { 488 } else {
699 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 489 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
700 DocLnk nf(curFile); 490 DocLnk nf(curFile);
701 QString execStr = nf.exec(); 491 QString execStr = nf.exec();
702 qDebug(execStr); 492 qDebug(execStr);
703 if( execStr.isEmpty() ) { 493 if( execStr.isEmpty() ) {
704 } else { 494 } else {
705 nf.execute(); 495 nf.execute();
706 } 496 }
707 } 497 }
708 } 498 }
709 } 499 }
710} 500}
711 501
712void AdvancedFm::runText() { 502void AdvancedFm::runText() {
713 if (TabWidget->currentPageIndex() == 0) { 503 if (TabWidget->currentPageIndex() == 0) {
714 QString curFile = Local_View->currentItem()->text(0); 504 QString curFile = Local_View->currentItem()->text(0);
715 if(curFile != "../") { 505 if(curFile != "../") {
716 curFile = currentDir.canonicalPath()+"/"+curFile; 506 curFile = currentDir.canonicalPath()+"/"+curFile;
717 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 507 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
718 e << curFile; 508 e << curFile;
719 } 509 }
720 } else { 510 } else {
721 QString curFile = Remote_View->currentItem()->text(0); 511 QString curFile = Remote_View->currentItem()->text(0);
722 if(curFile != "../") { 512 if(curFile != "../") {
723 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 513 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
724 DocLnk nf(curFile); 514 DocLnk nf(curFile);
725 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 515 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
726 e << curFile; 516 e << curFile;
727 } 517 }
728 } 518 }
729} 519}
730 520
731void AdvancedFm::localMakDir() 521void AdvancedFm::localMakDir() {
732{
733 InputDialog *fileDlg; 522 InputDialog *fileDlg;
734 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 523 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
735 fileDlg->exec(); 524 fileDlg->exec();
736 if( fileDlg->result() == 1 ) { 525 if( fileDlg->result() == 1 ) {
737 QString filename = fileDlg->LineEdit1->text(); 526 QString filename = fileDlg->LineEdit1->text();
738 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 527 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
739 } 528 }
740 populateLocalView(); 529 populateLocalView();
741} 530}
742 531
743void AdvancedFm::remoteMakDir() 532void AdvancedFm::remoteMakDir() {
744{
745 InputDialog *fileDlg; 533 InputDialog *fileDlg;
746 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 534 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
747 fileDlg->exec(); 535 fileDlg->exec();
748 if( fileDlg->result() == 1 ) { 536 if( fileDlg->result() == 1 ) {
749 QString filename = fileDlg->LineEdit1->text(); 537 QString filename = fileDlg->LineEdit1->text();
750 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); 538 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
751 } 539 }
752 populateRemoteView(); 540 populateRemoteView();
753} 541}
754 542
755void AdvancedFm::localDelete() 543void AdvancedFm::localDelete() {
756{
757 QStringList curFileList = getPath(); 544 QStringList curFileList = getPath();
758 if(curFileList.count() > 0) { 545 if(curFileList.count() > 0) {
759 QString myFile; 546 QString myFile;
760 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 547 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
761 myFile = (*it); 548 myFile = (*it);
762 if( myFile.find(" -> ",0,TRUE) != -1) 549 if( myFile.find(" -> ",0,TRUE) != -1)
763 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 550 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
764 551
765 QString f = currentDir.canonicalPath(); 552 QString f = currentDir.canonicalPath();
766 if(f.right(1).find("/",0,TRUE) == -1) 553 if(f.right(1).find("/",0,TRUE) == -1)
767 f+="/"; 554 f+="/";
768 f+=myFile; 555 f+=myFile;
769 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 556 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
770 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 557 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
771 "\nand all it's contents ?" 558 "\nand all it's contents ?"
772 ,tr("Yes"),tr("No"),0,0,1) ) { 559 ,tr("Yes"),tr("No"),0,0,1) ) {
773 case 0: { 560 case 0: {
774 f=f.left(f.length()-1); 561 f=f.left(f.length()-1);
775 QString cmd="rm -rf "+f; 562 QString cmd="rm -rf "+f;
776 system( cmd.latin1()); 563 system( cmd.latin1());
777 populateLocalView(); 564 populateLocalView();
778 } 565 }
779 break; 566 break;
780 case 1: 567 case 1:
781 // exit 568 // exit
782 break; 569 break;
783 }; 570 };
784 571
785 } else { 572 } else {
786 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 573 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
787 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 574 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
788 case 0: { 575 case 0: {
789 QString cmd="rm "+f; 576 QString cmd="rm "+f;
790 QFile file(f); 577 QFile file(f);
791 file.remove(); 578 file.remove();
792 // system( cmd.latin1()); 579 // system( cmd.latin1());
793 populateLocalView(); 580 populateLocalView();
794 } 581 }
795 break; 582 break;
796 case 1: 583 case 1:
797 // exit 584 // exit
798 break; 585 break;
799 }; 586 };
800 } 587 }
801 } 588 }
802 } 589 }
803} 590}
804 591
805void AdvancedFm::remoteDelete() 592void AdvancedFm::remoteDelete() {
806{
807 QStringList curFileList = getPath(); 593 QStringList curFileList = getPath();
808 if( curFileList.count() > 0) { 594 if( curFileList.count() > 0) {
809 QString myFile; 595 QString myFile;
810 596
811 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 597 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
812 myFile = (*it); 598 myFile = (*it);
813 if(myFile.find(" -> ",0,TRUE) != -1) 599 if(myFile.find(" -> ",0,TRUE) != -1)
814 myFile = myFile.left(myFile.find(" -> ",0,TRUE)); 600 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
815 QString f = currentRemoteDir.canonicalPath(); 601 QString f = currentRemoteDir.canonicalPath();
816 if(f.right(1).find("/",0,TRUE) == -1) 602 if(f.right(1).find("/",0,TRUE) == -1)
817 f+="/"; 603 f+="/";
818 f+=myFile; 604 f+=myFile;
819 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 605 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
820 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 606 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
821 "\nand all it's contents ?", 607 "\nand all it's contents ?",
822 tr("Yes"),tr("No"),0,0,1) ) { 608 tr("Yes"),tr("No"),0,0,1) ) {
823 case 0: { 609 case 0: {
824 f=f.left(f.length()-1); 610 f=f.left(f.length()-1);
825 QString cmd="rm -rf "+f; 611 QString cmd="rm -rf "+f;
826 system( cmd.latin1()); 612 system( cmd.latin1());
827 populateRemoteView(); 613 populateRemoteView();
828 } 614 }
829 break; 615 break;
830 case 1: 616 case 1:
831 // exit 617 // exit
832 break; 618 break;
833 }; 619 };
834 620
835 } else { 621 } else {
836 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 622 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
837 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 623 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
838 case 0: { 624 case 0: {
839 QString cmd="rm "+f; 625 QString cmd="rm "+f;
840 QFile file(f); 626 QFile file(f);
841 file.remove(); 627 file.remove();
842 // system( cmd.latin1()); 628 // system( cmd.latin1());
843 populateRemoteView(); 629 populateRemoteView();
844 } 630 }
845 break; 631 break;
846 case 1: 632 case 1:
847 // exit 633 // exit
848 break; 634 break;
849 }; 635 };
850 } 636 }
851 } 637 }
852 } 638 }
853} 639}
854 640
855void AdvancedFm::localRename() 641void AdvancedFm::localRename() {
856{
857 QString curFile = Local_View->currentItem()->text(0); 642 QString curFile = Local_View->currentItem()->text(0);
858 qDebug("currentItem "+curFile); 643 qDebug("currentItem "+curFile);
859 if( curFile !="../") { 644 if( curFile !="../") {
860 InputDialog *fileDlg; 645 InputDialog *fileDlg;
861 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 646 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
862 fileDlg->setInputText((const QString &)curFile); 647 fileDlg->setInputText((const QString &)curFile);
863 fileDlg->exec(); 648 fileDlg->exec();
864 if( fileDlg->result() == 1 ) { 649 if( fileDlg->result() == 1 ) {
865 QString oldname = currentDir.canonicalPath() + "/" + curFile; 650 QString oldname = currentDir.canonicalPath() + "/" + curFile;
866 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 651 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
867 if( rename(oldname.latin1(), newName.latin1())== -1) 652 if( rename(oldname.latin1(), newName.latin1())== -1)
868 QMessageBox::message(tr("Note"),tr("Could not rename")); 653 QMessageBox::message(tr("Note"),tr("Could not rename"));
869 } 654 }
870 populateLocalView(); 655 populateLocalView();
871 } 656 }
872} 657}
873 658
874void AdvancedFm::remoteRename() 659void AdvancedFm::remoteRename()
875{ 660{
876 QString curFile = Remote_View->currentItem()->text(0); 661 QString curFile = Remote_View->currentItem()->text(0);
877 if( curFile !="../") { 662 if( curFile !="../") {
878 InputDialog *fileDlg; 663 InputDialog *fileDlg;
879 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 664 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
880 fileDlg->setInputText((const QString &)curFile); 665 fileDlg->setInputText((const QString &)curFile);
881 fileDlg->exec(); 666 fileDlg->exec();
882 if( fileDlg->result() == 1 ) { 667 if( fileDlg->result() == 1 ) {
883 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; 668 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
884 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 669 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
885 if( rename(oldname.latin1(), newName.latin1())== -1) 670 if( rename(oldname.latin1(), newName.latin1())== -1)
886 QMessageBox::message(tr("Note"),tr("Could not rename")); 671 QMessageBox::message(tr("Note"),tr("Could not rename"));
887 } 672 }
888 populateRemoteView(); 673 populateRemoteView();
889 } 674 }
890} 675}
891 676
892void AdvancedFm::switchToLocalTab() 677void AdvancedFm::switchToLocalTab() {
893{
894 TabWidget->setCurrentPage(0); 678 TabWidget->setCurrentPage(0);
895 Local_View->setFocus(); 679 Local_View->setFocus();
896} 680}
897 681
898void AdvancedFm::switchToRemoteTab() 682void AdvancedFm::switchToRemoteTab() {
899{
900 TabWidget->setCurrentPage(1); 683 TabWidget->setCurrentPage(1);
901 Remote_View->setFocus(); 684 Remote_View->setFocus();
902} 685}
903 686
904void AdvancedFm::readConfig() 687void AdvancedFm::readConfig() {
905{
906 Config cfg("AdvancedFm"); 688 Config cfg("AdvancedFm");
907} 689}
908 690
909void AdvancedFm::writeConfig() 691void AdvancedFm::writeConfig() {
910{
911 Config cfg("AdvancedFm"); 692 Config cfg("AdvancedFm");
912} 693}
913 694
914void AdvancedFm::currentPathComboChanged() 695void AdvancedFm::currentPathComboChanged() {
915{
916 if (TabWidget->currentPageIndex() == 0) { 696 if (TabWidget->currentPageIndex() == 0) {
917 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 697 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
918 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 698 currentDir.setPath( currentPathCombo->lineEdit()->text() );
919 populateLocalView(); 699 populateLocalView();
920 } else { 700 } else {
921 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 701 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
922 } 702 }
923 } 703 }
924 if (TabWidget->currentPageIndex() == 0) { 704 if (TabWidget->currentPageIndex() == 0) {
925 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 705 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
926 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 706 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
927 populateRemoteView(); 707 populateRemoteView();
928 } else { 708 } else {
929 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 709 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
930 } 710 }
931 } 711 }
932} 712}
933 713
934void AdvancedFm::fillCombo(const QString &currentPath) { 714void AdvancedFm::fillCombo(const QString &currentPath) {
935 715
936 if (TabWidget->currentPageIndex() == 0) { 716 if (TabWidget->currentPageIndex() == 0) {
937 currentPathCombo->lineEdit()->setText( currentPath); 717 currentPathCombo->lineEdit()->setText( currentPath);
938 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 718 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
939 currentPathCombo->clear(); 719 currentPathCombo->clear();
940 localDirPathStringList.prepend( currentPath ); 720 localDirPathStringList.prepend( currentPath );
941 currentPathCombo->insertStringList( localDirPathStringList,-1); 721 currentPathCombo->insertStringList( localDirPathStringList,-1);
942 } 722 }
943 } else { 723 } else {
944 currentPathCombo->lineEdit()->setText( currentPath); 724 currentPathCombo->lineEdit()->setText( currentPath);
945 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 725 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
946 currentPathCombo->clear(); 726 currentPathCombo->clear();
947 remoteDirPathStringList.prepend( currentPath ); 727 remoteDirPathStringList.prepend( currentPath );
948 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 728 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
949 } 729 }
950 } 730 }
951} 731}
952 732
953void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 733void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
954 if (TabWidget->currentPageIndex() == 0) { 734 if (TabWidget->currentPageIndex() == 0) {
955 chdir( currentPath.latin1() ); 735 chdir( currentPath.latin1() );
956 currentDir.cd( currentPath, TRUE); 736 currentDir.cd( currentPath, TRUE);
957 populateLocalView(); 737 populateLocalView();
958 update(); 738 update();
959 } else { 739 } else {
960 chdir( currentPath.latin1() ); 740 chdir( currentPath.latin1() );
961 currentRemoteDir.cd( currentPath, TRUE); 741 currentRemoteDir.cd( currentPath, TRUE);
962 populateRemoteView(); 742 populateRemoteView();
963 update(); 743 update();
@@ -1049,121 +829,119 @@ void AdvancedFm::homeButtonPushed() {
1049 829
1050void AdvancedFm::docButtonPushed() { 830void AdvancedFm::docButtonPushed() {
1051 QString current = QPEApplication::documentDir(); 831 QString current = QPEApplication::documentDir();
1052 chdir( current.latin1() ); 832 chdir( current.latin1() );
1053 if (TabWidget->currentPageIndex() == 0) { 833 if (TabWidget->currentPageIndex() == 0) {
1054 currentDir.cd( current, TRUE); 834 currentDir.cd( current, TRUE);
1055 populateLocalView(); 835 populateLocalView();
1056 } else { 836 } else {
1057 currentRemoteDir.cd( current, TRUE); 837 currentRemoteDir.cd( current, TRUE);
1058 populateRemoteView(); 838 populateRemoteView();
1059 } 839 }
1060 update(); 840 update();
1061} 841}
1062 842
1063void AdvancedFm::SDButtonPushed() { 843void AdvancedFm::SDButtonPushed() {
1064 QString current = "/mnt/card"; 844 QString current = "/mnt/card";
1065 chdir( current.latin1() ); 845 chdir( current.latin1() );
1066 if (TabWidget->currentPageIndex() == 0) { 846 if (TabWidget->currentPageIndex() == 0) {
1067 currentDir.cd( current, TRUE); 847 currentDir.cd( current, TRUE);
1068 populateLocalView(); 848 populateLocalView();
1069 } else { 849 } else {
1070 currentRemoteDir.cd( current, TRUE); 850 currentRemoteDir.cd( current, TRUE);
1071 populateRemoteView(); 851 populateRemoteView();
1072 } 852 }
1073 update(); 853 update();
1074 854
1075} 855}
1076 856
1077void AdvancedFm::CFButtonPushed() { 857void AdvancedFm::CFButtonPushed() {
1078 QString current; 858 QString current;
1079 if(zaurusDevice) 859 if(zaurusDevice)
1080 current= "/mnt/cf"; 860 current= "/mnt/cf";
1081 else 861 else
1082 current = "/mnt/hda"; 862 current = "/mnt/hda";
1083 863
1084 chdir( current.latin1() ); 864 chdir( current.latin1() );
1085 if (TabWidget->currentPageIndex() == 0) { 865 if (TabWidget->currentPageIndex() == 0) {
1086 currentDir.cd( current, TRUE); 866 currentDir.cd( current, TRUE);
1087 populateLocalView(); 867 populateLocalView();
1088 } else { 868 } else {
1089 currentRemoteDir.cd( current, TRUE); 869 currentRemoteDir.cd( current, TRUE);
1090 populateRemoteView(); 870 populateRemoteView();
1091 } 871 }
1092 update(); 872 update();
1093 873
1094} 874}
1095 875
1096 876
1097void AdvancedFm::upDir() 877void AdvancedFm::upDir() {
1098{
1099 if (TabWidget->currentPageIndex() == 0) { 878 if (TabWidget->currentPageIndex() == 0) {
1100 QString current = currentDir.canonicalPath(); 879 QString current = currentDir.canonicalPath();
1101 QDir dir(current); 880 QDir dir(current);
1102 dir.cdUp(); 881 dir.cdUp();
1103 current = dir.canonicalPath(); 882 current = dir.canonicalPath();
1104 chdir( current.latin1() ); 883 chdir( current.latin1() );
1105 currentDir.cd( current, TRUE); 884 currentDir.cd( current, TRUE);
1106 populateLocalView(); 885 populateLocalView();
1107 update(); 886 update();
1108 } else { 887 } else {
1109 QString current = currentRemoteDir.canonicalPath(); 888 QString current = currentRemoteDir.canonicalPath();
1110 QDir dir(current); 889 QDir dir(current);
1111 dir.cdUp(); 890 dir.cdUp();
1112 current = dir.canonicalPath(); 891 current = dir.canonicalPath();
1113 chdir( current.latin1() ); 892 chdir( current.latin1() );
1114 currentRemoteDir.cd( current, TRUE); 893 currentRemoteDir.cd( current, TRUE);
1115 populateRemoteView(); 894 populateRemoteView();
1116 update(); 895 update();
1117 } 896 }
1118} 897}
1119 898
1120void AdvancedFm::copy() 899void AdvancedFm::copy() {
1121{
1122 qApp->processEvents(); 900 qApp->processEvents();
1123 QStringList curFileList = getPath(); 901 QStringList curFileList = getPath();
1124 if( curFileList.count() > 0) { 902 if( curFileList.count() > 0) {
1125 QString curFile; 903 QString curFile;
1126 if (TabWidget->currentPageIndex() == 0) { 904 if (TabWidget->currentPageIndex() == 0) {
1127 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 905 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1128 906
1129 QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); 907 QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1130 qDebug("Destination file is "+destFile); 908 qDebug("Destination file is "+destFile);
1131 909
1132 curFile = currentDir.canonicalPath()+"/"+(*it); 910 curFile = currentDir.canonicalPath()+"/"+(*it);
1133 qDebug("CurrentFile file is " + curFile); 911 qDebug("CurrentFile file is " + curFile);
1134 912
1135 QFile f(destFile); 913 QFile f(destFile);
1136 if( f.exists()) { 914 if( f.exists()) {
1137 switch ( QMessageBox::warning(this,tr("Delete"), 915 switch ( QMessageBox::warning(this,tr("Delete"),
1138 destFile+tr(" already exists\nDo you really want to delete it?"), 916 destFile+tr(" already exists\nDo you really want to delete it?"),
1139 tr("Yes"),tr("No"),0,0,1) ) { 917 tr("Yes"),tr("No"),0,0,1) ) {
1140 case 0: 918 case 0:
1141 f.remove(); 919 f.remove();
1142 break; 920 break;
1143 case 1: 921 case 1:
1144 return; 922 return;
1145 break; 923 break;
1146 }; 924 };
1147 } 925 }
1148 if(!copyFile(destFile, curFile) ) { 926 if(!copyFile(destFile, curFile) ) {
1149 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 927 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1150 qWarning("nothin doing"); 928 qWarning("nothin doing");
1151 } 929 }
1152 } 930 }
1153 populateRemoteView(); 931 populateRemoteView();
1154 TabWidget->setCurrentPage(1); 932 TabWidget->setCurrentPage(1);
1155 933
1156 } else { 934 } else {
1157 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 935 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1158 936
1159 QString destFile = currentDir.canonicalPath()+"/"+(*it); 937 QString destFile = currentDir.canonicalPath()+"/"+(*it);
1160 qDebug("Destination file is "+destFile); 938 qDebug("Destination file is "+destFile);
1161 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 939 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1162 qDebug("CurrentFile file is " + curFile); 940 qDebug("CurrentFile file is " + curFile);
1163 941
1164 QFile f(destFile); 942 QFile f(destFile);
1165 if( f.exists()) { 943 if( f.exists()) {
1166 switch ( QMessageBox::warning(this,tr("Delete"), 944 switch ( QMessageBox::warning(this,tr("Delete"),
1167 destFile+tr(" already exists\nDo you really want to delete it?"), 945 destFile+tr(" already exists\nDo you really want to delete it?"),
1168 tr("Yes"),tr("No"),0,0,1) ) { 946 tr("Yes"),tr("No"),0,0,1) ) {
1169 case 0: 947 case 0:
@@ -1550,98 +1328,97 @@ void AdvancedFm::fileStatus() {
1550 sleep(1); 1328 sleep(1);
1551 fp = popen( (const char *) command, "r"); 1329 fp = popen( (const char *) command, "r");
1552 if ( !fp ) { 1330 if ( !fp ) {
1553 qDebug("Could not execute '" + command + "'! err=%d", fp); 1331 qDebug("Could not execute '" + command + "'! err=%d", fp);
1554 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 1332 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1555 pclose(fp); 1333 pclose(fp);
1556 return; 1334 return;
1557 } else { 1335 } else {
1558 while ( fgets( line, sizeof line, fp)) { 1336 while ( fgets( line, sizeof line, fp)) {
1559 outDlg->OutputEdit->append(line); 1337 outDlg->OutputEdit->append(line);
1560 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1338 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1561 1339
1562 } 1340 }
1563 1341
1564 } 1342 }
1565 pclose(fp); 1343 pclose(fp);
1566} 1344}
1567 1345
1568void AdvancedFm::mkDir() { 1346void AdvancedFm::mkDir() {
1569 if (TabWidget->currentPageIndex() == 0) 1347 if (TabWidget->currentPageIndex() == 0)
1570 localMakDir(); 1348 localMakDir();
1571 else 1349 else
1572 remoteMakDir(); 1350 remoteMakDir();
1573 1351
1574} 1352}
1575 1353
1576void AdvancedFm::rn() { 1354void AdvancedFm::rn() {
1577 if (TabWidget->currentPageIndex() == 0) 1355 if (TabWidget->currentPageIndex() == 0)
1578 localRename(); 1356 localRename();
1579 else 1357 else
1580 remoteRename(); 1358 remoteRename();
1581 1359
1582} 1360}
1583 1361
1584void AdvancedFm::del() { 1362void AdvancedFm::del() {
1585 if (TabWidget->currentPageIndex() == 0) 1363 if (TabWidget->currentPageIndex() == 0)
1586 localDelete(); 1364 localDelete();
1587 else 1365 else
1588 remoteDelete(); 1366 remoteDelete();
1589} 1367}
1590 1368
1591void AdvancedFm::doAbout() { 1369void AdvancedFm::doAbout() {
1592 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 1370 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
1593 "is copyright 2002 by\n" 1371 "is copyright 2002 by\n"
1594 "L.J.Potter<llornkcor@handhelds.org>\n" 1372 "L.J.Potter<llornkcor@handhelds.org>\n"
1595 "and is licensed by the GPL")); 1373 "and is licensed by the GPL"));
1596} 1374}
1597 1375
1598void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 1376void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
1599{
1600 if( TabWidget->hasFocus()) 1377 if( TabWidget->hasFocus())
1601 switch ( e->key() ) { 1378 switch ( e->key() ) {
1602 case Key_Delete: 1379 case Key_Delete:
1603 del(); 1380 del();
1604 break; 1381 break;
1605 case Key_H: 1382 case Key_H:
1606 showHidden(); 1383 showHidden();
1607 break; 1384 break;
1608 case Key_E: 1385 case Key_E:
1609 runThis(); 1386 runThis();
1610 break; 1387 break;
1611 case Key_C: 1388 case Key_C:
1612 copy(); 1389 copy();
1613 break; 1390 break;
1614 case Key_A: 1391 case Key_A:
1615 copyAs(); 1392 copyAs();
1616 break; 1393 break;
1617 case Key_M: 1394 case Key_M:
1618 move(); 1395 move();
1619 break; 1396 break;
1620 case Key_R: 1397 case Key_R:
1621 rn(); 1398 rn();
1622 break; 1399 break;
1623 case Key_I: 1400 case Key_I:
1624 fileStatus(); 1401 fileStatus();
1625 break; 1402 break;
1626 case Key_U: 1403 case Key_U:
1627 upDir(); 1404 upDir();
1628 break; 1405 break;
1629 case Key_P: 1406 case Key_P:
1630 filePerms(); 1407 filePerms();
1631 break; 1408 break;
1632 case Key_N: 1409 case Key_N:
1633 mkDir(); 1410 mkDir();
1634 break; 1411 break;
1635 case Key_1: 1412 case Key_1:
1636 switchToLocalTab(); 1413 switchToLocalTab();
1637 break; 1414 break;
1638 case Key_2: 1415 case Key_2:
1639 switchToRemoteTab(); 1416 switchToRemoteTab();
1640 break; 1417 break;
1641 case Key_3: 1418 case Key_3:
1642 CFButtonPushed(); 1419 CFButtonPushed();
1643 break; 1420 break;
1644 case Key_4: 1421 case Key_4:
1645 SDButtonPushed(); 1422 SDButtonPushed();
1646 break; 1423 break;
1647 case Key_5: 1424 case Key_5:
@@ -1763,178 +1540,178 @@ QString AdvancedFm::getDiskSpace( const QString &path) {
1763 if ( !div ) div = 1; 1540 if ( !div ) div = 1;
1764 1541
1765 return QString::number(availBlks * mult / div); 1542 return QString::number(availBlks * mult / div);
1766 } 1543 }
1767 return ""; 1544 return "";
1768} 1545}
1769 1546
1770void AdvancedFm::doBeam() { 1547void AdvancedFm::doBeam() {
1771 Ir ir; 1548 Ir ir;
1772 if(!ir.supported()){ 1549 if(!ir.supported()){
1773 } else { 1550 } else {
1774 1551
1775 QStringList curFileList = getPath(); 1552 QStringList curFileList = getPath();
1776 if( curFileList.count() > 0) { 1553 if( curFileList.count() > 0) {
1777 1554
1778 if (TabWidget->currentPageIndex() == 0) { 1555 if (TabWidget->currentPageIndex() == 0) {
1779 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1556 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1780 1557
1781 QString curFile = currentDir.canonicalPath()+"/"+(*it); 1558 QString curFile = currentDir.canonicalPath()+"/"+(*it);
1782 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 1559 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
1783 Ir *file = new Ir(this, "IR"); 1560 Ir *file = new Ir(this, "IR");
1784 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 1561 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
1785 file->send( curFile, curFile ); 1562 file->send( curFile, curFile );
1786 } 1563 }
1787 1564
1788 } else { 1565 } else {
1789 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1566 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1790 1567
1791 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1568 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1792 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 1569 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
1793 Ir *file = new Ir(this, "IR"); 1570 Ir *file = new Ir(this, "IR");
1794 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 1571 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
1795 file->send( curFile, curFile ); 1572 file->send( curFile, curFile );
1796 1573
1797 } 1574 }
1798 } 1575 }
1799 } 1576 }
1800 } 1577 }
1801 1578
1802} 1579}
1803 1580
1804void AdvancedFm::fileBeamFinished( Ir *) { 1581void AdvancedFm::fileBeamFinished( Ir *) {
1805 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 1582 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
1806 1583
1807} 1584}
1808 1585
1809void AdvancedFm::showFileMenu() { 1586void AdvancedFm::showFileMenu() {
1810 1587
1811 QString curApp; 1588 QString curApp;
1812 bool isLocalView = false; 1589 bool isLocalView = false;
1813 if (TabWidget->currentPageIndex() == 0) { 1590 if (TabWidget->currentPageIndex() == 0) {
1814 isLocalView = TRUE; 1591 isLocalView = TRUE;
1815 curApp = Local_View->currentItem()->text(0); 1592 curApp = Local_View->currentItem()->text(0);
1816 } else { 1593 } else {
1817 curApp = Remote_View->currentItem()->text(0); 1594 curApp = Remote_View->currentItem()->text(0);
1818 } 1595 }
1819 1596
1820 MimeType mt( curApp ); 1597 MimeType mt( curApp );
1821 const AppLnk* app = mt.application(); 1598 const AppLnk* app = mt.application();
1822 QFile fi(curApp); 1599 QFile fi(curApp);
1823 1600
1824 QPopupMenu *m = new QPopupMenu(0); 1601 QPopupMenu *m = new QPopupMenu(0);
1825 1602
1826 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 1603 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
1827 m->insertSeparator(); 1604 m->insertSeparator();
1828 if ( QFileInfo(fi).isDir() ) { 1605 if ( QFileInfo(fi).isDir() ) {
1829 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 1606 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
1830 } else { 1607 } else {
1831 1608
1832 if ( app ) 1609 if ( app )
1833 m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); 1610 m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) );
1834 else if( QFileInfo(fi).isExecutable() ) 1611 else if( QFileInfo(fi).isExecutable() )
1835 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 1612 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
1836 1613
1837 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 1614 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
1838 } 1615 }
1839 m->insertSeparator(); 1616 m->insertSeparator();
1840 1617
1841 1618
1842 if(isLocalView) 1619 if(isLocalView)
1843 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 1620 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
1844 else 1621 else
1845 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 1622 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
1846 1623
1847 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 1624 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
1848 m->insertSeparator(); 1625 m->insertSeparator();
1849 1626
1850 if(isLocalView) 1627 if(isLocalView)
1851 m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 1628 m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
1852 else 1629 else
1853 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 1630 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
1854 1631
1855 m->insertItem( tr( "Copy" ), this, SLOT( copy() )); 1632 m->insertItem( tr( "Copy" ), this, SLOT( copy() ));
1856 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 1633 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
1857 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 1634 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
1858 m->insertItem( tr( "Move" ), this, SLOT( move() )); 1635 m->insertItem( tr( "Move" ), this, SLOT( move() ));
1859 m->insertSeparator(); 1636 m->insertSeparator();
1860 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 1637 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
1861 1638
1862// if(isLocalView) 1639// if(isLocalView)
1863// m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); 1640// m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() ));
1864// else 1641// else
1865// m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); 1642// m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() ));
1866 1643
1867 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 1644 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
1868 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 1645 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
1869 m->insertSeparator(); 1646 m->insertSeparator();
1870 1647
1871 if(isLocalView) 1648 if(isLocalView)
1872 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 1649 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
1873 else 1650 else
1874 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 1651 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
1875 1652
1876 m->insertSeparator(); 1653 m->insertSeparator();
1877 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 1654 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
1878 1655
1879 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings 1656 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings
1880 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1657 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1881 m->setCheckable(TRUE); 1658 m->setCheckable(TRUE);
1882 if (!b) 1659 if (!b)
1883 m->setItemChecked(m->idAt(0),TRUE); 1660 m->setItemChecked(m->idAt(0),TRUE);
1884 else 1661 else
1885 m->setItemChecked(m->idAt(0),FALSE); 1662 m->setItemChecked(m->idAt(0),FALSE);
1886 1663
1887 if(Ir::supported()) 1664 if(Ir::supported())
1888 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 1665 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
1889 m->setFocus(); 1666 m->setFocus();
1890 m->exec( QCursor::pos() ); 1667 m->exec( QCursor::pos() );
1891 sleep(1); 1668 sleep(1);
1892 if(m) delete m; 1669 if(m) delete m;
1893} 1670}
1894 1671
1895 1672
1896void AdvancedFm::cancelMenuTimer() { 1673void AdvancedFm::cancelMenuTimer() {
1897 1674
1898 qDebug("selectionChanged: cancel menu timer"); 1675 qDebug("selectionChanged: cancel menu timer");
1899 if( menuTimer.isActive() ) 1676 if( menuTimer.isActive() )
1900 menuTimer.stop(); 1677 menuTimer.stop();
1901} 1678}
1902 1679
1903QString AdvancedFm::checkDiskSpace(const QString &path) { 1680QString AdvancedFm::checkDiskSpace(const QString &path) {
1904 struct statfs fss; 1681 struct statfs fss;
1905 if ( !statfs( path.latin1(), &fss ) ) { 1682 if ( !statfs( path.latin1(), &fss ) ) {
1906 int blkSize = fss.f_bsize; 1683 int blkSize = fss.f_bsize;
1907// int totalBlks = fs.f_blocks; 1684// int totalBlks = fs.f_blocks;
1908 int availBlks = fss.f_bavail; 1685 int availBlks = fss.f_bavail;
1909 1686
1910 long mult = blkSize / 1024; 1687 long mult = blkSize / 1024;
1911 long div = 1024 / blkSize; 1688 long div = 1024 / blkSize;
1912 if ( !mult ) mult = 1; 1689 if ( !mult ) mult = 1;
1913 if ( !div ) div = 1; 1690 if ( !div ) div = 1;
1914 1691
1915 1692
1916 return QString::number(availBlks * mult / div); 1693 return QString::number(availBlks * mult / div);
1917 } 1694 }
1918 return ""; 1695 return "";
1919} 1696}
1920 1697
1921void AdvancedFm::addToDocs() { 1698void AdvancedFm::addToDocs() {
1922 QStringList strListPaths = getPath(); 1699 QStringList strListPaths = getPath();
1923 if( strListPaths.count() > 0) { 1700 if( strListPaths.count() > 0) {
1924 QString curFile; 1701 QString curFile;
1925 if (TabWidget->currentPageIndex() == 0) { 1702 if (TabWidget->currentPageIndex() == 0) {
1926 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 1703 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
1927 curFile = currentDir.canonicalPath()+"/"+(*it); 1704 curFile = currentDir.canonicalPath()+"/"+(*it);
1928 qDebug(curFile); 1705 qDebug(curFile);
1929 DocLnk f; 1706 DocLnk f;
1930// curFile.replace(QRegExp("\\..*"),""); 1707// curFile.replace(QRegExp("\\..*"),"");
1931 f.setName((*it)); 1708 f.setName((*it));
1932 f.setFile( curFile); 1709 f.setFile( curFile);
1933 f.writeLink(); 1710 f.writeLink();
1934 } 1711 }
1935 } else { 1712 } else {
1936 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 1713 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
1937 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1714 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1938 qDebug(curFile); 1715 qDebug(curFile);
1939 1716
1940 DocLnk f; 1717 DocLnk f;
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 53dad50..b2705b8 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -1,50 +1,50 @@
1/*************************************************************************** 1/***************************************************************************
2 opieftp.h 2 advancedfm.h
3 ------------------- 3 -------------------
4** Created: Sat Mar 9 23:33:09 2002 4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#ifndef ADVANCEDFM_H 12#ifndef ADVANCEDFM_H
13#define ADVANCEDFM_H 13#define ADVANCEDFM_H
14 14
15#include <qpe/ir.h> 15#include <qpe/ir.h>
16 16
17#include <qvariant.h> 17#include <qvariant.h>
18#include <qdialog.h> 18#include <qdialog.h>
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20#include <qstringlist.h> 20#include <qstringlist.h>
21#include <qdir.h> 21#include <qdir.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qpoint.h> 23#include <qpoint.h>
24#include <qtimer.h> 24#include <qtimer.h>
25 25
26class QVBoxLayout; 26class QVBoxLayout;
27class QHBoxLayout; 27class QHBoxLayout;
28class QGridLayout; 28class QGridLayout;
29class QComboBox; 29class QComboBox;
30class QListView; 30class QListView;
31class QListviewItem; 31class QListviewItem;
32class QLabel; 32class QLabel;
33class QProgressBar; 33class QProgressBar;
34class QSpinBox; 34class QSpinBox;
35class QTabWidget; 35class QTabWidget;
36class QWidget; 36class QWidget;
37class QPEToolBar; 37class QPEToolBar;
38class QPEMenuBar; 38class QPEMenuBar;
39class QPopupMenu; 39class QPopupMenu;
40class QFile; 40class QFile;
41class QListViewItem; 41class QListViewItem;
42class QLineEdit; 42class QLineEdit;
43//class QPushButton; 43//class QPushButton;
44class QToolButton; 44class QToolButton;
45class Ir; 45class Ir;
46 46
47class AdvancedFm : public QMainWindow 47class AdvancedFm : public QMainWindow
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50public: 50public:
@@ -65,81 +65,83 @@ public:
65 QListViewItem * item; 65 QListViewItem * item;
66 bool b; 66 bool b;
67 QStringList fileSystemTypeList, fsList; 67 QStringList fileSystemTypeList, fsList;
68 int currentServerConfig; 68 int currentServerConfig;
69protected slots: 69protected slots:
70 void addToDocs(); 70 void addToDocs();
71 void doLocalCd(); 71 void doLocalCd();
72 void doRemoteCd(); 72 void doRemoteCd();
73// void copy(); 73// void copy();
74 void mkDir(); 74 void mkDir();
75 void del(); 75 void del();
76 void rn(); 76 void rn();
77 void populateLocalView(); 77 void populateLocalView();
78 void populateRemoteView(); 78 void populateRemoteView();
79 void showHidden(); 79 void showHidden();
80 void showRemoteHidden(); 80 void showRemoteHidden();
81 void writeConfig(); 81 void writeConfig();
82 void readConfig(); 82 void readConfig();
83 void localListClicked(QListViewItem *); 83 void localListClicked(QListViewItem *);
84 void remoteListClicked(QListViewItem *); 84 void remoteListClicked(QListViewItem *);
85 void localListPressed( int, QListViewItem *, const QPoint&, int); 85 void localListPressed( int, QListViewItem *, const QPoint&, int);
86 void remoteListPressed( int, QListViewItem *, const QPoint&, int); 86 void remoteListPressed( int, QListViewItem *, const QPoint&, int);
87 void localMakDir(); 87 void localMakDir();
88 void localDelete(); 88 void localDelete();
89 void remoteMakDir(); 89 void remoteMakDir();
90 void remoteDelete(); 90 void remoteDelete();
91/* bool remoteDirList(const QString &); */ 91/* bool remoteDirList(const QString &); */
92/* bool remoteChDir(const QString &); */ 92/* bool remoteChDir(const QString &); */
93 void tabChanged(QWidget*); 93 void tabChanged(QWidget*);
94 void cleanUp(); 94 void cleanUp();
95 void remoteRename(); 95 void remoteRename();
96 void localRename(); 96 void localRename();
97 void runThis(); 97 void runThis();
98 void runText(); 98 void runText();
99 void filePerms(); 99 void filePerms();
100 void doProperties(); 100 void doProperties();
101 void runCommand(); 101 void runCommand();
102 void runCommandStd(); 102 void runCommandStd();
103 QStringList getPath(); 103 QStringList getPath();
104 void mkSym(); 104 void mkSym();
105 void switchToLocalTab(); 105 void switchToLocalTab();
106 void switchToRemoteTab(); 106 void switchToRemoteTab();
107 107
108protected: 108protected:
109 bool zaurusDevice; 109 bool zaurusDevice;
110 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 110 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
111 QStringList remoteDirPathStringList, localDirPathStringList; 111 QStringList remoteDirPathStringList, localDirPathStringList;
112 112
113 void init();
114 void initConnections();
113 void keyReleaseEvent( QKeyEvent *); 115 void keyReleaseEvent( QKeyEvent *);
114 QString getFileSystemType(const QString &); 116 QString getFileSystemType(const QString &);
115 QString getDiskSpace(const QString &); 117 QString getDiskSpace(const QString &);
116
117 void parsetab(const QString &fileName); 118 void parsetab(const QString &fileName);
118QString checkDiskSpace(const QString &); 119 QString checkDiskSpace(const QString &);
120
119protected slots: 121protected slots:
120 void showFileMenu(); 122 void showFileMenu();
121 void cancelMenuTimer(); 123 void cancelMenuTimer();
122 void homeButtonPushed(); 124 void homeButtonPushed();
123 void docButtonPushed(); 125 void docButtonPushed();
124 void SDButtonPushed(); 126 void SDButtonPushed();
125 void CFButtonPushed(); 127 void CFButtonPushed();
126 void QPEButtonPushed(); 128 void QPEButtonPushed();
127 void upDir(); 129 void upDir();
128 void currentPathComboChanged(); 130 void currentPathComboChanged();
129 void copy(); 131 void copy();
130 void copyAs(); 132 void copyAs();
131 void copySameDir(); 133 void copySameDir();
132 void currentPathComboActivated(const QString &); 134 void currentPathComboActivated(const QString &);
133 void fillCombo(const QString &); 135 void fillCombo(const QString &);
134 bool copyFile( const QString & , const QString & ); 136 bool copyFile( const QString & , const QString & );
135 void move(); 137 void move();
136 void fileStatus(); 138 void fileStatus();
137 void doAbout(); 139 void doAbout();
138 void doBeam(); 140 void doBeam();
139 void fileBeamFinished( Ir *); 141 void fileBeamFinished( Ir *);
140 142
141private: 143private:
142 QTimer menuTimer; 144 QTimer menuTimer;
143}; 145};
144 146
145#endif // ADVANCEDFM_H 147#endif // ADVANCEDFM_H
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
index 0f0f770..9629f0e 100644
--- a/noncore/apps/advancedfm/advancedfm.pro
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -1,25 +1,25 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h 3HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h
4SOURCES = advancedfm.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp 4SOURCES = advancedfm.cpp advancedfmData.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp
5TARGET = advancedfm 5TARGET = advancedfm
6REQUIRES=medium-config 6REQUIRES=medium-config
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9DESTDIR = $(OPIEDIR)/bin 9DESTDIR = $(OPIEDIR)/bin
10LIBS += -lqpe 10LIBS += -lqpe
11 11
12TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ 12TRANSLATIONS = ../../../i18n/de/advancedfm.ts \
13 ../../../i18n/en/advancedfm.ts \ 13 ../../../i18n/en/advancedfm.ts \
14 ../../../i18n/es/advancedfm.ts \ 14 ../../../i18n/es/advancedfm.ts \
15 ../../../i18n/fr/advancedfm.ts \ 15 ../../../i18n/fr/advancedfm.ts \
16 ../../../i18n/hu/advancedfm.ts \ 16 ../../../i18n/hu/advancedfm.ts \
17 ../../../i18n/ja/advancedfm.ts \ 17 ../../../i18n/ja/advancedfm.ts \
18 ../../../i18n/ko/advancedfm.ts \ 18 ../../../i18n/ko/advancedfm.ts \
19 ../../../i18n/no/advancedfm.ts \ 19 ../../../i18n/no/advancedfm.ts \
20 ../../../i18n/pl/advancedfm.ts \ 20 ../../../i18n/pl/advancedfm.ts \
21 ../../../i18n/pt/advancedfm.ts \ 21 ../../../i18n/pt/advancedfm.ts \
22 ../../../i18n/pt_BR/advancedfm.ts \ 22 ../../../i18n/pt_BR/advancedfm.ts \
23 ../../../i18n/sl/advancedfm.ts \ 23 ../../../i18n/sl/advancedfm.ts \
24 ../../../i18n/zh_CN/advancedfm.ts \ 24 ../../../i18n/zh_CN/advancedfm.ts \
25 ../../../i18n/zh_TW/advancedfm.ts 25 ../../../i18n/zh_TW/advancedfm.ts
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
new file mode 100644
index 0000000..a4f4d59
--- a/dev/null
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -0,0 +1,236 @@
1/***************************************************************************
2 advancedfmData.cpp
3 -------------------
4** Created: Mon 09-23-2002 13:24:11
5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 ***************************************************************************/
12#include "advancedfm.h"
13
14#include <qpe/qpeapplication.h>
15#include <qpe/qpemenubar.h>
16#include <qpe/qpetoolbar.h>
17#include <qpe/resource.h>
18
19#include <qlayout.h>
20#include <qpixmap.h>
21#include <qcombobox.h>
22#include <qpopupmenu.h>
23#include <qtabwidget.h>
24#include <qtoolbutton.h>
25#include <qtabwidget.h>
26#include <qlineedit.h>
27#include <qlistview.h>
28
29#include <sys/utsname.h>
30
31
32void AdvancedFm::init() {
33
34 setCaption( tr( "AdvancedFm" ) );
35
36 QGridLayout *layout = new QGridLayout( this );
37 layout->setSpacing( 2);
38 layout->setMargin( 2);
39
40
41 QPEMenuBar *menuBar = new QPEMenuBar(this);
42 fileMenu = new QPopupMenu( this );
43 viewMenu = new QPopupMenu( this );
44
45 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 );
46
47 menuBar->insertItem( tr( "File" ), fileMenu);
48 menuBar->insertItem( tr( "View" ), viewMenu);
49
50 qpeDirButton= new QToolButton(this,"QPEButton");
51 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton");
52 qpeDirButton ->setFixedSize( QSize( 20, 20 ) );
53 layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2);
54
55 cfButton = new QToolButton( this,"CFButton");
56 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia"));
57 cfButton ->setFixedSize( QSize( 20, 20 ) );
58 layout->addMultiCellWidget( cfButton , 0, 0, 3, 3);
59
60 sdButton = new QToolButton( this,"SDButton");
61 sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard"));
62 sdButton->setFixedSize( QSize( 20, 20 ) );
63 layout->addMultiCellWidget( sdButton , 0, 0, 4, 4);
64
65 cdUpButton = new QToolButton( this,"cdUpButton");
66 cdUpButton->setPixmap(Resource::loadPixmap("up"));
67 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
68 layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5);
69
70 docButton = new QToolButton( this,"docsButton");
71 docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
72 docButton->setFixedSize( QSize( 20, 20 ) );
73 layout->addMultiCellWidget( docButton, 0, 0, 6, 6);
74
75 homeButton = new QToolButton( this,"homeButton");
76 homeButton->setPixmap(Resource::loadPixmap("home"));
77 homeButton->setFixedSize( QSize( 20, 20 ) );
78 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7);
79
80 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
81 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
82 fileMenu->insertSeparator();
83 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ));
84 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ));
85 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
86 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
87 fileMenu->insertSeparator();
88 fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
89 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
90 fileMenu->setCheckable(TRUE);
91
92 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
93 viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
94 viewMenu->insertSeparator();
95 viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
96 viewMenu->setCheckable(TRUE);
97
98
99 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
100 currentPathCombo->setEditable(TRUE);
101 layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7);
102 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
103
104 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
105
106 layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7);
107
108
109 TabWidget = new QTabWidget( this, "TabWidget" );
110 layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7);
111
112 tab = new QWidget( TabWidget, "tab" );
113 tabLayout = new QGridLayout( tab );
114 tabLayout->setSpacing( 2);
115 tabLayout->setMargin( 2);
116
117 Local_View = new QListView( tab, "Local_View" );
118 Local_View->addColumn( tr("File"),130);
119 Local_View->addColumn( tr("Size"),-1);
120 Local_View->setColumnAlignment(1,QListView::AlignRight);
121 Local_View->addColumn( tr("Date"),-1);
122 Local_View->setColumnAlignment(2,QListView::AlignRight);
123 Local_View->setAllColumnsShowFocus(TRUE);
124 Local_View->setMultiSelection( TRUE );
125 Local_View->setSelectionMode(QListView::Extended);
126
127 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
128
129 tabLayout->addWidget( Local_View, 0, 0 );
130
131 TabWidget->insertTab( tab, tr("1"));
132
133 tab_2 = new QWidget( TabWidget, "tab_2" );
134 tabLayout_2 = new QGridLayout( tab_2 );
135 tabLayout_2->setSpacing( 2);
136 tabLayout_2->setMargin( 2);
137
138 Remote_View = new QListView( tab_2, "Remote_View" );
139 Remote_View->addColumn( tr("File"),130);
140 Remote_View->addColumn( tr("Size"),-1);
141 Remote_View->setColumnAlignment(1,QListView::AlignRight);
142 Remote_View->addColumn( tr("Date"),-1);
143 Remote_View->setColumnAlignment(2,QListView::AlignRight);
144 Remote_View->setAllColumnsShowFocus(TRUE);
145 Remote_View->setMultiSelection( TRUE );
146 Remote_View->setSelectionMode(QListView::Extended);
147
148
149 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
150
151 tabLayout_2->addWidget( Remote_View, 0, 0 );
152
153
154 TabWidget->insertTab( tab_2, tr( "2"));
155
156 /* tab_3 = new QWidget( TabWidget, "tab_3" );
157 tabLayout_3 = new QGridLayout( tab_3 );
158 tabLayout_3->setSpacing( 2);
159 tabLayout_3->setMargin( 2);
160
161
162 // OFileDialog fileDialog;
163 // fileDialog;
164 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
165 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
166 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");
167
168 QListView *fileTree;
169 fileTree = new QListView( tab_3, "tree" );
170
171
172 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
173
174 TabWidget->insertTab( tab_3, tr( "Remote" ) );
175 */
176
177 ///////////////
178
179 struct utsname name; /* check for embedix kernel running on the zaurus*/
180 if (uname(&name) != -1) {
181 QString release=name.release;
182 if(release.find("embedix",0,TRUE) !=-1) {
183 zaurusDevice=TRUE;
184 } else {
185 zaurusDevice=FALSE;
186 sdButton->hide();
187 }
188 }
189
190 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
191 currentDir.setPath( QDir::currentDirPath());
192
193 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
194 currentRemoteDir.setPath( QDir::currentDirPath());
195
196 b = TRUE;
197
198 filterStr="*";
199 b=FALSE;
200
201
202
203}
204
205void AdvancedFm::initConnections() {
206 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
207 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) );
208 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) );
209 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) );
210 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
211 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
212 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
213 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
214 this, SLOT( currentPathComboActivated( const QString & ) ) );
215
216 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
217 this,SLOT(currentPathComboChanged()));
218
219 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
220 this,SLOT( localListClicked(QListViewItem *)) );
221 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
222 this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) );
223
224 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
225
226 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
227 this,SLOT( remoteListClicked(QListViewItem *)) );
228 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
229 this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) );
230
231 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
232 this,SLOT(tabChanged(QWidget*)));
233
234 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
235
236}