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