summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-12 02:13:52 (UTC)
committer alwin <alwin>2005-03-12 02:13:52 (UTC)
commitcd1b9f7c11c73ef0df0ce66c53466c979a3a4d42 (patch) (unidiff)
treed4ed9b082abe2aa645fbd58b86d65f5ce9c48348
parent84af289057291a49a52a60b390bc5320c02b5a55 (diff)
downloadopie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.zip
opie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.tar.gz
opie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.tar.bz2
And I'm wondering why opie sometimes is that slow. Hopefully reduced
the calls to opie-eye for images in documenttab when changing layout and so on.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp34
-rw-r--r--core/launcher/launcherview.h4
2 files changed, 31 insertions, 7 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index a4c7561..d960908 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -98,63 +98,65 @@ public:
98 void setEyePixmap(const QPixmap&aIcon); 98 void setEyePixmap(const QPixmap&aIcon);
99 virtual QPixmap*pixmap()const; 99 virtual QPixmap*pixmap()const;
100 100
101protected: 101protected:
102 bool isBigIcon; 102 bool isBigIcon;
103 int iteration; 103 int iteration;
104 AppLnk* app; 104 AppLnk* app;
105 105
106private: 106private:
107 void paintAnimatedIcon( QPainter *p ); 107 void paintAnimatedIcon( QPainter *p );
108 BusyIndicatorType busyType; 108 BusyIndicatorType busyType;
109 int psize; 109 int psize;
110 bool m_EyeImage; 110 bool m_EyeImage;
111 iconstate_t m_EyeImageSet; 111 iconstate_t m_EyeImageSet;
112}; 112};
113 113
114static bool s_IgnoreNextPix = false;
115
114LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 116LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
115 : QIconViewItem( parent, applnk->name(), 117 : QIconViewItem( parent, applnk->name(),
116 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 118 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
117 isBigIcon( bigIcon ), 119 isBigIcon( bigIcon ),
118 iteration(0), 120 iteration(0),
119 app(applnk), // Takes ownership 121 app(applnk), // Takes ownership
120 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), 122 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
121 m_EyeImage(false), 123 m_EyeImage(false),
122 m_EyeImageSet(BASE_ICON) 124 m_EyeImageSet(BASE_ICON)
123{ 125{
124 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { 126 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
125 m_EyeImage = true; 127 m_EyeImage = true;
126 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); 128 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file());
127 if (it != LauncherIconView::sm_EyeCache->end()) { 129 if (it != LauncherIconView::sm_EyeCache->end()) {
128 m_EyeImageSet = EYE_ICON; 130 m_EyeImageSet = EYE_ICON;
129 setPixmap(*it); 131 setPixmap(*it);
130 } 132 }
131 } 133 }
132} 134}
133 135
134LauncherItem::~LauncherItem() 136LauncherItem::~LauncherItem()
135{ 137{
136 LauncherIconView* liv = (LauncherIconView*)iconView(); 138 LauncherIconView* liv = (LauncherIconView*)iconView();
137 if ( liv->busyItem() == this ) 139 if ( liv->busyItem() == this )
138 liv->setBusy(FALSE); 140 liv->setBusy(FALSE);
139 delete app; 141 delete app;
140} 142}
141 143
142QPixmap*LauncherItem::pixmap()const 144QPixmap*LauncherItem::pixmap()const
143{ 145{
144 if (m_EyeImage && m_EyeImageSet == BASE_ICON) { 146 if (m_EyeImage && m_EyeImageSet == BASE_ICON && s_IgnoreNextPix==false) {
145 LauncherIconView* liv = (LauncherIconView*)iconView(); 147 LauncherIconView* liv = (LauncherIconView*)iconView();
146 liv->requestEyePix(this); 148 liv->requestEyePix(this);
147 } 149 }
148 return QIconViewItem::pixmap(); 150 return QIconViewItem::pixmap();
149} 151}
150 152
151int LauncherItem::compare ( QIconViewItem * i ) const 153int LauncherItem::compare ( QIconViewItem * i ) const
152{ 154{
153 LauncherIconView* view = (LauncherIconView*)iconView(); 155 LauncherIconView* view = (LauncherIconView*)iconView();
154 return view->compare(app,((LauncherItem *)i)->appLnk()); 156 return view->compare(app,((LauncherItem *)i)->appLnk());
155} 157}
156 158
157void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 159void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
158{ 160{
159 LauncherIconView* liv = (LauncherIconView*)iconView(); 161 LauncherIconView* liv = (LauncherIconView*)iconView();
160 QBrush oldBrush( liv->itemTextBackground() ); 162 QBrush oldBrush( liv->itemTextBackground() );
@@ -281,62 +283,76 @@ void LauncherItem::setEyePixmap(const QPixmap&aIcon)
281//=========================================================================== 283//===========================================================================
282 284
283QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; 285QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0;
284 286
285LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 287LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
286 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0) 288 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0)
287{ 289{
288 m_EyeCallBack = 0; 290 m_EyeCallBack = 0;
289 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); 291 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>();
290 sortmeth = Name; 292 sortmeth = Name;
291 hidden.setAutoDelete(TRUE); 293 hidden.setAutoDelete(TRUE);
292 ike = FALSE; 294 ike = FALSE;
293 calculateGrid( Bottom ); 295 calculateGrid( Bottom );
294 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); 296 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
295 Config config( "Launcher" ); 297 Config config( "Launcher" );
296 config.setGroup( "GUI" ); 298 config.setGroup( "GUI" );
297 setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) ); 299 setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) );
298} 300}
299 301
300LauncherIconView::~LauncherIconView() 302LauncherIconView::~LauncherIconView()
301{ 303{
302 odebug << "LauncherIconView::~LauncherIconView()" << oendl; 304 odebug << "LauncherIconView::~LauncherIconView()" << oendl;
303#if 0 // debuggery 305#if 0 // debuggery
304 QListIterator<AppLnk> it(hidden); 306 QListIterator<AppLnk> it(hidden);
305 AppLnk* l; 307 AppLnk* l;
306 while ((l=it.current())) { 308 while ((l=it.current())) {
307 ++it; 309 ++it;
308 //odebug << "" << l << ": hidden (should remove)" << oendl; 310 //odebug << "" << l << ": hidden (should remove)" << oendl;
309 } 311 }
310#endif 312#endif
311} 313}
312 314
315void LauncherIconView::unsetPalette()
316{
317 s_IgnoreNextPix = true;
318 QIconView::unsetPalette();
319 s_IgnoreNextPix = false;
320}
321
322void LauncherIconView::setPalette(const QPalette & palette)
323{
324 s_IgnoreNextPix = true;
325 QIconView::setPalette(palette);
326 s_IgnoreNextPix = false;
327}
328
313void LauncherIconView::setStaticBackgroundPicture( bool enable ) 329void LauncherIconView::setStaticBackgroundPicture( bool enable )
314{ 330{
315 staticBackground = enable; 331 staticBackground = enable;
316 if ( staticBackground ) 332 if ( staticBackground )
317 { 333 {
318 setStaticBackground( true ); 334 setStaticBackground( true );
319 verticalScrollBar()->setTracking( false ); 335 verticalScrollBar()->setTracking( false );
320 } 336 }
321 else 337 else
322 { 338 {
323 setStaticBackground( false ); 339 setStaticBackground( false );
324 verticalScrollBar()->setTracking( true ); 340 verticalScrollBar()->setTracking( true );
325 } 341 }
326} 342}
327 343
328int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 344int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
329{ 345{
330 switch (sortmeth) { 346 switch (sortmeth) {
331 case Name: 347 case Name:
332 return a->name().lower().compare(b->name().lower()); 348 return a->name().lower().compare(b->name().lower());
333 case Date: { 349 case Date: {
334 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 350 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
335 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 351 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
336 return fa.lastModified().secsTo(fb.lastModified()); 352 return fa.lastModified().secsTo(fb.lastModified());
337 } 353 }
338 case Type: 354 case Type:
339 return a->type().compare(b->type()); 355 return a->type().compare(b->type());
340 } 356 }
341 return 0; 357 return 0;
342} 358}
@@ -473,34 +489,34 @@ LauncherItem*LauncherIconView::findDocItem(const QString&fname)
473void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) 489void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
474{ 490{
475 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 491 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
476 if (s!=width) return; 492 if (s!=width) return;
477 LauncherItem*item = findDocItem(aFile); 493 LauncherItem*item = findDocItem(aFile);
478 if (!item||!item->isEyeImage()) return; 494 if (!item||!item->isEyeImage()) return;
479 (*sm_EyeCache)[aFile]=aPixmap; 495 (*sm_EyeCache)[aFile]=aPixmap;
480 item->setEyePixmap(aPixmap); 496 item->setEyePixmap(aPixmap);
481} 497}
482 498
483void LauncherIconView::checkCallback() 499void LauncherIconView::checkCallback()
484{ 500{
485 if (!m_EyeCallBack) { 501 if (!m_EyeCallBack) {
486 m_EyeCallBack = new LauncherThumbReceiver(); 502 m_EyeCallBack = new LauncherThumbReceiver();
487 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 503 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
488 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 504 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
505 m_eyeTimer.changeInterval(600000);
489 } 506 }
490 m_eyeTimer.changeInterval(600000);
491} 507}
492 508
493void LauncherIconView::addCheckItem(AppLnk* app) 509void LauncherIconView::addCheckItem(AppLnk* app)
494{ 510{
495 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 511 LauncherItem*item = new LauncherItem( this, app, bigIcns );
496 if (item->isEyeImage()) { 512 if (item->isEyeImage()) {
497 checkCallback(); 513 checkCallback();
498 } 514 }
499} 515}
500 516
501void LauncherIconView::requestEyePix(const LauncherItem*item) 517void LauncherIconView::requestEyePix(const LauncherItem*item)
502{ 518{
503 if (!item) return; 519 if (!item) return;
504 if (item->isEyeImage()) { 520 if (item->isEyeImage()) {
505 checkCallback(); 521 checkCallback();
506 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 522 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
@@ -1195,34 +1211,36 @@ void LauncherView::flushBgCache()
1195 1211
1196/* 1212/*
1197 * Launcherthumbnail handling for image files 1213 * Launcherthumbnail handling for image files
1198 */ 1214 */
1199 1215
1200/* special image handling - based on opie eye */ 1216/* special image handling - based on opie eye */
1201QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 1217QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1202 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 1218 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1203 return s; 1219 return s;
1204} 1220}
1205 1221
1206QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 1222QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1207 return s << inf.file << inf.width << inf.height; 1223 return s << inf.file << inf.width << inf.height;
1208} 1224}
1209 1225
1210LauncherThumbReceiver::LauncherThumbReceiver() 1226LauncherThumbReceiver::LauncherThumbReceiver()
1211 :QObject() 1227 :QObject(),requestTimer(this)
1212{ 1228{
1229
1230 connect(&requestTimer,SIGNAL(timeout()),SLOT(sendRequest()));
1213 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); 1231 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1214 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 1232 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1215 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 1233 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1216 1234
1217 { 1235 {
1218 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 1236 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1219 } 1237 }
1220} 1238}
1221 1239
1222LauncherThumbReceiver::~LauncherThumbReceiver() 1240LauncherThumbReceiver::~LauncherThumbReceiver()
1223{ 1241{
1224 { 1242 {
1225 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 1243 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1226 } 1244 }
1227} 1245}
1228 1246
@@ -1234,27 +1252,29 @@ void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1234 /* we are just interested in thumbmails */ 1252 /* we are just interested in thumbmails */
1235 if ( str == "pixmapsHandled(PixmapList)" ) 1253 if ( str == "pixmapsHandled(PixmapList)" )
1236 stream >> pixinfos; 1254 stream >> pixinfos;
1237 1255
1238 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { 1256 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1239 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); 1257 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
1240 } 1258 }
1241} 1259}
1242 1260
1243void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) 1261void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1244{ 1262{
1245 PixmapInfo rItem; 1263 PixmapInfo rItem;
1246 rItem.file = file; 1264 rItem.file = file;
1247 rItem.width = width; 1265 rItem.width = width;
1248 rItem.height = height; 1266 rItem.height = height;
1249 m_inThumbNail.append(rItem); 1267 m_inThumbNail.append(rItem);
1250 QTimer::singleShot(2, this, SLOT(sendRequest())); 1268 if (!requestTimer.isActive()) {
1269 requestTimer.start(100,true);
1270 }
1251} 1271}
1252 1272
1253void LauncherThumbReceiver::sendRequest() 1273void LauncherThumbReceiver::sendRequest()
1254{ 1274{
1255 if (m_inThumbNail.count()>0) { 1275 if (m_inThumbNail.count()>0) {
1256 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); 1276 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1257 env << m_inThumbNail; 1277 env << m_inThumbNail;
1258 m_inThumbNail.clear(); 1278 m_inThumbNail.clear();
1259 } 1279 }
1260} 1280}
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 6a2d197..792c6d1 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -140,32 +140,33 @@ class LauncherThumbReceiver:public QObject
140 Q_OBJECT 140 Q_OBJECT
141 typedef QValueList<PixmapInfo> PixmapInfos; 141 typedef QValueList<PixmapInfo> PixmapInfos;
142public: 142public:
143 LauncherThumbReceiver(); 143 LauncherThumbReceiver();
144 ~LauncherThumbReceiver(); 144 ~LauncherThumbReceiver();
145 void requestThumb(const QString&file,int width,int height); 145 void requestThumb(const QString&file,int width,int height);
146 146
147public slots: 147public slots:
148 void recieve( const QCString&, const QByteArray& ); 148 void recieve( const QCString&, const QByteArray& );
149protected slots: 149protected slots:
150 virtual void sendRequest(); 150 virtual void sendRequest();
151 151
152signals: 152signals:
153 void sig_Thumbnail(const QPixmap&,const QString&,int); 153 void sig_Thumbnail(const QPixmap&,const QString&,int);
154 154
155protected: 155protected:
156 QTimer requestTimer;
156 PixmapInfos m_inThumbNail; 157 PixmapInfos m_inThumbNail;
157}; 158};
158 159
159class LauncherIconView : public QIconView { 160class LauncherIconView : public QIconView {
160 Q_OBJECT 161 Q_OBJECT
161public: 162public:
162 LauncherIconView( QWidget* parent, const char* name=0 ); 163 LauncherIconView( QWidget* parent, const char* name=0 );
163 ~LauncherIconView(); 164 ~LauncherIconView();
164 QIconViewItem* busyItem() const; 165 QIconViewItem* busyItem() const;
165 166
166#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 167#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
167 QPixmap busyPixmap() const { return busyPix; } 168 QPixmap busyPixmap() const { return busyPix; }
168#endif 169#endif
169 void setBigIcons( bool bi ); 170 void setBigIcons( bool bi );
170 void updateCategoriesAndMimeTypes(); 171 void updateCategoriesAndMimeTypes();
171 void setBusyIndicatorType ( BusyIndicatorType t ); 172 void setBusyIndicatorType ( BusyIndicatorType t );
@@ -201,32 +202,35 @@ public:
201 202
202 void drawBackground( QPainter *p, const QRect &r ); 203 void drawBackground( QPainter *p, const QRect &r );
203 void setItemTextPos( ItemTextPos pos ); 204 void setItemTextPos( ItemTextPos pos );
204 void hideOrShowItems(bool resort); 205 void hideOrShowItems(bool resort);
205 206
206 void setTypeFilter(const QString& typefilter, bool resort); 207 void setTypeFilter(const QString& typefilter, bool resort);
207 void setCategoryFilter( int catfilter, bool resort ); 208 void setCategoryFilter( int catfilter, bool resort );
208 209
209 enum SortMethod { Name, Date, Type }; 210 enum SortMethod { Name, Date, Type };
210 211
211 void setSortMethod( SortMethod m ); 212 void setSortMethod( SortMethod m );
212 int compare(const AppLnk* a, const AppLnk* b); 213 int compare(const AppLnk* a, const AppLnk* b);
213 void requestEyePix(const LauncherItem*which); 214 void requestEyePix(const LauncherItem*which);
214 215
215 static QMap<QString,QPixmap>* sm_EyeCache; 216 static QMap<QString,QPixmap>* sm_EyeCache;
216 217
218 virtual void setPalette(const QPalette & palette);
219 virtual void unsetPalette();
220
217protected: 221protected:
218 virtual void timerEvent( QTimerEvent *te ); 222 virtual void timerEvent( QTimerEvent *te );
219 void styleChange( QStyle &old ); 223 void styleChange( QStyle &old );
220 void calculateGrid( ItemTextPos pos ); 224 void calculateGrid( ItemTextPos pos );
221 void focusInEvent( QFocusEvent * ) {} 225 void focusInEvent( QFocusEvent * ) {}
222 void focusOutEvent( QFocusEvent * ) {} 226 void focusOutEvent( QFocusEvent * ) {}
223 LauncherItem*findDocItem(const QString&); 227 LauncherItem*findDocItem(const QString&);
224 void addCheckItem(AppLnk* app); 228 void addCheckItem(AppLnk* app);
225 void checkCallback(); 229 void checkCallback();
226 virtual void keyPressEvent(QKeyEvent* e); 230 virtual void keyPressEvent(QKeyEvent* e);
227 231
228protected slots: 232protected slots:
229 void setEyePixmap(const QPixmap&,const QString&,int width); 233 void setEyePixmap(const QPixmap&,const QString&,int width);
230 void stopEyeTimer(); 234 void stopEyeTimer();
231 235
232private: 236private: