summaryrefslogtreecommitdiff
authorsandman <sandman>2002-12-30 15:12:34 (UTC)
committer sandman <sandman>2002-12-30 15:12:34 (UTC)
commit66bfb25fe226a69f1ca2218b56fb3df74409de2f (patch) (unidiff)
tree2350a583f4b663f1c92cc442145ea342b133e3c0
parenta0eca1c0925a6893fa8f3ebfacd6363f906189df (diff)
downloadopie-66bfb25fe226a69f1ca2218b56fb3df74409de2f.zip
opie-66bfb25fe226a69f1ca2218b56fb3df74409de2f.tar.gz
opie-66bfb25fe226a69f1ca2218b56fb3df74409de2f.tar.bz2
getting rid of some qDebugs to make the startup a bit more quiet
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/irserver.cpp6
-rw-r--r--core/launcher/launcherview.cpp1
2 files changed, 3 insertions, 4 deletions
diff --git a/core/launcher/irserver.cpp b/core/launcher/irserver.cpp
index 2147d0a..625cb60 100644
--- a/core/launcher/irserver.cpp
+++ b/core/launcher/irserver.cpp
@@ -1,52 +1,52 @@
1#include "irserver.h" 1#include "irserver.h"
2 2
3#include <qpe/qlibrary.h> 3#include <qpe/qlibrary.h>
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5 5
6#include <qtranslator.h> 6#include <qtranslator.h>
7#include <stdlib.h> 7#include <stdlib.h>
8 8
9#include "obexinterface.h" 9#include "obexinterface.h"
10 10
11#include <qdir.h> 11#include <qdir.h>
12 12
13IrServer::IrServer( QObject *parent, const char *name ) 13IrServer::IrServer( QObject *parent, const char *name )
14 : QObject( parent, name ) 14 : QObject( parent, name )
15{ 15{
16 lib = 0; 16 lib = 0;
17 iface = 0; 17 iface = 0;
18 QString path = QPEApplication::qpeDir() + "/plugins/obex/"; 18 QString path = QPEApplication::qpeDir() + "/plugins/obex/";
19 QDir dir( path, "lib*.so" ); 19 QDir dir( path, "lib*.so" );
20 QStringList list = dir.entryList(); 20 QStringList list = dir.entryList();
21 QStringList::Iterator it; 21 QStringList::Iterator it;
22 for ( it = list.begin(); it != list.end(); ++it ) { 22 for ( it = list.begin(); it != list.end(); ++it ) {
23 QLibrary *trylib = new QLibrary( path + *it ); 23 QLibrary *trylib = new QLibrary( path + *it );
24 qDebug("trying lib %s", (path + (*it)).latin1() ); 24 //qDebug("trying lib %s", (path + (*it)).latin1() );
25 if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 25 if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
26 lib = trylib; 26 lib = trylib;
27 qDebug("found obex lib" ); 27 //qDebug("found obex lib" );
28 QString lang = getenv( "LANG" ); 28 QString lang = getenv( "LANG" );
29 QTranslator * trans = new QTranslator(qApp); 29 QTranslator * trans = new QTranslator(qApp);
30 QString type = (*it).left( (*it).find(".") ); 30 QString type = (*it).left( (*it).find(".") );
31 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 31 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
32 qDebug("tr fpr obex: %s", tfn.latin1() ); 32 //qDebug("tr fpr obex: %s", tfn.latin1() );
33 if ( trans->load( tfn )) 33 if ( trans->load( tfn ))
34 qApp->installTranslator( trans ); 34 qApp->installTranslator( trans );
35 else 35 else
36 delete trans; 36 delete trans;
37 37
38 break; 38 break;
39 } else { 39 } else {
40 delete lib; 40 delete lib;
41 } 41 }
42 } 42 }
43 if ( !lib ) 43 if ( !lib )
44 qDebug("could not load IR plugin" ); 44 qDebug("could not load IR plugin" );
45} 45}
46 46
47IrServer::~IrServer() 47IrServer::~IrServer()
48{ 48{
49 if ( iface ) 49 if ( iface )
50 iface->release(); 50 iface->release();
51 delete lib; 51 delete lib;
52} 52}
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 95a1d4a..7117e0b 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,982 +1,981 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "launcherview.h" 21#include "launcherview.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/qpedebug.h> 25#include <qpe/qpedebug.h>
26#include <qpe/categories.h> 26#include <qpe/categories.h>
27#include <qpe/categoryselect.h> 27#include <qpe/categoryselect.h>
28#include <qpe/menubutton.h> 28#include <qpe/menubutton.h>
29#include <qpe/mimetype.h> 29#include <qpe/mimetype.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
32//#include <qtopia/private/palmtoprecord.h> 32//#include <qtopia/private/palmtoprecord.h>
33 33
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qdict.h> 36#include <qdict.h>
37#include <qfile.h> 37#include <qfile.h>
38#include <qfileinfo.h> 38#include <qfileinfo.h>
39#include <qhbox.h> 39#include <qhbox.h>
40#include <qiconview.h> 40#include <qiconview.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qtoolbutton.h> 43#include <qtoolbutton.h>
44#include <qimage.h> 44#include <qimage.h>
45 45
46#include <cstdlib> 46#include <cstdlib>
47 47
48class BgPixmap 48class BgPixmap
49{ 49{
50public: 50public:
51 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 51 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
52 QPixmap pm; 52 QPixmap pm;
53 int ref; 53 int ref;
54}; 54};
55 55
56enum BusyIndicatorType { 56enum BusyIndicatorType {
57 BIT_Normal = 0, 57 BIT_Normal = 0,
58 BIT_Blinking 58 BIT_Blinking
59}; 59};
60 60
61static QMap<QString,BgPixmap*> *bgCache = 0; 61static QMap<QString,BgPixmap*> *bgCache = 0;
62 62
63class LauncherIconView : public QIconView { 63class LauncherIconView : public QIconView {
64public: 64public:
65 LauncherIconView( QWidget* parent, const char* name=0 ) : 65 LauncherIconView( QWidget* parent, const char* name=0 ) :
66 QIconView(parent,name), 66 QIconView(parent,name),
67 tf(""), 67 tf(""),
68 cf(0), 68 cf(0),
69 bsy(0), 69 bsy(0),
70 bigIcns(TRUE), 70 bigIcns(TRUE),
71 bgColor(white) 71 bgColor(white)
72 { 72 {
73 sortmeth = Name; 73 sortmeth = Name;
74 hidden.setAutoDelete(TRUE); 74 hidden.setAutoDelete(TRUE);
75 ike = FALSE; 75 ike = FALSE;
76 busytimer = 0; 76 busytimer = 0;
77 calculateGrid( Bottom ); 77 calculateGrid( Bottom );
78 } 78 }
79 79
80 ~LauncherIconView() 80 ~LauncherIconView()
81 { 81 {
82#if 0 // debuggery 82#if 0 // debuggery
83 QListIterator<AppLnk> it(hidden); 83 QListIterator<AppLnk> it(hidden);
84 AppLnk* l; 84 AppLnk* l;
85 while ((l=it.current())) { 85 while ((l=it.current())) {
86 ++it; 86 ++it;
87 //qDebug("%p: hidden (should remove)",l); 87 //qDebug("%p: hidden (should remove)",l);
88 } 88 }
89#endif 89#endif
90 } 90 }
91 91
92 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 92 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
93 93
94 QPixmap* busyPixmap() const { return (QPixmap*)&bpm[abs(busystate)]; } 94 QPixmap* busyPixmap() const { return (QPixmap*)&bpm[abs(busystate)]; }
95 QIconViewItem* busyItem() const { return bsy; } 95 QIconViewItem* busyItem() const { return bsy; }
96 void setBigIcons( bool bi ) { bigIcns = bi; } 96 void setBigIcons( bool bi ) { bigIcns = bi; }
97 97
98 void updateCategoriesAndMimeTypes(); 98 void updateCategoriesAndMimeTypes();
99 99
100 void doAutoScroll() 100 void doAutoScroll()
101 { 101 {
102 // We don't want rubberbanding (yet) 102 // We don't want rubberbanding (yet)
103 } 103 }
104 104
105 void setBusy(bool on) 105 void setBusy(bool on)
106 { 106 {
107 QIconViewItem *c = on ? currentItem() : 0; 107 QIconViewItem *c = on ? currentItem() : 0;
108 108
109 if ( bsy != c ) { 109 if ( bsy != c ) {
110 QIconViewItem *oldbsy = bsy; 110 QIconViewItem *oldbsy = bsy;
111 bsy = c; 111 bsy = c;
112 112
113 if ( oldbsy ) 113 if ( oldbsy )
114 oldbsy-> repaint ( ); 114 oldbsy-> repaint ( );
115 115
116 if ( busytimer ) { 116 if ( busytimer ) {
117 killTimer ( busytimer ); 117 killTimer ( busytimer );
118 busytimer = 0; 118 busytimer = 0;
119 } 119 }
120 120
121 if ( bsy ) { 121 if ( bsy ) {
122 QPixmap *src = bsy-> QIconViewItem::pixmap(); 122 QPixmap *src = bsy-> QIconViewItem::pixmap();
123 for ( int i = 0; i <= 5; i++ ) { 123 for ( int i = 0; i <= 5; i++ ) {
124 QImage img = src->convertToImage(); 124 QImage img = src->convertToImage();
125 QRgb* rgb; 125 QRgb* rgb;
126 int count; 126 int count;
127 if ( img.depth() == 32 ) { 127 if ( img.depth() == 32 ) {
128 rgb = (QRgb*)img.bits(); 128 rgb = (QRgb*)img.bits();
129 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 129 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
130 } else { 130 } else {
131 rgb = img.colorTable(); 131 rgb = img.colorTable();
132 count = img.numColors(); 132 count = img.numColors();
133 } 133 }
134 int rc, gc, bc; 134 int rc, gc, bc;
135 int bs = abs ( i * 10 ) + 25; 135 int bs = abs ( i * 10 ) + 25;
136 colorGroup().highlight().rgb( &rc, &gc, &bc ); 136 colorGroup().highlight().rgb( &rc, &gc, &bc );
137 rc = rc * bs / 100; 137 rc = rc * bs / 100;
138 gc = gc * bs / 100; 138 gc = gc * bs / 100;
139 bc = bc * bs / 100; 139 bc = bc * bs / 100;
140 140
141 for ( int r = 0; r < count; r++, rgb++ ) { 141 for ( int r = 0; r < count; r++, rgb++ ) {
142 int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100; 142 int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100;
143 int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100; 143 int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100;
144 int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100; 144 int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100;
145 int ai = qAlpha ( *rgb ); 145 int ai = qAlpha ( *rgb );
146 *rgb = qRgba ( ri, gi, bi, ai ); 146 *rgb = qRgba ( ri, gi, bi, ai );
147 } 147 }
148 148
149 bpm [i].convertFromImage( img ); 149 bpm [i].convertFromImage( img );
150 } 150 }
151 151
152 if ( busyType == BIT_Blinking ) { 152 if ( busyType == BIT_Blinking ) {
153 busystate = 0; 153 busystate = 0;
154 busytimer = startTimer ( 200 ); 154 busytimer = startTimer ( 200 );
155 } 155 }
156 else { 156 else {
157 busystate = 3; 157 busystate = 3;
158 } 158 }
159 timerEvent ( 0 ); 159 timerEvent ( 0 );
160 } 160 }
161 } 161 }
162 } 162 }
163 163
164 virtual void timerEvent ( QTimerEvent *te ) 164 virtual void timerEvent ( QTimerEvent *te )
165 { 165 {
166 if ( !te || ( te-> timerId ( ) == busytimer )) { 166 if ( !te || ( te-> timerId ( ) == busytimer )) {
167 if ( bsy ) { 167 if ( bsy ) {
168 busystate++; 168 busystate++;
169 if ( busystate > 5 ) 169 if ( busystate > 5 )
170 busystate = -4; 170 busystate = -4;
171 171
172 QScrollView::updateContents ( bsy-> pixmapRect ( false )); 172 QScrollView::updateContents ( bsy-> pixmapRect ( false ));
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 bool inKeyEvent() const { return ike; } 177 bool inKeyEvent() const { return ike; }
178 void keyPressEvent(QKeyEvent* e) 178 void keyPressEvent(QKeyEvent* e)
179 { 179 {
180 ike = TRUE; 180 ike = TRUE;
181 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) 181 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space )
182 returnPressed(currentItem()); 182 returnPressed(currentItem());
183 QIconView::keyPressEvent(e); 183 QIconView::keyPressEvent(e);
184 ike = FALSE; 184 ike = FALSE;
185 } 185 }
186 186
187 void addItem(AppLnk* app, bool resort=TRUE); 187 void addItem(AppLnk* app, bool resort=TRUE);
188 bool removeLink(const QString& linkfile); 188 bool removeLink(const QString& linkfile);
189 189
190 QStringList mimeTypes() const; 190 QStringList mimeTypes() const;
191 QStringList categories() const; 191 QStringList categories() const;
192 192
193 void clear() 193 void clear()
194 { 194 {
195 mimes.clear(); 195 mimes.clear();
196 cats.clear(); 196 cats.clear();
197 QIconView::clear(); 197 QIconView::clear();
198 hidden.clear(); 198 hidden.clear();
199 } 199 }
200 200
201 void addCatsAndMimes(AppLnk* app) 201 void addCatsAndMimes(AppLnk* app)
202 { 202 {
203 // QStringList c = app->categories(); 203 // QStringList c = app->categories();
204 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 204 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
205 // cats.replace(*cit,(void*)1); 205 // cats.replace(*cit,(void*)1);
206 // } 206 // }
207 QString maj=app->type(); 207 QString maj=app->type();
208 int sl=maj.find('/'); 208 int sl=maj.find('/');
209 if (sl>=0) { 209 if (sl>=0) {
210 QString k; 210 QString k;
211 k = maj.left(12) == "application/" ? maj : maj.left(sl); 211 k = maj.left(12) == "application/" ? maj : maj.left(sl);
212 mimes.replace(k,(void*)1); 212 mimes.replace(k,(void*)1);
213 } 213 }
214 } 214 }
215 215
216 void setBackgroundPixmap( const QPixmap &pm ) { 216 void setBackgroundPixmap( const QPixmap &pm ) {
217 if ( pm. isNull ( )) { 217 if ( pm. isNull ( )) {
218 bgPixmap = pm; 218 bgPixmap = pm;
219 } 219 }
220 else { 220 else {
221 // This is need for bg images with alpha channel 221 // This is need for bg images with alpha channel
222 222
223 QPixmap tmp ( pm. size ( ), pm. depth ( )); 223 QPixmap tmp ( pm. size ( ), pm. depth ( ));
224 224
225 QPainter p ( &tmp ); 225 QPainter p ( &tmp );
226 p. fillRect ( 0, 0, pm. width ( ), pm. height ( ), bgColor. isValid ( ) ? bgColor : white ); 226 p. fillRect ( 0, 0, pm. width ( ), pm. height ( ), bgColor. isValid ( ) ? bgColor : white );
227 p. drawPixmap ( 0, 0, pm ); 227 p. drawPixmap ( 0, 0, pm );
228 p. end ( ); 228 p. end ( );
229 229
230 bgPixmap = tmp; 230 bgPixmap = tmp;
231 } 231 }
232 } 232 }
233 233
234 void setBackgroundColor( const QColor &c ) { 234 void setBackgroundColor( const QColor &c ) {
235 bgColor = c; 235 bgColor = c;
236 } 236 }
237 237
238 void drawBackground( QPainter *p, const QRect &r ) 238 void drawBackground( QPainter *p, const QRect &r )
239 { 239 {
240 if ( !bgPixmap.isNull() ) { 240 if ( !bgPixmap.isNull() ) {
241 //p-> fillRect ( r, bgColor ); 241 //p-> fillRect ( r, bgColor );
242 p->drawTiledPixmap( r, bgPixmap, 242 p->drawTiledPixmap( r, bgPixmap,
243 QPoint( (r.x() + contentsX()) % bgPixmap.width(), 243 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
244 (r.y() + contentsY()) % bgPixmap.height() ) ); 244 (r.y() + contentsY()) % bgPixmap.height() ) );
245 } else { 245 } else {
246 p->fillRect( r, bgColor ); 246 p->fillRect( r, bgColor );
247 } 247 }
248 } 248 }
249 249
250 void setItemTextPos( ItemTextPos pos ) 250 void setItemTextPos( ItemTextPos pos )
251 { 251 {
252 calculateGrid( pos ); 252 calculateGrid( pos );
253 QIconView::setItemTextPos( pos ); 253 QIconView::setItemTextPos( pos );
254 } 254 }
255 255
256 void hideOrShowItems(bool resort); 256 void hideOrShowItems(bool resort);
257 257
258 void setTypeFilter(const QString& typefilter, bool resort) 258 void setTypeFilter(const QString& typefilter, bool resort)
259 { 259 {
260 tf = QRegExp(typefilter,FALSE,TRUE); 260 tf = QRegExp(typefilter,FALSE,TRUE);
261 hideOrShowItems(resort); 261 hideOrShowItems(resort);
262 } 262 }
263 263
264 void setCategoryFilter( int catfilter, bool resort ) 264 void setCategoryFilter( int catfilter, bool resort )
265 { 265 {
266 Categories cat; 266 Categories cat;
267 cat.load( categoryFileName() ); 267 cat.load( categoryFileName() );
268 QString str; 268 QString str;
269 if ( catfilter == -2 ) 269 if ( catfilter == -2 )
270 cf = 0; 270 cf = 0;
271 else 271 else
272 cf = catfilter; 272 cf = catfilter;
273 hideOrShowItems(resort); 273 hideOrShowItems(resort);
274 } 274 }
275 275
276 enum SortMethod { Name, Date, Type }; 276 enum SortMethod { Name, Date, Type };
277 277
278 void setSortMethod( SortMethod m ) 278 void setSortMethod( SortMethod m )
279 { 279 {
280 if ( sortmeth != m ) { 280 if ( sortmeth != m ) {
281 sortmeth = m; 281 sortmeth = m;
282 sort(); 282 sort();
283 } 283 }
284 } 284 }
285 285
286 int compare(const AppLnk* a, const AppLnk* b) 286 int compare(const AppLnk* a, const AppLnk* b)
287 { 287 {
288 switch (sortmeth) { 288 switch (sortmeth) {
289 case Name: 289 case Name:
290 return a->name().compare(b->name()); 290 return a->name().compare(b->name());
291 case Date: { 291 case Date: {
292 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 292 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
293 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 293 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
294 return fa.lastModified().secsTo(fb.lastModified()); 294 return fa.lastModified().secsTo(fb.lastModified());
295 } 295 }
296 case Type: 296 case Type:
297 return a->type().compare(b->type()); 297 return a->type().compare(b->type());
298 } 298 }
299 return 0; 299 return 0;
300 } 300 }
301 301
302 QString getAllDocLinkInfo() const; 302 QString getAllDocLinkInfo() const;
303 303
304protected: 304protected:
305 305
306 void styleChange( QStyle &old ) 306 void styleChange( QStyle &old )
307 { 307 {
308 QIconView::styleChange( old ); 308 QIconView::styleChange( old );
309 calculateGrid( itemTextPos() ); 309 calculateGrid( itemTextPos() );
310 } 310 }
311 311
312 void calculateGrid( ItemTextPos pos ) 312 void calculateGrid( ItemTextPos pos )
313 { 313 {
314 int dw = QApplication::desktop()->width(); 314 int dw = QApplication::desktop()->width();
315 int viewerWidth = dw-style().scrollBarExtent().width(); 315 int viewerWidth = dw-style().scrollBarExtent().width();
316 if ( pos == Bottom ) { 316 if ( pos == Bottom ) {
317 int cols = 3; 317 int cols = 3;
318 if ( viewerWidth <= 200 ) 318 if ( viewerWidth <= 200 )
319 cols = 2; 319 cols = 2;
320 else if ( viewerWidth >= 400 ) 320 else if ( viewerWidth >= 400 )
321 cols = viewerWidth/96; 321 cols = viewerWidth/96;
322 setSpacing( 4 ); 322 setSpacing( 4 );
323 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 323 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
324 setGridY( fontMetrics().height()*2+24 ); 324 setGridY( fontMetrics().height()*2+24 );
325 } else { 325 } else {
326 int cols = 2; 326 int cols = 2;
327 if ( viewerWidth < 150 ) 327 if ( viewerWidth < 150 )
328 cols = 1; 328 cols = 1;
329 else if ( viewerWidth >= 400 ) 329 else if ( viewerWidth >= 400 )
330 cols = viewerWidth/150; 330 cols = viewerWidth/150;
331 setSpacing( 2 ); 331 setSpacing( 2 );
332 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 332 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
333 setGridY( fontMetrics().height()+2 ); 333 setGridY( fontMetrics().height()+2 );
334 } 334 }
335 } 335 }
336 336
337 337
338 // flicker free redrawing of busy indicator 338 // flicker free redrawing of busy indicator
339 // code was taken from QScrollView::viewportPaintEvent 339 // code was taken from QScrollView::viewportPaintEvent
340 void viewportPaintEvent( QPaintEvent* pe ) 340 void viewportPaintEvent( QPaintEvent* pe )
341 { 341 {
342 static QPixmap *pix = new QPixmap ( ); 342 static QPixmap *pix = new QPixmap ( );
343 343
344 QWidget* vp = viewport(); 344 QWidget* vp = viewport();
345 345
346 if ( vp-> size ( ) != pix-> size ( )) 346 if ( vp-> size ( ) != pix-> size ( ))
347 pix-> resize ( vp-> size ( )); 347 pix-> resize ( vp-> size ( ));
348 348
349 QPainter p(pix, vp); 349 QPainter p(pix, vp);
350 QRect r = pe->rect(); 350 QRect r = pe->rect();
351 if ( clipper ( ) != vp ) { 351 if ( clipper ( ) != vp ) {
352 QRect rr( 352 QRect rr(
353 -vp->x(), -vp->y(), 353 -vp->x(), -vp->y(),
354 clipper()->width(), clipper()->height() 354 clipper()->width(), clipper()->height()
355 ); 355 );
356 r &= rr; 356 r &= rr;
357 if ( r.isValid() ) { 357 if ( r.isValid() ) {
358 int ex = r.x() + vp->x() + contentsX(); 358 int ex = r.x() + vp->x() + contentsX();
359 int ey = r.y() + vp->y() + contentsY(); 359 int ey = r.y() + vp->y() + contentsY();
360 int ew = r.width(); 360 int ew = r.width();
361 int eh = r.height(); 361 int eh = r.height();
362 drawContentsOffset(&p, 362 drawContentsOffset(&p,
363 contentsX()+vp->x(), 363 contentsX()+vp->x(),
364 contentsY()+vp->y(), 364 contentsY()+vp->y(),
365 ex, ey, ew, eh); 365 ex, ey, ew, eh);
366 } 366 }
367 } else { 367 } else {
368 r &= clipper()->rect(); 368 r &= clipper()->rect();
369 int ex = r.x() + contentsX(); 369 int ex = r.x() + contentsX();
370 int ey = r.y() + contentsY(); 370 int ey = r.y() + contentsY();
371 int ew = r.width(); 371 int ew = r.width();
372 int eh = r.height(); 372 int eh = r.height();
373 drawContentsOffset(&p, contentsX(), contentsY(), ex, ey, ew, eh); 373 drawContentsOffset(&p, contentsX(), contentsY(), ex, ey, ew, eh);
374 } 374 }
375 bitBlt ( vp, r.topLeft(), pix, r ); 375 bitBlt ( vp, r.topLeft(), pix, r );
376 } 376 }
377 377
378private: 378private:
379 QList<AppLnk> hidden; 379 QList<AppLnk> hidden;
380 QDict<void> mimes; 380 QDict<void> mimes;
381 QDict<void> cats; 381 QDict<void> cats;
382 SortMethod sortmeth; 382 SortMethod sortmeth;
383 QRegExp tf; 383 QRegExp tf;
384 int cf; 384 int cf;
385 QIconViewItem* bsy; 385 QIconViewItem* bsy;
386 bool ike; 386 bool ike;
387 bool bigIcns; 387 bool bigIcns;
388 QPixmap bgPixmap; 388 QPixmap bgPixmap;
389 QPixmap bpm [6]; 389 QPixmap bpm [6];
390 QColor bgColor; 390 QColor bgColor;
391 int busytimer; 391 int busytimer;
392 int busystate; 392 int busystate;
393 BusyIndicatorType busyType; 393 BusyIndicatorType busyType;
394}; 394};
395 395
396 396
397bool LauncherView::bsy=FALSE; 397bool LauncherView::bsy=FALSE;
398 398
399void LauncherView::setBusy(bool on) 399void LauncherView::setBusy(bool on)
400{ 400{
401 icons->setBusy(on); 401 icons->setBusy(on);
402} 402}
403 403
404class LauncherItem : public QIconViewItem 404class LauncherItem : public QIconViewItem
405{ 405{
406public: 406public:
407 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 407 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
408 ~LauncherItem() 408 ~LauncherItem()
409 { 409 {
410 LauncherIconView* liv = (LauncherIconView*)iconView(); 410 LauncherIconView* liv = (LauncherIconView*)iconView();
411 if ( liv->busyItem() == this ) 411 if ( liv->busyItem() == this )
412 liv->setBusy(FALSE); 412 liv->setBusy(FALSE);
413 delete app; 413 delete app;
414 } 414 }
415 415
416 AppLnk* appLnk() const { return app; } 416 AppLnk* appLnk() const { return app; }
417 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } 417 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; }
418 418
419 virtual int compare ( QIconViewItem * i ) const; 419 virtual int compare ( QIconViewItem * i ) const;
420 420
421 void paintItem( QPainter *p, const QColorGroup &cg ) 421 void paintItem( QPainter *p, const QColorGroup &cg )
422 { 422 {
423 LauncherIconView* liv = (LauncherIconView*)iconView(); 423 LauncherIconView* liv = (LauncherIconView*)iconView();
424 QBrush oldBrush( liv->itemTextBackground() ); 424 QBrush oldBrush( liv->itemTextBackground() );
425 QColorGroup mycg( cg ); 425 QColorGroup mycg( cg );
426 if ( liv->currentItem() == this ) { 426 if ( liv->currentItem() == this ) {
427 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 427 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
428 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 428 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
429 } 429 }
430 QIconViewItem::paintItem(p,mycg); 430 QIconViewItem::paintItem(p,mycg);
431 if ( liv->currentItem() == this ) 431 if ( liv->currentItem() == this )
432 liv->setItemTextBackground( oldBrush ); 432 liv->setItemTextBackground( oldBrush );
433 } 433 }
434 434
435 virtual QPixmap* pixmap () const 435 virtual QPixmap* pixmap () const
436 { 436 {
437 const LauncherIconView* liv = (LauncherIconView*)iconView(); 437 const LauncherIconView* liv = (LauncherIconView*)iconView();
438 if ( (const LauncherItem *)liv->busyItem() == this ) 438 if ( (const LauncherItem *)liv->busyItem() == this )
439 return liv->busyPixmap(); 439 return liv->busyPixmap();
440 return QIconViewItem::pixmap(); 440 return QIconViewItem::pixmap();
441 } 441 }
442 442
443protected: 443protected:
444 AppLnk* app; 444 AppLnk* app;
445}; 445};
446 446
447 447
448LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 448LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
449 : QIconViewItem( parent, applnk->name(), 449 : QIconViewItem( parent, applnk->name(),
450 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 450 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
451 app(applnk) // Takes ownership 451 app(applnk) // Takes ownership
452{ 452{
453} 453}
454 454
455int LauncherItem::compare ( QIconViewItem * i ) const 455int LauncherItem::compare ( QIconViewItem * i ) const
456{ 456{
457 LauncherIconView* view = (LauncherIconView*)iconView(); 457 LauncherIconView* view = (LauncherIconView*)iconView();
458 return view->compare(app,((LauncherItem *)i)->appLnk()); 458 return view->compare(app,((LauncherItem *)i)->appLnk());
459} 459}
460 460
461QStringList LauncherIconView::mimeTypes() const 461QStringList LauncherIconView::mimeTypes() const
462{ 462{
463 QStringList r; 463 QStringList r;
464 QDictIterator<void> it(mimes); 464 QDictIterator<void> it(mimes);
465 while (it.current()) { 465 while (it.current()) {
466 r.append(it.currentKey()); 466 r.append(it.currentKey());
467 ++it; 467 ++it;
468 } 468 }
469 r.sort(); 469 r.sort();
470 return r; 470 return r;
471} 471}
472 472
473void LauncherIconView::addItem(AppLnk* app, bool resort) 473void LauncherIconView::addItem(AppLnk* app, bool resort)
474{ 474{
475 addCatsAndMimes(app); 475 addCatsAndMimes(app);
476 476
477 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 477 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
478 && (cf == 0 || app->categories().contains(cf) 478 && (cf == 0 || app->categories().contains(cf)
479 || cf == -1 && app->categories().count() == 0 ) ) 479 || cf == -1 && app->categories().count() == 0 ) )
480 (void) new LauncherItem( this, app, bigIcns ); 480 (void) new LauncherItem( this, app, bigIcns );
481 else 481 else
482 hidden.append(app); 482 hidden.append(app);
483 if ( resort ) 483 if ( resort )
484 sort(); 484 sort();
485} 485}
486 486
487void LauncherIconView::updateCategoriesAndMimeTypes() 487void LauncherIconView::updateCategoriesAndMimeTypes()
488{ 488{
489 mimes.clear(); 489 mimes.clear();
490 cats.clear(); 490 cats.clear();
491 LauncherItem* item = (LauncherItem*)firstItem(); 491 LauncherItem* item = (LauncherItem*)firstItem();
492 while (item) { 492 while (item) {
493 addCatsAndMimes(item->appLnk()); 493 addCatsAndMimes(item->appLnk());
494 item = (LauncherItem*)item->nextItem(); 494 item = (LauncherItem*)item->nextItem();
495 } 495 }
496 QListIterator<AppLnk> it(hidden); 496 QListIterator<AppLnk> it(hidden);
497 AppLnk* l; 497 AppLnk* l;
498 while ((l=it.current())) { 498 while ((l=it.current())) {
499 addCatsAndMimes(l); 499 addCatsAndMimes(l);
500 ++it; 500 ++it;
501 } 501 }
502} 502}
503 503
504void LauncherIconView::hideOrShowItems(bool resort) 504void LauncherIconView::hideOrShowItems(bool resort)
505{ 505{
506 hidden.setAutoDelete(FALSE); 506 hidden.setAutoDelete(FALSE);
507 QList<AppLnk> links=hidden; 507 QList<AppLnk> links=hidden;
508 hidden.clear(); 508 hidden.clear();
509 hidden.setAutoDelete(TRUE); 509 hidden.setAutoDelete(TRUE);
510 LauncherItem* item = (LauncherItem*)firstItem(); 510 LauncherItem* item = (LauncherItem*)firstItem();
511 while (item) { 511 while (item) {
512 links.append(item->takeAppLnk()); 512 links.append(item->takeAppLnk());
513 item = (LauncherItem*)item->nextItem(); 513 item = (LauncherItem*)item->nextItem();
514 } 514 }
515 viewport()->setUpdatesEnabled( FALSE ); 515 viewport()->setUpdatesEnabled( FALSE );
516 clear(); 516 clear();
517 QListIterator<AppLnk> it(links); 517 QListIterator<AppLnk> it(links);
518 AppLnk* l; 518 AppLnk* l;
519 while ((l=it.current())) { 519 while ((l=it.current())) {
520 addItem(l,FALSE); 520 addItem(l,FALSE);
521 ++it; 521 ++it;
522 } 522 }
523 viewport()->setUpdatesEnabled( TRUE ); 523 viewport()->setUpdatesEnabled( TRUE );
524 if ( resort && !autoArrange() ) 524 if ( resort && !autoArrange() )
525 sort(); 525 sort();
526} 526}
527 527
528bool LauncherIconView::removeLink(const QString& linkfile) 528bool LauncherIconView::removeLink(const QString& linkfile)
529{ 529{
530 LauncherItem* item = (LauncherItem*)firstItem(); 530 LauncherItem* item = (LauncherItem*)firstItem();
531 AppLnk* l; 531 AppLnk* l;
532 bool did = FALSE; 532 bool did = FALSE;
533 DocLnk dl(linkfile); 533 DocLnk dl(linkfile);
534 while (item) { 534 while (item) {
535 l = item->appLnk(); 535 l = item->appLnk();
536 if ( ( l->linkFileKnown() && ( l->linkFile() == linkfile )) 536 if ( ( l->linkFileKnown() && ( l->linkFile() == linkfile ))
537 || ( l->fileKnown() && ( l->file() == linkfile )) 537 || ( l->fileKnown() && ( l->file() == linkfile ))
538 || ( dl.fileKnown() && l->fileKnown() && ( dl.file() == l->file() )) ) { 538 || ( dl.fileKnown() && l->fileKnown() && ( dl.file() == l->file() )) ) {
539 delete item; 539 delete item;
540 did = TRUE; 540 did = TRUE;
541 } 541 }
542 item = (LauncherItem*)item->nextItem(); 542 item = (LauncherItem*)item->nextItem();
543 } 543 }
544 QListIterator<AppLnk> it(hidden); 544 QListIterator<AppLnk> it(hidden);
545 while ((l=it.current())) { 545 while ((l=it.current())) {
546 ++it; 546 ++it;
547 if ( ( l->linkFileKnown() && ( l->linkFile() == linkfile )) 547 if ( ( l->linkFileKnown() && ( l->linkFile() == linkfile ))
548 || ( l->file() == linkfile ) 548 || ( l->file() == linkfile )
549 || ( dl.fileKnown() && ( dl.file() == l->file() )) ) { 549 || ( dl.fileKnown() && ( dl.file() == l->file() )) ) {
550 hidden.removeRef(l); 550 hidden.removeRef(l);
551 did = TRUE; 551 did = TRUE;
552 } 552 }
553 } 553 }
554 return did; 554 return did;
555} 555}
556 556
557static QString docLinkInfo(const Categories& cats, DocLnk* doc) 557static QString docLinkInfo(const Categories& cats, DocLnk* doc)
558{ 558{
559 QString contents; 559 QString contents;
560 560
561 QFileInfo fi( doc->file() ); 561 QFileInfo fi( doc->file() );
562 if ( !fi.exists() ) 562 if ( !fi.exists() )
563 return contents; 563 return contents;
564 564
565 if ( doc->linkFileKnown() ) { 565 if ( doc->linkFileKnown() ) {
566 QString lfn = doc->linkFile(); 566 QString lfn = doc->linkFile();
567 QFile f( lfn ); 567 QFile f( lfn );
568 if ( f.open( IO_ReadOnly ) ) { 568 if ( f.open( IO_ReadOnly ) ) {
569 QTextStream ts( &f ); 569 QTextStream ts( &f );
570 ts.setEncoding( QTextStream::UnicodeUTF8 ); 570 ts.setEncoding( QTextStream::UnicodeUTF8 );
571 contents += ts.read(); 571 contents += ts.read();
572 f.close(); 572 f.close();
573 goto calcsize; 573 goto calcsize;
574 } 574 }
575 } 575 }
576 576
577 contents += "[Desktop Entry]\n"; 577 contents += "[Desktop Entry]\n";
578 contents += "Categories = " // No tr 578 contents += "Categories = " // No tr
579 + cats.labels("Document View", doc->categories()).join(";") + "\n"; // No tr 579 + cats.labels("Document View", doc->categories()).join(";") + "\n"; // No tr
580 contents += "File = "+doc->file()+"\n"; // No tr 580 contents += "File = "+doc->file()+"\n"; // No tr
581 contents += "Name = "+doc->name()+"\n"; // No tr 581 contents += "Name = "+doc->name()+"\n"; // No tr
582 contents += "Type = "+doc->type()+"\n"; // No tr 582 contents += "Type = "+doc->type()+"\n"; // No tr
583 583
584calcsize: 584calcsize:
585 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 585 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
586 return contents; 586 return contents;
587} 587}
588 588
589QString LauncherIconView::getAllDocLinkInfo() const 589QString LauncherIconView::getAllDocLinkInfo() const
590{ 590{
591 QString contents; 591 QString contents;
592 LauncherItem* item = (LauncherItem*)firstItem(); 592 LauncherItem* item = (LauncherItem*)firstItem();
593 Categories cats; 593 Categories cats;
594 while (item) { 594 while (item) {
595 DocLnk* doc = (DocLnk*)item->appLnk(); 595 DocLnk* doc = (DocLnk*)item->appLnk();
596 contents += docLinkInfo(cats,doc); 596 contents += docLinkInfo(cats,doc);
597 item = (LauncherItem*)item->nextItem(); 597 item = (LauncherItem*)item->nextItem();
598 } 598 }
599 QListIterator<AppLnk> it(hidden); 599 QListIterator<AppLnk> it(hidden);
600 DocLnk* doc; 600 DocLnk* doc;
601 while ((doc=(DocLnk*)it.current())) { 601 while ((doc=(DocLnk*)it.current())) {
602 contents += docLinkInfo(cats,doc); 602 contents += docLinkInfo(cats,doc);
603 ++it; 603 ++it;
604 } 604 }
605 return contents; 605 return contents;
606} 606}
607 607
608//=========================================================================== 608//===========================================================================
609 609
610LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 610LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
611 : QVBox( parent, name, fl ) 611 : QVBox( parent, name, fl )
612{ 612{
613 icons = new LauncherIconView( this ); 613 icons = new LauncherIconView( this );
614 setFocusProxy(icons); 614 setFocusProxy(icons);
615 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 615 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
616 616
617 icons->setItemsMovable( FALSE ); 617 icons->setItemsMovable( FALSE );
618 icons->setAutoArrange( TRUE ); 618 icons->setAutoArrange( TRUE );
619 icons->setSorting( TRUE ); 619 icons->setSorting( TRUE );
620 icons->setFrameStyle( QFrame::NoFrame ); 620 icons->setFrameStyle( QFrame::NoFrame );
621 icons->setMargin( 0 ); 621 icons->setMargin( 0 );
622 icons->setSelectionMode( QIconView::NoSelection ); 622 icons->setSelectionMode( QIconView::NoSelection );
623 icons->setBackgroundMode( PaletteBase ); 623 icons->setBackgroundMode( PaletteBase );
624 icons->setResizeMode( QIconView::Fixed ); 624 icons->setResizeMode( QIconView::Fixed );
625 vmode = (ViewMode)-1; 625 vmode = (ViewMode)-1;
626 setViewMode( Icon ); 626 setViewMode( Icon );
627 627
628 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 628 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
629 SLOT(itemClicked(int, QIconViewItem *)) ); 629 SLOT(itemClicked(int, QIconViewItem *)) );
630 connect( icons, SIGNAL(selectionChanged()), 630 connect( icons, SIGNAL(selectionChanged()),
631 SLOT(selectionChanged()) ); 631 SLOT(selectionChanged()) );
632 connect( icons, SIGNAL(returnPressed(QIconViewItem *)), 632 connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
633 SLOT(returnPressed(QIconViewItem *)) ); 633 SLOT(returnPressed(QIconViewItem *)) );
634 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), 634 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
635 SLOT(itemPressed(int, QIconViewItem *)) ); 635 SLOT(itemPressed(int, QIconViewItem *)) );
636 636
637 tools = 0; 637 tools = 0;
638 setBackgroundType( Ruled, QString::null ); 638 setBackgroundType( Ruled, QString::null );
639} 639}
640 640
641LauncherView::~LauncherView() 641LauncherView::~LauncherView()
642{ 642{
643} 643}
644 644
645void LauncherView::setToolsEnabled(bool y) 645void LauncherView::setToolsEnabled(bool y)
646{ 646{
647 if ( !y != !tools ) { 647 if ( !y != !tools ) {
648 if ( y ) { 648 if ( y ) {
649 tools = new QHBox(this); 649 tools = new QHBox(this);
650 650
651 // Type filter 651 // Type filter
652 typemb = new QComboBox(tools); 652 typemb = new QComboBox(tools);
653 653
654 // Category filter 654 // Category filter
655 catmb = new CategorySelect(tools); 655 catmb = new CategorySelect(tools);
656 656
657 updateTools(); 657 updateTools();
658 tools->show(); 658 tools->show();
659 } else { 659 } else {
660 delete tools; 660 delete tools;
661 tools = 0; 661 tools = 0;
662 } 662 }
663 } 663 }
664} 664}
665 665
666void LauncherView::updateTools() 666void LauncherView::updateTools()
667{ 667{
668 disconnect( typemb, SIGNAL(activated(int)), 668 disconnect( typemb, SIGNAL(activated(int)),
669 this, SLOT(showType(int)) ); 669 this, SLOT(showType(int)) );
670 disconnect( catmb, SIGNAL(signalSelected(int)), 670 disconnect( catmb, SIGNAL(signalSelected(int)),
671 this, SLOT(showCategory(int)) ); 671 this, SLOT(showCategory(int)) );
672 672
673 icons->updateCategoriesAndMimeTypes(); 673 icons->updateCategoriesAndMimeTypes();
674 674
675 QString prev; 675 QString prev;
676 676
677 // Type filter 677 // Type filter
678 QStringList types; 678 QStringList types;
679 typelist = icons->mimeTypes(); 679 typelist = icons->mimeTypes();
680 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 680 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
681 QString t = *it; 681 QString t = *it;
682 if ( t.left(12) == "application/" ) { 682 if ( t.left(12) == "application/" ) {
683 MimeType mt(t); 683 MimeType mt(t);
684 const AppLnk* app = mt.application(); 684 const AppLnk* app = mt.application();
685 if ( app ) 685 if ( app )
686 t = app->name(); 686 t = app->name();
687 else 687 else
688 t = t.mid(12); 688 t = t.mid(12);
689 } else { 689 } else {
690 t[0] = t[0].upper(); 690 t[0] = t[0].upper();
691 } 691 }
692 types += tr("%1 files").arg(t); 692 types += tr("%1 files").arg(t);
693 } 693 }
694 types << tr("All types of file"); 694 types << tr("All types of file");
695 prev = typemb->currentText(); 695 prev = typemb->currentText();
696 typemb->clear(); 696 typemb->clear();
697 typemb->insertStringList(types); 697 typemb->insertStringList(types);
698 for (int i=0; i<typemb->count(); i++) { 698 for (int i=0; i<typemb->count(); i++) {
699 if ( typemb->text(i) == prev ) { 699 if ( typemb->text(i) == prev ) {
700 typemb->setCurrentItem(i); 700 typemb->setCurrentItem(i);
701 break; 701 break;
702 } 702 }
703 } 703 }
704 if ( prev.isNull() ) 704 if ( prev.isNull() )
705 typemb->setCurrentItem(typemb->count()-1); 705 typemb->setCurrentItem(typemb->count()-1);
706 706
707 Categories cats( 0 ); 707 Categories cats( 0 );
708 cats.load( categoryFileName() ); 708 cats.load( categoryFileName() );
709 QArray<int> vl( 0 ); 709 QArray<int> vl( 0 );
710 catmb->setCategories( vl, "Document View", // No tr 710 catmb->setCategories( vl, "Document View", // No tr
711 tr("Document View") ); 711 tr("Document View") );
712 catmb->setRemoveCategoryEdit( TRUE ); 712 catmb->setRemoveCategoryEdit( TRUE );
713 catmb->setAllCategories( TRUE ); 713 catmb->setAllCategories( TRUE );
714 714
715 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 715 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
716 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 716 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
717} 717}
718 718
719void LauncherView::sortBy(int s) 719void LauncherView::sortBy(int s)
720{ 720{
721 icons->setSortMethod((LauncherIconView::SortMethod)s); 721 icons->setSortMethod((LauncherIconView::SortMethod)s);
722} 722}
723 723
724void LauncherView::showType(int t) 724void LauncherView::showType(int t)
725{ 725{
726 if ( t >= (int)typelist.count() ) { 726 if ( t >= (int)typelist.count() ) {
727 icons->setTypeFilter("",TRUE); 727 icons->setTypeFilter("",TRUE);
728 } else { 728 } else {
729 QString ty = typelist[t]; 729 QString ty = typelist[t];
730 if ( !ty.contains('/') ) 730 if ( !ty.contains('/') )
731 ty += "/*"; 731 ty += "/*";
732 icons->setTypeFilter(ty,TRUE); 732 icons->setTypeFilter(ty,TRUE);
733 } 733 }
734} 734}
735 735
736void LauncherView::showCategory( int c ) 736void LauncherView::showCategory( int c )
737{ 737{
738 icons->setCategoryFilter( c, TRUE ); 738 icons->setCategoryFilter( c, TRUE );
739} 739}
740 740
741void LauncherView::setViewMode( ViewMode m ) 741void LauncherView::setViewMode( ViewMode m )
742{ 742{
743 if ( vmode != m ) { 743 if ( vmode != m ) {
744 bool bigIcons = m == Icon; 744 bool bigIcons = m == Icon;
745 icons->viewport()->setUpdatesEnabled( FALSE ); 745 icons->viewport()->setUpdatesEnabled( FALSE );
746 icons->setBigIcons( bigIcons ); 746 icons->setBigIcons( bigIcons );
747 switch ( m ) { 747 switch ( m ) {
748 case List: 748 case List:
749 icons->setItemTextPos( QIconView::Right ); 749 icons->setItemTextPos( QIconView::Right );
750 break; 750 break;
751 case Icon: 751 case Icon:
752 icons->setItemTextPos( QIconView::Bottom ); 752 icons->setItemTextPos( QIconView::Bottom );
753 break; 753 break;
754 } 754 }
755 icons->hideOrShowItems( FALSE ); 755 icons->hideOrShowItems( FALSE );
756 icons->viewport()->setUpdatesEnabled( TRUE ); 756 icons->viewport()->setUpdatesEnabled( TRUE );
757 vmode = m; 757 vmode = m;
758 } 758 }
759} 759}
760 760
761void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 761void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
762{ 762{
763 if ( !bgCache ) 763 if ( !bgCache )
764 bgCache = new QMap<QString,BgPixmap*>; 764 bgCache = new QMap<QString,BgPixmap*>;
765 if ( bgCache->contains( bgName ) ) 765 if ( bgCache->contains( bgName ) )
766 (*bgCache)[bgName]->ref--; 766 (*bgCache)[bgName]->ref--;
767 767
768 switch ( t ) { 768 switch ( t ) {
769 case Ruled: { 769 case Ruled: {
770 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 770 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
771 QPixmap bg; 771 QPixmap bg;
772 if ( bgCache->contains( bgName ) ) { 772 if ( bgCache->contains( bgName ) ) {
773 (*bgCache)[bgName]->ref++; 773 (*bgCache)[bgName]->ref++;
774 bg = (*bgCache)[bgName]->pm; 774 bg = (*bgCache)[bgName]->pm;
775 } else { 775 } else {
776 bg.resize( width(), 9 ); 776 bg.resize( width(), 9 );
777 QPainter painter( &bg ); 777 QPainter painter( &bg );
778 for ( int i = 0; i < 3; i++ ) { 778 for ( int i = 0; i < 3; i++ ) {
779 painter.setPen( white ); 779 painter.setPen( white );
780 painter.drawLine( 0, i*3, width()-1, i*3 ); 780 painter.drawLine( 0, i*3, width()-1, i*3 );
781 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 781 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
782 painter.setPen( colorGroup().background().light(105) ); 782 painter.setPen( colorGroup().background().light(105) );
783 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 783 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
784 } 784 }
785 painter.end(); 785 painter.end();
786 bgCache->insert( bgName, new BgPixmap(bg) ); 786 bgCache->insert( bgName, new BgPixmap(bg) );
787 } 787 }
788 icons->setBackgroundPixmap( bg ); 788 icons->setBackgroundPixmap( bg );
789 break; 789 break;
790 } 790 }
791 791
792 case SolidColor: 792 case SolidColor:
793 icons->setBackgroundPixmap( QPixmap() ); 793 icons->setBackgroundPixmap( QPixmap() );
794 if ( val.isEmpty() ) { 794 if ( val.isEmpty() ) {
795 icons->setBackgroundColor( colorGroup().base() ); 795 icons->setBackgroundColor( colorGroup().base() );
796 } else { 796 } else {
797 icons->setBackgroundColor( val ); 797 icons->setBackgroundColor( val );
798 } 798 }
799 bgName = ""; 799 bgName = "";
800 break; 800 break;
801 801
802 case Image: 802 case Image:
803 bgName = val; 803 bgName = val;
804 if ( bgCache->contains( bgName ) ) { 804 if ( bgCache->contains( bgName ) ) {
805 (*bgCache)[bgName]->ref++; 805 (*bgCache)[bgName]->ref++;
806 icons->setBackgroundPixmap( (*bgCache)[bgName]->pm ); 806 icons->setBackgroundPixmap( (*bgCache)[bgName]->pm );
807 } else { 807 } else {
808 qDebug( "Loading image: %s", val.latin1() );
809 QPixmap bg( Resource::loadPixmap( val ) ); 808 QPixmap bg( Resource::loadPixmap( val ) );
810 if ( bg.isNull() ) { 809 if ( bg.isNull() ) {
811 QImageIO imgio; 810 QImageIO imgio;
812 imgio.setFileName( bgName ); 811 imgio.setFileName( bgName );
813 QSize ds = qApp->desktop()->size(); 812 QSize ds = qApp->desktop()->size();
814 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 813 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
815 imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() ); 814 imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() );
816 imgio.read(); 815 imgio.read();
817 bg = imgio.image(); 816 bg = imgio.image();
818 } 817 }
819 bgCache->insert( bgName, new BgPixmap(bg) ); 818 bgCache->insert( bgName, new BgPixmap(bg) );
820 icons->setBackgroundPixmap( bg ); 819 icons->setBackgroundPixmap( bg );
821 } 820 }
822 break; 821 break;
823 } 822 }
824 823
825 // remove unreferenced backgrounds. 824 // remove unreferenced backgrounds.
826 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 825 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
827 while ( it != bgCache->end() ) { 826 while ( it != bgCache->end() ) {
828 QMap<QString,BgPixmap*>::Iterator curr = it; 827 QMap<QString,BgPixmap*>::Iterator curr = it;
829 ++it; 828 ++it;
830 if ( (*curr)->ref == 0 ) { 829 if ( (*curr)->ref == 0 ) {
831 delete (*curr); 830 delete (*curr);
832 bgCache->remove( curr ); 831 bgCache->remove( curr );
833 } 832 }
834 } 833 }
835 834
836 bgType = t; 835 bgType = t;
837 icons->viewport()->update(); 836 icons->viewport()->update();
838} 837}
839 838
840void LauncherView::setTextColor( const QColor &tc ) 839void LauncherView::setTextColor( const QColor &tc )
841{ 840{
842 textCol = tc; 841 textCol = tc;
843 QColorGroup cg = icons->colorGroup(); 842 QColorGroup cg = icons->colorGroup();
844 cg.setColor( QColorGroup::Text, tc ); 843 cg.setColor( QColorGroup::Text, tc );
845 icons->setPalette( QPalette(cg,cg,cg) ); 844 icons->setPalette( QPalette(cg,cg,cg) );
846 icons->viewport()->update(); 845 icons->viewport()->update();
847} 846}
848 847
849void LauncherView::setViewFont( const QFont &f ) 848void LauncherView::setViewFont( const QFont &f )
850{ 849{
851 icons->setFont( f ); 850 icons->setFont( f );
852} 851}
853 852
854void LauncherView::unsetViewFont( ) 853void LauncherView::unsetViewFont( )
855{ 854{
856 icons->unsetFont( ); 855 icons->unsetFont( );
857} 856}
858 857
859void LauncherView::resizeEvent(QResizeEvent *e) 858void LauncherView::resizeEvent(QResizeEvent *e)
860{ 859{
861 QVBox::resizeEvent( e ); 860 QVBox::resizeEvent( e );
862 if ( e->size().width() != e->oldSize().width() ) 861 if ( e->size().width() != e->oldSize().width() )
863 sort(); 862 sort();
864} 863}
865 864
866void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) 865void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
867{ 866{
868 icons->clear(); 867 icons->clear();
869 internalPopulate( folder, typefilter ); 868 internalPopulate( folder, typefilter );
870} 869}
871 870
872QString LauncherView::getAllDocLinkInfo() const 871QString LauncherView::getAllDocLinkInfo() const
873{ 872{
874 return icons->getAllDocLinkInfo(); 873 return icons->getAllDocLinkInfo();
875} 874}
876 875
877void LauncherView::selectionChanged() 876void LauncherView::selectionChanged()
878{ 877{
879 QIconViewItem* item = icons->currentItem(); 878 QIconViewItem* item = icons->currentItem();
880 if ( item && item->isSelected() ) { 879 if ( item && item->isSelected() ) {
881 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 880 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
882 if ( icons->inKeyEvent() ) // not for mouse press 881 if ( icons->inKeyEvent() ) // not for mouse press
883 emit clicked( appLnk ); 882 emit clicked( appLnk );
884 item->setSelected(FALSE); 883 item->setSelected(FALSE);
885 } 884 }
886} 885}
887 886
888void LauncherView::returnPressed( QIconViewItem *item ) 887void LauncherView::returnPressed( QIconViewItem *item )
889{ 888{
890 if ( item ) { 889 if ( item ) {
891 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 890 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
892 emit clicked( appLnk ); 891 emit clicked( appLnk );
893 } 892 }
894} 893}
895 894
896void LauncherView::itemClicked( int btn, QIconViewItem *item ) 895void LauncherView::itemClicked( int btn, QIconViewItem *item )
897{ 896{
898 if ( item ) { 897 if ( item ) {
899 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 898 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
900 if ( btn == LeftButton ) { 899 if ( btn == LeftButton ) {
901 // Make sure it's the item we execute that gets highlighted 900 // Make sure it's the item we execute that gets highlighted
902 icons->setCurrentItem( item ); 901 icons->setCurrentItem( item );
903 emit clicked( appLnk ); 902 emit clicked( appLnk );
904 } 903 }
905 item->setSelected(FALSE); 904 item->setSelected(FALSE);
906 } 905 }
907} 906}
908 907
909void LauncherView::itemPressed( int btn, QIconViewItem *item ) 908void LauncherView::itemPressed( int btn, QIconViewItem *item )
910{ 909{
911 if ( item ) { 910 if ( item ) {
912 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 911 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
913 if ( btn == RightButton ) 912 if ( btn == RightButton )
914 emit rightPressed( appLnk ); 913 emit rightPressed( appLnk );
915/* 914/*
916 else if ( btn == LeftButton ) 915 else if ( btn == LeftButton )
917 emit clicked( appLnk ); 916 emit clicked( appLnk );
918*/ 917*/
919 item->setSelected(FALSE); 918 item->setSelected(FALSE);
920 } 919 }
921} 920}
922 921
923void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) 922void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter )
924{ 923{
925 QListIterator<AppLnk> it( folder->children() ); 924 QListIterator<AppLnk> it( folder->children() );
926 icons->setTypeFilter(typefilter,FALSE); 925 icons->setTypeFilter(typefilter,FALSE);
927 926
928 while ( it.current() ) { 927 while ( it.current() ) {
929 // show only the icons for existing files 928 // show only the icons for existing files
930 if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) { 929 if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) {
931 icons->addItem(*it,FALSE); 930 icons->addItem(*it,FALSE);
932 } 931 }
933 else { 932 else {
934 //maybe insert some .desktop file deletion code later 933 //maybe insert some .desktop file deletion code later
935 //maybe dir specific 934 //maybe dir specific
936 } 935 }
937 ++it; 936 ++it;
938 } 937 }
939 938
940 icons->sort(); 939 icons->sort();
941} 940}
942 941
943bool LauncherView::removeLink(const QString& linkfile) 942bool LauncherView::removeLink(const QString& linkfile)
944{ 943{
945 return icons->removeLink(linkfile); 944 return icons->removeLink(linkfile);
946} 945}
947 946
948void LauncherView::sort() 947void LauncherView::sort()
949{ 948{
950 icons->sort(); 949 icons->sort();
951} 950}
952 951
953void LauncherView::addItem(AppLnk* app, bool resort) 952void LauncherView::addItem(AppLnk* app, bool resort)
954{ 953{
955 icons->addItem(app,resort); 954 icons->addItem(app,resort);
956} 955}
957 956
958void LauncherView::setFileSystems(const QList<FileSystem> &) 957void LauncherView::setFileSystems(const QList<FileSystem> &)
959{ 958{
960 // ### does nothing now... 959 // ### does nothing now...
961} 960}
962 961
963void LauncherView::paletteChange( const QPalette &p ) 962void LauncherView::paletteChange( const QPalette &p )
964{ 963{
965 icons->unsetPalette(); 964 icons->unsetPalette();
966 QVBox::paletteChange( p ); 965 QVBox::paletteChange( p );
967 if ( bgType == Ruled ) 966 if ( bgType == Ruled )
968 setBackgroundType( Ruled, QString::null ); 967 setBackgroundType( Ruled, QString::null );
969 QColorGroup cg = icons->colorGroup(); 968 QColorGroup cg = icons->colorGroup();
970 cg.setColor( QColorGroup::Text, textCol ); 969 cg.setColor( QColorGroup::Text, textCol );
971 icons->setPalette( QPalette(cg,cg,cg) ); 970 icons->setPalette( QPalette(cg,cg,cg) );
972} 971}
973 972
974 973
975void LauncherView::setBusyIndicatorType ( const QString &type ) 974void LauncherView::setBusyIndicatorType ( const QString &type )
976{ 975{
977 if ( type. lower ( ) == "blink" ) 976 if ( type. lower ( ) == "blink" )
978 icons-> setBusyIndicatorType ( BIT_Blinking ); 977 icons-> setBusyIndicatorType ( BIT_Blinking );
979 else 978 else
980 icons-> setBusyIndicatorType ( BIT_Normal ); 979 icons-> setBusyIndicatorType ( BIT_Normal );
981} 980}
982 981