-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 22 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.pro | 28 |
2 files changed, 31 insertions, 19 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index b169a79..7ee78c0 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,533 +1,533 @@ | |||
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> | 73 | #include <sys/vfs.h> |
74 | #include <mntent.h> | 74 | #include <mntent.h> |
75 | 75 | ||
76 | AdvancedFm::AdvancedFm( ) | 76 | AdvancedFm::AdvancedFm( ) |
77 | : QMainWindow( ) | 77 | : QMainWindow( ) |
78 | { | 78 | { |
79 | setCaption( tr( "AdvancedFm" ) ); | 79 | setCaption( tr( "AdvancedFm" ) ); |
80 | 80 | ||
81 | QGridLayout *layout = new QGridLayout( this ); | 81 | QGridLayout *layout = new QGridLayout( this ); |
82 | layout->setSpacing( 2); | 82 | layout->setSpacing( 2); |
83 | layout->setMargin( 2); | 83 | layout->setMargin( 2); |
84 | 84 | ||
85 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 85 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
86 | 86 | ||
87 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 87 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
88 | fileMenu = new QPopupMenu( this ); | 88 | fileMenu = new QPopupMenu( this ); |
89 | viewMenu = new QPopupMenu( this ); | 89 | viewMenu = new QPopupMenu( this ); |
90 | 90 | ||
91 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); | 91 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); |
92 | 92 | ||
93 | menuBar->insertItem( tr( "File" ), fileMenu); | 93 | menuBar->insertItem( tr( "File" ), fileMenu); |
94 | menuBar->insertItem( tr( "View" ), viewMenu); | 94 | menuBar->insertItem( tr( "View" ), viewMenu); |
95 | 95 | ||
96 | qpeDirButton= new QToolButton(this,"QPEButton"); | 96 | qpeDirButton= new QToolButton(this,"QPEButton"); |
97 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); | 97 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); |
98 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); | 98 | qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); |
99 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); | 99 | connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); |
100 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); | 100 | layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); |
101 | 101 | ||
102 | cfButton = new QToolButton( this,"CFButton"); | 102 | cfButton = new QToolButton( this,"CFButton"); |
103 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); | 103 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); |
104 | cfButton ->setFixedSize( QSize( 20, 20 ) ); | 104 | cfButton ->setFixedSize( QSize( 20, 20 ) ); |
105 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); | 105 | connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); |
106 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); | 106 | layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); |
107 | 107 | ||
108 | sdButton = new QToolButton( this,"SDButton"); | 108 | sdButton = new QToolButton( this,"SDButton"); |
109 | sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); | 109 | sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); |
110 | sdButton->setFixedSize( QSize( 20, 20 ) ); | 110 | sdButton->setFixedSize( QSize( 20, 20 ) ); |
111 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); | 111 | connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); |
112 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); | 112 | layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); |
113 | 113 | ||
114 | cdUpButton = new QToolButton( this,"cdUpButton"); | 114 | cdUpButton = new QToolButton( this,"cdUpButton"); |
115 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 115 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
116 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 116 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
117 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 117 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
118 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); | 118 | layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); |
119 | 119 | ||
120 | docButton = new QToolButton( this,"docsButton"); | 120 | docButton = new QToolButton( this,"docsButton"); |
121 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); | 121 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); |
122 | docButton->setFixedSize( QSize( 20, 20 ) ); | 122 | docButton->setFixedSize( QSize( 20, 20 ) ); |
123 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 123 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
124 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); | 124 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6); |
125 | 125 | ||
126 | homeButton = new QToolButton( this,"homeButton"); | 126 | homeButton = new QToolButton( this,"homeButton"); |
127 | homeButton->setPixmap(Resource::loadPixmap("home")); | 127 | homeButton->setPixmap(Resource::loadPixmap("home")); |
128 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 128 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
129 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 129 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
130 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); | 130 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); |
131 | 131 | ||
132 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 132 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
133 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 133 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
134 | fileMenu->insertSeparator(); | 134 | fileMenu->insertSeparator(); |
135 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 135 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
136 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 136 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
137 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 137 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
138 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 138 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
139 | fileMenu->insertSeparator(); | 139 | fileMenu->insertSeparator(); |
140 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 140 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
141 | fileMenu->setCheckable(TRUE); | 141 | fileMenu->setCheckable(TRUE); |
142 | 142 | ||
143 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 143 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
144 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 144 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
145 | viewMenu->insertSeparator(); | 145 | viewMenu->insertSeparator(); |
146 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 146 | viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
147 | viewMenu->setCheckable(TRUE); | 147 | viewMenu->setCheckable(TRUE); |
148 | 148 | ||
149 | 149 | ||
150 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 150 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
151 | currentPathCombo->setEditable(TRUE); | 151 | currentPathCombo->setEditable(TRUE); |
152 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); | 152 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); |
153 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 153 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
154 | 154 | ||
155 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 155 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
156 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 156 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
157 | 157 | ||
158 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 158 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
159 | this,SLOT(currentPathComboChanged())); | 159 | this,SLOT(currentPathComboChanged())); |
160 | 160 | ||
161 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 161 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
162 | 162 | ||
163 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); | 163 | layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); |
164 | 164 | ||
165 | 165 | ||
166 | TabWidget = new QTabWidget( this, "TabWidget" ); | 166 | TabWidget = new QTabWidget( this, "TabWidget" ); |
167 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); | 167 | layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); |
168 | 168 | ||
169 | tab = new QWidget( TabWidget, "tab" ); | 169 | tab = new QWidget( TabWidget, "tab" ); |
170 | tabLayout = new QGridLayout( tab ); | 170 | tabLayout = new QGridLayout( tab ); |
171 | tabLayout->setSpacing( 2); | 171 | tabLayout->setSpacing( 2); |
172 | tabLayout->setMargin( 2); | 172 | tabLayout->setMargin( 2); |
173 | 173 | ||
174 | Local_View = new QListView( tab, "Local_View" ); | 174 | Local_View = new QListView( tab, "Local_View" ); |
175 | Local_View->addColumn( tr("File"),130); | 175 | Local_View->addColumn( tr("File"),130); |
176 | Local_View->addColumn( tr("Size"),-1); | 176 | Local_View->addColumn( tr("Size"),-1); |
177 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 177 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
178 | Local_View->addColumn( tr("Date"),-1); | 178 | Local_View->addColumn( tr("Date"),-1); |
179 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 179 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
180 | Local_View->setAllColumnsShowFocus(TRUE); | 180 | Local_View->setAllColumnsShowFocus(TRUE); |
181 | Local_View->setMultiSelection( TRUE ); | 181 | Local_View->setMultiSelection( TRUE ); |
182 | Local_View->setSelectionMode(QListView::Extended); | 182 | Local_View->setSelectionMode(QListView::Extended); |
183 | 183 | ||
184 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 184 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
185 | 185 | ||
186 | tabLayout->addWidget( Local_View, 0, 0 ); | 186 | tabLayout->addWidget( Local_View, 0, 0 ); |
187 | 187 | ||
188 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 188 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
189 | this,SLOT( localListClicked(QListViewItem *)) ); | 189 | this,SLOT( localListClicked(QListViewItem *)) ); |
190 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 190 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
191 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); | 191 | this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); |
192 | 192 | ||
193 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 193 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
194 | 194 | ||
195 | TabWidget->insertTab( tab, tr("1")); | 195 | TabWidget->insertTab( tab, tr("1")); |
196 | 196 | ||
197 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 197 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
198 | tabLayout_2 = new QGridLayout( tab_2 ); | 198 | tabLayout_2 = new QGridLayout( tab_2 ); |
199 | tabLayout_2->setSpacing( 2); | 199 | tabLayout_2->setSpacing( 2); |
200 | tabLayout_2->setMargin( 2); | 200 | tabLayout_2->setMargin( 2); |
201 | 201 | ||
202 | Remote_View = new QListView( tab_2, "Remote_View" ); | 202 | Remote_View = new QListView( tab_2, "Remote_View" ); |
203 | Remote_View->addColumn( tr("File"),130); | 203 | Remote_View->addColumn( tr("File"),130); |
204 | Remote_View->addColumn( tr("Size"),-1); | 204 | Remote_View->addColumn( tr("Size"),-1); |
205 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 205 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
206 | Remote_View->addColumn( tr("Date"),-1); | 206 | Remote_View->addColumn( tr("Date"),-1); |
207 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 207 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
208 | Remote_View->setAllColumnsShowFocus(TRUE); | 208 | Remote_View->setAllColumnsShowFocus(TRUE); |
209 | Remote_View->setMultiSelection( TRUE ); | 209 | Remote_View->setMultiSelection( TRUE ); |
210 | Remote_View->setSelectionMode(QListView::Extended); | 210 | Remote_View->setSelectionMode(QListView::Extended); |
211 | 211 | ||
212 | 212 | ||
213 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 213 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
214 | 214 | ||
215 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 215 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
216 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 216 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
217 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 217 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
218 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 218 | this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
219 | 219 | ||
220 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 220 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
221 | 221 | ||
222 | 222 | ||
223 | TabWidget->insertTab( tab_2, tr( "2")); | 223 | TabWidget->insertTab( tab_2, tr( "2")); |
224 | 224 | ||
225 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 225 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
226 | this,SLOT(tabChanged(QWidget*))); | 226 | this,SLOT(tabChanged(QWidget*))); |
227 | 227 | ||
228 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 228 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
229 | tabLayout_3 = new QGridLayout( tab_3 ); | 229 | tabLayout_3 = new QGridLayout( tab_3 ); |
230 | tabLayout_3->setSpacing( 2); | 230 | tabLayout_3->setSpacing( 2); |
231 | tabLayout_3->setMargin( 2); | 231 | tabLayout_3->setMargin( 2); |
232 | 232 | ||
233 | 233 | ||
234 | // OFileDialog fileDialog; | 234 | // OFileDialog fileDialog; |
235 | // fileDialog; | 235 | // fileDialog; |
236 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 236 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
237 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 237 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
238 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 238 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
239 | 239 | ||
240 | QListView *fileTree; | 240 | QListView *fileTree; |
241 | fileTree = new QListView( tab_3, "tree" ); | 241 | fileTree = new QListView( tab_3, "tree" ); |
242 | 242 | ||
243 | 243 | ||
244 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 244 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
245 | 245 | ||
246 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 246 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
247 | */ | 247 | */ |
248 | 248 | ||
249 | /////////////// | 249 | /////////////// |
250 | 250 | ||
251 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 251 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
252 | currentDir.setPath( QDir::currentDirPath()); | 252 | currentDir.setPath( QDir::currentDirPath()); |
253 | 253 | ||
254 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 254 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
255 | currentRemoteDir.setPath( QDir::currentDirPath()); | 255 | currentRemoteDir.setPath( QDir::currentDirPath()); |
256 | 256 | ||
257 | b = TRUE; | 257 | b = TRUE; |
258 | 258 | ||
259 | filterStr="*"; | 259 | filterStr="*"; |
260 | b=FALSE; | 260 | b=FALSE; |
261 | 261 | ||
262 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 262 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
263 | 263 | ||
264 | populateLocalView(); | 264 | populateLocalView(); |
265 | populateRemoteView(); | 265 | populateRemoteView(); |
266 | currentPathCombo->setFocus(); | 266 | currentPathCombo->setFocus(); |
267 | } | 267 | } |
268 | 268 | ||
269 | AdvancedFm::~AdvancedFm() | 269 | AdvancedFm::~AdvancedFm() |
270 | { | 270 | { |
271 | } | 271 | } |
272 | 272 | ||
273 | void AdvancedFm::cleanUp() | 273 | void AdvancedFm::cleanUp() |
274 | { | 274 | { |
275 | QString sfile=QDir::homeDirPath(); | 275 | QString sfile=QDir::homeDirPath(); |
276 | if(sfile.right(1) != "/") | 276 | if(sfile.right(1) != "/") |
277 | sfile+="/._temp"; | 277 | sfile+="/._temp"; |
278 | else | 278 | else |
279 | sfile+="._temp"; | 279 | sfile+="._temp"; |
280 | QFile file( sfile); | 280 | QFile file( sfile); |
281 | if(file.exists()) | 281 | if(file.exists()) |
282 | file.remove(); | 282 | file.remove(); |
283 | } | 283 | } |
284 | 284 | ||
285 | void AdvancedFm::tabChanged(QWidget *w) | 285 | void AdvancedFm::tabChanged(QWidget *w) |
286 | { | 286 | { |
287 | if (TabWidget->currentPageIndex() == 0) { | 287 | if (TabWidget->currentPageIndex() == 0) { |
288 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 288 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
289 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 289 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
290 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 290 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
291 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 291 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
292 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 292 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
293 | 293 | ||
294 | } | 294 | } |
295 | if (TabWidget->currentPageIndex() == 1) { | 295 | if (TabWidget->currentPageIndex() == 1) { |
296 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 296 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
297 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 297 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
298 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 298 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
299 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 299 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
300 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 300 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | void AdvancedFm::populateLocalView() | 305 | void AdvancedFm::populateLocalView() |
306 | { | 306 | { |
307 | QPixmap pm; | 307 | QPixmap pm; |
308 | Local_View->clear(); | 308 | Local_View->clear(); |
309 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 309 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
310 | currentDir.setMatchAllDirs(TRUE); | 310 | currentDir.setMatchAllDirs(TRUE); |
311 | currentDir.setNameFilter(filterStr); | 311 | currentDir.setNameFilter(filterStr); |
312 | QString fileL, fileS, fileDate; | 312 | QString fileL, fileS, fileDate; |
313 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 313 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
314 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 314 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
315 | bool isDir=FALSE; | 315 | bool isDir=FALSE; |
316 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 316 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
317 | QFileInfoListIterator it(*list); | 317 | QFileInfoListIterator it(*list); |
318 | QFileInfo *fi; | 318 | QFileInfo *fi; |
319 | while ( (fi=it.current()) ) { | 319 | while ( (fi=it.current()) ) { |
320 | if (fi->isSymLink() ) { | 320 | if (fi->isSymLink() ) { |
321 | QString symLink=fi->readLink(); | 321 | QString symLink=fi->readLink(); |
322 | QFileInfo sym( symLink); | 322 | QFileInfo sym( symLink); |
323 | fileS.sprintf( "%10li", sym.size() ); | 323 | fileS.sprintf( "%10li", sym.size() ); |
324 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 324 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
325 | fileDate = sym.lastModified().toString(); | 325 | fileDate = sym.lastModified().toString(); |
326 | } else { | 326 | } else { |
327 | fileS.sprintf( "%10li", fi->size() ); | 327 | fileS.sprintf( "%10li", fi->size() ); |
328 | fileL.sprintf( "%s",fi->fileName().data() ); | 328 | fileL.sprintf( "%s",fi->fileName().data() ); |
329 | fileDate= fi->lastModified().toString(); | 329 | fileDate= fi->lastModified().toString(); |
330 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 330 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
331 | fileL+="/"; | 331 | fileL+="/"; |
332 | isDir=TRUE; | 332 | isDir=TRUE; |
333 | } | 333 | } |
334 | } | 334 | } |
335 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 335 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
336 | if(fileL !="./" && fi->exists()) { | 336 | if(fileL !="./" && fi->exists()) { |
337 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 337 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
338 | 338 | ||
339 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 339 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
340 | 340 | ||
341 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 341 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
342 | pm = Resource::loadPixmap( "lockedfolder" ); | 342 | pm = Resource::loadPixmap( "lockedfolder" ); |
343 | else | 343 | else |
344 | pm= Resource::loadPixmap( "folder" ); | 344 | pm= Resource::loadPixmap( "folder" ); |
345 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 345 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
346 | pm = Resource::loadPixmap( "exec"); | 346 | pm = Resource::loadPixmap( "exec"); |
347 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 347 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
348 | | fileInfo.permission( QFileInfo::ExeGroup) | 348 | | fileInfo.permission( QFileInfo::ExeGroup) |
349 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 349 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
350 | pm = Resource::loadPixmap( "exec"); | 350 | pm = Resource::loadPixmap( "exec"); |
351 | } else if( !fi->isReadable() ) { | 351 | } else if( !fi->isReadable() ) { |
352 | pm = Resource::loadPixmap( "locked" ); | 352 | pm = Resource::loadPixmap( "locked" ); |
353 | } else { //everything else goes by mimetype | 353 | } else { //everything else goes by mimetype |
354 | MimeType mt(fi->filePath()); | 354 | MimeType mt(fi->filePath()); |
355 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 355 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
356 | if(pm.isNull()) | 356 | if(pm.isNull()) |
357 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 357 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
358 | } | 358 | } |
359 | item->setPixmap( 0,pm); | 359 | item->setPixmap( 0,pm); |
360 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 360 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
361 | // overlay link image | 361 | // overlay link image |
362 | pm= Resource::loadPixmap( "folder" ); | 362 | pm= Resource::loadPixmap( "folder" ); |
363 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 363 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
364 | QPainter painter( &pm ); | 364 | QPainter painter( &pm ); |
365 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 365 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
366 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 366 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
367 | item->setPixmap( 0, pm); | 367 | item->setPixmap( 0, pm); |
368 | } | 368 | } |
369 | } | 369 | } |
370 | isDir=FALSE; | 370 | isDir=FALSE; |
371 | ++it; | 371 | ++it; |
372 | } | 372 | } |
373 | 373 | ||
374 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 374 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
375 | struct stat buf; | 375 | struct stat buf; |
376 | dev_t devT; | 376 | dev_t devT; |
377 | DIR *dir; | 377 | DIR *dir; |
378 | struct dirent *mydirent; | 378 | struct dirent *mydirent; |
379 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 379 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
380 | while ((mydirent = readdir(dir)) != NULL) { | 380 | while ((mydirent = readdir(dir)) != NULL) { |
381 | lstat( mydirent->d_name, &buf); | 381 | lstat( mydirent->d_name, &buf); |
382 | qDebug(mydirent->d_name); | 382 | qDebug(mydirent->d_name); |
383 | fileL.sprintf("%s", mydirent->d_name); | 383 | fileL.sprintf("%s", mydirent->d_name); |
384 | devT = buf.st_dev; | 384 | devT = buf.st_dev; |
385 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 385 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
386 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 386 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
387 | if( fileL.find(".") == -1 ){ | 387 | if( fileL.find(".") == -1 ){ |
388 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 388 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
389 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 389 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
390 | item->setPixmap( 0,pm); | 390 | item->setPixmap( 0,pm); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | closedir(dir); | 394 | closedir(dir); |
395 | } | 395 | } |
396 | 396 | ||
397 | Local_View->setSorting( 3,FALSE); | 397 | Local_View->setSorting( 3,FALSE); |
398 | fillCombo( (const QString &) currentDir.canonicalPath()); | 398 | fillCombo( (const QString &) currentDir.canonicalPath()); |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void AdvancedFm::populateRemoteView() | 402 | void AdvancedFm::populateRemoteView() |
403 | { | 403 | { |
404 | QPixmap pm; | 404 | QPixmap pm; |
405 | Remote_View->clear(); | 405 | Remote_View->clear(); |
406 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 406 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
407 | currentRemoteDir.setMatchAllDirs(TRUE); | 407 | currentRemoteDir.setMatchAllDirs(TRUE); |
408 | currentRemoteDir.setNameFilter(filterStr); | 408 | currentRemoteDir.setNameFilter(filterStr); |
409 | QString fileL, fileS, fileDate; | 409 | QString fileL, fileS, fileDate; |
410 | 410 | ||
411 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 411 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
412 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 412 | setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
413 | bool isDir=FALSE; | 413 | bool isDir=FALSE; |
414 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 414 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
415 | QFileInfoListIterator it(*list); | 415 | QFileInfoListIterator it(*list); |
416 | QFileInfo *fi; | 416 | QFileInfo *fi; |
417 | while ( (fi=it.current()) ) { | 417 | while ( (fi=it.current()) ) { |
418 | if (fi->isSymLink() ){ | 418 | if (fi->isSymLink() ){ |
419 | QString symLink=fi->readLink(); | 419 | QString symLink=fi->readLink(); |
420 | // qDebug("Symlink detected "+symLink); | 420 | // qDebug("Symlink detected "+symLink); |
421 | QFileInfo sym( symLink); | 421 | QFileInfo sym( symLink); |
422 | fileS.sprintf( "%10li", sym.size() ); | 422 | fileS.sprintf( "%10li", sym.size() ); |
423 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 423 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
424 | fileDate = sym.lastModified().toString(); | 424 | fileDate = sym.lastModified().toString(); |
425 | } else { | 425 | } else { |
426 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 426 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
427 | fileS.sprintf( "%10li", fi->size() ); | 427 | fileS.sprintf( "%10li", fi->size() ); |
428 | fileL.sprintf( "%s",fi->fileName().data() ); | 428 | fileL.sprintf( "%s",fi->fileName().data() ); |
429 | fileDate= fi->lastModified().toString(); | 429 | fileDate= fi->lastModified().toString(); |
430 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 430 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
431 | fileL+="/"; | 431 | fileL+="/"; |
432 | isDir=TRUE; | 432 | isDir=TRUE; |
433 | // qDebug( fileL); | 433 | // qDebug( fileL); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); | 436 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); |
437 | if(fileL !="./" && fi->exists()) { | 437 | if(fileL !="./" && fi->exists()) { |
438 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 438 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
439 | QPixmap pm; | 439 | QPixmap pm; |
440 | 440 | ||
441 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 441 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
442 | if( !QDir( fi->filePath() ).isReadable()) | 442 | if( !QDir( fi->filePath() ).isReadable()) |
443 | pm = Resource::loadPixmap( "lockedfolder" ); | 443 | pm = Resource::loadPixmap( "lockedfolder" ); |
444 | else | 444 | else |
445 | pm= Resource::loadPixmap( "folder" ); | 445 | pm= Resource::loadPixmap( "folder" ); |
446 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 446 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
447 | pm = Resource::loadPixmap( "exec"); | 447 | pm = Resource::loadPixmap( "exec"); |
448 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 448 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
449 | | fileInfo.permission( QFileInfo::ExeGroup) | 449 | | fileInfo.permission( QFileInfo::ExeGroup) |
450 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 450 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
451 | pm = Resource::loadPixmap( "exec"); | 451 | pm = Resource::loadPixmap( "exec"); |
452 | } else if( !fi->isReadable() ) { | 452 | } else if( !fi->isReadable() ) { |
453 | pm = Resource::loadPixmap( "locked" ); | 453 | pm = Resource::loadPixmap( "locked" ); |
454 | } else { | 454 | } else { |
455 | MimeType mt(fi->filePath()); | 455 | MimeType mt(fi->filePath()); |
456 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 456 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
457 | if(pm.isNull()) | 457 | if(pm.isNull()) |
458 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 458 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
459 | } | 459 | } |
460 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 460 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
461 | // overlay link image | 461 | // overlay link image |
462 | pm= Resource::loadPixmap( "folder" ); | 462 | pm= Resource::loadPixmap( "folder" ); |
463 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 463 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
464 | QPainter painter( &pm ); | 464 | QPainter painter( &pm ); |
465 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 465 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
466 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 466 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
467 | } | 467 | } |
468 | item->setPixmap( 0, pm); | 468 | item->setPixmap( 0, pm); |
469 | } | 469 | } |
470 | isDir=FALSE; | 470 | isDir=FALSE; |
471 | ++it; | 471 | ++it; |
472 | } | 472 | } |
473 | 473 | ||
474 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 474 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
475 | struct stat buf; | 475 | struct stat buf; |
476 | DIR *dir; | 476 | DIR *dir; |
477 | struct dirent *mydirent; | 477 | struct dirent *mydirent; |
478 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 478 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
479 | while ((mydirent = readdir(dir)) != NULL) { | 479 | while ((mydirent = readdir(dir)) != NULL) { |
480 | lstat( mydirent->d_name, &buf); | 480 | lstat( mydirent->d_name, &buf); |
481 | qDebug(mydirent->d_name); | 481 | qDebug(mydirent->d_name); |
482 | fileL.sprintf("%s", mydirent->d_name); | 482 | fileL.sprintf("%s", mydirent->d_name); |
483 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 483 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
484 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 484 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
485 | if( fileL.find(".") == -1 ){ | 485 | if( fileL.find(".") == -1 ){ |
486 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 486 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
487 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 487 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
488 | item->setPixmap( 0,pm); | 488 | item->setPixmap( 0,pm); |
489 | } | 489 | } |
490 | } | 490 | } |
491 | 491 | ||
492 | closedir(dir); | 492 | closedir(dir); |
493 | } | 493 | } |
494 | 494 | ||
495 | Remote_View->setSorting( 3,FALSE); | 495 | Remote_View->setSorting( 3,FALSE); |
496 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 496 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
497 | } | 497 | } |
498 | 498 | ||
499 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) | 499 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) |
500 | { | 500 | { |
501 | if(selectedItem) { | 501 | if(selectedItem) { |
502 | QString strItem=selectedItem->text(0); | 502 | QString strItem=selectedItem->text(0); |
503 | QString strSize=selectedItem->text(1); | 503 | QString strSize=selectedItem->text(1); |
504 | strSize=strSize.stripWhiteSpace(); | 504 | strSize=strSize.stripWhiteSpace(); |
505 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 505 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
506 | // is symlink | 506 | // is symlink |
507 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 507 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
508 | if(QDir(strItem2).exists() ) { | 508 | if(QDir(strItem2).exists() ) { |
509 | currentDir.cd(strItem2, TRUE); | 509 | currentDir.cd(strItem2, TRUE); |
510 | populateLocalView(); | 510 | populateLocalView(); |
511 | } | 511 | } |
512 | } else { // not a symlink | 512 | } else { // not a symlink |
513 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 513 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
514 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 514 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
515 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 515 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
516 | currentDir.cd(strItem,FALSE); | 516 | currentDir.cd(strItem,FALSE); |
517 | populateLocalView(); | 517 | populateLocalView(); |
518 | } else { | 518 | } else { |
519 | currentDir.cdUp(); | 519 | currentDir.cdUp(); |
520 | populateLocalView(); | 520 | populateLocalView(); |
521 | } | 521 | } |
522 | if(QDir(strItem).exists()){ | 522 | if(QDir(strItem).exists()){ |
523 | currentDir.cd(strItem, TRUE); | 523 | currentDir.cd(strItem, TRUE); |
524 | populateLocalView(); | 524 | populateLocalView(); |
525 | } | 525 | } |
526 | } else { | 526 | } else { |
527 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 527 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
528 | if( QFile::exists(strItem ) ) { | 528 | if( QFile::exists(strItem ) ) { |
529 | // qDebug("clicked item "+strItem); | 529 | // qDebug("clicked item "+strItem); |
530 | // DocLnk doc( strItem, FALSE ); | 530 | // DocLnk doc( strItem, FALSE ); |
531 | // doc.execute(); | 531 | // doc.execute(); |
532 | // Local_View->clearSelection(); | 532 | // Local_View->clearSelection(); |
533 | } | 533 | } |
@@ -1223,666 +1223,678 @@ void AdvancedFm::copyAs() { | |||
1223 | fileDlg->setInputText((const QString &) destFile); | 1223 | fileDlg->setInputText((const QString &) destFile); |
1224 | fileDlg->exec(); | 1224 | fileDlg->exec(); |
1225 | 1225 | ||
1226 | if( fileDlg->result() == 1 ) { | 1226 | if( fileDlg->result() == 1 ) { |
1227 | QString filename = fileDlg->LineEdit1->text(); | 1227 | QString filename = fileDlg->LineEdit1->text(); |
1228 | destFile = currentDir.canonicalPath()+"/"+filename; | 1228 | destFile = currentDir.canonicalPath()+"/"+filename; |
1229 | 1229 | ||
1230 | QFile f( destFile); | 1230 | QFile f( destFile); |
1231 | if( f.exists()) { | 1231 | if( f.exists()) { |
1232 | switch ( QMessageBox::warning(this,tr("Delete"), | 1232 | switch ( QMessageBox::warning(this,tr("Delete"), |
1233 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1233 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1234 | tr("Yes"),tr("No"),0,0,1) ) { | 1234 | tr("Yes"),tr("No"),0,0,1) ) { |
1235 | case 0: | 1235 | case 0: |
1236 | f.remove(); | 1236 | f.remove(); |
1237 | break; | 1237 | break; |
1238 | case 1: | 1238 | case 1: |
1239 | return; | 1239 | return; |
1240 | break; | 1240 | break; |
1241 | }; | 1241 | }; |
1242 | } | 1242 | } |
1243 | if(!copyFile(destFile, curFile) ) { | 1243 | if(!copyFile(destFile, curFile) ) { |
1244 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | 1244 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); |
1245 | qWarning("nothin doing"); | 1245 | qWarning("nothin doing"); |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | } | 1248 | } |
1249 | delete fileDlg; | 1249 | delete fileDlg; |
1250 | 1250 | ||
1251 | } | 1251 | } |
1252 | populateLocalView(); | 1252 | populateLocalView(); |
1253 | TabWidget->setCurrentPage(0); | 1253 | TabWidget->setCurrentPage(0); |
1254 | } | 1254 | } |
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | void AdvancedFm::copySameDir() { | 1257 | void AdvancedFm::copySameDir() { |
1258 | qApp->processEvents(); | 1258 | qApp->processEvents(); |
1259 | QStringList curFileList = getPath(); | 1259 | QStringList curFileList = getPath(); |
1260 | QString curFile; | 1260 | QString curFile; |
1261 | InputDialog *fileDlg; | 1261 | InputDialog *fileDlg; |
1262 | 1262 | ||
1263 | if (TabWidget->currentPageIndex() == 0) { | 1263 | if (TabWidget->currentPageIndex() == 0) { |
1264 | 1264 | ||
1265 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1265 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1266 | 1266 | ||
1267 | QString destFile; | 1267 | QString destFile; |
1268 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1268 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1269 | 1269 | ||
1270 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 1270 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
1271 | fileDlg->setInputText((const QString &) destFile ); | 1271 | fileDlg->setInputText((const QString &) destFile ); |
1272 | fileDlg->exec(); | 1272 | fileDlg->exec(); |
1273 | 1273 | ||
1274 | if( fileDlg->result() == 1 ) { | 1274 | if( fileDlg->result() == 1 ) { |
1275 | 1275 | ||
1276 | QString filename = fileDlg->LineEdit1->text(); | 1276 | QString filename = fileDlg->LineEdit1->text(); |
1277 | destFile = currentDir.canonicalPath()+"/"+filename; | 1277 | destFile = currentDir.canonicalPath()+"/"+filename; |
1278 | 1278 | ||
1279 | QFile f(destFile); | 1279 | QFile f(destFile); |
1280 | if( f.exists()) { | 1280 | if( f.exists()) { |
1281 | switch (QMessageBox::warning(this,tr("Delete"), | 1281 | switch (QMessageBox::warning(this,tr("Delete"), |
1282 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1282 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1283 | tr("Yes"),tr("No"),0,0,1) ) { | 1283 | tr("Yes"),tr("No"),0,0,1) ) { |
1284 | case 0: | 1284 | case 0: |
1285 | qDebug(""); | 1285 | qDebug(""); |
1286 | f.remove(); | 1286 | f.remove(); |
1287 | break; | 1287 | break; |
1288 | case 1: | 1288 | case 1: |
1289 | return; | 1289 | return; |
1290 | break; | 1290 | break; |
1291 | }; | 1291 | }; |
1292 | } | 1292 | } |
1293 | if(!copyFile(destFile, curFile) ) { | 1293 | if(!copyFile(destFile, curFile) ) { |
1294 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | 1294 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); |
1295 | qWarning("nothin doing"); | 1295 | qWarning("nothin doing"); |
1296 | } | 1296 | } |
1297 | 1297 | ||
1298 | qDebug("copy "+curFile+" as "+destFile); | 1298 | qDebug("copy "+curFile+" as "+destFile); |
1299 | } | 1299 | } |
1300 | delete fileDlg; | 1300 | delete fileDlg; |
1301 | } | 1301 | } |
1302 | populateLocalView(); | 1302 | populateLocalView(); |
1303 | 1303 | ||
1304 | } else { | 1304 | } else { |
1305 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1305 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1306 | 1306 | ||
1307 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1307 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1308 | 1308 | ||
1309 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 1309 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
1310 | QString destFile; | 1310 | QString destFile; |
1311 | fileDlg->setInputText((const QString &) destFile); | 1311 | fileDlg->setInputText((const QString &) destFile); |
1312 | fileDlg->exec(); | 1312 | fileDlg->exec(); |
1313 | if( fileDlg->result() == 1 ) { | 1313 | if( fileDlg->result() == 1 ) { |
1314 | QString filename = fileDlg->LineEdit1->text(); | 1314 | QString filename = fileDlg->LineEdit1->text(); |
1315 | 1315 | ||
1316 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 1316 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
1317 | 1317 | ||
1318 | QFile f(destFile); | 1318 | QFile f(destFile); |
1319 | if( f.exists()) { | 1319 | if( f.exists()) { |
1320 | switch ( QMessageBox::warning(this,tr("Delete"), | 1320 | switch ( QMessageBox::warning(this,tr("Delete"), |
1321 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1321 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1322 | tr("Yes"),tr("No"),0,0,1) ) { | 1322 | tr("Yes"),tr("No"),0,0,1) ) { |
1323 | case 0: | 1323 | case 0: |
1324 | f.remove(); | 1324 | f.remove(); |
1325 | break; | 1325 | break; |
1326 | case 1: | 1326 | case 1: |
1327 | return; | 1327 | return; |
1328 | break; | 1328 | break; |
1329 | }; | 1329 | }; |
1330 | } | 1330 | } |
1331 | if(!copyFile(destFile, curFile) ) { | 1331 | if(!copyFile(destFile, curFile) ) { |
1332 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | 1332 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); |
1333 | qWarning("nothin doing"); | 1333 | qWarning("nothin doing"); |
1334 | } | 1334 | } |
1335 | qDebug("copy "+curFile+" as "+destFile); | 1335 | qDebug("copy "+curFile+" as "+destFile); |
1336 | } | 1336 | } |
1337 | delete fileDlg; | 1337 | delete fileDlg; |
1338 | } | 1338 | } |
1339 | populateRemoteView(); | 1339 | populateRemoteView(); |
1340 | } | 1340 | } |
1341 | } | 1341 | } |
1342 | 1342 | ||
1343 | void AdvancedFm::move() { | 1343 | void AdvancedFm::move() { |
1344 | qApp->processEvents(); | 1344 | qApp->processEvents(); |
1345 | 1345 | ||
1346 | QStringList curFileList = getPath(); | 1346 | QStringList curFileList = getPath(); |
1347 | if( curFileList.count() > 0) { | 1347 | if( curFileList.count() > 0) { |
1348 | QString curFile; | 1348 | QString curFile; |
1349 | QString destFile; | 1349 | QString destFile; |
1350 | 1350 | ||
1351 | if (TabWidget->currentPageIndex() == 0) { | 1351 | if (TabWidget->currentPageIndex() == 0) { |
1352 | 1352 | ||
1353 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1353 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1354 | 1354 | ||
1355 | QString destFile = currentRemoteDir.canonicalPath(); | 1355 | QString destFile = currentRemoteDir.canonicalPath(); |
1356 | 1356 | ||
1357 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1357 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1358 | destFile+="/"; | 1358 | destFile+="/"; |
1359 | destFile +=(*it); | 1359 | destFile +=(*it); |
1360 | curFile = currentDir.canonicalPath(); | 1360 | curFile = currentDir.canonicalPath(); |
1361 | 1361 | ||
1362 | qDebug("Destination file is "+destFile); | 1362 | qDebug("Destination file is "+destFile); |
1363 | 1363 | ||
1364 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1364 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1365 | curFile +="/"; | 1365 | curFile +="/"; |
1366 | 1366 | ||
1367 | curFile+=(*it); | 1367 | curFile+=(*it); |
1368 | qDebug("CurrentFile file is " + curFile); | 1368 | qDebug("CurrentFile file is " + curFile); |
1369 | 1369 | ||
1370 | QFile f( curFile); | 1370 | QFile f( curFile); |
1371 | if( f.exists()) { | 1371 | if( f.exists()) { |
1372 | if(!copyFile( destFile, curFile) ) { | 1372 | if(!copyFile( destFile, curFile) ) { |
1373 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 1373 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
1374 | return; | 1374 | return; |
1375 | } else | 1375 | } else |
1376 | QFile::remove(curFile); | 1376 | QFile::remove(curFile); |
1377 | } | 1377 | } |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | TabWidget->setCurrentPage(1); | 1380 | TabWidget->setCurrentPage(1); |
1381 | 1381 | ||
1382 | } else { //view 2 | 1382 | } else { //view 2 |
1383 | 1383 | ||
1384 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1384 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1385 | 1385 | ||
1386 | QString destFile = currentDir.canonicalPath(); | 1386 | QString destFile = currentDir.canonicalPath(); |
1387 | 1387 | ||
1388 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1388 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1389 | destFile+="/"; | 1389 | destFile+="/"; |
1390 | 1390 | ||
1391 | destFile +=(*it); | 1391 | destFile +=(*it); |
1392 | 1392 | ||
1393 | qDebug("Destination file is "+destFile); | 1393 | qDebug("Destination file is "+destFile); |
1394 | 1394 | ||
1395 | curFile = currentRemoteDir.canonicalPath(); | 1395 | curFile = currentRemoteDir.canonicalPath(); |
1396 | 1396 | ||
1397 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1397 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1398 | curFile +="/"; | 1398 | curFile +="/"; |
1399 | curFile+=(*it); | 1399 | curFile+=(*it); |
1400 | qDebug("CurrentFile file is " + curFile); | 1400 | qDebug("CurrentFile file is " + curFile); |
1401 | 1401 | ||
1402 | QFile f( curFile); | 1402 | QFile f( curFile); |
1403 | if( f.exists()) { | 1403 | if( f.exists()) { |
1404 | if(!copyFile( destFile, curFile) ) { | 1404 | if(!copyFile( destFile, curFile) ) { |
1405 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | 1405 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); |
1406 | return; | 1406 | return; |
1407 | } else | 1407 | } else |
1408 | QFile::remove( curFile); | 1408 | QFile::remove( curFile); |
1409 | } | 1409 | } |
1410 | TabWidget->setCurrentPage(0); | 1410 | TabWidget->setCurrentPage(0); |
1411 | } | 1411 | } |
1412 | } | 1412 | } |
1413 | populateRemoteView(); | 1413 | populateRemoteView(); |
1414 | populateLocalView(); | 1414 | populateLocalView(); |
1415 | } | 1415 | } |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { | 1418 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { |
1419 | char bf[ 50000 ]; | 1419 | char bf[ 50000 ]; |
1420 | int bytesRead; | 1420 | int bytesRead; |
1421 | bool success = TRUE; | 1421 | bool success = TRUE; |
1422 | struct stat status; | 1422 | struct stat status; |
1423 | 1423 | ||
1424 | QFile s( src ); | 1424 | QFile s( src ); |
1425 | QFile d( dest ); | 1425 | QFile d( dest ); |
1426 | 1426 | ||
1427 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 1427 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
1428 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 1428 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
1429 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 1429 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
1430 | success = FALSE; | 1430 | success = FALSE; |
1431 | break; | 1431 | break; |
1432 | } | 1432 | } |
1433 | } | 1433 | } |
1434 | if( success && (bytesRead > 0) ){ | 1434 | if( success && (bytesRead > 0) ){ |
1435 | d.writeBlock( bf, bytesRead ); | 1435 | d.writeBlock( bf, bytesRead ); |
1436 | } | 1436 | } |
1437 | } else { | 1437 | } else { |
1438 | success = FALSE; | 1438 | success = FALSE; |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | // Set file permissions | 1441 | // Set file permissions |
1442 | if( stat( (const char *) src, &status ) == 0 ){ | 1442 | if( stat( (const char *) src, &status ) == 0 ){ |
1443 | chmod( (const char *) dest, status.st_mode ); | 1443 | chmod( (const char *) dest, status.st_mode ); |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | return success; | 1446 | return success; |
1447 | } | 1447 | } |
1448 | 1448 | ||
1449 | void AdvancedFm::runCommand() { | 1449 | void AdvancedFm::runCommand() { |
1450 | QString curFile; | 1450 | QString curFile; |
1451 | if (TabWidget->currentPageIndex() == 0) { | 1451 | if (TabWidget->currentPageIndex() == 0) { |
1452 | if( Local_View->currentItem()) | 1452 | if( Local_View->currentItem()) |
1453 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 1453 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1454 | } else { | 1454 | } else { |
1455 | if(Remote_View->currentItem()) | 1455 | if(Remote_View->currentItem()) |
1456 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 1456 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
1457 | } | 1457 | } |
1458 | 1458 | ||
1459 | InputDialog *fileDlg; | 1459 | InputDialog *fileDlg; |
1460 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1460 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1461 | fileDlg->setInputText(curFile); | 1461 | fileDlg->setInputText(curFile); |
1462 | fileDlg->exec(); | 1462 | fileDlg->exec(); |
1463 | QString command; | 1463 | QString command; |
1464 | if( fileDlg->result() == 1 ) { | 1464 | if( fileDlg->result() == 1 ) { |
1465 | command = fileDlg->LineEdit1->text(); | 1465 | command = fileDlg->LineEdit1->text(); |
1466 | 1466 | ||
1467 | Output *outDlg; | 1467 | Output *outDlg; |
1468 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1468 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1469 | outDlg->showMaximized(); | 1469 | outDlg->showMaximized(); |
1470 | outDlg->show(); | 1470 | outDlg->show(); |
1471 | qApp->processEvents(); | 1471 | qApp->processEvents(); |
1472 | FILE *fp; | 1472 | FILE *fp; |
1473 | char line[130]; | 1473 | char line[130]; |
1474 | sleep(1); | 1474 | sleep(1); |
1475 | command +=" 2>&1"; | 1475 | command +=" 2>&1"; |
1476 | fp = popen( (const char *) command, "r"); | 1476 | fp = popen( (const char *) command, "r"); |
1477 | if ( !fp ) { | 1477 | if ( !fp ) { |
1478 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1478 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1479 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 1479 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
1480 | pclose(fp); | 1480 | pclose(fp); |
1481 | return; | 1481 | return; |
1482 | } else { | 1482 | } else { |
1483 | while ( fgets( line, sizeof line, fp)) { | 1483 | while ( fgets( line, sizeof line, fp)) { |
1484 | QString lineStr = line; | 1484 | QString lineStr = line; |
1485 | lineStr=lineStr.left(lineStr.length()-1); | 1485 | lineStr=lineStr.left(lineStr.length()-1); |
1486 | outDlg->OutputEdit->append(lineStr); | 1486 | outDlg->OutputEdit->append(lineStr); |
1487 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1487 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1488 | } | 1488 | } |
1489 | } | 1489 | } |
1490 | pclose(fp); | 1490 | pclose(fp); |
1491 | 1491 | ||
1492 | } | 1492 | } |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | void AdvancedFm::runCommandStd() { | 1495 | void AdvancedFm::runCommandStd() { |
1496 | QString curFile; | 1496 | QString curFile; |
1497 | if (TabWidget->currentPageIndex() == 0) { | 1497 | if (TabWidget->currentPageIndex() == 0) { |
1498 | if( Local_View->currentItem()) | 1498 | if( Local_View->currentItem()) |
1499 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 1499 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1500 | } else { | 1500 | } else { |
1501 | if(Remote_View->currentItem()) | 1501 | if(Remote_View->currentItem()) |
1502 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); | 1502 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); |
1503 | } | 1503 | } |
1504 | 1504 | ||
1505 | InputDialog *fileDlg; | 1505 | InputDialog *fileDlg; |
1506 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1506 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1507 | fileDlg->setInputText(curFile); | 1507 | fileDlg->setInputText(curFile); |
1508 | fileDlg->exec(); | 1508 | fileDlg->exec(); |
1509 | QString command; | 1509 | QString command; |
1510 | if( fileDlg->result() == 1 ) { | 1510 | if( fileDlg->result() == 1 ) { |
1511 | qApp->processEvents(); | 1511 | qApp->processEvents(); |
1512 | command = fileDlg->LineEdit1->text() + " &"; | 1512 | command = fileDlg->LineEdit1->text() + " &"; |
1513 | system(command.latin1()); | 1513 | system(command.latin1()); |
1514 | } | 1514 | } |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | void AdvancedFm::fileStatus() { | 1517 | void AdvancedFm::fileStatus() { |
1518 | QString curFile; | 1518 | QString curFile; |
1519 | if (TabWidget->currentPageIndex() == 0) { | 1519 | if (TabWidget->currentPageIndex() == 0) { |
1520 | curFile = Local_View->currentItem()->text(0); | 1520 | curFile = Local_View->currentItem()->text(0); |
1521 | } else { | 1521 | } else { |
1522 | curFile = Remote_View->currentItem()->text(0); | 1522 | curFile = Remote_View->currentItem()->text(0); |
1523 | } | 1523 | } |
1524 | QString command = " stat -l "+ curFile +" 2>&1"; | 1524 | QString command = " stat -l "+ curFile +" 2>&1"; |
1525 | Output *outDlg; | 1525 | Output *outDlg; |
1526 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1526 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1527 | outDlg->showMaximized(); | 1527 | outDlg->showMaximized(); |
1528 | outDlg->show(); | 1528 | outDlg->show(); |
1529 | qApp->processEvents(); | 1529 | qApp->processEvents(); |
1530 | FILE *fp; | 1530 | FILE *fp; |
1531 | char line[130]; | 1531 | char line[130]; |
1532 | sleep(1); | 1532 | sleep(1); |
1533 | fp = popen( (const char *) command, "r"); | 1533 | fp = popen( (const char *) command, "r"); |
1534 | if ( !fp ) { | 1534 | if ( !fp ) { |
1535 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1535 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1536 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 1536 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
1537 | pclose(fp); | 1537 | pclose(fp); |
1538 | return; | 1538 | return; |
1539 | } else { | 1539 | } else { |
1540 | while ( fgets( line, sizeof line, fp)) { | 1540 | while ( fgets( line, sizeof line, fp)) { |
1541 | outDlg->OutputEdit->append(line); | 1541 | outDlg->OutputEdit->append(line); |
1542 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1542 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1543 | 1543 | ||
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | } | 1546 | } |
1547 | pclose(fp); | 1547 | pclose(fp); |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | void AdvancedFm::mkDir() { | 1550 | void AdvancedFm::mkDir() { |
1551 | if (TabWidget->currentPageIndex() == 0) | 1551 | if (TabWidget->currentPageIndex() == 0) |
1552 | localMakDir(); | 1552 | localMakDir(); |
1553 | else | 1553 | else |
1554 | remoteMakDir(); | 1554 | remoteMakDir(); |
1555 | 1555 | ||
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | void AdvancedFm::rn() { | 1558 | void AdvancedFm::rn() { |
1559 | if (TabWidget->currentPageIndex() == 0) | 1559 | if (TabWidget->currentPageIndex() == 0) |
1560 | localRename(); | 1560 | localRename(); |
1561 | else | 1561 | else |
1562 | remoteRename(); | 1562 | remoteRename(); |
1563 | 1563 | ||
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | void AdvancedFm::del() { | 1566 | void AdvancedFm::del() { |
1567 | if (TabWidget->currentPageIndex() == 0) | 1567 | if (TabWidget->currentPageIndex() == 0) |
1568 | localDelete(); | 1568 | localDelete(); |
1569 | else | 1569 | else |
1570 | remoteDelete(); | 1570 | remoteDelete(); |
1571 | } | 1571 | } |
1572 | 1572 | ||
1573 | void AdvancedFm::doAbout() { | 1573 | void AdvancedFm::doAbout() { |
1574 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 1574 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
1575 | "is copyright 2002 by\n" | 1575 | "is copyright 2002 by\n" |
1576 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1576 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1577 | "and is licensed by the GPL")); | 1577 | "and is licensed by the GPL")); |
1578 | } | 1578 | } |
1579 | 1579 | ||
1580 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 1580 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
1581 | { | 1581 | { |
1582 | if( TabWidget->hasFocus()) | 1582 | if( TabWidget->hasFocus()) |
1583 | switch ( e->key() ) { | 1583 | switch ( e->key() ) { |
1584 | case Key_Delete: | 1584 | case Key_Delete: |
1585 | del(); | 1585 | del(); |
1586 | break; | 1586 | break; |
1587 | case Key_H: | 1587 | case Key_H: |
1588 | showHidden(); | 1588 | showHidden(); |
1589 | break; | 1589 | break; |
1590 | case Key_E: | 1590 | case Key_E: |
1591 | runThis(); | 1591 | runThis(); |
1592 | break; | 1592 | break; |
1593 | case Key_C: | 1593 | case Key_C: |
1594 | copy(); | 1594 | copy(); |
1595 | break; | 1595 | break; |
1596 | case Key_A: | 1596 | case Key_A: |
1597 | copyAs(); | 1597 | copyAs(); |
1598 | break; | 1598 | break; |
1599 | case Key_M: | 1599 | case Key_M: |
1600 | move(); | 1600 | move(); |
1601 | break; | 1601 | break; |
1602 | case Key_R: | 1602 | case Key_R: |
1603 | rn(); | 1603 | rn(); |
1604 | break; | 1604 | break; |
1605 | case Key_I: | 1605 | case Key_I: |
1606 | fileStatus(); | 1606 | fileStatus(); |
1607 | break; | 1607 | break; |
1608 | case Key_U: | 1608 | case Key_U: |
1609 | upDir(); | 1609 | upDir(); |
1610 | break; | 1610 | break; |
1611 | case Key_P: | 1611 | case Key_P: |
1612 | filePerms(); | 1612 | filePerms(); |
1613 | break; | 1613 | break; |
1614 | case Key_N: | 1614 | case Key_N: |
1615 | mkDir(); | 1615 | mkDir(); |
1616 | break; | 1616 | break; |
1617 | case Key_1: | 1617 | case Key_1: |
1618 | switchToLocalTab(); | 1618 | switchToLocalTab(); |
1619 | break; | 1619 | break; |
1620 | case Key_2: | 1620 | case Key_2: |
1621 | switchToRemoteTab(); | 1621 | switchToRemoteTab(); |
1622 | break; | 1622 | break; |
1623 | case Key_3: | 1623 | case Key_3: |
1624 | CFButtonPushed(); | 1624 | CFButtonPushed(); |
1625 | break; | 1625 | break; |
1626 | case Key_4: | 1626 | case Key_4: |
1627 | SDButtonPushed(); | 1627 | SDButtonPushed(); |
1628 | break; | 1628 | break; |
1629 | case Key_5: | 1629 | case Key_5: |
1630 | homeButtonPushed(); | 1630 | homeButtonPushed(); |
1631 | break; | 1631 | break; |
1632 | case Key_6: | 1632 | case Key_6: |
1633 | docButtonPushed(); | 1633 | docButtonPushed(); |
1634 | break; | 1634 | break; |
1635 | case Key_7: | 1635 | case Key_7: |
1636 | break; | 1636 | break; |
1637 | case Key_8: | 1637 | case Key_8: |
1638 | break; | 1638 | break; |
1639 | case Key_9: | 1639 | case Key_9: |
1640 | break; | 1640 | break; |
1641 | case Key_0: | 1641 | case Key_0: |
1642 | break; | 1642 | break; |
1643 | } | 1643 | } |
1644 | } | 1644 | } |
1645 | 1645 | ||
1646 | void AdvancedFm::mkSym() { | 1646 | void AdvancedFm::mkSym() { |
1647 | QString cmd; | 1647 | QString cmd; |
1648 | QStringList curFileList = getPath(); | 1648 | QStringList curFileList = getPath(); |
1649 | if( curFileList.count() > 0) { | 1649 | if( curFileList.count() > 0) { |
1650 | 1650 | ||
1651 | if (TabWidget->currentPageIndex() == 0) { | 1651 | if (TabWidget->currentPageIndex() == 0) { |
1652 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1652 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1653 | 1653 | ||
1654 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 1654 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
1655 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 1655 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
1656 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 1656 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
1657 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1657 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1658 | cmd = "ln -s "+curFile+" "+destName; | 1658 | cmd = "ln -s "+curFile+" "+destName; |
1659 | qDebug(cmd); | 1659 | qDebug(cmd); |
1660 | system(cmd.latin1() ); | 1660 | system(cmd.latin1() ); |
1661 | } | 1661 | } |
1662 | populateRemoteView(); | 1662 | populateRemoteView(); |
1663 | TabWidget->setCurrentPage(1); | 1663 | TabWidget->setCurrentPage(1); |
1664 | } else { | 1664 | } else { |
1665 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1665 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1666 | 1666 | ||
1667 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 1667 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
1668 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 1668 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
1669 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1669 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1670 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1670 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1671 | 1671 | ||
1672 | cmd = "ln -s "+curFile+" "+destName; | 1672 | cmd = "ln -s "+curFile+" "+destName; |
1673 | qDebug(cmd); | 1673 | qDebug(cmd); |
1674 | system(cmd.latin1() ); | 1674 | system(cmd.latin1() ); |
1675 | } | 1675 | } |
1676 | populateLocalView(); | 1676 | populateLocalView(); |
1677 | TabWidget->setCurrentPage(0); | 1677 | TabWidget->setCurrentPage(0); |
1678 | } | 1678 | } |
1679 | } | 1679 | } |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | void AdvancedFm::QPEButtonPushed() { | 1682 | void AdvancedFm::QPEButtonPushed() { |
1683 | QString current = QPEApplication::qpeDir(); | 1683 | QString current = QPEApplication::qpeDir(); |
1684 | chdir( current.latin1() ); | 1684 | chdir( current.latin1() ); |
1685 | if (TabWidget->currentPageIndex() == 0) { | 1685 | if (TabWidget->currentPageIndex() == 0) { |
1686 | currentDir.cd( current, TRUE); | 1686 | currentDir.cd( current, TRUE); |
1687 | populateLocalView(); | 1687 | populateLocalView(); |
1688 | } else { | 1688 | } else { |
1689 | currentRemoteDir.cd( current, TRUE); | 1689 | currentRemoteDir.cd( current, TRUE); |
1690 | populateRemoteView(); | 1690 | populateRemoteView(); |
1691 | } | 1691 | } |
1692 | update(); | 1692 | update(); |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | void AdvancedFm::parsetab(const QString &fileName) { | 1695 | void AdvancedFm::parsetab(const QString &fileName) { |
1696 | 1696 | ||
1697 | fileSystemTypeList.clear(); | 1697 | fileSystemTypeList.clear(); |
1698 | fsList.clear(); | 1698 | fsList.clear(); |
1699 | struct mntent *me; | 1699 | struct mntent *me; |
1700 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 1700 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
1701 | if ( mntfp ) { | 1701 | if ( mntfp ) { |
1702 | while ( (me = getmntent( mntfp )) != 0 ) { | 1702 | while ( (me = getmntent( mntfp )) != 0 ) { |
1703 | QString deviceName = me->mnt_fsname; | 1703 | QString deviceName = me->mnt_fsname; |
1704 | QString filesystemType = me->mnt_type; | 1704 | QString filesystemType = me->mnt_type; |
1705 | QString mountDir = me->mnt_dir; | 1705 | QString mountDir = me->mnt_dir; |
1706 | if(deviceName != "none") { | 1706 | if(deviceName != "none") { |
1707 | if( fsList.contains(filesystemType) == 0 | 1707 | if( fsList.contains(filesystemType) == 0 |
1708 | & filesystemType.find("proc",0,TRUE) == -1 | 1708 | & filesystemType.find("proc",0,TRUE) == -1 |
1709 | & filesystemType.find("cramfs",0,TRUE) == -1 | 1709 | & filesystemType.find("cramfs",0,TRUE) == -1 |
1710 | & filesystemType.find("auto",0,TRUE) == -1) | 1710 | & filesystemType.find("auto",0,TRUE) == -1) |
1711 | fsList << filesystemType; | 1711 | fsList << filesystemType; |
1712 | fileSystemTypeList << mountDir+"::"+filesystemType; | 1712 | fileSystemTypeList << mountDir+"::"+filesystemType; |
1713 | } | 1713 | } |
1714 | } | 1714 | } |
1715 | } | 1715 | } |
1716 | endmntent( mntfp ); | 1716 | endmntent( mntfp ); |
1717 | } | 1717 | } |
1718 | 1718 | ||
1719 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 1719 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
1720 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 1720 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
1721 | QString current = currentText;//.right( currentText.length()-1); | 1721 | QString current = currentText;//.right( currentText.length()-1); |
1722 | QString baseFs; | 1722 | QString baseFs; |
1723 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 1723 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
1724 | QString temp = (*it); | 1724 | QString temp = (*it); |
1725 | QString path = temp.left(temp.find("::",0,TRUE) ); | 1725 | QString path = temp.left(temp.find("::",0,TRUE) ); |
1726 | path = path.right( path.length()-1); | 1726 | path = path.right( path.length()-1); |
1727 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 1727 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
1728 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 1728 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
1729 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 1729 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
1730 | } | 1730 | } |
1731 | } | 1731 | } |
1732 | return baseFs; | 1732 | return baseFs; |
1733 | } | 1733 | } |
1734 | 1734 | ||
1735 | QString AdvancedFm::getDiskSpace( const QString &) { | 1735 | QString AdvancedFm::getDiskSpace( const QString &path) { |
1736 | 1736 | struct statfs fss; | |
1737 | if ( !statfs( path.latin1(), &fss ) ) { | ||
1738 | int blkSize = fss.f_bsize; | ||
1739 | // int totalBlks = fs.f_blocks; | ||
1740 | int availBlks = fss.f_bavail; | ||
1741 | |||
1742 | long mult = blkSize / 1024; | ||
1743 | long div = 1024 / blkSize; | ||
1744 | if ( !mult ) mult = 1; | ||
1745 | if ( !div ) div = 1; | ||
1746 | |||
1747 | return QString::number(availBlks * mult / div); | ||
1748 | } | ||
1749 | return ""; | ||
1737 | } | 1750 | } |
1738 | 1751 | ||
1739 | void AdvancedFm::doBeam() { | 1752 | void AdvancedFm::doBeam() { |
1740 | Ir ir; | 1753 | Ir ir; |
1741 | if(!ir.supported()){ | 1754 | if(!ir.supported()){ |
1742 | } else { | 1755 | } else { |
1743 | 1756 | ||
1744 | QStringList curFileList = getPath(); | 1757 | QStringList curFileList = getPath(); |
1745 | if( curFileList.count() > 0) { | 1758 | if( curFileList.count() > 0) { |
1746 | 1759 | ||
1747 | if (TabWidget->currentPageIndex() == 0) { | 1760 | if (TabWidget->currentPageIndex() == 0) { |
1748 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1761 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1749 | 1762 | ||
1750 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 1763 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
1751 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1764 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1752 | Ir *file = new Ir(this, "IR"); | 1765 | Ir *file = new Ir(this, "IR"); |
1753 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 1766 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
1754 | file->send( curFile, curFile ); | 1767 | file->send( curFile, curFile ); |
1755 | } | 1768 | } |
1756 | 1769 | ||
1757 | } else { | 1770 | } else { |
1758 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1771 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1759 | 1772 | ||
1760 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1773 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1761 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1774 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1762 | Ir *file = new Ir(this, "IR"); | 1775 | Ir *file = new Ir(this, "IR"); |
1763 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 1776 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
1764 | file->send( curFile, curFile ); | 1777 | file->send( curFile, curFile ); |
1765 | 1778 | ||
1766 | } | 1779 | } |
1767 | } | 1780 | } |
1768 | } | 1781 | } |
1769 | } | 1782 | } |
1770 | 1783 | ||
1771 | } | 1784 | } |
1772 | 1785 | ||
1773 | void AdvancedFm::fileBeamFinished( Ir *ir) { | 1786 | void AdvancedFm::fileBeamFinished( Ir *ir) { |
1774 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 1787 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
1775 | 1788 | ||
1776 | } | 1789 | } |
1777 | 1790 | ||
1778 | void AdvancedFm::showFileMenu() { | 1791 | void AdvancedFm::showFileMenu() { |
1779 | 1792 | ||
1780 | QString curApp; | 1793 | QString curApp; |
1781 | bool isLocalView = false; | 1794 | bool isLocalView = false; |
1782 | if (TabWidget->currentPageIndex() == 0) { | 1795 | if (TabWidget->currentPageIndex() == 0) { |
1783 | isLocalView = TRUE; | 1796 | isLocalView = TRUE; |
1784 | curApp = Local_View->currentItem()->text(0); | 1797 | curApp = Local_View->currentItem()->text(0); |
1785 | } else { | 1798 | } else { |
1786 | curApp = Remote_View->currentItem()->text(0); | 1799 | curApp = Remote_View->currentItem()->text(0); |
1787 | } | 1800 | } |
1788 | 1801 | ||
1789 | MimeType mt( curApp ); | 1802 | MimeType mt( curApp ); |
1790 | const AppLnk* app = mt.application(); | 1803 | const AppLnk* app = mt.application(); |
1791 | QFile fi(curApp); | 1804 | QFile fi(curApp); |
1792 | 1805 | ||
1793 | QPopupMenu *m = new QPopupMenu(0); | 1806 | QPopupMenu *m = new QPopupMenu(0); |
1794 | 1807 | ||
1795 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 1808 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
1796 | m->insertSeparator(); | 1809 | m->insertSeparator(); |
1797 | if ( QFileInfo(fi).isDir() ) { | 1810 | if ( QFileInfo(fi).isDir() ) { |
1798 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 1811 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
1799 | } else { | 1812 | } else { |
1800 | 1813 | ||
1801 | if ( app ) | 1814 | if ( app ) |
1802 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); | 1815 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); |
1803 | else if( QFileInfo(fi).isExecutable() ) | 1816 | else if( QFileInfo(fi).isExecutable() ) |
1804 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 1817 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
1805 | 1818 | ||
1806 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 1819 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
1807 | } | 1820 | } |
1808 | m->insertSeparator(); | 1821 | m->insertSeparator(); |
1809 | 1822 | ||
1810 | 1823 | ||
1811 | if(isLocalView) | 1824 | if(isLocalView) |
1812 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 1825 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
1813 | else | 1826 | else |
1814 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 1827 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
1815 | 1828 | ||
1816 | m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 1829 | m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
1817 | m->insertSeparator(); | 1830 | m->insertSeparator(); |
1818 | 1831 | ||
1819 | if(isLocalView) | 1832 | if(isLocalView) |
1820 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 1833 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
1821 | else | 1834 | else |
1822 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 1835 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
1823 | 1836 | ||
1824 | m->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 1837 | m->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
1825 | m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 1838 | m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
1826 | m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 1839 | m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
1827 | m->insertItem( tr( "Move" ), this, SLOT( move() )); | 1840 | m->insertItem( tr( "Move" ), this, SLOT( move() )); |
1828 | m->insertSeparator(); | 1841 | m->insertSeparator(); |
1829 | 1842 | ||
1830 | if(isLocalView) | 1843 | if(isLocalView) |
1831 | m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); | 1844 | m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); |
1832 | else | 1845 | else |
1833 | m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); | 1846 | m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); |
1834 | 1847 | ||
1835 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 1848 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
1836 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 1849 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
1837 | m->insertSeparator(); | 1850 | m->insertSeparator(); |
1838 | 1851 | ||
1839 | if(isLocalView) | 1852 | if(isLocalView) |
1840 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 1853 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
1841 | else | 1854 | else |
1842 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 1855 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
1843 | 1856 | ||
1844 | m->insertSeparator(); | 1857 | m->insertSeparator(); |
1845 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 1858 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
1846 | 1859 | ||
1847 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings | 1860 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings |
1848 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 1861 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
1849 | m->setCheckable(TRUE); | 1862 | m->setCheckable(TRUE); |
1850 | if (!b) | 1863 | if (!b) |
1851 | m->setItemChecked(m->idAt(0),TRUE); | 1864 | m->setItemChecked(m->idAt(0),TRUE); |
1852 | else | 1865 | else |
1853 | m->setItemChecked(m->idAt(0),FALSE); | 1866 | m->setItemChecked(m->idAt(0),FALSE); |
1854 | if(Ir::supported()) | 1867 | if(Ir::supported()) |
1855 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 1868 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
1856 | m->setFocus(); | 1869 | m->setFocus(); |
1857 | m->exec( QCursor::pos() ); | 1870 | m->exec( QCursor::pos() ); |
1858 | sleep(1); | 1871 | sleep(1); |
1859 | if(m) delete m; | 1872 | if(m) delete m; |
1860 | } | 1873 | } |
1861 | 1874 | ||
1862 | 1875 | ||
1863 | void AdvancedFm::cancelMenuTimer() { | 1876 | void AdvancedFm::cancelMenuTimer() { |
1864 | 1877 | ||
1865 | qDebug("selectionChanged: cancel menu timer"); | 1878 | qDebug("selectionChanged: cancel menu timer"); |
1866 | if( menuTimer.isActive() ) | 1879 | if( menuTimer.isActive() ) |
1867 | menuTimer.stop(); | 1880 | menuTimer.stop(); |
1868 | } | 1881 | } |
1869 | 1882 | ||
1870 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 1883 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
1871 | |||
1872 | struct statfs fss; | 1884 | struct statfs fss; |
1873 | if ( !statfs( path.latin1(), &fss ) ) { | 1885 | if ( !statfs( path.latin1(), &fss ) ) { |
1874 | int blkSize = fss.f_bsize; | 1886 | int blkSize = fss.f_bsize; |
1875 | // int totalBlks = fs.f_blocks; | 1887 | // int totalBlks = fs.f_blocks; |
1876 | int availBlks = fss.f_bavail; | 1888 | int availBlks = fss.f_bavail; |
1877 | 1889 | ||
1878 | long mult = blkSize / 1024; | 1890 | long mult = blkSize / 1024; |
1879 | long div = 1024 / blkSize; | 1891 | long div = 1024 / blkSize; |
1880 | if ( !mult ) mult = 1; | 1892 | if ( !mult ) mult = 1; |
1881 | if ( !div ) div = 1; | 1893 | if ( !div ) div = 1; |
1882 | 1894 | ||
1883 | 1895 | ||
1884 | return QString::number(availBlks * mult / div); | 1896 | return QString::number(availBlks * mult / div); |
1885 | } | 1897 | } |
1886 | return ""; | 1898 | return ""; |
1887 | } | 1899 | } |
1888 | 1900 | ||
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro index e99ab12..0f0f770 100644 --- a/noncore/apps/advancedfm/advancedfm.pro +++ b/noncore/apps/advancedfm/advancedfm.pro | |||
@@ -1,25 +1,25 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h | 3 | HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h |
4 | SOURCES = advancedfm.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp | 4 | SOURCES = advancedfm.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp |
5 | TARGET = advancedfm | 5 | TARGET = advancedfm |
6 | REQUIRES=medium-config | 6 | REQUIRES=medium-config |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | DESTDIR = $(OPIEDIR)/bin | 9 | DESTDIR = $(OPIEDIR)/bin |
10 | LIBS += -lqpe -lopie | 10 | LIBS += -lqpe |
11 | 11 | ||
12 | TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ | 12 | TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ |
13 | ../../../i18n/en/advancedfm.ts \ | 13 | ../../../i18n/en/advancedfm.ts \ |
14 | ../../../i18n/es/advancedfm.ts \ | 14 | ../../../i18n/es/advancedfm.ts \ |
15 | ../../../i18n/fr/advancedfm.ts \ | 15 | ../../../i18n/fr/advancedfm.ts \ |
16 | ../../../i18n/hu/advancedfm.ts \ | 16 | ../../../i18n/hu/advancedfm.ts \ |
17 | ../../../i18n/ja/advancedfm.ts \ | 17 | ../../../i18n/ja/advancedfm.ts \ |
18 | ../../../i18n/ko/advancedfm.ts \ | 18 | ../../../i18n/ko/advancedfm.ts \ |
19 | ../../../i18n/no/advancedfm.ts \ | 19 | ../../../i18n/no/advancedfm.ts \ |
20 | ../../../i18n/pl/advancedfm.ts \ | 20 | ../../../i18n/pl/advancedfm.ts \ |
21 | ../../../i18n/pt/advancedfm.ts \ | 21 | ../../../i18n/pt/advancedfm.ts \ |
22 | ../../../i18n/pt_BR/advancedfm.ts \ | 22 | ../../../i18n/pt_BR/advancedfm.ts \ |
23 | ../../../i18n/sl/advancedfm.ts \ | 23 | ../../../i18n/sl/advancedfm.ts \ |
24 | ../../../i18n/zh_CN/advancedfm.ts \ | 24 | ../../../i18n/zh_CN/advancedfm.ts \ |
25 | ../../../i18n/zh_TW/advancedfm.ts | 25 | ../../../i18n/zh_TW/advancedfm.ts |