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