summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -1,71 +1,71 @@
1/* 1/*
2 * datebookplugin.cpp 2 * datebookplugin.cpp
3 * 3 *
4 * copyright : (c) 2002,2003, 2004 by Maximilian Reiß 4 * copyright : (c) 2002,2003, 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "datebookplugin.h" 17#include "datebookplugin.h"
18#include "datebookpluginconfig.h" 18#include "datebookpluginconfig.h"
19 19
20 20
21DatebookPlugin::DatebookPlugin() { 21DatebookPlugin::DatebookPlugin() {
22} 22}
23 23
24DatebookPlugin::~DatebookPlugin() { 24DatebookPlugin::~DatebookPlugin() {
25} 25}
26 26
27QString DatebookPlugin::pluginName() const { 27QString DatebookPlugin::pluginName() const {
28 return QObject::tr( "Datebook plugin"); 28 return QObject::tr( "Datebook plugin");
29} 29}
30 30
31double DatebookPlugin::versionNumber() const { 31double DatebookPlugin::versionNumber() const {
32 return 1.0; 32 return 1.0;
33} 33}
34 34
35QString DatebookPlugin::pixmapNameWidget() const { 35QString DatebookPlugin::pixmapNameWidget() const {
36 return "datebook/DateBook"; 36 return "datebook/DateBook";
37} 37}
38 38
39QWidget* DatebookPlugin::widget( QWidget* wid ) { 39QWidget* DatebookPlugin::widget( QWidget* wid ) {
40 m_widget = new DatebookPluginWidget( wid, "Datebook" ); 40 m_widget = new DatebookPluginWidget( wid, "Datebook" );
41 return m_widget; 41 return m_widget;
42} 42}
43 43
44QString DatebookPlugin::pixmapNameConfig() const { 44QString DatebookPlugin::pixmapNameConfig() const {
45 return "datebook/DateBook"; 45 return "datebook/DateBook";
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 {
53 return "datebook"; 53 return "datebook";
54} 54}
55 55
56bool DatebookPlugin::excludeFromRefresh() const { 56bool DatebookPlugin::excludeFromRefresh() const {
57 return false; 57 return false;
58} 58}
59 59
60void DatebookPlugin::refresh() { 60void DatebookPlugin::refresh() {
61 if ( m_widget ) { 61 if ( m_widget ) {
62 m_widget->refresh(); 62 m_widget->refresh();
63 } 63 }
64} 64}
65 65
66void DatebookPlugin::reinitialize() { 66void DatebookPlugin::reinitialize() {
67 if ( m_widget ) { 67 if ( m_widget ) {
68 m_widget->reinitialize(); 68 m_widget->reinitialize();
69 } 69 }
70} 70}
71 71
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
@@ -1,72 +1,72 @@
1/* 1/*
2 * todoplugin.cpp 2 * todoplugin.cpp
3 * 3 *
4 * copyright : (c) 2002,2003, 2004 by Maximilian Reiß 4 * copyright : (c) 2002,2003, 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "todoplugin.h" 17#include "todoplugin.h"
18#include "todopluginconfig.h" 18#include "todopluginconfig.h"
19 19
20TodolistPlugin::TodolistPlugin() 20TodolistPlugin::TodolistPlugin()
21 : m_widget(0l) 21 : m_widget(0l)
22{ 22{
23} 23}
24 24
25TodolistPlugin::~TodolistPlugin() { 25TodolistPlugin::~TodolistPlugin() {
26} 26}
27 27
28QString TodolistPlugin::pluginName() const { 28QString TodolistPlugin::pluginName() const {
29 return QObject::tr( "Todolist plugin" ); 29 return QObject::tr( "Todolist plugin" );
30} 30}
31 31
32double TodolistPlugin::versionNumber() const { 32double TodolistPlugin::versionNumber() const {
33 return 0.9; 33 return 0.9;
34} 34}
35 35
36QString TodolistPlugin::pixmapNameWidget() const { 36QString TodolistPlugin::pixmapNameWidget() const {
37 return "todo/TodoList"; 37 return "todo/TodoList";
38} 38}
39 39
40QWidget* TodolistPlugin::widget( QWidget *wid ) { 40QWidget* TodolistPlugin::widget( QWidget *wid ) {
41 m_widget = new TodolistPluginWidget( wid, "Todolist" ); 41 m_widget = new TodolistPluginWidget( wid, "Todolist" );
42 return m_widget; 42 return m_widget;
43} 43}
44 44
45QString TodolistPlugin::pixmapNameConfig() const { 45QString TodolistPlugin::pixmapNameConfig() const {
46 return "todo/TodoList"; 46 return "todo/TodoList";
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 {
54 return "todolist"; 54 return "todolist";
55} 55}
56 56
57 57
58bool TodolistPlugin::excludeFromRefresh() const { 58bool TodolistPlugin::excludeFromRefresh() const {
59 return false; 59 return false;
60} 60}
61 61
62void TodolistPlugin::refresh() { 62void TodolistPlugin::refresh() {
63 if ( m_widget ) { 63 if ( m_widget ) {
64 m_widget->refresh(); 64 m_widget->refresh();
65 } 65 }
66} 66}
67 67
68void TodolistPlugin::reinitialize() { 68void TodolistPlugin::reinitialize() {
69 if ( m_widget ) { 69 if ( m_widget ) {
70 m_widget->reinitialize(); 70 m_widget->reinitialize();
71 } 71 }
72} 72}
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
@@ -1,364 +1,316 @@
1/* 1/*
2 * today.cpp 2 * today.cpp
3 * 3 *
4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß 4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "today.h" 17#include "today.h"
18 18
19#include <opie2/odebug.h> 19#include <opie2/odebug.h>
20#include <opie2/opluginloader.h> 20#include <opie2/opluginloader.h>
21#include <opie2/oconfig.h> 21#include <opie2/oconfig.h>
22 22
23#include <qpe/qcopenvelope_qws.h> 23#include <qpe/qcopenvelope_qws.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/contact.h> 26#include <qpe/contact.h>
27 27
28#include <qdir.h> 28#include <qdir.h>
29#include <qtimer.h> 29#include <qtimer.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32 32
33using namespace Opie::Ui; 33using namespace Opie::Ui;
34using Opie::Core::OPluginItem; 34using Opie::Core::OPluginItem;
35using Opie::Core::OPluginLoader; 35using Opie::Core::OPluginLoader;
36using Opie::Core::OPluginManager; 36using Opie::Core::OPluginManager;
37using Opie::Core::OConfig; 37using Opie::Core::OConfig;
38 38
39 39
40struct TodayPlugin { 40struct TodayPlugin {
41TodayPlugin() : iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} 41TodayPlugin() : iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
42 QInterfacePtr<TodayPluginInterface> iface; 42 QInterfacePtr<TodayPluginInterface> iface;
43 TodayPluginObject *guiPart; 43 TodayPluginObject *guiPart;
44 OPluginItem oplugin; 44 OPluginItem oplugin;
45 QWidget *guiBox; 45 QWidget *guiBox;
46 QString name; 46 QString name;
47 bool excludeRefresh; 47 bool excludeRefresh;
48}; 48};
49 49
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
60 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 61 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
61 connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 62 connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
62 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); 63 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) );
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 );
75 m_sv->setFrameShape( QFrame::NoFrame ); 81 m_sv->setFrameShape( QFrame::NoFrame );
76 82
77 layout->addWidget( m_sv ); 83 layout->addWidget( m_sv );
78 layout->setStretchFactor( m_sv,4 ); 84 layout->setStretchFactor( m_sv,4 );
79 85
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/**
89 * Qcop receive method. 95 * Qcop receive method.
90 */ 96 */
91void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 97void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
92 QDataStream stream( data, IO_ReadOnly ); 98 QDataStream stream( data, IO_ReadOnly );
93 if ( msg == "message(QString)" ) { 99 if ( msg == "message(QString)" ) {
94 QString message; 100 QString message;
95 stream >> message; 101 stream >> message;
96 setOwnerField( message ); 102 setOwnerField( message );
97 } 103 }
98} 104}
99 105
100void Today::setRefreshTimer( int interval ) { 106void Today::setRefreshTimer( int interval ) {
101 107
102 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 108 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
103 // 0 is "never" case 109 // 0 is "never" case
104 if ( !interval == 0 ) { 110 if ( !interval == 0 ) {
105 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 111 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
106 m_refreshTimer->changeInterval( interval ); 112 m_refreshTimer->changeInterval( interval );
107 } 113 }
108} 114}
109 115
110 116
111/** 117/**
112 * Initialises the owner field with the default value, the username 118 * Initialises the owner field with the default value, the username
113 */ 119 */
114void Today::setOwnerField() { 120void Today::setOwnerField() {
115 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 121 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
116 if ( QFile::exists( file ) ) { 122 if ( QFile::exists( file ) ) {
117 Contact cont = Contact::readVCard( file )[0]; 123 Contact cont = Contact::readVCard( file )[0];
118 QString returnString = cont.fullName(); 124 QString returnString = cont.fullName();
119 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 125 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
120 } else { 126 } else {
121 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 127 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
122 } 128 }
123} 129}
124 130
125/** 131/**
126 * Set the owner field with a given QString, for example per qcop. 132 * Set the owner field with a given QString, for example per qcop.
127 */ 133 */
128void Today::setOwnerField( QString &message ) { 134void Today::setOwnerField( QString &message ) {
129 if ( !message.isEmpty() ) { 135 if ( !message.isEmpty() ) {
130 OwnerField->setText( "<b>" + message + "</b>" ); 136 OwnerField->setText( "<b>" + message + "</b>" );
131 } 137 }
132} 138}
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 );
147 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); 159 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
148 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 160 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
149 161
150 // set the date in top label 162 // set the date in top label
151 QDate date = QDate::currentDate(); 163 QDate date = QDate::currentDate();
152 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); 164 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
153 165
154 if ( m_hideBanner ) { 166 if ( m_hideBanner ) {
155 Opiezilla->hide(); 167 Opiezilla->hide();
156 TodayLabel->hide(); 168 TodayLabel->hide();
157 } else { 169 } else {
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 */
186 if( m_pluginLoader->isInSafeMode() ) { 179 if( m_pluginLoader->isInSafeMode() ) {
187 QMessageBox::information(this, tr("Today Error"), 180 QMessageBox::information(this, tr("Today Error"),
188 tr("<qt>The plugin '%1' caused Today to crash." 181 tr("<qt>The plugin '%1' caused Today to crash."
189 " It could be that the plugin is not properly" 182 " It could be that the plugin is not properly"
190 " installed.<br>Today tries to continue loading" 183 " installed.<br>Today tries to continue loading"
191 " plugins.</qt>") 184 " plugins.</qt>")
192 .arg( m_manager->crashedPlugin().name())); 185 .arg( m_manager->crashedPlugin().name()));
193 } 186 }
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 );
200 208
201 TodayPlugin plugin; 209 TodayPlugin plugin;
202 plugin.iface = iface; 210 plugin.iface = iface;
203 plugin.name = (*it).name(); 211 plugin.name = (*it).name();
204 plugin.oplugin = (*it); 212 plugin.oplugin = (*it);
205 213
206 plugin.guiPart = plugin.iface->guiPart(); 214 plugin.guiPart = plugin.iface->guiPart();
207 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 215 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
208 216
209 // package the whole thing into a qwidget so it can be shown and hidden 217 // package the whole thing into a qwidget so it can be shown and hidden
210 plugin.guiBox = new QWidget( m_big_box ); 218 plugin.guiBox = new QWidget( m_big_box );
211 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 219 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
212 QPixmap plugPix; 220 QPixmap plugPix;
213 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 221 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
214 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 222 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
215 plugIcon->setPixmap( plugPix ); 223 plugIcon->setPixmap( plugPix );
216 QWhatsThis::add 224 QWhatsThis::add
217 ( plugIcon, tr("Click here to launch the associated app") ); 225 ( plugIcon, tr("Click here to launch the associated app") );
218 plugIcon->setName( plugin.guiPart->appName() ); 226 plugIcon->setName( plugin.guiPart->appName() );
219 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 227 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
220 228
221 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); 229 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox );
222 boxLayout->addWidget( plugIcon, 0, AlignTop ); 230 boxLayout->addWidget( plugIcon, 0, AlignTop );
223 boxLayout->addWidget( plugWidget, 0, AlignTop ); 231 boxLayout->addWidget( plugWidget, 0, AlignTop );
224 boxLayout->setStretchFactor( plugIcon, 1 ); 232 boxLayout->setStretchFactor( plugIcon, 1 );
225 boxLayout->setStretchFactor( plugWidget, 9 ); 233 boxLayout->setStretchFactor( plugWidget, 9 );
226 234
227 pluginList.insert( plugin.name, plugin ); 235 pluginList.insert( plugin.name, plugin );
228 m_bblayout->addWidget(plugin.guiBox); 236 m_bblayout->addWidget(plugin.guiBox);
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
235/** 244/**
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( );
243 251
244 TodayConfig conf( this, "dialog", true ); 252 TodayConfig conf( this, "dialog", true );
245 conf.setUpPlugins( m_manager, m_pluginLoader ); 253 conf.setUpPlugins( m_manager, m_pluginLoader );
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
253 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 263 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
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
338 updateGeometry(); 278 updateGeometry();
339 repaint(); 279 repaint();
340} 280}
341 281
342 282
343void Today::startApplication() { 283void Today::startApplication() {
344 QCopEnvelope e( "QPE/System", "execute(QString)" ); 284 QCopEnvelope e( "QPE/System", "execute(QString)" );
345 e << QString( sender()->name() ); 285 e << QString( sender()->name() );
346} 286}
347 287
348 288
349/** 289/**
350* launch addressbook (personal card) 290* launch addressbook (personal card)
351*/ 291*/
352void Today::editCard() { 292void Today::editCard() {
353 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); 293 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" );
354} 294}
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
@@ -1,90 +1,94 @@
1/* 1/*
2 * today.h 2 * today.h
3 * 3 *
4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß 4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16#ifndef TODAY_H 16#ifndef TODAY_H
17#define TODAY_H 17#define TODAY_H
18 18
19 19
20#include "todayconfig.h" 20#include "todayconfig.h"
21#include "todaybase.h" 21#include "todaybase.h"
22 22
23#include <opie2/todayplugininterface.h> 23#include <opie2/todayplugininterface.h>
24#include <opie2/oclickablelabel.h> 24#include <opie2/oclickablelabel.h>
25#include <opie2/opluginloader.h> 25#include <opie2/opluginloader.h>
26 26
27#include <qpe/qlibrary.h> 27#include <qpe/qlibrary.h>
28 28
29#include <qscrollview.h> 29#include <qscrollview.h>
30#include <qvbox.h> 30#include <qvbox.h>
31 31
32 32
33class QVBoxLayout; 33class QVBoxLayout;
34 34
35namespace Opie { 35namespace Opie {
36 namespace Core { 36 namespace Core {
37 class OPluginManager; 37 class OPluginManager;
38 class OPluginLoader; 38 class OPluginLoader;
39 } 39 }
40} 40}
41 41
42class Today : public TodayBase { 42class Today : public TodayBase {
43 Q_OBJECT 43 Q_OBJECT
44 44
45public: 45public:
46 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 46 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
47 ~Today(); 47 ~Today();
48 static QString appName() { 48 static QString appName() {
49 return QString::fromLatin1("today"); 49 return QString::fromLatin1("today");
50 } 50 }
51 51
52private slots: 52private slots:
53 void startConfig(); 53 void startConfig();
54 void startApplication(); 54 void startApplication();
55 void editCard(); 55 void editCard();
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();
69 72
70private: 73private:
71 TodayConfig *conf; 74 TodayConfig *conf;
72 QStringList m_excludeApplets; 75 QStringList m_excludeApplets;
73 QStringList m_allApplets; 76 QStringList m_allApplets;
74 77
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;
81 85
82 QTimer *m_refreshTimer; 86 QTimer *m_refreshTimer;
83 87
84 bool m_refreshTimerEnabled; 88 bool m_refreshTimerEnabled;
85 int m_newStart; 89 int m_newStart;
86 int m_iconSize; 90 int m_iconSize;
87 int m_maxCharClip; 91 int m_maxCharClip;
88 int m_hideBanner; 92 int m_hideBanner;
89}; 93};
90#endif 94#endif
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
@@ -1,250 +1,255 @@
1/* 1/*
2 * todayconfig.cpp 2 * todayconfig.cpp
3 * 3 *
4 * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß 4 * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "todayconfig.h" 17#include "todayconfig.h"
18 18
19#include <opie2/oconfig.h> 19#include <opie2/oconfig.h>
20#include <opie2/opluginloader.h> 20#include <opie2/opluginloader.h>
21#include <opie2/todayplugininterface.h> 21#include <opie2/todayplugininterface.h>
22 22
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26 26
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qspinbox.h> 29#include <qspinbox.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qheader.h> 31#include <qheader.h>
32#include <qvbox.h> 32#include <qvbox.h>
33#include <qtoolbutton.h> 33#include <qtoolbutton.h>
34#include <qwhatsthis.h> 34#include <qwhatsthis.h>
35 35
36using namespace Opie::Ui; 36using namespace Opie::Ui;
37using Opie::Core::OConfig; 37using Opie::Core::OConfig;
38using Opie::Core::OPluginManager; 38using Opie::Core::OPluginManager;
39using Opie::Core::OPluginLoader; 39using Opie::Core::OPluginLoader;
40using Opie::Core::OPluginItem; 40using Opie::Core::OPluginItem;
41 41
42class ToolButton : public QToolButton { 42class ToolButton : public QToolButton {
43 43
44public: 44public:
45 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 45 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
46: QToolButton( parent, name ) { 46: QToolButton( parent, name ) {
47 setPixmap( Resource::loadPixmap( icon ) ); 47 setPixmap( Resource::loadPixmap( icon ) );
48 setAutoRaise( TRUE ); 48 setAutoRaise( TRUE );
49 setFocusPolicy( QWidget::NoFocus ); 49 setFocusPolicy( QWidget::NoFocus );
50 setToggleButton( t ); 50 setToggleButton( t );
51 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 51 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
52 } 52 }
53}; 53};
54 54
55 55
56/** 56/**
57 * The class has currently quite some duplicate code. 57 * The class has currently quite some duplicate code.
58 * By that way it would be real easy to have it as seperate app in settings tab 58 * By that way it would be real easy to have it as seperate app in settings tab
59 * 59 *
60 */ 60 */
61TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) 61TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
62: QDialog( parent, name, modal, WStyle_ContextHelp ) { 62: QDialog( parent, name, modal, WStyle_ContextHelp ) {
63 63
64 setCaption( tr( "Today Config" ) ); 64 setCaption( tr( "Today Config" ) );
65 65
66 QVBoxLayout *layout = new QVBoxLayout( this ); 66 QVBoxLayout *layout = new QVBoxLayout( this );
67 TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 67 TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
68 layout->addWidget( TabWidget3 ); 68 layout->addWidget( TabWidget3 );
69 69
70 tab_2 = new QWidget( TabWidget3, "tab_2" ); 70 tab_2 = new QWidget( TabWidget3, "tab_2" );
71 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); 71 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 );
72 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); 72 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 );
73 tab2Layout->addWidget( l ); 73 tab2Layout->addWidget( l );
74 QHBox *hbox1 = new QHBox( tab_2 ); 74 QHBox *hbox1 = new QHBox( tab_2 );
75 m_appletListView = new QListView( hbox1 ); 75 m_appletListView = new QListView( hbox1 );
76 m_appletListView->addColumn( "PluginList" ); 76 m_appletListView->addColumn( "PluginList" );
77 m_appletListView->header()->hide(); 77 m_appletListView->header()->hide();
78 m_appletListView->setSorting( -1 ); 78 m_appletListView->setSorting( -1 );
79 QWhatsThis::add 79 QWhatsThis::add
80 ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); 80 ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) );
81 QVBox *vbox1 = new QVBox( hbox1 ); 81 QVBox *vbox1 = new QVBox( hbox1 );
82 new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); 82 new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
83 new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); 83 new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
84 tab2Layout->addWidget( hbox1 ); 84 tab2Layout->addWidget( hbox1 );
85 TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); 85 TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) );
86 86
87 // Misc tab 87 // Misc tab
88 tab_3 = new QWidget( TabWidget3, "tab_3" ); 88 tab_3 = new QWidget( TabWidget3, "tab_3" );
89 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); 89 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 );
90 90
91 m_guiMisc = new TodayConfigMiscBase( tab_3 ); 91 m_guiMisc = new TodayConfigMiscBase( tab_3 );
92 92
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}
100 99
101 100
102void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { 101void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) {
103 m_configMap.clear(); 102 m_configMap.clear();
104 103
105 m_pluginManager = plugManager; 104 m_pluginManager = plugManager;
106 m_pluginLoader = plugLoader; 105 m_pluginLoader = plugLoader;
107 106
108 OPluginItem::List inLst = m_pluginLoader->allAvailable( true ); 107 OPluginItem::List inLst = m_pluginLoader->allAvailable( true );
109 108
110 OPluginItem::List lst; 109 OPluginItem::List lst;
111 for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { 110 for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) {
112 lst.prepend((*it)); 111 lst.prepend((*it));
113 112
114 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); 113 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
115 TodayConfigWidget *widget = iface->guiPart()->configWidget( TabWidget3 ); 114 TodayConfigWidget *widget = iface->guiPart()->configWidget( TabWidget3 );
116 115
117 if (!widget ) 116 if (!widget )
118 continue; 117 continue;
119 118
120 m_configMap.insert( iface, widget ); 119 m_configMap.insert( iface, widget );
121 TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() 120 TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig()
122 , iface->guiPart()->appName() ); 121 , iface->guiPart()->appName() );
123 } 122 }
124 123
125 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) 124 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it )
126 pluginManagement( (*it) ); 125 pluginManagement( (*it) );
127 126
128 127
129 TabWidget3->setCurrentTab( tab_2 ); 128 TabWidget3->setCurrentTab( tab_2 );
130} 129}
131 130
132/** 131/**
133 * Autostart, uses the new (opie only) autostart method in the launcher code. 132 * Autostart, uses the new (opie only) autostart method in the launcher code.
134 * If registered against that today ist started on each resume. 133 * If registered against that today ist started on each resume.
135 */ 134 */
136void TodayConfig::setAutoStart() { 135void TodayConfig::setAutoStart() {
137 OConfig cfg( "today" ); 136 OConfig cfg( "today" );
138 cfg.setGroup( "Autostart" ); 137 cfg.setGroup( "Autostart" );
139 if ( m_autoStart ) { 138 if ( m_autoStart ) {
140 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); 139 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" );
141 e << QString( "add" ); 140 e << QString( "add" );
142 e << QString( "today" ); 141 e << QString( "today" );
143 e << QString( "%1" ).arg( m_autoStartTimer ); 142 e << QString( "%1" ).arg( m_autoStartTimer );
144 } else { 143 } else {
145 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); 144 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" );
146 e << QString( "remove" ); 145 e << QString( "remove" );
147 e << QString( "today" ); 146 e << QString( "today" );
148 } 147 }
149} 148}
150 149
151/** 150/**
152 * Read the config part 151 * Read the config part
153 */ 152 */
154void TodayConfig::readConfig() { 153void TodayConfig::readConfig() {
155 OConfig cfg( "today" ); 154 OConfig cfg( "today" );
156 cfg.setGroup( "Autostart" ); 155 cfg.setGroup( "Autostart" );
157 m_autoStart = cfg.readNumEntry( "autostart", 1 ); 156 m_autoStart = cfg.readNumEntry( "autostart", 1 );
158 m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); 157 m_guiMisc->CheckBoxAuto->setChecked( m_autoStart );
159 m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); 158 m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 );
160 m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); 159 m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer );
161 160
162 cfg.setGroup( "General" ); 161 cfg.setGroup( "General" );
163 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 162 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
164 m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); 163 m_guiMisc->SpinBoxIconSize->setValue( m_iconSize );
165 m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); 164 m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 );
166 m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); 165 m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) );
167} 166}
168 167
169/** 168/**
170 * Write the config part 169 * Write the config part
171 */ 170 */
172void TodayConfig::writeConfig() { 171void TodayConfig::writeConfig() {
173 OConfig cfg( "today" ); 172 OConfig cfg( "today" );
174 173
175 int position = m_appletListView->childCount(); 174 int position = m_appletListView->childCount();
176 175
177 QListViewItemIterator list_it( m_appletListView ); 176 QListViewItemIterator list_it( m_appletListView );
178 OPluginItem::List lst = m_pluginLoader->allAvailable( true ); 177 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
179 178
180 // this makes sure the names get saved in the order selected 179 // this makes sure the names get saved in the order selected
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" );
193 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); 197 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked();
194 cfg.writeEntry( "autostart", m_autoStart ); 198 cfg.writeEntry( "autostart", m_autoStart );
195 m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); 199 m_autoStartTimer = m_guiMisc->SpinBoxTime->value();
196 cfg.writeEntry( "autostartdelay", m_autoStartTimer ); 200 cfg.writeEntry( "autostartdelay", m_autoStartTimer );
197 m_iconSize = m_guiMisc->SpinBoxIconSize->value(); 201 m_iconSize = m_guiMisc->SpinBoxIconSize->value();
198 202
199 cfg.setGroup( "General" ); 203 cfg.setGroup( "General" );
200 cfg.writeEntry( "IconSize", m_iconSize ); 204 cfg.writeEntry( "IconSize", m_iconSize );
201 cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); 205 cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() );
202 cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); 206 cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 );
203 207
204 // set autostart settings 208 // set autostart settings
205 setAutoStart(); 209 setAutoStart();
206 210
207 OPluginItem::List managedLst = m_pluginManager->managedPlugins(); 211 OPluginItem::List managedLst = m_pluginManager->managedPlugins();
208 for ( OPluginItem::List::Iterator it = managedLst.begin(); it != managedLst.end(); ++it ) { 212 for ( OPluginItem::List::Iterator it = managedLst.begin(); it != managedLst.end(); ++it ) {
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
215 220
216void TodayConfig::moveSelectedUp() { 221void TodayConfig::moveSelectedUp() {
217 QListViewItem *item = m_appletListView->selectedItem(); 222 QListViewItem *item = m_appletListView->selectedItem();
218 if ( item && item->itemAbove() ) { 223 if ( item && item->itemAbove() ) {
219 item->itemAbove()->moveItem( item ); 224 item->itemAbove()->moveItem( item );
220 } 225 }
221} 226}
222 227
223 228
224void TodayConfig::moveSelectedDown() { 229void TodayConfig::moveSelectedDown() {
225 QListViewItem *item = m_appletListView->selectedItem(); 230 QListViewItem *item = m_appletListView->selectedItem();
226 if ( item && item->itemBelow() ) { 231 if ( item && item->itemBelow() ) {
227 item->moveItem( item->itemBelow() ); 232 item->moveItem( item->itemBelow() );
228 } 233 }
229} 234}
230 235
231 236
232/** 237/**
233 * Set up the icons in the order/active tab 238 * Set up the icons in the order/active tab
234 */ 239 */
235void TodayConfig::pluginManagement( OPluginItem plugItem ) { 240void TodayConfig::pluginManagement( OPluginItem plugItem ) {
236 241
237 QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox ); 242 QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox );
238 243
239 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface ); 244 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface );
240 QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() ); 245 QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() );
241 if ( !icon.isNull() ) { 246 if ( !icon.isNull() ) {
242 item->setPixmap( 0, icon ); 247 item->setPixmap( 0, icon );
243 } 248 }
244 item->setOn( plugItem.isEnabled() ); 249 item->setOn( plugItem.isEnabled() );
245 previousItem = item; 250 previousItem = item;
246} 251}
247 252
248 253
249 254
250TodayConfig::~TodayConfig() {} 255TodayConfig::~TodayConfig() {}