-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 | |||
@@ -70,208 +70,207 @@ public: | |||
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 | |||
@@ -222,257 +222,257 @@ void AdvancedFm::populateView() | |||
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(); |
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 | |||
@@ -583,257 +583,257 @@ void AdvancedFm::runCommand() | |||
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); |