summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp145
-rw-r--r--core/pim/today/today.h2
2 files changed, 61 insertions, 86 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 1f758f2..2f6907d 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -3,3 +3,3 @@
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002,2003 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
@@ -72,3 +72,3 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
72 m_refreshTimer->start( 15000 ); 72 m_refreshTimer->start( 15000 );
73 init(); 73 //init();
74 loadPlugins(); 74 loadPlugins();
@@ -124,3 +124,2 @@ void Today::setOwnerField( QString &message ) {
124 124
125
126/** 125/**
@@ -140,4 +139,2 @@ void Today::init() {
140 139
141
142 // qDebug(" refresh ");
143 // set the date in top label 140 // set the date in top label
@@ -145,5 +142,4 @@ void Today::init() {
145 QString time = ( tr( date.toString() ) ); 142 QString time = ( tr( date.toString() ) );
146
147 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); 143 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) );
148 144
149 if ( layout ) { 145 if ( layout ) {
@@ -156,3 +152,2 @@ void Today::init() {
156 152
157
158/** 153/**
@@ -162,5 +157,3 @@ void Today::loadPlugins() {
162 157
163 // extra list for plugins that exclude themself from periodic refresh 158 init();
164 QMap<QString, TodayPlugin> pluginListRefreshExclude;
165
166 QValueList<TodayPlugin>::Iterator tit; 159 QValueList<TodayPlugin>::Iterator tit;
@@ -168,12 +161,7 @@ void Today::loadPlugins() {
168 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 161 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
169 if ( (*tit).excludeRefresh ) { 162 (*tit).guiBox->hide();
170 pluginListRefreshExclude.insert( (*tit).name , (*tit) ); 163 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) );
171 qDebug( "Found a plugin that does not want refresh feature" ); 164 (*tit).library->unload();
172 } else { 165 delete (*tit).guiBox;
173 (*tit).guiBox->hide(); 166 delete (*tit).library;
174 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) );
175 (*tit).library->unload();
176 delete (*tit).guiBox;
177 delete (*tit).library;
178 }
179 } 167 }
@@ -191,3 +179,2 @@ void Today::loadPlugins() {
191 for ( it = list.begin(); it != list.end(); ++it ) { 179 for ( it = list.begin(); it != list.end(); ++it ) {
192 //TodayPluginInterface *iface = 0;
193 QInterfacePtr<TodayPluginInterface> iface; 180 QInterfacePtr<TodayPluginInterface> iface;
@@ -200,67 +187,54 @@ void Today::loadPlugins() {
200 187
201 // If plugin is exludes from refresh, get it in the list again here. 188 TodayPlugin plugin;
189 plugin.library = lib;
190 plugin.iface = iface;
191 plugin.name = QString(*it);
202 192
203 if ( pluginListRefreshExclude.contains( (*it) ) ) { 193 // find out if plugins should be shown
204 // if its not in allApplets list, add it to a layout 194 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
205 if ( !m_allApplets.contains( pluginListRefreshExclude[(*it)].name ) ) { 195 plugin.active = true;
206 layout->addWidget( pluginListRefreshExclude[(*it)].guiBox );
207 pluginList.append( pluginListRefreshExclude[(*it)] );
208 } else {
209 tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] );
210 }
211 } else { 196 } else {
197 plugin.active = false;
198 }
212 199
213 TodayPlugin plugin; 200 plugin.guiPart = plugin.iface->guiPart();
214 plugin.library = lib; 201 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
215 plugin.iface = iface; 202
216 plugin.name = QString(*it); 203 // package the whole thing into a qwidget so it can be shown and hidden
217 204 plugin.guiBox = new QWidget( this );
218 // find out if plugins should be shown 205 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
219 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 206 QPixmap plugPix;
220 plugin.active = true; 207 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
221 } else { 208 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
222 plugin.active = false; 209 plugIcon->setPixmap( plugPix );
223 } 210 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
224 211 plugIcon->setName( plugin.guiPart->appName() );
225 plugin.guiPart = plugin.iface->guiPart(); 212 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
226 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 213 // a scrollview for each plugin
227 214 QScrollView* sv = new QScrollView( plugin.guiBox );
228 // package the whole thing into a qwidget so it can be shown and hidden 215 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() );
229 plugin.guiBox = new QWidget( this ); 216 // not sure if that is good .-)
230 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 217 sv->setMinimumHeight( 12 );
231 QPixmap plugPix; 218 sv->setResizePolicy( QScrollView::AutoOneFit );
232 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 219 sv->setHScrollBarMode( QScrollView::AlwaysOff );
233 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 220 sv->setFrameShape( QFrame::NoFrame );
234 plugIcon->setPixmap( plugPix ); 221 sv->addChild( plugWidget );
235 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 222 // make sure the icon is on the top alligned
236 plugIcon->setName( plugin.guiPart->appName() ); 223 boxLayout->addWidget( plugIcon, 0, AlignTop );
237 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 224 boxLayout->addWidget( sv, 0, AlignTop );
238 // a scrollview for each plugin 225 boxLayout->setStretchFactor( plugIcon, 1 );
239 QScrollView* sv = new QScrollView( plugin.guiBox ); 226 boxLayout->setStretchFactor( sv, 9 );
240 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); 227 // "prebuffer" it in one more list, to get the sorting done
241 // not sure if that is good .-) 228 tempList.insert( plugin.name, plugin );
242 sv->setMinimumHeight( 10 ); 229
243 sv->setResizePolicy( QScrollView::AutoOneFit ); 230 // on first start the list is off course empty
244 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 231 if ( m_allApplets.isEmpty() ) {
245 sv->setFrameShape( QFrame::NoFrame ); 232 layout->addWidget( plugin.guiBox );
246 sv->addChild( plugWidget ); 233 pluginList.append( plugin );
247 // make sure the icon is on the top alligned 234 }
248 boxLayout->addWidget( plugIcon, 0, AlignTop ); 235
249 boxLayout->addWidget( sv, 0, AlignTop ); 236 // if plugin is not yet in the list, add it to the layout too
250 boxLayout->setStretchFactor( plugIcon, 1 ); 237 else if ( !m_allApplets.contains( plugin.name ) ) {
251 boxLayout->setStretchFactor( sv, 9 ); 238 layout->addWidget( plugin.guiBox );
252 // "prebuffer" it in one more list, to get the sorting done 239 pluginList.append( plugin );
253 tempList.insert( plugin.name, plugin );
254
255 // on first start the list is off course empty
256 if ( m_allApplets.isEmpty() ) {
257 layout->addWidget( plugin.guiBox );
258 pluginList.append( plugin );
259 }
260
261 // if plugin is not yet in the list, add it to the layout too
262 else if ( !m_allApplets.contains( plugin.name ) ) {
263 layout->addWidget( plugin.guiBox );
264 pluginList.append( plugin );
265 }
266 } 240 }
@@ -372,2 +346,3 @@ void Today::startConfig() {
372void Today::refresh() { 346void Today::refresh() {
347
373 init(); 348 init();
@@ -379,3 +354,3 @@ void Today::refresh() {
379 qDebug( "refresh" ); 354 qDebug( "refresh" );
380 } 355 }
381 } 356 }
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index 35b7ee3..24f5611 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -3,3 +3,3 @@
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002,2003 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org