-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 32 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 2 |
2 files changed, 29 insertions, 5 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 96a2d0a..16dc7da 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,168 +1,170 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #define DEVELOPERS_VERSION | 12 | #define DEVELOPERS_VERSION |
13 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | 13 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties |
14 | 14 | ||
15 | #include "advancedfm.h" | 15 | #include "advancedfm.h" |
16 | #include "inputDialog.h" | 16 | #include "inputDialog.h" |
17 | #include "filePermissions.h" | 17 | #include "filePermissions.h" |
18 | #include "output.h" | 18 | #include "output.h" |
19 | 19 | ||
20 | #include <opie/ofileselector.h> | 20 | #include <opie/ofileselector.h> |
21 | #include <opie/ofiledialog.h> | 21 | #include <opie/ofiledialog.h> |
22 | 22 | ||
23 | 23 | ||
24 | #include <qpe/lnkproperties.h> | 24 | #include <qpe/lnkproperties.h> |
25 | #include <qpe/filemanager.h> | 25 | #include <qpe/filemanager.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/qpemenubar.h> | 27 | #include <qpe/qpemenubar.h> |
28 | #include <qpe/qpetoolbar.h> | 28 | #include <qpe/qpetoolbar.h> |
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/mimetype.h> | 33 | #include <qpe/mimetype.h> |
34 | #include <qpe/applnk.h> | 34 | #include <qpe/applnk.h> |
35 | #include <qpe/ir.h> | 35 | #include <qpe/ir.h> |
36 | 36 | ||
37 | //#include <opie/ofileselector.h> | 37 | //#include <opie/ofileselector.h> |
38 | #include <qmultilineedit.h> | 38 | #include <qmultilineedit.h> |
39 | 39 | ||
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qtoolbutton.h> | 42 | #include <qtoolbutton.h> |
43 | #include <qdatetime.h> | 43 | #include <qdatetime.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qfile.h> | 45 | #include <qfile.h> |
46 | #include <qstring.h> | 46 | #include <qstring.h> |
47 | #include <qcombobox.h> | 47 | #include <qcombobox.h> |
48 | #include <qpopupmenu.h> | 48 | #include <qpopupmenu.h> |
49 | #include <qlistview.h> | 49 | #include <qlistview.h> |
50 | #include <qmainwindow.h> | 50 | #include <qmainwindow.h> |
51 | #include <qlabel.h> | 51 | #include <qlabel.h> |
52 | #include <qprogressbar.h> | 52 | #include <qprogressbar.h> |
53 | #include <qspinbox.h> | 53 | #include <qspinbox.h> |
54 | #include <qtabwidget.h> | 54 | #include <qtabwidget.h> |
55 | #include <qwidget.h> | 55 | #include <qwidget.h> |
56 | #include <qlayout.h> | 56 | #include <qlayout.h> |
57 | #include <qimage.h> | 57 | #include <qimage.h> |
58 | #include <qpixmap.h> | 58 | #include <qpixmap.h> |
59 | #include <qmessagebox.h> | 59 | #include <qmessagebox.h> |
60 | #include <qlineedit.h> | 60 | #include <qlineedit.h> |
61 | #include <qregexp.h> | 61 | #include <qregexp.h> |
62 | 62 | ||
63 | #include <unistd.h> | 63 | #include <unistd.h> |
64 | #include <stdlib.h> | 64 | #include <stdlib.h> |
65 | #include <sys/stat.h> | 65 | #include <sys/stat.h> |
66 | #include <dirent.h> | 66 | #include <dirent.h> |
67 | #include <stdio.h> | 67 | #include <stdio.h> |
68 | #include <time.h> | 68 | #include <time.h> |
69 | #include <fcntl.h> | 69 | #include <fcntl.h> |
70 | #include <mntent.h> | 70 | #include <mntent.h> |
71 | #include <string.h> | 71 | #include <string.h> |
72 | #include <errno.h> | 72 | #include <errno.h> |
73 | #include <sys/vfs.h> | ||
74 | #include <mntent.h> | ||
73 | 75 | ||
74 | AdvancedFm::AdvancedFm( ) | 76 | AdvancedFm::AdvancedFm( ) |
75 | : QMainWindow( ) | 77 | : QMainWindow( ) |
76 | { | 78 | { |
77 | setCaption( tr( "AdvancedFm" ) ); | 79 | setCaption( tr( "AdvancedFm" ) ); |
78 | 80 | ||
79 | QGridLayout *layout = new QGridLayout( this ); | 81 | QGridLayout *layout = new QGridLayout( this ); |
80 | layout->setSpacing( 2); | 82 | layout->setSpacing( 2); |
81 | layout->setMargin( 2); | 83 | layout->setMargin( 2); |
82 | 84 | ||
83 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 85 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
84 | 86 | ||
85 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 87 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
86 | fileMenu = new QPopupMenu( this ); | 88 | fileMenu = new QPopupMenu( this ); |
87 | viewMenu = new QPopupMenu( this ); | 89 | viewMenu = new QPopupMenu( this ); |
88 | 90 | ||
89 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); | 91 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); |
90 | 92 | ||
91 | menuBar->insertItem( tr( "File" ), fileMenu); | 93 | menuBar->insertItem( tr( "File" ), fileMenu); |
92 | menuBar->insertItem( tr( "View" ), viewMenu); | 94 | menuBar->insertItem( tr( "View" ), viewMenu); |
93 | 95 | ||
94 | qpeDirButton= new QToolButton(this,"QPEButton"); | 96 | qpeDirButton= new QToolButton(this,"QPEButton"); |
95 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); | 97 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); |
96 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); | 98 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); |
97 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); | 99 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); |
98 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); | 100 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); |
99 | 101 | ||
100 | cfButton = new QToolButton( this,"CFButton"); | 102 | cfButton = new QToolButton( this,"CFButton"); |
101 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); | 103 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); |
102 | cfButton ->setFixedSize( QSize( 20, 20 ) ); | 104 | cfButton ->setFixedSize( QSize( 20, 20 ) ); |
103 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); | 105 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); |
104 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); | 106 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); |
105 | 107 | ||
106 | sdButton = new QToolButton( this,"SDButton"); | 108 | sdButton = new QToolButton( this,"SDButton"); |
107 | sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); | 109 | sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); |
108 | sdButton->setFixedSize( QSize( 20, 20 ) ); | 110 | sdButton->setFixedSize( QSize( 20, 20 ) ); |
109 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); | 111 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); |
110 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); | 112 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); |
111 | 113 | ||
112 | cdUpButton = new QToolButton( this,"cdUpButton"); | 114 | cdUpButton = new QToolButton( this,"cdUpButton"); |
113 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 115 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
114 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 116 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
115 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 117 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
116 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); | 118 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); |
117 | 119 | ||
118 | docButton = new QToolButton( this,"docsButton"); | 120 | docButton = new QToolButton( this,"docsButton"); |
119 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); | 121 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); |
120 | docButton->setFixedSize( QSize( 20, 20 ) ); | 122 | docButton->setFixedSize( QSize( 20, 20 ) ); |
121 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 123 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
122 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); | 124 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); |
123 | 125 | ||
124 | homeButton = new QToolButton( this,"homeButton"); | 126 | homeButton = new QToolButton( this,"homeButton"); |
125 | homeButton->setPixmap(Resource::loadPixmap("home")); | 127 | homeButton->setPixmap(Resource::loadPixmap("home")); |
126 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 128 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
127 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 129 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
128 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); | 130 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); |
129 | 131 | ||
130 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 132 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
131 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 133 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
132 | fileMenu->insertSeparator(); | 134 | fileMenu->insertSeparator(); |
133 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 135 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
134 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 136 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
135 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 137 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
136 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 138 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
137 | fileMenu->insertSeparator(); | 139 | fileMenu->insertSeparator(); |
138 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 140 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
139 | fileMenu->setCheckable(TRUE); | 141 | fileMenu->setCheckable(TRUE); |
140 | 142 | ||
141 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 143 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
142 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 144 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
143 | viewMenu->insertSeparator(); | 145 | viewMenu->insertSeparator(); |
144 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 146 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
145 | viewMenu->setCheckable(TRUE); | 147 | viewMenu->setCheckable(TRUE); |
146 | 148 | ||
147 | 149 | ||
148 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 150 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
149 | currentPathCombo->setEditable(TRUE); | 151 | currentPathCombo->setEditable(TRUE); |
150 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); | 152 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); |
151 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 153 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
152 | 154 | ||
153 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 155 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
154 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 156 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
155 | 157 | ||
156 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 158 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
157 | this,SLOT(currentPathComboChanged())); | 159 | this,SLOT(currentPathComboChanged())); |
158 | 160 | ||
159 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 161 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
160 | 162 | ||
161 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); | 163 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); |
162 | 164 | ||
163 | 165 | ||
164 | TabWidget = new QTabWidget( this, "TabWidget" ); | 166 | TabWidget = new QTabWidget( this, "TabWidget" ); |
165 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); | 167 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); |
166 | 168 | ||
167 | tab = new QWidget( TabWidget, "tab" ); | 169 | tab = new QWidget( TabWidget, "tab" ); |
168 | tabLayout = new QGridLayout( tab ); | 170 | tabLayout = new QGridLayout( tab ); |
@@ -211,291 +213,291 @@ AdvancedFm::AdvancedFm( ) | |||
211 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 213 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
212 | 214 | ||
213 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 215 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
214 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 216 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
215 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 217 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
216 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 218 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
217 | 219 | ||
218 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 220 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
219 | 221 | ||
220 | 222 | ||
221 | TabWidget->insertTab( tab_2, tr( "2")); | 223 | TabWidget->insertTab( tab_2, tr( "2")); |
222 | 224 | ||
223 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 225 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
224 | this,SLOT(tabChanged(QWidget*))); | 226 | this,SLOT(tabChanged(QWidget*))); |
225 | 227 | ||
226 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 228 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
227 | tabLayout_3 = new QGridLayout( tab_3 ); | 229 | tabLayout_3 = new QGridLayout( tab_3 ); |
228 | tabLayout_3->setSpacing( 2); | 230 | tabLayout_3->setSpacing( 2); |
229 | tabLayout_3->setMargin( 2); | 231 | tabLayout_3->setMargin( 2); |
230 | 232 | ||
231 | 233 | ||
232 | // OFileDialog fileDialog; | 234 | // OFileDialog fileDialog; |
233 | // fileDialog; | 235 | // fileDialog; |
234 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 236 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
235 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 237 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
236 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 238 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
237 | 239 | ||
238 | QListView *fileTree; | 240 | QListView *fileTree; |
239 | fileTree = new QListView( tab_3, "tree" ); | 241 | fileTree = new QListView( tab_3, "tree" ); |
240 | 242 | ||
241 | 243 | ||
242 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 244 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
243 | 245 | ||
244 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 246 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
245 | */ | 247 | */ |
246 | 248 | ||
247 | /////////////// | 249 | /////////////// |
248 | 250 | ||
249 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 251 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
250 | currentDir.setPath( QDir::currentDirPath()); | 252 | currentDir.setPath( QDir::currentDirPath()); |
251 | 253 | ||
252 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 254 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
253 | currentRemoteDir.setPath( QDir::currentDirPath()); | 255 | currentRemoteDir.setPath( QDir::currentDirPath()); |
254 | 256 | ||
255 | b = TRUE; | 257 | b = TRUE; |
256 | 258 | ||
257 | filterStr="*"; | 259 | filterStr="*"; |
258 | b=FALSE; | 260 | b=FALSE; |
259 | 261 | ||
260 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 262 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
261 | 263 | ||
262 | populateLocalView(); | 264 | populateLocalView(); |
263 | populateRemoteView(); | 265 | populateRemoteView(); |
264 | currentPathCombo->setFocus(); | 266 | currentPathCombo->setFocus(); |
265 | } | 267 | } |
266 | 268 | ||
267 | AdvancedFm::~AdvancedFm() | 269 | AdvancedFm::~AdvancedFm() |
268 | { | 270 | { |
269 | } | 271 | } |
270 | 272 | ||
271 | void AdvancedFm::cleanUp() | 273 | void AdvancedFm::cleanUp() |
272 | { | 274 | { |
273 | QString sfile=QDir::homeDirPath(); | 275 | QString sfile=QDir::homeDirPath(); |
274 | if(sfile.right(1) != "/") | 276 | if(sfile.right(1) != "/") |
275 | sfile+="/._temp"; | 277 | sfile+="/._temp"; |
276 | else | 278 | else |
277 | sfile+="._temp"; | 279 | sfile+="._temp"; |
278 | QFile file( sfile); | 280 | QFile file( sfile); |
279 | if(file.exists()) | 281 | if(file.exists()) |
280 | file.remove(); | 282 | file.remove(); |
281 | } | 283 | } |
282 | 284 | ||
283 | void AdvancedFm::tabChanged(QWidget *w) | 285 | void AdvancedFm::tabChanged(QWidget *w) |
284 | { | 286 | { |
285 | if (TabWidget->currentPageIndex() == 0) { | 287 | if (TabWidget->currentPageIndex() == 0) { |
286 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 288 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
287 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 289 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
288 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 290 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
289 | } | 291 | } |
290 | if (TabWidget->currentPageIndex() == 1) { | 292 | if (TabWidget->currentPageIndex() == 1) { |
291 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 293 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
292 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 294 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
293 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 295 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
294 | } | 296 | } |
295 | } | 297 | } |
296 | 298 | ||
297 | 299 | ||
298 | void AdvancedFm::populateLocalView() | 300 | void AdvancedFm::populateLocalView() |
299 | { | 301 | { |
300 | QPixmap pm; | 302 | QPixmap pm; |
301 | Local_View->clear(); | 303 | Local_View->clear(); |
302 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 304 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
303 | currentDir.setMatchAllDirs(TRUE); | 305 | currentDir.setMatchAllDirs(TRUE); |
304 | currentDir.setNameFilter(filterStr); | 306 | currentDir.setNameFilter(filterStr); |
305 | QString fileL, fileS, fileDate; | 307 | QString fileL, fileS, fileDate; |
306 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 308 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
307 | setCaption("AdvancedFm :: "+fs); | 309 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
308 | bool isDir=FALSE; | 310 | bool isDir=FALSE; |
309 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 311 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
310 | QFileInfoListIterator it(*list); | 312 | QFileInfoListIterator it(*list); |
311 | QFileInfo *fi; | 313 | QFileInfo *fi; |
312 | while ( (fi=it.current()) ) { | 314 | while ( (fi=it.current()) ) { |
313 | if (fi->isSymLink() ) { | 315 | if (fi->isSymLink() ) { |
314 | QString symLink=fi->readLink(); | 316 | QString symLink=fi->readLink(); |
315 | QFileInfo sym( symLink); | 317 | QFileInfo sym( symLink); |
316 | fileS.sprintf( "%10li", sym.size() ); | 318 | fileS.sprintf( "%10li", sym.size() ); |
317 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 319 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
318 | fileDate = sym.lastModified().toString(); | 320 | fileDate = sym.lastModified().toString(); |
319 | } else { | 321 | } else { |
320 | fileS.sprintf( "%10li", fi->size() ); | 322 | fileS.sprintf( "%10li", fi->size() ); |
321 | fileL.sprintf( "%s",fi->fileName().data() ); | 323 | fileL.sprintf( "%s",fi->fileName().data() ); |
322 | fileDate= fi->lastModified().toString(); | 324 | fileDate= fi->lastModified().toString(); |
323 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 325 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
324 | fileL+="/"; | 326 | fileL+="/"; |
325 | isDir=TRUE; | 327 | isDir=TRUE; |
326 | } | 328 | } |
327 | } | 329 | } |
328 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 330 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
329 | if(fileL !="./" && fi->exists()) { | 331 | if(fileL !="./" && fi->exists()) { |
330 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 332 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
331 | 333 | ||
332 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 334 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
333 | 335 | ||
334 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 336 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
335 | pm = Resource::loadPixmap( "lockedfolder" ); | 337 | pm = Resource::loadPixmap( "lockedfolder" ); |
336 | else | 338 | else |
337 | pm= Resource::loadPixmap( "folder" ); | 339 | pm= Resource::loadPixmap( "folder" ); |
338 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 340 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
339 | pm = Resource::loadPixmap( "exec"); | 341 | pm = Resource::loadPixmap( "exec"); |
340 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 342 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
341 | | fileInfo.permission( QFileInfo::ExeGroup) | 343 | | fileInfo.permission( QFileInfo::ExeGroup) |
342 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 344 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
343 | pm = Resource::loadPixmap( "exec"); | 345 | pm = Resource::loadPixmap( "exec"); |
344 | } else if( !fi->isReadable() ) { | 346 | } else if( !fi->isReadable() ) { |
345 | pm = Resource::loadPixmap( "locked" ); | 347 | pm = Resource::loadPixmap( "locked" ); |
346 | } else { //everything else goes by mimetype | 348 | } else { //everything else goes by mimetype |
347 | MimeType mt(fi->filePath()); | 349 | MimeType mt(fi->filePath()); |
348 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 350 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
349 | if(pm.isNull()) | 351 | if(pm.isNull()) |
350 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 352 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
351 | } | 353 | } |
352 | item->setPixmap( 0,pm); | 354 | item->setPixmap( 0,pm); |
353 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 355 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
354 | // overlay link image | 356 | // overlay link image |
355 | pm= Resource::loadPixmap( "folder" ); | 357 | pm= Resource::loadPixmap( "folder" ); |
356 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 358 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
357 | QPainter painter( &pm ); | 359 | QPainter painter( &pm ); |
358 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 360 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
359 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 361 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
360 | item->setPixmap( 0, pm); | 362 | item->setPixmap( 0, pm); |
361 | } | 363 | } |
362 | } | 364 | } |
363 | isDir=FALSE; | 365 | isDir=FALSE; |
364 | ++it; | 366 | ++it; |
365 | } | 367 | } |
366 | 368 | ||
367 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 369 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
368 | struct stat buf; | 370 | struct stat buf; |
369 | dev_t devT; | 371 | dev_t devT; |
370 | DIR *dir; | 372 | DIR *dir; |
371 | struct dirent *mydirent; | 373 | struct dirent *mydirent; |
372 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 374 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
373 | while ((mydirent = readdir(dir)) != NULL) { | 375 | while ((mydirent = readdir(dir)) != NULL) { |
374 | lstat( mydirent->d_name, &buf); | 376 | lstat( mydirent->d_name, &buf); |
375 | qDebug(mydirent->d_name); | 377 | qDebug(mydirent->d_name); |
376 | fileL.sprintf("%s", mydirent->d_name); | 378 | fileL.sprintf("%s", mydirent->d_name); |
377 | devT = buf.st_dev; | 379 | devT = buf.st_dev; |
378 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 380 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
379 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 381 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
380 | if( fileL.find(".") == -1 ){ | 382 | if( fileL.find(".") == -1 ){ |
381 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 383 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
382 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 384 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
383 | item->setPixmap( 0,pm); | 385 | item->setPixmap( 0,pm); |
384 | } | 386 | } |
385 | } | 387 | } |
386 | 388 | ||
387 | closedir(dir); | 389 | closedir(dir); |
388 | } | 390 | } |
389 | 391 | ||
390 | Local_View->setSorting( 3,FALSE); | 392 | Local_View->setSorting( 3,FALSE); |
391 | fillCombo( (const QString &) currentDir.canonicalPath()); | 393 | fillCombo( (const QString &) currentDir.canonicalPath()); |
392 | } | 394 | } |
393 | 395 | ||
394 | 396 | ||
395 | void AdvancedFm::populateRemoteView() | 397 | void AdvancedFm::populateRemoteView() |
396 | { | 398 | { |
397 | QPixmap pm; | 399 | QPixmap pm; |
398 | Remote_View->clear(); | 400 | Remote_View->clear(); |
399 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 401 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
400 | currentRemoteDir.setMatchAllDirs(TRUE); | 402 | currentRemoteDir.setMatchAllDirs(TRUE); |
401 | currentRemoteDir.setNameFilter(filterStr); | 403 | currentRemoteDir.setNameFilter(filterStr); |
402 | QString fileL, fileS, fileDate; | 404 | QString fileL, fileS, fileDate; |
403 | 405 | ||
404 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 406 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
405 | setCaption("AdvancedFm :: "+fs); | 407 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
406 | bool isDir=FALSE; | 408 | bool isDir=FALSE; |
407 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 409 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
408 | QFileInfoListIterator it(*list); | 410 | QFileInfoListIterator it(*list); |
409 | QFileInfo *fi; | 411 | QFileInfo *fi; |
410 | while ( (fi=it.current()) ) { | 412 | while ( (fi=it.current()) ) { |
411 | if (fi->isSymLink() ){ | 413 | if (fi->isSymLink() ){ |
412 | QString symLink=fi->readLink(); | 414 | QString symLink=fi->readLink(); |
413 | // qDebug("Symlink detected "+symLink); | 415 | // qDebug("Symlink detected "+symLink); |
414 | QFileInfo sym( symLink); | 416 | QFileInfo sym( symLink); |
415 | fileS.sprintf( "%10li", sym.size() ); | 417 | fileS.sprintf( "%10li", sym.size() ); |
416 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 418 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
417 | fileDate = sym.lastModified().toString(); | 419 | fileDate = sym.lastModified().toString(); |
418 | } else { | 420 | } else { |
419 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 421 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
420 | fileS.sprintf( "%10li", fi->size() ); | 422 | fileS.sprintf( "%10li", fi->size() ); |
421 | fileL.sprintf( "%s",fi->fileName().data() ); | 423 | fileL.sprintf( "%s",fi->fileName().data() ); |
422 | fileDate= fi->lastModified().toString(); | 424 | fileDate= fi->lastModified().toString(); |
423 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 425 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
424 | fileL+="/"; | 426 | fileL+="/"; |
425 | isDir=TRUE; | 427 | isDir=TRUE; |
426 | // qDebug( fileL); | 428 | // qDebug( fileL); |
427 | } | 429 | } |
428 | } | 430 | } |
429 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); | 431 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); |
430 | if(fileL !="./" && fi->exists()) { | 432 | if(fileL !="./" && fi->exists()) { |
431 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 433 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
432 | QPixmap pm; | 434 | QPixmap pm; |
433 | 435 | ||
434 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 436 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
435 | if( !QDir( fi->filePath() ).isReadable()) | 437 | if( !QDir( fi->filePath() ).isReadable()) |
436 | pm = Resource::loadPixmap( "lockedfolder" ); | 438 | pm = Resource::loadPixmap( "lockedfolder" ); |
437 | else | 439 | else |
438 | pm= Resource::loadPixmap( "folder" ); | 440 | pm= Resource::loadPixmap( "folder" ); |
439 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 441 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
440 | pm = Resource::loadPixmap( "exec"); | 442 | pm = Resource::loadPixmap( "exec"); |
441 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 443 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
442 | | fileInfo.permission( QFileInfo::ExeGroup) | 444 | | fileInfo.permission( QFileInfo::ExeGroup) |
443 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 445 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
444 | pm = Resource::loadPixmap( "exec"); | 446 | pm = Resource::loadPixmap( "exec"); |
445 | } else if( !fi->isReadable() ) { | 447 | } else if( !fi->isReadable() ) { |
446 | pm = Resource::loadPixmap( "locked" ); | 448 | pm = Resource::loadPixmap( "locked" ); |
447 | } else { | 449 | } else { |
448 | MimeType mt(fi->filePath()); | 450 | MimeType mt(fi->filePath()); |
449 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 451 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
450 | if(pm.isNull()) | 452 | if(pm.isNull()) |
451 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 453 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
452 | } | 454 | } |
453 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 455 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
454 | // overlay link image | 456 | // overlay link image |
455 | pm= Resource::loadPixmap( "folder" ); | 457 | pm= Resource::loadPixmap( "folder" ); |
456 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 458 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
457 | QPainter painter( &pm ); | 459 | QPainter painter( &pm ); |
458 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 460 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
459 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 461 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
460 | } | 462 | } |
461 | item->setPixmap( 0, pm); | 463 | item->setPixmap( 0, pm); |
462 | } | 464 | } |
463 | isDir=FALSE; | 465 | isDir=FALSE; |
464 | ++it; | 466 | ++it; |
465 | } | 467 | } |
466 | 468 | ||
467 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 469 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
468 | struct stat buf; | 470 | struct stat buf; |
469 | DIR *dir; | 471 | DIR *dir; |
470 | struct dirent *mydirent; | 472 | struct dirent *mydirent; |
471 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 473 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
472 | while ((mydirent = readdir(dir)) != NULL) { | 474 | while ((mydirent = readdir(dir)) != NULL) { |
473 | lstat( mydirent->d_name, &buf); | 475 | lstat( mydirent->d_name, &buf); |
474 | qDebug(mydirent->d_name); | 476 | qDebug(mydirent->d_name); |
475 | fileL.sprintf("%s", mydirent->d_name); | 477 | fileL.sprintf("%s", mydirent->d_name); |
476 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 478 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
477 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 479 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
478 | if( fileL.find(".") == -1 ){ | 480 | if( fileL.find(".") == -1 ){ |
479 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 481 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
480 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 482 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
481 | item->setPixmap( 0,pm); | 483 | item->setPixmap( 0,pm); |
482 | } | 484 | } |
483 | } | 485 | } |
484 | 486 | ||
485 | closedir(dir); | 487 | closedir(dir); |
486 | } | 488 | } |
487 | 489 | ||
488 | Remote_View->setSorting( 3,FALSE); | 490 | Remote_View->setSorting( 3,FALSE); |
489 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 491 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
490 | } | 492 | } |
491 | 493 | ||
492 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) | 494 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) |
493 | { | 495 | { |
494 | if(selectedItem) { | 496 | if(selectedItem) { |
495 | QString strItem=selectedItem->text(0); | 497 | QString strItem=selectedItem->text(0); |
496 | QString strSize=selectedItem->text(1); | 498 | QString strSize=selectedItem->text(1); |
497 | strSize=strSize.stripWhiteSpace(); | 499 | strSize=strSize.stripWhiteSpace(); |
498 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 500 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
499 | // is symlink | 501 | // is symlink |
500 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 502 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
501 | if(QDir(strItem2).exists() ) { | 503 | if(QDir(strItem2).exists() ) { |
@@ -1373,247 +1375,250 @@ void AdvancedFm::move() { | |||
1373 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1375 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1374 | tr("Yes"),tr("No"),0,0,1) ) { | 1376 | tr("Yes"),tr("No"),0,0,1) ) { |
1375 | case 0: | 1377 | case 0: |
1376 | f.remove(); | 1378 | f.remove(); |
1377 | break; | 1379 | break; |
1378 | case 1: | 1380 | case 1: |
1379 | return; | 1381 | return; |
1380 | break; | 1382 | break; |
1381 | }; | 1383 | }; |
1382 | if(!copyFile(destFile, curFile) ) { | 1384 | if(!copyFile(destFile, curFile) ) { |
1383 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 1385 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
1384 | return; | 1386 | return; |
1385 | } | 1387 | } |
1386 | } | 1388 | } |
1387 | QFile::remove(curFile); | 1389 | QFile::remove(curFile); |
1388 | TabWidget->setCurrentPage(0); | 1390 | TabWidget->setCurrentPage(0); |
1389 | } | 1391 | } |
1390 | } | 1392 | } |
1391 | populateRemoteView(); | 1393 | populateRemoteView(); |
1392 | populateLocalView(); | 1394 | populateLocalView(); |
1393 | } | 1395 | } |
1394 | } | 1396 | } |
1395 | 1397 | ||
1396 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1398 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) |
1397 | { | 1399 | { |
1398 | char bf[ 50000 ]; | 1400 | char bf[ 50000 ]; |
1399 | int bytesRead; | 1401 | int bytesRead; |
1400 | bool success = TRUE; | 1402 | bool success = TRUE; |
1401 | struct stat status; | 1403 | struct stat status; |
1402 | 1404 | ||
1403 | QFile s( src ); | 1405 | QFile s( src ); |
1404 | QFile d( dest ); | 1406 | QFile d( dest ); |
1405 | 1407 | ||
1406 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 1408 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
1407 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 1409 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
1408 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 1410 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
1409 | success = FALSE; | 1411 | success = FALSE; |
1410 | break; | 1412 | break; |
1411 | } | 1413 | } |
1412 | } | 1414 | } |
1413 | if( success && (bytesRead > 0) ){ | 1415 | if( success && (bytesRead > 0) ){ |
1414 | d.writeBlock( bf, bytesRead ); | 1416 | d.writeBlock( bf, bytesRead ); |
1415 | } | 1417 | } |
1416 | } else { | 1418 | } else { |
1417 | success = FALSE; | 1419 | success = FALSE; |
1418 | } | 1420 | } |
1419 | 1421 | ||
1420 | // Set file permissions | 1422 | // Set file permissions |
1421 | if( stat( (const char *) src, &status ) == 0 ){ | 1423 | if( stat( (const char *) src, &status ) == 0 ){ |
1422 | chmod( (const char *) dest, status.st_mode ); | 1424 | chmod( (const char *) dest, status.st_mode ); |
1423 | } | 1425 | } |
1424 | 1426 | ||
1425 | return success; | 1427 | return success; |
1426 | } | 1428 | } |
1427 | 1429 | ||
1428 | void AdvancedFm::runCommand() { | 1430 | void AdvancedFm::runCommand() { |
1429 | QString curFile; | 1431 | QString curFile; |
1430 | if (TabWidget->currentPageIndex() == 0) { | 1432 | if (TabWidget->currentPageIndex() == 0) { |
1431 | if( Local_View->currentItem()) | 1433 | if( Local_View->currentItem()) |
1432 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 1434 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1433 | } else { | 1435 | } else { |
1434 | if(Remote_View->currentItem()) | 1436 | if(Remote_View->currentItem()) |
1435 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 1437 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
1436 | } | 1438 | } |
1437 | 1439 | ||
1438 | InputDialog *fileDlg; | 1440 | InputDialog *fileDlg; |
1439 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1441 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1440 | fileDlg->setInputText(curFile); | 1442 | fileDlg->setInputText(curFile); |
1441 | fileDlg->exec(); | 1443 | fileDlg->exec(); |
1442 | QString command; | 1444 | QString command; |
1443 | if( fileDlg->result() == 1 ) { | 1445 | if( fileDlg->result() == 1 ) { |
1444 | command = fileDlg->LineEdit1->text(); | 1446 | command = fileDlg->LineEdit1->text(); |
1445 | 1447 | ||
1446 | Output *outDlg; | 1448 | Output *outDlg; |
1447 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1449 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1448 | outDlg->showMaximized(); | 1450 | outDlg->showMaximized(); |
1449 | outDlg->show(); | 1451 | outDlg->show(); |
1450 | qApp->processEvents(); | 1452 | qApp->processEvents(); |
1451 | FILE *fp; | 1453 | FILE *fp; |
1452 | char line[130]; | 1454 | char line[130]; |
1453 | sleep(1); | 1455 | sleep(1); |
1454 | command +=" 2>&1"; | 1456 | command +=" 2>&1"; |
1455 | fp = popen( (const char *) command, "r"); | 1457 | fp = popen( (const char *) command, "r"); |
1456 | if ( !fp ) { | 1458 | if ( !fp ) { |
1457 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1459 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1458 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 1460 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
1459 | pclose(fp); | 1461 | pclose(fp); |
1460 | return; | 1462 | return; |
1461 | } else { | 1463 | } else { |
1462 | while ( fgets( line, sizeof line, fp)) { | 1464 | while ( fgets( line, sizeof line, fp)) { |
1463 | QString lineStr = line; | 1465 | QString lineStr = line; |
1464 | lineStr=lineStr.left(lineStr.length()-1); | 1466 | lineStr=lineStr.left(lineStr.length()-1); |
1465 | outDlg->OutputEdit->append(lineStr); | 1467 | outDlg->OutputEdit->append(lineStr); |
1466 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1468 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1467 | } | 1469 | } |
1468 | } | 1470 | } |
1471 | pclose(fp); | ||
1472 | |||
1469 | } | 1473 | } |
1470 | } | 1474 | } |
1471 | 1475 | ||
1472 | void AdvancedFm::runCommandStd() { | 1476 | void AdvancedFm::runCommandStd() { |
1473 | QString curFile; | 1477 | QString curFile; |
1474 | if (TabWidget->currentPageIndex() == 0) { | 1478 | if (TabWidget->currentPageIndex() == 0) { |
1475 | if( Local_View->currentItem()) | 1479 | if( Local_View->currentItem()) |
1476 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 1480 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1477 | } else { | 1481 | } else { |
1478 | if(Remote_View->currentItem()) | 1482 | if(Remote_View->currentItem()) |
1479 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); | 1483 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); |
1480 | } | 1484 | } |
1481 | 1485 | ||
1482 | InputDialog *fileDlg; | 1486 | InputDialog *fileDlg; |
1483 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1487 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1484 | fileDlg->setInputText(curFile); | 1488 | fileDlg->setInputText(curFile); |
1485 | fileDlg->exec(); | 1489 | fileDlg->exec(); |
1486 | QString command; | 1490 | QString command; |
1487 | if( fileDlg->result() == 1 ) { | 1491 | if( fileDlg->result() == 1 ) { |
1488 | qApp->processEvents(); | 1492 | qApp->processEvents(); |
1489 | command = fileDlg->LineEdit1->text() + " &"; | 1493 | command = fileDlg->LineEdit1->text() + " &"; |
1490 | system(command.latin1()); | 1494 | system(command.latin1()); |
1491 | } | 1495 | } |
1492 | } | 1496 | } |
1493 | 1497 | ||
1494 | void AdvancedFm::fileStatus() { | 1498 | void AdvancedFm::fileStatus() { |
1495 | QString curFile; | 1499 | QString curFile; |
1496 | if (TabWidget->currentPageIndex() == 0) { | 1500 | if (TabWidget->currentPageIndex() == 0) { |
1497 | curFile = Local_View->currentItem()->text(0); | 1501 | curFile = Local_View->currentItem()->text(0); |
1498 | } else { | 1502 | } else { |
1499 | curFile = Remote_View->currentItem()->text(0); | 1503 | curFile = Remote_View->currentItem()->text(0); |
1500 | } | 1504 | } |
1501 | QString command = " stat -l "+ curFile +" 2>&1"; | 1505 | QString command = " stat -l "+ curFile +" 2>&1"; |
1502 | Output *outDlg; | 1506 | Output *outDlg; |
1503 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1507 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1504 | outDlg->showMaximized(); | 1508 | outDlg->showMaximized(); |
1505 | outDlg->show(); | 1509 | outDlg->show(); |
1506 | qApp->processEvents(); | 1510 | qApp->processEvents(); |
1507 | FILE *fp; | 1511 | FILE *fp; |
1508 | char line[130]; | 1512 | char line[130]; |
1509 | sleep(1); | 1513 | sleep(1); |
1510 | fp = popen( (const char *) command, "r"); | 1514 | fp = popen( (const char *) command, "r"); |
1511 | if ( !fp ) { | 1515 | if ( !fp ) { |
1512 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1516 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1513 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 1517 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
1514 | pclose(fp); | 1518 | pclose(fp); |
1515 | return; | 1519 | return; |
1516 | } else { | 1520 | } else { |
1517 | while ( fgets( line, sizeof line, fp)) { | 1521 | while ( fgets( line, sizeof line, fp)) { |
1518 | outDlg->OutputEdit->append(line); | 1522 | outDlg->OutputEdit->append(line); |
1519 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1523 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1520 | 1524 | ||
1521 | } | 1525 | } |
1522 | 1526 | ||
1523 | } | 1527 | } |
1528 | pclose(fp); | ||
1524 | } | 1529 | } |
1525 | 1530 | ||
1526 | void AdvancedFm::mkDir() { | 1531 | void AdvancedFm::mkDir() { |
1527 | if (TabWidget->currentPageIndex() == 0) | 1532 | if (TabWidget->currentPageIndex() == 0) |
1528 | localMakDir(); | 1533 | localMakDir(); |
1529 | else | 1534 | else |
1530 | remoteMakDir(); | 1535 | remoteMakDir(); |
1531 | 1536 | ||
1532 | } | 1537 | } |
1533 | 1538 | ||
1534 | void AdvancedFm::rn() { | 1539 | void AdvancedFm::rn() { |
1535 | if (TabWidget->currentPageIndex() == 0) | 1540 | if (TabWidget->currentPageIndex() == 0) |
1536 | localRename(); | 1541 | localRename(); |
1537 | else | 1542 | else |
1538 | remoteRename(); | 1543 | remoteRename(); |
1539 | 1544 | ||
1540 | } | 1545 | } |
1541 | 1546 | ||
1542 | void AdvancedFm::del() { | 1547 | void AdvancedFm::del() { |
1543 | if (TabWidget->currentPageIndex() == 0) | 1548 | if (TabWidget->currentPageIndex() == 0) |
1544 | localDelete(); | 1549 | localDelete(); |
1545 | else | 1550 | else |
1546 | remoteDelete(); | 1551 | remoteDelete(); |
1547 | } | 1552 | } |
1548 | 1553 | ||
1549 | void AdvancedFm::doAbout() { | 1554 | void AdvancedFm::doAbout() { |
1550 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 1555 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
1551 | "is copyright 2002 by\n" | 1556 | "is copyright 2002 by\n" |
1552 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1557 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1553 | "and is licensed by the GPL")); | 1558 | "and is licensed by the GPL")); |
1554 | } | 1559 | } |
1555 | 1560 | ||
1556 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 1561 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
1557 | { | 1562 | { |
1558 | if( TabWidget->hasFocus()) | 1563 | if( TabWidget->hasFocus()) |
1559 | switch ( e->key() ) { | 1564 | switch ( e->key() ) { |
1560 | case Key_Delete: | 1565 | case Key_Delete: |
1561 | del(); | 1566 | del(); |
1562 | break; | 1567 | break; |
1563 | case Key_H: | 1568 | case Key_H: |
1564 | showHidden(); | 1569 | showHidden(); |
1565 | break; | 1570 | break; |
1566 | case Key_E: | 1571 | case Key_E: |
1567 | runThis(); | 1572 | runThis(); |
1568 | break; | 1573 | break; |
1569 | case Key_C: | 1574 | case Key_C: |
1570 | copy(); | 1575 | copy(); |
1571 | break; | 1576 | break; |
1572 | case Key_A: | 1577 | case Key_A: |
1573 | copyAs(); | 1578 | copyAs(); |
1574 | break; | 1579 | break; |
1575 | case Key_M: | 1580 | case Key_M: |
1576 | move(); | 1581 | move(); |
1577 | break; | 1582 | break; |
1578 | case Key_R: | 1583 | case Key_R: |
1579 | rn(); | 1584 | rn(); |
1580 | break; | 1585 | break; |
1581 | case Key_I: | 1586 | case Key_I: |
1582 | fileStatus(); | 1587 | fileStatus(); |
1583 | break; | 1588 | break; |
1584 | case Key_U: | 1589 | case Key_U: |
1585 | upDir(); | 1590 | upDir(); |
1586 | break; | 1591 | break; |
1587 | case Key_P: | 1592 | case Key_P: |
1588 | filePerms(); | 1593 | filePerms(); |
1589 | break; | 1594 | break; |
1590 | case Key_N: | 1595 | case Key_N: |
1591 | mkDir(); | 1596 | mkDir(); |
1592 | break; | 1597 | break; |
1593 | case Key_1: | 1598 | case Key_1: |
1594 | switchToLocalTab(); | 1599 | switchToLocalTab(); |
1595 | break; | 1600 | break; |
1596 | case Key_2: | 1601 | case Key_2: |
1597 | switchToRemoteTab(); | 1602 | switchToRemoteTab(); |
1598 | break; | 1603 | break; |
1599 | case Key_3: | 1604 | case Key_3: |
1600 | CFButtonPushed(); | 1605 | CFButtonPushed(); |
1601 | break; | 1606 | break; |
1602 | case Key_4: | 1607 | case Key_4: |
1603 | SDButtonPushed(); | 1608 | SDButtonPushed(); |
1604 | break; | 1609 | break; |
1605 | case Key_5: | 1610 | case Key_5: |
1606 | homeButtonPushed(); | 1611 | homeButtonPushed(); |
1607 | break; | 1612 | break; |
1608 | case Key_6: | 1613 | case Key_6: |
1609 | docButtonPushed(); | 1614 | docButtonPushed(); |
1610 | break; | 1615 | break; |
1611 | case Key_7: | 1616 | case Key_7: |
1612 | break; | 1617 | break; |
1613 | case Key_8: | 1618 | case Key_8: |
1614 | break; | 1619 | break; |
1615 | case Key_9: | 1620 | case Key_9: |
1616 | break; | 1621 | break; |
1617 | case Key_0: | 1622 | case Key_0: |
1618 | break; | 1623 | break; |
1619 | } | 1624 | } |
@@ -1743,103 +1748,122 @@ void AdvancedFm::doBeam() { | |||
1743 | } | 1748 | } |
1744 | } | 1749 | } |
1745 | } | 1750 | } |
1746 | 1751 | ||
1747 | } | 1752 | } |
1748 | 1753 | ||
1749 | void AdvancedFm::fileBeamFinished( Ir *ir) { | 1754 | void AdvancedFm::fileBeamFinished( Ir *ir) { |
1750 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 1755 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
1751 | 1756 | ||
1752 | } | 1757 | } |
1753 | 1758 | ||
1754 | void AdvancedFm::showFileMenu() { | 1759 | void AdvancedFm::showFileMenu() { |
1755 | 1760 | ||
1756 | QString curApp; | 1761 | QString curApp; |
1757 | bool isLocalView = false; | 1762 | bool isLocalView = false; |
1758 | if (TabWidget->currentPageIndex() == 0) { | 1763 | if (TabWidget->currentPageIndex() == 0) { |
1759 | isLocalView = TRUE; | 1764 | isLocalView = TRUE; |
1760 | curApp = Local_View->currentItem()->text(0); | 1765 | curApp = Local_View->currentItem()->text(0); |
1761 | } else { | 1766 | } else { |
1762 | curApp = Remote_View->currentItem()->text(0); | 1767 | curApp = Remote_View->currentItem()->text(0); |
1763 | } | 1768 | } |
1764 | 1769 | ||
1765 | MimeType mt( curApp ); | 1770 | MimeType mt( curApp ); |
1766 | const AppLnk* app = mt.application(); | 1771 | const AppLnk* app = mt.application(); |
1767 | QFile fi(curApp); | 1772 | QFile fi(curApp); |
1768 | 1773 | ||
1769 | QPopupMenu *m = new QPopupMenu(0); | 1774 | QPopupMenu *m = new QPopupMenu(0); |
1770 | 1775 | ||
1771 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 1776 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
1772 | m->insertSeparator(); | 1777 | m->insertSeparator(); |
1773 | if ( QFileInfo(fi).isDir() ) { | 1778 | if ( QFileInfo(fi).isDir() ) { |
1774 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 1779 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
1775 | } else { | 1780 | } else { |
1776 | 1781 | ||
1777 | if ( app ) | 1782 | if ( app ) |
1778 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); | 1783 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); |
1779 | else if( QFileInfo(fi).isExecutable() ) | 1784 | else if( QFileInfo(fi).isExecutable() ) |
1780 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 1785 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
1781 | 1786 | ||
1782 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 1787 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
1783 | } | 1788 | } |
1784 | m->insertSeparator(); | 1789 | m->insertSeparator(); |
1785 | 1790 | ||
1786 | 1791 | ||
1787 | if(isLocalView) | 1792 | if(isLocalView) |
1788 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 1793 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
1789 | else | 1794 | else |
1790 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 1795 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
1791 | 1796 | ||
1792 | m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 1797 | m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
1793 | m->insertSeparator(); | 1798 | m->insertSeparator(); |
1794 | 1799 | ||
1795 | if(isLocalView) | 1800 | if(isLocalView) |
1796 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 1801 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
1797 | else | 1802 | else |
1798 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 1803 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
1799 | 1804 | ||
1800 | m->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 1805 | m->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
1801 | m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 1806 | m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
1802 | m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 1807 | m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
1803 | m->insertItem( tr( "Move" ), this, SLOT( move() )); | 1808 | m->insertItem( tr( "Move" ), this, SLOT( move() )); |
1804 | m->insertSeparator(); | 1809 | m->insertSeparator(); |
1805 | 1810 | ||
1806 | if(isLocalView) | 1811 | if(isLocalView) |
1807 | m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); | 1812 | m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); |
1808 | else | 1813 | else |
1809 | m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); | 1814 | m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); |
1810 | 1815 | ||
1811 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 1816 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
1812 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 1817 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
1813 | m->insertSeparator(); | 1818 | m->insertSeparator(); |
1814 | 1819 | ||
1815 | if(isLocalView) | 1820 | if(isLocalView) |
1816 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 1821 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
1817 | else | 1822 | else |
1818 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 1823 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
1819 | 1824 | ||
1820 | m->insertSeparator(); | 1825 | m->insertSeparator(); |
1821 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 1826 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
1822 | 1827 | ||
1823 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings | 1828 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings |
1824 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 1829 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
1825 | m->setCheckable(TRUE); | 1830 | m->setCheckable(TRUE); |
1826 | if (!b) | 1831 | if (!b) |
1827 | m->setItemChecked(m->idAt(0),TRUE); | 1832 | m->setItemChecked(m->idAt(0),TRUE); |
1828 | else | 1833 | else |
1829 | m->setItemChecked(m->idAt(0),FALSE); | 1834 | m->setItemChecked(m->idAt(0),FALSE); |
1830 | if(Ir::supported()) | 1835 | if(Ir::supported()) |
1831 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 1836 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
1832 | m->setFocus(); | 1837 | m->setFocus(); |
1833 | m->exec( QCursor::pos() ); | 1838 | m->exec( QCursor::pos() ); |
1834 | sleep(1); | 1839 | sleep(1); |
1835 | if(m) delete m; | 1840 | if(m) delete m; |
1836 | } | 1841 | } |
1837 | 1842 | ||
1838 | 1843 | ||
1839 | void AdvancedFm::cancelMenuTimer() | 1844 | void AdvancedFm::cancelMenuTimer() { |
1840 | { | ||
1841 | 1845 | ||
1842 | qDebug("selectionChanged: cancel menu timer"); | 1846 | qDebug("selectionChanged: cancel menu timer"); |
1843 | if( menuTimer.isActive() ) | 1847 | if( menuTimer.isActive() ) |
1844 | menuTimer.stop(); | 1848 | menuTimer.stop(); |
1845 | } | 1849 | } |
1850 | |||
1851 | QString AdvancedFm::checkDiskSpace(const QString &path) { | ||
1852 | |||
1853 | struct statfs fss; | ||
1854 | if ( !statfs( path.latin1(), &fss ) ) { | ||
1855 | int blkSize = fss.f_bsize; | ||
1856 | // int totalBlks = fs.f_blocks; | ||
1857 | int availBlks = fss.f_bavail; | ||
1858 | |||
1859 | long mult = blkSize / 1024; | ||
1860 | long div = 1024 / blkSize; | ||
1861 | if ( !mult ) mult = 1; | ||
1862 | if ( !div ) div = 1; | ||
1863 | |||
1864 | |||
1865 | return QString::number(availBlks * mult / div); | ||
1866 | } | ||
1867 | return ""; | ||
1868 | } | ||
1869 | |||
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 45f00ad..78f0bad 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -20,124 +20,124 @@ | |||
20 | #include <qstringlist.h> | 20 | #include <qstringlist.h> |
21 | #include <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qpoint.h> | 23 | #include <qpoint.h> |
24 | #include <qtimer.h> | 24 | #include <qtimer.h> |
25 | 25 | ||
26 | class QVBoxLayout; | 26 | class QVBoxLayout; |
27 | class QHBoxLayout; | 27 | class QHBoxLayout; |
28 | class QGridLayout; | 28 | class QGridLayout; |
29 | class QComboBox; | 29 | class QComboBox; |
30 | class QListView; | 30 | class QListView; |
31 | class QListviewItem; | 31 | class QListviewItem; |
32 | class QLabel; | 32 | class QLabel; |
33 | class QProgressBar; | 33 | class QProgressBar; |
34 | class QSpinBox; | 34 | class QSpinBox; |
35 | class QTabWidget; | 35 | class QTabWidget; |
36 | class QWidget; | 36 | class QWidget; |
37 | class QPEToolBar; | 37 | class QPEToolBar; |
38 | class QPEMenuBar; | 38 | class QPEMenuBar; |
39 | class QPopupMenu; | 39 | class QPopupMenu; |
40 | class QFile; | 40 | class QFile; |
41 | class QListViewItem; | 41 | class QListViewItem; |
42 | class QLineEdit; | 42 | class QLineEdit; |
43 | //class QPushButton; | 43 | //class QPushButton; |
44 | class QToolButton; | 44 | class QToolButton; |
45 | class Ir; | 45 | class Ir; |
46 | 46 | ||
47 | class AdvancedFm : public QMainWindow | 47 | class AdvancedFm : public QMainWindow |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | AdvancedFm(); | 51 | AdvancedFm(); |
52 | ~AdvancedFm(); | 52 | ~AdvancedFm(); |
53 | 53 | ||
54 | QTabWidget *TabWidget; | 54 | QTabWidget *TabWidget; |
55 | QWidget *tab, *tab_2, *tab_3; | 55 | QWidget *tab, *tab_2, *tab_3; |
56 | QListView *Local_View, *Remote_View; | 56 | QListView *Local_View, *Remote_View; |
57 | 57 | ||
58 | QLineEdit *currentPathEdit; | 58 | QLineEdit *currentPathEdit; |
59 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; | 59 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; |
60 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 60 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
61 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 61 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
62 | QDir currentDir, currentRemoteDir; | 62 | QDir currentDir, currentRemoteDir; |
63 | QComboBox *currentPathCombo; | 63 | QComboBox *currentPathCombo; |
64 | QString filterStr; | 64 | QString filterStr; |
65 | QListViewItem * item; | 65 | QListViewItem * item; |
66 | bool b; | 66 | bool b; |
67 | QStringList fileSystemTypeList, fsList; | 67 | QStringList fileSystemTypeList, fsList; |
68 | int currentServerConfig; | 68 | int currentServerConfig; |
69 | protected slots: | 69 | protected slots: |
70 | void doLocalCd(); | 70 | void doLocalCd(); |
71 | void doRemoteCd(); | 71 | void doRemoteCd(); |
72 | // void copy(); | 72 | // void copy(); |
73 | void mkDir(); | 73 | void mkDir(); |
74 | void del(); | 74 | void del(); |
75 | void rn(); | 75 | void rn(); |
76 | void populateLocalView(); | 76 | void populateLocalView(); |
77 | void populateRemoteView(); | 77 | void populateRemoteView(); |
78 | void showHidden(); | 78 | void showHidden(); |
79 | void showRemoteHidden(); | 79 | void showRemoteHidden(); |
80 | void writeConfig(); | 80 | void writeConfig(); |
81 | void readConfig(); | 81 | void readConfig(); |
82 | void localListClicked(QListViewItem *); | 82 | void localListClicked(QListViewItem *); |
83 | void remoteListClicked(QListViewItem *); | 83 | void remoteListClicked(QListViewItem *); |
84 | void localListPressed( int, QListViewItem *, const QPoint&, int); | 84 | void localListPressed( int, QListViewItem *, const QPoint&, int); |
85 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); | 85 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); |
86 | void localMakDir(); | 86 | void localMakDir(); |
87 | void localDelete(); | 87 | void localDelete(); |
88 | void remoteMakDir(); | 88 | void remoteMakDir(); |
89 | void remoteDelete(); | 89 | void remoteDelete(); |
90 | /* bool remoteDirList(const QString &); */ | 90 | /* bool remoteDirList(const QString &); */ |
91 | /* bool remoteChDir(const QString &); */ | 91 | /* bool remoteChDir(const QString &); */ |
92 | void tabChanged(QWidget*); | 92 | void tabChanged(QWidget*); |
93 | void cleanUp(); | 93 | void cleanUp(); |
94 | void remoteRename(); | 94 | void remoteRename(); |
95 | void localRename(); | 95 | void localRename(); |
96 | void runThis(); | 96 | void runThis(); |
97 | void runText(); | 97 | void runText(); |
98 | void filePerms(); | 98 | void filePerms(); |
99 | void doProperties(); | 99 | void doProperties(); |
100 | void runCommand(); | 100 | void runCommand(); |
101 | void runCommandStd(); | 101 | void runCommandStd(); |
102 | QStringList getPath(); | 102 | QStringList getPath(); |
103 | void mkSym(); | 103 | void mkSym(); |
104 | void switchToLocalTab(); | 104 | void switchToLocalTab(); |
105 | void switchToRemoteTab(); | 105 | void switchToRemoteTab(); |
106 | 106 | ||
107 | protected: | 107 | protected: |
108 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; | 108 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; |
109 | QStringList remoteDirPathStringList, localDirPathStringList; | 109 | QStringList remoteDirPathStringList, localDirPathStringList; |
110 | 110 | ||
111 | void keyReleaseEvent( QKeyEvent *); | 111 | void keyReleaseEvent( QKeyEvent *); |
112 | QString getFileSystemType(const QString &); | 112 | QString getFileSystemType(const QString &); |
113 | QString getDiskSpace(const QString &); | 113 | QString getDiskSpace(const QString &); |
114 | 114 | ||
115 | void parsetab(const QString &fileName); | 115 | void parsetab(const QString &fileName); |
116 | 116 | QString checkDiskSpace(const QString &); | |
117 | protected slots: | 117 | protected slots: |
118 | void showFileMenu(); | 118 | void showFileMenu(); |
119 | void cancelMenuTimer(); | 119 | void cancelMenuTimer(); |
120 | void homeButtonPushed(); | 120 | void homeButtonPushed(); |
121 | void docButtonPushed(); | 121 | void docButtonPushed(); |
122 | void SDButtonPushed(); | 122 | void SDButtonPushed(); |
123 | void CFButtonPushed(); | 123 | void CFButtonPushed(); |
124 | void QPEButtonPushed(); | 124 | void QPEButtonPushed(); |
125 | void upDir(); | 125 | void upDir(); |
126 | void currentPathComboChanged(); | 126 | void currentPathComboChanged(); |
127 | void copy(); | 127 | void copy(); |
128 | void copyAs(); | 128 | void copyAs(); |
129 | void copySameDir(); | 129 | void copySameDir(); |
130 | void currentPathComboActivated(const QString &); | 130 | void currentPathComboActivated(const QString &); |
131 | void fillCombo(const QString &); | 131 | void fillCombo(const QString &); |
132 | bool copyFile( const QString & , const QString & ); | 132 | bool copyFile( const QString & , const QString & ); |
133 | void move(); | 133 | void move(); |
134 | void fileStatus(); | 134 | void fileStatus(); |
135 | void doAbout(); | 135 | void doAbout(); |
136 | void doBeam(); | 136 | void doBeam(); |
137 | void fileBeamFinished( Ir *); | 137 | void fileBeamFinished( Ir *); |
138 | 138 | ||
139 | private: | 139 | private: |
140 | QTimer menuTimer; | 140 | QTimer menuTimer; |
141 | }; | 141 | }; |
142 | 142 | ||
143 | #endif // ADVANCEDFM_H | 143 | #endif // ADVANCEDFM_H |