author | llornkcor <llornkcor> | 2002-08-04 23:16:00 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-04 23:16:00 (UTC) |
commit | 400870188f123415355589ce4fb533614ecdf2ac (patch) (unidiff) | |
tree | 6dc7b0f747c3c48de6b730154c1167186226ec4a | |
parent | 57bd412cf973805fbe69ecfa8f168ad2e28311a9 (diff) | |
download | opie-400870188f123415355589ce4fb533614ecdf2ac.zip opie-400870188f123415355589ce4fb533614ecdf2ac.tar.gz opie-400870188f123415355589ce4fb533614ecdf2ac.tar.bz2 |
fix several severe file handling bugs
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 362 |
1 files changed, 188 insertions, 174 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 818a281..b169a79 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,1874 +1,1888 @@ | |||
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 | } | 1007 | } |
1007 | } | 1008 | } |
1008 | return strList; | 1009 | return strList; |
1009 | } else { | 1010 | } else { |
1010 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1011 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1011 | QListViewItemIterator it( Remote_View ); | 1012 | QListViewItemIterator it( Remote_View ); |
1012 | for ( ; it.current(); ++it ) { | 1013 | for ( ; it.current(); ++it ) { |
1013 | if ( it.current()->isSelected() ) { | 1014 | if ( it.current()->isSelected() ) { |
1014 | strList << it.current()->text(0); | 1015 | strList << it.current()->text(0); |
1016 | qDebug(it.current()->text(0)); | ||
1015 | } | 1017 | } |
1016 | } | 1018 | } |
1017 | return strList; | 1019 | return strList; |
1018 | } | 1020 | } |
1019 | return ""; | 1021 | return ""; |
1020 | } | 1022 | } |
1021 | 1023 | ||
1022 | void AdvancedFm::homeButtonPushed() { | 1024 | void AdvancedFm::homeButtonPushed() { |
1023 | QString current = QDir::homeDirPath(); | 1025 | QString current = QDir::homeDirPath(); |
1024 | chdir( current.latin1() ); | 1026 | chdir( current.latin1() ); |
1025 | if (TabWidget->currentPageIndex() == 0) { | 1027 | if (TabWidget->currentPageIndex() == 0) { |
1026 | currentDir.cd( current, TRUE); | 1028 | currentDir.cd( current, TRUE); |
1027 | populateLocalView(); | 1029 | populateLocalView(); |
1028 | } else { | 1030 | } else { |
1029 | currentRemoteDir.cd( current, TRUE); | 1031 | currentRemoteDir.cd( current, TRUE); |
1030 | populateRemoteView(); | 1032 | populateRemoteView(); |
1031 | } | 1033 | } |
1032 | update(); | 1034 | update(); |
1033 | } | 1035 | } |
1034 | 1036 | ||
1035 | void AdvancedFm::docButtonPushed() { | 1037 | void AdvancedFm::docButtonPushed() { |
1036 | QString current = QPEApplication::documentDir(); | 1038 | QString current = QPEApplication::documentDir(); |
1037 | chdir( current.latin1() ); | 1039 | chdir( current.latin1() ); |
1038 | if (TabWidget->currentPageIndex() == 0) { | 1040 | if (TabWidget->currentPageIndex() == 0) { |
1039 | currentDir.cd( current, TRUE); | 1041 | currentDir.cd( current, TRUE); |
1040 | populateLocalView(); | 1042 | populateLocalView(); |
1041 | } else { | 1043 | } else { |
1042 | currentRemoteDir.cd( current, TRUE); | 1044 | currentRemoteDir.cd( current, TRUE); |
1043 | populateRemoteView(); | 1045 | populateRemoteView(); |
1044 | } | 1046 | } |
1045 | update(); | 1047 | update(); |
1046 | } | 1048 | } |
1047 | 1049 | ||
1048 | void AdvancedFm::SDButtonPushed() { | 1050 | void AdvancedFm::SDButtonPushed() { |
1049 | QString current = "/mnt/card"; | 1051 | QString current = "/mnt/card"; |
1050 | chdir( current.latin1() ); | 1052 | chdir( current.latin1() ); |
1051 | if (TabWidget->currentPageIndex() == 0) { | 1053 | if (TabWidget->currentPageIndex() == 0) { |
1052 | currentDir.cd( current, TRUE); | 1054 | currentDir.cd( current, TRUE); |
1053 | populateLocalView(); | 1055 | populateLocalView(); |
1054 | } else { | 1056 | } else { |
1055 | currentRemoteDir.cd( current, TRUE); | 1057 | currentRemoteDir.cd( current, TRUE); |
1056 | populateRemoteView(); | 1058 | populateRemoteView(); |
1057 | } | 1059 | } |
1058 | update(); | 1060 | update(); |
1059 | 1061 | ||
1060 | } | 1062 | } |
1061 | 1063 | ||
1062 | void AdvancedFm::CFButtonPushed() { | 1064 | void AdvancedFm::CFButtonPushed() { |
1063 | QString current = "/mnt/cf"; | 1065 | QString current = "/mnt/cf"; |
1064 | chdir( current.latin1() ); | 1066 | chdir( current.latin1() ); |
1065 | if (TabWidget->currentPageIndex() == 0) { | 1067 | if (TabWidget->currentPageIndex() == 0) { |
1066 | currentDir.cd( current, TRUE); | 1068 | currentDir.cd( current, TRUE); |
1067 | populateLocalView(); | 1069 | populateLocalView(); |
1068 | } else { | 1070 | } else { |
1069 | currentRemoteDir.cd( current, TRUE); | 1071 | currentRemoteDir.cd( current, TRUE); |
1070 | populateRemoteView(); | 1072 | populateRemoteView(); |
1071 | } | 1073 | } |
1072 | update(); | 1074 | update(); |
1073 | 1075 | ||
1074 | } | 1076 | } |
1075 | 1077 | ||
1076 | 1078 | ||
1077 | void AdvancedFm::upDir() | 1079 | void AdvancedFm::upDir() |
1078 | { | 1080 | { |
1079 | if (TabWidget->currentPageIndex() == 0) { | 1081 | if (TabWidget->currentPageIndex() == 0) { |
1080 | QString current = currentDir.canonicalPath(); | 1082 | QString current = currentDir.canonicalPath(); |
1081 | QDir dir(current); | 1083 | QDir dir(current); |
1082 | dir.cdUp(); | 1084 | dir.cdUp(); |
1083 | current = dir.canonicalPath(); | 1085 | current = dir.canonicalPath(); |
1084 | chdir( current.latin1() ); | 1086 | chdir( current.latin1() ); |
1085 | currentDir.cd( current, TRUE); | 1087 | currentDir.cd( current, TRUE); |
1086 | populateLocalView(); | 1088 | populateLocalView(); |
1087 | update(); | 1089 | update(); |
1088 | } else { | 1090 | } else { |
1089 | QString current = currentRemoteDir.canonicalPath(); | 1091 | QString current = currentRemoteDir.canonicalPath(); |
1090 | QDir dir(current); | 1092 | QDir dir(current); |
1091 | dir.cdUp(); | 1093 | dir.cdUp(); |
1092 | current = dir.canonicalPath(); | 1094 | current = dir.canonicalPath(); |
1093 | chdir( current.latin1() ); | 1095 | chdir( current.latin1() ); |
1094 | currentRemoteDir.cd( current, TRUE); | 1096 | currentRemoteDir.cd( current, TRUE); |
1095 | populateRemoteView(); | 1097 | populateRemoteView(); |
1096 | update(); | 1098 | update(); |
1097 | } | 1099 | } |
1098 | } | 1100 | } |
1099 | 1101 | ||
1100 | void AdvancedFm::copy() | 1102 | void AdvancedFm::copy() |
1101 | { | 1103 | { |
1104 | qApp->processEvents(); | ||
1102 | QStringList curFileList = getPath(); | 1105 | QStringList curFileList = getPath(); |
1103 | if( curFileList.count() > 0) { | 1106 | if( curFileList.count() > 0) { |
1104 | QString curFile; | 1107 | QString curFile; |
1105 | if (TabWidget->currentPageIndex() == 0) { | 1108 | if (TabWidget->currentPageIndex() == 0) { |
1106 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1109 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1107 | 1110 | ||
1108 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1111 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1112 | qDebug("Destination file is "+destFile); | ||
1113 | |||
1109 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1114 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1115 | qDebug("CurrentFile file is " + curFile); | ||
1116 | |||
1110 | QFile f(destFile); | 1117 | QFile f(destFile); |
1111 | if( f.exists()) { | 1118 | if( f.exists()) { |
1112 | switch ( QMessageBox::warning(this,tr("Delete"), | 1119 | switch ( QMessageBox::warning(this,tr("Delete"), |
1113 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1120 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1114 | tr("Yes"),tr("No"),0,0,1) ) { | 1121 | tr("Yes"),tr("No"),0,0,1) ) { |
1115 | case 0: | 1122 | case 0: |
1116 | f.remove(); | 1123 | f.remove(); |
1117 | break; | 1124 | break; |
1118 | case 1: | 1125 | case 1: |
1119 | return; | 1126 | return; |
1120 | break; | 1127 | break; |
1121 | }; | 1128 | }; |
1122 | } | 1129 | } |
1123 | if(!copyFile(destFile, curFile) ) { | 1130 | if(!copyFile(destFile, curFile) ) { |
1124 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); | 1131 | QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); |
1125 | qWarning("nothin doing"); | 1132 | qWarning("nothin doing"); |
1126 | } | 1133 | } |
1127 | } | 1134 | } |
1128 | populateRemoteView(); | 1135 | populateRemoteView(); |
1129 | TabWidget->setCurrentPage(1); | 1136 | TabWidget->setCurrentPage(1); |
1130 | 1137 | ||
1131 | } else { | 1138 | } else { |
1132 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1139 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1133 | 1140 | ||
1134 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | 1141 | QString destFile = currentDir.canonicalPath()+"/"+(*it); |
1142 | qDebug("Destination file is "+destFile); | ||
1135 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1143 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1144 | qDebug("CurrentFile file is " + curFile); | ||
1136 | 1145 | ||
1137 | QFile f(destFile); | 1146 | QFile f(destFile); |
1138 | if( f.exists()) { | 1147 | if( f.exists()) { |
1139 | switch ( QMessageBox::warning(this,tr("Delete"), | 1148 | switch ( QMessageBox::warning(this,tr("Delete"), |
1140 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1149 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1141 | tr("Yes"),tr("No"),0,0,1) ) { | 1150 | tr("Yes"),tr("No"),0,0,1) ) { |
1142 | case 0: | 1151 | case 0: |
1143 | f.remove(); | 1152 | f.remove(); |
1144 | break; | 1153 | break; |
1145 | case 1: | 1154 | case 1: |
1146 | return; | 1155 | return; |
1147 | break; | 1156 | break; |
1148 | }; | 1157 | }; |
1149 | } | 1158 | } |
1150 | if(!copyFile(destFile, curFile) ) { | 1159 | if(!copyFile(destFile, curFile) ) { |
1151 | 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); |
1152 | 1161 | ||
1153 | qWarning("nothin doing"); | 1162 | qWarning("nothin doing"); |
1154 | } | 1163 | } |
1155 | } | 1164 | } |
1156 | populateLocalView(); | 1165 | populateLocalView(); |
1157 | TabWidget->setCurrentPage(0); | 1166 | TabWidget->setCurrentPage(0); |
1158 | } | 1167 | } |
1168 | |||
1159 | } | 1169 | } |
1160 | } | 1170 | } |
1161 | 1171 | ||
1162 | void AdvancedFm::copyAs() | 1172 | void AdvancedFm::copyAs() { |
1163 | { | 1173 | qApp->processEvents(); |
1174 | |||
1164 | QStringList curFileList = getPath(); | 1175 | QStringList curFileList = getPath(); |
1165 | if( curFileList.count() > 0) { | 1176 | QString curFile; |
1166 | QString curFile; | 1177 | InputDialog *fileDlg; |
1167 | InputDialog *fileDlg; | 1178 | if (TabWidget->currentPageIndex() == 0) { |
1168 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1179 | qDebug("tab 1"); |
1180 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1181 | QString destFile; | ||
1182 | curFile = currentDir.canonicalPath()+"/"+(*it); | ||
1183 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
1169 | 1184 | ||
1170 | if (TabWidget->currentPageIndex() == 0) { | 1185 | fileDlg->setInputText((const QString &) destFile ); |
1171 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1186 | fileDlg->exec(); |
1172 | QString destFile; | 1187 | |
1173 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1188 | if( fileDlg->result() == 1 ) { |
1174 | fileDlg->setInputText((const QString &) destFile ); | 1189 | QString filename = fileDlg->LineEdit1->text(); |
1175 | fileDlg->exec(); | 1190 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
1176 | if( fileDlg->result() == 1 ) { | 1191 | |
1177 | QString filename = fileDlg->LineEdit1->text(); | 1192 | QFile f(destFile); |
1178 | destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1193 | if( f.exists()) { |
1179 | 1194 | switch (QMessageBox::warning(this,tr("Delete"), | |
1180 | QFile f(destFile); | 1195 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1181 | if( f.exists()) { | 1196 | tr("Yes"),tr("No"),0,0,1) ) { |
1182 | switch (QMessageBox::warning(this,tr("Delete"), | 1197 | case 0: |
1183 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1198 | f.remove(); |
1184 | tr("Yes"),tr("No"),0,0,1) ) { | 1199 | break; |
1185 | case 0: | 1200 | case 1: |
1186 | f.remove(); | 1201 | return; |
1187 | break; | 1202 | break; |
1188 | case 1: | 1203 | }; |
1189 | return; | 1204 | } |
1190 | break; | 1205 | if(!copyFile(destFile, curFile) ) { |
1191 | }; | 1206 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); |
1192 | } | 1207 | qWarning("nothin doing"); |
1193 | if(!copyFile(destFile, curFile) ) { | ||
1194 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1195 | qWarning("nothin doing"); | ||
1196 | } | ||
1197 | } | 1208 | } |
1198 | } | 1209 | } |
1199 | populateRemoteView(); | 1210 | delete fileDlg; |
1200 | TabWidget->setCurrentPage(1); | ||
1201 | } else { | ||
1202 | if (TabWidget->currentPageIndex() == 0) { | ||
1203 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1204 | 1211 | ||
1205 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1212 | } |
1206 | QString destFile; | 1213 | populateRemoteView(); |
1207 | fileDlg->setInputText((const QString &) destFile); | 1214 | TabWidget->setCurrentPage(1); |
1208 | fileDlg->exec(); | 1215 | |
1209 | if( fileDlg->result() == 1 ) { | 1216 | } else { |
1210 | QString filename = fileDlg->LineEdit1->text(); | 1217 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1211 | destFile = currentDir.canonicalPath()+"/"+(*it); | 1218 | |
1212 | 1219 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | |
1213 | QFile f(destFile); | 1220 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
1214 | if( f.exists()) { | 1221 | |
1215 | switch ( QMessageBox::warning(this,tr("Delete"), | 1222 | QString destFile; |
1216 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1223 | fileDlg->setInputText((const QString &) destFile); |
1217 | tr("Yes"),tr("No"),0,0,1) ) { | 1224 | fileDlg->exec(); |
1218 | case 0: | 1225 | |
1219 | f.remove(); | 1226 | if( fileDlg->result() == 1 ) { |
1220 | break; | 1227 | QString filename = fileDlg->LineEdit1->text(); |
1221 | case 1: | 1228 | destFile = currentDir.canonicalPath()+"/"+filename; |
1222 | return; | 1229 | |
1223 | break; | 1230 | QFile f( destFile); |
1224 | }; | 1231 | if( f.exists()) { |
1225 | } | 1232 | switch ( QMessageBox::warning(this,tr("Delete"), |
1226 | if(!copyFile(destFile, curFile) ) { | 1233 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1227 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | 1234 | tr("Yes"),tr("No"),0,0,1) ) { |
1228 | qWarning("nothin doing"); | 1235 | case 0: |
1229 | } | 1236 | f.remove(); |
1230 | 1237 | break; | |
1231 | } | 1238 | case 1: |
1239 | return; | ||
1240 | break; | ||
1241 | }; | ||
1232 | } | 1242 | } |
1233 | populateLocalView(); | 1243 | if(!copyFile(destFile, curFile) ) { |
1234 | TabWidget->setCurrentPage(0); | 1244 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); |
1245 | qWarning("nothin doing"); | ||
1246 | } | ||
1247 | |||
1235 | } | 1248 | } |
1249 | delete fileDlg; | ||
1250 | |||
1236 | } | 1251 | } |
1252 | populateLocalView(); | ||
1253 | TabWidget->setCurrentPage(0); | ||
1237 | } | 1254 | } |
1238 | |||
1239 | } | 1255 | } |
1240 | 1256 | ||
1241 | void AdvancedFm::copySameDir() { | 1257 | void AdvancedFm::copySameDir() { |
1258 | qApp->processEvents(); | ||
1242 | QStringList curFileList = getPath(); | 1259 | QStringList curFileList = getPath(); |
1243 | if( curFileList.count() > 0) { | 1260 | QString curFile; |
1244 | QString curFile; | 1261 | InputDialog *fileDlg; |
1245 | InputDialog *fileDlg; | ||
1246 | 1262 | ||
1247 | if (TabWidget->currentPageIndex() == 0) { | 1263 | if (TabWidget->currentPageIndex() == 0) { |
1248 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1264 | |
1249 | QString destFile; | 1265 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1250 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1266 | |
1251 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 1267 | QString destFile; |
1252 | fileDlg->setInputText((const QString &) destFile ); | 1268 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1253 | fileDlg->exec(); | 1269 | |
1254 | if( fileDlg->result() == 1 ) { | 1270 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
1255 | QString filename = fileDlg->LineEdit1->text(); | 1271 | fileDlg->setInputText((const QString &) destFile ); |
1256 | destFile = currentDir.canonicalPath()+"/"+filename; | 1272 | fileDlg->exec(); |
1257 | 1273 | ||
1258 | QFile f(destFile); | 1274 | if( fileDlg->result() == 1 ) { |
1259 | if( f.exists()) { | 1275 | |
1260 | switch (QMessageBox::warning(this,tr("Delete"), | 1276 | QString filename = fileDlg->LineEdit1->text(); |
1261 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1277 | destFile = currentDir.canonicalPath()+"/"+filename; |
1262 | tr("Yes"),tr("No"),0,0,1) ) { | 1278 | |
1263 | case 0: | 1279 | QFile f(destFile); |
1264 | qDebug(""); | 1280 | if( f.exists()) { |
1265 | f.remove(); | 1281 | switch (QMessageBox::warning(this,tr("Delete"), |
1266 | break; | 1282 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1267 | case 1: | 1283 | tr("Yes"),tr("No"),0,0,1) ) { |
1268 | return; | 1284 | case 0: |
1269 | break; | 1285 | qDebug(""); |
1270 | }; | 1286 | f.remove(); |
1271 | } | 1287 | break; |
1272 | if(!copyFile(destFile, curFile) ) { | 1288 | case 1: |
1273 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | 1289 | return; |
1274 | qWarning("nothin doing"); | 1290 | break; |
1275 | } | 1291 | }; |
1276 | |||
1277 | qDebug("copy "+curFile+" as "+destFile); | ||
1278 | } | 1292 | } |
1279 | delete fileDlg; | 1293 | if(!copyFile(destFile, curFile) ) { |
1294 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | ||
1295 | qWarning("nothin doing"); | ||
1296 | } | ||
1297 | |||
1298 | qDebug("copy "+curFile+" as "+destFile); | ||
1280 | } | 1299 | } |
1281 | populateRemoteView(); | 1300 | delete fileDlg; |
1282 | TabWidget->setCurrentPage(1); | 1301 | } |
1283 | } else { | 1302 | populateLocalView(); |
1284 | if (TabWidget->currentPageIndex() == 0) { | ||
1285 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | ||
1286 | 1303 | ||
1287 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1304 | } else { |
1288 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 1305 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1289 | QString destFile; | 1306 | |
1290 | fileDlg->setInputText((const QString &) destFile); | 1307 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1291 | fileDlg->exec(); | 1308 | |
1292 | if( fileDlg->result() == 1 ) { | 1309 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
1293 | QString filename = fileDlg->LineEdit1->text(); | 1310 | QString destFile; |
1294 | destFile = currentDir.canonicalPath()+"/"+filename; | 1311 | fileDlg->setInputText((const QString &) destFile); |
1295 | 1312 | fileDlg->exec(); | |
1296 | QFile f(destFile); | 1313 | if( fileDlg->result() == 1 ) { |
1297 | if( f.exists()) { | 1314 | QString filename = fileDlg->LineEdit1->text(); |
1298 | switch ( QMessageBox::warning(this,tr("Delete"), | 1315 | |
1299 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1316 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
1300 | tr("Yes"),tr("No"),0,0,1) ) { | 1317 | |
1301 | case 0: | 1318 | QFile f(destFile); |
1302 | f.remove(); | 1319 | if( f.exists()) { |
1303 | break; | 1320 | switch ( QMessageBox::warning(this,tr("Delete"), |
1304 | case 1: | 1321 | destFile+tr(" already exists\nDo you really want to delete it?"), |
1305 | return; | 1322 | tr("Yes"),tr("No"),0,0,1) ) { |
1306 | break; | 1323 | case 0: |
1307 | }; | 1324 | f.remove(); |
1308 | } | 1325 | break; |
1309 | if(!copyFile(destFile, curFile) ) { | 1326 | case 1: |
1310 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); | 1327 | return; |
1311 | qWarning("nothin doing"); | 1328 | break; |
1312 | } | 1329 | }; |
1313 | qDebug("copy "+curFile+" as "+destFile); | ||
1314 | } | ||
1315 | delete fileDlg; | ||
1316 | } | 1330 | } |
1317 | populateLocalView(); | 1331 | if(!copyFile(destFile, curFile) ) { |
1318 | TabWidget->setCurrentPage(0); | 1332 | QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); |
1333 | qWarning("nothin doing"); | ||
1334 | } | ||
1335 | qDebug("copy "+curFile+" as "+destFile); | ||
1319 | } | 1336 | } |
1337 | delete fileDlg; | ||
1320 | } | 1338 | } |
1339 | populateRemoteView(); | ||
1321 | } | 1340 | } |
1322 | |||
1323 | } | 1341 | } |
1324 | 1342 | ||
1325 | void AdvancedFm::move() { | 1343 | void AdvancedFm::move() { |
1344 | qApp->processEvents(); | ||
1326 | 1345 | ||
1327 | QStringList curFileList = getPath(); | 1346 | QStringList curFileList = getPath(); |
1328 | if( curFileList.count() > 0) { | 1347 | if( curFileList.count() > 0) { |
1329 | QString curFile; | 1348 | QString curFile; |
1330 | // qDebug(curFile); | ||
1331 | QString destFile; | 1349 | QString destFile; |
1332 | 1350 | ||
1333 | if (TabWidget->currentPageIndex() == 0) { | 1351 | if (TabWidget->currentPageIndex() == 0) { |
1352 | |||
1334 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1353 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1354 | |||
1335 | QString destFile = currentRemoteDir.canonicalPath(); | 1355 | QString destFile = currentRemoteDir.canonicalPath(); |
1356 | |||
1336 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1357 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1337 | destFile+="/"; | 1358 | destFile+="/"; |
1338 | destFile +=(*it); | 1359 | destFile +=(*it); |
1339 | curFile = currentDir.canonicalPath(); | 1360 | curFile = currentDir.canonicalPath(); |
1361 | |||
1340 | qDebug("Destination file is "+destFile); | 1362 | qDebug("Destination file is "+destFile); |
1363 | |||
1341 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1364 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1342 | curFile +="/"; | 1365 | curFile +="/"; |
1366 | |||
1343 | curFile+=(*it); | 1367 | curFile+=(*it); |
1368 | qDebug("CurrentFile file is " + curFile); | ||
1344 | 1369 | ||
1345 | QFile f(destFile); | 1370 | QFile f( curFile); |
1346 | if( f.exists()) { | 1371 | if( f.exists()) { |
1347 | switch (QMessageBox::warning(this,tr("Delete"), | ||
1348 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1349 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1350 | case 0: | ||
1351 | f.remove(); | ||
1352 | break; | ||
1353 | case 1: | ||
1354 | return; | ||
1355 | break; | ||
1356 | }; | ||
1357 | if(!copyFile( destFile, curFile) ) { | 1372 | if(!copyFile( destFile, curFile) ) { |
1358 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 1373 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
1359 | return; | 1374 | return; |
1360 | } | 1375 | } else |
1361 | QFile::remove(curFile); | 1376 | QFile::remove(curFile); |
1362 | } | 1377 | } |
1363 | } | 1378 | } |
1379 | |||
1364 | TabWidget->setCurrentPage(1); | 1380 | TabWidget->setCurrentPage(1); |
1365 | } else { | 1381 | |
1382 | } else { //view 2 | ||
1383 | |||
1366 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1384 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1367 | QString destFile = currentRemoteDir.canonicalPath(); | 1385 | |
1386 | QString destFile = currentDir.canonicalPath(); | ||
1387 | |||
1368 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1388 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1369 | destFile+="/"; | 1389 | destFile+="/"; |
1390 | |||
1370 | destFile +=(*it); | 1391 | destFile +=(*it); |
1392 | |||
1371 | qDebug("Destination file is "+destFile); | 1393 | qDebug("Destination file is "+destFile); |
1372 | curFile = currentDir.canonicalPath(); | 1394 | |
1395 | curFile = currentRemoteDir.canonicalPath(); | ||
1396 | |||
1373 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1397 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1374 | curFile +="/"; | 1398 | curFile +="/"; |
1375 | curFile+=(*it); | 1399 | curFile+=(*it); |
1400 | qDebug("CurrentFile file is " + curFile); | ||
1376 | 1401 | ||
1377 | QFile f(destFile); | 1402 | QFile f( curFile); |
1378 | if( f.exists()) { | 1403 | if( f.exists()) { |
1379 | switch (QMessageBox::warning(this,tr("Delete"), | 1404 | if(!copyFile( destFile, curFile) ) { |
1380 | destFile+tr(" already exists\nDo you really want to delete it?"), | 1405 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); |
1381 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1382 | case 0: | ||
1383 | f.remove(); | ||
1384 | break; | ||
1385 | case 1: | ||
1386 | return; | ||
1387 | break; | ||
1388 | }; | ||
1389 | if(!copyFile(destFile, curFile) ) { | ||
1390 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | ||
1391 | return; | 1406 | return; |
1392 | } | 1407 | } else |
1408 | QFile::remove( curFile); | ||
1393 | } | 1409 | } |
1394 | QFile::remove(curFile); | ||
1395 | TabWidget->setCurrentPage(0); | 1410 | TabWidget->setCurrentPage(0); |
1396 | } | 1411 | } |
1397 | } | 1412 | } |
1398 | populateRemoteView(); | 1413 | populateRemoteView(); |
1399 | populateLocalView(); | 1414 | populateLocalView(); |
1400 | } | 1415 | } |
1401 | } | 1416 | } |
1402 | 1417 | ||
1403 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1418 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { |
1404 | { | ||
1405 | char bf[ 50000 ]; | 1419 | char bf[ 50000 ]; |
1406 | int bytesRead; | 1420 | int bytesRead; |
1407 | bool success = TRUE; | 1421 | bool success = TRUE; |
1408 | struct stat status; | 1422 | struct stat status; |
1409 | 1423 | ||
1410 | QFile s( src ); | 1424 | QFile s( src ); |
1411 | QFile d( dest ); | 1425 | QFile d( dest ); |
1412 | 1426 | ||
1413 | 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 ) ) { |
1414 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 1428 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
1415 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 1429 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
1416 | success = FALSE; | 1430 | success = FALSE; |
1417 | break; | 1431 | break; |
1418 | } | 1432 | } |
1419 | } | 1433 | } |
1420 | if( success && (bytesRead > 0) ){ | 1434 | if( success && (bytesRead > 0) ){ |
1421 | d.writeBlock( bf, bytesRead ); | 1435 | d.writeBlock( bf, bytesRead ); |
1422 | } | 1436 | } |
1423 | } else { | 1437 | } else { |
1424 | success = FALSE; | 1438 | success = FALSE; |
1425 | } | 1439 | } |
1426 | 1440 | ||
1427 | // Set file permissions | 1441 | // Set file permissions |
1428 | if( stat( (const char *) src, &status ) == 0 ){ | 1442 | if( stat( (const char *) src, &status ) == 0 ){ |
1429 | chmod( (const char *) dest, status.st_mode ); | 1443 | chmod( (const char *) dest, status.st_mode ); |
1430 | } | 1444 | } |
1431 | 1445 | ||
1432 | return success; | 1446 | return success; |
1433 | } | 1447 | } |
1434 | 1448 | ||
1435 | void AdvancedFm::runCommand() { | 1449 | void AdvancedFm::runCommand() { |
1436 | QString curFile; | 1450 | QString curFile; |
1437 | if (TabWidget->currentPageIndex() == 0) { | 1451 | if (TabWidget->currentPageIndex() == 0) { |
1438 | if( Local_View->currentItem()) | 1452 | if( Local_View->currentItem()) |
1439 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 1453 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1440 | } else { | 1454 | } else { |
1441 | if(Remote_View->currentItem()) | 1455 | if(Remote_View->currentItem()) |
1442 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 1456 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
1443 | } | 1457 | } |
1444 | 1458 | ||
1445 | InputDialog *fileDlg; | 1459 | InputDialog *fileDlg; |
1446 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1460 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1447 | fileDlg->setInputText(curFile); | 1461 | fileDlg->setInputText(curFile); |
1448 | fileDlg->exec(); | 1462 | fileDlg->exec(); |
1449 | QString command; | 1463 | QString command; |
1450 | if( fileDlg->result() == 1 ) { | 1464 | if( fileDlg->result() == 1 ) { |
1451 | command = fileDlg->LineEdit1->text(); | 1465 | command = fileDlg->LineEdit1->text(); |
1452 | 1466 | ||
1453 | Output *outDlg; | 1467 | Output *outDlg; |
1454 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1468 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1455 | outDlg->showMaximized(); | 1469 | outDlg->showMaximized(); |
1456 | outDlg->show(); | 1470 | outDlg->show(); |
1457 | qApp->processEvents(); | 1471 | qApp->processEvents(); |
1458 | FILE *fp; | 1472 | FILE *fp; |
1459 | char line[130]; | 1473 | char line[130]; |
1460 | sleep(1); | 1474 | sleep(1); |
1461 | command +=" 2>&1"; | 1475 | command +=" 2>&1"; |
1462 | fp = popen( (const char *) command, "r"); | 1476 | fp = popen( (const char *) command, "r"); |
1463 | if ( !fp ) { | 1477 | if ( !fp ) { |
1464 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1478 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1465 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 1479 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
1466 | pclose(fp); | 1480 | pclose(fp); |
1467 | return; | 1481 | return; |
1468 | } else { | 1482 | } else { |
1469 | while ( fgets( line, sizeof line, fp)) { | 1483 | while ( fgets( line, sizeof line, fp)) { |
1470 | QString lineStr = line; | 1484 | QString lineStr = line; |
1471 | lineStr=lineStr.left(lineStr.length()-1); | 1485 | lineStr=lineStr.left(lineStr.length()-1); |
1472 | outDlg->OutputEdit->append(lineStr); | 1486 | outDlg->OutputEdit->append(lineStr); |
1473 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1487 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1474 | } | 1488 | } |
1475 | } | 1489 | } |
1476 | pclose(fp); | 1490 | pclose(fp); |
1477 | 1491 | ||
1478 | } | 1492 | } |
1479 | } | 1493 | } |
1480 | 1494 | ||
1481 | void AdvancedFm::runCommandStd() { | 1495 | void AdvancedFm::runCommandStd() { |
1482 | QString curFile; | 1496 | QString curFile; |
1483 | if (TabWidget->currentPageIndex() == 0) { | 1497 | if (TabWidget->currentPageIndex() == 0) { |
1484 | if( Local_View->currentItem()) | 1498 | if( Local_View->currentItem()) |
1485 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 1499 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1486 | } else { | 1500 | } else { |
1487 | if(Remote_View->currentItem()) | 1501 | if(Remote_View->currentItem()) |
1488 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); | 1502 | curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); |
1489 | } | 1503 | } |
1490 | 1504 | ||
1491 | InputDialog *fileDlg; | 1505 | InputDialog *fileDlg; |
1492 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1506 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1493 | fileDlg->setInputText(curFile); | 1507 | fileDlg->setInputText(curFile); |
1494 | fileDlg->exec(); | 1508 | fileDlg->exec(); |
1495 | QString command; | 1509 | QString command; |
1496 | if( fileDlg->result() == 1 ) { | 1510 | if( fileDlg->result() == 1 ) { |
1497 | qApp->processEvents(); | 1511 | qApp->processEvents(); |
1498 | command = fileDlg->LineEdit1->text() + " &"; | 1512 | command = fileDlg->LineEdit1->text() + " &"; |
1499 | system(command.latin1()); | 1513 | system(command.latin1()); |
1500 | } | 1514 | } |
1501 | } | 1515 | } |
1502 | 1516 | ||
1503 | void AdvancedFm::fileStatus() { | 1517 | void AdvancedFm::fileStatus() { |
1504 | QString curFile; | 1518 | QString curFile; |
1505 | if (TabWidget->currentPageIndex() == 0) { | 1519 | if (TabWidget->currentPageIndex() == 0) { |
1506 | curFile = Local_View->currentItem()->text(0); | 1520 | curFile = Local_View->currentItem()->text(0); |
1507 | } else { | 1521 | } else { |
1508 | curFile = Remote_View->currentItem()->text(0); | 1522 | curFile = Remote_View->currentItem()->text(0); |
1509 | } | 1523 | } |
1510 | QString command = " stat -l "+ curFile +" 2>&1"; | 1524 | QString command = " stat -l "+ curFile +" 2>&1"; |
1511 | Output *outDlg; | 1525 | Output *outDlg; |
1512 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1526 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1513 | outDlg->showMaximized(); | 1527 | outDlg->showMaximized(); |
1514 | outDlg->show(); | 1528 | outDlg->show(); |
1515 | qApp->processEvents(); | 1529 | qApp->processEvents(); |
1516 | FILE *fp; | 1530 | FILE *fp; |
1517 | char line[130]; | 1531 | char line[130]; |
1518 | sleep(1); | 1532 | sleep(1); |
1519 | fp = popen( (const char *) command, "r"); | 1533 | fp = popen( (const char *) command, "r"); |
1520 | if ( !fp ) { | 1534 | if ( !fp ) { |
1521 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1535 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1522 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 1536 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
1523 | pclose(fp); | 1537 | pclose(fp); |
1524 | return; | 1538 | return; |
1525 | } else { | 1539 | } else { |
1526 | while ( fgets( line, sizeof line, fp)) { | 1540 | while ( fgets( line, sizeof line, fp)) { |
1527 | outDlg->OutputEdit->append(line); | 1541 | outDlg->OutputEdit->append(line); |
1528 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1542 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1529 | 1543 | ||
1530 | } | 1544 | } |
1531 | 1545 | ||
1532 | } | 1546 | } |
1533 | pclose(fp); | 1547 | pclose(fp); |
1534 | } | 1548 | } |
1535 | 1549 | ||
1536 | void AdvancedFm::mkDir() { | 1550 | void AdvancedFm::mkDir() { |
1537 | if (TabWidget->currentPageIndex() == 0) | 1551 | if (TabWidget->currentPageIndex() == 0) |
1538 | localMakDir(); | 1552 | localMakDir(); |
1539 | else | 1553 | else |
1540 | remoteMakDir(); | 1554 | remoteMakDir(); |
1541 | 1555 | ||
1542 | } | 1556 | } |
1543 | 1557 | ||
1544 | void AdvancedFm::rn() { | 1558 | void AdvancedFm::rn() { |
1545 | if (TabWidget->currentPageIndex() == 0) | 1559 | if (TabWidget->currentPageIndex() == 0) |
1546 | localRename(); | 1560 | localRename(); |
1547 | else | 1561 | else |
1548 | remoteRename(); | 1562 | remoteRename(); |
1549 | 1563 | ||
1550 | } | 1564 | } |
1551 | 1565 | ||
1552 | void AdvancedFm::del() { | 1566 | void AdvancedFm::del() { |
1553 | if (TabWidget->currentPageIndex() == 0) | 1567 | if (TabWidget->currentPageIndex() == 0) |
1554 | localDelete(); | 1568 | localDelete(); |
1555 | else | 1569 | else |
1556 | remoteDelete(); | 1570 | remoteDelete(); |
1557 | } | 1571 | } |
1558 | 1572 | ||
1559 | void AdvancedFm::doAbout() { | 1573 | void AdvancedFm::doAbout() { |
1560 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 1574 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
1561 | "is copyright 2002 by\n" | 1575 | "is copyright 2002 by\n" |
1562 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1576 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1563 | "and is licensed by the GPL")); | 1577 | "and is licensed by the GPL")); |
1564 | } | 1578 | } |
1565 | 1579 | ||
1566 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 1580 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
1567 | { | 1581 | { |
1568 | if( TabWidget->hasFocus()) | 1582 | if( TabWidget->hasFocus()) |
1569 | switch ( e->key() ) { | 1583 | switch ( e->key() ) { |
1570 | case Key_Delete: | 1584 | case Key_Delete: |
1571 | del(); | 1585 | del(); |
1572 | break; | 1586 | break; |
1573 | case Key_H: | 1587 | case Key_H: |
1574 | showHidden(); | 1588 | showHidden(); |
1575 | break; | 1589 | break; |
1576 | case Key_E: | 1590 | case Key_E: |
1577 | runThis(); | 1591 | runThis(); |
1578 | break; | 1592 | break; |
1579 | case Key_C: | 1593 | case Key_C: |
1580 | copy(); | 1594 | copy(); |
1581 | break; | 1595 | break; |
1582 | case Key_A: | 1596 | case Key_A: |
1583 | copyAs(); | 1597 | copyAs(); |
1584 | break; | 1598 | break; |
1585 | case Key_M: | 1599 | case Key_M: |
1586 | move(); | 1600 | move(); |
1587 | break; | 1601 | break; |
1588 | case Key_R: | 1602 | case Key_R: |
1589 | rn(); | 1603 | rn(); |
1590 | break; | 1604 | break; |
1591 | case Key_I: | 1605 | case Key_I: |
1592 | fileStatus(); | 1606 | fileStatus(); |
1593 | break; | 1607 | break; |
1594 | case Key_U: | 1608 | case Key_U: |
1595 | upDir(); | 1609 | upDir(); |
1596 | break; | 1610 | break; |
1597 | case Key_P: | 1611 | case Key_P: |
1598 | filePerms(); | 1612 | filePerms(); |
1599 | break; | 1613 | break; |
1600 | case Key_N: | 1614 | case Key_N: |
1601 | mkDir(); | 1615 | mkDir(); |
1602 | break; | 1616 | break; |
1603 | case Key_1: | 1617 | case Key_1: |
1604 | switchToLocalTab(); | 1618 | switchToLocalTab(); |
1605 | break; | 1619 | break; |
1606 | case Key_2: | 1620 | case Key_2: |
1607 | switchToRemoteTab(); | 1621 | switchToRemoteTab(); |
1608 | break; | 1622 | break; |
1609 | case Key_3: | 1623 | case Key_3: |
1610 | CFButtonPushed(); | 1624 | CFButtonPushed(); |
1611 | break; | 1625 | break; |
1612 | case Key_4: | 1626 | case Key_4: |
1613 | SDButtonPushed(); | 1627 | SDButtonPushed(); |
1614 | break; | 1628 | break; |
1615 | case Key_5: | 1629 | case Key_5: |
1616 | homeButtonPushed(); | 1630 | homeButtonPushed(); |
1617 | break; | 1631 | break; |
1618 | case Key_6: | 1632 | case Key_6: |
1619 | docButtonPushed(); | 1633 | docButtonPushed(); |
1620 | break; | 1634 | break; |
1621 | case Key_7: | 1635 | case Key_7: |
1622 | break; | 1636 | break; |
1623 | case Key_8: | 1637 | case Key_8: |
1624 | break; | 1638 | break; |
1625 | case Key_9: | 1639 | case Key_9: |
1626 | break; | 1640 | break; |
1627 | case Key_0: | 1641 | case Key_0: |
1628 | break; | 1642 | break; |
1629 | } | 1643 | } |
1630 | } | 1644 | } |
1631 | 1645 | ||
1632 | void AdvancedFm::mkSym() { | 1646 | void AdvancedFm::mkSym() { |
1633 | QString cmd; | 1647 | QString cmd; |
1634 | QStringList curFileList = getPath(); | 1648 | QStringList curFileList = getPath(); |
1635 | if( curFileList.count() > 0) { | 1649 | if( curFileList.count() > 0) { |
1636 | 1650 | ||
1637 | if (TabWidget->currentPageIndex() == 0) { | 1651 | if (TabWidget->currentPageIndex() == 0) { |
1638 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1652 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1639 | 1653 | ||
1640 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 1654 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
1641 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 1655 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
1642 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 1656 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
1643 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1657 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1644 | cmd = "ln -s "+curFile+" "+destName; | 1658 | cmd = "ln -s "+curFile+" "+destName; |
1645 | qDebug(cmd); | 1659 | qDebug(cmd); |
1646 | system(cmd.latin1() ); | 1660 | system(cmd.latin1() ); |
1647 | } | 1661 | } |
1648 | populateRemoteView(); | 1662 | populateRemoteView(); |
1649 | TabWidget->setCurrentPage(1); | 1663 | TabWidget->setCurrentPage(1); |
1650 | } else { | 1664 | } else { |
1651 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1665 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1652 | 1666 | ||
1653 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 1667 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
1654 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 1668 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
1655 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1669 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1656 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1670 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1657 | 1671 | ||
1658 | cmd = "ln -s "+curFile+" "+destName; | 1672 | cmd = "ln -s "+curFile+" "+destName; |
1659 | qDebug(cmd); | 1673 | qDebug(cmd); |
1660 | system(cmd.latin1() ); | 1674 | system(cmd.latin1() ); |
1661 | } | 1675 | } |
1662 | populateLocalView(); | 1676 | populateLocalView(); |
1663 | TabWidget->setCurrentPage(0); | 1677 | TabWidget->setCurrentPage(0); |
1664 | } | 1678 | } |
1665 | } | 1679 | } |
1666 | } | 1680 | } |
1667 | 1681 | ||
1668 | void AdvancedFm::QPEButtonPushed() { | 1682 | void AdvancedFm::QPEButtonPushed() { |
1669 | QString current = QPEApplication::qpeDir(); | 1683 | QString current = QPEApplication::qpeDir(); |
1670 | chdir( current.latin1() ); | 1684 | chdir( current.latin1() ); |
1671 | if (TabWidget->currentPageIndex() == 0) { | 1685 | if (TabWidget->currentPageIndex() == 0) { |
1672 | currentDir.cd( current, TRUE); | 1686 | currentDir.cd( current, TRUE); |
1673 | populateLocalView(); | 1687 | populateLocalView(); |
1674 | } else { | 1688 | } else { |
1675 | currentRemoteDir.cd( current, TRUE); | 1689 | currentRemoteDir.cd( current, TRUE); |
1676 | populateRemoteView(); | 1690 | populateRemoteView(); |
1677 | } | 1691 | } |
1678 | update(); | 1692 | update(); |
1679 | } | 1693 | } |
1680 | 1694 | ||
1681 | void AdvancedFm::parsetab(const QString &fileName) { | 1695 | void AdvancedFm::parsetab(const QString &fileName) { |
1682 | 1696 | ||
1683 | fileSystemTypeList.clear(); | 1697 | fileSystemTypeList.clear(); |
1684 | fsList.clear(); | 1698 | fsList.clear(); |
1685 | struct mntent *me; | 1699 | struct mntent *me; |
1686 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 1700 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
1687 | if ( mntfp ) { | 1701 | if ( mntfp ) { |
1688 | while ( (me = getmntent( mntfp )) != 0 ) { | 1702 | while ( (me = getmntent( mntfp )) != 0 ) { |
1689 | QString deviceName = me->mnt_fsname; | 1703 | QString deviceName = me->mnt_fsname; |
1690 | QString filesystemType = me->mnt_type; | 1704 | QString filesystemType = me->mnt_type; |
1691 | QString mountDir = me->mnt_dir; | 1705 | QString mountDir = me->mnt_dir; |
1692 | if(deviceName != "none") { | 1706 | if(deviceName != "none") { |
1693 | if( fsList.contains(filesystemType) == 0 | 1707 | if( fsList.contains(filesystemType) == 0 |
1694 | & filesystemType.find("proc",0,TRUE) == -1 | 1708 | & filesystemType.find("proc",0,TRUE) == -1 |
1695 | & filesystemType.find("cramfs",0,TRUE) == -1 | 1709 | & filesystemType.find("cramfs",0,TRUE) == -1 |
1696 | & filesystemType.find("auto",0,TRUE) == -1) | 1710 | & filesystemType.find("auto",0,TRUE) == -1) |
1697 | fsList << filesystemType; | 1711 | fsList << filesystemType; |
1698 | fileSystemTypeList << mountDir+"::"+filesystemType; | 1712 | fileSystemTypeList << mountDir+"::"+filesystemType; |
1699 | } | 1713 | } |
1700 | } | 1714 | } |
1701 | } | 1715 | } |
1702 | endmntent( mntfp ); | 1716 | endmntent( mntfp ); |
1703 | } | 1717 | } |
1704 | 1718 | ||
1705 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 1719 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
1706 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 1720 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
1707 | QString current = currentText;//.right( currentText.length()-1); | 1721 | QString current = currentText;//.right( currentText.length()-1); |
1708 | QString baseFs; | 1722 | QString baseFs; |
1709 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 1723 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
1710 | QString temp = (*it); | 1724 | QString temp = (*it); |
1711 | QString path = temp.left(temp.find("::",0,TRUE) ); | 1725 | QString path = temp.left(temp.find("::",0,TRUE) ); |
1712 | path = path.right( path.length()-1); | 1726 | path = path.right( path.length()-1); |
1713 | 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); |
1714 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 1728 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
1715 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 1729 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
1716 | } | 1730 | } |
1717 | } | 1731 | } |
1718 | return baseFs; | 1732 | return baseFs; |
1719 | } | 1733 | } |
1720 | 1734 | ||
1721 | QString AdvancedFm::getDiskSpace( const QString &) { | 1735 | QString AdvancedFm::getDiskSpace( const QString &) { |
1722 | 1736 | ||
1723 | } | 1737 | } |
1724 | 1738 | ||
1725 | void AdvancedFm::doBeam() { | 1739 | void AdvancedFm::doBeam() { |
1726 | Ir ir; | 1740 | Ir ir; |
1727 | if(!ir.supported()){ | 1741 | if(!ir.supported()){ |
1728 | } else { | 1742 | } else { |
1729 | 1743 | ||
1730 | QStringList curFileList = getPath(); | 1744 | QStringList curFileList = getPath(); |
1731 | if( curFileList.count() > 0) { | 1745 | if( curFileList.count() > 0) { |
1732 | 1746 | ||
1733 | if (TabWidget->currentPageIndex() == 0) { | 1747 | if (TabWidget->currentPageIndex() == 0) { |
1734 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1748 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1735 | 1749 | ||
1736 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 1750 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
1737 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1751 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1738 | Ir *file = new Ir(this, "IR"); | 1752 | Ir *file = new Ir(this, "IR"); |
1739 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 1753 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
1740 | file->send( curFile, curFile ); | 1754 | file->send( curFile, curFile ); |
1741 | } | 1755 | } |
1742 | 1756 | ||
1743 | } else { | 1757 | } else { |
1744 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1758 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1745 | 1759 | ||
1746 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1760 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1747 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 1761 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1748 | Ir *file = new Ir(this, "IR"); | 1762 | Ir *file = new Ir(this, "IR"); |
1749 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 1763 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
1750 | file->send( curFile, curFile ); | 1764 | file->send( curFile, curFile ); |
1751 | 1765 | ||
1752 | } | 1766 | } |
1753 | } | 1767 | } |
1754 | } | 1768 | } |
1755 | } | 1769 | } |
1756 | 1770 | ||
1757 | } | 1771 | } |
1758 | 1772 | ||
1759 | void AdvancedFm::fileBeamFinished( Ir *ir) { | 1773 | void AdvancedFm::fileBeamFinished( Ir *ir) { |
1760 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 1774 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
1761 | 1775 | ||
1762 | } | 1776 | } |
1763 | 1777 | ||
1764 | void AdvancedFm::showFileMenu() { | 1778 | void AdvancedFm::showFileMenu() { |
1765 | 1779 | ||
1766 | QString curApp; | 1780 | QString curApp; |
1767 | bool isLocalView = false; | 1781 | bool isLocalView = false; |
1768 | if (TabWidget->currentPageIndex() == 0) { | 1782 | if (TabWidget->currentPageIndex() == 0) { |
1769 | isLocalView = TRUE; | 1783 | isLocalView = TRUE; |
1770 | curApp = Local_View->currentItem()->text(0); | 1784 | curApp = Local_View->currentItem()->text(0); |
1771 | } else { | 1785 | } else { |
1772 | curApp = Remote_View->currentItem()->text(0); | 1786 | curApp = Remote_View->currentItem()->text(0); |
1773 | } | 1787 | } |
1774 | 1788 | ||
1775 | MimeType mt( curApp ); | 1789 | MimeType mt( curApp ); |
1776 | const AppLnk* app = mt.application(); | 1790 | const AppLnk* app = mt.application(); |
1777 | QFile fi(curApp); | 1791 | QFile fi(curApp); |
1778 | 1792 | ||
1779 | QPopupMenu *m = new QPopupMenu(0); | 1793 | QPopupMenu *m = new QPopupMenu(0); |
1780 | 1794 | ||
1781 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 1795 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
1782 | m->insertSeparator(); | 1796 | m->insertSeparator(); |
1783 | if ( QFileInfo(fi).isDir() ) { | 1797 | if ( QFileInfo(fi).isDir() ) { |
1784 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 1798 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
1785 | } else { | 1799 | } else { |
1786 | 1800 | ||
1787 | if ( app ) | 1801 | if ( app ) |
1788 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); | 1802 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); |
1789 | else if( QFileInfo(fi).isExecutable() ) | 1803 | else if( QFileInfo(fi).isExecutable() ) |
1790 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 1804 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
1791 | 1805 | ||
1792 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 1806 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
1793 | } | 1807 | } |
1794 | m->insertSeparator(); | 1808 | m->insertSeparator(); |
1795 | 1809 | ||
1796 | 1810 | ||
1797 | if(isLocalView) | 1811 | if(isLocalView) |
1798 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 1812 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
1799 | else | 1813 | else |
1800 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 1814 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
1801 | 1815 | ||
1802 | m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 1816 | m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
1803 | m->insertSeparator(); | 1817 | m->insertSeparator(); |
1804 | 1818 | ||
1805 | if(isLocalView) | 1819 | if(isLocalView) |
1806 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 1820 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
1807 | else | 1821 | else |
1808 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 1822 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
1809 | 1823 | ||
1810 | m->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 1824 | m->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
1811 | m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 1825 | m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
1812 | m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 1826 | m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
1813 | m->insertItem( tr( "Move" ), this, SLOT( move() )); | 1827 | m->insertItem( tr( "Move" ), this, SLOT( move() )); |
1814 | m->insertSeparator(); | 1828 | m->insertSeparator(); |
1815 | 1829 | ||
1816 | if(isLocalView) | 1830 | if(isLocalView) |
1817 | m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); | 1831 | m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); |
1818 | else | 1832 | else |
1819 | m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); | 1833 | m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); |
1820 | 1834 | ||
1821 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 1835 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
1822 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 1836 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
1823 | m->insertSeparator(); | 1837 | m->insertSeparator(); |
1824 | 1838 | ||
1825 | if(isLocalView) | 1839 | if(isLocalView) |
1826 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 1840 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
1827 | else | 1841 | else |
1828 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 1842 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
1829 | 1843 | ||
1830 | m->insertSeparator(); | 1844 | m->insertSeparator(); |
1831 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 1845 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
1832 | 1846 | ||
1833 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings | 1847 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings |
1834 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 1848 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
1835 | m->setCheckable(TRUE); | 1849 | m->setCheckable(TRUE); |
1836 | if (!b) | 1850 | if (!b) |
1837 | m->setItemChecked(m->idAt(0),TRUE); | 1851 | m->setItemChecked(m->idAt(0),TRUE); |
1838 | else | 1852 | else |
1839 | m->setItemChecked(m->idAt(0),FALSE); | 1853 | m->setItemChecked(m->idAt(0),FALSE); |
1840 | if(Ir::supported()) | 1854 | if(Ir::supported()) |
1841 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 1855 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
1842 | m->setFocus(); | 1856 | m->setFocus(); |
1843 | m->exec( QCursor::pos() ); | 1857 | m->exec( QCursor::pos() ); |
1844 | sleep(1); | 1858 | sleep(1); |
1845 | if(m) delete m; | 1859 | if(m) delete m; |
1846 | } | 1860 | } |
1847 | 1861 | ||
1848 | 1862 | ||
1849 | void AdvancedFm::cancelMenuTimer() { | 1863 | void AdvancedFm::cancelMenuTimer() { |
1850 | 1864 | ||
1851 | qDebug("selectionChanged: cancel menu timer"); | 1865 | qDebug("selectionChanged: cancel menu timer"); |
1852 | if( menuTimer.isActive() ) | 1866 | if( menuTimer.isActive() ) |
1853 | menuTimer.stop(); | 1867 | menuTimer.stop(); |
1854 | } | 1868 | } |
1855 | 1869 | ||
1856 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 1870 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
1857 | 1871 | ||
1858 | struct statfs fss; | 1872 | struct statfs fss; |
1859 | if ( !statfs( path.latin1(), &fss ) ) { | 1873 | if ( !statfs( path.latin1(), &fss ) ) { |
1860 | int blkSize = fss.f_bsize; | 1874 | int blkSize = fss.f_bsize; |
1861 | // int totalBlks = fs.f_blocks; | 1875 | // int totalBlks = fs.f_blocks; |
1862 | int availBlks = fss.f_bavail; | 1876 | int availBlks = fss.f_bavail; |
1863 | 1877 | ||
1864 | long mult = blkSize / 1024; | 1878 | long mult = blkSize / 1024; |
1865 | long div = 1024 / blkSize; | 1879 | long div = 1024 / blkSize; |
1866 | if ( !mult ) mult = 1; | 1880 | if ( !mult ) mult = 1; |
1867 | if ( !div ) div = 1; | 1881 | if ( !div ) div = 1; |
1868 | 1882 | ||
1869 | 1883 | ||
1870 | return QString::number(availBlks * mult / div); | 1884 | return QString::number(availBlks * mult / div); |
1871 | } | 1885 | } |
1872 | return ""; | 1886 | return ""; |
1873 | } | 1887 | } |
1874 | 1888 | ||