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