summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp54
-rw-r--r--core/pim/today/today.h3
-rw-r--r--core/pim/today/todayconfig.cpp51
3 files changed, 66 insertions, 42 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
@@ -63,245 +63,263 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
63#endif 63#endif
64#endif 64#endif
65 65
66 setOwnerField(); 66 setOwnerField();
67 refresh(); 67 refresh();
68 showMaximized(); 68 showMaximized();
69} 69}
70 70
71/** 71/**
72 * Qcop receive method. 72 * Qcop receive method.
73 */ 73 */
74void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 74void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
75 QDataStream stream( data, IO_ReadOnly ); 75 QDataStream stream( data, IO_ReadOnly );
76 if ( msg == "message(QString)" ) { 76 if ( msg == "message(QString)" ) {
77 QString message; 77 QString message;
78 stream >> message; 78 stream >> message;
79 setOwnerField( message ); 79 setOwnerField( message );
80 } 80 }
81} 81}
82 82
83/** 83/**
84 * Initialises the owner field with the default value, the username 84 * Initialises the owner field with the default value, the username
85 */ 85 */
86void Today::setOwnerField() { 86void Today::setOwnerField() {
87 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 87 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
88 if ( QFile::exists( file ) ) { 88 if ( QFile::exists( file ) ) {
89 Contact cont = Contact::readVCard( file )[0]; 89 Contact cont = Contact::readVCard( file )[0];
90 QString returnString = cont.fullName(); 90 QString returnString = cont.fullName();
91 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 91 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
92 } else { 92 } else {
93 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 93 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
94 } 94 }
95} 95}
96 96
97/** 97/**
98 * Set the owner field with a given QString, for example per qcop. 98 * Set the owner field with a given QString, for example per qcop.
99 */ 99 */
100void Today::setOwnerField( QString &message ) { 100void Today::setOwnerField( QString &message ) {
101 if ( !message.isEmpty() ) { 101 if ( !message.isEmpty() ) {
102 OwnerField->setText( "<b>" + message + "</b>" ); 102 OwnerField->setText( "<b>" + message + "</b>" );
103 } 103 }
104} 104}
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 */
110void Today::init() { 110void 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 */
127void Today::loadPlugins() { 123void Today::loadPlugins() {
128 124
129 QValueList<TodayPlugin>::Iterator tit; 125 QValueList<TodayPlugin>::Iterator tit;
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 ) {
149 qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); 147 qDebug( "loading: %s", QString( path + "/" + *it ).latin1() );
150 qDebug( QString(*it) ); 148 qDebug( QString(*it) );
151 TodayPlugin plugin; 149 TodayPlugin plugin;
152 plugin.library = lib; 150 plugin.library = lib;
153 plugin.iface = iface; 151 plugin.iface = iface;
154 plugin.name = QString(*it); 152 plugin.name = QString(*it);
155 153
156 // find out if plugins should be shown 154 // find out if plugins should be shown
157 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 155 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
158 plugin.active = true; 156 plugin.active = true;
159 } else { 157 } else {
160 plugin.active = false; 158 plugin.active = false;
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 */
201void Today::draw() { 213void Today::draw() {
202 214
203 if ( pluginList.count() == 0 ) { 215 if ( pluginList.count() == 0 ) {
204 QLabel *noPlugins = new QLabel( this ); 216 QLabel *noPlugins = new QLabel( this );
205 noPlugins->setText( tr( "No plugins found" ) ); 217 noPlugins->setText( tr( "No plugins found" ) );
206 layout->addWidget( noPlugins ); 218 layout->addWidget( noPlugins );
207 return; 219 return;
208 } 220 }
209 221
210 uint count = 0; 222 uint count = 0;
211 TodayPlugin plugin; 223 TodayPlugin plugin;
212 for ( uint i = 0; i < pluginList.count(); i++ ) { 224 for ( uint i = 0; i < pluginList.count(); i++ ) {
213 plugin = pluginList[i]; 225 plugin = pluginList[i];
214 226
215 if ( plugin.active ) { 227 if ( plugin.active ) {
216 qDebug( plugin.name + " is ACTIVE " ); 228 qDebug( plugin.name + " is ACTIVE " );
217 plugin.guiBox->show(); 229 plugin.guiBox->show();
218 } else { 230 } else {
219 qDebug( plugin.name + " is INACTIVE" ); 231 qDebug( plugin.name + " is INACTIVE" );
220 plugin.guiBox->hide(); 232 plugin.guiBox->hide();
221 } 233 }
222 count++; 234 count++;
223 } 235 }
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 */
238void Today::startConfig() { 249void 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() ) );
256 } 268 }
257 269
258 if ( conf.exec() == QDialog::Accepted ) { 270 if ( conf.exec() == QDialog::Accepted ) {
259 conf.writeConfig(); 271 conf.writeConfig();
260 ConfigWidget *confWidget; 272 ConfigWidget *confWidget;
261 for ( confWidget = configWidgetList.first(); confWidget != 0; 273 for ( confWidget = configWidgetList.first(); confWidget != 0;
262 confWidget = configWidgetList.next() ) { 274 confWidget = configWidgetList.next() ) {
263 confWidget->writeConfig(); 275 confWidget->writeConfig();
264 } 276 }
265 refresh(); 277 refresh();
266 } 278 }
267} 279}
268 280
269 281
270/** 282/**
271 * Refresh for the view. Reload all applets 283 * Refresh for the view. Reload all applets
272 * 284 *
273 */ 285 */
274void Today::refresh() { 286void 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 );
283 301
284 loadPlugins(); 302 loadPlugins();
285 draw(); 303 draw();
286} 304}
287 305
288void Today::startAddressbook() { 306void Today::startAddressbook() {
289 QCopEnvelope e( "QPE/System", "execute(QString)" ); 307 QCopEnvelope e( "QPE/System", "execute(QString)" );
290 e << QString( "addressbook" ); 308 e << QString( "addressbook" );
291} 309}
292 310
293 311
294/** 312/**
295 * launch addressbook (personal card) 313 * launch addressbook (personal card)
296 */ 314 */
297void Today::editCard() { 315void Today::editCard() {
298 startAddressbook(); 316 startAddressbook();
299 while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { 317 while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) {
300 qApp->processEvents(); 318 qApp->processEvents();
301 } 319 }
302 QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); 320 QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" );
303} 321}
304 322
305Today::~Today() { 323Today::~Today() {
306} 324}
307 325
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index 672adc4..b35c9b1 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -1,72 +1,73 @@
1/* 1/*
2 * today.h 2 * today.h
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 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 17
18#ifndef TODAY_H 18#ifndef TODAY_H
19#define TODAY_H 19#define TODAY_H
20 20
21#include <opie/tododb.h> 21#include <opie/tododb.h>
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qlist.h> 24#include <qlist.h>
25#include <qhbox.h> 25#include <qhbox.h>
26 26
27#include <qpe/qlibrary.h> 27#include <qpe/qlibrary.h>
28#include <qpe/event.h> 28#include <qpe/event.h>
29 29
30#include "todayconfig.h" 30#include "todayconfig.h"
31#include "todaybase.h" 31#include "todaybase.h"
32#include "todayplugininterface.h" 32#include "todayplugininterface.h"
33 33
34class QVBoxLayout; 34class QVBoxLayout;
35 35
36 36
37
37class Today : public TodayBase { 38class Today : public TodayBase {
38 39
39 Q_OBJECT 40 Q_OBJECT
40 41
41 public: 42 public:
42 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 43 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
43 ~Today(); 44 ~Today();
44 45
45private slots: 46private slots:
46 void startConfig(); 47 void startConfig();
47 void startAddressbook(); 48 void startAddressbook();
48 void editCard(); 49 void editCard();
49 void refresh(); 50 void refresh();
50 51
51private: 52private:
52 void init(); 53 void init();
53 void setOwnerField(); 54 void setOwnerField();
54 void setOwnerField(QString &string); 55 void setOwnerField(QString &string);
55 void loadPlugins(); 56 void loadPlugins();
56 void draw(); 57 void draw();
57 58
58
59private slots: 59private slots:
60 void channelReceived(const QCString &msg, const QByteArray & data); 60 void channelReceived(const QCString &msg, const QByteArray & data);
61 61
62 private: 62 private:
63 TodayConfig *conf; 63 TodayConfig *conf;
64 QStringList m_excludeApplets; 64 QStringList m_excludeApplets;
65 QStringList m_allApplets;
65 66
66 // QString m_autoStartTimer; 67 // QString m_autoStartTimer;
67 int m_newStart; 68 int m_newStart;
68 // int m_autoStart; 69 // int m_autoStart;
69 int m_maxCharClip; 70 int m_maxCharClip;
70}; 71};
71 72
72#endif 73#endif
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp
index 4f23471..532d126 100644
--- a/core/pim/today/todayconfig.cpp
+++ b/core/pim/today/todayconfig.cpp
@@ -1,215 +1,220 @@
1/* 1/*
2 * todayconfig.cpp 2 * todayconfig.cpp
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 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 <qpe/config.h> 19#include <qpe/config.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22 22
23#include <qcheckbox.h> 23#include <qcheckbox.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qspinbox.h> 25#include <qspinbox.h>
26#include <qtabwidget.h> 26#include <qtabwidget.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qheader.h> 28#include <qheader.h>
29#include <qhbox.h> 29#include <qhbox.h>
30#include <qvbox.h> 30#include <qvbox.h>
31#include <qtoolbutton.h> 31#include <qtoolbutton.h>
32 32
33class ToolButton : public QToolButton { 33class ToolButton : public QToolButton {
34 34
35public: 35public:
36 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 36 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
37 : QToolButton( parent, name ) { 37 : QToolButton( parent, name ) {
38 // setTextLabel( name );
39 setPixmap( Resource::loadPixmap( icon ) ); 38 setPixmap( Resource::loadPixmap( icon ) );
40 setAutoRaise( TRUE ); 39 setAutoRaise( TRUE );
41 setFocusPolicy( QWidget::NoFocus ); 40 setFocusPolicy( QWidget::NoFocus );
42 setToggleButton( t ); 41 setToggleButton( t );
43 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 42 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
44 } 43 }
45}; 44};
46 45
47 46
48/** 47/**
49 * The class has currently quite some duplicate code. 48 * The class has currently quite some duplicate code.
50 * By that way it would be real easy to have it as seperate app in settings tab 49 * By that way it would be real easy to have it as seperate app in settings tab
51 * 50 *
52 */ 51 */
53TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags fl ) 52TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags fl )
54 : QDialog( parent, name, modal, fl ) { 53 : QDialog( parent, name, modal, fl ) {
55 54
56 setCaption( tr( "Today config" ) ); 55 setCaption( tr( "Today config" ) );
57 56
58 QVBoxLayout *layout = new QVBoxLayout( this ); 57 QVBoxLayout *layout = new QVBoxLayout( this );
59 TabWidget3 = new QTabWidget( this, "TabWidget3" ); 58 TabWidget3 = new QTabWidget( this, "TabWidget3" );
60 TabWidget3->setAutoMask( FALSE ); 59 TabWidget3->setAutoMask( FALSE );
61 TabWidget3->setTabShape( QTabWidget::Rounded ); 60 TabWidget3->setTabShape( QTabWidget::Rounded );
62 layout->addWidget( TabWidget3 ); 61 layout->addWidget( TabWidget3 );
63 62
64 tab_2 = new QWidget( TabWidget3, "tab_2" ); 63 tab_2 = new QWidget( TabWidget3, "tab_2" );
65 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); 64 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 );
66 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); 65 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 );
67 tab2Layout->addWidget( l ); 66 tab2Layout->addWidget( l );
68 QHBox *hbox1 = new QHBox( tab_2 ); 67 QHBox *hbox1 = new QHBox( tab_2 );
69 m_appletListView = new QListView( hbox1 ); 68 m_appletListView = new QListView( hbox1 );
70 m_appletListView->addColumn( "PluginList" ); 69 m_appletListView->addColumn( "PluginList" );
71 m_appletListView->header()->hide(); 70 m_appletListView->header()->hide();
71 m_appletListView->setSorting( -1 );
72 QVBox *vbox1 = new QVBox( hbox1 ); 72 QVBox *vbox1 = new QVBox( hbox1 );
73 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) ); 73 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) );
74 new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) ); 74 new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) );
75 tab2Layout->addWidget( hbox1 ); 75 tab2Layout->addWidget( hbox1 );
76
77 TabWidget3->insertTab( tab_2, tr( "active/order" ) ); 76 TabWidget3->insertTab( tab_2, tr( "active/order" ) );
77
78 tab_3 = new QWidget( TabWidget3, "tab_3" ); 78 tab_3 = new QWidget( TabWidget3, "tab_3" );
79 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); 79 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 );
80 QHBox *hbox_clip = new QHBox( tab_3 ); 80 tab3Layout->setMargin( 20 );
81 TextLabel1 = new QLabel( hbox_clip, "TextLabel1" );
82 TextLabel1->setText( tr( "Clip after how\n"
83 "many letters" ) );
84 SpinBox7 = new QSpinBox( hbox_clip, "SpinBox7" );
85 SpinBox7->setMaxValue( 80 );
86 QHBox *hbox_auto = new QHBox( tab_3 ); 81 QHBox *hbox_auto = new QHBox( tab_3 );
87 TextLabel2 = new QLabel( hbox_auto, "AutoStart" ); 82 TextLabel2 = new QLabel( hbox_auto, "AutoStart" );
88 TextLabel2->setText( tr( "autostart on \nresume? (Opie only)" ) ); 83 TextLabel2->setText( tr( "autostart on \nresume?\n (Opie only)" ) );
89 CheckBoxAuto = new QCheckBox( hbox_auto, "CheckBoxAuto" ); 84 CheckBoxAuto = new QCheckBox( hbox_auto, "CheckBoxAuto" );
90 QHBox *hbox_inactive = new QHBox( tab_3 ); 85 QHBox *hbox_inactive = new QHBox( tab_3 );
91 TimeLabel = new QLabel( hbox_inactive , "TimeLabel" ); 86 TimeLabel = new QLabel( hbox_inactive , "TimeLabel" );
92 TimeLabel->setText( tr( "minutes inactive" ) ); 87 TimeLabel->setText( tr( "minutes inactive" ) );
93 SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner"); 88 SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner" );
94 tab3Layout->addWidget( hbox_clip );
95 tab3Layout->addWidget( hbox_auto ); 89 tab3Layout->addWidget( hbox_auto );
96 tab3Layout->addWidget( hbox_inactive ); 90 tab3Layout->addWidget( hbox_inactive );
97 TabWidget3->insertTab( tab_3, tr( "Misc" ) ); 91 TabWidget3->insertTab( tab_3, tr( "Misc" ) );
98 92
99 m_applets_changed = false; 93 m_applets_changed = false;
100 94
101 connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); 95 connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) );
102 96
103 readConfig(); 97 readConfig();
104 showMaximized(); 98 showMaximized();
105} 99}
106 100
107 101
108/** 102/**
109 * Autostart, uses the new (opie only) autostart method in the launcher code. 103 * Autostart, uses the new (opie only) autostart method in the launcher code.
110 * If registered against that today ist started on each resume. 104 * If registered against that today ist started on each resume.
111 */ 105 */
112void TodayConfig::setAutoStart() { 106void TodayConfig::setAutoStart() {
113 Config cfg( "today" ); 107 Config cfg( "today" );
114 cfg.setGroup( "Autostart" ); 108 cfg.setGroup( "Autostart" );
115 int autostart = cfg.readNumEntry( "autostart", 1); 109 int autostart = cfg.readNumEntry( "autostart", 1 );
116 if ( autostart ) { 110 if ( autostart ) {
117 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); 111 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" );
118 e << QString( "add" ); 112 e << QString( "add" );
119 e << QString( "today" ); 113 e << QString( "today" );
120 e << m_autoStartTimer; 114 e << m_autoStartTimer;
121 } else { 115 } else {
122 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); 116 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" );
123 e << QString( "remove" ); 117 e << QString( "remove" );
124 e << QString( "today" ); 118 e << QString( "today" );
125 } 119 }
126} 120}
127 121
128/** 122/**
129 * Read the config part 123 * Read the config part
130 */ 124 */
131void TodayConfig::readConfig() { 125void TodayConfig::readConfig() {
132 Config cfg( "today" ); 126 Config cfg( "today" );
133 cfg.setGroup( "Autostart" ); 127 cfg.setGroup( "Autostart" );
134 m_autoStart = cfg.readNumEntry( "autostart", 1 ); 128 m_autoStart = cfg.readNumEntry( "autostart", 1 );
135 CheckBoxAuto->setChecked( m_autoStart ); 129 CheckBoxAuto->setChecked( m_autoStart );
136 m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" ); 130 m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" );
137 SpinBoxTime->setValue( m_autoStartTimer.toInt() ); 131 SpinBoxTime->setValue( m_autoStartTimer.toInt() );
138 132
139 cfg.setGroup( "Applets" ); 133 cfg.setGroup( "Plugins" );
140 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 134 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
141} 135}
142 136
143/** 137/**
144 * Write the config part 138 * Write the config part
145 */ 139 */
146void TodayConfig::writeConfig() { 140void TodayConfig::writeConfig() {
147 Config cfg( "today" ); 141 Config cfg( "today" );
148 cfg. setGroup ( "Applets" ); 142 cfg.setGroup( "Plugins" );
149 if ( m_applets_changed ) { 143 if ( m_applets_changed ) {
150 QStringList exclude; 144 QStringList exclude;
151 QStringList include; 145 QStringList include;
152 QMap <QString, QCheckListItem *>::Iterator it; 146 QStringList all_applets;
153 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { 147
154 if ( !(*it)-> isOn () ) { 148 QListViewItemIterator list_it( m_appletListView );
155 exclude << it.key(); 149
156 } else { 150 // this makes sure the names get saved in the order selected
157 include << it.key(); 151 for ( ; list_it.current(); ++list_it ) {
152 QMap <QString, QCheckListItem *>::Iterator it;
153 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) {
154 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
155 exclude << it.key();
156 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
157 include << it.key();
158 }
159 if ( list_it.current() == (*it) ) {
160 all_applets << it.key();
161 }
158 } 162 }
159 } 163 }
160 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 164 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
161 cfg.writeEntry( "IncludeApplets", include, ',' ); 165 cfg.writeEntry( "IncludeApplets", include, ',' );
166 cfg.writeEntry( "AllApplets", all_applets, ',' );
162 } 167 }
163 168
164 cfg.setGroup( "Autostart" ); 169 cfg.setGroup( "Autostart" );
165 m_autoStart = CheckBoxAuto->isChecked(); 170 m_autoStart = CheckBoxAuto->isChecked();
166 cfg.writeEntry( "autostart", m_autoStart ); 171 cfg.writeEntry( "autostart", m_autoStart );
167 m_autoStartTimer = SpinBoxTime->value(); 172 m_autoStartTimer = SpinBoxTime->value();
168 cfg.readEntry( "autostartdelay", m_autoStartTimer ); 173 cfg.readEntry( "autostartdelay", m_autoStartTimer );
169} 174}
170 175
171 176
172void TodayConfig::moveSelectedUp() { 177void TodayConfig::moveSelectedUp() {
173 QListViewItem *item = m_appletListView->selectedItem(); 178 QListViewItem *item = m_appletListView->selectedItem();
174 if ( item && item->itemAbove() ) { 179 if ( item && item->itemAbove() ) {
175 item->itemAbove()->moveItem( item ); 180 item->itemAbove()->moveItem( item );
176 } 181 }
177} 182}
178 183
179 184
180void TodayConfig::moveSelectedDown() { 185void TodayConfig::moveSelectedDown() {
181 QListViewItem *item = m_appletListView->selectedItem(); 186 QListViewItem *item = m_appletListView->selectedItem();
182 if ( item && item->itemBelow() ) { 187 if ( item && item->itemBelow() ) {
183 item->moveItem( item->itemBelow() ); 188 item->moveItem( item->itemBelow() );
184 } 189 }
185} 190}
186 191
187 192
188/** 193/**
189 * Set up the 194 * Set up the
190 */ 195 */
191void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { 196void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) {
192 197
193 QCheckListItem *item; 198 QCheckListItem *item;
194 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); 199 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox );
195 200
196 if ( !icon.isNull() ) { 201 if ( !icon.isNull() ) {
197 item->setPixmap( 0, icon ); 202 item->setPixmap( 0, icon );
198 } 203 }
199 204
200 qDebug (" SUCHNAME: " + name );
201 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { 205 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) {
202 item->setOn( TRUE ); 206 item->setOn( TRUE );
203 } 207 }
208
204 m_applets[libName] = item; 209 m_applets[libName] = item;
205} 210}
206 211
207 212
208void TodayConfig::appletChanged() { 213void TodayConfig::appletChanged() {
209 m_applets_changed = true; 214 m_applets_changed = true;
210} 215}
211 216
212 217
213TodayConfig::~TodayConfig() { 218TodayConfig::~TodayConfig() {
214} 219}
215 220