author | drw <drw> | 2003-04-13 23:00:25 (UTC) |
---|---|---|
committer | drw <drw> | 2003-04-13 23:00:25 (UTC) |
commit | 377a172d8b497674d14d7e3580a008228f83d081 (patch) (unidiff) | |
tree | 7a4fdb5986db9ce9b3b26c9c0b56ece9ec63a468 | |
parent | f744559411664bc8c017bd642302ffe72dfbbb84 (diff) | |
download | opie-377a172d8b497674d14d7e3580a008228f83d081.zip opie-377a172d8b497674d14d7e3580a008228f83d081.tar.gz opie-377a172d8b497674d14d7e3580a008228f83d081.tar.bz2 |
OTabWidget::getCurrentTab() is now OTabWidget::currentTab()
-rw-r--r-- | libopie/otabwidget.cpp | 20 | ||||
-rw-r--r-- | libopie/otabwidget.h | 7 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 2 |
4 files changed, 15 insertions, 16 deletions
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp index a1fd2c0..05aafd4 100644 --- a/libopie/otabwidget.cpp +++ b/libopie/otabwidget.cpp | |||
@@ -1,409 +1,409 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "otabwidget.h" | 32 | #include "otabwidget.h" |
33 | 33 | ||
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <opie/otabbar.h> | 36 | #include <opie/otabbar.h> |
37 | 37 | ||
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qwidgetstack.h> | 39 | #include <qwidgetstack.h> |
40 | 40 | ||
41 | OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) | 41 | OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) |
42 | : QWidget( parent, name ) | 42 | : QWidget( parent, name ) |
43 | { | 43 | { |
44 | if ( s == Global ) | 44 | if ( s == Global ) |
45 | { | 45 | { |
46 | Config config( "qpe" ); | 46 | Config config( "qpe" ); |
47 | config.setGroup( "Appearance" ); | 47 | config.setGroup( "Appearance" ); |
48 | s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); | 48 | s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); |
49 | if ( s <= Global || s > IconList) | 49 | if ( s <= Global || s > IconList) |
50 | { | 50 | { |
51 | s = IconTab; | 51 | s = IconTab; |
52 | } | 52 | } |
53 | QString pos = config.readEntry( "TabPosition", "Top"); | 53 | QString pos = config.readEntry( "TabPosition", "Top"); |
54 | if ( pos == "Bottom" ) | 54 | if ( pos == "Bottom" ) |
55 | { | 55 | { |
56 | p = Bottom; | 56 | p = Bottom; |
57 | } | 57 | } |
58 | else | 58 | else |
59 | { | 59 | { |
60 | p = Top; | 60 | p = Top; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | widgetStack = new QWidgetStack( this, "widgetstack" ); | 64 | widgetStack = new QWidgetStack( this, "widgetstack" ); |
65 | widgetStack->setFrameStyle( QFrame::NoFrame ); | 65 | widgetStack->setFrameStyle( QFrame::NoFrame ); |
66 | widgetStack->setLineWidth( style().defaultFrameWidth() ); | 66 | widgetStack->setLineWidth( style().defaultFrameWidth() ); |
67 | 67 | ||
68 | tabBarStack = new QWidgetStack( this, "tabbarstack" ); | 68 | tabBarStack = new QWidgetStack( this, "tabbarstack" ); |
69 | 69 | ||
70 | tabBar = new OTabBar( tabBarStack, "tabbar" ); | 70 | tabBar = new OTabBar( tabBarStack, "tabbar" ); |
71 | tabBarStack->addWidget( tabBar, 0 ); | 71 | tabBarStack->addWidget( tabBar, 0 ); |
72 | connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) ); | 72 | connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) ); |
73 | 73 | ||
74 | tabList = new QComboBox( false, tabBarStack, "tablist" ); | 74 | tabList = new QComboBox( false, tabBarStack, "tablist" ); |
75 | tabBarStack->addWidget( tabList, 1 ); | 75 | tabBarStack->addWidget( tabList, 1 ); |
76 | connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) ); | 76 | connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) ); |
77 | 77 | ||
78 | setTabStyle( s ); | 78 | setTabStyle( s ); |
79 | setTabPosition( p ); | 79 | setTabPosition( p ); |
80 | 80 | ||
81 | currentTab= 0x0; | 81 | currTab= 0x0; |
82 | } | 82 | } |
83 | 83 | ||
84 | OTabWidget::~OTabWidget() | 84 | OTabWidget::~OTabWidget() |
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) | 88 | void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) |
89 | { | 89 | { |
90 | QPixmap iconset = loadSmooth( icon ); | 90 | QPixmap iconset = loadSmooth( icon ); |
91 | 91 | ||
92 | QTab *tab = new QTab(); | 92 | QTab *tab = new QTab(); |
93 | if ( tabBarStyle == IconTab ) | 93 | if ( tabBarStyle == IconTab ) |
94 | { | 94 | { |
95 | tab->label = QString::null; | 95 | tab->label = QString::null; |
96 | } | 96 | } |
97 | else | 97 | else |
98 | { | 98 | { |
99 | tab->label = label; | 99 | tab->label = label; |
100 | } | 100 | } |
101 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) | 101 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) |
102 | { | 102 | { |
103 | tab->iconset = new QIconSet( iconset ); | 103 | tab->iconset = new QIconSet( iconset ); |
104 | } | 104 | } |
105 | int tabid = tabBar->addTab( tab ); | 105 | int tabid = tabBar->addTab( tab ); |
106 | 106 | ||
107 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) | 107 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) |
108 | { | 108 | { |
109 | tabList->insertItem( iconset, label, -1 ); | 109 | tabList->insertItem( iconset, label, -1 ); |
110 | } | 110 | } |
111 | else | 111 | else |
112 | { | 112 | { |
113 | tabList->insertItem( label ); | 113 | tabList->insertItem( label ); |
114 | } | 114 | } |
115 | 115 | ||
116 | widgetStack->addWidget( child, tabid ); | 116 | widgetStack->addWidget( child, tabid ); |
117 | widgetStack->raiseWidget( child ); | 117 | widgetStack->raiseWidget( child ); |
118 | widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); | 118 | widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); |
119 | 119 | ||
120 | OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); | 120 | OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); |
121 | tabs.append( tabinfo ); | 121 | tabs.append( tabinfo ); |
122 | selectTab( tabinfo ); | 122 | selectTab( tabinfo ); |
123 | } | 123 | } |
124 | 124 | ||
125 | void OTabWidget::removePage( QWidget *childwidget ) | 125 | void OTabWidget::removePage( QWidget *childwidget ) |
126 | { | 126 | { |
127 | if ( childwidget ) | 127 | if ( childwidget ) |
128 | { | 128 | { |
129 | OTabInfo *tab = tabs.first(); | 129 | OTabInfo *tab = tabs.first(); |
130 | while ( tab && tab->control() != childwidget ) | 130 | while ( tab && tab->control() != childwidget ) |
131 | { | 131 | { |
132 | tab = tabs.next(); | 132 | tab = tabs.next(); |
133 | } | 133 | } |
134 | if ( tab && tab->control() == childwidget ) | 134 | if ( tab && tab->control() == childwidget ) |
135 | { | 135 | { |
136 | tabBar->setTabEnabled( tab->id(), FALSE ); | 136 | tabBar->setTabEnabled( tab->id(), FALSE ); |
137 | tabBar->removeTab( tabBar->tab( tab->id() ) ); | 137 | tabBar->removeTab( tabBar->tab( tab->id() ) ); |
138 | int i = 0; | 138 | int i = 0; |
139 | while ( i < tabList->count() && tabList->text( i ) != tab->label() ) | 139 | while ( i < tabList->count() && tabList->text( i ) != tab->label() ) |
140 | { | 140 | { |
141 | i++; | 141 | i++; |
142 | } | 142 | } |
143 | if ( tabList->text( i ) == tab->label() ) | 143 | if ( tabList->text( i ) == tab->label() ) |
144 | { | 144 | { |
145 | tabList->removeItem( i ); | 145 | tabList->removeItem( i ); |
146 | } | 146 | } |
147 | widgetStack->removeWidget( childwidget ); | 147 | widgetStack->removeWidget( childwidget ); |
148 | tabs.remove( tab ); | 148 | tabs.remove( tab ); |
149 | delete tab; | 149 | delete tab; |
150 | currentTab = tabs.current(); | 150 | currTab = tabs.current(); |
151 | if ( !currentTab ) | 151 | if ( !currTab ) |
152 | { | 152 | { |
153 | widgetStack->setFrameStyle( QFrame::NoFrame ); | 153 | widgetStack->setFrameStyle( QFrame::NoFrame ); |
154 | } | 154 | } |
155 | 155 | ||
156 | setUpLayout(); | 156 | setUpLayout(); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) | 161 | void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) |
162 | { | 162 | { |
163 | OTabInfo *currtab = tabs.first(); | 163 | OTabInfo *currtab = tabs.first(); |
164 | while ( currtab && currtab->control() != widget ) | 164 | while ( currtab && currtab->control() != widget ) |
165 | { | 165 | { |
166 | currtab = tabs.next(); | 166 | currtab = tabs.next(); |
167 | } | 167 | } |
168 | if ( currtab && currtab->control() == widget ) | 168 | if ( currtab && currtab->control() == widget ) |
169 | { | 169 | { |
170 | QTab *tab = tabBar->tab( currtab->id() ); | 170 | QTab *tab = tabBar->tab( currtab->id() ); |
171 | QPixmap icon( loadSmooth( iconset ) ); | 171 | QPixmap icon( loadSmooth( iconset ) ); |
172 | tab->setText( label ); | 172 | tab->setText( label ); |
173 | if ( tabBarStyle == IconTab ) | 173 | if ( tabBarStyle == IconTab ) |
174 | tab->setIconSet( icon ); | 174 | tab->setIconSet( icon ); |
175 | int i = 0; | 175 | int i = 0; |
176 | while ( i < tabList->count() && tabList->text( i ) != currtab->label() ) | 176 | while ( i < tabList->count() && tabList->text( i ) != currtab->label() ) |
177 | { | 177 | { |
178 | i++; | 178 | i++; |
179 | } | 179 | } |
180 | if ( i < tabList->count() && tabList->text( i ) == currtab->label() ) | 180 | if ( i < tabList->count() && tabList->text( i ) == currtab->label() ) |
181 | { | 181 | { |
182 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) | 182 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) |
183 | { | 183 | { |
184 | tabList->changeItem( icon, label, i ); | 184 | tabList->changeItem( icon, label, i ); |
185 | } | 185 | } |
186 | else | 186 | else |
187 | { | 187 | { |
188 | tabList->changeItem( label, i ); | 188 | tabList->changeItem( label, i ); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | currtab->setLabel( label ); | 191 | currtab->setLabel( label ); |
192 | currtab->setIcon( iconset ); | 192 | currtab->setIcon( iconset ); |
193 | } | 193 | } |
194 | setUpLayout(); | 194 | setUpLayout(); |
195 | } | 195 | } |
196 | 196 | ||
197 | void OTabWidget::setCurrentTab( QWidget *childwidget ) | 197 | void OTabWidget::setCurrentTab( QWidget *childwidget ) |
198 | { | 198 | { |
199 | OTabInfo *currtab = tabs.first(); | 199 | OTabInfo *currtab = tabs.first(); |
200 | while ( currtab && currtab->control() != childwidget ) | 200 | while ( currtab && currtab->control() != childwidget ) |
201 | { | 201 | { |
202 | currtab = tabs.next(); | 202 | currtab = tabs.next(); |
203 | } | 203 | } |
204 | if ( currtab && currtab->control() == childwidget ) | 204 | if ( currtab && currtab->control() == childwidget ) |
205 | { | 205 | { |
206 | selectTab( currtab ); | 206 | selectTab( currtab ); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void OTabWidget::setCurrentTab( const QString &tabname ) | 210 | void OTabWidget::setCurrentTab( const QString &tabname ) |
211 | { | 211 | { |
212 | OTabInfo *newtab = tabs.first(); | 212 | OTabInfo *newtab = tabs.first(); |
213 | while ( newtab && newtab->label() != tabname ) | 213 | while ( newtab && newtab->label() != tabname ) |
214 | { | 214 | { |
215 | newtab = tabs.next(); | 215 | newtab = tabs.next(); |
216 | } | 216 | } |
217 | if ( newtab && newtab->label() == tabname ) | 217 | if ( newtab && newtab->label() == tabname ) |
218 | { | 218 | { |
219 | selectTab( newtab ); | 219 | selectTab( newtab ); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | void OTabWidget::setCurrentTab(int tabindex) { | 223 | void OTabWidget::setCurrentTab(int tabindex) { |
224 | OTabInfo *newtab = tabs.first(); | 224 | OTabInfo *newtab = tabs.first(); |
225 | while ( newtab && newtab->id() != tabindex ) | 225 | while ( newtab && newtab->id() != tabindex ) |
226 | { | 226 | { |
227 | newtab = tabs.next(); | 227 | newtab = tabs.next(); |
228 | } | 228 | } |
229 | if ( newtab && newtab->id() == tabindex ) | 229 | if ( newtab && newtab->id() == tabindex ) |
230 | { | 230 | { |
231 | selectTab( newtab ); | 231 | selectTab( newtab ); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | OTabWidget::TabStyle OTabWidget::tabStyle() const | 236 | OTabWidget::TabStyle OTabWidget::tabStyle() const |
237 | { | 237 | { |
238 | return tabBarStyle; | 238 | return tabBarStyle; |
239 | } | 239 | } |
240 | 240 | ||
241 | void OTabWidget::setTabStyle( TabStyle s ) | 241 | void OTabWidget::setTabStyle( TabStyle s ) |
242 | { | 242 | { |
243 | tabBarStyle = s; | 243 | tabBarStyle = s; |
244 | if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) | 244 | if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) |
245 | { | 245 | { |
246 | QTab *currtab; | 246 | QTab *currtab; |
247 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) | 247 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) |
248 | { | 248 | { |
249 | currtab = tabBar->tab( tabinfo->id() ); | 249 | currtab = tabBar->tab( tabinfo->id() ); |
250 | if ( tabBarStyle == IconTab ) | 250 | if ( tabBarStyle == IconTab ) |
251 | { | 251 | { |
252 | currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); | 252 | currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); |
253 | if ( tabinfo == currentTab ) | 253 | if ( tabinfo == currTab ) |
254 | currtab->setText( tabinfo->label() ); | 254 | currtab->setText( tabinfo->label() ); |
255 | else | 255 | else |
256 | currtab->setText( QString::null ); | 256 | currtab->setText( QString::null ); |
257 | } | 257 | } |
258 | else | 258 | else |
259 | { | 259 | { |
260 | currtab->iconset = 0x0; | 260 | currtab->iconset = 0x0; |
261 | currtab->setText( tabinfo->label() ); | 261 | currtab->setText( tabinfo->label() ); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | tabBarStack->raiseWidget( tabBar ); | 264 | tabBarStack->raiseWidget( tabBar ); |
265 | } | 265 | } |
266 | else if ( tabBarStyle == TextList || tabBarStyle == IconList ) | 266 | else if ( tabBarStyle == TextList || tabBarStyle == IconList ) |
267 | { | 267 | { |
268 | tabList->clear(); | 268 | tabList->clear(); |
269 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) | 269 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) |
270 | { | 270 | { |
271 | if ( tabBarStyle == IconList ) | 271 | if ( tabBarStyle == IconList ) |
272 | { | 272 | { |
273 | tabList->insertItem( loadSmooth( tabinfo->icon() ), tabinfo->label() ); | 273 | tabList->insertItem( loadSmooth( tabinfo->icon() ), tabinfo->label() ); |
274 | } | 274 | } |
275 | else | 275 | else |
276 | { | 276 | { |
277 | tabList->insertItem( tabinfo->label() ); | 277 | tabList->insertItem( tabinfo->label() ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | tabBarStack->raiseWidget( tabList ); | 280 | tabBarStack->raiseWidget( tabList ); |
281 | } | 281 | } |
282 | setUpLayout(); | 282 | setUpLayout(); |
283 | } | 283 | } |
284 | 284 | ||
285 | OTabWidget::TabPosition OTabWidget::tabPosition() const | 285 | OTabWidget::TabPosition OTabWidget::tabPosition() const |
286 | { | 286 | { |
287 | return tabBarPosition; | 287 | return tabBarPosition; |
288 | } | 288 | } |
289 | 289 | ||
290 | void OTabWidget::setTabPosition( TabPosition p ) | 290 | void OTabWidget::setTabPosition( TabPosition p ) |
291 | { | 291 | { |
292 | tabBarPosition = p; | 292 | tabBarPosition = p; |
293 | if ( tabBarPosition == Top ) | 293 | if ( tabBarPosition == Top ) |
294 | { | 294 | { |
295 | tabBar->setShape( QTabBar::RoundedAbove ); | 295 | tabBar->setShape( QTabBar::RoundedAbove ); |
296 | } | 296 | } |
297 | else | 297 | else |
298 | { | 298 | { |
299 | tabBar->setShape( QTabBar::RoundedBelow ); | 299 | tabBar->setShape( QTabBar::RoundedBelow ); |
300 | } | 300 | } |
301 | setUpLayout(); | 301 | setUpLayout(); |
302 | } | 302 | } |
303 | 303 | ||
304 | void OTabWidget::slotTabBarSelected( int id ) | 304 | void OTabWidget::slotTabBarSelected( int id ) |
305 | { | 305 | { |
306 | OTabInfo *newtab = tabs.first(); | 306 | OTabInfo *newtab = tabs.first(); |
307 | while ( newtab && newtab->id() != id ) | 307 | while ( newtab && newtab->id() != id ) |
308 | { | 308 | { |
309 | newtab = tabs.next(); | 309 | newtab = tabs.next(); |
310 | } | 310 | } |
311 | if ( newtab && newtab->id() == id ) | 311 | if ( newtab && newtab->id() == id ) |
312 | { | 312 | { |
313 | selectTab( newtab ); | 313 | selectTab( newtab ); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | void OTabWidget::slotTabListSelected( int index ) | 317 | void OTabWidget::slotTabListSelected( int index ) |
318 | { | 318 | { |
319 | OTabInfo *newtab = tabs.at( index ); | 319 | OTabInfo *newtab = tabs.at( index ); |
320 | if ( newtab ) | 320 | if ( newtab ) |
321 | { | 321 | { |
322 | selectTab( newtab ); | 322 | selectTab( newtab ); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | QPixmap OTabWidget::loadSmooth( const QString &name ) | 326 | QPixmap OTabWidget::loadSmooth( const QString &name ) |
327 | { | 327 | { |
328 | QImage image = Resource::loadImage( name ); | 328 | QImage image = Resource::loadImage( name ); |
329 | QPixmap pixmap; | 329 | QPixmap pixmap; |
330 | pixmap.convertFromImage( image.smoothScale( 14, 14 ) ); | 330 | pixmap.convertFromImage( image.smoothScale( 14, 14 ) ); |
331 | return pixmap; | 331 | return pixmap; |
332 | } | 332 | } |
333 | 333 | ||
334 | void OTabWidget::selectTab( OTabInfo *tab ) | 334 | void OTabWidget::selectTab( OTabInfo *tab ) |
335 | { | 335 | { |
336 | if ( tabBarStyle == IconTab ) | 336 | if ( tabBarStyle == IconTab ) |
337 | { | 337 | { |
338 | if ( currentTab ) | 338 | if ( currTab ) |
339 | { | 339 | { |
340 | tabBar->tab( currentTab->id() )->setText( QString::null ); | 340 | tabBar->tab( currTab->id() )->setText( QString::null ); |
341 | setUpLayout(); | 341 | setUpLayout(); |
342 | } | 342 | } |
343 | tabBar->tab( tab->id() )->setText( tab->label() ); | 343 | tabBar->tab( tab->id() )->setText( tab->label() ); |
344 | tabBar->setCurrentTab( tab->id() ); | 344 | tabBar->setCurrentTab( tab->id() ); |
345 | setUpLayout(); | 345 | setUpLayout(); |
346 | tabBar->update(); | 346 | tabBar->update(); |
347 | } | 347 | } |
348 | else | 348 | else |
349 | { | 349 | { |
350 | tabBar->setCurrentTab( tab->id() ); | 350 | tabBar->setCurrentTab( tab->id() ); |
351 | } | 351 | } |
352 | 352 | ||
353 | widgetStack->raiseWidget( tab->control() ); | 353 | widgetStack->raiseWidget( tab->control() ); |
354 | 354 | ||
355 | emit currentChanged( tab->control() ); | 355 | emit currentChanged( tab->control() ); |
356 | 356 | ||
357 | currentTab = tab; | 357 | currTab = tab; |
358 | } | 358 | } |
359 | 359 | ||
360 | void OTabWidget::setUpLayout() | 360 | void OTabWidget::setUpLayout() |
361 | { | 361 | { |
362 | tabBar->layoutTabs(); | 362 | tabBar->layoutTabs(); |
363 | QSize t( tabBarStack->sizeHint() ); | 363 | QSize t( tabBarStack->sizeHint() ); |
364 | if ( tabBarStyle == IconTab ) | 364 | if ( tabBarStyle == IconTab ) |
365 | { | 365 | { |
366 | if ( t.width() > width() ) | 366 | if ( t.width() > width() ) |
367 | t.setWidth( width() ); | 367 | t.setWidth( width() ); |
368 | } | 368 | } |
369 | else | 369 | else |
370 | { | 370 | { |
371 | t.setWidth( width() ); | 371 | t.setWidth( width() ); |
372 | } | 372 | } |
373 | int lw = widgetStack->lineWidth(); | 373 | int lw = widgetStack->lineWidth(); |
374 | if ( tabBarPosition == Bottom ) | 374 | if ( tabBarPosition == Bottom ) |
375 | { | 375 | { |
376 | tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); | 376 | tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); |
377 | widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); | 377 | widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); |
378 | } | 378 | } |
379 | else | 379 | else |
380 | { | 380 | { |
381 | tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); | 381 | tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); |
382 | widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); | 382 | widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); |
383 | } | 383 | } |
384 | 384 | ||
385 | if ( autoMask() ) | 385 | if ( autoMask() ) |
386 | updateMask(); | 386 | updateMask(); |
387 | } | 387 | } |
388 | 388 | ||
389 | QSize OTabWidget::sizeHint() const | 389 | QSize OTabWidget::sizeHint() const |
390 | { | 390 | { |
391 | QSize s( widgetStack->sizeHint() ); | 391 | QSize s( widgetStack->sizeHint() ); |
392 | QSize t( tabBarStack->sizeHint() ); | 392 | QSize t( tabBarStack->sizeHint() ); |
393 | return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() ); | 393 | return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() ); |
394 | } | 394 | } |
395 | 395 | ||
396 | void OTabWidget::resizeEvent( QResizeEvent * ) | 396 | void OTabWidget::resizeEvent( QResizeEvent * ) |
397 | { | 397 | { |
398 | setUpLayout(); | 398 | setUpLayout(); |
399 | } | 399 | } |
400 | 400 | ||
401 | int OTabWidget::getCurrentTab() | 401 | int OTabWidget::currentTab() |
402 | { | 402 | { |
403 | if ( currentTab ) | 403 | if ( currTab ) |
404 | { | 404 | { |
405 | return currentTab->id(); | 405 | return currTab->id(); |
406 | } | 406 | } |
407 | return -1; | 407 | return -1; |
408 | } | 408 | } |
409 | 409 | ||
diff --git a/libopie/otabwidget.h b/libopie/otabwidget.h index 23fe774..bcd9a85 100644 --- a/libopie/otabwidget.h +++ b/libopie/otabwidget.h | |||
@@ -1,277 +1,276 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OTABWIDGET_H | 32 | #ifndef OTABWIDGET_H |
33 | #define OTABWIDGET_H | 33 | #define OTABWIDGET_H |
34 | 34 | ||
35 | #include "otabinfo.h" | 35 | #include "otabinfo.h" |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qlist.h> | 38 | #include <qlist.h> |
39 | 39 | ||
40 | class OTabBar; | 40 | class OTabBar; |
41 | class QComboBox; | 41 | class QComboBox; |
42 | class QPixmap; | 42 | class QPixmap; |
43 | class QTabBar; | 43 | class QTabBar; |
44 | class QWidgetStack; | 44 | class QWidgetStack; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * @class OTabWidget | 47 | * @class OTabWidget |
48 | * @brief The OTabWidget class provides a stack of widgets. | 48 | * @brief The OTabWidget class provides a stack of widgets. |
49 | * | 49 | * |
50 | * OTabWidget is a derivation of TrollTech's QTabWidget which provides | 50 | * OTabWidget is a derivation of TrollTech's QTabWidget which provides |
51 | * a stack of widgets. Widgets can be selected using either a tab bar or | 51 | * a stack of widgets. Widgets can be selected using either a tab bar or |
52 | * drop down list box. | 52 | * drop down list box. |
53 | * | 53 | * |
54 | * The normal way to use OTabWidget is to do the following in the | 54 | * The normal way to use OTabWidget is to do the following in the |
55 | * constructor: | 55 | * constructor: |
56 | * - Create a OTabWidget. | 56 | * - Create a OTabWidget. |
57 | * - Create a QWidget for each of the pages in the control, insert | 57 | * - Create a QWidget for each of the pages in the control, insert |
58 | * children into it, set up geometry management for it, and use addTab() | 58 | * children into it, set up geometry management for it, and use addTab() |
59 | * to add the widget. | 59 | * to add the widget. |
60 | */ | 60 | */ |
61 | class OTabWidget : public QWidget | 61 | class OTabWidget : public QWidget |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * @enum TabStyle | 67 | * @enum TabStyle |
68 | * @brief Defines how the widget selection control is displayed. | 68 | * @brief Defines how the widget selection control is displayed. |
69 | * | 69 | * |
70 | * Valid values: | 70 | * Valid values: |
71 | * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) | 71 | * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) |
72 | * - TextTab: Tabbed widget selection with text labels | 72 | * - TextTab: Tabbed widget selection with text labels |
73 | * - IconTab: Tabbed widget selection with icon labels, text label for active widget | 73 | * - IconTab: Tabbed widget selection with icon labels, text label for active widget |
74 | * (similar to Opie launcher) | 74 | * (similar to Opie launcher) |
75 | * - TextList: Drop down list widget selection with text labels | 75 | * - TextList: Drop down list widget selection with text labels |
76 | * - IconList: Drop down list widget selection with icon & text labels | 76 | * - IconList: Drop down list widget selection with icon & text labels |
77 | */ | 77 | */ |
78 | enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; | 78 | enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * @enum TabPosition | 81 | * @enum TabPosition |
82 | * @brief Defines where the widget selection control is drawn. | 82 | * @brief Defines where the widget selection control is drawn. |
83 | * | 83 | * |
84 | * Valid values: | 84 | * Valid values: |
85 | * - Top: Widget selection control is drawn above widgets | 85 | * - Top: Widget selection control is drawn above widgets |
86 | * - Bottom: Widget selection control is drawn below widgets | 86 | * - Bottom: Widget selection control is drawn below widgets |
87 | */ | 87 | */ |
88 | enum TabPosition { Top, Bottom }; | 88 | enum TabPosition { Top, Bottom }; |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top ) | 91 | * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top ) |
92 | * @brief Object constructor. | 92 | * @brief Object constructor. |
93 | * | 93 | * |
94 | * @param parent Pointer to parent of this control. | 94 | * @param parent Pointer to parent of this control. |
95 | * @param name Name of control. | 95 | * @param name Name of control. |
96 | * @param s Style of widget selection control. | 96 | * @param s Style of widget selection control. |
97 | * @param p Position of the widget selection control. | 97 | * @param p Position of the widget selection control. |
98 | * | 98 | * |
99 | * Constructs a new OTabWidget control with parent and name. The style and position parameters | 99 | * Constructs a new OTabWidget control with parent and name. The style and position parameters |
100 | * determine how the widget selection control will be displayed. | 100 | * determine how the widget selection control will be displayed. |
101 | */ | 101 | */ |
102 | // FIXME WFlags? -zecke | 102 | // FIXME WFlags? -zecke |
103 | OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); | 103 | OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * @fn ~OTabWidget() | 106 | * @fn ~OTabWidget() |
107 | * @brief Object destructor. | 107 | * @brief Object destructor. |
108 | */ | 108 | */ |
109 | ~OTabWidget(); | 109 | ~OTabWidget(); |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * @fn addTab( QWidget *child, const QString &icon, const QString &label ) | 112 | * @fn addTab( QWidget *child, const QString &icon, const QString &label ) |
113 | * @brief Add new widget to control. | 113 | * @brief Add new widget to control. |
114 | * | 114 | * |
115 | * @param child Widget control. | 115 | * @param child Widget control. |
116 | * @param icon Path to icon. | 116 | * @param icon Path to icon. |
117 | * @param label Text label. | 117 | * @param label Text label. |
118 | */ | 118 | */ |
119 | void addTab( QWidget *, const QString &, const QString & ); | 119 | void addTab( QWidget *, const QString &, const QString & ); |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * @fn removePage( QWidget *widget ) | 122 | * @fn removePage( QWidget *widget ) |
123 | * @brief Remove widget from control. Does not delete widget. | 123 | * @brief Remove widget from control. Does not delete widget. |
124 | * | 124 | * |
125 | * @param widget Widget control to be removed. | 125 | * @param widget Widget control to be removed. |
126 | */ | 126 | */ |
127 | void removePage( QWidget * ); | 127 | void removePage( QWidget * ); |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * @fn changeTab( QWidget *widget, const QIconSet &icon, const QString &label ) | 130 | * @fn changeTab( QWidget *widget, const QIconSet &icon, const QString &label ) |
131 | * @brief Change text and/or icon for existing tab | 131 | * @brief Change text and/or icon for existing tab |
132 | * | 132 | * |
133 | * @param child Widget control. | 133 | * @param child Widget control. |
134 | * @param icon Path to icon. | 134 | * @param icon Path to icon. |
135 | * @param label Text label. | 135 | * @param label Text label. |
136 | */ | 136 | */ |
137 | void changeTab( QWidget *, const QString &, const QString & ); | 137 | void changeTab( QWidget *, const QString &, const QString & ); |
138 | 138 | ||
139 | /** | 139 | /** |
140 | * @fn tabStyle() | 140 | * @fn tabStyle() |
141 | * @brief Returns current widget selection control style. | 141 | * @brief Returns current widget selection control style. |
142 | */ | 142 | */ |
143 | TabStyle tabStyle() const; | 143 | TabStyle tabStyle() const; |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * @fn setTabStyle( TabStyle s ) | 146 | * @fn setTabStyle( TabStyle s ) |
147 | * @brief Set the current widget selection control style. | 147 | * @brief Set the current widget selection control style. |
148 | * | 148 | * |
149 | * @param s New style to be used. | 149 | * @param s New style to be used. |
150 | */ | 150 | */ |
151 | void setTabStyle( TabStyle ); | 151 | void setTabStyle( TabStyle ); |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * @fn tabPosition() | 154 | * @fn tabPosition() |
155 | * @brief Returns current widget selection control position. | 155 | * @brief Returns current widget selection control position. |
156 | */ | 156 | */ |
157 | TabPosition tabPosition() const; | 157 | TabPosition tabPosition() const; |
158 | 158 | ||
159 | /** | 159 | /** |
160 | * @fn setTabPosition( TabPosition p ) | 160 | * @fn setTabPosition( TabPosition p ) |
161 | * @brief Set the current widget selection control position. | 161 | * @brief Set the current widget selection control position. |
162 | * | 162 | * |
163 | * @param p New position of widget selection control. | 163 | * @param p New position of widget selection control. |
164 | */ | 164 | */ |
165 | void setTabPosition( TabPosition ); | 165 | void setTabPosition( TabPosition ); |
166 | 166 | ||
167 | /** | 167 | /** |
168 | * @fn setCurrentTab( QWidget *childwidget ) | 168 | * @fn setCurrentTab( QWidget *childwidget ) |
169 | * @brief Selects and brings to top the desired widget by using widget pointer. | 169 | * @brief Selects and brings to top the desired widget by using widget pointer. |
170 | * | 170 | * |
171 | * @param childwidget Widget to select. | 171 | * @param childwidget Widget to select. |
172 | */ | 172 | */ |
173 | void setCurrentTab( QWidget * ); | 173 | void setCurrentTab( QWidget * ); |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * @fn setCurrentTab( const QString &tabname ) | 176 | * @fn setCurrentTab( const QString &tabname ) |
177 | * @brief Selects and brings to top the desired widget, by using label. | 177 | * @brief Selects and brings to top the desired widget, by using label. |
178 | * | 178 | * |
179 | * @param tabname Text label for widget to select. | 179 | * @param tabname Text label for widget to select. |
180 | */ | 180 | */ |
181 | void setCurrentTab( const QString & ); | 181 | void setCurrentTab( const QString & ); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | * @fn setCurrentTab( int ) | 184 | * @fn setCurrentTab( int ) |
185 | * @brief Selects and brings to top the desired widget, by using id. | 185 | * @brief Selects and brings to top the desired widget, by using id. |
186 | * | 186 | * |
187 | * @param tab id for widget to select. | 187 | * @param tab id for widget to select. |
188 | */ | 188 | */ |
189 | void setCurrentTab(int); | 189 | void setCurrentTab(int); |
190 | 190 | ||
191 | /** | 191 | /** |
192 | * @fn sizeHint() | 192 | * @fn sizeHint() |
193 | * @brief Reimplemented for internal purposes. | 193 | * @brief Reimplemented for internal purposes. |
194 | */ | 194 | */ |
195 | QSize sizeHint() const; | 195 | QSize sizeHint() const; |
196 | 196 | ||
197 | /** | 197 | /** |
198 | * @fn getCurrentTab( ) | 198 | * @fn currentTab( ) |
199 | * @brief returns current tab id. | 199 | * @brief returns current tab id. |
200 | */ | 200 | */ |
201 | //FIXME TT coding style currentTab() -zecke | 201 | int currentTab(); |
202 | int getCurrentTab(); | ||
203 | 202 | ||
204 | 203 | ||
205 | protected: | 204 | protected: |
206 | 205 | ||
207 | /** | 206 | /** |
208 | * @fn resizeEvent( QResizeEvent * ) | 207 | * @fn resizeEvent( QResizeEvent * ) |
209 | * @brief Reimplemented for internal purposes. | 208 | * @brief Reimplemented for internal purposes. |
210 | */ | 209 | */ |
211 | void resizeEvent( QResizeEvent * ); | 210 | void resizeEvent( QResizeEvent * ); |
212 | 211 | ||
213 | private: | 212 | private: |
214 | OTabInfoList tabs; | 213 | OTabInfoList tabs; |
215 | OTabInfo *currentTab; | 214 | OTabInfo *currTab; |
216 | 215 | ||
217 | TabStyle tabBarStyle; | 216 | TabStyle tabBarStyle; |
218 | TabPosition tabBarPosition; | 217 | TabPosition tabBarPosition; |
219 | 218 | ||
220 | QWidgetStack *tabBarStack; | 219 | QWidgetStack *tabBarStack; |
221 | OTabBar *tabBar; | 220 | OTabBar *tabBar; |
222 | QComboBox *tabList; | 221 | QComboBox *tabList; |
223 | 222 | ||
224 | QWidgetStack *widgetStack; | 223 | QWidgetStack *widgetStack; |
225 | 224 | ||
226 | /** | 225 | /** |
227 | * @fn loadSmooth( const QString &name ) | 226 | * @fn loadSmooth( const QString &name ) |
228 | * @brief Loads icon for widget. | 227 | * @brief Loads icon for widget. |
229 | * | 228 | * |
230 | * @param name Name of icon image file. | 229 | * @param name Name of icon image file. |
231 | */ | 230 | */ |
232 | QPixmap loadSmooth( const QString & ); | 231 | QPixmap loadSmooth( const QString & ); |
233 | 232 | ||
234 | /** | 233 | /** |
235 | * @fn selectTab( OTabInfo *tab ) | 234 | * @fn selectTab( OTabInfo *tab ) |
236 | * @brief Internal function to select desired widget. | 235 | * @brief Internal function to select desired widget. |
237 | * | 236 | * |
238 | * @param tab Pointer to data for widget. | 237 | * @param tab Pointer to data for widget. |
239 | */ | 238 | */ |
240 | void selectTab( OTabInfo * ); | 239 | void selectTab( OTabInfo * ); |
241 | 240 | ||
242 | /** | 241 | /** |
243 | * @fn setUpLayout() | 242 | * @fn setUpLayout() |
244 | * @brief Internal function to adjust layout. | 243 | * @brief Internal function to adjust layout. |
245 | */ | 244 | */ |
246 | void setUpLayout(); | 245 | void setUpLayout(); |
247 | 246 | ||
248 | 247 | ||
249 | signals: | 248 | signals: |
250 | /** | 249 | /** |
251 | * @fn currentChanegd( QWidget *widget ) | 250 | * @fn currentChanegd( QWidget *widget ) |
252 | * @brief This signal is emitted whenever the widget has changed. | 251 | * @brief This signal is emitted whenever the widget has changed. |
253 | * | 252 | * |
254 | * @param widget Pointer to new current widget. | 253 | * @param widget Pointer to new current widget. |
255 | */ | 254 | */ |
256 | void currentChanged( QWidget * ); | 255 | void currentChanged( QWidget * ); |
257 | 256 | ||
258 | private slots: | 257 | private slots: |
259 | 258 | ||
260 | /** | 259 | /** |
261 | * @fn slotTabBarSelected( int id ) | 260 | * @fn slotTabBarSelected( int id ) |
262 | * @brief Slot which is called when a tab is selected. | 261 | * @brief Slot which is called when a tab is selected. |
263 | * | 262 | * |
264 | * @param id ID of widget selected. | 263 | * @param id ID of widget selected. |
265 | */ | 264 | */ |
266 | void slotTabBarSelected( int ); | 265 | void slotTabBarSelected( int ); |
267 | 266 | ||
268 | /** | 267 | /** |
269 | * @fn slotTabListSelected( int index ) | 268 | * @fn slotTabListSelected( int index ) |
270 | * @brief Slot which is called when a drop down selection is made. | 269 | * @brief Slot which is called when a drop down selection is made. |
271 | * | 270 | * |
272 | * @param id Index of widget selected. | 271 | * @param id Index of widget selected. |
273 | */ | 272 | */ |
274 | void slotTabListSelected( int ); | 273 | void slotTabListSelected( int ); |
275 | }; | 274 | }; |
276 | 275 | ||
277 | #endif | 276 | #endif |
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 1a5e131..41e83c7 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,904 +1,904 @@ | |||
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 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
14 | 14 | ||
15 | #include <opie/otabwidget.h> | 15 | #include <opie/otabwidget.h> |
16 | // #include <opie/ofileselector.h> | 16 | // #include <opie/ofileselector.h> |
17 | // #include <opie/ofiledialog.h> | 17 | // #include <opie/ofiledialog.h> |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qpe/filemanager.h> | 20 | #include <qpe/filemanager.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/mimetype.h> | 27 | #include <qpe/mimetype.h> |
28 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
29 | #include <qpe/ir.h> | 29 | #include <qpe/ir.h> |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qpe/menubutton.h> | 31 | #include <qpe/menubutton.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include <qwmatrix.h> | 34 | #include <qwmatrix.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qdatetime.h> | 39 | #include <qdatetime.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qstring.h> | 42 | #include <qstring.h> |
43 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qlistview.h> | 45 | #include <qlistview.h> |
46 | #include <qmainwindow.h> | 46 | #include <qmainwindow.h> |
47 | #include <qlabel.h> | 47 | #include <qlabel.h> |
48 | #include <qprogressbar.h> | 48 | #include <qprogressbar.h> |
49 | #include <qspinbox.h> | 49 | #include <qspinbox.h> |
50 | #include <qwidget.h> | 50 | #include <qwidget.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qimage.h> | 52 | #include <qimage.h> |
53 | #include <qpixmap.h> | 53 | #include <qpixmap.h> |
54 | #include <qmessagebox.h> | 54 | #include <qmessagebox.h> |
55 | #include <qlineedit.h> | 55 | #include <qlineedit.h> |
56 | #include <qregexp.h> | 56 | #include <qregexp.h> |
57 | 57 | ||
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
60 | #include <sys/stat.h> | 60 | #include <sys/stat.h> |
61 | #include <dirent.h> | 61 | #include <dirent.h> |
62 | #include <stdio.h> | 62 | #include <stdio.h> |
63 | #include <time.h> | 63 | #include <time.h> |
64 | #include <fcntl.h> | 64 | #include <fcntl.h> |
65 | #include <mntent.h> | 65 | #include <mntent.h> |
66 | #include <string.h> | 66 | #include <string.h> |
67 | #include <errno.h> | 67 | #include <errno.h> |
68 | #include <sys/vfs.h> | 68 | #include <sys/vfs.h> |
69 | #include <mntent.h> | 69 | #include <mntent.h> |
70 | #include <sys/utsname.h> | 70 | #include <sys/utsname.h> |
71 | 71 | ||
72 | AdvancedFm::AdvancedFm( ) | 72 | AdvancedFm::AdvancedFm( ) |
73 | : QMainWindow( ) { | 73 | : QMainWindow( ) { |
74 | init(); | 74 | init(); |
75 | renameBox = 0; | 75 | renameBox = 0; |
76 | 76 | ||
77 | QWMatrix matrix; | 77 | QWMatrix matrix; |
78 | QPixmap pix(Resource::loadPixmap( "UnknownDocument" )); | 78 | QPixmap pix(Resource::loadPixmap( "UnknownDocument" )); |
79 | matrix.scale( .4, .4); | 79 | matrix.scale( .4, .4); |
80 | unknownXpm = pix.xForm(matrix); | 80 | unknownXpm = pix.xForm(matrix); |
81 | 81 | ||
82 | initConnections(); | 82 | initConnections(); |
83 | whichTab=1; | 83 | whichTab=1; |
84 | rePopulate(); | 84 | rePopulate(); |
85 | currentPathCombo->setFocus(); | 85 | currentPathCombo->setFocus(); |
86 | } | 86 | } |
87 | 87 | ||
88 | AdvancedFm::~AdvancedFm() { | 88 | AdvancedFm::~AdvancedFm() { |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void AdvancedFm::cleanUp() | 92 | void AdvancedFm::cleanUp() |
93 | { | 93 | { |
94 | QString sfile=QDir::homeDirPath(); | 94 | QString sfile=QDir::homeDirPath(); |
95 | if(sfile.right(1) != "/") | 95 | if(sfile.right(1) != "/") |
96 | sfile+="/._temp"; | 96 | sfile+="/._temp"; |
97 | else | 97 | else |
98 | sfile+="._temp"; | 98 | sfile+="._temp"; |
99 | QFile file( sfile); | 99 | QFile file( sfile); |
100 | if(file.exists()) | 100 | if(file.exists()) |
101 | file.remove(); | 101 | file.remove(); |
102 | } | 102 | } |
103 | 103 | ||
104 | void AdvancedFm::tabChanged(QWidget *w) | 104 | void AdvancedFm::tabChanged(QWidget *w) |
105 | { | 105 | { |
106 | if( w == tab) | 106 | if( w == tab) |
107 | whichTab = 1; | 107 | whichTab = 1; |
108 | else | 108 | else |
109 | whichTab = 2; | 109 | whichTab = 2; |
110 | 110 | ||
111 | // qDebug("tab changed %d", whichTab ); | 111 | // qDebug("tab changed %d", whichTab ); |
112 | 112 | ||
113 | QString path = CurrentDir()->canonicalPath(); | 113 | QString path = CurrentDir()->canonicalPath(); |
114 | currentPathCombo->lineEdit()->setText( path ); | 114 | currentPathCombo->lineEdit()->setText( path ); |
115 | 115 | ||
116 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 116 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
117 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 117 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
118 | 118 | ||
119 | QString fs= getFileSystemType( (const QString &) path); | 119 | QString fs= getFileSystemType( (const QString &) path); |
120 | 120 | ||
121 | setCaption("AdvancedFm :: "+fs+" :: " | 121 | setCaption("AdvancedFm :: "+fs+" :: " |
122 | +checkDiskSpace( (const QString &) path )+ " kB free" ); | 122 | +checkDiskSpace( (const QString &) path )+ " kB free" ); |
123 | chdir( path.latin1()); | 123 | chdir( path.latin1()); |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | void AdvancedFm::populateView() | 127 | void AdvancedFm::populateView() |
128 | { | 128 | { |
129 | QPixmap pm; | 129 | QPixmap pm; |
130 | QListView *thisView = CurrentView(); | 130 | QListView *thisView = CurrentView(); |
131 | QDir *thisDir = CurrentDir(); | 131 | QDir *thisDir = CurrentDir(); |
132 | QString path = thisDir->canonicalPath(); | 132 | QString path = thisDir->canonicalPath(); |
133 | 133 | ||
134 | thisView->clear(); | 134 | thisView->clear(); |
135 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 135 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
136 | thisDir->setMatchAllDirs(TRUE); | 136 | thisDir->setMatchAllDirs(TRUE); |
137 | thisDir->setNameFilter(filterStr); | 137 | thisDir->setNameFilter(filterStr); |
138 | QString fileL, fileS, fileDate; | 138 | QString fileL, fileS, fileDate; |
139 | QString fs= getFileSystemType((const QString &) path); | 139 | QString fs= getFileSystemType((const QString &) path); |
140 | setCaption("AdvancedFm :: "+fs+" :: " | 140 | setCaption("AdvancedFm :: "+fs+" :: " |
141 | +checkDiskSpace((const QString &) path)+" kB free" ); | 141 | +checkDiskSpace((const QString &) path)+" kB free" ); |
142 | bool isDir=FALSE; | 142 | bool isDir=FALSE; |
143 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 143 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
144 | QFileInfoListIterator it(*list); | 144 | QFileInfoListIterator it(*list); |
145 | QFileInfo *fi; | 145 | QFileInfo *fi; |
146 | while ( (fi=it.current()) ) | 146 | while ( (fi=it.current()) ) |
147 | { | 147 | { |
148 | if (fi->isSymLink() ) | 148 | if (fi->isSymLink() ) |
149 | { | 149 | { |
150 | QString symLink=fi->readLink(); | 150 | QString symLink=fi->readLink(); |
151 | QFileInfo sym( symLink); | 151 | QFileInfo sym( symLink); |
152 | fileS.sprintf( "%10i", sym.size() ); | 152 | fileS.sprintf( "%10i", sym.size() ); |
153 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 153 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
154 | fileDate = sym.lastModified().toString(); | 154 | fileDate = sym.lastModified().toString(); |
155 | } | 155 | } |
156 | else | 156 | else |
157 | { | 157 | { |
158 | fileS.sprintf( "%10i", fi->size() ); | 158 | fileS.sprintf( "%10i", fi->size() ); |
159 | fileL.sprintf( "%s",fi->fileName().data() ); | 159 | fileL.sprintf( "%s",fi->fileName().data() ); |
160 | fileDate= fi->lastModified().toString(); | 160 | fileDate= fi->lastModified().toString(); |
161 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) | 161 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) |
162 | { | 162 | { |
163 | fileL+="/"; | 163 | fileL+="/"; |
164 | isDir=TRUE; | 164 | isDir=TRUE; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | QFileInfo fileInfo( path + "/" + fileL); | 168 | QFileInfo fileInfo( path + "/" + fileL); |
169 | 169 | ||
170 | if(fileL !="./" && fi->exists()) | 170 | if(fileL !="./" && fi->exists()) |
171 | { | 171 | { |
172 | item= new QListViewItem( thisView, fileL, fileS , fileDate); | 172 | item= new QListViewItem( thisView, fileL, fileS , fileDate); |
173 | 173 | ||
174 | if(isDir || fileL.find("/",0,TRUE) != -1) | 174 | if(isDir || fileL.find("/",0,TRUE) != -1) |
175 | { | 175 | { |
176 | 176 | ||
177 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 177 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
178 | pm = Resource::loadPixmap( "lockedfolder" ); | 178 | pm = Resource::loadPixmap( "lockedfolder" ); |
179 | else | 179 | else |
180 | pm= Resource::loadPixmap( "folder" ); | 180 | pm= Resource::loadPixmap( "folder" ); |
181 | } | 181 | } |
182 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) | 182 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) |
183 | { | 183 | { |
184 | pm = Resource::loadPixmap( "exec"); | 184 | pm = Resource::loadPixmap( "exec"); |
185 | } | 185 | } |
186 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 186 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
187 | | fileInfo.permission( QFileInfo::ExeGroup) | 187 | | fileInfo.permission( QFileInfo::ExeGroup) |
188 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) | 188 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) |
189 | { | 189 | { |
190 | pm = Resource::loadPixmap( "exec"); | 190 | pm = Resource::loadPixmap( "exec"); |
191 | } | 191 | } |
192 | else if( !fi->isReadable() ) | 192 | else if( !fi->isReadable() ) |
193 | { | 193 | { |
194 | pm = Resource::loadPixmap( "locked" ); | 194 | pm = Resource::loadPixmap( "locked" ); |
195 | } | 195 | } |
196 | else { //everything else goes by mimetype | 196 | else { //everything else goes by mimetype |
197 | MimeType mt(fi->filePath()); | 197 | MimeType mt(fi->filePath()); |
198 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 198 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
199 | if(pm.isNull()) { | 199 | if(pm.isNull()) { |
200 | pm = unknownXpm; | 200 | pm = unknownXpm; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) | 203 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) |
204 | { | 204 | { |
205 | // overlay link image | 205 | // overlay link image |
206 | pm= Resource::loadPixmap( "folder" ); | 206 | pm= Resource::loadPixmap( "folder" ); |
207 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 207 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
208 | QPainter painter( &pm ); | 208 | QPainter painter( &pm ); |
209 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 209 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
210 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 210 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
211 | } | 211 | } |
212 | item->setPixmap( 0,pm); | 212 | item->setPixmap( 0,pm); |
213 | 213 | ||
214 | } | 214 | } |
215 | isDir=FALSE; | 215 | isDir=FALSE; |
216 | ++it; | 216 | ++it; |
217 | } | 217 | } |
218 | 218 | ||
219 | if( path.find("dev",0,TRUE) != -1) | 219 | if( path.find("dev",0,TRUE) != -1) |
220 | { | 220 | { |
221 | struct stat buf; | 221 | struct stat buf; |
222 | dev_t devT; | 222 | dev_t devT; |
223 | DIR *dir; | 223 | DIR *dir; |
224 | struct dirent *mydirent; | 224 | struct dirent *mydirent; |
225 | 225 | ||
226 | if((dir = opendir( path.latin1())) != NULL) | 226 | if((dir = opendir( path.latin1())) != NULL) |
227 | while ((mydirent = readdir(dir)) != NULL) | 227 | while ((mydirent = readdir(dir)) != NULL) |
228 | { | 228 | { |
229 | lstat( mydirent->d_name, &buf); | 229 | lstat( mydirent->d_name, &buf); |
230 | // qDebug(mydirent->d_name); | 230 | // qDebug(mydirent->d_name); |
231 | fileL.sprintf("%s", mydirent->d_name); | 231 | fileL.sprintf("%s", mydirent->d_name); |
232 | devT = buf.st_dev; | 232 | devT = buf.st_dev; |
233 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 233 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
234 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 234 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
235 | if( fileL.find(".") == -1 ) | 235 | if( fileL.find(".") == -1 ) |
236 | { | 236 | { |
237 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 237 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
238 | pm = unknownXpm; | 238 | pm = unknownXpm; |
239 | item->setPixmap( 0,pm); | 239 | item->setPixmap( 0,pm); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | closedir(dir); | 243 | closedir(dir); |
244 | } | 244 | } |
245 | 245 | ||
246 | thisView->setSorting( 3,FALSE); | 246 | thisView->setSorting( 3,FALSE); |
247 | fillCombo( (const QString &) path ); | 247 | fillCombo( (const QString &) path ); |
248 | } | 248 | } |
249 | 249 | ||
250 | void AdvancedFm::rePopulate() | 250 | void AdvancedFm::rePopulate() |
251 | { | 251 | { |
252 | int tmpTab = whichTab; | 252 | int tmpTab = whichTab; |
253 | qDebug("%d", tmpTab); | 253 | qDebug("%d", tmpTab); |
254 | 254 | ||
255 | for(int i =1; i < 3; i++) | 255 | for(int i =1; i < 3; i++) |
256 | { | 256 | { |
257 | TabWidget->setCurrentTab(i - 1); | 257 | TabWidget->setCurrentTab(i - 1); |
258 | populateView(); | 258 | populateView(); |
259 | } | 259 | } |
260 | TabWidget->setCurrentTab( tmpTab - 1); | 260 | TabWidget->setCurrentTab( tmpTab - 1); |
261 | } | 261 | } |
262 | 262 | ||
263 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) | 263 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) |
264 | { | 264 | { |
265 | if(selectedItem) | 265 | if(selectedItem) |
266 | { | 266 | { |
267 | QString strItem=selectedItem->text(0); | 267 | QString strItem=selectedItem->text(0); |
268 | QString strSize=selectedItem->text(1); | 268 | QString strSize=selectedItem->text(1); |
269 | strSize=strSize.stripWhiteSpace(); | 269 | strSize=strSize.stripWhiteSpace(); |
270 | bool isDirectory = false; | 270 | bool isDirectory = false; |
271 | QString strItem2; | 271 | QString strItem2; |
272 | 272 | ||
273 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink | 273 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink |
274 | { | 274 | { |
275 | strItem2 = dealWithSymName((const QString&)strItem); | 275 | strItem2 = dealWithSymName((const QString&)strItem); |
276 | if(QDir(strItem2).exists() ) | 276 | if(QDir(strItem2).exists() ) |
277 | strItem = strItem2; | 277 | strItem = strItem2; |
278 | } | 278 | } |
279 | 279 | ||
280 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) | 280 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) |
281 | { | 281 | { |
282 | 282 | ||
283 | if(QDir(strItem).exists()) | 283 | if(QDir(strItem).exists()) |
284 | isDirectory = true; | 284 | isDirectory = true; |
285 | } | 285 | } |
286 | 286 | ||
287 | if( isDirectory ) | 287 | if( isDirectory ) |
288 | { | 288 | { |
289 | CurrentDir()->cd( strItem, TRUE); | 289 | CurrentDir()->cd( strItem, TRUE); |
290 | populateView(); | 290 | populateView(); |
291 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 291 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
292 | } | 292 | } |
293 | chdir( strItem.latin1()); | 293 | chdir( strItem.latin1()); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 297 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
298 | switch (mouse) { | 298 | switch (mouse) { |
299 | case 1: | 299 | case 1: |
300 | { | 300 | { |
301 | if(renameBox != 0 ) | 301 | if(renameBox != 0 ) |
302 | { | 302 | { |
303 | cancelRename(); | 303 | cancelRename(); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | break; | 306 | break; |
307 | case 2: | 307 | case 2: |
308 | menuTimer.start( 500, TRUE ); | 308 | menuTimer.start( 500, TRUE ); |
309 | break; | 309 | break; |
310 | }; | 310 | }; |
311 | } | 311 | } |
312 | 312 | ||
313 | void AdvancedFm::switchToLocalTab() | 313 | void AdvancedFm::switchToLocalTab() |
314 | { | 314 | { |
315 | TabWidget->setCurrentTab(0); | 315 | TabWidget->setCurrentTab(0); |
316 | Local_View->setFocus(); | 316 | Local_View->setFocus(); |
317 | } | 317 | } |
318 | 318 | ||
319 | void AdvancedFm::switchToRemoteTab() | 319 | void AdvancedFm::switchToRemoteTab() |
320 | { | 320 | { |
321 | TabWidget->setCurrentTab(1); | 321 | TabWidget->setCurrentTab(1); |
322 | Remote_View->setFocus(); | 322 | Remote_View->setFocus(); |
323 | } | 323 | } |
324 | 324 | ||
325 | void AdvancedFm::readConfig() | 325 | void AdvancedFm::readConfig() |
326 | { | 326 | { |
327 | Config cfg("AdvancedFm"); | 327 | Config cfg("AdvancedFm"); |
328 | } | 328 | } |
329 | 329 | ||
330 | void AdvancedFm::writeConfig() | 330 | void AdvancedFm::writeConfig() |
331 | { | 331 | { |
332 | Config cfg("AdvancedFm"); | 332 | Config cfg("AdvancedFm"); |
333 | } | 333 | } |
334 | 334 | ||
335 | void AdvancedFm::currentPathComboChanged() | 335 | void AdvancedFm::currentPathComboChanged() |
336 | { | 336 | { |
337 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) | 337 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) |
338 | { | 338 | { |
339 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 339 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
340 | populateView(); | 340 | populateView(); |
341 | } | 341 | } |
342 | else | 342 | else |
343 | { | 343 | { |
344 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 344 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | void AdvancedFm::fillCombo(const QString ¤tPath) | 348 | void AdvancedFm::fillCombo(const QString ¤tPath) |
349 | { | 349 | { |
350 | // qDebug("%d",TabWidget->getCurrentTab()); | 350 | // qDebug("%d",TabWidget->currentTab()); |
351 | if ( whichTab == 1) | 351 | if ( whichTab == 1) |
352 | { | 352 | { |
353 | currentPathCombo->lineEdit()->setText( currentPath); | 353 | currentPathCombo->lineEdit()->setText( currentPath); |
354 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 354 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) |
355 | { | 355 | { |
356 | currentPathCombo->clear(); | 356 | currentPathCombo->clear(); |
357 | localDirPathStringList.prepend( currentPath ); | 357 | localDirPathStringList.prepend( currentPath ); |
358 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 358 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | else | 361 | else |
362 | { | 362 | { |
363 | currentPathCombo->lineEdit()->setText( currentPath); | 363 | currentPathCombo->lineEdit()->setText( currentPath); |
364 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 364 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) |
365 | { | 365 | { |
366 | currentPathCombo->clear(); | 366 | currentPathCombo->clear(); |
367 | remoteDirPathStringList.prepend( currentPath ); | 367 | remoteDirPathStringList.prepend( currentPath ); |
368 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 368 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
369 | } | 369 | } |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) | 373 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) |
374 | { | 374 | { |
375 | chdir( currentPath.latin1() ); | 375 | chdir( currentPath.latin1() ); |
376 | CurrentDir()->cd( currentPath, TRUE); | 376 | CurrentDir()->cd( currentPath, TRUE); |
377 | populateView(); | 377 | populateView(); |
378 | update(); | 378 | update(); |
379 | } | 379 | } |
380 | 380 | ||
381 | QStringList AdvancedFm::getPath() | 381 | QStringList AdvancedFm::getPath() |
382 | { | 382 | { |
383 | QStringList strList; | 383 | QStringList strList; |
384 | QListView *thisView=CurrentView(); | 384 | QListView *thisView=CurrentView(); |
385 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 385 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
386 | QListViewItemIterator it( thisView ); | 386 | QListViewItemIterator it( thisView ); |
387 | for ( ; it.current(); ++it ) | 387 | for ( ; it.current(); ++it ) |
388 | { | 388 | { |
389 | if ( it.current()->isSelected() ) | 389 | if ( it.current()->isSelected() ) |
390 | { | 390 | { |
391 | strList << it.current()->text(0); | 391 | strList << it.current()->text(0); |
392 | // qDebug(it.current()->text(0)); | 392 | // qDebug(it.current()->text(0)); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | return strList; | 395 | return strList; |
396 | } | 396 | } |
397 | 397 | ||
398 | void AdvancedFm::homeButtonPushed() | 398 | void AdvancedFm::homeButtonPushed() |
399 | { | 399 | { |
400 | QString current = QDir::homeDirPath(); | 400 | QString current = QDir::homeDirPath(); |
401 | chdir( current.latin1() ); | 401 | chdir( current.latin1() ); |
402 | CurrentDir()->cd( current, TRUE); | 402 | CurrentDir()->cd( current, TRUE); |
403 | populateView(); | 403 | populateView(); |
404 | update(); | 404 | update(); |
405 | } | 405 | } |
406 | 406 | ||
407 | void AdvancedFm::docButtonPushed() | 407 | void AdvancedFm::docButtonPushed() |
408 | { | 408 | { |
409 | QString current = QPEApplication::documentDir(); | 409 | QString current = QPEApplication::documentDir(); |
410 | chdir( current.latin1() ); | 410 | chdir( current.latin1() ); |
411 | CurrentDir()->cd( current, TRUE); | 411 | CurrentDir()->cd( current, TRUE); |
412 | populateView(); | 412 | populateView(); |
413 | update(); | 413 | update(); |
414 | } | 414 | } |
415 | 415 | ||
416 | void AdvancedFm::SDButtonPushed() | 416 | void AdvancedFm::SDButtonPushed() |
417 | { | 417 | { |
418 | QString current = "/mnt/card";// this can change so fix | 418 | QString current = "/mnt/card";// this can change so fix |
419 | chdir( current.latin1() ); | 419 | chdir( current.latin1() ); |
420 | CurrentDir()->cd( current, TRUE); | 420 | CurrentDir()->cd( current, TRUE); |
421 | populateView(); | 421 | populateView(); |
422 | update(); | 422 | update(); |
423 | } | 423 | } |
424 | 424 | ||
425 | void AdvancedFm::CFButtonPushed() | 425 | void AdvancedFm::CFButtonPushed() |
426 | { | 426 | { |
427 | QString current; | 427 | QString current; |
428 | if(zaurusDevice) | 428 | if(zaurusDevice) |
429 | current= "/mnt/cf"; //zaurus | 429 | current= "/mnt/cf"; //zaurus |
430 | else | 430 | else |
431 | current = "/mnt/hda"; //ipaq | 431 | current = "/mnt/hda"; //ipaq |
432 | chdir( current.latin1() ); | 432 | chdir( current.latin1() ); |
433 | CurrentDir()->cd( current, TRUE); | 433 | CurrentDir()->cd( current, TRUE); |
434 | populateView(); | 434 | populateView(); |
435 | update(); | 435 | update(); |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | void AdvancedFm::doAbout() | 439 | void AdvancedFm::doAbout() |
440 | { | 440 | { |
441 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 441 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
442 | "is copyright 2002-2003 by\n" | 442 | "is copyright 2002-2003 by\n" |
443 | "L.J.Potter<llornkcor@handhelds.org>\n" | 443 | "L.J.Potter<llornkcor@handhelds.org>\n" |
444 | "and is licensed by the GPL")); | 444 | "and is licensed by the GPL")); |
445 | } | 445 | } |
446 | 446 | ||
447 | void AdvancedFm::keyPressEvent( QKeyEvent *e) | 447 | void AdvancedFm::keyPressEvent( QKeyEvent *e) |
448 | { | 448 | { |
449 | // e->accept(); | 449 | // e->accept(); |
450 | if( CurrentView()->hasFocus() ) | 450 | if( CurrentView()->hasFocus() ) |
451 | { | 451 | { |
452 | switch ( e->key() ) { | 452 | switch ( e->key() ) { |
453 | case Key_Delete: | 453 | case Key_Delete: |
454 | del(); | 454 | del(); |
455 | break; | 455 | break; |
456 | case Key_A: | 456 | case Key_A: |
457 | copyAs(); | 457 | copyAs(); |
458 | break; | 458 | break; |
459 | case Key_C: | 459 | case Key_C: |
460 | copy(); | 460 | copy(); |
461 | break; | 461 | break; |
462 | case Key_E: | 462 | case Key_E: |
463 | runThis(); | 463 | runThis(); |
464 | break; | 464 | break; |
465 | case Key_G: | 465 | case Key_G: |
466 | { | 466 | { |
467 | currentPathCombo->lineEdit()->setFocus(); | 467 | currentPathCombo->lineEdit()->setFocus(); |
468 | } | 468 | } |
469 | break; | 469 | break; |
470 | 470 | ||
471 | case Key_H: | 471 | case Key_H: |
472 | showHidden(); | 472 | showHidden(); |
473 | break; | 473 | break; |
474 | case Key_I: | 474 | case Key_I: |
475 | fileStatus(); | 475 | fileStatus(); |
476 | break; | 476 | break; |
477 | case Key_M: | 477 | case Key_M: |
478 | move(); | 478 | move(); |
479 | break; | 479 | break; |
480 | case Key_N: | 480 | case Key_N: |
481 | mkDir(); | 481 | mkDir(); |
482 | break; | 482 | break; |
483 | case Key_P: | 483 | case Key_P: |
484 | filePerms(); | 484 | filePerms(); |
485 | break; | 485 | break; |
486 | case Key_R: | 486 | case Key_R: |
487 | rn(); | 487 | rn(); |
488 | break; | 488 | break; |
489 | case Key_U: | 489 | case Key_U: |
490 | upDir(); | 490 | upDir(); |
491 | break; | 491 | break; |
492 | case Key_1: | 492 | case Key_1: |
493 | switchToLocalTab(); | 493 | switchToLocalTab(); |
494 | break; | 494 | break; |
495 | case Key_2: | 495 | case Key_2: |
496 | switchToRemoteTab(); | 496 | switchToRemoteTab(); |
497 | break; | 497 | break; |
498 | case Key_3: | 498 | case Key_3: |
499 | CFButtonPushed(); | 499 | CFButtonPushed(); |
500 | break; | 500 | break; |
501 | case Key_4: | 501 | case Key_4: |
502 | SDButtonPushed(); | 502 | SDButtonPushed(); |
503 | break; | 503 | break; |
504 | case Key_5: | 504 | case Key_5: |
505 | homeButtonPushed(); | 505 | homeButtonPushed(); |
506 | break; | 506 | break; |
507 | case Key_6: | 507 | case Key_6: |
508 | docButtonPushed(); | 508 | docButtonPushed(); |
509 | break; | 509 | break; |
510 | case Key_7: | 510 | case Key_7: |
511 | break; | 511 | break; |
512 | case Key_8: | 512 | case Key_8: |
513 | break; | 513 | break; |
514 | case Key_9: | 514 | case Key_9: |
515 | break; | 515 | break; |
516 | case Key_0: | 516 | case Key_0: |
517 | break; | 517 | break; |
518 | }; | 518 | }; |
519 | e->accept(); | 519 | e->accept(); |
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 523 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
524 | { | 524 | { |
525 | if( CurrentView()->hasFocus() ) | 525 | if( CurrentView()->hasFocus() ) |
526 | e->ignore(); | 526 | e->ignore(); |
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | void AdvancedFm::QPEButtonPushed() | 530 | void AdvancedFm::QPEButtonPushed() |
531 | { | 531 | { |
532 | QString current = QPEApplication::qpeDir(); | 532 | QString current = QPEApplication::qpeDir(); |
533 | chdir( current.latin1() ); | 533 | chdir( current.latin1() ); |
534 | CurrentDir()->cd( current, TRUE); | 534 | CurrentDir()->cd( current, TRUE); |
535 | populateView(); | 535 | populateView(); |
536 | update(); | 536 | update(); |
537 | } | 537 | } |
538 | 538 | ||
539 | void AdvancedFm::parsetab(const QString &fileName) | 539 | void AdvancedFm::parsetab(const QString &fileName) |
540 | { | 540 | { |
541 | 541 | ||
542 | fileSystemTypeList.clear(); | 542 | fileSystemTypeList.clear(); |
543 | fsList.clear(); | 543 | fsList.clear(); |
544 | struct mntent *me; | 544 | struct mntent *me; |
545 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 545 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
546 | if ( mntfp ) | 546 | if ( mntfp ) |
547 | { | 547 | { |
548 | while ( (me = getmntent( mntfp )) != 0 ) | 548 | while ( (me = getmntent( mntfp )) != 0 ) |
549 | { | 549 | { |
550 | QString deviceName = me->mnt_fsname; | 550 | QString deviceName = me->mnt_fsname; |
551 | QString filesystemType = me->mnt_type; | 551 | QString filesystemType = me->mnt_type; |
552 | QString mountDir = me->mnt_dir; | 552 | QString mountDir = me->mnt_dir; |
553 | if(deviceName != "none") | 553 | if(deviceName != "none") |
554 | { | 554 | { |
555 | if( fsList.contains(filesystemType) == 0 | 555 | if( fsList.contains(filesystemType) == 0 |
556 | & filesystemType.find("proc",0,TRUE) == -1 | 556 | & filesystemType.find("proc",0,TRUE) == -1 |
557 | & filesystemType.find("cramfs",0,TRUE) == -1 | 557 | & filesystemType.find("cramfs",0,TRUE) == -1 |
558 | & filesystemType.find("auto",0,TRUE) == -1) | 558 | & filesystemType.find("auto",0,TRUE) == -1) |
559 | fsList << filesystemType; | 559 | fsList << filesystemType; |
560 | fileSystemTypeList << mountDir+"::"+filesystemType; | 560 | fileSystemTypeList << mountDir+"::"+filesystemType; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | } | 563 | } |
564 | endmntent( mntfp ); | 564 | endmntent( mntfp ); |
565 | } | 565 | } |
566 | 566 | ||
567 | QString AdvancedFm::getFileSystemType(const QString ¤tText) | 567 | QString AdvancedFm::getFileSystemType(const QString ¤tText) |
568 | { | 568 | { |
569 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 569 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
570 | QString current = currentText;//.right( currentText.length()-1); | 570 | QString current = currentText;//.right( currentText.length()-1); |
571 | QString baseFs; | 571 | QString baseFs; |
572 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 572 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
573 | QString temp = (*it); | 573 | QString temp = (*it); |
574 | QString path = temp.left(temp.find("::",0,TRUE) ); | 574 | QString path = temp.left(temp.find("::",0,TRUE) ); |
575 | path = path.right( path.length()-1); | 575 | path = path.right( path.length()-1); |
576 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 576 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
577 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 577 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
578 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 578 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
579 | } | 579 | } |
580 | } | 580 | } |
581 | return baseFs; | 581 | return baseFs; |
582 | } | 582 | } |
583 | 583 | ||
584 | QString AdvancedFm::getDiskSpace( const QString &path) | 584 | QString AdvancedFm::getDiskSpace( const QString &path) |
585 | { | 585 | { |
586 | struct statfs fss; | 586 | struct statfs fss; |
587 | if ( !statfs( path.latin1(), &fss ) ) { | 587 | if ( !statfs( path.latin1(), &fss ) ) { |
588 | int blkSize = fss.f_bsize; | 588 | int blkSize = fss.f_bsize; |
589 | // int totalBlks = fs.f_blocks; | 589 | // int totalBlks = fs.f_blocks; |
590 | int availBlks = fss.f_bavail; | 590 | int availBlks = fss.f_bavail; |
591 | 591 | ||
592 | long mult = blkSize / 1024; | 592 | long mult = blkSize / 1024; |
593 | long div = 1024 / blkSize; | 593 | long div = 1024 / blkSize; |
594 | if ( !mult ) mult = 1; | 594 | if ( !mult ) mult = 1; |
595 | if ( !div ) div = 1; | 595 | if ( !div ) div = 1; |
596 | 596 | ||
597 | return QString::number(availBlks * mult / div); | 597 | return QString::number(availBlks * mult / div); |
598 | } | 598 | } |
599 | return ""; | 599 | return ""; |
600 | } | 600 | } |
601 | 601 | ||
602 | 602 | ||
603 | void AdvancedFm::showFileMenu() | 603 | void AdvancedFm::showFileMenu() |
604 | { | 604 | { |
605 | QString curApp; | 605 | QString curApp; |
606 | curApp = CurrentView()->currentItem()->text(0); | 606 | curApp = CurrentView()->currentItem()->text(0); |
607 | 607 | ||
608 | MimeType mt( curApp ); | 608 | MimeType mt( curApp ); |
609 | const AppLnk* app = mt.application(); | 609 | const AppLnk* app = mt.application(); |
610 | QFile fi(curApp); | 610 | QFile fi(curApp); |
611 | QPopupMenu *m = new QPopupMenu(0); | 611 | QPopupMenu *m = new QPopupMenu(0); |
612 | QPopupMenu *n = new QPopupMenu(0); | 612 | QPopupMenu *n = new QPopupMenu(0); |
613 | // QPopupMenu *o = new QPopupMenu(0); | 613 | // QPopupMenu *o = new QPopupMenu(0); |
614 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 614 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
615 | 615 | ||
616 | if ( QFileInfo(fi).isDir() ) | 616 | if ( QFileInfo(fi).isDir() ) |
617 | { | 617 | { |
618 | m->insertSeparator(); | 618 | m->insertSeparator(); |
619 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); | 619 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); |
620 | } | 620 | } |
621 | else | 621 | else |
622 | { | 622 | { |
623 | 623 | ||
624 | if ( app ) | 624 | if ( app ) |
625 | m->insertItem( app->pixmap(), tr( "Open in " | 625 | m->insertItem( app->pixmap(), tr( "Open in " |
626 | + app->name() ), this, SLOT( runThis() ) ); | 626 | + app->name() ), this, SLOT( runThis() ) ); |
627 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 627 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
628 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 628 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
629 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 629 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
630 | } | 630 | } |
631 | 631 | ||
632 | m->insertItem(tr("Actions"),n); | 632 | m->insertItem(tr("Actions"),n); |
633 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); | 633 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); |
634 | 634 | ||
635 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 635 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
636 | 636 | ||
637 | n->insertSeparator(); | 637 | n->insertSeparator(); |
638 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); | 638 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); |
639 | 639 | ||
640 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 640 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
641 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 641 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
642 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 642 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
643 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 643 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
644 | 644 | ||
645 | n->insertSeparator(); | 645 | n->insertSeparator(); |
646 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); | 646 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); |
647 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 647 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
648 | 648 | ||
649 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 649 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
650 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 650 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
651 | 651 | ||
652 | m->insertSeparator(); | 652 | m->insertSeparator(); |
653 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 653 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
654 | 654 | ||
655 | #if defined(QT_QWS_OPIE) | 655 | #if defined(QT_QWS_OPIE) |
656 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 656 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
657 | #endif | 657 | #endif |
658 | m->setCheckable(TRUE); | 658 | m->setCheckable(TRUE); |
659 | if (!b) | 659 | if (!b) |
660 | m->setItemChecked(m->idAt(0),TRUE); | 660 | m->setItemChecked(m->idAt(0),TRUE); |
661 | else | 661 | else |
662 | m->setItemChecked(m->idAt(0),FALSE); | 662 | m->setItemChecked(m->idAt(0),FALSE); |
663 | 663 | ||
664 | if(Ir::supported()) | 664 | if(Ir::supported()) |
665 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 665 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
666 | m->setFocus(); | 666 | m->setFocus(); |
667 | m->exec( QPoint( 4,QCursor::pos().y()) ); | 667 | m->exec( QPoint( 4,QCursor::pos().y()) ); |
668 | 668 | ||
669 | if(m) delete m; | 669 | if(m) delete m; |
670 | } | 670 | } |
671 | 671 | ||
672 | 672 | ||
673 | void AdvancedFm::cancelMenuTimer() | 673 | void AdvancedFm::cancelMenuTimer() |
674 | { | 674 | { |
675 | // qDebug("selectionChanged: cancel menu timer"); | 675 | // qDebug("selectionChanged: cancel menu timer"); |
676 | if( menuTimer.isActive() ) | 676 | if( menuTimer.isActive() ) |
677 | menuTimer.stop(); | 677 | menuTimer.stop(); |
678 | } | 678 | } |
679 | 679 | ||
680 | QString AdvancedFm::checkDiskSpace(const QString &path) | 680 | QString AdvancedFm::checkDiskSpace(const QString &path) |
681 | { | 681 | { |
682 | struct statfs fss; | 682 | struct statfs fss; |
683 | if ( !statfs( path.latin1(), &fss ) ) | 683 | if ( !statfs( path.latin1(), &fss ) ) |
684 | { | 684 | { |
685 | int blkSize = fss.f_bsize; | 685 | int blkSize = fss.f_bsize; |
686 | // int totalBlks = fs.f_blocks; | 686 | // int totalBlks = fs.f_blocks; |
687 | int availBlks = fss.f_bavail; | 687 | int availBlks = fss.f_bavail; |
688 | 688 | ||
689 | long mult = blkSize / 1024; | 689 | long mult = blkSize / 1024; |
690 | long div = 1024 / blkSize; | 690 | long div = 1024 / blkSize; |
691 | if ( !mult ) mult = 1; | 691 | if ( !mult ) mult = 1; |
692 | if ( !div ) div = 1; | 692 | if ( !div ) div = 1; |
693 | 693 | ||
694 | 694 | ||
695 | return QString::number(availBlks * mult / div); | 695 | return QString::number(availBlks * mult / div); |
696 | } | 696 | } |
697 | return ""; | 697 | return ""; |
698 | } | 698 | } |
699 | 699 | ||
700 | void AdvancedFm::addToDocs() | 700 | void AdvancedFm::addToDocs() |
701 | { | 701 | { |
702 | QStringList strListPaths = getPath(); | 702 | QStringList strListPaths = getPath(); |
703 | QDir *thisDir = CurrentDir(); | 703 | QDir *thisDir = CurrentDir(); |
704 | 704 | ||
705 | if( strListPaths.count() > 0) | 705 | if( strListPaths.count() > 0) |
706 | { | 706 | { |
707 | QString curFile; | 707 | QString curFile; |
708 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) | 708 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) |
709 | { | 709 | { |
710 | curFile = thisDir->canonicalPath()+"/"+(*it); | 710 | curFile = thisDir->canonicalPath()+"/"+(*it); |
711 | // qDebug(curFile); | 711 | // qDebug(curFile); |
712 | DocLnk f; | 712 | DocLnk f; |
713 | // curFile.replace(QRegExp("\\..*"),""); | 713 | // curFile.replace(QRegExp("\\..*"),""); |
714 | f.setName((*it)); | 714 | f.setName((*it)); |
715 | f.setFile( curFile); | 715 | f.setFile( curFile); |
716 | f.writeLink(); | 716 | f.writeLink(); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | } | 719 | } |
720 | 720 | ||
721 | 721 | ||
722 | void AdvancedFm::customDirsToMenu() | 722 | void AdvancedFm::customDirsToMenu() |
723 | { | 723 | { |
724 | 724 | ||
725 | Config cfg("AdvancedFm"); | 725 | Config cfg("AdvancedFm"); |
726 | cfg.setGroup("Menu"); | 726 | cfg.setGroup("Menu"); |
727 | 727 | ||
728 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 728 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
729 | menuButton->insertItems(list ); | 729 | menuButton->insertItems(list ); |
730 | 730 | ||
731 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 731 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
732 | // { | 732 | // { |
733 | // customDirMenu->insertItem(*it ); | 733 | // customDirMenu->insertItem(*it ); |
734 | // } | 734 | // } |
735 | } | 735 | } |
736 | 736 | ||
737 | void AdvancedFm::dirMenuSelected(int item) | 737 | void AdvancedFm::dirMenuSelected(int item) |
738 | { | 738 | { |
739 | qDebug("menu item %d", item); | 739 | qDebug("menu item %d", item); |
740 | switch(item) | 740 | switch(item) |
741 | { | 741 | { |
742 | 742 | ||
743 | case -21: | 743 | case -21: |
744 | case 0: | 744 | case 0: |
745 | addCustomDir(); | 745 | addCustomDir(); |
746 | break; | 746 | break; |
747 | case -22: | 747 | case -22: |
748 | case 1: | 748 | case 1: |
749 | removeCustomDir(); | 749 | removeCustomDir(); |
750 | break; | 750 | break; |
751 | default: | 751 | default: |
752 | { | 752 | { |
753 | // gotoCustomDir( menuButton->text(item)); | 753 | // gotoCustomDir( menuButton->text(item)); |
754 | // gotoCustomDir( customDirMenu->text(item)); | 754 | // gotoCustomDir( customDirMenu->text(item)); |
755 | } | 755 | } |
756 | break; | 756 | break; |
757 | 757 | ||
758 | }; | 758 | }; |
759 | } | 759 | } |
760 | 760 | ||
761 | void AdvancedFm::addCustomDir() | 761 | void AdvancedFm::addCustomDir() |
762 | { | 762 | { |
763 | Config cfg("AdvancedFm"); | 763 | Config cfg("AdvancedFm"); |
764 | cfg.setGroup("Menu"); | 764 | cfg.setGroup("Menu"); |
765 | QString dir; | 765 | QString dir; |
766 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 766 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
767 | 767 | ||
768 | dir = CurrentDir()->canonicalPath(); | 768 | dir = CurrentDir()->canonicalPath(); |
769 | 769 | ||
770 | bool addIt=true; | 770 | bool addIt=true; |
771 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 771 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
772 | { | 772 | { |
773 | if( dir == (*it)) | 773 | if( dir == (*it)) |
774 | { | 774 | { |
775 | addIt=false; | 775 | addIt=false; |
776 | } | 776 | } |
777 | } | 777 | } |
778 | if(addIt) | 778 | if(addIt) |
779 | { | 779 | { |
780 | menuButton->insertItem(dir); | 780 | menuButton->insertItem(dir); |
781 | // customDirMenu->insertItem(dir); | 781 | // customDirMenu->insertItem(dir); |
782 | list << dir; | 782 | list << dir; |
783 | } | 783 | } |
784 | 784 | ||
785 | cfg.writeEntry("CustomDir", list, ','); | 785 | cfg.writeEntry("CustomDir", list, ','); |
786 | cfg.write(); | 786 | cfg.write(); |
787 | } | 787 | } |
788 | 788 | ||
789 | void AdvancedFm::removeCustomDir() | 789 | void AdvancedFm::removeCustomDir() |
790 | { | 790 | { |
791 | // qDebug("remove custom dir"); | 791 | // qDebug("remove custom dir"); |
792 | Config cfg("AdvancedFm"); | 792 | Config cfg("AdvancedFm"); |
793 | cfg.setGroup("Menu"); | 793 | cfg.setGroup("Menu"); |
794 | QString dir; | 794 | QString dir; |
795 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 795 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
796 | QStringList list2; | 796 | QStringList list2; |
797 | dir = CurrentDir()->canonicalPath(); | 797 | dir = CurrentDir()->canonicalPath(); |
798 | int ramble=2; | 798 | int ramble=2; |
799 | // int ramble=-24; | 799 | // int ramble=-24; |
800 | //first remove list | 800 | //first remove list |
801 | if(list.grep(dir,true).isEmpty()) | 801 | if(list.grep(dir,true).isEmpty()) |
802 | { | 802 | { |
803 | QMessageBox::message("AdvancedFm", | 803 | QMessageBox::message("AdvancedFm", |
804 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); | 804 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); |
805 | } | 805 | } |
806 | else | 806 | else |
807 | { | 807 | { |
808 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 808 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
809 | { | 809 | { |
810 | if((*it) != dir)//current item is not our current dir, so add it to temp list | 810 | if((*it) != dir)//current item is not our current dir, so add it to temp list |
811 | { | 811 | { |
812 | list2 <<(*it); | 812 | list2 <<(*it); |
813 | } | 813 | } |
814 | else | 814 | else |
815 | { | 815 | { |
816 | // customDirMenu->removeItem( ramble); | 816 | // customDirMenu->removeItem( ramble); |
817 | menuButton->remove( ramble); | 817 | menuButton->remove( ramble); |
818 | 818 | ||
819 | } | 819 | } |
820 | ramble++; | 820 | ramble++; |
821 | // ramble--; | 821 | // ramble--; |
822 | } | 822 | } |
823 | 823 | ||
824 | cfg.writeEntry("CustomDir", list2, ','); | 824 | cfg.writeEntry("CustomDir", list2, ','); |
825 | cfg.write(); | 825 | cfg.write(); |
826 | } | 826 | } |
827 | // customDirsToMenu(); | 827 | // customDirsToMenu(); |
828 | 828 | ||
829 | } | 829 | } |
830 | 830 | ||
831 | void AdvancedFm::gotoCustomDir(const QString &dir) | 831 | void AdvancedFm::gotoCustomDir(const QString &dir) |
832 | { | 832 | { |
833 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); | 833 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); |
834 | QString curDir = dir; | 834 | QString curDir = dir; |
835 | QDir *thisDir = CurrentDir(); | 835 | QDir *thisDir = CurrentDir(); |
836 | // if( curDir.isEmpty()) { | 836 | // if( curDir.isEmpty()) { |
837 | // } | 837 | // } |
838 | if( curDir == s_addBookmark) | 838 | if( curDir == s_addBookmark) |
839 | { | 839 | { |
840 | addCustomDir(); | 840 | addCustomDir(); |
841 | } | 841 | } |
842 | if( curDir == s_removeBookmark) | 842 | if( curDir == s_removeBookmark) |
843 | { | 843 | { |
844 | removeCustomDir( ); | 844 | removeCustomDir( ); |
845 | } | 845 | } |
846 | else | 846 | else |
847 | { | 847 | { |
848 | if(QDir( curDir).exists() ) | 848 | if(QDir( curDir).exists() ) |
849 | { | 849 | { |
850 | thisDir->setPath( curDir ); | 850 | thisDir->setPath( curDir ); |
851 | chdir( curDir.latin1() ); | 851 | chdir( curDir.latin1() ); |
852 | thisDir->cd( curDir, TRUE); | 852 | thisDir->cd( curDir, TRUE); |
853 | populateView(); | 853 | populateView(); |
854 | } | 854 | } |
855 | } | 855 | } |
856 | } | 856 | } |
857 | 857 | ||
858 | QDir *AdvancedFm::CurrentDir() | 858 | QDir *AdvancedFm::CurrentDir() |
859 | { | 859 | { |
860 | if ( whichTab == 1) | 860 | if ( whichTab == 1) |
861 | { | 861 | { |
862 | return ¤tDir; | 862 | return ¤tDir; |
863 | } | 863 | } |
864 | else | 864 | else |
865 | { | 865 | { |
866 | return ¤tRemoteDir; | 866 | return ¤tRemoteDir; |
867 | } | 867 | } |
868 | } | 868 | } |
869 | 869 | ||
870 | QDir *AdvancedFm::OtherDir() | 870 | QDir *AdvancedFm::OtherDir() |
871 | { | 871 | { |
872 | if ( whichTab == 1) | 872 | if ( whichTab == 1) |
873 | { | 873 | { |
874 | return ¤tRemoteDir; | 874 | return ¤tRemoteDir; |
875 | } | 875 | } |
876 | else | 876 | else |
877 | { | 877 | { |
878 | return ¤tDir; | 878 | return ¤tDir; |
879 | } | 879 | } |
880 | } | 880 | } |
881 | 881 | ||
882 | QListView * AdvancedFm::CurrentView() | 882 | QListView * AdvancedFm::CurrentView() |
883 | { | 883 | { |
884 | if ( whichTab == 1) | 884 | if ( whichTab == 1) |
885 | return Local_View; | 885 | return Local_View; |
886 | else | 886 | else |
887 | return Remote_View; | 887 | return Remote_View; |
888 | } | 888 | } |
889 | 889 | ||
890 | QListView * AdvancedFm::OtherView() | 890 | QListView * AdvancedFm::OtherView() |
891 | { | 891 | { |
892 | if ( whichTab == 1) | 892 | if ( whichTab == 1) |
893 | return Remote_View; | 893 | return Remote_View; |
894 | else | 894 | else |
895 | return Local_View; | 895 | return Local_View; |
896 | } | 896 | } |
897 | 897 | ||
898 | void AdvancedFm::setOtherTabCurrent() | 898 | void AdvancedFm::setOtherTabCurrent() |
899 | { | 899 | { |
900 | if ( whichTab == 1) | 900 | if ( whichTab == 1) |
901 | TabWidget->setCurrentTab(1); | 901 | TabWidget->setCurrentTab(1); |
902 | else | 902 | else |
903 | TabWidget->setCurrentTab(0); | 903 | TabWidget->setCurrentTab(0); |
904 | } | 904 | } |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index eac13f6..93203cd 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,864 +1,864 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/ir.h> | 26 | #include <qpe/ir.h> |
27 | 27 | ||
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qmultilineedit.h> | 29 | #include <qmultilineedit.h> |
30 | 30 | ||
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | 32 | ||
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
46 | #include <dirent.h> | 46 | #include <dirent.h> |
47 | 47 | ||
48 | 48 | ||
49 | void AdvancedFm::doDirChange() | 49 | void AdvancedFm::doDirChange() |
50 | { | 50 | { |
51 | ListClicked( CurrentView()->currentItem()); | 51 | ListClicked( CurrentView()->currentItem()); |
52 | } | 52 | } |
53 | 53 | ||
54 | void AdvancedFm::showMenuHidden() | 54 | void AdvancedFm::showMenuHidden() |
55 | { | 55 | { |
56 | if (b) | 56 | if (b) |
57 | { | 57 | { |
58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
61 | // b=FALSE; | 61 | // b=FALSE; |
62 | 62 | ||
63 | } | 63 | } |
64 | else | 64 | else |
65 | { | 65 | { |
66 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 66 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
69 | // b=TRUE; | 69 | // b=TRUE; |
70 | } | 70 | } |
71 | rePopulate(); | 71 | rePopulate(); |
72 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 72 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
73 | if(b) b = false; else b = true; | 73 | if(b) b = false; else b = true; |
74 | } | 74 | } |
75 | 75 | ||
76 | void AdvancedFm::showHidden() | 76 | void AdvancedFm::showHidden() |
77 | { | 77 | { |
78 | if (b) | 78 | if (b) |
79 | { | 79 | { |
80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
83 | // b=FALSE; | 83 | // b=FALSE; |
84 | 84 | ||
85 | } | 85 | } |
86 | else | 86 | else |
87 | { | 87 | { |
88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
89 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 89 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
90 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 90 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
91 | // b=TRUE; | 91 | // b=TRUE; |
92 | } | 92 | } |
93 | rePopulate(); | 93 | rePopulate(); |
94 | } | 94 | } |
95 | 95 | ||
96 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 96 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
97 | { | 97 | { |
98 | QString strItem = fileName; | 98 | QString strItem = fileName; |
99 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 99 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
100 | } | 100 | } |
101 | 101 | ||
102 | void AdvancedFm::runThis() | 102 | void AdvancedFm::runThis() |
103 | { | 103 | { |
104 | QString fs; | 104 | QString fs; |
105 | QDir *thisDir = CurrentDir(); | 105 | QDir *thisDir = CurrentDir(); |
106 | 106 | ||
107 | QString curFile = CurrentView()->currentItem()->text(0); | 107 | QString curFile = CurrentView()->currentItem()->text(0); |
108 | QString path = thisDir->canonicalPath(); | 108 | QString path = thisDir->canonicalPath(); |
109 | 109 | ||
110 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 110 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
111 | 111 | ||
112 | curFile = dealWithSymName((const QString&)curFile); | 112 | curFile = dealWithSymName((const QString&)curFile); |
113 | 113 | ||
114 | if(curFile != "../") | 114 | if(curFile != "../") |
115 | { | 115 | { |
116 | 116 | ||
117 | fs = getFileSystemType((const QString &) path); | 117 | fs = getFileSystemType((const QString &) path); |
118 | QFileInfo fileInfo( path + "/" + curFile); | 118 | QFileInfo fileInfo( path + "/" + curFile); |
119 | qDebug( fileInfo.owner()); | 119 | qDebug( fileInfo.owner()); |
120 | 120 | ||
121 | if( (fileInfo.permission( QFileInfo::ExeUser) | 121 | if( (fileInfo.permission( QFileInfo::ExeUser) |
122 | | fileInfo.permission( QFileInfo::ExeGroup) | 122 | | fileInfo.permission( QFileInfo::ExeGroup) |
123 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 123 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
124 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 124 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
125 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 125 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
126 | e << curFile; | 126 | e << curFile; |
127 | } | 127 | } |
128 | else | 128 | else |
129 | { | 129 | { |
130 | curFile = path + "/" + curFile; | 130 | curFile = path + "/" + curFile; |
131 | DocLnk nf(curFile); | 131 | DocLnk nf(curFile); |
132 | QString execStr = nf.exec(); | 132 | QString execStr = nf.exec(); |
133 | qDebug( execStr); | 133 | qDebug( execStr); |
134 | if( execStr.isEmpty() ) | 134 | if( execStr.isEmpty() ) |
135 | { | 135 | { |
136 | } | 136 | } |
137 | else | 137 | else |
138 | { | 138 | { |
139 | nf.execute(); | 139 | nf.execute(); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void AdvancedFm::runText() | 145 | void AdvancedFm::runText() |
146 | { | 146 | { |
147 | QString curFile = CurrentView()->currentItem()->text(0); | 147 | QString curFile = CurrentView()->currentItem()->text(0); |
148 | if(curFile != "../") | 148 | if(curFile != "../") |
149 | { | 149 | { |
150 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 150 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
151 | curFile = dealWithSymName((const QString&)curFile); | 151 | curFile = dealWithSymName((const QString&)curFile); |
152 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 152 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
153 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 153 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
154 | e << curFile; | 154 | e << curFile; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void AdvancedFm::makeDir() | 158 | void AdvancedFm::makeDir() |
159 | { | 159 | { |
160 | InputDialog *fileDlg; | 160 | InputDialog *fileDlg; |
161 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 161 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
162 | fileDlg->exec(); | 162 | fileDlg->exec(); |
163 | if( fileDlg->result() == 1 ) | 163 | if( fileDlg->result() == 1 ) |
164 | { | 164 | { |
165 | QDir *thisDir = CurrentDir(); | 165 | QDir *thisDir = CurrentDir(); |
166 | QString filename = fileDlg->LineEdit1->text(); | 166 | QString filename = fileDlg->LineEdit1->text(); |
167 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 167 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
168 | } | 168 | } |
169 | populateView(); | 169 | populateView(); |
170 | } | 170 | } |
171 | 171 | ||
172 | void AdvancedFm::doDelete() | 172 | void AdvancedFm::doDelete() |
173 | { | 173 | { |
174 | 174 | ||
175 | QStringList curFileList = getPath(); | 175 | QStringList curFileList = getPath(); |
176 | bool doMsg=true; | 176 | bool doMsg=true; |
177 | int count = curFileList.count(); | 177 | int count = curFileList.count(); |
178 | if( count > 0) | 178 | if( count > 0) |
179 | { | 179 | { |
180 | if(count > 1 ) | 180 | if(count > 1 ) |
181 | { | 181 | { |
182 | QString msg; | 182 | QString msg; |
183 | msg=tr("Really delete\n%1 files?").arg(count); | 183 | msg=tr("Really delete\n%1 files?").arg(count); |
184 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 184 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
185 | ,tr("Yes"),tr("No"),0,0,1) ) | 185 | ,tr("Yes"),tr("No"),0,0,1) ) |
186 | { | 186 | { |
187 | case 0: | 187 | case 0: |
188 | doMsg=false; | 188 | doMsg=false; |
189 | break; | 189 | break; |
190 | case 1: | 190 | case 1: |
191 | return; | 191 | return; |
192 | break; | 192 | break; |
193 | }; | 193 | }; |
194 | } | 194 | } |
195 | 195 | ||
196 | QString myFile; | 196 | QString myFile; |
197 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 197 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
198 | { | 198 | { |
199 | myFile = (*it); | 199 | myFile = (*it); |
200 | if( myFile.find(" -> ",0,TRUE) != -1) | 200 | if( myFile.find(" -> ",0,TRUE) != -1) |
201 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 201 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
202 | 202 | ||
203 | QString f = CurrentDir()->canonicalPath(); | 203 | QString f = CurrentDir()->canonicalPath(); |
204 | if(f.right(1).find("/",0,TRUE) == -1) | 204 | if(f.right(1).find("/",0,TRUE) == -1) |
205 | f += "/"; | 205 | f += "/"; |
206 | f += myFile; | 206 | f += myFile; |
207 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) | 207 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) |
208 | { | 208 | { |
209 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + | 209 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + |
210 | "\nand all it's contents ?" | 210 | "\nand all it's contents ?" |
211 | ,tr("Yes"),tr("No"),0,0,1) ) | 211 | ,tr("Yes"),tr("No"),0,0,1) ) |
212 | { | 212 | { |
213 | case 0: | 213 | case 0: |
214 | { | 214 | { |
215 | f=f.left(f.length()-1); | 215 | f=f.left(f.length()-1); |
216 | QString cmd="rm -rf "+f; | 216 | QString cmd="rm -rf "+f; |
217 | startProcess( (const QString)cmd.latin1() ); | 217 | startProcess( (const QString)cmd.latin1() ); |
218 | populateView(); | 218 | populateView(); |
219 | } | 219 | } |
220 | break; | 220 | break; |
221 | case 1: | 221 | case 1: |
222 | // exit | 222 | // exit |
223 | break; | 223 | break; |
224 | }; | 224 | }; |
225 | 225 | ||
226 | } else { | 226 | } else { |
227 | if(doMsg) { | 227 | if(doMsg) { |
228 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 228 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
229 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 229 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
230 | case 1: | 230 | case 1: |
231 | return; | 231 | return; |
232 | break; | 232 | break; |
233 | }; | 233 | }; |
234 | } | 234 | } |
235 | QString cmd="rm "+f; | 235 | QString cmd="rm "+f; |
236 | QFile file(f); | 236 | QFile file(f); |
237 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 237 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
238 | file.remove(); | 238 | file.remove(); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | } | 241 | } |
242 | populateView(); | 242 | populateView(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void AdvancedFm::filePerms() | 245 | void AdvancedFm::filePerms() |
246 | { | 246 | { |
247 | QStringList curFileList = getPath(); | 247 | QStringList curFileList = getPath(); |
248 | QString filePath; | 248 | QString filePath; |
249 | 249 | ||
250 | filePath = CurrentDir()->canonicalPath()+"/"; | 250 | filePath = CurrentDir()->canonicalPath()+"/"; |
251 | 251 | ||
252 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 252 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
253 | { | 253 | { |
254 | filePermissions *filePerm; | 254 | filePermissions *filePerm; |
255 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 255 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
256 | filePerm->showMaximized(); | 256 | filePerm->showMaximized(); |
257 | filePerm->exec(); | 257 | filePerm->exec(); |
258 | if( filePerm) | 258 | if( filePerm) |
259 | delete filePerm; | 259 | delete filePerm; |
260 | } | 260 | } |
261 | populateView(); | 261 | populateView(); |
262 | } | 262 | } |
263 | 263 | ||
264 | void AdvancedFm::doProperties() | 264 | void AdvancedFm::doProperties() |
265 | { | 265 | { |
266 | #if defined(QT_QWS_OPIE) | 266 | #if defined(QT_QWS_OPIE) |
267 | 267 | ||
268 | QStringList curFileList = getPath(); | 268 | QStringList curFileList = getPath(); |
269 | 269 | ||
270 | QString filePath; | 270 | QString filePath; |
271 | filePath = CurrentDir()->canonicalPath()+"/"; | 271 | filePath = CurrentDir()->canonicalPath()+"/"; |
272 | 272 | ||
273 | qDebug("%d",curFileList.count()); | 273 | qDebug("%d",curFileList.count()); |
274 | 274 | ||
275 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 275 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
276 | { | 276 | { |
277 | qDebug((filePath+*it)); | 277 | qDebug((filePath+*it)); |
278 | DocLnk lnk( (filePath+*it)); | 278 | DocLnk lnk( (filePath+*it)); |
279 | LnkProperties prop( &lnk ); | 279 | LnkProperties prop( &lnk ); |
280 | prop.showMaximized(); | 280 | prop.showMaximized(); |
281 | prop.exec(); | 281 | prop.exec(); |
282 | } | 282 | } |
283 | #endif | 283 | #endif |
284 | 284 | ||
285 | } | 285 | } |
286 | 286 | ||
287 | void AdvancedFm::upDir() | 287 | void AdvancedFm::upDir() |
288 | { | 288 | { |
289 | QDir *thisDir = CurrentDir(); | 289 | QDir *thisDir = CurrentDir(); |
290 | QString current = thisDir->canonicalPath(); | 290 | QString current = thisDir->canonicalPath(); |
291 | QDir dir(current); | 291 | QDir dir(current); |
292 | dir.cdUp(); | 292 | dir.cdUp(); |
293 | current = dir.canonicalPath(); | 293 | current = dir.canonicalPath(); |
294 | chdir( current.latin1() ); | 294 | chdir( current.latin1() ); |
295 | thisDir->cd( current, TRUE); | 295 | thisDir->cd( current, TRUE); |
296 | 296 | ||
297 | populateView(); | 297 | populateView(); |
298 | update(); | 298 | update(); |
299 | } | 299 | } |
300 | 300 | ||
301 | void AdvancedFm::copy() | 301 | void AdvancedFm::copy() |
302 | { | 302 | { |
303 | qApp->processEvents(); | 303 | qApp->processEvents(); |
304 | QStringList curFileList = getPath(); | 304 | QStringList curFileList = getPath(); |
305 | 305 | ||
306 | QDir *thisDir = CurrentDir(); | 306 | QDir *thisDir = CurrentDir(); |
307 | QDir *thatDir = OtherDir(); | 307 | QDir *thatDir = OtherDir(); |
308 | 308 | ||
309 | bool doMsg=true; | 309 | bool doMsg=true; |
310 | int count=curFileList.count(); | 310 | int count=curFileList.count(); |
311 | if( count > 0) { | 311 | if( count > 0) { |
312 | if(count > 1 ){ | 312 | if(count > 1 ){ |
313 | QString msg; | 313 | QString msg; |
314 | msg=tr("Really copy\n%1 files?").arg(count); | 314 | msg=tr("Really copy\n%1 files?").arg(count); |
315 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 315 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
316 | ,tr("Yes"),tr("No"),0,0,1) ) | 316 | ,tr("Yes"),tr("No"),0,0,1) ) |
317 | { | 317 | { |
318 | case 0: | 318 | case 0: |
319 | doMsg=false; | 319 | doMsg=false; |
320 | break; | 320 | break; |
321 | case 1: | 321 | case 1: |
322 | return; | 322 | return; |
323 | break; | 323 | break; |
324 | }; | 324 | }; |
325 | } | 325 | } |
326 | 326 | ||
327 | QString curFile, item, destFile; | 327 | QString curFile, item, destFile; |
328 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 328 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
329 | { | 329 | { |
330 | item=(*it); | 330 | item=(*it); |
331 | if(item.find("->",0,TRUE)) //symlink | 331 | if(item.find("->",0,TRUE)) //symlink |
332 | item = item.left(item.find("->",0,TRUE)); | 332 | item = item.left(item.find("->",0,TRUE)); |
333 | 333 | ||
334 | curFile = thisDir->canonicalPath()+"/"+ item; | 334 | curFile = thisDir->canonicalPath()+"/"+ item; |
335 | destFile = thatDir->canonicalPath()+"/"+ item; | 335 | destFile = thatDir->canonicalPath()+"/"+ item; |
336 | 336 | ||
337 | qDebug("Destination file is "+destFile); | 337 | qDebug("Destination file is "+destFile); |
338 | qDebug("CurrentFile file is " + curFile); | 338 | qDebug("CurrentFile file is " + curFile); |
339 | 339 | ||
340 | QFile f(destFile); | 340 | QFile f(destFile); |
341 | if( f.exists()) | 341 | if( f.exists()) |
342 | { | 342 | { |
343 | if(doMsg) | 343 | if(doMsg) |
344 | { | 344 | { |
345 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 345 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
346 | tr("%1 exists. Ok to overwrite?").arg( item ), | 346 | tr("%1 exists. Ok to overwrite?").arg( item ), |
347 | tr("Yes"),tr("No"),0,0,1) ) | 347 | tr("Yes"),tr("No"),0,0,1) ) |
348 | { | 348 | { |
349 | case 1: | 349 | case 1: |
350 | return; | 350 | return; |
351 | break; | 351 | break; |
352 | }; | 352 | }; |
353 | } | 353 | } |
354 | f.remove(); | 354 | f.remove(); |
355 | } | 355 | } |
356 | 356 | ||
357 | if( !copyFile( curFile, destFile) ) | 357 | if( !copyFile( curFile, destFile) ) |
358 | { | 358 | { |
359 | QMessageBox::message("AdvancedFm", | 359 | QMessageBox::message("AdvancedFm", |
360 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 360 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
361 | return; | 361 | return; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | setOtherTabCurrent(); | 364 | setOtherTabCurrent(); |
365 | populateView(); | 365 | populateView(); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | void AdvancedFm::copyAs() | 369 | void AdvancedFm::copyAs() |
370 | { | 370 | { |
371 | qApp->processEvents(); | 371 | qApp->processEvents(); |
372 | 372 | ||
373 | QStringList curFileList = getPath(); | 373 | QStringList curFileList = getPath(); |
374 | QString curFile, item; | 374 | QString curFile, item; |
375 | InputDialog *fileDlg; | 375 | InputDialog *fileDlg; |
376 | 376 | ||
377 | QDir *thisDir = CurrentDir(); | 377 | QDir *thisDir = CurrentDir(); |
378 | QDir *thatDir = OtherDir(); | 378 | QDir *thatDir = OtherDir(); |
379 | 379 | ||
380 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 380 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
381 | { | 381 | { |
382 | QString destFile; | 382 | QString destFile; |
383 | item=(*it); | 383 | item=(*it); |
384 | curFile = thisDir->canonicalPath()+"/"+(*it); | 384 | curFile = thisDir->canonicalPath()+"/"+(*it); |
385 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 385 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
386 | 386 | ||
387 | fileDlg->setInputText((const QString &) destFile ); | 387 | fileDlg->setInputText((const QString &) destFile ); |
388 | fileDlg->exec(); | 388 | fileDlg->exec(); |
389 | 389 | ||
390 | if( fileDlg->result() == 1 ) | 390 | if( fileDlg->result() == 1 ) |
391 | { | 391 | { |
392 | QString filename = fileDlg->LineEdit1->text(); | 392 | QString filename = fileDlg->LineEdit1->text(); |
393 | destFile = thatDir->canonicalPath()+"/"+filename; | 393 | destFile = thatDir->canonicalPath()+"/"+filename; |
394 | 394 | ||
395 | QFile f( destFile); | 395 | QFile f( destFile); |
396 | if( f.exists()) | 396 | if( f.exists()) |
397 | { | 397 | { |
398 | switch (QMessageBox::warning(this,tr("File Exists!"), | 398 | switch (QMessageBox::warning(this,tr("File Exists!"), |
399 | item+tr("\nexists. Ok to overwrite?"), | 399 | item+tr("\nexists. Ok to overwrite?"), |
400 | tr("Yes"),tr("No"),0,0,1) ) | 400 | tr("Yes"),tr("No"),0,0,1) ) |
401 | { | 401 | { |
402 | case 0: | 402 | case 0: |
403 | f.remove(); | 403 | f.remove(); |
404 | break; | 404 | break; |
405 | case 1: | 405 | case 1: |
406 | return; | 406 | return; |
407 | break; | 407 | break; |
408 | }; | 408 | }; |
409 | } | 409 | } |
410 | if( !copyFile( curFile, destFile) ) | 410 | if( !copyFile( curFile, destFile) ) |
411 | { | 411 | { |
412 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 412 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
413 | +curFile +tr("to\n")+destFile); | 413 | +curFile +tr("to\n")+destFile); |
414 | return; | 414 | return; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | delete fileDlg; | 417 | delete fileDlg; |
418 | 418 | ||
419 | } | 419 | } |
420 | setOtherTabCurrent(); | 420 | setOtherTabCurrent(); |
421 | populateView(); | 421 | populateView(); |
422 | } | 422 | } |
423 | 423 | ||
424 | void AdvancedFm::copySameDir() | 424 | void AdvancedFm::copySameDir() |
425 | { | 425 | { |
426 | qApp->processEvents(); | 426 | qApp->processEvents(); |
427 | QStringList curFileList = getPath(); | 427 | QStringList curFileList = getPath(); |
428 | QString curFile, item, destFile; | 428 | QString curFile, item, destFile; |
429 | InputDialog *fileDlg; | 429 | InputDialog *fileDlg; |
430 | 430 | ||
431 | QDir *thisDir = CurrentDir(); | 431 | QDir *thisDir = CurrentDir(); |
432 | 432 | ||
433 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 433 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
434 | { | 434 | { |
435 | item=(*it); | 435 | item=(*it); |
436 | curFile = thisDir->canonicalPath()+"/"+ item; | 436 | curFile = thisDir->canonicalPath()+"/"+ item; |
437 | 437 | ||
438 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 438 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
439 | fileDlg->setInputText((const QString &) destFile ); | 439 | fileDlg->setInputText((const QString &) destFile ); |
440 | fileDlg->exec(); | 440 | fileDlg->exec(); |
441 | 441 | ||
442 | if( fileDlg->result() == 1 ) | 442 | if( fileDlg->result() == 1 ) |
443 | { | 443 | { |
444 | 444 | ||
445 | QString filename = fileDlg->LineEdit1->text(); | 445 | QString filename = fileDlg->LineEdit1->text(); |
446 | destFile = thisDir->canonicalPath()+"/"+filename; | 446 | destFile = thisDir->canonicalPath()+"/"+filename; |
447 | 447 | ||
448 | QFile f(destFile); | 448 | QFile f(destFile); |
449 | if( f.exists()) | 449 | if( f.exists()) |
450 | { | 450 | { |
451 | switch (QMessageBox::warning(this,tr("Delete"), | 451 | switch (QMessageBox::warning(this,tr("Delete"), |
452 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 452 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
453 | tr("Yes"),tr("No"),0,0,1) ) { | 453 | tr("Yes"),tr("No"),0,0,1) ) { |
454 | case 0: | 454 | case 0: |
455 | 455 | ||
456 | f.remove(); | 456 | f.remove(); |
457 | break; | 457 | break; |
458 | case 1: | 458 | case 1: |
459 | return; | 459 | return; |
460 | break; | 460 | break; |
461 | }; | 461 | }; |
462 | } | 462 | } |
463 | if(!copyFile( curFile,destFile) ) | 463 | if(!copyFile( curFile,destFile) ) |
464 | { | 464 | { |
465 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 465 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
466 | +curFile +tr("to\n")+destFile); | 466 | +curFile +tr("to\n")+destFile); |
467 | return; | 467 | return; |
468 | } | 468 | } |
469 | 469 | ||
470 | qDebug("copy "+curFile+" as "+destFile); | 470 | qDebug("copy "+curFile+" as "+destFile); |
471 | } | 471 | } |
472 | delete fileDlg; | 472 | delete fileDlg; |
473 | } | 473 | } |
474 | populateView(); | 474 | populateView(); |
475 | } | 475 | } |
476 | 476 | ||
477 | void AdvancedFm::move() | 477 | void AdvancedFm::move() |
478 | { | 478 | { |
479 | qApp->processEvents(); | 479 | qApp->processEvents(); |
480 | 480 | ||
481 | QStringList curFileList = getPath(); | 481 | QStringList curFileList = getPath(); |
482 | if( curFileList.count() > 0) | 482 | if( curFileList.count() > 0) |
483 | { | 483 | { |
484 | QString curFile, destFile, item; | 484 | QString curFile, destFile, item; |
485 | 485 | ||
486 | QDir *thisDir = CurrentDir(); | 486 | QDir *thisDir = CurrentDir(); |
487 | QDir *thatDir = OtherDir(); | 487 | QDir *thatDir = OtherDir(); |
488 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 488 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
489 | { | 489 | { |
490 | item=(*it); | 490 | item=(*it); |
491 | QString destFile = thatDir->canonicalPath(); | 491 | QString destFile = thatDir->canonicalPath(); |
492 | 492 | ||
493 | if(destFile.right(1).find("/",0,TRUE) == -1) | 493 | if(destFile.right(1).find("/",0,TRUE) == -1) |
494 | destFile+="/"; | 494 | destFile+="/"; |
495 | destFile += item; | 495 | destFile += item; |
496 | qDebug("Destination file is "+destFile); | 496 | qDebug("Destination file is "+destFile); |
497 | 497 | ||
498 | curFile = thisDir->canonicalPath(); | 498 | curFile = thisDir->canonicalPath(); |
499 | if(curFile.right(1).find("/",0,TRUE) == -1) | 499 | if(curFile.right(1).find("/",0,TRUE) == -1) |
500 | curFile +="/"; | 500 | curFile +="/"; |
501 | curFile+= item; | 501 | curFile+= item; |
502 | qDebug("CurrentFile file is " + curFile); | 502 | qDebug("CurrentFile file is " + curFile); |
503 | 503 | ||
504 | QFile f( curFile); | 504 | QFile f( curFile); |
505 | if( f.exists()) { | 505 | if( f.exists()) { |
506 | if( !copyFile( curFile, destFile) ) | 506 | if( !copyFile( curFile, destFile) ) |
507 | { | 507 | { |
508 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 508 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
509 | return; | 509 | return; |
510 | } else | 510 | } else |
511 | QFile::remove(curFile); | 511 | QFile::remove(curFile); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | } | 515 | } |
516 | setOtherTabCurrent(); | 516 | setOtherTabCurrent(); |
517 | populateView(); | 517 | populateView(); |
518 | // populateLocalView(); | 518 | // populateLocalView(); |
519 | } | 519 | } |
520 | 520 | ||
521 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 521 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) |
522 | { | 522 | { |
523 | char bf[ 50000 ]; | 523 | char bf[ 50000 ]; |
524 | int bytesRead; | 524 | int bytesRead; |
525 | bool success = TRUE; | 525 | bool success = TRUE; |
526 | struct stat status; | 526 | struct stat status; |
527 | 527 | ||
528 | QFile s( src ); | 528 | QFile s( src ); |
529 | QFile d( dest ); | 529 | QFile d( dest ); |
530 | 530 | ||
531 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) | 531 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) |
532 | { | 532 | { |
533 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) | 533 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) |
534 | { | 534 | { |
535 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 535 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
536 | success = FALSE; | 536 | success = FALSE; |
537 | break; | 537 | break; |
538 | } | 538 | } |
539 | } | 539 | } |
540 | if( success && (bytesRead > 0) ) | 540 | if( success && (bytesRead > 0) ) |
541 | { | 541 | { |
542 | d.writeBlock( bf, bytesRead ); | 542 | d.writeBlock( bf, bytesRead ); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | else | 545 | else |
546 | { | 546 | { |
547 | success = FALSE; | 547 | success = FALSE; |
548 | } | 548 | } |
549 | 549 | ||
550 | // Set file permissions | 550 | // Set file permissions |
551 | if( stat( (const char *) src, &status ) == 0 ) | 551 | if( stat( (const char *) src, &status ) == 0 ) |
552 | { | 552 | { |
553 | chmod( (const char *) dest, status.st_mode ); | 553 | chmod( (const char *) dest, status.st_mode ); |
554 | } | 554 | } |
555 | 555 | ||
556 | return success; | 556 | return success; |
557 | } | 557 | } |
558 | 558 | ||
559 | void AdvancedFm::runCommand() | 559 | void AdvancedFm::runCommand() |
560 | { | 560 | { |
561 | QDir *thisDir = CurrentDir(); | 561 | QDir *thisDir = CurrentDir(); |
562 | 562 | ||
563 | QString curFile; | 563 | QString curFile; |
564 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 564 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
565 | 565 | ||
566 | InputDialog *fileDlg; | 566 | InputDialog *fileDlg; |
567 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 567 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
568 | fileDlg->setInputText(curFile); | 568 | fileDlg->setInputText(curFile); |
569 | fileDlg->exec(); | 569 | fileDlg->exec(); |
570 | //QString command; | 570 | //QString command; |
571 | 571 | ||
572 | if( fileDlg->result() == 1 ) | 572 | if( fileDlg->result() == 1 ) |
573 | { | 573 | { |
574 | qDebug(fileDlg->LineEdit1->text()); | 574 | qDebug(fileDlg->LineEdit1->text()); |
575 | QStringList command; | 575 | QStringList command; |
576 | 576 | ||
577 | command << "/bin/sh"; | 577 | command << "/bin/sh"; |
578 | command << "-c"; | 578 | command << "-c"; |
579 | command << fileDlg->LineEdit1->text(); | 579 | command << fileDlg->LineEdit1->text(); |
580 | Output *outDlg; | 580 | Output *outDlg; |
581 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 581 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
582 | outDlg->showMaximized(); | 582 | outDlg->showMaximized(); |
583 | outDlg->exec(); | 583 | outDlg->exec(); |
584 | qApp->processEvents(); | 584 | qApp->processEvents(); |
585 | 585 | ||
586 | } | 586 | } |
587 | } | 587 | } |
588 | 588 | ||
589 | void AdvancedFm::runCommandStd() | 589 | void AdvancedFm::runCommandStd() |
590 | { | 590 | { |
591 | QString curFile; | 591 | QString curFile; |
592 | QDir *thisDir = CurrentDir(); | 592 | QDir *thisDir = CurrentDir(); |
593 | QListView *thisView = CurrentView(); | 593 | QListView *thisView = CurrentView(); |
594 | if( thisView->currentItem()) | 594 | if( thisView->currentItem()) |
595 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 595 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
596 | 596 | ||
597 | InputDialog *fileDlg; | 597 | InputDialog *fileDlg; |
598 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 598 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
599 | fileDlg->setInputText(curFile); | 599 | fileDlg->setInputText(curFile); |
600 | fileDlg->exec(); | 600 | fileDlg->exec(); |
601 | 601 | ||
602 | if( fileDlg->result() == 1 ) | 602 | if( fileDlg->result() == 1 ) |
603 | { | 603 | { |
604 | qApp->processEvents(); | 604 | qApp->processEvents(); |
605 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 605 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
606 | } | 606 | } |
607 | } | 607 | } |
608 | 608 | ||
609 | void AdvancedFm::fileStatus() | 609 | void AdvancedFm::fileStatus() |
610 | { | 610 | { |
611 | QString curFile; | 611 | QString curFile; |
612 | curFile = CurrentView()->currentItem()->text(0); | 612 | curFile = CurrentView()->currentItem()->text(0); |
613 | 613 | ||
614 | QStringList command; | 614 | QStringList command; |
615 | command << "/bin/sh"; | 615 | command << "/bin/sh"; |
616 | command << "-c"; | 616 | command << "-c"; |
617 | command << "stat -l "+ curFile; | 617 | command << "stat -l "+ curFile; |
618 | 618 | ||
619 | Output *outDlg; | 619 | Output *outDlg; |
620 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 620 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
621 | outDlg->showMaximized(); | 621 | outDlg->showMaximized(); |
622 | outDlg->exec(); | 622 | outDlg->exec(); |
623 | qApp->processEvents(); | 623 | qApp->processEvents(); |
624 | } | 624 | } |
625 | 625 | ||
626 | 626 | ||
627 | void AdvancedFm::mkDir() | 627 | void AdvancedFm::mkDir() |
628 | { | 628 | { |
629 | makeDir(); | 629 | makeDir(); |
630 | } | 630 | } |
631 | 631 | ||
632 | void AdvancedFm::rn() | 632 | void AdvancedFm::rn() |
633 | { | 633 | { |
634 | renameIt(); | 634 | renameIt(); |
635 | } | 635 | } |
636 | 636 | ||
637 | void AdvancedFm::del() | 637 | void AdvancedFm::del() |
638 | { | 638 | { |
639 | doDelete(); | 639 | doDelete(); |
640 | } | 640 | } |
641 | 641 | ||
642 | void AdvancedFm::mkSym() | 642 | void AdvancedFm::mkSym() |
643 | { | 643 | { |
644 | QString cmd; | 644 | QString cmd; |
645 | QStringList curFileList = getPath(); | 645 | QStringList curFileList = getPath(); |
646 | if( curFileList.count() > 0) | 646 | if( curFileList.count() > 0) |
647 | { | 647 | { |
648 | QDir *thisDir = CurrentDir(); | 648 | QDir *thisDir = CurrentDir(); |
649 | QDir * thatDir = OtherDir(); | 649 | QDir * thatDir = OtherDir(); |
650 | 650 | ||
651 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 651 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
652 | { | 652 | { |
653 | 653 | ||
654 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 654 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
655 | if(destName.right(1) == "/") | 655 | if(destName.right(1) == "/") |
656 | { | 656 | { |
657 | destName = destName.left( destName.length() -1); | 657 | destName = destName.left( destName.length() -1); |
658 | } | 658 | } |
659 | 659 | ||
660 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 660 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
661 | 661 | ||
662 | if( curFile.right(1) == "/") | 662 | if( curFile.right(1) == "/") |
663 | { | 663 | { |
664 | curFile = curFile.left( curFile.length() -1); | 664 | curFile = curFile.left( curFile.length() -1); |
665 | } | 665 | } |
666 | 666 | ||
667 | cmd = "ln -s "+curFile+" "+destName; | 667 | cmd = "ln -s "+curFile+" "+destName; |
668 | qDebug(cmd); | 668 | qDebug(cmd); |
669 | startProcess( (const QString)cmd ); | 669 | startProcess( (const QString)cmd ); |
670 | } | 670 | } |
671 | setOtherTabCurrent(); | 671 | setOtherTabCurrent(); |
672 | populateView(); | 672 | populateView(); |
673 | } | 673 | } |
674 | } | 674 | } |
675 | 675 | ||
676 | void AdvancedFm::doBeam() | 676 | void AdvancedFm::doBeam() |
677 | { | 677 | { |
678 | Ir ir; | 678 | Ir ir; |
679 | if(!ir.supported()) | 679 | if(!ir.supported()) |
680 | { | 680 | { |
681 | } | 681 | } |
682 | else | 682 | else |
683 | { | 683 | { |
684 | QStringList curFileList = getPath(); | 684 | QStringList curFileList = getPath(); |
685 | if( curFileList.count() > 0) | 685 | if( curFileList.count() > 0) |
686 | { | 686 | { |
687 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 687 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
688 | { | 688 | { |
689 | 689 | ||
690 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); | 690 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); |
691 | if( curFile.right(1) == "/") | 691 | if( curFile.right(1) == "/") |
692 | { | 692 | { |
693 | curFile = curFile.left( curFile.length() -1); | 693 | curFile = curFile.left( curFile.length() -1); |
694 | } | 694 | } |
695 | Ir *file = new Ir(this, "IR"); | 695 | Ir *file = new Ir(this, "IR"); |
696 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 696 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
697 | file->send( curFile, curFile ); | 697 | file->send( curFile, curFile ); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | } | 700 | } |
701 | 701 | ||
702 | } | 702 | } |
703 | 703 | ||
704 | void AdvancedFm::fileBeamFinished( Ir *) | 704 | void AdvancedFm::fileBeamFinished( Ir *) |
705 | { | 705 | { |
706 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 706 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void AdvancedFm::selectAll() | 709 | void AdvancedFm::selectAll() |
710 | { | 710 | { |
711 | // if (TabWidget->getCurrentTab() == 0) { | 711 | // if (TabWidget->currentTab() == 0) { |
712 | QListView *thisView = CurrentView(); | 712 | QListView *thisView = CurrentView(); |
713 | thisView->selectAll(true); | 713 | thisView->selectAll(true); |
714 | thisView->setSelected( thisView->firstChild(),false); | 714 | thisView->setSelected( thisView->firstChild(),false); |
715 | // } else { | 715 | // } else { |
716 | // Remote_View->selectAll(true); | 716 | // Remote_View->selectAll(true); |
717 | // Remote_View->setSelected( Remote_View->firstChild(),false); | 717 | // Remote_View->setSelected( Remote_View->firstChild(),false); |
718 | // } | 718 | // } |
719 | } | 719 | } |
720 | 720 | ||
721 | void AdvancedFm::startProcess(const QString & cmd) | 721 | void AdvancedFm::startProcess(const QString & cmd) |
722 | { | 722 | { |
723 | QStringList command; | 723 | QStringList command; |
724 | OProcess *process; | 724 | OProcess *process; |
725 | process = new OProcess(); | 725 | process = new OProcess(); |
726 | connect(process, SIGNAL(processExited(OProcess *)), | 726 | connect(process, SIGNAL(processExited(OProcess *)), |
727 | this, SLOT( processEnded(OProcess *))); | 727 | this, SLOT( processEnded(OProcess *))); |
728 | 728 | ||
729 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 729 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), |
730 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 730 | this, SLOT( oprocessStderr(OProcess *, char *, int))); |
731 | 731 | ||
732 | command << "/bin/sh"; | 732 | command << "/bin/sh"; |
733 | command << "-c"; | 733 | command << "-c"; |
734 | command << cmd.latin1(); | 734 | command << cmd.latin1(); |
735 | *process << command; | 735 | *process << command; |
736 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 736 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
737 | qDebug("could not start process"); | 737 | qDebug("could not start process"); |
738 | } | 738 | } |
739 | 739 | ||
740 | void AdvancedFm::processEnded(OProcess *) | 740 | void AdvancedFm::processEnded(OProcess *) |
741 | { | 741 | { |
742 | // populateLocalView(); | 742 | // populateLocalView(); |
743 | populateView(); | 743 | populateView(); |
744 | } | 744 | } |
745 | 745 | ||
746 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { | 746 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { |
747 | qWarning("received stderrt %d bytes", buflen); | 747 | qWarning("received stderrt %d bytes", buflen); |
748 | 748 | ||
749 | QString lineStr = buffer; | 749 | QString lineStr = buffer; |
750 | // lineStr=lineStr.left(lineStr.length()-1); | 750 | // lineStr=lineStr.left(lineStr.length()-1); |
751 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 751 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
752 | 752 | ||
753 | // OutputEdit->append(lineStr); | 753 | // OutputEdit->append(lineStr); |
754 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 754 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
755 | } | 755 | } |
756 | 756 | ||
757 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 757 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) |
758 | { | 758 | { |
759 | if ( o->inherits( "QLineEdit" ) ) | 759 | if ( o->inherits( "QLineEdit" ) ) |
760 | { | 760 | { |
761 | if ( e->type() == QEvent::KeyPress ) | 761 | if ( e->type() == QEvent::KeyPress ) |
762 | { | 762 | { |
763 | QKeyEvent *ke = (QKeyEvent*)e; | 763 | QKeyEvent *ke = (QKeyEvent*)e; |
764 | if ( ke->key() == Key_Return || | 764 | if ( ke->key() == Key_Return || |
765 | ke->key() == Key_Enter ) | 765 | ke->key() == Key_Enter ) |
766 | { | 766 | { |
767 | okRename(); | 767 | okRename(); |
768 | return true; | 768 | return true; |
769 | } | 769 | } |
770 | else if ( ke->key() == Key_Escape ) | 770 | else if ( ke->key() == Key_Escape ) |
771 | { | 771 | { |
772 | cancelRename(); | 772 | cancelRename(); |
773 | return true; | 773 | return true; |
774 | } | 774 | } |
775 | } | 775 | } |
776 | else if ( e->type() == QEvent::FocusOut ) | 776 | else if ( e->type() == QEvent::FocusOut ) |
777 | { | 777 | { |
778 | cancelRename(); | 778 | cancelRename(); |
779 | return true; | 779 | return true; |
780 | } | 780 | } |
781 | } | 781 | } |
782 | if ( o->inherits( "QListView" ) ) | 782 | if ( o->inherits( "QListView" ) ) |
783 | { | 783 | { |
784 | if ( e->type() == QEvent::FocusOut ) | 784 | if ( e->type() == QEvent::FocusOut ) |
785 | { | 785 | { |
786 | printf("focusIn\n"); | 786 | printf("focusIn\n"); |
787 | 787 | ||
788 | } | 788 | } |
789 | } | 789 | } |
790 | 790 | ||
791 | return QWidget::eventFilter( o, e ); | 791 | return QWidget::eventFilter( o, e ); |
792 | } | 792 | } |
793 | 793 | ||
794 | 794 | ||
795 | void AdvancedFm::cancelRename() | 795 | void AdvancedFm::cancelRename() |
796 | { | 796 | { |
797 | qDebug("cancel rename"); | 797 | qDebug("cancel rename"); |
798 | QListView * view; | 798 | QListView * view; |
799 | view = CurrentView(); | 799 | view = CurrentView(); |
800 | 800 | ||
801 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 801 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
802 | delete renameBox; | 802 | delete renameBox; |
803 | renameBox = 0; | 803 | renameBox = 0; |
804 | if ( resetFocus ) | 804 | if ( resetFocus ) |
805 | { | 805 | { |
806 | view->viewport()->setFocusProxy( view); | 806 | view->viewport()->setFocusProxy( view); |
807 | view->setFocus(); | 807 | view->setFocus(); |
808 | } | 808 | } |
809 | } | 809 | } |
810 | 810 | ||
811 | void AdvancedFm::doRename(QListView * view) | 811 | void AdvancedFm::doRename(QListView * view) |
812 | { | 812 | { |
813 | 813 | ||
814 | QRect r = view->itemRect( view->currentItem( )); | 814 | QRect r = view->itemRect( view->currentItem( )); |
815 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 815 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
816 | r.setX( view->contentsX() ); | 816 | r.setX( view->contentsX() ); |
817 | if ( r.width() > view->visibleWidth() ) | 817 | if ( r.width() > view->visibleWidth() ) |
818 | r.setWidth( view->visibleWidth() ); | 818 | r.setWidth( view->visibleWidth() ); |
819 | 819 | ||
820 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 820 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
821 | renameBox->setFrame(true); | 821 | renameBox->setFrame(true); |
822 | 822 | ||
823 | renameBox->setText( view->currentItem()->text(0) ); | 823 | renameBox->setText( view->currentItem()->text(0) ); |
824 | 824 | ||
825 | renameBox->selectAll(); | 825 | renameBox->selectAll(); |
826 | renameBox->installEventFilter( this ); | 826 | renameBox->installEventFilter( this ); |
827 | view->addChild( renameBox, r.x(), r.y() ); | 827 | view->addChild( renameBox, r.x(), r.y() ); |
828 | renameBox->resize( r.size() ); | 828 | renameBox->resize( r.size() ); |
829 | view->viewport()->setFocusProxy( renameBox ); | 829 | view->viewport()->setFocusProxy( renameBox ); |
830 | renameBox->setFocus(); | 830 | renameBox->setFocus(); |
831 | renameBox->show(); | 831 | renameBox->show(); |
832 | 832 | ||
833 | } | 833 | } |
834 | 834 | ||
835 | 835 | ||
836 | void AdvancedFm::renameIt() | 836 | void AdvancedFm::renameIt() |
837 | { | 837 | { |
838 | QListView *thisView = CurrentView(); | 838 | QListView *thisView = CurrentView(); |
839 | oldName = thisView->currentItem()->text(0); | 839 | oldName = thisView->currentItem()->text(0); |
840 | doRename( thisView ); | 840 | doRename( thisView ); |
841 | populateView(); | 841 | populateView(); |
842 | } | 842 | } |
843 | 843 | ||
844 | void AdvancedFm::okRename() | 844 | void AdvancedFm::okRename() |
845 | { | 845 | { |
846 | QString newName = renameBox->text(); | 846 | QString newName = renameBox->text(); |
847 | cancelRename(); | 847 | cancelRename(); |
848 | // int tabs=0; | 848 | // int tabs=0; |
849 | QListView * view = CurrentView(); | 849 | QListView * view = CurrentView(); |
850 | QString path = CurrentDir()->canonicalPath() + "/"; | 850 | QString path = CurrentDir()->canonicalPath() + "/"; |
851 | oldName = path + oldName; | 851 | oldName = path + oldName; |
852 | newName = path + newName; | 852 | newName = path + newName; |
853 | 853 | ||
854 | if( view->currentItem() == NULL) | 854 | if( view->currentItem() == NULL) |
855 | return; | 855 | return; |
856 | if( rename( oldName.latin1(), newName.latin1())== -1) | 856 | if( rename( oldName.latin1(), newName.latin1())== -1) |
857 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 857 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
858 | else | 858 | else |
859 | oldName = ""; | 859 | oldName = ""; |
860 | 860 | ||
861 | view->takeItem( view->currentItem() ); | 861 | view->takeItem( view->currentItem() ); |
862 | delete view->currentItem(); | 862 | delete view->currentItem(); |
863 | populateView(); | 863 | populateView(); |
864 | } | 864 | } |