-rw-r--r-- | core/pim/today/today.cpp | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 7537631..d8b427d 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -105,22 +105,18 @@ void Today::setOwnerField( QString &message ) { | |||
105 | 105 | ||
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Init stuff needed for today. Reads the config file. | 108 | * Init stuff needed for today. Reads the config file. |
109 | */ | 109 | */ |
110 | void Today::init() { | 110 | void Today::init() { |
111 | |||
112 | QDate date = QDate::currentDate(); | ||
113 | QString time = ( tr( date.toString() ) ); | ||
114 | |||
115 | DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); | ||
116 | |||
117 | // read config | 111 | // read config |
118 | Config cfg( "today" ); | 112 | Config cfg( "today" ); |
119 | cfg.setGroup( "Applets" ); | 113 | cfg.setGroup( "Plugins" ); |
114 | |||
120 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 115 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
116 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | ||
121 | } | 117 | } |
122 | 118 | ||
123 | 119 | ||
124 | /** | 120 | /** |
125 | * Load the plugins | 121 | * Load the plugins |
126 | */ | 122 | */ |
@@ -130,19 +126,21 @@ void Today::loadPlugins() { | |||
130 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { | 126 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
131 | (*tit).library->unload(); | 127 | (*tit).library->unload(); |
132 | delete (*tit).library; | 128 | delete (*tit).library; |
133 | } | 129 | } |
134 | pluginList.clear(); | 130 | pluginList.clear(); |
135 | 131 | ||
136 | |||
137 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 132 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
138 | QDir dir( path, "lib*.so" ); | 133 | QDir dir( path, "lib*.so" ); |
139 | 134 | ||
140 | QStringList list = dir.entryList(); | 135 | QStringList list = dir.entryList(); |
141 | QStringList::Iterator it; | 136 | QStringList::Iterator it; |
142 | 137 | ||
138 | |||
139 | QMap<QString, TodayPlugin> tempList; | ||
140 | |||
143 | for ( it = list.begin(); it != list.end(); ++it ) { | 141 | for ( it = list.begin(); it != list.end(); ++it ) { |
144 | TodayPluginInterface *iface = 0; | 142 | TodayPluginInterface *iface = 0; |
145 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 143 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
146 | 144 | ||
147 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 145 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
148 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 146 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
@@ -161,40 +159,54 @@ void Today::loadPlugins() { | |||
161 | } | 159 | } |
162 | plugin.guiPart = plugin.iface->guiPart(); | 160 | plugin.guiPart = plugin.iface->guiPart(); |
163 | 161 | ||
164 | // package the whole thing into a qwidget so it can be shown and hidden | 162 | // package the whole thing into a qwidget so it can be shown and hidden |
165 | plugin.guiBox = new QWidget( this ); | 163 | plugin.guiBox = new QWidget( this ); |
166 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); | 164 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); |
167 | |||
168 | QPixmap plugPix; | 165 | QPixmap plugPix; |
169 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); | 166 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); |
170 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 167 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
171 | plugIcon->setPixmap( plugPix ); | 168 | plugIcon->setPixmap( plugPix ); |
172 | |||
173 | // a scrollview for each plugin | 169 | // a scrollview for each plugin |
174 | QScrollView* sv = new QScrollView( plugin.guiBox ); | 170 | QScrollView* sv = new QScrollView( plugin.guiBox ); |
175 | QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); | 171 | QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); |
176 | sv->setMinimumHeight( plugin.guiPart->minHeight() ); | 172 | sv->setMinimumHeight( plugin.guiPart->minHeight() ); |
177 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 173 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
178 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 174 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
179 | sv->setFrameShape( QFrame::NoFrame ); | 175 | sv->setFrameShape( QFrame::NoFrame ); |
180 | sv->addChild( plugWidget ); | 176 | sv->addChild( plugWidget ); |
181 | |||
182 | // make sure the icon is on the top alligned | 177 | // make sure the icon is on the top alligned |
183 | boxLayout->addWidget( plugIcon, 0, AlignTop ); | 178 | boxLayout->addWidget( plugIcon, 0, AlignTop ); |
184 | boxLayout->addWidget( sv, 0, AlignTop ); | 179 | boxLayout->addWidget( sv, 0, AlignTop ); |
185 | boxLayout->setStretchFactor( plugIcon, 1 ); | 180 | boxLayout->setStretchFactor( plugIcon, 1 ); |
186 | boxLayout->setStretchFactor( sv, 9 ); | 181 | boxLayout->setStretchFactor( sv, 9 ); |
187 | layout->addWidget( plugin.guiBox ); | 182 | // "prebuffer" it in one more list, to get the sorting done |
183 | tempList.insert( plugin.name, plugin ); | ||
188 | 184 | ||
189 | pluginList.append( plugin ); | 185 | // on first start the list is off course empty |
186 | if ( m_allApplets.isEmpty() ) { | ||
187 | layout->addWidget( plugin.guiBox ); | ||
188 | pluginList.append( plugin ); | ||
189 | } | ||
190 | } else { | 190 | } else { |
191 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); | 191 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); |
192 | delete lib; | 192 | delete lib; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | |||
196 | if ( !m_allApplets.isEmpty() ) { | ||
197 | TodayPlugin tempPlugin; | ||
198 | QStringList::Iterator stringit; | ||
199 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { | ||
200 | tempPlugin = ( tempList.find( *stringit ) ).data(); | ||
201 | if ( !( (tempPlugin.name).isEmpty() ) ) { | ||
202 | layout->addWidget( tempPlugin.guiBox ); | ||
203 | pluginList.append( tempPlugin ); | ||
204 | } | ||
205 | } | ||
206 | } | ||
195 | } | 207 | } |
196 | 208 | ||
197 | 209 | ||
198 | /** | 210 | /** |
199 | * Repaint method. Reread all fields. | 211 | * Repaint method. Reread all fields. |
200 | */ | 212 | */ |
@@ -224,32 +236,32 @@ void Today::draw() { | |||
224 | 236 | ||
225 | if ( count == 0 ) { | 237 | if ( count == 0 ) { |
226 | QLabel *noPluginsActive = new QLabel( this ); | 238 | QLabel *noPluginsActive = new QLabel( this ); |
227 | noPluginsActive->setText( tr( "No plugins activated" ) ); | 239 | noPluginsActive->setText( tr( "No plugins activated" ) ); |
228 | layout->addWidget( noPluginsActive ); | 240 | layout->addWidget( noPluginsActive ); |
229 | } | 241 | } |
230 | //layout->addStretch(0); | 242 | layout->addStretch(0); |
231 | //layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | ||
232 | } | 243 | } |
233 | 244 | ||
234 | 245 | ||
235 | /** | 246 | /** |
236 | * The method for the configuration dialog. | 247 | * The method for the configuration dialog. |
237 | */ | 248 | */ |
238 | void Today::startConfig() { | 249 | void Today::startConfig() { |
239 | 250 | ||
240 | TodayConfig conf( this, "dialog", true ); | 251 | TodayConfig conf( this, "dialog", true ); |
241 | 252 | ||
242 | TodayPlugin plugin; | 253 | TodayPlugin plugin; |
243 | QList<ConfigWidget> configWidgetList; | 254 | QList<ConfigWidget> configWidgetList; |
244 | for ( uint i = 0; i < pluginList.count(); i++ ) { | 255 | |
256 | for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { | ||
245 | plugin = pluginList[i]; | 257 | plugin = pluginList[i]; |
246 | 258 | ||
247 | // load the config widgets in the tabs | 259 | // load the config widgets in the tabs |
248 | if ( plugin.guiPart->configWidget( this ) != 0l ) { | 260 | if ( plugin.guiPart->configWidget( this ) != 0l ) { |
249 | ConfigWidget* widget = plugin.guiPart->configWidget( this ); | 261 | ConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); |
250 | configWidgetList.append( widget ); | 262 | configWidgetList.append( widget ); |
251 | conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); | 263 | conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); |
252 | } | 264 | } |
253 | // set the order/activate tab | 265 | // set the order/activate tab |
254 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), | 266 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), |
255 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); | 267 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); |
@@ -271,12 +283,18 @@ void Today::startConfig() { | |||
271 | * Refresh for the view. Reload all applets | 283 | * Refresh for the view. Reload all applets |
272 | * | 284 | * |
273 | */ | 285 | */ |
274 | void Today::refresh() { | 286 | void Today::refresh() { |
275 | init(); | 287 | init(); |
276 | 288 | ||
289 | // set the date in top label | ||
290 | QDate date = QDate::currentDate(); | ||
291 | QString time = ( tr( date.toString() ) ); | ||
292 | |||
293 | DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); | ||
294 | |||
277 | if ( layout ) { | 295 | if ( layout ) { |
278 | delete layout; | 296 | delete layout; |
279 | } | 297 | } |
280 | layout = new QVBoxLayout( this ); | 298 | layout = new QVBoxLayout( this ); |
281 | layout->addWidget( Frame ); | 299 | layout->addWidget( Frame ); |
282 | layout->addWidget( OwnerField ); | 300 | layout->addWidget( OwnerField ); |