summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
Unidiff
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp172
1 files changed, 62 insertions, 110 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index be7cbce..3e895a4 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -52,6 +52,7 @@ static QMap<QString, TodayPlugin> pluginList;
52Today::Today( QWidget* parent, const char* name, WFlags fl ) 52Today::Today( QWidget* parent, const char* name, WFlags fl )
53: TodayBase( parent, name, fl ) { 53: TodayBase( parent, name, fl | WStyle_ContextHelp) {
54 54
55 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); 55 setCaption( tr("Today") );
56 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); 56 connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) );
57 connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) );
57 58
@@ -65,3 +66,4 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
65 setOwnerField(); 66 setOwnerField();
66 m_big_box = 0L; 67 m_big_box = 0l;
68 m_bblayout = 0l;
67 69
@@ -71,2 +73,6 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
71 73
74
75 m_informationLabel = new QLabel( tr("No plugins activated"), this );
76 layout->addWidget( m_informationLabel );
77
72 m_sv = new QScrollView( this ); 78 m_sv = new QScrollView( this );
@@ -82,5 +88,5 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
82 88
83 init();
84 loadPlugins(); 89 loadPlugins();
85 initialize(); 90 loadShellContent();
91 loadPluginWidgets();
86} 92}
@@ -135,10 +141,16 @@ void Today::setOwnerField( QString &message ) {
135/** 141/**
136 * Init stuff needed for today. Reads the config file. 142 * Load the plugins
137 */ 143 */
138void Today::init() { 144void Today::loadPlugins() {
139 // read config 145 m_pluginLoader = new OPluginLoader( "today", true );
140 OConfig cfg( "today" ); 146 m_pluginLoader->setAutoDelete( true );
147
148 m_manager = new OPluginManager( m_pluginLoader );
149 m_manager->load();
150}
151
152void Today::loadShellContent() {
153 Config cfg( "today" );
141 cfg.setGroup( "Plugins" ); 154 cfg.setGroup( "Plugins" );
142 // m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 155
143 // m_allApplets = cfg.readListEntry( "AllApplets", ',' );
144 156
@@ -160,24 +172,5 @@ void Today::init() {
160 } 172 }
161
162 if ( m_big_box ) {
163 delete m_big_box;
164 }
165
166 m_big_box = new QWidget( m_sv->viewport() );
167 m_sv->addChild( m_big_box );
168 m_bblayout = new QVBoxLayout ( m_big_box );
169} 173}
170 174
171 175void Today::loadPluginWidgets() {
172/**
173 * Load the plugins
174 */
175void Today::loadPlugins() {
176
177 m_pluginLoader = new OPluginLoader( "today", true );
178 m_pluginLoader->setAutoDelete( true );
179
180 m_manager = new OPluginManager( m_pluginLoader );
181 m_manager->load();
182
183 /* 176 /*
@@ -196,2 +189,17 @@ void Today::loadPlugins() {
196 189
190 /*
191 * Show or Hide the information of no plugin installed
192 */
193 if ( lst.isEmpty() )
194 m_informationLabel->show();
195 else
196 m_informationLabel->hide();
197
198
199 /*
200 * Now let us add the plugins
201 */
202 m_big_box = new QWidget( m_sv->viewport() );
203 m_sv->addChild( m_big_box );
204 m_bblayout = new QVBoxLayout( m_big_box );
197 205
@@ -231,2 +239,3 @@ void Today::loadPlugins() {
231 m_bblayout->addStretch( 1 ); 239 m_bblayout->addStretch( 1 );
240 m_big_box->show();
232} 241}
@@ -238,3 +247,2 @@ void Today::loadPlugins() {
238void Today::startConfig() { 247void Today::startConfig() {
239
240 // disconnect timer to prevent problems while being on config dialog 248 // disconnect timer to prevent problems while being on config dialog
@@ -248,3 +256,5 @@ void Today::startConfig() {
248 conf.writeConfig(); 256 conf.writeConfig();
249 initialize(); 257 clearPluginWidgets();
258 loadShellContent();
259 loadPluginWidgets();
250 } else { 260 } else {
@@ -256,67 +266,2 @@ void Today::startConfig() {
256 266
257
258void Today::initialize() {
259
260 Config cfg( "today" );
261 cfg.setGroup( "Plugins" );
262
263
264 cfg.setGroup( "General" );
265 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
266 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
267 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
268
269 // set the date in top label
270 QDate date = QDate::currentDate();
271 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
272
273 if ( m_hideBanner ) {
274 Opiezilla->hide();
275 TodayLabel->hide();
276 } else {
277 Opiezilla->show();
278 TodayLabel->show();
279 }
280
281 if ( m_bblayout ) {
282 delete m_bblayout;
283 }
284 m_bblayout = new QVBoxLayout ( m_big_box );
285
286 if ( pluginList.count() == 0 ) {
287 QLabel *noPlugins = new QLabel( this );
288 noPlugins->setText( tr( "No plugins found" ) );
289 layout->addWidget( noPlugins );
290 } else {
291
292 uint count = 0;
293 TodayPlugin tempPlugin;
294 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
295 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
296
297 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
298
299 tempPlugin = ( pluginList.find( (*it).name() ).data() );
300 if ( !( (tempPlugin.name).isEmpty() ) ) {
301 if ( (*it).isEnabled() ) {
302 iface->guiPart()->reinitialize();
303 odebug << "reinit" << oendl;
304 tempPlugin.guiBox->show();
305 m_bblayout->addWidget(tempPlugin.guiBox);
306 count++;
307 } else {
308 tempPlugin.guiBox->hide();
309 }
310 }
311 }
312 if ( count == 0 ) {
313 QLabel *noPluginsActive = new QLabel( this );
314 noPluginsActive->setText( tr( "No plugins activated" ) );
315 layout->addWidget( noPluginsActive );
316 }
317 }
318 m_bblayout->addStretch( 1 );
319 repaint();
320}
321
322/** 267/**
@@ -326,10 +271,5 @@ void Today::initialize() {
326void Today::refresh() { 271void Today::refresh() {
327 272 for ( QMap<QString, TodayPlugin>::Iterator it = pluginList.begin();
328 OPluginItem::List lst = m_pluginLoader->filtered( true ); 273 it != pluginList.end(); ++it )
329 274 it.data().guiPart->refresh();
330 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
331 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
332 iface->guiPart()->refresh();
333 odebug << "refresh" << oendl;
334 }
335 275
@@ -357,5 +297,3 @@ void Today::editCard() {
357Today::~Today() { 297Today::~Today() {
358 for(QMap<QString, TodayPlugin>::Iterator it = pluginList.begin(); it != pluginList.end(); ++it ) 298 clearPluginWidgets();
359 delete it.data().guiBox;
360
361 delete m_pluginLoader; 299 delete m_pluginLoader;
@@ -364 +302,15 @@ Today::~Today() {
364 302
303
304void Today::clearPluginWidgets() {
305 for(QMap<QString, TodayPlugin>::Iterator it = pluginList.begin(); it != pluginList.end(); ++it ) {
306 delete it.data().guiBox;
307 it.data().guiBox = 0;
308 }
309
310 pluginList.clear();
311
312 delete m_bblayout;
313 delete m_big_box;
314 m_bblayout = 0;
315 m_big_box = 0;
316}