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