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