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