summaryrefslogtreecommitdiff
path: root/core/pim
Unidiff
Diffstat (limited to 'core/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/datebookplugin.cpp2
-rw-r--r--core/pim/today/plugins/todolist/todoplugin.cpp2
-rw-r--r--core/pim/today/today.cpp172
-rw-r--r--core/pim/today/today.h8
-rw-r--r--core/pim/today/todayconfig.cpp7
5 files changed, 76 insertions, 115 deletions
diff --git a/core/pim/today/plugins/datebook/datebookplugin.cpp b/core/pim/today/plugins/datebook/datebookplugin.cpp
index 892a0ad..bef284e 100644
--- a/core/pim/today/plugins/datebook/datebookplugin.cpp
+++ b/core/pim/today/plugins/datebook/datebookplugin.cpp
@@ -46,7 +46,7 @@ QString DatebookPlugin::pixmapNameConfig() const {
46} 46}
47 47
48TodayConfigWidget* DatebookPlugin::configWidget( QWidget* wid ) { 48TodayConfigWidget* DatebookPlugin::configWidget( QWidget* wid ) {
49 return new DatebookPluginConfig( wid , "Datebook" ); 49 return new DatebookPluginConfig( wid , "Datebook Config" );
50} 50}
51 51
52QString DatebookPlugin::appName() const { 52QString DatebookPlugin::appName() const {
diff --git a/core/pim/today/plugins/todolist/todoplugin.cpp b/core/pim/today/plugins/todolist/todoplugin.cpp
index 6cfcbe0..4be5673 100644
--- a/core/pim/today/plugins/todolist/todoplugin.cpp
+++ b/core/pim/today/plugins/todolist/todoplugin.cpp
@@ -47,7 +47,7 @@ QString TodolistPlugin::pixmapNameConfig() const {
47} 47}
48 48
49TodayConfigWidget* TodolistPlugin::configWidget( QWidget* wid ) { 49TodayConfigWidget* TodolistPlugin::configWidget( QWidget* wid ) {
50 return new TodolistPluginConfig( wid , "Todolist" ); 50 return new TodolistPluginConfig( wid , "Todolist Config" );
51} 51}
52 52
53QString TodolistPlugin::appName() const { 53QString TodolistPlugin::appName() const {
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
@@ -50,10 +50,11 @@ TodayPlugin() : iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
50static QMap<QString, TodayPlugin> pluginList; 50static QMap<QString, TodayPlugin> pluginList;
51 51
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
58#if !defined(QT_NO_COP) 59#if !defined(QT_NO_COP)
59 60
@@ -63,12 +64,17 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
63#endif 64#endif
64 65
65 setOwnerField(); 66 setOwnerField();
66 m_big_box = 0L; 67 m_big_box = 0l;
68 m_bblayout = 0l;
67 69
68 layout = new QVBoxLayout( this ); 70 layout = new QVBoxLayout( this );
69 layout->addWidget( Frame ); 71 layout->addWidget( Frame );
70 layout->addWidget( OwnerField ); 72 layout->addWidget( OwnerField );
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 );
73 m_sv->setResizePolicy( QScrollView::AutoOneFit ); 79 m_sv->setResizePolicy( QScrollView::AutoOneFit );
74 m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); 80 m_sv->setHScrollBarMode( QScrollView::AlwaysOff );
@@ -80,9 +86,9 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
80 m_refreshTimer = new QTimer( this ); 86 m_refreshTimer = new QTimer( this );
81 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 87 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
82 88
83 init();
84 loadPlugins(); 89 loadPlugins();
85 initialize(); 90 loadShellContent();
91 loadPluginWidgets();
86} 92}
87 93
88/** 94/**
@@ -133,14 +139,20 @@ void Today::setOwnerField( QString &message ) {
133 139
134 140
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
145 cfg.setGroup( "General" ); 157 cfg.setGroup( "General" );
146 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 158 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
@@ -158,28 +170,9 @@ void Today::init() {
158 Opiezilla->show(); 170 Opiezilla->show();
159 TodayLabel->show(); 171 TodayLabel->show();
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 /*
184 * check if loading of Plugins crashed 177 * check if loading of Plugins crashed
185 */ 178 */
@@ -194,6 +187,21 @@ void Today::loadPlugins() {
194 187
195 OPluginItem::List lst = m_pluginLoader->filtered( true ); 188 OPluginItem::List lst = m_pluginLoader->filtered( true );
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
198 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { 206 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
199 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); 207 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
@@ -229,6 +237,7 @@ void Today::loadPlugins() {
229 } 237 }
230 238
231 m_bblayout->addStretch( 1 ); 239 m_bblayout->addStretch( 1 );
240 m_big_box->show();
232} 241}
233 242
234 243
@@ -236,7 +245,6 @@ void Today::loadPlugins() {
236 * The method for the configuration dialog. 245 * The method for the configuration dialog.
237 */ 246 */
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
241 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 249 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
242 m_refreshTimer->stop( ); 250 m_refreshTimer->stop( );
@@ -246,7 +254,9 @@ void Today::startConfig() {
246 254
247 if ( QPEApplication::execDialog(&conf) == QDialog::Accepted ) { 255 if ( QPEApplication::execDialog(&conf) == QDialog::Accepted ) {
248 conf.writeConfig(); 256 conf.writeConfig();
249 initialize(); 257 clearPluginWidgets();
258 loadShellContent();
259 loadPluginWidgets();
250 } else { 260 } else {
251 // since reinitialize is not called in that case , reconnect the signal 261 // since reinitialize is not called in that case , reconnect the signal
252 m_refreshTimer->start( 15000 ); // get the config value in here later 262 m_refreshTimer->start( 15000 ); // get the config value in here later
@@ -254,84 +264,14 @@ void Today::startConfig() {
254 } 264 }
255} 265}
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/**
323 * Refresh for the view. Reload all applets 268 * Refresh for the view. Reload all applets
324 * 269 *
325 */ 270 */
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
336 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); 276 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) );
337 277
@@ -355,10 +295,22 @@ void Today::editCard() {
355 295
356 296
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;
362 delete m_manager; 300 delete m_manager;
363} 301}
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}
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index dfc819d..8dbe9aa 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -56,13 +56,16 @@ private slots:
56 void refresh(); 56 void refresh();
57 57
58private: 58private:
59 void init();
60 void setOwnerField(); 59 void setOwnerField();
61 void setOwnerField(QString &string); 60 void setOwnerField(QString &string);
62 void initialize();
63 61
64 void setRefreshTimer( int ); 62 void setRefreshTimer( int );
65 63
64 void clearPluginWidgets();
65 void loadPluginWidgets();
66 void loadShellContent();
67
68
66private slots: 69private slots:
67 void channelReceived(const QCString &msg, const QByteArray & data); 70 void channelReceived(const QCString &msg, const QByteArray & data);
68 void loadPlugins(); 71 void loadPlugins();
@@ -75,6 +78,7 @@ private:
75 QScrollView *m_sv; 78 QScrollView *m_sv;
76 QWidget* m_big_box; 79 QWidget* m_big_box;
77 QVBoxLayout *m_bblayout; 80 QVBoxLayout *m_bblayout;
81 QLabel *m_informationLabel;
78 82
79 Opie::Core::OPluginLoader *m_pluginLoader; 83 Opie::Core::OPluginLoader *m_pluginLoader;
80 Opie::Core::OPluginManager *m_manager; 84 Opie::Core::OPluginManager *m_manager;
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp
index dacce8b..864c708 100644
--- a/core/pim/today/todayconfig.cpp
+++ b/core/pim/today/todayconfig.cpp
@@ -93,7 +93,6 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
93 tab3Layout->addWidget( m_guiMisc ); 93 tab3Layout->addWidget( m_guiMisc );
94 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); 94 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) );
95 95
96 connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) );
97 previousItem = 0l; 96 previousItem = 0l;
98 readConfig(); 97 readConfig();
99} 98}
@@ -181,12 +180,17 @@ void TodayConfig::writeConfig() {
181 for ( ; list_it.current(); ++list_it ) { 180 for ( ; list_it.current(); ++list_it ) {
182 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { 181 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
183 if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { 182 if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) {
183 qWarning( "Enabling %d and make it %d", position-1,
184 ((QCheckListItem*)list_it.current())->isOn() );
184 (*it).setPosition(position--); 185 (*it).setPosition(position--);
185 m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); 186 m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() );
186 } 187 }
187 } 188 }
188 } 189 }
189 190
191 /*
192 * save and get the changes back
193 */
190 m_pluginManager->save(); 194 m_pluginManager->save();
191 195
192 cfg.setGroup( "Autostart" ); 196 cfg.setGroup( "Autostart" );
@@ -209,6 +213,7 @@ void TodayConfig::writeConfig() {
209 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); 213 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
210 if ( m_configMap.contains( iface ) ) 214 if ( m_configMap.contains( iface ) )
211 m_configMap[iface]->writeConfig(); 215 m_configMap[iface]->writeConfig();
216
212 } 217 }
213} 218}
214 219