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