summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp37
-rw-r--r--noncore/apps/advancedfm/advancedfm.h4
2 files changed, 34 insertions, 7 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 1083f23..4289fcf 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,466 +1,468 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4** Created: Sat Mar 9 23:33:09 2002 4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties 13#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties
14 14
15#include "advancedfm.h" 15#include "advancedfm.h"
16#include "inputDialog.h" 16#include "inputDialog.h"
17#include "filePermissions.h" 17#include "filePermissions.h"
18#include "output.h" 18#include "output.h"
19 19
20#include <qpe/lnkproperties.h> 20#include <qpe/lnkproperties.h>
21#include <qpe/filemanager.h> 21#include <qpe/filemanager.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpemenubar.h> 23#include <qpe/qpemenubar.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#include <qpe/mimetype.h> 29#include <qpe/mimetype.h>
30#include <qpe/applnk.h> 30#include <qpe/applnk.h>
31 31
32//#include <opie/ofileselector.h> 32//#include <opie/ofileselector.h>
33#include <qmultilineedit.h> 33#include <qmultilineedit.h>
34 34
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37#include <qtoolbutton.h> 37#include <qtoolbutton.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qstring.h> 41#include <qstring.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <qpopupmenu.h> 43#include <qpopupmenu.h>
44#include <qlistview.h> 44#include <qlistview.h>
45#include <qmainwindow.h> 45#include <qmainwindow.h>
46#include <qlabel.h> 46#include <qlabel.h>
47#include <qprogressbar.h> 47#include <qprogressbar.h>
48#include <qspinbox.h> 48#include <qspinbox.h>
49#include <qtabwidget.h> 49#include <qtabwidget.h>
50#include <qwidget.h> 50#include <qwidget.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qimage.h> 52#include <qimage.h>
53#include <qpixmap.h> 53#include <qpixmap.h>
54#include <qmessagebox.h> 54#include <qmessagebox.h>
55#include <qlineedit.h> 55#include <qlineedit.h>
56#include <qregexp.h> 56#include <qregexp.h>
57 57
58#include <unistd.h> 58#include <unistd.h>
59#include <stdlib.h> 59#include <stdlib.h>
60#include <sys/stat.h> 60#include <sys/stat.h>
61#include <dirent.h> 61#include <dirent.h>
62#include <stdio.h> 62#include <stdio.h>
63#include <time.h> 63#include <time.h>
64#include <fcntl.h> 64#include <fcntl.h>
65 65
66AdvancedFm::AdvancedFm( ) 66AdvancedFm::AdvancedFm( )
67 : QMainWindow( ) 67 : QMainWindow( )
68{ 68{
69 setCaption( tr( "AdvancedFm" ) ); 69 setCaption( tr( "AdvancedFm" ) );
70 70
71 QGridLayout *layout = new QGridLayout( this ); 71 QGridLayout *layout = new QGridLayout( this );
72 layout->setSpacing( 2); 72 layout->setSpacing( 2);
73 layout->setMargin( 2); 73 layout->setMargin( 2);
74 74
75 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 75 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
76 76
77 QPEMenuBar *menuBar = new QPEMenuBar(this); 77 QPEMenuBar *menuBar = new QPEMenuBar(this);
78// fileMenu = new QPopupMenu( this ); 78// fileMenu = new QPopupMenu( this );
79 fileMenu = new QPopupMenu( this ); 79 fileMenu = new QPopupMenu( this );
80 viewMenu = new QPopupMenu( this ); 80 viewMenu = new QPopupMenu( this );
81 81
82 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); 82 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 );
83 83
84 menuBar->insertItem( tr( "File" ), fileMenu); 84 menuBar->insertItem( tr( "File" ), fileMenu);
85 menuBar->insertItem( tr( "View" ), viewMenu); 85 menuBar->insertItem( tr( "View" ), viewMenu);
86 86
87 cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton"); 87 cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton");
88 cfButton ->setFixedSize( QSize( 20, 20 ) ); 88 cfButton ->setFixedSize( QSize( 20, 20 ) );
89 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); 89 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) );
90 cfButton->setFlat(TRUE); 90 cfButton->setFlat(TRUE);
91 layout->addMultiCellWidget( cfButton , 0, 0, 2, 2); 91 layout->addMultiCellWidget( cfButton , 0, 0, 2, 2);
92 92
93 sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton"); 93 sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton");
94 sdButton->setFixedSize( QSize( 20, 20 ) ); 94 sdButton->setFixedSize( QSize( 20, 20 ) );
95 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); 95 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) );
96 sdButton->setFlat(TRUE); 96 sdButton->setFlat(TRUE);
97 layout->addMultiCellWidget( sdButton , 0, 0, 3, 3); 97 layout->addMultiCellWidget( sdButton , 0, 0, 3, 3);
98 98
99 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); 99 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
100 cdUpButton ->setFixedSize( QSize( 20, 20 ) ); 100 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
101 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 101 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
102 cdUpButton ->setFlat(TRUE); 102 cdUpButton ->setFlat(TRUE);
103 layout->addMultiCellWidget( cdUpButton , 0, 0, 4, 4); 103 layout->addMultiCellWidget( cdUpButton , 0, 0, 4, 4);
104 104
105 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 105 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
106 docButton->setFixedSize( QSize( 20, 20 ) ); 106 docButton->setFixedSize( QSize( 20, 20 ) );
107 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 107 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
108 docButton->setFlat(TRUE); 108 docButton->setFlat(TRUE);
109 layout->addMultiCellWidget( docButton, 0, 0, 5, 5); 109 layout->addMultiCellWidget( docButton, 0, 0, 5, 5);
110 110
111 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); 111 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
112 homeButton->setFixedSize( QSize( 20, 20 ) ); 112 homeButton->setFixedSize( QSize( 20, 20 ) );
113 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 113 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
114 homeButton->setFlat(TRUE); 114 homeButton->setFlat(TRUE);
115 layout->addMultiCellWidget( homeButton, 0, 0, 6, 6); 115 layout->addMultiCellWidget( homeButton, 0, 0, 6, 6);
116// fileMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 116// fileMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
117// fileMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 117// fileMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
118// fileMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 118// fileMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
119 119
120 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 120 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
121 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
121 fileMenu->insertSeparator(); 122 fileMenu->insertSeparator();
122 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 123 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ));
123 fileMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 124 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ));
124 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); 125 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
125 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); 126 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
126 fileMenu->insertSeparator(); 127 fileMenu->insertSeparator();
127 fileMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 128 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
128 fileMenu->setCheckable(TRUE); 129 fileMenu->setCheckable(TRUE);
129 130
130 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 131 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
131 viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 132 viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
132 viewMenu->insertSeparator(); 133 viewMenu->insertSeparator();
133 viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); 134 viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
134 viewMenu->setCheckable(TRUE); 135 viewMenu->setCheckable(TRUE);
135 136
136 TabWidget = new QTabWidget( this, "TabWidget" ); 137 TabWidget = new QTabWidget( this, "TabWidget" );
137 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 6); 138 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 6);
138 139
139 tab = new QWidget( TabWidget, "tab" ); 140 tab = new QWidget( TabWidget, "tab" );
140 tabLayout = new QGridLayout( tab ); 141 tabLayout = new QGridLayout( tab );
141 tabLayout->setSpacing( 2); 142 tabLayout->setSpacing( 2);
142 tabLayout->setMargin( 2); 143 tabLayout->setMargin( 2);
143 144
144 Local_View = new QListView( tab, "Local_View" ); 145 Local_View = new QListView( tab, "Local_View" );
145// Local_View->setResizePolicy( QListView::AutoOneFit ); 146// Local_View->setResizePolicy( QListView::AutoOneFit );
146 Local_View->addColumn( tr("File"),130); 147 Local_View->addColumn( tr("File"),130);
147 Local_View->addColumn( tr("Size"),-1); 148 Local_View->addColumn( tr("Size"),-1);
148 Local_View->setColumnAlignment(1,QListView::AlignRight); 149 Local_View->setColumnAlignment(1,QListView::AlignRight);
149 Local_View->addColumn( tr("Date"),-1); 150 Local_View->addColumn( tr("Date"),-1);
150 Local_View->setColumnAlignment(2,QListView::AlignRight); 151 Local_View->setColumnAlignment(2,QListView::AlignRight);
151 Local_View->setAllColumnsShowFocus(TRUE); 152 Local_View->setAllColumnsShowFocus(TRUE);
152// Local_View->setMultiSelection( TRUE ); 153// Local_View->setMultiSelection( TRUE );
153// Local_View->setSelectionMode(QListView::Extended); 154// Local_View->setSelectionMode(QListView::Extended);
154 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 155 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
155 156
156 tabLayout->addWidget( Local_View, 0, 0 ); 157 tabLayout->addWidget( Local_View, 0, 0 );
157 158
158 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 159 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
159 this,SLOT( localListClicked(QListViewItem *)) ); 160 this,SLOT( localListClicked(QListViewItem *)) );
160 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 161 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
161 this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); 162 this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) );
162 163
163 TabWidget->insertTab( tab, tr("1")); 164 TabWidget->insertTab( tab, tr("1"));
164 165
165 tab_2 = new QWidget( TabWidget, "tab_2" ); 166 tab_2 = new QWidget( TabWidget, "tab_2" );
166 tabLayout_2 = new QGridLayout( tab_2 ); 167 tabLayout_2 = new QGridLayout( tab_2 );
167 tabLayout_2->setSpacing( 2); 168 tabLayout_2->setSpacing( 2);
168 tabLayout_2->setMargin( 2); 169 tabLayout_2->setMargin( 2);
169 170
170 Remote_View = new QListView( tab_2, "Remote_View" ); 171 Remote_View = new QListView( tab_2, "Remote_View" );
171 Remote_View->addColumn( tr("File"),130); 172 Remote_View->addColumn( tr("File"),130);
172 Remote_View->addColumn( tr("Size"),-1); 173 Remote_View->addColumn( tr("Size"),-1);
173 Remote_View->setColumnAlignment(1,QListView::AlignRight); 174 Remote_View->setColumnAlignment(1,QListView::AlignRight);
174 Remote_View->addColumn( tr("Date"),-1); 175 Remote_View->addColumn( tr("Date"),-1);
175 Remote_View->setColumnAlignment(2,QListView::AlignRight); 176 Remote_View->setColumnAlignment(2,QListView::AlignRight);
176 Remote_View->setAllColumnsShowFocus(TRUE); 177 Remote_View->setAllColumnsShowFocus(TRUE);
177// Remote_View->setMultiSelection( TRUE ); 178// Remote_View->setMultiSelection( TRUE );
178// Remote_View->setSelectionMode(QListView::Extended); 179// Remote_View->setSelectionMode(QListView::Extended);
179 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 180 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
180 181
181 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 182 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
182 this,SLOT( remoteListClicked(QListViewItem *)) ); 183 this,SLOT( remoteListClicked(QListViewItem *)) );
183 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 184 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
184 this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 185 this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) );
185 186
186 tabLayout_2->addWidget( Remote_View, 0, 0 ); 187 tabLayout_2->addWidget( Remote_View, 0, 0 );
187 188
188 TabWidget->insertTab( tab_2, tr( "2")); 189 TabWidget->insertTab( tab_2, tr( "2"));
189 190
190 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 191 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
191 this,SLOT(tabChanged(QWidget*))); 192 this,SLOT(tabChanged(QWidget*)));
192 193
193// tab_3 = new QWidget( TabWidget, "tab_3" ); 194// tab_3 = new QWidget( TabWidget, "tab_3" );
194// tabLayout_3 = new QGridLayout( tab_3 ); 195// tabLayout_3 = new QGridLayout( tab_3 );
195// tabLayout_3->setSpacing( 2); 196// tabLayout_3->setSpacing( 2);
196// tabLayout_3->setMargin( 2); 197// tabLayout_3->setMargin( 2);
197 198
198// OFileSelector *fileSelector; 199// OFileSelector *fileSelector;
199// fileSelector = new OFileSelector(tab_3,0,0,"/","","*"); 200// fileSelector = new OFileSelector(tab_3,0,0,"/","","*");
200// tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 ); 201// tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 );
201 202
202// TabWidget->insertTab( tab_3, tr( "Files" ) ); 203// TabWidget->insertTab( tab_3, tr( "Files" ) );
203 204
204 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 205 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
205 currentDir.setPath( QDir::currentDirPath()); 206 currentDir.setPath( QDir::currentDirPath());
206 207
207 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 208 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
208 currentRemoteDir.setPath( QDir::currentDirPath()); 209 currentRemoteDir.setPath( QDir::currentDirPath());
209 210
210 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 211b = TRUE;
212 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
211 currentPathCombo->setEditable(TRUE); 213 currentPathCombo->setEditable(TRUE);
212 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6); 214 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6);
213 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 215 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
214 216
215 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 217 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
216 this, SLOT( currentPathComboActivated( const QString & ) ) ); 218 this, SLOT( currentPathComboActivated( const QString & ) ) );
217 219
218 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 220 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
219 this,SLOT(currentPathComboChanged())); 221 this,SLOT(currentPathComboChanged()));
220 222
221 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 223 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
222 224
223 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6); 225 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6);
224 226
225 filterStr="*"; 227 filterStr="*";
226 b=FALSE; 228 b=FALSE;
227 populateLocalView(); 229 populateLocalView();
228 populateRemoteView(); 230 populateRemoteView();
229} 231}
230 232
231AdvancedFm::~AdvancedFm() 233AdvancedFm::~AdvancedFm()
232{ 234{
233} 235}
234 236
235void AdvancedFm::cleanUp() 237void AdvancedFm::cleanUp()
236{ 238{
237 QString sfile=QDir::homeDirPath(); 239 QString sfile=QDir::homeDirPath();
238 if(sfile.right(1) != "/") 240 if(sfile.right(1) != "/")
239 sfile+="/._temp"; 241 sfile+="/._temp";
240 else 242 else
241 sfile+="._temp"; 243 sfile+="._temp";
242 QFile file( sfile); 244 QFile file( sfile);
243 if(file.exists()) 245 if(file.exists())
244 file.remove(); 246 file.remove();
245} 247}
246 248
247void AdvancedFm::tabChanged(QWidget *w) 249void AdvancedFm::tabChanged(QWidget *w)
248{ 250{
249 if (TabWidget->currentPageIndex() == 0) { 251 if (TabWidget->currentPageIndex() == 0) {
250 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 252 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
251 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 253 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
252 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 254 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
253 } 255 }
254 if (TabWidget->currentPageIndex() == 1) { 256 if (TabWidget->currentPageIndex() == 1) {
255 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 257 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
256 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 258 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
257 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 259 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
258 } 260 }
259} 261}
260 262
261 263
262void AdvancedFm::populateLocalView() 264void AdvancedFm::populateLocalView()
263{ 265{
264// QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 266// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
265// QListViewItemIterator it( Local_View ); 267// QListViewItemIterator it( Local_View );
266// for ( ; it.current(); ++it ) { 268// for ( ; it.current(); ++it ) {
267// if ( it.current()->isSelected() ) { 269// if ( it.current()->isSelected() ) {
268// QString strItem = it.current()->text(0); 270// QString strItem = it.current()->text(0);
269// QString localFile = currentDir.canonicalPath()+"/"+strItem; 271// QString localFile = currentDir.canonicalPath()+"/"+strItem;
270// QFileInfo fi(localFile); 272// QFileInfo fi(localFile);
271// } 273// }
272// } 274// }
273 QPixmap pm; 275 QPixmap pm;
274 Local_View->clear(); 276 Local_View->clear();
275 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 277 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
276 currentDir.setMatchAllDirs(TRUE); 278 currentDir.setMatchAllDirs(TRUE);
277 currentDir.setNameFilter(filterStr); 279 currentDir.setNameFilter(filterStr);
278 QString fileL, fileS, fileDate; 280 QString fileL, fileS, fileDate;
279// qDebug(currentDir.canonicalPath()); 281// qDebug(currentDir.canonicalPath());
280 282
281 bool isDir=FALSE; 283 bool isDir=FALSE;
282 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 284 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
283 QFileInfoListIterator it(*list); 285 QFileInfoListIterator it(*list);
284 QFileInfo *fi; 286 QFileInfo *fi;
285 while ( (fi=it.current()) ) { 287 while ( (fi=it.current()) ) {
286 if (fi->isSymLink() ) { 288 if (fi->isSymLink() ) {
287 QString symLink=fi->readLink(); 289 QString symLink=fi->readLink();
288// qDebug("Symlink detected "+symLink); 290// qDebug("Symlink detected "+symLink);
289 QFileInfo sym( symLink); 291 QFileInfo sym( symLink);
290 fileS.sprintf( "%10li", sym.size() ); 292 fileS.sprintf( "%10li", sym.size() );
291 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 293 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
292 fileDate = sym.lastModified().toString(); 294 fileDate = sym.lastModified().toString();
293 } else { 295 } else {
294 fileS.sprintf( "%10li", fi->size() ); 296 fileS.sprintf( "%10li", fi->size() );
295 fileL.sprintf( "%s",fi->fileName().data() ); 297 fileL.sprintf( "%s",fi->fileName().data() );
296 fileDate= fi->lastModified().toString(); 298 fileDate= fi->lastModified().toString();
297 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 299 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
298 fileL+="/"; 300 fileL+="/";
299 isDir=TRUE; 301 isDir=TRUE;
300// qDebug( fileL); 302// qDebug( fileL);
301 } 303 }
302 } 304 }
303 if(fileL !="./" && fi->exists()) { 305 if(fileL !="./" && fi->exists()) {
304 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 306 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
305 307
306 if(isDir || fileL.find("/",0,TRUE) != -1) { 308 if(isDir || fileL.find("/",0,TRUE) != -1) {
307 if( !QDir( fi->filePath() ).isReadable()) 309 if( !QDir( fi->filePath() ).isReadable())
308 pm = Resource::loadPixmap( "lockedfolder" ); 310 pm = Resource::loadPixmap( "lockedfolder" );
309 else 311 else
310 pm= Resource::loadPixmap( "folder" ); 312 pm= Resource::loadPixmap( "folder" );
311 item->setPixmap( 0,pm ); 313 item->setPixmap( 0,pm );
312 } else { 314 } else {
313 if( !fi->isReadable() ) 315 if( !fi->isReadable() )
314 pm = Resource::loadPixmap( "locked" ); 316 pm = Resource::loadPixmap( "locked" );
315 else { 317 else {
316 MimeType mt(fi->filePath()); 318 MimeType mt(fi->filePath());
317 pm=mt.pixmap(); //sets the correct pixmap for mimetype 319 pm=mt.pixmap(); //sets the correct pixmap for mimetype
318 if(pm.isNull()) 320 if(pm.isNull())
319 pm = Resource::loadPixmap( "UnknownDocument-14" ); 321 pm = Resource::loadPixmap( "UnknownDocument-14" );
320 item->setPixmap( 0,pm); 322 item->setPixmap( 0,pm);
321 } 323 }
322 } 324 }
323 if( fileL.find("->",0,TRUE) != -1) { 325 if( fileL.find("->",0,TRUE) != -1) {
324 // overlay link image 326 // overlay link image
325 pm= Resource::loadPixmap( "folder" ); 327 pm= Resource::loadPixmap( "folder" );
326 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 328 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
327 QPainter painter( &pm ); 329 QPainter painter( &pm );
328 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 330 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
329 pm.setMask( pm.createHeuristicMask( FALSE ) ); 331 pm.setMask( pm.createHeuristicMask( FALSE ) );
330 item->setPixmap( 0, pm); 332 item->setPixmap( 0, pm);
331 } 333 }
332 } isDir=FALSE; 334 } isDir=FALSE;
333 ++it; 335 ++it;
334 } 336 }
335 337
336 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 338 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
337 struct stat buf; 339 struct stat buf;
338 struct stat st; 340 struct stat st;
339 dev_t devT; 341 dev_t devT;
340 mode_t mode; 342 mode_t mode;
341 DIR *dir; 343 DIR *dir;
342 int fd = 0; 344 int fd = 0;
343 struct dirent *mydirent; 345 struct dirent *mydirent;
344 int i = 1; 346 int i = 1;
345 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 347 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
346 while ((mydirent = readdir(dir)) != NULL) { 348 while ((mydirent = readdir(dir)) != NULL) {
347 lstat( mydirent->d_name, &buf); 349 lstat( mydirent->d_name, &buf);
348 qDebug(mydirent->d_name); 350 qDebug(mydirent->d_name);
349// mode = buf.st_mode; 351// mode = buf.st_mode;
350 fileL.sprintf("%s", mydirent->d_name); 352 fileL.sprintf("%s", mydirent->d_name);
351// fileS.sprintf("%d, %d", ); //this isn't correct 353// fileS.sprintf("%d, %d", ); //this isn't correct
352 devT = buf.st_dev; 354 devT = buf.st_dev;
353 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 355 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
354// fileS.sprintf("%d,%d", devT, devT); 356// fileS.sprintf("%d,%d", devT, devT);
355 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 357 fileDate.sprintf("%s", ctime( &buf.st_mtime));
356 if( fileL.find(".") == -1 ){ 358 if( fileL.find(".") == -1 ){
357 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 359 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
358 pm = Resource::loadPixmap( "UnknownDocument-14" ); 360 pm = Resource::loadPixmap( "UnknownDocument-14" );
359 item->setPixmap( 0,pm); 361 item->setPixmap( 0,pm);
360 } 362 }
361 } 363 }
362 364
363 closedir(dir); 365 closedir(dir);
364 } 366 }
365 367
366 Local_View->setSorting( 3,FALSE); 368 Local_View->setSorting( 3,FALSE);
367 fillCombo( (const QString &) currentDir.canonicalPath()); 369 fillCombo( (const QString &) currentDir.canonicalPath());
368} 370}
369 371
370void AdvancedFm::populateRemoteView() 372void AdvancedFm::populateRemoteView()
371{ 373{
372// QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 374// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
373// QListViewItemIterator it( Remote_View ); 375// QListViewItemIterator it( Remote_View );
374// for ( ; it.current(); ++it ) { 376// for ( ; it.current(); ++it ) {
375// if ( it.current()->isSelected() ) { 377// if ( it.current()->isSelected() ) {
376// QString strItem = it.current()->text(0); 378// QString strItem = it.current()->text(0);
377// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; 379// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem;
378// QFileInfo fi(localFile); 380// QFileInfo fi(localFile);
379// } 381// }
380// } 382// }
381 QPixmap pm; 383 QPixmap pm;
382 Remote_View->clear(); 384 Remote_View->clear();
383 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 385 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
384 currentRemoteDir.setMatchAllDirs(TRUE); 386 currentRemoteDir.setMatchAllDirs(TRUE);
385 currentRemoteDir.setNameFilter(filterStr); 387 currentRemoteDir.setNameFilter(filterStr);
386 QString fileL, fileS, fileDate; 388 QString fileL, fileS, fileDate;
387 bool isDir=FALSE; 389 bool isDir=FALSE;
388 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 390 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
389 QFileInfoListIterator it(*list); 391 QFileInfoListIterator it(*list);
390 QFileInfo *fi; 392 QFileInfo *fi;
391 while ( (fi=it.current()) ) { 393 while ( (fi=it.current()) ) {
392 if (fi->isSymLink() ){ 394 if (fi->isSymLink() ){
393 QString symLink=fi->readLink(); 395 QString symLink=fi->readLink();
394// qDebug("Symlink detected "+symLink); 396// qDebug("Symlink detected "+symLink);
395 QFileInfo sym( symLink); 397 QFileInfo sym( symLink);
396 fileS.sprintf( "%10li", sym.size() ); 398 fileS.sprintf( "%10li", sym.size() );
397 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 399 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
398 fileDate = sym.lastModified().toString(); 400 fileDate = sym.lastModified().toString();
399 } else { 401 } else {
400// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 402// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
401 fileS.sprintf( "%10li", fi->size() ); 403 fileS.sprintf( "%10li", fi->size() );
402 fileL.sprintf( "%s",fi->fileName().data() ); 404 fileL.sprintf( "%s",fi->fileName().data() );
403 fileDate= fi->lastModified().toString(); 405 fileDate= fi->lastModified().toString();
404 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 406 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
405 fileL+="/"; 407 fileL+="/";
406 isDir=TRUE; 408 isDir=TRUE;
407// qDebug( fileL); 409// qDebug( fileL);
408 } 410 }
409 } 411 }
410 if(fileL !="./" && fi->exists()) { 412 if(fileL !="./" && fi->exists()) {
411 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 413 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
412 QPixmap pm; 414 QPixmap pm;
413 415
414 if(isDir || fileL.find("/",0,TRUE) != -1) { 416 if(isDir || fileL.find("/",0,TRUE) != -1) {
415 if( !QDir( fi->filePath() ).isReadable()) 417 if( !QDir( fi->filePath() ).isReadable())
416 pm = Resource::loadPixmap( "lockedfolder" ); 418 pm = Resource::loadPixmap( "lockedfolder" );
417 else 419 else
418 pm= Resource::loadPixmap( "folder" ); 420 pm= Resource::loadPixmap( "folder" );
419 item->setPixmap( 0,pm ); 421 item->setPixmap( 0,pm );
420 } else { 422 } else {
421 if( !fi->isReadable() ) 423 if( !fi->isReadable() )
422 pm = Resource::loadPixmap( "locked" ); 424 pm = Resource::loadPixmap( "locked" );
423 else { 425 else {
424 MimeType mt(fi->filePath()); 426 MimeType mt(fi->filePath());
425 pm=mt.pixmap(); //sets the correct pixmap for mimetype 427 pm=mt.pixmap(); //sets the correct pixmap for mimetype
426 if(pm.isNull()) 428 if(pm.isNull())
427 pm = Resource::loadPixmap( "UnknownDocument-14" ); 429 pm = Resource::loadPixmap( "UnknownDocument-14" );
428 item->setPixmap( 0,pm); 430 item->setPixmap( 0,pm);
429 } 431 }
430 } 432 }
431 if( fileL.find("->",0,TRUE) != -1) { 433 if( fileL.find("->",0,TRUE) != -1) {
432 // overlay link image 434 // overlay link image
433 pm= Resource::loadPixmap( "folder" ); 435 pm= Resource::loadPixmap( "folder" );
434 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 436 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
435 QPainter painter( &pm ); 437 QPainter painter( &pm );
436 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 438 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
437 pm.setMask( pm.createHeuristicMask( FALSE ) ); 439 pm.setMask( pm.createHeuristicMask( FALSE ) );
438 item->setPixmap( 0, pm); 440 item->setPixmap( 0, pm);
439 } 441 }
440 } isDir=FALSE; 442 } isDir=FALSE;
441 ++it; 443 ++it;
442 } 444 }
443 445
444 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 446 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
445 struct stat buf; 447 struct stat buf;
446 struct stat st; 448 struct stat st;
447 mode_t mode; 449 mode_t mode;
448 DIR *dir; 450 DIR *dir;
449 int fd = 0; 451 int fd = 0;
450 struct dirent *mydirent; 452 struct dirent *mydirent;
451 int i = 1; 453 int i = 1;
452 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 454 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
453 while ((mydirent = readdir(dir)) != NULL) { 455 while ((mydirent = readdir(dir)) != NULL) {
454 lstat( mydirent->d_name, &buf); 456 lstat( mydirent->d_name, &buf);
455 qDebug(mydirent->d_name); 457 qDebug(mydirent->d_name);
456// mode = buf.st_mode; 458// mode = buf.st_mode;
457 fileL.sprintf("%s", mydirent->d_name); 459 fileL.sprintf("%s", mydirent->d_name);
458// fileS.sprintf("%d, %d", ); //this isn't correct 460// fileS.sprintf("%d, %d", ); //this isn't correct
459 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 461 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
460 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 462 fileDate.sprintf("%s", ctime( &buf.st_mtime));
461 if( fileL.find(".") == -1 ){ 463 if( fileL.find(".") == -1 ){
462 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 464 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
463 pm = Resource::loadPixmap( "UnknownDocument-14" ); 465 pm = Resource::loadPixmap( "UnknownDocument-14" );
464 item->setPixmap( 0,pm); 466 item->setPixmap( 0,pm);
465 } 467 }
466 } 468 }
@@ -1009,262 +1011,285 @@ void AdvancedFm::upDir()
1009{ 1011{
1010 if (TabWidget->currentPageIndex() == 0) { 1012 if (TabWidget->currentPageIndex() == 0) {
1011 QString current = currentDir.canonicalPath(); 1013 QString current = currentDir.canonicalPath();
1012 QDir dir(current); 1014 QDir dir(current);
1013 dir.cdUp(); 1015 dir.cdUp();
1014 current = dir.canonicalPath(); 1016 current = dir.canonicalPath();
1015 chdir( current.latin1() ); 1017 chdir( current.latin1() );
1016 currentDir.cd( current, TRUE); 1018 currentDir.cd( current, TRUE);
1017 populateLocalView(); 1019 populateLocalView();
1018 update(); 1020 update();
1019 } else { 1021 } else {
1020 QString current = currentRemoteDir.canonicalPath(); 1022 QString current = currentRemoteDir.canonicalPath();
1021 QDir dir(current); 1023 QDir dir(current);
1022 dir.cdUp(); 1024 dir.cdUp();
1023 current = dir.canonicalPath(); 1025 current = dir.canonicalPath();
1024 chdir( current.latin1() ); 1026 chdir( current.latin1() );
1025 currentRemoteDir.cd( current, TRUE); 1027 currentRemoteDir.cd( current, TRUE);
1026 populateRemoteView(); 1028 populateRemoteView();
1027 update(); 1029 update();
1028 } 1030 }
1029} 1031}
1030 1032
1031void AdvancedFm::copy() 1033void AdvancedFm::copy()
1032{ 1034{
1033 QString curFile = getPath(); 1035 QString curFile = getPath();
1034 if (TabWidget->currentPageIndex() == 0) { 1036 if (TabWidget->currentPageIndex() == 0) {
1035 QString destFile = currentRemoteDir.canonicalPath()+"/"+Local_View->currentItem()->text(0); 1037 QString destFile = currentRemoteDir.canonicalPath()+"/"+Local_View->currentItem()->text(0);
1036 QFile f(destFile); 1038 QFile f(destFile);
1037 if( f.exists()) 1039 if( f.exists())
1038 f.remove(); 1040 f.remove();
1039 if(!copyFile(destFile, curFile) ) 1041 if(!copyFile(destFile, curFile) )
1040 qWarning("nothin doing"); 1042 qWarning("nothin doing");
1041 populateRemoteView(); 1043 populateRemoteView();
1042 TabWidget->setCurrentPage(1); 1044 TabWidget->setCurrentPage(1);
1043 } else { 1045 } else {
1044 QString destFile = currentDir.canonicalPath()+"/"+Remote_View->currentItem()->text(0); 1046 QString destFile = currentDir.canonicalPath()+"/"+Remote_View->currentItem()->text(0);
1045 QFile f(destFile); 1047 QFile f(destFile);
1046 if( f.exists()) 1048 if( f.exists())
1047 f.remove(); 1049 f.remove();
1048 if(!copyFile(destFile, curFile) ) 1050 if(!copyFile(destFile, curFile) )
1049 qWarning("nothin doing"); 1051 qWarning("nothin doing");
1050 populateLocalView(); 1052 populateLocalView();
1051 TabWidget->setCurrentPage(0); 1053 TabWidget->setCurrentPage(0);
1052 } 1054 }
1053} 1055}
1054 1056
1055void AdvancedFm::copyAs() 1057void AdvancedFm::copyAs()
1056{ 1058{
1057 QString curFile = getPath(); 1059 QString curFile = getPath();
1058 if (TabWidget->currentPageIndex() == 0) { 1060 if (TabWidget->currentPageIndex() == 0) {
1059 QString destFile = Local_View->currentItem()->text(0); 1061 QString destFile = Local_View->currentItem()->text(0);
1060 InputDialog *fileDlg; 1062 InputDialog *fileDlg;
1061 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1063 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1062 fileDlg->setInputText((const QString &) destFile ); 1064 fileDlg->setInputText((const QString &) destFile );
1063 fileDlg->exec(); 1065 fileDlg->exec();
1064 if( fileDlg->result() == 1 ) { 1066 if( fileDlg->result() == 1 ) {
1065 QString filename = fileDlg->LineEdit1->text(); 1067 QString filename = fileDlg->LineEdit1->text();
1066 destFile = currentRemoteDir.canonicalPath()+"/"+destFile; 1068 destFile = currentRemoteDir.canonicalPath()+"/"+destFile;
1067 1069
1068 QFile f(destFile); 1070 QFile f(destFile);
1069 if( f.exists()) 1071 if( f.exists())
1070 f.remove(); 1072 f.remove();
1071 if(!copyFile(destFile, curFile) ) 1073 if(!copyFile(destFile, curFile) )
1072 qWarning("nothin doing"); 1074 qWarning("nothin doing");
1073 } 1075 }
1074 populateRemoteView(); 1076 populateRemoteView();
1075 TabWidget->setCurrentPage(1); 1077 TabWidget->setCurrentPage(1);
1076 } else { 1078 } else {
1077 QString destFile = Remote_View->currentItem()->text(0); 1079 QString destFile = Remote_View->currentItem()->text(0);
1078 InputDialog *fileDlg; 1080 InputDialog *fileDlg;
1079 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1081 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1080 fileDlg->setInputText((const QString &) destFile); 1082 fileDlg->setInputText((const QString &) destFile);
1081 fileDlg->exec(); 1083 fileDlg->exec();
1082 if( fileDlg->result() == 1 ) { 1084 if( fileDlg->result() == 1 ) {
1083 QString filename = fileDlg->LineEdit1->text(); 1085 QString filename = fileDlg->LineEdit1->text();
1084 destFile = currentDir.canonicalPath()+"/"+destFile; 1086 destFile = currentDir.canonicalPath()+"/"+destFile;
1085 1087
1086 QFile f(destFile); 1088 QFile f(destFile);
1087 if( f.exists()) 1089 if( f.exists())
1088 f.remove(); 1090 f.remove();
1089 if(!copyFile(destFile, curFile) ) 1091 if(!copyFile(destFile, curFile) )
1090 qWarning("nothin doing"); 1092 qWarning("nothin doing");
1091 } 1093 }
1092 populateLocalView(); 1094 populateLocalView();
1093 TabWidget->setCurrentPage(0); 1095 TabWidget->setCurrentPage(0);
1094 } 1096 }
1095} 1097}
1096 1098
1097void AdvancedFm::move() { 1099void AdvancedFm::move() {
1098 QString curFile = getPath(); 1100 QString curFile = getPath();
1099// qDebug(curFile); 1101// qDebug(curFile);
1100 QString destFile; 1102 QString destFile;
1101 if (TabWidget->currentPageIndex() == 0) { 1103 if (TabWidget->currentPageIndex() == 0) {
1102 QString destFile = currentRemoteDir.canonicalPath() + "/" + Local_View->currentItem()->text(0); 1104 QString destFile = currentRemoteDir.canonicalPath() + "/" + Local_View->currentItem()->text(0);
1103 qDebug("Destination file is "+destFile); 1105 qDebug("Destination file is "+destFile);
1104 1106
1105 QFile f(destFile); 1107 QFile f(destFile);
1106 if( f.exists()) 1108 if( f.exists())
1107 f.remove(); 1109 f.remove();
1108 if(!copyFile( destFile, curFile) ) { 1110 if(!copyFile( destFile, curFile) ) {
1109 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); 1111 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile));
1110 return; 1112 return;
1111 } 1113 }
1112 QFile::remove(curFile); 1114 QFile::remove(curFile);
1113 TabWidget->setCurrentPage(1); 1115 TabWidget->setCurrentPage(1);
1114 } else { 1116 } else {
1115 QString destFile = currentDir.canonicalPath() + "/" + Remote_View->currentItem()->text(0); 1117 QString destFile = currentDir.canonicalPath() + "/" + Remote_View->currentItem()->text(0);
1116 qDebug("Destination file is "+destFile); 1118 qDebug("Destination file is "+destFile);
1117 1119
1118 QFile f(destFile); 1120 QFile f(destFile);
1119 if( f.exists()) 1121 if( f.exists())
1120 f.remove(); 1122 f.remove();
1121 if(!copyFile(destFile, curFile) ) { 1123 if(!copyFile(destFile, curFile) ) {
1122 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); 1124 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile));
1123 return; 1125 return;
1124 } 1126 }
1125 QFile::remove(curFile); 1127 QFile::remove(curFile);
1126 TabWidget->setCurrentPage(0); 1128 TabWidget->setCurrentPage(0);
1127 } 1129 }
1128 populateRemoteView(); 1130 populateRemoteView();
1129 populateLocalView(); 1131 populateLocalView();
1130} 1132}
1131 1133
1132bool AdvancedFm::copyFile( const QString & dest, const QString & src ) 1134bool AdvancedFm::copyFile( const QString & dest, const QString & src )
1133{ 1135{
1134 char bf[ 50000 ]; 1136 char bf[ 50000 ];
1135 int bytesRead; 1137 int bytesRead;
1136 bool success = TRUE; 1138 bool success = TRUE;
1137 struct stat status; 1139 struct stat status;
1138 1140
1139 QFile s( src ); 1141 QFile s( src );
1140 QFile d( dest ); 1142 QFile d( dest );
1141 1143
1142 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 1144 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
1143 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 1145 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
1144 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 1146 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
1145 success = FALSE; 1147 success = FALSE;
1146 break; 1148 break;
1147 } 1149 }
1148 } 1150 }
1149 if( success && (bytesRead > 0) ){ 1151 if( success && (bytesRead > 0) ){
1150 d.writeBlock( bf, bytesRead ); 1152 d.writeBlock( bf, bytesRead );
1151 } 1153 }
1152 } else { 1154 } else {
1153 success = FALSE; 1155 success = FALSE;
1154 } 1156 }
1155 1157
1156 // Set file permissions 1158 // Set file permissions
1157 if( stat( (const char *) src, &status ) == 0 ){ 1159 if( stat( (const char *) src, &status ) == 0 ){
1158 chmod( (const char *) dest, status.st_mode ); 1160 chmod( (const char *) dest, status.st_mode );
1159 } 1161 }
1160 1162
1161 return success; 1163 return success;
1162} 1164}
1163 1165
1164void AdvancedFm::runCommand() { 1166void AdvancedFm::runCommand() {
1165 QString curFile; 1167 QString curFile;
1166 if (TabWidget->currentPageIndex() == 0) { 1168 if (TabWidget->currentPageIndex() == 0) {
1167 if( Local_View->currentItem()) 1169 if( Local_View->currentItem())
1168 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); 1170 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0);
1169 } else { 1171 } else {
1170 if(Remote_View->currentItem()) 1172 if(Remote_View->currentItem())
1171 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); 1173 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0);
1172 } 1174 }
1173 1175
1174 InputDialog *fileDlg; 1176 InputDialog *fileDlg;
1175 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1177 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1176 fileDlg->setInputText(curFile); 1178 fileDlg->setInputText(curFile);
1177 fileDlg->exec(); 1179 fileDlg->exec();
1178 QString command; 1180 QString command;
1179 if( fileDlg->result() == 1 ) { 1181 if( fileDlg->result() == 1 ) {
1180 command = fileDlg->LineEdit1->text(); 1182 command = fileDlg->LineEdit1->text();
1181 1183
1182 int err=0; 1184 int err=0;
1183 Output *outDlg; 1185 Output *outDlg;
1184 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1186 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1185 outDlg->showMaximized(); 1187 outDlg->showMaximized();
1186 outDlg->show(); 1188 outDlg->show();
1187 qApp->processEvents(); 1189 qApp->processEvents();
1188 FILE *fp; 1190 FILE *fp;
1189 char line[130]; 1191 char line[130];
1190 sleep(1); 1192 sleep(1);
1191// if(command.find("2>",0,TRUE) != -1) 1193// if(command.find("2>",0,TRUE) != -1)
1192 command +=" 2>&1"; 1194 command +=" 2>&1";
1193 fp = popen( (const char *) command, "r"); 1195 fp = popen( (const char *) command, "r");
1194 if ( !fp ) { 1196 if ( !fp ) {
1195 qDebug("Could not execute '" + command + "'! err=%d", fp); 1197 qDebug("Could not execute '" + command + "'! err=%d", fp);
1196 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); 1198 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
1197 pclose(fp); 1199 pclose(fp);
1198 return; 1200 return;
1199 } else { 1201 } else {
1200 while ( fgets( line, sizeof line, fp)) { 1202 while ( fgets( line, sizeof line, fp)) {
1201 QString lineStr = line; 1203 QString lineStr = line;
1202 lineStr=lineStr.left(lineStr.length()-1); 1204 lineStr=lineStr.left(lineStr.length()-1);
1203 outDlg->OutputEdit->append(lineStr); 1205 outDlg->OutputEdit->append(lineStr);
1204 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1206 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1205 } 1207 }
1206 } 1208 }
1207 } 1209 }
1208} 1210}
1209 1211
1210void AdvancedFm::runCommandStd() { 1212void AdvancedFm::runCommandStd() {
1211 QString curFile; 1213 QString curFile;
1212 if (TabWidget->currentPageIndex() == 0) { 1214 if (TabWidget->currentPageIndex() == 0) {
1213 if( Local_View->currentItem()) 1215 if( Local_View->currentItem())
1214 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); 1216 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0);
1215 } else { 1217 } else {
1216 if(Remote_View->currentItem()) 1218 if(Remote_View->currentItem())
1217 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); 1219 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0);
1218 } 1220 }
1219 1221
1220 InputDialog *fileDlg; 1222 InputDialog *fileDlg;
1221 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1223 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1222 fileDlg->setInputText(curFile); 1224 fileDlg->setInputText(curFile);
1223 fileDlg->exec(); 1225 fileDlg->exec();
1224 QString command; 1226 QString command;
1225 if( fileDlg->result() == 1 ) { 1227 if( fileDlg->result() == 1 ) {
1226 qApp->processEvents(); 1228 qApp->processEvents();
1227 command = fileDlg->LineEdit1->text() + " &"; 1229 command = fileDlg->LineEdit1->text() + " &";
1228 system(command.latin1()); 1230 system(command.latin1());
1229 } 1231 }
1230} 1232}
1231 1233
1232void AdvancedFm::fileStatus() { 1234void AdvancedFm::fileStatus() {
1233 QString curFile; 1235 QString curFile;
1234 if (TabWidget->currentPageIndex() == 0) { 1236 if (TabWidget->currentPageIndex() == 0) {
1235 curFile = Local_View->currentItem()->text(0); 1237 curFile = Local_View->currentItem()->text(0);
1236 } else { 1238 } else {
1237 curFile = Remote_View->currentItem()->text(0); 1239 curFile = Remote_View->currentItem()->text(0);
1238 } 1240 }
1239 QString command = " stat -l "+ curFile +" 2>&1"; 1241 QString command = " stat -l "+ curFile +" 2>&1";
1240 int err=0; 1242 int err=0;
1241 Output *outDlg; 1243 Output *outDlg;
1242 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1244 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1243 outDlg->showMaximized(); 1245 outDlg->showMaximized();
1244 outDlg->show(); 1246 outDlg->show();
1245 qApp->processEvents(); 1247 qApp->processEvents();
1246 FILE *fp; 1248 FILE *fp;
1247 char line[130]; 1249 char line[130];
1248 sleep(1); 1250 sleep(1);
1249 fp = popen( (const char *) command, "r"); 1251 fp = popen( (const char *) command, "r");
1250 if ( !fp ) { 1252 if ( !fp ) {
1251 qDebug("Could not execute '" + command + "'! err=%d", fp); 1253 qDebug("Could not execute '" + command + "'! err=%d", fp);
1252 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); 1254 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
1253 pclose(fp); 1255 pclose(fp);
1254 return; 1256 return;
1255 } else { 1257 } else {
1256 while ( fgets( line, sizeof line, fp)) { 1258 while ( fgets( line, sizeof line, fp)) {
1257 outDlg->OutputEdit->append(line); 1259 outDlg->OutputEdit->append(line);
1258 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1260 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1259 1261
1260 } 1262 }
1261 1263
1262 } 1264 }
1263} 1265}
1264 1266
1267void AdvancedFm::mkDir() {
1268 if (TabWidget->currentPageIndex() == 0)
1269 localMakDir();
1270 else
1271 remoteMakDir();
1272
1273}
1274
1275void AdvancedFm::rn() {
1276 if (TabWidget->currentPageIndex() == 0)
1277 localRename();
1278 else
1279 remoteRename();
1280
1281}
1282
1283void AdvancedFm::del() {
1284 if (TabWidget->currentPageIndex() == 0)
1285 localDelete();
1286 else
1287 remoteDelete();
1288}
1289
1265void AdvancedFm::doAbout() { 1290void AdvancedFm::doAbout() {
1266 QMessageBox::message("AdvancedFm","Advanced FileManager\n" 1291 QMessageBox::message("AdvancedFm","Advanced FileManager\n"
1267 "is copyright 2002 by\n" 1292 "is copyright 2002 by\n"
1268 "L.J.Potter<llornkcor@handhelds.org>\n" 1293 "L.J.Potter<llornkcor@handhelds.org>\n"
1269 "and is licensed by the GPL"); 1294 "and is licensed by the GPL");
1270} 1295}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 30ff28c..a5f26a7 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -1,119 +1,121 @@
1/*************************************************************************** 1/***************************************************************************
2 opieftp.h 2 opieftp.h
3 ------------------- 3 -------------------
4** Created: Sat Mar 9 23:33:09 2002 4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#ifndef ADVANCEDFM_H 12#ifndef ADVANCEDFM_H
13#define ADVANCEDFM_H 13#define ADVANCEDFM_H
14 14
15#include <qvariant.h> 15#include <qvariant.h>
16#include <qdialog.h> 16#include <qdialog.h>
17#include <qmainwindow.h> 17#include <qmainwindow.h>
18#include <qdir.h> 18#include <qdir.h>
19#include <qstring.h> 19#include <qstring.h>
20#include <qpoint.h> 20#include <qpoint.h>
21 21
22class QVBoxLayout; 22class QVBoxLayout;
23class QHBoxLayout; 23class QHBoxLayout;
24class QGridLayout; 24class QGridLayout;
25class QComboBox; 25class QComboBox;
26class QListView; 26class QListView;
27class QListviewItem; 27class QListviewItem;
28class QLabel; 28class QLabel;
29class QProgressBar; 29class QProgressBar;
30class QSpinBox; 30class QSpinBox;
31class QTabWidget; 31class QTabWidget;
32class QWidget; 32class QWidget;
33class QPEToolBar; 33class QPEToolBar;
34class QPEMenuBar; 34class QPEMenuBar;
35class QPopupMenu; 35class QPopupMenu;
36class QFile; 36class QFile;
37class QListViewItem; 37class QListViewItem;
38class QLineEdit; 38class QLineEdit;
39class QPushButton; 39class QPushButton;
40 40
41class AdvancedFm : public QMainWindow 41class AdvancedFm : public QMainWindow
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
45 AdvancedFm(); 45 AdvancedFm();
46 ~AdvancedFm(); 46 ~AdvancedFm();
47 47
48 QTabWidget *TabWidget; 48 QTabWidget *TabWidget;
49 QWidget *tab, *tab_2, *tab_3; 49 QWidget *tab, *tab_2, *tab_3;
50 QListView *Local_View, *Remote_View; 50 QListView *Local_View, *Remote_View;
51 51
52 QLineEdit *currentPathEdit; 52 QLineEdit *currentPathEdit;
53 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; 53 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu;
54 QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton; 54 QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton;
55 QDir currentDir, currentRemoteDir; 55 QDir currentDir, currentRemoteDir;
56 QComboBox *currentPathCombo; 56 QComboBox *currentPathCombo;
57 QString filterStr; 57 QString filterStr;
58 QListViewItem * item; 58 QListViewItem * item;
59 bool b; 59 bool b;
60 int currentServerConfig; 60 int currentServerConfig;
61protected slots: 61protected slots:
62 void showLocalMenu( QListViewItem *); 62 void showLocalMenu( QListViewItem *);
63 void showRemoteMenu( QListViewItem *); 63 void showRemoteMenu( QListViewItem *);
64 void doLocalCd(); 64 void doLocalCd();
65 void doRemoteCd(); 65 void doRemoteCd();
66// void copy(); 66// void copy();
67 67 void mkDir();
68 void del();
69 void rn();
68 void populateLocalView(); 70 void populateLocalView();
69 void populateRemoteView(); 71 void populateRemoteView();
70 void showHidden(); 72 void showHidden();
71 void showRemoteHidden(); 73 void showRemoteHidden();
72 void writeConfig(); 74 void writeConfig();
73 void readConfig(); 75 void readConfig();
74 void localListClicked(QListViewItem *); 76 void localListClicked(QListViewItem *);
75 void remoteListClicked(QListViewItem *); 77 void remoteListClicked(QListViewItem *);
76 void localListPressed( int, QListViewItem *, const QPoint&, int); 78 void localListPressed( int, QListViewItem *, const QPoint&, int);
77 void remoteListPressed( int, QListViewItem *, const QPoint&, int); 79 void remoteListPressed( int, QListViewItem *, const QPoint&, int);
78 void localMakDir(); 80 void localMakDir();
79 void localDelete(); 81 void localDelete();
80 void remoteMakDir(); 82 void remoteMakDir();
81 void remoteDelete(); 83 void remoteDelete();
82/* bool remoteDirList(const QString &); */ 84/* bool remoteDirList(const QString &); */
83/* bool remoteChDir(const QString &); */ 85/* bool remoteChDir(const QString &); */
84 void tabChanged(QWidget*); 86 void tabChanged(QWidget*);
85 void cleanUp(); 87 void cleanUp();
86 void remoteRename(); 88 void remoteRename();
87 void localRename(); 89 void localRename();
88 void runThis(); 90 void runThis();
89 void runText(); 91 void runText();
90 void filePerms(); 92 void filePerms();
91 void doProperties(); 93 void doProperties();
92 void runCommand(); 94 void runCommand();
93 void runCommandStd(); 95 void runCommandStd();
94 QString getPath(); 96 QString getPath();
95 void switchToLocalTab(); 97 void switchToLocalTab();
96 void switchToRemoteTab(); 98 void switchToRemoteTab();
97 99
98protected: 100protected:
99 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 101 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
100 QStringList remoteDirPathStringList, localDirPathStringList; 102 QStringList remoteDirPathStringList, localDirPathStringList;
101 103
102protected slots: 104protected slots:
103 void homeButtonPushed(); 105 void homeButtonPushed();
104 void docButtonPushed(); 106 void docButtonPushed();
105 void SDButtonPushed(); 107 void SDButtonPushed();
106 void CFButtonPushed(); 108 void CFButtonPushed();
107 void upDir(); 109 void upDir();
108 void currentPathComboChanged(); 110 void currentPathComboChanged();
109 void copy(); 111 void copy();
110 void copyAs(); 112 void copyAs();
111 void currentPathComboActivated(const QString &); 113 void currentPathComboActivated(const QString &);
112 void fillCombo(const QString &); 114 void fillCombo(const QString &);
113 bool copyFile( const QString & , const QString & ); 115 bool copyFile( const QString & , const QString & );
114 void move(); 116 void move();
115 void fileStatus(); 117 void fileStatus();
116 void doAbout(); 118 void doAbout();
117}; 119};
118 120
119#endif // ADVANCEDFM_H 121#endif // ADVANCEDFM_H