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