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