-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,1888 +1,1900 @@ | |||
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 | } |
534 | } //end not symlink | 534 | } //end not symlink |
535 | chdir(strItem.latin1()); | 535 | chdir(strItem.latin1()); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) | 540 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) |
541 | { | 541 | { |
542 | if(selectedItem) { | 542 | if(selectedItem) { |
543 | QString strItem=selectedItem->text(0); | 543 | QString strItem=selectedItem->text(0); |
544 | QString strSize=selectedItem->text(1); | 544 | QString strSize=selectedItem->text(1); |
545 | strSize=strSize.stripWhiteSpace(); | 545 | strSize=strSize.stripWhiteSpace(); |
546 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 546 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
547 | // is symlink | 547 | // is symlink |
548 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 548 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
549 | if(QDir(strItem2).exists() ) { | 549 | if(QDir(strItem2).exists() ) { |
550 | currentRemoteDir.cd(strItem2, TRUE); | 550 | currentRemoteDir.cd(strItem2, TRUE); |
551 | populateRemoteView(); | 551 | populateRemoteView(); |
552 | } | 552 | } |
553 | } else { // not a symlink | 553 | } else { // not a symlink |
554 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 554 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
555 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 555 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
556 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 556 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
557 | currentRemoteDir.cd(strItem,FALSE); | 557 | currentRemoteDir.cd(strItem,FALSE); |
558 | populateRemoteView(); | 558 | populateRemoteView(); |
559 | } else { | 559 | } else { |
560 | currentRemoteDir.cdUp(); | 560 | currentRemoteDir.cdUp(); |
561 | populateRemoteView(); | 561 | populateRemoteView(); |
562 | } | 562 | } |
563 | if(QDir(strItem).exists()){ | 563 | if(QDir(strItem).exists()){ |
564 | currentRemoteDir.cd(strItem, TRUE); | 564 | currentRemoteDir.cd(strItem, TRUE); |
565 | populateRemoteView(); | 565 | populateRemoteView(); |
566 | } | 566 | } |
567 | } else { | 567 | } else { |
568 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 568 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
569 | if( QFile::exists(strItem ) ) { | 569 | if( QFile::exists(strItem ) ) { |
570 | // qDebug("clicked item "+strItem); | 570 | // qDebug("clicked item "+strItem); |
571 | // DocLnk doc( strItem, FALSE ); | 571 | // DocLnk doc( strItem, FALSE ); |
572 | // doc.execute(); | 572 | // doc.execute(); |
573 | // Remote_View->clearSelection(); | 573 | // Remote_View->clearSelection(); |
574 | } | 574 | } |
575 | } //end not symlink | 575 | } //end not symlink |
576 | chdir(strItem.latin1()); | 576 | chdir(strItem.latin1()); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | void AdvancedFm::doLocalCd() | 581 | void AdvancedFm::doLocalCd() |
582 | { | 582 | { |
583 | localListClicked( Local_View->currentItem()); | 583 | localListClicked( Local_View->currentItem()); |
584 | } | 584 | } |
585 | 585 | ||
586 | void AdvancedFm::doRemoteCd() | 586 | void AdvancedFm::doRemoteCd() |
587 | { | 587 | { |
588 | localListClicked( Remote_View->currentItem()); | 588 | localListClicked( Remote_View->currentItem()); |
589 | } | 589 | } |
590 | 590 | ||
591 | void AdvancedFm::showHidden() | 591 | void AdvancedFm::showHidden() |
592 | { | 592 | { |
593 | if (b) { | 593 | if (b) { |
594 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 594 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
595 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 595 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
596 | b=FALSE; | 596 | b=FALSE; |
597 | 597 | ||
598 | } else { | 598 | } else { |
599 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 599 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
600 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 600 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
601 | b=TRUE; | 601 | b=TRUE; |
602 | } | 602 | } |
603 | populateLocalView(); | 603 | populateLocalView(); |
604 | 604 | ||
605 | } | 605 | } |
606 | 606 | ||
607 | void AdvancedFm::showRemoteHidden() | 607 | void AdvancedFm::showRemoteHidden() |
608 | { | 608 | { |
609 | if (b) { | 609 | if (b) { |
610 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 610 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
611 | b=TRUE; | 611 | b=TRUE; |
612 | 612 | ||
613 | } else { | 613 | } else { |
614 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 614 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
615 | b=FALSE; | 615 | b=FALSE; |
616 | } | 616 | } |
617 | populateRemoteView(); | 617 | populateRemoteView(); |
618 | } | 618 | } |
619 | 619 | ||
620 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 620 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
621 | { | 621 | { |
622 | qDebug("list pressed"); | 622 | qDebug("list pressed"); |
623 | switch (mouse) { | 623 | switch (mouse) { |
624 | case 1: | 624 | case 1: |
625 | break; | 625 | break; |
626 | case 2: | 626 | case 2: |
627 | menuTimer.start( 750, TRUE ); | 627 | menuTimer.start( 750, TRUE ); |
628 | qDebug("Start menu timer\n"); | 628 | qDebug("Start menu timer\n"); |
629 | break; | 629 | break; |
630 | }; | 630 | }; |
631 | } | 631 | } |
632 | 632 | ||
633 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 633 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
634 | { | 634 | { |
635 | 635 | ||
636 | switch (mouse) { | 636 | switch (mouse) { |
637 | case 1: | 637 | case 1: |
638 | break; | 638 | break; |
639 | case 2: | 639 | case 2: |
640 | menuTimer.start( 750, TRUE ); | 640 | menuTimer.start( 750, TRUE ); |
641 | qDebug("Start menu timer"); | 641 | qDebug("Start menu timer"); |
642 | break; | 642 | break; |
643 | }; | 643 | }; |
644 | } | 644 | } |
645 | 645 | ||
646 | void AdvancedFm::runThis() { | 646 | void AdvancedFm::runThis() { |
647 | QString fs; | 647 | QString fs; |
648 | if (TabWidget->currentPageIndex() == 0) { | 648 | if (TabWidget->currentPageIndex() == 0) { |
649 | QString curFile = Local_View->currentItem()->text(0); | 649 | QString curFile = Local_View->currentItem()->text(0); |
650 | if(curFile != "../") { | 650 | if(curFile != "../") { |
651 | 651 | ||
652 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 652 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
653 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | 653 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); |
654 | qDebug( fileInfo.owner()); | 654 | qDebug( fileInfo.owner()); |
655 | if( (fileInfo.permission( QFileInfo::ExeUser) | 655 | if( (fileInfo.permission( QFileInfo::ExeUser) |
656 | | fileInfo.permission( QFileInfo::ExeGroup) | 656 | | fileInfo.permission( QFileInfo::ExeGroup) |
657 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 657 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
658 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 658 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
659 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 659 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
660 | e << curFile; | 660 | e << curFile; |
661 | } else { | 661 | } else { |
662 | curFile = currentDir.canonicalPath()+"/"+curFile; | 662 | curFile = currentDir.canonicalPath()+"/"+curFile; |
663 | DocLnk nf(curFile); | 663 | DocLnk nf(curFile); |
664 | QString execStr = nf.exec(); | 664 | QString execStr = nf.exec(); |
665 | qDebug( execStr); | 665 | qDebug( execStr); |
666 | if( execStr.isEmpty() ) { | 666 | if( execStr.isEmpty() ) { |
667 | } else { | 667 | } else { |
668 | nf.execute(); | 668 | nf.execute(); |
669 | } | 669 | } |
670 | } | 670 | } |
671 | } | 671 | } |
672 | } else { | 672 | } else { |
673 | QString curFile = Remote_View->currentItem()->text(0); | 673 | QString curFile = Remote_View->currentItem()->text(0); |
674 | if(curFile != "../") { | 674 | if(curFile != "../") { |
675 | 675 | ||
676 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 676 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
677 | qDebug("Filesystemtype is "+fs); | 677 | qDebug("Filesystemtype is "+fs); |
678 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | 678 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); |
679 | if( (fileInfo.permission( QFileInfo::ExeUser) | 679 | if( (fileInfo.permission( QFileInfo::ExeUser) |
680 | | fileInfo.permission( QFileInfo::ExeGroup) | 680 | | fileInfo.permission( QFileInfo::ExeGroup) |
681 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 681 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
682 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 682 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
683 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 683 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
684 | e << curFile; | 684 | e << curFile; |
685 | } else { | 685 | } else { |
686 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 686 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
687 | DocLnk nf(curFile); | 687 | DocLnk nf(curFile); |
688 | QString execStr = nf.exec(); | 688 | QString execStr = nf.exec(); |
689 | qDebug(execStr); | 689 | qDebug(execStr); |
690 | if( execStr.isEmpty() ) { | 690 | if( execStr.isEmpty() ) { |
691 | } else { | 691 | } else { |
692 | nf.execute(); | 692 | nf.execute(); |
693 | } | 693 | } |
694 | } | 694 | } |
695 | } | 695 | } |
696 | } | 696 | } |
697 | } | 697 | } |
698 | 698 | ||
699 | void AdvancedFm::runText() { | 699 | void AdvancedFm::runText() { |
700 | if (TabWidget->currentPageIndex() == 0) { | 700 | if (TabWidget->currentPageIndex() == 0) { |
701 | QString curFile = Local_View->currentItem()->text(0); | 701 | QString curFile = Local_View->currentItem()->text(0); |
702 | if(curFile != "../") { | 702 | if(curFile != "../") { |
703 | curFile = currentDir.canonicalPath()+"/"+curFile; | 703 | curFile = currentDir.canonicalPath()+"/"+curFile; |
704 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 704 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
705 | e << curFile; | 705 | e << curFile; |
706 | } | 706 | } |
707 | } else { | 707 | } else { |
708 | QString curFile = Remote_View->currentItem()->text(0); | 708 | QString curFile = Remote_View->currentItem()->text(0); |
709 | if(curFile != "../") { | 709 | if(curFile != "../") { |
710 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 710 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
711 | DocLnk nf(curFile); | 711 | DocLnk nf(curFile); |
712 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 712 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
713 | e << curFile; | 713 | e << curFile; |
714 | } | 714 | } |
715 | } | 715 | } |
716 | } | 716 | } |
717 | 717 | ||
718 | void AdvancedFm::localMakDir() | 718 | void AdvancedFm::localMakDir() |
719 | { | 719 | { |
720 | InputDialog *fileDlg; | 720 | InputDialog *fileDlg; |
721 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 721 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
722 | fileDlg->exec(); | 722 | fileDlg->exec(); |
723 | if( fileDlg->result() == 1 ) { | 723 | if( fileDlg->result() == 1 ) { |
724 | QString filename = fileDlg->LineEdit1->text(); | 724 | QString filename = fileDlg->LineEdit1->text(); |
725 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 725 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
726 | } | 726 | } |
727 | populateLocalView(); | 727 | populateLocalView(); |
728 | } | 728 | } |
729 | 729 | ||
730 | void AdvancedFm::remoteMakDir() | 730 | void AdvancedFm::remoteMakDir() |
731 | { | 731 | { |
732 | InputDialog *fileDlg; | 732 | InputDialog *fileDlg; |
733 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 733 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
734 | fileDlg->exec(); | 734 | fileDlg->exec(); |
735 | if( fileDlg->result() == 1 ) { | 735 | if( fileDlg->result() == 1 ) { |
736 | QString filename = fileDlg->LineEdit1->text(); | 736 | QString filename = fileDlg->LineEdit1->text(); |
737 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | 737 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); |
738 | } | 738 | } |
739 | populateRemoteView(); | 739 | populateRemoteView(); |
740 | } | 740 | } |
741 | 741 | ||
742 | void AdvancedFm::localDelete() | 742 | void AdvancedFm::localDelete() |
743 | { | 743 | { |
744 | QStringList curFileList = getPath(); | 744 | QStringList curFileList = getPath(); |
745 | if(curFileList.count() > 0) { | 745 | if(curFileList.count() > 0) { |
746 | QString myFile; | 746 | QString myFile; |
747 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 747 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
748 | myFile = (*it); | 748 | myFile = (*it); |
749 | if( myFile.find(" -> ",0,TRUE) != -1) | 749 | if( myFile.find(" -> ",0,TRUE) != -1) |
750 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 750 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
751 | 751 | ||
752 | QString f = currentDir.canonicalPath(); | 752 | QString f = currentDir.canonicalPath(); |
753 | if(f.right(1).find("/",0,TRUE) == -1) | 753 | if(f.right(1).find("/",0,TRUE) == -1) |
754 | f+="/"; | 754 | f+="/"; |
755 | f+=myFile; | 755 | f+=myFile; |
756 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 756 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
757 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 757 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
758 | "\nand all it's contents ?" | 758 | "\nand all it's contents ?" |
759 | ,tr("Yes"),tr("No"),0,0,1) ) { | 759 | ,tr("Yes"),tr("No"),0,0,1) ) { |
760 | case 0: { | 760 | case 0: { |
761 | f=f.left(f.length()-1); | 761 | f=f.left(f.length()-1); |
762 | QString cmd="rm -rf "+f; | 762 | QString cmd="rm -rf "+f; |
763 | system( cmd.latin1()); | 763 | system( cmd.latin1()); |
764 | populateLocalView(); | 764 | populateLocalView(); |
765 | } | 765 | } |
766 | break; | 766 | break; |
767 | case 1: | 767 | case 1: |
768 | // exit | 768 | // exit |
769 | break; | 769 | break; |
770 | }; | 770 | }; |
771 | 771 | ||
772 | } else { | 772 | } else { |
773 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 773 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
774 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 774 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
775 | case 0: { | 775 | case 0: { |
776 | QString cmd="rm "+f; | 776 | QString cmd="rm "+f; |
777 | QFile file(f); | 777 | QFile file(f); |
778 | file.remove(); | 778 | file.remove(); |
779 | // system( cmd.latin1()); | 779 | // system( cmd.latin1()); |
780 | populateLocalView(); | 780 | populateLocalView(); |
781 | } | 781 | } |
782 | break; | 782 | break; |
783 | case 1: | 783 | case 1: |
784 | // exit | 784 | // exit |
785 | break; | 785 | break; |
786 | }; | 786 | }; |
787 | } | 787 | } |
788 | } | 788 | } |
789 | } | 789 | } |
790 | } | 790 | } |
791 | 791 | ||
792 | void AdvancedFm::remoteDelete() | 792 | void AdvancedFm::remoteDelete() |
793 | { | 793 | { |
794 | QStringList curFileList = getPath(); | 794 | QStringList curFileList = getPath(); |
795 | if( curFileList.count() > 0) { | 795 | if( curFileList.count() > 0) { |
796 | QString myFile; | 796 | QString myFile; |
797 | 797 | ||
798 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 798 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
799 | myFile = (*it); | 799 | myFile = (*it); |
800 | if(myFile.find(" -> ",0,TRUE) != -1) | 800 | if(myFile.find(" -> ",0,TRUE) != -1) |
801 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 801 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
802 | QString f = currentRemoteDir.canonicalPath(); | 802 | QString f = currentRemoteDir.canonicalPath(); |
803 | if(f.right(1).find("/",0,TRUE) == -1) | 803 | if(f.right(1).find("/",0,TRUE) == -1) |
804 | f+="/"; | 804 | f+="/"; |
805 | f+=myFile; | 805 | f+=myFile; |
806 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 806 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
807 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 807 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
808 | "\nand all it's contents ?", | 808 | "\nand all it's contents ?", |
809 | tr("Yes"),tr("No"),0,0,1) ) { | 809 | tr("Yes"),tr("No"),0,0,1) ) { |
810 | case 0: { | 810 | case 0: { |
811 | f=f.left(f.length()-1); | 811 | f=f.left(f.length()-1); |
812 | QString cmd="rm -rf "+f; | 812 | QString cmd="rm -rf "+f; |
813 | system( cmd.latin1()); | 813 | system( cmd.latin1()); |
814 | populateRemoteView(); | 814 | populateRemoteView(); |
815 | } | 815 | } |
816 | break; | 816 | break; |
817 | case 1: | 817 | case 1: |
818 | // exit | 818 | // exit |
819 | break; | 819 | break; |
820 | }; | 820 | }; |
821 | 821 | ||
822 | } else { | 822 | } else { |
823 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 823 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
824 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 824 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
825 | case 0: { | 825 | case 0: { |
826 | QString cmd="rm "+f; | 826 | QString cmd="rm "+f; |
827 | QFile file(f); | 827 | QFile file(f); |
828 | file.remove(); | 828 | file.remove(); |
829 | // system( cmd.latin1()); | 829 | // system( cmd.latin1()); |
830 | populateRemoteView(); | 830 | populateRemoteView(); |
831 | } | 831 | } |
832 | break; | 832 | break; |
833 | case 1: | 833 | case 1: |
834 | // exit | 834 | // exit |
835 | break; | 835 | break; |
836 | }; | 836 | }; |
837 | } | 837 | } |
838 | } | 838 | } |
839 | } | 839 | } |
840 | } | 840 | } |
841 | 841 | ||
842 | void AdvancedFm::localRename() | 842 | void AdvancedFm::localRename() |
843 | { | 843 | { |
844 | QString curFile = Local_View->currentItem()->text(0); | 844 | QString curFile = Local_View->currentItem()->text(0); |
845 | qDebug("currentItem "+curFile); | 845 | qDebug("currentItem "+curFile); |
846 | if( curFile !="../") { | 846 | if( curFile !="../") { |
847 | InputDialog *fileDlg; | 847 | InputDialog *fileDlg; |
848 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 848 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
849 | fileDlg->setInputText((const QString &)curFile); | 849 | fileDlg->setInputText((const QString &)curFile); |
850 | fileDlg->exec(); | 850 | fileDlg->exec(); |
851 | if( fileDlg->result() == 1 ) { | 851 | if( fileDlg->result() == 1 ) { |
852 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 852 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
853 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 853 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
854 | if( rename(oldname.latin1(), newName.latin1())== -1) | 854 | if( rename(oldname.latin1(), newName.latin1())== -1) |
855 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 855 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
856 | } | 856 | } |
857 | populateLocalView(); | 857 | populateLocalView(); |
858 | } | 858 | } |
859 | } | 859 | } |
860 | 860 | ||
861 | void AdvancedFm::remoteRename() | 861 | void AdvancedFm::remoteRename() |
862 | { | 862 | { |
863 | QString curFile = Remote_View->currentItem()->text(0); | 863 | QString curFile = Remote_View->currentItem()->text(0); |
864 | if( curFile !="../") { | 864 | if( curFile !="../") { |
865 | InputDialog *fileDlg; | 865 | InputDialog *fileDlg; |
866 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 866 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
867 | fileDlg->setInputText((const QString &)curFile); | 867 | fileDlg->setInputText((const QString &)curFile); |
868 | fileDlg->exec(); | 868 | fileDlg->exec(); |
869 | if( fileDlg->result() == 1 ) { | 869 | if( fileDlg->result() == 1 ) { |
870 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | 870 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; |
871 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 871 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
872 | if( rename(oldname.latin1(), newName.latin1())== -1) | 872 | if( rename(oldname.latin1(), newName.latin1())== -1) |
873 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 873 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
874 | } | 874 | } |
875 | populateRemoteView(); | 875 | populateRemoteView(); |
876 | } | 876 | } |
877 | } | 877 | } |
878 | 878 | ||
879 | void AdvancedFm::switchToLocalTab() | 879 | void AdvancedFm::switchToLocalTab() |
880 | { | 880 | { |
881 | TabWidget->setCurrentPage(0); | 881 | TabWidget->setCurrentPage(0); |
882 | Local_View->setFocus(); | 882 | Local_View->setFocus(); |
883 | } | 883 | } |
884 | 884 | ||
885 | void AdvancedFm::switchToRemoteTab() | 885 | void AdvancedFm::switchToRemoteTab() |
886 | { | 886 | { |
887 | TabWidget->setCurrentPage(1); | 887 | TabWidget->setCurrentPage(1); |
888 | Remote_View->setFocus(); | 888 | Remote_View->setFocus(); |
889 | } | 889 | } |
890 | 890 | ||
891 | void AdvancedFm::readConfig() | 891 | void AdvancedFm::readConfig() |
892 | { | 892 | { |
893 | Config cfg("AdvancedFm"); | 893 | Config cfg("AdvancedFm"); |
894 | } | 894 | } |
895 | 895 | ||
896 | void AdvancedFm::writeConfig() | 896 | void AdvancedFm::writeConfig() |
897 | { | 897 | { |
898 | Config cfg("AdvancedFm"); | 898 | Config cfg("AdvancedFm"); |
899 | } | 899 | } |
900 | 900 | ||
901 | void AdvancedFm::currentPathComboChanged() | 901 | void AdvancedFm::currentPathComboChanged() |
902 | { | 902 | { |
903 | if (TabWidget->currentPageIndex() == 0) { | 903 | if (TabWidget->currentPageIndex() == 0) { |
904 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 904 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
905 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 905 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
906 | populateLocalView(); | 906 | populateLocalView(); |
907 | } else { | 907 | } else { |
908 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 908 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | if (TabWidget->currentPageIndex() == 0) { | 911 | if (TabWidget->currentPageIndex() == 0) { |
912 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 912 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
913 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 913 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
914 | populateRemoteView(); | 914 | populateRemoteView(); |
915 | } else { | 915 | } else { |
916 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 916 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
917 | } | 917 | } |
918 | } | 918 | } |
919 | } | 919 | } |
920 | 920 | ||
921 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 921 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
922 | 922 | ||
923 | if (TabWidget->currentPageIndex() == 0) { | 923 | if (TabWidget->currentPageIndex() == 0) { |
924 | currentPathCombo->lineEdit()->setText( currentPath); | 924 | currentPathCombo->lineEdit()->setText( currentPath); |
925 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 925 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
926 | currentPathCombo->clear(); | 926 | currentPathCombo->clear(); |
927 | localDirPathStringList.prepend( currentPath ); | 927 | localDirPathStringList.prepend( currentPath ); |
928 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 928 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
929 | } | 929 | } |
930 | } else { | 930 | } else { |
931 | currentPathCombo->lineEdit()->setText( currentPath); | 931 | currentPathCombo->lineEdit()->setText( currentPath); |
932 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 932 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
933 | currentPathCombo->clear(); | 933 | currentPathCombo->clear(); |
934 | remoteDirPathStringList.prepend( currentPath ); | 934 | remoteDirPathStringList.prepend( currentPath ); |
935 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 935 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
936 | } | 936 | } |
937 | } | 937 | } |
938 | } | 938 | } |
939 | 939 | ||
940 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 940 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
941 | if (TabWidget->currentPageIndex() == 0) { | 941 | if (TabWidget->currentPageIndex() == 0) { |
942 | chdir( currentPath.latin1() ); | 942 | chdir( currentPath.latin1() ); |
943 | currentDir.cd( currentPath, TRUE); | 943 | currentDir.cd( currentPath, TRUE); |
944 | populateLocalView(); | 944 | populateLocalView(); |
945 | update(); | 945 | update(); |
946 | } else { | 946 | } else { |
947 | chdir( currentPath.latin1() ); | 947 | chdir( currentPath.latin1() ); |
948 | currentRemoteDir.cd( currentPath, TRUE); | 948 | currentRemoteDir.cd( currentPath, TRUE); |
949 | populateRemoteView(); | 949 | populateRemoteView(); |
950 | update(); | 950 | update(); |
951 | } | 951 | } |
952 | } | 952 | } |
953 | 953 | ||
954 | void AdvancedFm::filePerms() { | 954 | void AdvancedFm::filePerms() { |
955 | 955 | ||
956 | QStringList curFileList = getPath(); | 956 | QStringList curFileList = getPath(); |
957 | QString filePath; | 957 | QString filePath; |
958 | 958 | ||
959 | if (TabWidget->currentPageIndex() == 0) { | 959 | if (TabWidget->currentPageIndex() == 0) { |
960 | filePath = currentDir.canonicalPath()+"/"; | 960 | filePath = currentDir.canonicalPath()+"/"; |
961 | } else { | 961 | } else { |
962 | filePath= currentRemoteDir.canonicalPath()+"/"; | 962 | filePath= currentRemoteDir.canonicalPath()+"/"; |
963 | } | 963 | } |
964 | 964 | ||
965 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 965 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
966 | filePermissions *filePerm; | 966 | filePermissions *filePerm; |
967 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 967 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
968 | filePerm->showMaximized(); | 968 | filePerm->showMaximized(); |
969 | filePerm->exec(); | 969 | filePerm->exec(); |
970 | if( filePerm) | 970 | if( filePerm) |
971 | delete filePerm; | 971 | delete filePerm; |
972 | } | 972 | } |
973 | if (TabWidget->currentPageIndex() == 0) { | 973 | if (TabWidget->currentPageIndex() == 0) { |
974 | populateLocalView(); | 974 | populateLocalView(); |
975 | } else { | 975 | } else { |
976 | populateRemoteView(); | 976 | populateRemoteView(); |
977 | } | 977 | } |
978 | } | 978 | } |
979 | 979 | ||
980 | void AdvancedFm::doProperties() { | 980 | void AdvancedFm::doProperties() { |
981 | QStringList curFileList = getPath(); | 981 | QStringList curFileList = getPath(); |
982 | QString filePath; | 982 | QString filePath; |
983 | if (TabWidget->currentPageIndex() == 0) { | 983 | if (TabWidget->currentPageIndex() == 0) { |
984 | filePath = currentDir.canonicalPath()+"/"; | 984 | filePath = currentDir.canonicalPath()+"/"; |
985 | } else { | 985 | } else { |
986 | filePath= currentRemoteDir.canonicalPath()+"/"; | 986 | filePath= currentRemoteDir.canonicalPath()+"/"; |
987 | } | 987 | } |
988 | // qDebug("%d",curFileList.count()); | 988 | // qDebug("%d",curFileList.count()); |
989 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 989 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
990 | qDebug((filePath+*it)); | 990 | qDebug((filePath+*it)); |
991 | DocLnk lnk( (filePath+*it)); | 991 | DocLnk lnk( (filePath+*it)); |
992 | LnkProperties prop( &lnk ); | 992 | LnkProperties prop( &lnk ); |
993 | prop.showMaximized(); | 993 | prop.showMaximized(); |
994 | prop.exec(); | 994 | prop.exec(); |
995 | } | 995 | } |
996 | } | 996 | } |
997 | 997 | ||
998 | QStringList AdvancedFm::getPath() { | 998 | QStringList AdvancedFm::getPath() { |
999 | QStringList strList; | 999 | QStringList strList; |
1000 | if (TabWidget->currentPageIndex() == 0) { | 1000 | if (TabWidget->currentPageIndex() == 0) { |
1001 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 1001 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
1002 | QListViewItemIterator it( Local_View ); | 1002 | QListViewItemIterator it( Local_View ); |
1003 | for ( ; it.current(); ++it ) { | 1003 | for ( ; it.current(); ++it ) { |
1004 | if ( it.current()->isSelected() ) { | 1004 | if ( it.current()->isSelected() ) { |
1005 | strList << it.current()->text(0); | 1005 | strList << it.current()->text(0); |
1006 | qDebug(it.current()->text(0)); | 1006 | qDebug(it.current()->text(0)); |
1007 | } | 1007 | } |
1008 | } | 1008 | } |
1009 | return strList; | 1009 | return strList; |
1010 | } else { | 1010 | } else { |
1011 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1011 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1012 | QListViewItemIterator it( Remote_View ); | 1012 | QListViewItemIterator it( Remote_View ); |
1013 | for ( ; it.current(); ++it ) { | 1013 | for ( ; it.current(); ++it ) { |
1014 | if ( it.current()->isSelected() ) { | 1014 | if ( it.current()->isSelected() ) { |
1015 | strList << it.current()->text(0); | 1015 | strList << it.current()->text(0); |
1016 | qDebug(it.current()->text(0)); | 1016 | qDebug(it.current()->text(0)); |
1017 | } | 1017 | } |
1018 | } | 1018 | } |
1019 | return strList; | 1019 | return strList; |
1020 | } | 1020 | } |
1021 | return ""; | 1021 | return ""; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | void AdvancedFm::homeButtonPushed() { | 1024 | void AdvancedFm::homeButtonPushed() { |
1025 | QString current = QDir::homeDirPath(); | 1025 | QString current = QDir::homeDirPath(); |
1026 | chdir( current.latin1() ); | 1026 | chdir( current.latin1() ); |
1027 | if (TabWidget->currentPageIndex() == 0) { | 1027 | if (TabWidget->currentPageIndex() == 0) { |
1028 | currentDir.cd( current, TRUE); | 1028 | currentDir.cd( current, TRUE); |
1029 | populateLocalView(); | 1029 | populateLocalView(); |
1030 | } else { | 1030 | } else { |
1031 | currentRemoteDir.cd( current, TRUE); | 1031 | currentRemoteDir.cd( current, TRUE); |
1032 | populateRemoteView(); | 1032 | populateRemoteView(); |
1033 | } | 1033 | } |
1034 | update(); | 1034 | update(); |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | void AdvancedFm::docButtonPushed() { | 1037 | void AdvancedFm::docButtonPushed() { |
1038 | QString current = QPEApplication::documentDir(); | 1038 | QString current = QPEApplication::documentDir(); |
1039 | chdir( current.latin1() ); | 1039 | chdir( current.latin1() ); |
1040 | if (TabWidget->currentPageIndex() == 0) { | 1040 | if (TabWidget->currentPageIndex() == 0) { |
1041 | currentDir.cd( current, TRUE); | 1041 | currentDir.cd( current, TRUE); |
1042 | populateLocalView(); | 1042 | populateLocalView(); |
1043 | } else { | 1043 | } else { |
1044 | currentRemoteDir.cd( current, TRUE); | 1044 | currentRemoteDir.cd( current, TRUE); |
1045 | populateRemoteView(); | 1045 | populateRemoteView(); |
1046 | } | 1046 | } |
1047 | update(); | 1047 | update(); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | void AdvancedFm::SDButtonPushed() { | 1050 | void AdvancedFm::SDButtonPushed() { |
1051 | QString current = "/mnt/card"; | 1051 | QString current = "/mnt/card"; |
1052 | chdir( current.latin1() ); | 1052 | chdir( current.latin1() ); |
1053 | if (TabWidget->currentPageIndex() == 0) { | 1053 | if (TabWidget->currentPageIndex() == 0) { |
1054 | currentDir.cd( current, TRUE); | 1054 | currentDir.cd( current, TRUE); |
1055 | populateLocalView(); | 1055 | populateLocalView(); |
1056 | } else { | 1056 | } else { |
1057 | currentRemoteDir.cd( current, TRUE); | 1057 | currentRemoteDir.cd( current, TRUE); |
1058 | populateRemoteView(); | 1058 | populateRemoteView(); |
1059 | } | 1059 | } |
1060 | update(); | 1060 | update(); |
1061 | 1061 | ||
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | void AdvancedFm::CFButtonPushed() { | 1064 | void AdvancedFm::CFButtonPushed() { |
1065 | QString current = "/mnt/cf"; | 1065 | QString current = "/mnt/cf"; |
1066 | chdir( current.latin1() ); | 1066 | chdir( current.latin1() ); |
1067 | if (TabWidget->currentPageIndex() == 0) { | 1067 | if (TabWidget->currentPageIndex() == 0) { |
1068 | currentDir.cd( current, TRUE); | 1068 | currentDir.cd( current, TRUE); |
1069 | populateLocalView(); | 1069 | populateLocalView(); |
1070 | } else { | 1070 | } else { |
1071 | currentRemoteDir.cd( current, TRUE); | 1071 | currentRemoteDir.cd( current, TRUE); |
1072 | populateRemoteView(); | 1072 | populateRemoteView(); |
1073 | } | 1073 | } |
1074 | update(); | 1074 | update(); |
1075 | 1075 | ||
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | 1078 | ||
1079 | void AdvancedFm::upDir() | 1079 | void AdvancedFm::upDir() |
1080 | { | 1080 | { |
1081 | if (TabWidget->currentPageIndex() == 0) { | 1081 | if (TabWidget->currentPageIndex() == 0) { |
1082 | QString current = currentDir.canonicalPath(); | 1082 | QString current = currentDir.canonicalPath(); |
1083 | QDir dir(current); | 1083 | QDir dir(current); |
1084 | dir.cdUp(); | 1084 | dir.cdUp(); |
1085 | current = dir.canonicalPath(); | 1085 | current = dir.canonicalPath(); |
1086 | chdir( current.latin1() ); | 1086 | chdir( current.latin1() ); |
1087 | currentDir.cd( current, TRUE); | 1087 | currentDir.cd( current, TRUE); |
1088 | populateLocalView(); | 1088 | populateLocalView(); |
1089 | update(); | 1089 | update(); |
1090 | } else { | 1090 | } else { |
1091 | QString current = currentRemoteDir.canonicalPath(); | 1091 | QString current = currentRemoteDir.canonicalPath(); |
1092 | QDir dir(current); | 1092 | QDir dir(current); |
1093 | dir.cdUp(); | 1093 | dir.cdUp(); |
1094 | current = dir.canonicalPath(); | 1094 | current = dir.canonicalPath(); |
1095 | chdir( current.latin1() ); | 1095 | chdir( current.latin1() ); |
1096 | currentRemoteDir.cd( current, TRUE); | 1096 | currentRemoteDir.cd( current, TRUE); |
1097 | populateRemoteView(); | 1097 | populateRemoteView(); |
1098 | update(); | 1098 | update(); |
1099 | } | 1099 | } |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void AdvancedFm::copy() | 1102 | void AdvancedFm::copy() |
1103 | { | 1103 | { |
1104 | qApp->processEvents(); | 1104 | qApp->processEvents(); |
1105 | QStringList curFileList = getPath(); | 1105 | QStringList curFileList = getPath(); |
1106 | if( curFileList.count() > 0) { | 1106 | if( curFileList.count() > 0) { |
1107 | QString curFile; | 1107 | QString curFile; |
1108 | if (TabWidget->currentPageIndex() == 0) { | 1108 | if (TabWidget->currentPageIndex() == 0) { |
1109 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1109 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1110 | 1110 | ||
1111 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1111 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1112 | qDebug("Destination file is "+destFile); | 1112 | qDebug("Destination file is "+destFile); |
1113 | 1113 | ||
1114 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1114 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1115 | qDebug("CurrentFile file is " + curFile); | 1115 | qDebug("CurrentFile file is " + curFile); |
1116 | 1116 | ||
1117 | QFile f(destFile); | 1117 | QFile f(destFile); |
1118 | if( f.exists()) { | 1118 | if( f.exists()) { |
1119 | switch ( QMessageBox::warning(this,tr("Delete"), | 1119 | switch ( QMessageBox::warning(this,tr("Delete"), |
1120 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1120 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1121 | tr("Yes"),tr("No"),0,0,1) ) { | 1121 | tr("Yes"),tr("No"),0,0,1) ) { |
1122 | case 0: | 1122 | case 0: |
1123 | f.remove(); | 1123 | f.remove(); |
1124 | break; | 1124 | break; |
1125 | case 1: | 1125 | case 1: |
1126 | return; | 1126 | return; |
1127 | break; | 1127 | break; |
1128 | }; | 1128 | }; |
1129 | } | 1129 | } |
1130 | if(!copyFile(destFile, curFile) ) { | 1130 | if(!copyFile(destFile, curFile) ) { |
1131 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1131 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1132 | qWarning("nothin doing"); | 1132 | qWarning("nothin doing"); |
1133 | } | 1133 | } |
1134 | } | 1134 | } |
1135 | populateRemoteView(); | 1135 | populateRemoteView(); |
1136 | TabWidget->setCurrentPage(1); | 1136 | TabWidget->setCurrentPage(1); |
1137 | 1137 | ||
1138 | } else { | 1138 | } else { |
1139 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1139 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1140 | 1140 | ||
1141 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | 1141 | QString destFile = currentDir.canonicalPath()+"/"+(*it); |
1142 | qDebug("Destination file is "+destFile); | 1142 | qDebug("Destination file is "+destFile); |
1143 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1143 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1144 | qDebug("CurrentFile file is " + curFile); | 1144 | qDebug("CurrentFile file is " + curFile); |
1145 | 1145 | ||
1146 | QFile f(destFile); | 1146 | QFile f(destFile); |
1147 | if( f.exists()) { | 1147 | if( f.exists()) { |
1148 | switch ( QMessageBox::warning(this,tr("Delete"), | 1148 | switch ( QMessageBox::warning(this,tr("Delete"), |
1149 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1149 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1150 | tr("Yes"),tr("No"),0,0,1) ) { | 1150 | tr("Yes"),tr("No"),0,0,1) ) { |
1151 | case 0: | 1151 | case 0: |
1152 | f.remove(); | 1152 | f.remove(); |
1153 | break; | 1153 | break; |
1154 | case 1: | 1154 | case 1: |
1155 | return; | 1155 | return; |
1156 | break; | 1156 | break; |
1157 | }; | 1157 | }; |
1158 | } | 1158 | } |
1159 | if(!copyFile(destFile, curFile) ) { | 1159 | if(!copyFile(destFile, curFile) ) { |
1160 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | 1160 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); |
1161 | 1161 | ||
1162 | qWarning("nothin doing"); | 1162 | qWarning("nothin doing"); |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | populateLocalView(); | 1165 | populateLocalView(); |
1166 | TabWidget->setCurrentPage(0); | 1166 | TabWidget->setCurrentPage(0); |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | void AdvancedFm::copyAs() { | 1172 | void AdvancedFm::copyAs() { |
1173 | qApp->processEvents(); | 1173 | qApp->processEvents(); |
1174 | 1174 | ||
1175 | QStringList curFileList = getPath(); | 1175 | QStringList curFileList = getPath(); |
1176 | QString curFile; | 1176 | QString curFile; |
1177 | InputDialog *fileDlg; | 1177 | InputDialog *fileDlg; |
1178 | if (TabWidget->currentPageIndex() == 0) { | 1178 | if (TabWidget->currentPageIndex() == 0) { |
1179 | qDebug("tab 1"); | 1179 | qDebug("tab 1"); |
1180 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1180 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1181 | QString destFile; | 1181 | QString destFile; |
1182 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1182 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1183 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 1183 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
1184 | 1184 | ||
1185 | fileDlg->setInputText((const QString &) destFile ); | 1185 | fileDlg->setInputText((const QString &) destFile ); |
1186 | fileDlg->exec(); | 1186 | fileDlg->exec(); |
1187 | 1187 | ||
1188 | if( fileDlg->result() == 1 ) { | 1188 | if( fileDlg->result() == 1 ) { |
1189 | QString filename = fileDlg->LineEdit1->text(); | 1189 | QString filename = fileDlg->LineEdit1->text(); |
1190 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 1190 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
1191 | 1191 | ||
1192 | QFile f(destFile); | 1192 | QFile f(destFile); |
1193 | if( f.exists()) { | 1193 | if( f.exists()) { |
1194 | switch (QMessageBox::warning(this,tr("Delete"), | 1194 | switch (QMessageBox::warning(this,tr("Delete"), |
1195 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1195 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1196 | tr("Yes"),tr("No"),0,0,1) ) { | 1196 | tr("Yes"),tr("No"),0,0,1) ) { |
1197 | case 0: | 1197 | case 0: |
1198 | f.remove(); | 1198 | f.remove(); |
1199 | break; | 1199 | break; |
1200 | case 1: | 1200 | case 1: |
1201 | return; | 1201 | return; |
1202 | break; | 1202 | break; |
1203 | }; | 1203 | }; |
1204 | } | 1204 | } |
1205 | if(!copyFile(destFile, curFile) ) { | 1205 | if(!copyFile(destFile, curFile) ) { |
1206 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | 1206 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); |
1207 | qWarning("nothin doing"); | 1207 | qWarning("nothin doing"); |
1208 | } | 1208 | } |
1209 | } | 1209 | } |
1210 | delete fileDlg; | 1210 | delete fileDlg; |
1211 | 1211 | ||
1212 | } | 1212 | } |
1213 | populateRemoteView(); | 1213 | populateRemoteView(); |
1214 | TabWidget->setCurrentPage(1); | 1214 | TabWidget->setCurrentPage(1); |
1215 | 1215 | ||
1216 | } else { | 1216 | } else { |
1217 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1217 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1218 | 1218 | ||
1219 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1219 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1220 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 1220 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
1221 | 1221 | ||
1222 | QString destFile; | 1222 | QString destFile; |
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 |