summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 68e3245..ed39720 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -33,239 +33,239 @@
33#include <qdict.h> 33#include <qdict.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qfileinfo.h> 35#include <qfileinfo.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qiconview.h> 37#include <qiconview.h>
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41 41
42class LauncherIconView : public QIconView { 42class LauncherIconView : public QIconView {
43public: 43public:
44 LauncherIconView( QWidget* parent, const char* name=0 ) : 44 LauncherIconView( QWidget* parent, const char* name=0 ) :
45 QIconView(parent,name), 45 QIconView(parent,name),
46 tf(""), 46 tf(""),
47 cf(0), 47 cf(0),
48 bsy(0) 48 bsy(0)
49 { 49 {
50 sortmeth = Name; 50 sortmeth = Name;
51 hidden.setAutoDelete(TRUE); 51 hidden.setAutoDelete(TRUE);
52 ike = FALSE; 52 ike = FALSE;
53 } 53 }
54 54
55 ~LauncherIconView() 55 ~LauncherIconView()
56 { 56 {
57#if 0 // debuggery 57#if 0 // debuggery
58 QListIterator<AppLnk> it(hidden); 58 QListIterator<AppLnk> it(hidden);
59 AppLnk* l; 59 AppLnk* l;
60 while ((l=it.current())) { 60 while ((l=it.current())) {
61 ++it; 61 ++it;
62 //qDebug("%p: hidden (should remove)",l); 62 //qDebug("%p: hidden (should remove)",l);
63 } 63 }
64#endif 64#endif
65 } 65 }
66 66
67 QIconViewItem* busyItem() const { return bsy; } 67 QIconViewItem* busyItem() const { return bsy; }
68 68
69 void updateCategoriesAndMimeTypes(); 69 void updateCategoriesAndMimeTypes();
70 70
71 void doAutoScroll() 71 void doAutoScroll()
72 { 72 {
73 // We don't want rubberbanding (yet) 73 // We don't want rubberbanding (yet)
74 } 74 }
75 75
76 void setBusy(bool on) 76 void setBusy(bool on)
77 { 77 {
78 QIconViewItem *c = on ? currentItem() : 0; 78 QIconViewItem *c = on ? currentItem() : 0;
79 if ( bsy != c ) { 79 if ( bsy != c ) {
80 QIconViewItem* o = bsy; 80 QIconViewItem* o = bsy;
81 bsy = c; 81 bsy = c;
82 if ( o ) o->repaint(); 82 if ( o ) o->repaint();
83 if ( c ) c->repaint(); 83 if ( c ) c->repaint();
84 } 84 }
85 } 85 }
86 86
87 bool inKeyEvent() const { return ike; } 87 bool inKeyEvent() const { return ike; }
88 void keyPressEvent(QKeyEvent* e) 88 void keyPressEvent(QKeyEvent* e)
89 { 89 {
90 ike = TRUE; 90 ike = TRUE;
91 if ( e->key() == Key_F33 ) { 91 if ( e->key() == Key_F33 ) {
92 // "OK" button 92 // "OK" button
93 returnPressed(currentItem()); 93 returnPressed(currentItem());
94 } 94 }
95 QIconView::keyPressEvent(e); 95 QIconView::keyPressEvent(e);
96 ike = FALSE; 96 ike = FALSE;
97 } 97 }
98 98
99 void addItem(AppLnk* app, bool resort=TRUE); 99 void addItem(AppLnk* app, bool resort=TRUE);
100 bool removeLink(const QString& linkfile); 100 bool removeLink(const QString& linkfile);
101 101
102 QStringList mimeTypes() const; 102 QStringList mimeTypes() const;
103 QStringList categories() const; 103 QStringList categories() const;
104 104
105 void clear() 105 void clear()
106 { 106 {
107 mimes.clear(); 107 mimes.clear();
108 cats.clear(); 108 cats.clear();
109 QIconView::clear(); 109 QIconView::clear();
110 hidden.clear(); 110 hidden.clear();
111 } 111 }
112 112
113 void addCatsAndMimes(AppLnk* app) 113 void addCatsAndMimes(AppLnk* app)
114 { 114 {
115 // QStringList c = app->categories(); 115 // QStringList c = app->categories();
116 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 116 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
117 // cats.replace(*cit,(void*)1); 117 // cats.replace(*cit,(void*)1);
118 // } 118 // }
119 QString maj=app->type(); 119 QString maj=app->type();
120 int sl=maj.find('/'); 120 int sl=maj.find('/');
121 if (sl>=0) { 121 if (sl>=0) {
122 QString k = maj.left(sl); 122 QString k = maj.left(sl);
123 mimes.replace(k,(void*)1); 123 mimes.replace(k,(void*)1);
124 } 124 }
125 } 125 }
126 126
127 void drawBackground( QPainter *p, const QRect &r ) 127 void drawBackground( QPainter *p, const QRect &r )
128 { 128 {
129 //int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; 129 int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0;
130 int backgroundMode = 2; 130 //int backgroundMode = 2;
131 131
132 if ( backgroundMode == 1 ) { 132 if ( backgroundMode == 1 ) {
133 133
134 // Double buffer the background 134 // Double buffer the background
135 static QPixmap *bg = NULL; 135 static QPixmap *bg = NULL;
136 static QColor bgColor; 136 static QColor bgColor;
137 137
138 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { 138 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) {
139 // Create a new background double buffer 139 // Create a new background double buffer
140 if (bg == NULL) 140 if (bg == NULL)
141 bg = new QPixmap( width(), height() ); 141 bg = new QPixmap( width(), height() );
142 bgColor = colorGroup().button(); 142 bgColor = colorGroup().button();
143 QPainter painter( bg ); 143 QPainter painter( bg );
144 144
145 painter.fillRect( QRect( 0, 0, width(), height() ), QBrush( white ) ); 145 painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110));
146 146
147 // Overlay the Qtopia logo in the center 147 // Overlay the Qtopia logo in the center
148 QImage logo = Resource::loadImage( "qpe-logo" ); 148 QImage logo = Resource::loadImage( "qpe-background" );
149 if ( !logo.isNull() ) 149 if ( !logo.isNull() )
150 painter.drawImage( (width() - logo.width()) / 2, 150 painter.drawImage( (width() - logo.width()) / 2,
151 (height() - logo.height()) / 2, logo ); 151 (height() - logo.height()) / 2, logo );
152 } 152 }
153 153
154 // Draw the double buffer to the widget (it is tiled for when the icon view is large) 154 // Draw the double buffer to the widget (it is tiled for when the icon view is large)
155 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), 155 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
156 (r.y() + contentsY()) % bg->height() ) ); 156 (r.y() + contentsY()) % bg->height() ) );
157 } else if ( backgroundMode == 2 ) { 157 } else if ( backgroundMode == 2 ) {
158 static QPixmap *bg = 0; 158 static QPixmap *bg = 0;
159 static QColor bgColor; 159 static QColor bgColor;
160 if ( !bg || (bgColor != colorGroup().background()) ) { 160 if ( !bg || (bgColor != colorGroup().background()) ) {
161 bgColor = colorGroup().background(); 161 bgColor = colorGroup().background();
162 bg = new QPixmap( width(), 9 ); 162 bg = new QPixmap( width(), 9 );
163 QPainter painter( bg ); 163 QPainter painter( bg );
164 for ( int i = 0; i < 3; i++ ) { 164 for ( int i = 0; i < 3; i++ ) {
165 painter.setPen( white ); 165 painter.setPen( colorGroup().background().light(130) );
166 painter.drawLine( 0, i*3, width()-1, i*3 ); 166 painter.drawLine( 0, i*3, width()-1, i*3 );
167 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 167 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
168 painter.setPen( colorGroup().background().light(105) ); 168 painter.setPen( colorGroup().background().light(105) );
169 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 169 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
170 } 170 }
171 } 171 }
172 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), 172 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
173 (r.y() + contentsY()) % bg->height() ) ); 173 (r.y() + contentsY()) % bg->height() ) );
174 } else { 174 } else {
175 p->fillRect( r, QBrush( white ) ); 175 p->fillRect( r, QBrush( colorGroup().background().light(110) ) );
176 } 176 }
177 } 177 }
178 178
179 void hideOrShowItems(bool resort); 179 void hideOrShowItems(bool resort);
180 180
181 void setTypeFilter(const QString& typefilter, bool resort) 181 void setTypeFilter(const QString& typefilter, bool resort)
182 { 182 {
183 tf = QRegExp(typefilter,FALSE,TRUE); 183 tf = QRegExp(typefilter,FALSE,TRUE);
184 hideOrShowItems(resort); 184 hideOrShowItems(resort);
185 } 185 }
186 186
187 void setCategoryFilter( int catfilter, bool resort ) 187 void setCategoryFilter( int catfilter, bool resort )
188 { 188 {
189 Categories cat; 189 Categories cat;
190 cat.load( categoryFileName() ); 190 cat.load( categoryFileName() );
191 QString str; 191 QString str;
192 if ( catfilter == -2 ) 192 if ( catfilter == -2 )
193 cf = 0; 193 cf = 0;
194 else 194 else
195 cf = catfilter; 195 cf = catfilter;
196 hideOrShowItems(resort); 196 hideOrShowItems(resort);
197 } 197 }
198 198
199 enum SortMethod { Name, Date, Type }; 199 enum SortMethod { Name, Date, Type };
200 200
201 void setSortMethod( SortMethod m ) 201 void setSortMethod( SortMethod m )
202 { 202 {
203 if ( sortmeth != m ) { 203 if ( sortmeth != m ) {
204 sortmeth = m; 204 sortmeth = m;
205 sort(); 205 sort();
206 } 206 }
207 } 207 }
208 208
209 int compare(const AppLnk* a, const AppLnk* b) 209 int compare(const AppLnk* a, const AppLnk* b)
210 { 210 {
211 switch (sortmeth) { 211 switch (sortmeth) {
212 case Name: 212 case Name:
213 return a->name().compare(b->name()); 213 return a->name().compare(b->name());
214 case Date: { 214 case Date: {
215 QFileInfo fa(a->linkFile()); 215 QFileInfo fa(a->linkFile());
216 if ( !fa.exists() ) fa.setFile(a->file()); 216 if ( !fa.exists() ) fa.setFile(a->file());
217 QFileInfo fb(b->linkFile()); 217 QFileInfo fb(b->linkFile());
218 if ( !fb.exists() ) fb.setFile(b->file()); 218 if ( !fb.exists() ) fb.setFile(b->file());
219 return fa.lastModified().secsTo(fb.lastModified()); 219 return fa.lastModified().secsTo(fb.lastModified());
220 } 220 }
221 case Type: 221 case Type:
222 return a->type().compare(b->type()); 222 return a->type().compare(b->type());
223 } 223 }
224 return 0; 224 return 0;
225 } 225 }
226 226
227protected: 227protected:
228 228
229 void styleChange( QStyle &old ) 229 void styleChange( QStyle &old )
230 { 230 {
231 QIconView::styleChange( old ); 231 QIconView::styleChange( old );
232 //### duplicated code from LauncherView constructor 232 //### duplicated code from LauncherView constructor
233 int dw = QApplication::desktop()->width(); 233 int dw = QApplication::desktop()->width();
234 setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 234 setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240
235 } 235 }
236 236
237private: 237private:
238 QList<AppLnk> hidden; 238 QList<AppLnk> hidden;
239 QDict<void> mimes; 239 QDict<void> mimes;
240 QDict<void> cats; 240 QDict<void> cats;
241 SortMethod sortmeth; 241 SortMethod sortmeth;
242 QRegExp tf; 242 QRegExp tf;
243 int cf; 243 int cf;
244 QIconViewItem* bsy; 244 QIconViewItem* bsy;
245 bool ike; 245 bool ike;
246 246
247}; 247};
248 248
249 249
250bool LauncherView::bsy=FALSE; 250bool LauncherView::bsy=FALSE;
251 251
252void LauncherView::setBusy(bool on) 252void LauncherView::setBusy(bool on)
253{ 253{
254 icons->setBusy(on); 254 icons->setBusy(on);
255} 255}
256 256
257class LauncherItem : public QIconViewItem 257class LauncherItem : public QIconViewItem
258{ 258{
259public: 259public:
260 LauncherItem( QIconView *parent, AppLnk* applnk ); 260 LauncherItem( QIconView *parent, AppLnk* applnk );
261 ~LauncherItem() 261 ~LauncherItem()
262 { 262 {
263 LauncherIconView* liv = (LauncherIconView*)iconView(); 263 LauncherIconView* liv = (LauncherIconView*)iconView();
264 if ( liv->busyItem() == this ) 264 if ( liv->busyItem() == this )
265 liv->setBusy(FALSE); 265 liv->setBusy(FALSE);
266 delete app; 266 delete app;
267 } 267 }
268 268
269 AppLnk* appLnk() const { return app; } 269 AppLnk* appLnk() const { return app; }
270 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } 270 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; }
271 271