summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp3
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp9
2 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index a120f35..45dc0c4 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -134,151 +134,152 @@ void AdvancedFm::init() {
134// TabWidget = new QTabWidget( this, "TabWidget" ); 134// TabWidget = new QTabWidget( this, "TabWidget" );
135 layout->addWidget( TabWidget, 4 ); 135 layout->addWidget( TabWidget, 4 );
136 136
137 tab = new QWidget( TabWidget, "tab" ); 137 tab = new QWidget( TabWidget, "tab" );
138 tabLayout = new QGridLayout( tab ); 138 tabLayout = new QGridLayout( tab );
139 tabLayout->setSpacing( 2); 139 tabLayout->setSpacing( 2);
140 tabLayout->setMargin( 2); 140 tabLayout->setMargin( 2);
141 141
142 Local_View = new QListView( tab, "Local_View" ); 142 Local_View = new QListView( tab, "Local_View" );
143 Local_View->addColumn( tr("File"),130); 143 Local_View->addColumn( tr("File"),130);
144 Local_View->addColumn( tr("Size"),-1); 144 Local_View->addColumn( tr("Size"),-1);
145 Local_View->setColumnAlignment(1,QListView::AlignRight); 145 Local_View->setColumnAlignment(1,QListView::AlignRight);
146 Local_View->addColumn( tr("Date"),-1); 146 Local_View->addColumn( tr("Date"),-1);
147 Local_View->setColumnAlignment(2,QListView::AlignRight); 147 Local_View->setColumnAlignment(2,QListView::AlignRight);
148 Local_View->setAllColumnsShowFocus(TRUE); 148 Local_View->setAllColumnsShowFocus(TRUE);
149 Local_View->setMultiSelection( TRUE ); 149 Local_View->setMultiSelection( TRUE );
150 Local_View->setSelectionMode(QListView::Extended); 150 Local_View->setSelectionMode(QListView::Extended);
151 151
152 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 152 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
153 153
154 tabLayout->addWidget( Local_View, 0, 0 ); 154 tabLayout->addWidget( Local_View, 0, 0 );
155 155
156 TabWidget->addTab( tab,"advancedfm/smFileBrowser.png", tr("1")); 156 TabWidget->addTab( tab,"advancedfm/smFileBrowser.png", tr("1"));
157// TabWidget->insertTab( tab, tr("1")); 157// TabWidget->insertTab( tab, tr("1"));
158 158
159 tab_2 = new QWidget( TabWidget, "tab_2" ); 159 tab_2 = new QWidget( TabWidget, "tab_2" );
160 tabLayout_2 = new QGridLayout( tab_2 ); 160 tabLayout_2 = new QGridLayout( tab_2 );
161 tabLayout_2->setSpacing( 2); 161 tabLayout_2->setSpacing( 2);
162 tabLayout_2->setMargin( 2); 162 tabLayout_2->setMargin( 2);
163 163
164 Remote_View = new QListView( tab_2, "Remote_View" ); 164 Remote_View = new QListView( tab_2, "Remote_View" );
165 Remote_View->addColumn( tr("File"),130); 165 Remote_View->addColumn( tr("File"),130);
166 Remote_View->addColumn( tr("Size"),-1); 166 Remote_View->addColumn( tr("Size"),-1);
167 Remote_View->setColumnAlignment(1,QListView::AlignRight); 167 Remote_View->setColumnAlignment(1,QListView::AlignRight);
168 Remote_View->addColumn( tr("Date"),-1); 168 Remote_View->addColumn( tr("Date"),-1);
169 Remote_View->setColumnAlignment(2,QListView::AlignRight); 169 Remote_View->setColumnAlignment(2,QListView::AlignRight);
170 Remote_View->setAllColumnsShowFocus(TRUE); 170 Remote_View->setAllColumnsShowFocus(TRUE);
171 Remote_View->setMultiSelection( TRUE ); 171 Remote_View->setMultiSelection( TRUE );
172 Remote_View->setSelectionMode(QListView::Extended); 172 Remote_View->setSelectionMode(QListView::Extended);
173 173
174 174
175 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 175 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
176 176
177 tabLayout_2->addWidget( Remote_View, 0, 0 ); 177 tabLayout_2->addWidget( Remote_View, 0, 0 );
178 178
179 TabWidget->addTab( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); 179 TabWidget->addTab( tab_2, "advancedfm/smFileBrowser.png",tr( "2"));
180// TabWidget->insertTab( tab_2, tr( "2")); 180// TabWidget->insertTab( tab_2, tr( "2"));
181 181
182 /* tab_3 = new QWidget( TabWidget, "tab_3" ); 182 /* tab_3 = new QWidget( TabWidget, "tab_3" );
183 tabLayout_3 = new QGridLayout( tab_3 ); 183 tabLayout_3 = new QGridLayout( tab_3 );
184 tabLayout_3->setSpacing( 2); 184 tabLayout_3->setSpacing( 2);
185 tabLayout_3->setMargin( 2); 185 tabLayout_3->setMargin( 2);
186 186
187 187
188 // OFileDialog fileDialog; 188 // OFileDialog fileDialog;
189 // fileDialog; 189 // fileDialog;
190 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy 190 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
191 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); 191 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
192 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); 192 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");
193 193
194 QListView *fileTree; 194 QListView *fileTree;
195 fileTree = new QListView( tab_3, "tree" ); 195 fileTree = new QListView( tab_3, "tree" );
196 196
197 197
198 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); 198 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
199 199
200 TabWidget->insertTab( tab_3, tr( "Remote" ) ); 200 TabWidget->insertTab( tab_3, tr( "Remote" ) );
201 */ 201 */
202 202
203 /////////////// 203 ///////////////
204 204
205 205
206 struct utsname name; /* check for embedix kernel running on the zaurus*/ 206 struct utsname name; /* check for embedix kernel running on the zaurus*/
207 if (uname(&name) != -1) { 207 if (uname(&name) != -1) {
208 QString release=name.release; 208 QString release=name.release;
209 if(release.find("embedix",0,TRUE) !=-1) { 209 if(release.find("embedix",0,TRUE) !=-1) {
210 zaurusDevice=TRUE; 210 zaurusDevice=TRUE;
211 } else { 211 } else {
212 zaurusDevice=FALSE; 212 zaurusDevice=FALSE;
213 } 213 }
214 } 214 }
215 215
216 if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { 216 if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) {
217 qDebug("not have sd"); 217 qDebug("not have sd");
218 sdButton->hide(); 218 sdButton->hide();
219 } 219 }
220 if( !StorageInfo::hasCf() ) { 220 if( !StorageInfo::hasCf() ) {
221 qDebug("not have cf"); 221 qDebug("not have cf");
222 cfButton->hide(); 222 cfButton->hide();
223 } 223 }
224 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 224 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
225 currentDir.setPath( QDir::currentDirPath()); 225 currentDir.setPath( QDir::currentDirPath());
226 226
227 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 227 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
228 currentRemoteDir.setPath( QDir::currentDirPath()); 228 currentRemoteDir.setPath( QDir::currentDirPath());
229 229
230 b = TRUE; 230 // b = TRUE;
231 231
232 filterStr="*"; 232 filterStr="*";
233 b=FALSE; 233 b=FALSE;
234 showMenuHidden();
234 TabWidget->setCurrentTab(0); 235 TabWidget->setCurrentTab(0);
235 236
236} 237}
237 238
238void AdvancedFm::initConnections() 239void AdvancedFm::initConnections()
239{ 240{
240 241
241 connect( qApp,SIGNAL( aboutToQuit()), 242 connect( qApp,SIGNAL( aboutToQuit()),
242 this, SLOT( cleanUp()) ); 243 this, SLOT( cleanUp()) );
243 connect( qpeDirButton ,SIGNAL(released()), 244 connect( qpeDirButton ,SIGNAL(released()),
244 this,SLOT( QPEButtonPushed()) ); 245 this,SLOT( QPEButtonPushed()) );
245 connect( cfButton ,SIGNAL(released()), 246 connect( cfButton ,SIGNAL(released()),
246 this,SLOT( CFButtonPushed()) ); 247 this,SLOT( CFButtonPushed()) );
247 connect( sdButton ,SIGNAL(released()), 248 connect( sdButton ,SIGNAL(released()),
248 this,SLOT( SDButtonPushed()) ); 249 this,SLOT( SDButtonPushed()) );
249 connect( cdUpButton ,SIGNAL(released()), 250 connect( cdUpButton ,SIGNAL(released()),
250 this,SLOT( upDir()) ); 251 this,SLOT( upDir()) );
251 connect( docButton,SIGNAL(released()), 252 connect( docButton,SIGNAL(released()),
252 this,SLOT( docButtonPushed()) ); 253 this,SLOT( docButtonPushed()) );
253 connect( homeButton,SIGNAL(released()), 254 connect( homeButton,SIGNAL(released()),
254 this,SLOT( homeButtonPushed()) ); 255 this,SLOT( homeButtonPushed()) );
255 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 256 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
256 this, SLOT( currentPathComboActivated( const QString & ) ) ); 257 this, SLOT( currentPathComboActivated( const QString & ) ) );
257 258
258 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 259 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
259 this,SLOT(currentPathComboChanged())); 260 this,SLOT(currentPathComboChanged()));
260 261
261 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 262 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
262 this,SLOT( ListClicked(QListViewItem *)) ); 263 this,SLOT( ListClicked(QListViewItem *)) );
263 264
264 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 265 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
265 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 266 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
266 267
267 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); 268 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
268 269
269 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 270 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
270 this,SLOT( ListClicked(QListViewItem *)) ); 271 this,SLOT( ListClicked(QListViewItem *)) );
271 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 272 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
272 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 273 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
273 274
274 connect( TabWidget,SIGNAL(currentChanged(QWidget *)), 275 connect( TabWidget,SIGNAL(currentChanged(QWidget *)),
275 this,SLOT(tabChanged(QWidget*))); 276 this,SLOT(tabChanged(QWidget*)));
276 277
277 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); 278 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
278 279
279 connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); 280 connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&)));
280// connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); 281// connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int)));
281 282
282// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); 283// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int)));
283 284
284} 285}
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 00d0e07..544350c 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,170 +1,169 @@
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#include "advancedfm.h" 12#include "advancedfm.h"
13#include "output.h" 13#include "output.h"
14#include "filePermissions.h" 14#include "filePermissions.h"
15 15
16#include <opie/otabwidget.h> 16#include <opie/otabwidget.h>
17#include <opie/oprocess.h> 17#include <opie/oprocess.h>
18 18
19#include <qpe/lnkproperties.h> 19#include <qpe/lnkproperties.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/ir.h> 24#include <qpe/ir.h>
25 25
26#include <qmessagebox.h> 26#include <qmessagebox.h>
27#include <qmultilineedit.h> 27#include <qmultilineedit.h>
28 28
29#include <qstring.h> 29#include <qstring.h>
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qpixmap.h> 32#include <qpixmap.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtabwidget.h> 35#include <qtabwidget.h>
36#include <qtoolbutton.h> 36#include <qtoolbutton.h>
37#include <qtabwidget.h>
38#include <qlineedit.h> 37#include <qlineedit.h>
39#include <qlistview.h> 38#include <qlistview.h>
40 39
41#include <errno.h> 40#include <errno.h>
42#include <stdlib.h> 41#include <stdlib.h>
43#include <unistd.h> 42#include <unistd.h>
44#include <sys/stat.h> 43#include <sys/stat.h>
45#include <dirent.h> 44#include <dirent.h>
46#include <sys/sendfile.h> 45#include <sys/sendfile.h>
47#include <fcntl.h> 46#include <fcntl.h>
48 47
49 48
50void AdvancedFm::doDirChange() 49void AdvancedFm::doDirChange()
51{ 50{
52 ListClicked( CurrentView()->currentItem()); 51 ListClicked( CurrentView()->currentItem());
53} 52}
54 53
55void AdvancedFm::showMenuHidden() 54void AdvancedFm::showMenuHidden()
56{ 55{
57 if (b) 56 if (b)
58 { 57 {
59 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 58 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
60 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 59 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
61 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 60 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
62// b=FALSE; 61// b=FALSE;
63 62
64 } 63 }
65 else 64 else
66 { 65 {
67 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 66 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
68 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 67 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 68 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
70// b=TRUE; 69// b=TRUE;
71 } 70 }
72 rePopulate(); 71 rePopulate();
73// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); 72// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
74 if(b) b = false; else b = true; 73 b = !b;
75} 74}
76 75
77void AdvancedFm::showHidden() 76void AdvancedFm::showHidden()
78{ 77{
79 if (b) 78 if (b)
80 { 79 {
81 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
82 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 81 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
83// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 82// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
84// b=FALSE; 83// b=FALSE;
85 84
86 } 85 }
87 else 86 else
88 { 87 {
89 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 88 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
90 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 89 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
91// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 90// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
92// b=TRUE; 91// b=TRUE;
93 } 92 }
94 rePopulate(); 93 rePopulate();
95} 94}
96 95
97QString AdvancedFm::dealWithSymName(const QString &fileName) 96QString AdvancedFm::dealWithSymName(const QString &fileName)
98{ 97{
99 QString strItem = fileName; 98 QString strItem = fileName;
100 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 99 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
101} 100}
102 101
103void AdvancedFm::runThis() 102void AdvancedFm::runThis()
104{ 103{
105 QString fs; 104 QString fs;
106 QDir *thisDir = CurrentDir(); 105 QDir *thisDir = CurrentDir();
107 106
108 QString curFile = CurrentView()->currentItem()->text(0); 107 QString curFile = CurrentView()->currentItem()->text(0);
109 QString path = thisDir->canonicalPath(); 108 QString path = thisDir->canonicalPath();
110 109
111 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 110 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
112 111
113 curFile = dealWithSymName((const QString&)curFile); 112 curFile = dealWithSymName((const QString&)curFile);
114 113
115 if(curFile != "../") 114 if(curFile != "../")
116 { 115 {
117 116
118 fs = getFileSystemType((const QString &) path); 117 fs = getFileSystemType((const QString &) path);
119 QFileInfo fileInfo( path + "/" + curFile); 118 QFileInfo fileInfo( path + "/" + curFile);
120 qDebug( fileInfo.owner()); 119 qDebug( fileInfo.owner());
121 120
122 if( (fileInfo.permission( QFileInfo::ExeUser) 121 if( (fileInfo.permission( QFileInfo::ExeUser)
123 | fileInfo.permission( QFileInfo::ExeGroup) 122 | fileInfo.permission( QFileInfo::ExeGroup)
124 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 123 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
125 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 124 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
126 QCopEnvelope e("QPE/System", "execute(QString)" ); 125 QCopEnvelope e("QPE/System", "execute(QString)" );
127 e << curFile; 126 e << curFile;
128 } 127 }
129 else 128 else
130 { 129 {
131 curFile = path + "/" + curFile; 130 curFile = path + "/" + curFile;
132 DocLnk nf(curFile); 131 DocLnk nf(curFile);
133 QString execStr = nf.exec(); 132 QString execStr = nf.exec();
134 qDebug( execStr); 133 qDebug( execStr);
135 if( execStr.isEmpty() ) 134 if( execStr.isEmpty() )
136 { 135 {
137 } 136 }
138 else 137 else
139 { 138 {
140 nf.execute(); 139 nf.execute();
141 } 140 }
142 } 141 }
143 } 142 }
144} 143}
145 144
146void AdvancedFm::runText() 145void AdvancedFm::runText()
147{ 146{
148 QString curFile = CurrentView()->currentItem()->text(0); 147 QString curFile = CurrentView()->currentItem()->text(0);
149 if(curFile != "../") 148 if(curFile != "../")
150 { 149 {
151 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 150 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
152 curFile = dealWithSymName((const QString&)curFile); 151 curFile = dealWithSymName((const QString&)curFile);
153 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 152 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
154 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 153 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
155 e << curFile; 154 e << curFile;
156 } 155 }
157} 156}
158 157
159void AdvancedFm::makeDir() 158void AdvancedFm::makeDir()
160{ 159{
161 InputDialog *fileDlg; 160 InputDialog *fileDlg;
162 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 161 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
163 fileDlg->exec(); 162 fileDlg->exec();
164 if( fileDlg->result() == 1 ) 163 if( fileDlg->result() == 1 )
165 { 164 {
166 QDir *thisDir = CurrentDir(); 165 QDir *thisDir = CurrentDir();
167 QString filename = fileDlg->LineEdit1->text(); 166 QString filename = fileDlg->LineEdit1->text();
168 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 167 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
169 } 168 }
170 populateView(); 169 populateView();
@@ -427,195 +426,195 @@ void AdvancedFm::copyAs()
427 426
428 } 427 }
429 setOtherTabCurrent(); 428 setOtherTabCurrent();
430 populateView(); 429 populateView();
431} 430}
432 431
433void AdvancedFm::copySameDir() 432void AdvancedFm::copySameDir()
434{ 433{
435 qApp->processEvents(); 434 qApp->processEvents();
436 QStringList curFileList = getPath(); 435 QStringList curFileList = getPath();
437 QString curFile, item, destFile; 436 QString curFile, item, destFile;
438 InputDialog *fileDlg; 437 InputDialog *fileDlg;
439 438
440 QDir *thisDir = CurrentDir(); 439 QDir *thisDir = CurrentDir();
441 440
442 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 441 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
443 { 442 {
444 item=(*it); 443 item=(*it);
445 curFile = thisDir->canonicalPath()+"/"+ item; 444 curFile = thisDir->canonicalPath()+"/"+ item;
446 445
447 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 446 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
448 fileDlg->setInputText((const QString &) destFile ); 447 fileDlg->setInputText((const QString &) destFile );
449 fileDlg->exec(); 448 fileDlg->exec();
450 449
451 if( fileDlg->result() == 1 ) 450 if( fileDlg->result() == 1 )
452 { 451 {
453 452
454 QString filename = fileDlg->LineEdit1->text(); 453 QString filename = fileDlg->LineEdit1->text();
455 destFile = thisDir->canonicalPath()+"/"+filename; 454 destFile = thisDir->canonicalPath()+"/"+filename;
456 455
457 QFile f(destFile); 456 QFile f(destFile);
458 if( f.exists()) 457 if( f.exists())
459 { 458 {
460 switch (QMessageBox::warning(this,tr("Delete"), 459 switch (QMessageBox::warning(this,tr("Delete"),
461 destFile+tr(" already exists.\nDo you really want to delete it?"), 460 destFile+tr(" already exists.\nDo you really want to delete it?"),
462 tr("Yes"),tr("No"),0,0,1) ) { 461 tr("Yes"),tr("No"),0,0,1) ) {
463 case 0: 462 case 0:
464 463
465 f.remove(); 464 f.remove();
466 break; 465 break;
467 case 1: 466 case 1:
468 return; 467 return;
469 break; 468 break;
470 }; 469 };
471 } 470 }
472 if(!copyFile( curFile,destFile) ) { 471 if(!copyFile( curFile,destFile) ) {
473 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 472 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
474 +curFile +tr("to\n")+destFile); 473 +curFile +tr("to\n")+destFile);
475 return; 474 return;
476 } 475 }
477 476
478 qDebug("copy "+curFile+" as "+destFile); 477 qDebug("copy "+curFile+" as "+destFile);
479 } 478 }
480 delete fileDlg; 479 delete fileDlg;
481 } 480 }
482 populateView(); 481 populateView();
483} 482}
484 483
485void AdvancedFm::move() 484void AdvancedFm::move()
486{ 485{
487 qApp->processEvents(); 486 qApp->processEvents();
488 487
489 QStringList curFileList = getPath(); 488 QStringList curFileList = getPath();
490 if( curFileList.count() > 0) 489 if( curFileList.count() > 0)
491 { 490 {
492 QString curFile, destFile, item; 491 QString curFile, destFile, item;
493 492
494 QDir *thisDir = CurrentDir(); 493 QDir *thisDir = CurrentDir();
495 QDir *thatDir = OtherDir(); 494 QDir *thatDir = OtherDir();
496 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 495 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
497 { 496 {
498 item=(*it); 497 item=(*it);
499 QString destFile = thatDir->canonicalPath(); 498 QString destFile = thatDir->canonicalPath();
500 499
501 if(destFile.right(1).find("/",0,TRUE) == -1) 500 if(destFile.right(1).find("/",0,TRUE) == -1)
502 destFile+="/"; 501 destFile+="/";
503 destFile += item; 502 destFile += item;
504 qDebug("Destination file is "+destFile); 503 qDebug("Destination file is "+destFile);
505 504
506 curFile = thisDir->canonicalPath(); 505 curFile = thisDir->canonicalPath();
507 if(curFile.right(1).find("/",0,TRUE) == -1) 506 if(curFile.right(1).find("/",0,TRUE) == -1)
508 curFile +="/"; 507 curFile +="/";
509 curFile+= item; 508 curFile+= item;
510 qDebug("CurrentFile file is " + curFile); 509 qDebug("CurrentFile file is " + curFile);
511 510
512 QFile f( curFile); 511 QFile f( curFile);
513 if( f.exists()) { 512 if( f.exists()) {
514 if( !copyFile( curFile, destFile) ) { 513 if( !copyFile( curFile, destFile) ) {
515 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 514 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
516 return; 515 return;
517 } else 516 } else
518 QFile::remove(curFile); 517 QFile::remove(curFile);
519 } 518 }
520 } 519 }
521 520
522 } 521 }
523 setOtherTabCurrent(); 522 populateView();
524 populateView(); 523 setOtherTabCurrent();
525// populateLocalView(); 524 populateView();
526} 525}
527 526
528bool AdvancedFm::copyFile( const QString & src, const QString & dest ) 527bool AdvancedFm::copyFile( const QString & src, const QString & dest )
529{ 528{
530 bool success = true; 529 bool success = true;
531 struct stat status; 530 struct stat status;
532 QFile srcFile(src); 531 QFile srcFile(src);
533 QFile destFile(dest); 532 QFile destFile(dest);
534 int err=0; 533 int err=0;
535 int read_fd=0; 534 int read_fd=0;
536 int write_fd=0; 535 int write_fd=0;
537 struct stat stat_buf; 536 struct stat stat_buf;
538 off_t offset = 0; 537 off_t offset = 0;
539 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 538 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
540 qWarning("open failed"); 539 qWarning("open failed");
541 return success = false; 540 return success = false;
542 } 541 }
543 read_fd = srcFile.handle(); 542 read_fd = srcFile.handle();
544 if(read_fd != -1) { 543 if(read_fd != -1) {
545 fstat (read_fd, &stat_buf); 544 fstat (read_fd, &stat_buf);
546 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 545 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
547 qWarning("destfile open failed"); 546 qWarning("destfile open failed");
548 return success = false; 547 return success = false;
549 } 548 }
550 write_fd = destFile.handle(); 549 write_fd = destFile.handle();
551 if(write_fd != -1) { 550 if(write_fd != -1) {
552 err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 551 err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
553 if( err == -1) { 552 if( err == -1) {
554 QString msg; 553 QString msg;
555 switch(err) { 554 switch(err) {
556 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 555 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
557 case EINVAL: msg = "Descriptor is not valid or locked. "; 556 case EINVAL: msg = "Descriptor is not valid or locked. ";
558 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 557 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
559 case EIO: msg = "Unspecified error while reading from in_fd."; 558 case EIO: msg = "Unspecified error while reading from in_fd.";
560 }; 559 };
561 success = false; 560 success = false;
562 qWarning(msg); 561 qWarning(msg);
563 } 562 }
564 } else { 563 } else {
565 success = false; 564 success = false;
566 } 565 }
567 } else { 566 } else {
568 success = false; 567 success = false;
569 } 568 }
570 srcFile.close(); 569 srcFile.close();
571 destFile.close(); 570 destFile.close();
572 // Set file permissions 571 // Set file permissions
573 if( stat( (const char *) src, &status ) == 0 ) { 572 if( stat( (const char *) src, &status ) == 0 ) {
574 chmod( (const char *) dest, status.st_mode ); 573 chmod( (const char *) dest, status.st_mode );
575 } 574 }
576 575
577 return success; 576 return success;
578} 577}
579 578
580void AdvancedFm::runCommand() 579void AdvancedFm::runCommand()
581{ 580{
582 QDir *thisDir = CurrentDir(); 581 QDir *thisDir = CurrentDir();
583 582
584 QString curFile; 583 QString curFile;
585 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 584 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
586 585
587 InputDialog *fileDlg; 586 InputDialog *fileDlg;
588 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 587 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
589 fileDlg->setInputText(curFile); 588 fileDlg->setInputText(curFile);
590 fileDlg->exec(); 589 fileDlg->exec();
591 //QString command; 590 //QString command;
592 591
593 if( fileDlg->result() == 1 ) 592 if( fileDlg->result() == 1 )
594 { 593 {
595 qDebug(fileDlg->LineEdit1->text()); 594 qDebug(fileDlg->LineEdit1->text());
596 QStringList command; 595 QStringList command;
597 596
598 command << "/bin/sh"; 597 command << "/bin/sh";
599 command << "-c"; 598 command << "-c";
600 command << fileDlg->LineEdit1->text(); 599 command << fileDlg->LineEdit1->text();
601 Output *outDlg; 600 Output *outDlg;
602 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 601 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
603 outDlg->showMaximized(); 602 outDlg->showMaximized();
604 outDlg->exec(); 603 outDlg->exec();
605 qApp->processEvents(); 604 qApp->processEvents();
606 605
607 } 606 }
608} 607}
609 608
610void AdvancedFm::runCommandStd() 609void AdvancedFm::runCommandStd()
611{ 610{
612 QString curFile; 611 QString curFile;
613 QDir *thisDir = CurrentDir(); 612 QDir *thisDir = CurrentDir();
614 QListView *thisView = CurrentView(); 613 QListView *thisView = CurrentView();
615 if( thisView->currentItem()) 614 if( thisView->currentItem())
616 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 615 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
617 616
618 InputDialog *fileDlg; 617 InputDialog *fileDlg;
619 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 618 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
620 fileDlg->setInputText(curFile); 619 fileDlg->setInputText(curFile);
621 fileDlg->exec(); 620 fileDlg->exec();