summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 3eda5c0..01ef02d 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -139,77 +139,86 @@ void Today::init() {
139} 139}
140 140
141 141
142/** 142/**
143 * Load the plugins 143 * Load the plugins
144 */ 144 */
145void Today::loadPlugins() { 145void Today::loadPlugins() {
146 146
147 // extra list for plugins that exclude themself from periodic refresh 147 // extra list for plugins that exclude themself from periodic refresh
148 QMap<QString, TodayPlugin> pluginListRefreshExclude; 148 QMap<QString, TodayPlugin> pluginListRefreshExclude;
149 149
150 QValueList<TodayPlugin>::Iterator tit; 150 QValueList<TodayPlugin>::Iterator tit;
151 if ( !pluginList.isEmpty() ) { 151 if ( !pluginList.isEmpty() ) {
152 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 152 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
153 if ( (*tit).excludeRefresh ) { 153 if ( (*tit).excludeRefresh ) {
154 pluginListRefreshExclude.insert( (*tit).name , (*tit) ); 154 pluginListRefreshExclude.insert( (*tit).name , (*tit) );
155 qDebug( "Found an plug that does not want refresh feature" ); 155 qDebug( "Found an plugin that does not want refresh feature" );
156 } else { 156 } else {
157 (*tit).library->unload(); 157 (*tit).library->unload();
158 delete (*tit).library; 158 delete (*tit).library;
159 } 159 }
160 } 160 }
161 pluginList.clear(); 161 pluginList.clear();
162 } 162 }
163 163
164 164
165 QString path = QPEApplication::qpeDir() + "/plugins/today"; 165 QString path = QPEApplication::qpeDir() + "/plugins/today";
166 QDir dir( path, "lib*.so" ); 166 QDir dir( path, "lib*.so" );
167 167
168 QStringList list = dir.entryList(); 168 QStringList list = dir.entryList();
169 QStringList::Iterator it; 169 QStringList::Iterator it;
170 170
171 QMap<QString, TodayPlugin> tempList; 171 QMap<QString, TodayPlugin> tempList;
172 172
173 for ( it = list.begin(); it != list.end(); ++it ) { 173 for ( it = list.begin(); it != list.end(); ++it ) {
174 TodayPluginInterface *iface = 0; 174 TodayPluginInterface *iface = 0;
175 QLibrary *lib = new QLibrary( path + "/" + *it ); 175 QLibrary *lib = new QLibrary( path + "/" + *it );
176 176
177 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 177 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
178 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 178 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
179 qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); 179 qDebug( "loading: %s", QString( path + "/" + *it ).latin1() );
180 qDebug( QString(*it) ); 180 qDebug( QString(*it) );
181 181
182 // If plugin is exludes from refresh, get it in the list again here. 182 // If plugin is exludes from refresh, get it in the list again here.
183 183
184 if ( pluginListRefreshExclude.contains( (*it) ) ) { 184 if ( pluginListRefreshExclude.contains( (*it) ) ) {
185 tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] ); 185
186 qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name ); 186 // if its not in allApplets list, add it to a layout
187 if ( !m_allApplets.contains( pluginListRefreshExclude[(*it)].name ) ) {
188 qDebug( "NUGASDA" );
189 layout->addWidget( pluginListRefreshExclude[(*it)].guiBox );
190 pluginList.append( pluginListRefreshExclude[(*it)] );
191 } else {
192 tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] );
193 qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name );
194 }
187 } else { 195 } else {
188 196
189 TodayPlugin plugin; 197 TodayPlugin plugin;
190 plugin.library = lib; 198 plugin.library = lib;
191 plugin.iface = iface; 199 plugin.iface = iface;
192 plugin.name = QString(*it); 200 plugin.name = QString(*it);
193 201
194 // find out if plugins should be shown 202 // find out if plugins should be shown
195 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 203 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
196 plugin.active = true; 204 plugin.active = true;
197 } else { 205 } else {
198 plugin.active = false; 206 plugin.active = false;
199 } 207 }
208
200 plugin.guiPart = plugin.iface->guiPart(); 209 plugin.guiPart = plugin.iface->guiPart();
201 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 210 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
202 211
203 // package the whole thing into a qwidget so it can be shown and hidden 212 // package the whole thing into a qwidget so it can be shown and hidden
204 plugin.guiBox = new QWidget( this ); 213 plugin.guiBox = new QWidget( this );
205 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 214 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
206 QPixmap plugPix; 215 QPixmap plugPix;
207 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 216 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
208 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 217 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
209 plugIcon->setPixmap( plugPix ); 218 plugIcon->setPixmap( plugPix );
210 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 219 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
211 plugIcon->setName( plugin.guiPart->appName() ); 220 plugIcon->setName( plugin.guiPart->appName() );
212 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 221 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
213 // a scrollview for each plugin 222 // a scrollview for each plugin
214 QScrollView* sv = new QScrollView( plugin.guiBox ); 223 QScrollView* sv = new QScrollView( plugin.guiBox );
215 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); 224 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() );
@@ -219,32 +228,38 @@ void Today::loadPlugins() {
219 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 228 sv->setHScrollBarMode( QScrollView::AlwaysOff );
220 sv->setFrameShape( QFrame::NoFrame ); 229 sv->setFrameShape( QFrame::NoFrame );
221 sv->addChild( plugWidget ); 230 sv->addChild( plugWidget );
222 // make sure the icon is on the top alligned 231 // make sure the icon is on the top alligned
223 boxLayout->addWidget( plugIcon, 0, AlignTop ); 232 boxLayout->addWidget( plugIcon, 0, AlignTop );
224 boxLayout->addWidget( sv, 0, AlignTop ); 233 boxLayout->addWidget( sv, 0, AlignTop );
225 boxLayout->setStretchFactor( plugIcon, 1 ); 234 boxLayout->setStretchFactor( plugIcon, 1 );
226 boxLayout->setStretchFactor( sv, 9 ); 235 boxLayout->setStretchFactor( sv, 9 );
227 // "prebuffer" it in one more list, to get the sorting done 236 // "prebuffer" it in one more list, to get the sorting done
228 tempList.insert( plugin.name, plugin ); 237 tempList.insert( plugin.name, plugin );
229 238
230 // on first start the list is off course empty 239 // on first start the list is off course empty
231 if ( m_allApplets.isEmpty() ) { 240 if ( m_allApplets.isEmpty() ) {
232 layout->addWidget( plugin.guiBox ); 241 layout->addWidget( plugin.guiBox );
233 pluginList.append( plugin ); 242 pluginList.append( plugin );
234 } 243 }
244
245 // if plugin is not yet in the list, add it to the layout too
246 if ( !m_allApplets.contains( plugin.name ) ) {
247 layout->addWidget( plugin.guiBox );
248 pluginList.append( plugin );
249 }
235 } 250 }
236 } else { 251 } else {
237 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); 252 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() );
238 delete lib; 253 delete lib;
239 } 254 }
240 } 255 }
241 256
242 if ( !m_allApplets.isEmpty() ) { 257 if ( !m_allApplets.isEmpty() ) {
243 TodayPlugin tempPlugin; 258 TodayPlugin tempPlugin;
244 QStringList::Iterator stringit; 259 QStringList::Iterator stringit;
245 260
246 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 261 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
247 tempPlugin = ( tempList.find( *stringit ) ).data(); 262 tempPlugin = ( tempList.find( *stringit ) ).data();
248 if ( !( (tempPlugin.name).isEmpty() ) ) { 263 if ( !( (tempPlugin.name).isEmpty() ) ) {
249 layout->addWidget( tempPlugin.guiBox ); 264 layout->addWidget( tempPlugin.guiBox );
250 pluginList.append( tempPlugin ); 265 pluginList.append( tempPlugin );