summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/addressbook/addresspluginconfig.cpp61
-rw-r--r--core/pim/today/plugins/addressbook/addresspluginconfig.h3
-rw-r--r--core/pim/today/plugins/addressbook/addresspluginwidget.cpp93
-rw-r--r--core/pim/today/plugins/addressbook/addresspluginwidget.h2
4 files changed, 107 insertions, 52 deletions
diff --git a/core/pim/today/plugins/addressbook/addresspluginconfig.cpp b/core/pim/today/plugins/addressbook/addresspluginconfig.cpp
index a234236..9c65e7d 100644
--- a/core/pim/today/plugins/addressbook/addresspluginconfig.cpp
+++ b/core/pim/today/plugins/addressbook/addresspluginconfig.cpp
@@ -1,152 +1,175 @@
1/* 1/*
2 * addresspluginconfig.cpp 2 * addresspluginconfig.cpp
3 * 3 *
4 * copyright : (c) 2003 by Stefan Eilers 4 * copyright : (c) 2003 by Stefan Eilers
5 * email : eilers.stefan@epost.de 5 * email : eilers.stefan@epost.de
6 * 6 *
7 * This implementation was derived from the todolist plugin implementation 7 * This implementation was derived from the todolist plugin implementation
8 * 8 *
9 */ 9 */
10/*************************************************************************** 10/***************************************************************************
11 * * 11 * *
12 * This program is free software; you can redistribute it and/or modify * 12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by * 13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or * 14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. * 15 * (at your option) any later version. *
16 * * 16 * *
17 ***************************************************************************/ 17 ***************************************************************************/
18 18
19#include "addresspluginconfig.h" 19#include "addresspluginconfig.h"
20 20
21#include <qpe/config.h> 21#include <qpe/config.h>
22 22
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qtoolbutton.h> 25#include <qtoolbutton.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qvgroupbox.h>
28 29
29 30
30AddressBookPluginConfig::AddressBookPluginConfig( QWidget *parent, const char* name) 31AddressBookPluginConfig::AddressBookPluginConfig( QWidget *parent, const char* name)
31 : TodayConfigWidget(parent, name ) { 32 : TodayConfigWidget(parent, name ) {
32 33
33 QVBoxLayout * layout = new QVBoxLayout( this ); 34 QVBoxLayout * layout = new QVBoxLayout( this );
34 layout->setMargin( 20 ); 35 layout->setMargin( 20 );
35 36
36 QHBox *box1 = new QHBox( this ); 37#if 0
38 // Informational stuff
39 QHBox *box4 = new QHBox( this );
40 QLabel* colorLabel = new QLabel( box4, "" );
41 colorLabel->setText( tr( "To activate settings: Restart application !" ) );
42#endif
43
44 // Buttongroup to enable/disable shown stuff
45 QVGroupBox* b_group = new QVGroupBox( this, "name" );
46 b_group -> setTitle( tr("Enable/Disable Views") );
47 m_showBirthdayButton = new QRadioButton( b_group );
48 m_showBirthdayButton -> setText( tr( "Show &Birthdays" ) );
49 m_showAnniversaryButton = new QRadioButton( b_group );
50 m_showAnniversaryButton -> setText( tr( "Show &Anniveraries" ) );
51
52 QWhatsThis::add( m_showBirthdayButton , tr( "The next birthdays will just be shown, if enabled!" ) );
53 QWhatsThis::add( m_showAnniversaryButton , tr( "The next anniversaries will just be shown, if enabled !" ) );
37 54
55 // Max lines settings
56 QHBox *box1 = new QHBox( this );
38 QLabel* TextLabel6 = new QLabel( box1, "TextLabel6" ); 57 QLabel* TextLabel6 = new QLabel( box1, "TextLabel6" );
39 TextLabel6->setText( tr( "Max Lines: " ) ); 58 TextLabel6->setText( tr( "Max Lines: " ) );
40
41 SpinBox2 = new QSpinBox( box1, "SpinBox2" ); 59 SpinBox2 = new QSpinBox( box1, "SpinBox2" );
42 SpinBox2->setMaxValue( 40 ); 60 SpinBox2->setMaxValue( 40 );
43 QWhatsThis::add( SpinBox2 , tr( "Set the maximum number of lines that should be shown for each anniversaries/birthdays" ) ); 61 QWhatsThis::add( SpinBox2 , tr( "Set the maximum number of lines that should be shown for each anniversaries/birthdays" ) );
44 62
63#if 0
64 // Clip settings (currently not used)
45 QHBox *box2 = new QHBox( this ); 65 QHBox *box2 = new QHBox( this );
46
47 QLabel* clipLabel = new QLabel( box2, "" ); 66 QLabel* clipLabel = new QLabel( box2, "" );
48 clipLabel->setText( tr( "Clip line after X chars: " ) ); 67 clipLabel->setText( tr( "Clip line after X chars: " ) );
49
50 SpinBoxClip = new QSpinBox( box2, "SpinClip" ); 68 SpinBoxClip = new QSpinBox( box2, "SpinClip" );
51 SpinBoxClip->setMaxValue( 200 ); 69 SpinBoxClip->setMaxValue( 200 );
52 QWhatsThis::add( SpinBoxClip , tr( "After how many chars should be the info about the task be cut off" ) ); 70 QWhatsThis::add( SpinBoxClip , tr( "After how many chars should be the info about the task be cut off" ) );
71#endif
53 72
73 // Look ahead settings
54 QHBox *box3 = new QHBox( this ); 74 QHBox *box3 = new QHBox( this );
55
56 QLabel* daysLabel = new QLabel( box3, "" ); 75 QLabel* daysLabel = new QLabel( box3, "" );
57 daysLabel->setText( tr( "Days look ahead: " ) ); 76 daysLabel->setText( tr( "Days look ahead: " ) );
58 SpinDaysClip = new QSpinBox( box3, "SpinDays" ); 77 SpinDaysClip = new QSpinBox( box3, "SpinDays" );
59 SpinDaysClip->setMaxValue( 200 ); 78 SpinDaysClip->setMaxValue( 200 );
60 QWhatsThis::add( SpinDaysClip , tr( "How many days we should search forward" ) ); 79 QWhatsThis::add( SpinDaysClip , tr( "How many days we should search forward" ) );
61 80
62 QHBox *box4 = new QHBox( this ); 81 // Headline color settings
63
64 QLabel* colorLabel = new QLabel( box4, "" );
65 colorLabel->setText( tr( "To activate settings: Restart application !" ) );
66
67 QHBox *box5 = new QHBox( this ); 82 QHBox *box5 = new QHBox( this );
68
69 QLabel* colorLabel2 = new QLabel( box5, "" ); 83 QLabel* colorLabel2 = new QLabel( box5, "" );
70 colorLabel2->setText( tr( "Set Headline Color: " ) ); 84 colorLabel2->setText( tr( "Set Headline Color: " ) );
71 headlineColor = new OColorButton( box5, black , "headlineColor" ); 85 headlineColor = new OColorButton( box5, black , "headlineColor" );
72 QWhatsThis::add( headlineColor , tr( "Colors for the headlines !" ) ); 86 QWhatsThis::add( headlineColor , tr( "Colors for the headlines !" ) );
73
74 QHBox *box6 = new QHBox( this ); 87 QHBox *box6 = new QHBox( this );
75 88
89 // Entry color settings
76 QLabel* colorLabel3= new QLabel( box6, "" ); 90 QLabel* colorLabel3= new QLabel( box6, "" );
77 colorLabel3->setText( tr( "Set Entry Color: " ) ); 91 colorLabel3->setText( tr( "Set Entry Color: " ) );
78 entryColor = new OColorButton( box6, black , "entryColor" ); 92 entryColor = new OColorButton( box6, black , "entryColor" );
79 QWhatsThis::add( entryColor , tr( "This color will be used for shown birthdays/anniversaries !" ) ); 93 QWhatsThis::add( entryColor , tr( "This color will be used for shown birthdays/anniversaries !" ) );
80 94
95 // Urgent color settings
81 QHBox *box7 = new QHBox( this ); 96 QHBox *box7 = new QHBox( this );
82
83 QLabel* colorLabel5 = new QLabel( box7, "" ); 97 QLabel* colorLabel5 = new QLabel( box7, "" );
84 colorLabel5->setText( tr( "Set Urgent\nColor if below " ) ); 98 colorLabel5->setText( tr( "Set Urgent\nColor if below " ) );
85 SpinUrgentClip = new QSpinBox( box7, "SpinDays" ); 99 SpinUrgentClip = new QSpinBox( box7, "SpinDays" );
86 SpinUrgentClip->setMaxValue( 200 ); 100 SpinUrgentClip->setMaxValue( 200 );
87 QLabel* colorLabel6 = new QLabel( box7, "" ); 101 QLabel* colorLabel6 = new QLabel( box7, "" );
88 colorLabel6->setText( tr( " days: " ) ); 102 colorLabel6->setText( tr( " days: " ) );
89 urgentColor = new OColorButton( box7, red , "urgentColor" ); 103 urgentColor = new OColorButton( box7, red , "urgentColor" );
90 QWhatsThis::add( urgentColor , tr( "This urgent color will be used if we are close to the event !" ) ); 104 QWhatsThis::add( urgentColor , tr( "This urgent color will be used if we are close to the event !" ) );
91 QWhatsThis::add( SpinUrgentClip , tr( "The urgent color will be used if the birthday/anniversary is closer than given days !" ) ); 105 QWhatsThis::add( SpinUrgentClip , tr( "The urgent color will be used if the birthday/anniversary is closer than given days !" ) );
92 106
93 107
94 layout->addWidget( box4 ); 108 layout->addWidget( b_group );
109 // layout->addWidget( box4 );
95 layout->addWidget( box1 ); 110 layout->addWidget( box1 );
96 layout->addWidget( box2 ); 111 // layout->addWidget( box2 );
97 layout->addWidget( box3 ); 112 layout->addWidget( box3 );
98 layout->addWidget( box5 ); 113 layout->addWidget( box5 );
99 layout->addWidget( box6 ); 114 layout->addWidget( box6 );
100 layout->addWidget( box7 ); 115 layout->addWidget( box7 );
101 116
102 readConfig(); 117 readConfig();
103 118
104} 119}
105 120
106void AddressBookPluginConfig::readConfig() { 121void AddressBookPluginConfig::readConfig() {
107 Config cfg( "todayaddressplugin" ); 122 Config cfg( "todayaddressplugin" );
108 cfg.setGroup( "config" ); 123 cfg.setGroup( "config" );
109 m_max_lines_task = cfg.readNumEntry( "maxlinestask", 5 ); 124 m_max_lines_task = cfg.readNumEntry( "maxlinestask", 5 );
110 SpinBox2->setValue( m_max_lines_task ); 125 SpinBox2->setValue( m_max_lines_task );
111 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); 126// m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
112 SpinBoxClip->setValue( m_maxCharClip ); 127// SpinBoxClip->setValue( m_maxCharClip );
113 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); 128 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 );
114 SpinDaysClip->setValue( m_daysLookAhead ); 129 SpinDaysClip->setValue( m_daysLookAhead );
115 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); 130 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 );
116 SpinUrgentClip->setValue( m_urgentDays ); 131 SpinUrgentClip->setValue( m_urgentDays );
117 132
118 m_entryColor = cfg.readEntry( "entrycolor", Qt::black.name() ); 133 m_entryColor = cfg.readEntry( "entrycolor", Qt::black.name() );
119 entryColor->setColor( QColor( m_entryColor ) ); 134 entryColor->setColor( QColor( m_entryColor ) );
120 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); 135 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() );
121 headlineColor->setColor( QColor( m_headlineColor ) ); 136 headlineColor->setColor( QColor( m_headlineColor ) );
122 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); 137 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() );
123 urgentColor->setColor( QColor( m_urgentColor ) ); 138 urgentColor->setColor( QColor( m_urgentColor ) );
139
140 m_showBirthdayButton->setChecked( cfg.readBoolEntry( "showBirthdays", true ) );
141 m_showAnniversaryButton->setChecked( cfg.readBoolEntry( "showAnniversaries", true ) );
142
124} 143}
125 144
126 145
127void AddressBookPluginConfig::writeConfig() { 146void AddressBookPluginConfig::writeConfig() {
128 Config cfg( "todayaddressplugin" ); 147 Config cfg( "todayaddressplugin" );
129 cfg.setGroup( "config" ); 148 cfg.setGroup( "config" );
130 m_max_lines_task = SpinBox2->value(); 149 m_max_lines_task = SpinBox2->value();
131 cfg.writeEntry( "maxlinestask", m_max_lines_task ); 150 cfg.writeEntry( "maxlinestask", m_max_lines_task );
132 m_maxCharClip = SpinBoxClip->value(); 151// m_maxCharClip = SpinBoxClip->value();
133 cfg.writeEntry( "maxcharclip", m_maxCharClip ); 152// cfg.writeEntry( "maxcharclip", m_maxCharClip );
134 m_daysLookAhead = SpinDaysClip->value(); 153 m_daysLookAhead = SpinDaysClip->value();
135 cfg.writeEntry( "dayslookahead", m_daysLookAhead ); 154 cfg.writeEntry( "dayslookahead", m_daysLookAhead );
136 m_urgentDays = SpinUrgentClip->value(); 155 m_urgentDays = SpinUrgentClip->value();
137 if ( m_urgentDays > m_daysLookAhead ) 156 if ( m_urgentDays > m_daysLookAhead )
138 m_urgentDays = m_daysLookAhead; 157 m_urgentDays = m_daysLookAhead;
139 cfg.writeEntry( "urgentdays", m_urgentDays ); 158 cfg.writeEntry( "urgentdays", m_urgentDays );
140 159
141 m_entryColor = entryColor->color().name(); 160 m_entryColor = entryColor->color().name();
142 cfg.writeEntry( "entrycolor", m_entryColor ); 161 cfg.writeEntry( "entrycolor", m_entryColor );
143 m_headlineColor = headlineColor->color().name(); 162 m_headlineColor = headlineColor->color().name();
144 cfg.writeEntry( "headlinecolor", m_headlineColor ); 163 cfg.writeEntry( "headlinecolor", m_headlineColor );
145 m_urgentColor = urgentColor->color().name(); 164 m_urgentColor = urgentColor->color().name();
146 cfg.writeEntry( "urgentcolor", m_urgentColor ); 165 cfg.writeEntry( "urgentcolor", m_urgentColor );
166
167 cfg.writeEntry( "showBirthdays", m_showBirthdayButton->isChecked() );
168 cfg.writeEntry( "showAnniversaries", m_showAnniversaryButton->isChecked() );
169
147 cfg.write(); 170 cfg.write();
148} 171}
149 172
150 173
151AddressBookPluginConfig::~AddressBookPluginConfig() { 174AddressBookPluginConfig::~AddressBookPluginConfig() {
152} 175}
diff --git a/core/pim/today/plugins/addressbook/addresspluginconfig.h b/core/pim/today/plugins/addressbook/addresspluginconfig.h
index ea03368..5e07aa3 100644
--- a/core/pim/today/plugins/addressbook/addresspluginconfig.h
+++ b/core/pim/today/plugins/addressbook/addresspluginconfig.h
@@ -1,72 +1,75 @@
1/* 1/*
2 * addresspluginconfig.h 2 * addresspluginconfig.h
3 * 3 *
4 * copyright : (c) 2003 by Stefan Eilers 4 * copyright : (c) 2003 by Stefan Eilers
5 * email : eilers.stefan@epost.de 5 * email : eilers.stefan@epost.de
6 * 6 *
7 * This implementation was derived from the todolist plugin implementation 7 * This implementation was derived from the todolist plugin implementation
8 * 8 *
9 */ 9 */
10/*************************************************************************** 10/***************************************************************************
11 * * 11 * *
12 * This program is free software; you can redistribute it and/or modify * 12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by * 13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or * 14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. * 15 * (at your option) any later version. *
16 * * 16 * *
17 ***************************************************************************/ 17 ***************************************************************************/
18 18
19#ifndef ADDRESSBOOK_PLUGIN_CONFIG_H 19#ifndef ADDRESSBOOK_PLUGIN_CONFIG_H
20#define ADDRESSBOOK_PLUGIN_CONFIG_H 20#define ADDRESSBOOK_PLUGIN_CONFIG_H
21 21
22#include <qwidget.h> 22#include <qwidget.h>
23#include <qspinbox.h> 23#include <qspinbox.h>
24#include <qradiobutton.h>
24 25
25#include <opie/todayconfigwidget.h> 26#include <opie/todayconfigwidget.h>
26#include <opie/ocolorbutton.h> 27#include <opie/ocolorbutton.h>
27 28
28class AddressBookPluginConfig : public TodayConfigWidget { 29class AddressBookPluginConfig : public TodayConfigWidget {
29 30
30 31
31public: 32public:
32 33
33 AddressBookPluginConfig( QWidget *parent, const char *name ); 34 AddressBookPluginConfig( QWidget *parent, const char *name );
34 ~AddressBookPluginConfig(); 35 ~AddressBookPluginConfig();
35 36
36private: 37private:
37 /** 38 /**
38 * if changed then save 39 * if changed then save
39 */ 40 */
40 bool changed(); 41 bool changed();
41 void readConfig(); 42 void readConfig();
42 void writeConfig(); 43 void writeConfig();
43 44
44 QSpinBox* SpinBox2; 45 QSpinBox* SpinBox2;
45 QSpinBox* SpinBoxClip; 46 QSpinBox* SpinBoxClip;
46 QSpinBox* SpinDaysClip; 47 QSpinBox* SpinDaysClip;
47 QSpinBox* SpinUrgentClip; 48 QSpinBox* SpinUrgentClip;
48 OColorButton* entryColor; 49 OColorButton* entryColor;
49 OColorButton* headlineColor; 50 OColorButton* headlineColor;
50 OColorButton* urgentColor; 51 OColorButton* urgentColor;
52 QRadioButton* m_showBirthdayButton;
53 QRadioButton* m_showAnniversaryButton;
51 54
52 // how many lines should be showed in the AddressBook section 55 // how many lines should be showed in the AddressBook section
53 int m_max_lines_task; 56 int m_max_lines_task;
54 // clip the lines after X chars 57 // clip the lines after X chars
55 int m_maxCharClip; 58 int m_maxCharClip;
56 // How many days look ahead 59 // How many days look ahead
57 int m_daysLookAhead; 60 int m_daysLookAhead;
58 // Days until urgent color is used 61 // Days until urgent color is used
59 int m_urgentDays; 62 int m_urgentDays;
60 // Entry Color 63 // Entry Color
61 QString m_entryColor; 64 QString m_entryColor;
62 // Headline Color 65 // Headline Color
63 QString m_headlineColor; 66 QString m_headlineColor;
64 // Urgent Color 67 // Urgent Color
65 QString m_urgentColor; 68 QString m_urgentColor;
66}; 69};
67 70
68 71
69 72
70 73
71 74
72#endif 75#endif
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
index 7d87fca..498de28 100644
--- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
+++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
@@ -46,152 +46,179 @@ AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char*
46 m_contactdb = new OContactAccess("addressplugin"); 46 m_contactdb = new OContactAccess("addressplugin");
47 47
48 connect( m_contactdb, SIGNAL( signalChanged( const OContactAccess * ) ), 48 connect( m_contactdb, SIGNAL( signalChanged( const OContactAccess * ) ),
49 this, SLOT( refresh( const OContactAccess * ) ) ); 49 this, SLOT( refresh( const OContactAccess * ) ) );
50 50
51 51
52 readConfig(); 52 readConfig();
53 getAddress(); 53 getAddress();
54} 54}
55 55
56AddressBookPluginWidget::~AddressBookPluginWidget() { 56AddressBookPluginWidget::~AddressBookPluginWidget() {
57 delete m_contactdb; 57 delete m_contactdb;
58} 58}
59 59
60void AddressBookPluginWidget::refresh( const OContactAccess* ) 60void AddressBookPluginWidget::refresh( const OContactAccess* )
61{ 61{
62 qWarning(" AddressBookPluginWidget::Database was changed externally ! "); 62 qWarning(" AddressBookPluginWidget::Database was changed externally ! ");
63 m_contactdb->reload(); 63 m_contactdb->reload();
64 getAddress(); 64 getAddress();
65} 65}
66 66
67 67
68void AddressBookPluginWidget::readConfig() { 68void AddressBookPluginWidget::readConfig() {
69 Config cfg( "todayaddressplugin" ); 69 Config cfg( "todayaddressplugin" );
70 cfg.setGroup( "config" ); 70 cfg.setGroup( "config" );
71 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); 71 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 );
72 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); 72 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
73 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); 73 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 );
74 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); 74 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 );
75 m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); 75 m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() );
76 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); 76 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() );
77 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); 77 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() );
78 m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true );
79 m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true );
78} 80}
79 81
80 82
81/** 83/**
82 * Get the addresss 84 * Get the addresss
83 */ 85 */
84void AddressBookPluginWidget::getAddress() { 86void AddressBookPluginWidget::getAddress() {
85 87
86 if ( ! layoutTodo ){ 88 if ( ! layoutTodo ){
87 layoutTodo = new QVBoxLayout( this ); 89 layoutTodo = new QVBoxLayout( this );
88 } 90 }
89 91
90 if ( ! addressLabel ) { 92 if ( ! addressLabel ) {
91 addressLabel = new OClickableLabel( this ); 93 addressLabel = new OClickableLabel( this );
92 connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); 94 connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) );
93 layoutTodo->addWidget( addressLabel ); 95 layoutTodo->addWidget( addressLabel );
94 } 96 }
95 97
96 QString output; 98 QString output;
97 99
98 // Check whether the database provide the search option.. 100 // Check whether the database provide the search option..
99 if ( ! m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ 101 // The following if-statement was replaced due to a bug in some
100 102 // implementations of libopie. The replacement should work everywhere..(eilers)
101 // Define the query for birthdays and start search.. 103 // if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
102 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); 104 if ( !( m_contactdb->querySettings() & OContactAccess::DateDiff ) ){
103 qWarning("Searching from now (%s) until %s ! ", QDate::currentDate().toString().latin1(), 105 // Libopie seems to be old..
106 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" );
107 addressLabel->setText( output );
108 return;
109 }
110
111 // Define the query for birthdays and start search..
112 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead );
113 int ammount = 0;
114 if ( m_showBirthdays ){
115 qWarning("Searching from now (%s) until %s ! ",
116 QDate::currentDate().toString().latin1(),
104 lookAheadDate.toString().latin1() ); 117 lookAheadDate.toString().latin1() );
105 OContact querybirthdays; 118 OContact querybirthdays;
106 querybirthdays.setBirthday( lookAheadDate ); 119 querybirthdays.setBirthday( lookAheadDate );
107
108 int ammount = 0;
109 120
110 m_list = m_contactdb->queryByExample( querybirthdays, OContactAccess::DateDiff ); 121
122 m_list = m_contactdb->queryByExample( querybirthdays,
123 OContactAccess::DateDiff );
111 if ( m_list.count() > 0 ){ 124 if ( m_list.count() > 0 ){
112 output = "<font color=" + m_headlineColor + ">" 125 output = "<font color=" + m_headlineColor + ">"
113 + QObject::tr( "Next birthdays in <b> %1 </b> days:" ).arg( m_daysLookAhead ) 126 + QObject::tr( "Next birthdays in <b> %1 </b> days:" )
127 .arg( m_daysLookAhead )
114 + "</font> <br>"; 128 + "</font> <br>";
115 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 129 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
116 if ( ammount++ < m_maxLinesTask ){ 130 if ( ammount++ < m_maxLinesTask ){
117 // Now we want to calculate how many days until birthday. We have to set 131 // Now we want to calculate how many days
132 //until birthday. We have to set
118 // the correct year to calculate the day diff... 133 // the correct year to calculate the day diff...
119 QDate destdate = (*m_it).birthday(); 134 QDate destdate = (*m_it).birthday();
120 destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); 135 destdate.setYMD( QDate::currentDate().year(),
136 destdate.month(), destdate.day() );
121 if ( QDate::currentDate().daysTo(destdate) < 0 ) 137 if ( QDate::currentDate().daysTo(destdate) < 0 )
122 destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); 138 destdate.setYMD( QDate::currentDate().year()+1,
139 destdate.month(), destdate.day() );
123 140
124 141
125 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) 142 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays )
126 output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName() 143 output += "<font color=" + m_urgentColor + "><b>-"
144 + (*m_it).fullName()
127 + " (" 145 + " ("
128 + QString::number(QDate::currentDate().daysTo(destdate)) 146 + QString::number(QDate::currentDate()
147 .daysTo(destdate))
129 + " Days) </b></font><br>"; 148 + " Days) </b></font><br>";
130 149
131 else 150 else
132 output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() 151 output += "<font color=" + m_entryColor + "><b>-"
152 + (*m_it).fullName()
133 + " (" 153 + " ("
134 + QString::number(QDate::currentDate().daysTo(destdate)) 154 + QString::number(QDate::currentDate()
155 .daysTo(destdate))
135 + " Days) </b></font><br>"; 156 + " Days) </b></font><br>";
136 } 157 }
137 } 158 }
138 } else { 159 } else {
139 output = "<font color=" + m_headlineColor + ">" 160 output = "<font color=" + m_headlineColor + ">"
140 + QObject::tr( "No birthdays in <b> %1 </b> days!" ).arg( m_daysLookAhead ) 161 + QObject::tr( "No birthdays in <b> %1 </b> days!" )
162 .arg( m_daysLookAhead )
141 + "</font> <br>"; 163 + "</font> <br>";
142 } 164 }
165 }
143 166
167 if ( m_showAnniversaries ){
144 // Define the query for anniversaries and start search.. 168 // Define the query for anniversaries and start search..
145 OContact queryanniversaries; 169 OContact queryanniversaries;
146 queryanniversaries.setAnniversary( lookAheadDate ); 170 queryanniversaries.setAnniversary( lookAheadDate );
147 171
148 m_list = m_contactdb->queryByExample( queryanniversaries, OContactAccess::DateDiff ); 172 m_list = m_contactdb->queryByExample( queryanniversaries, OContactAccess::DateDiff );
149 173
150 ammount = 0; 174 ammount = 0;
151 if ( m_list.count() > 0 ){ 175 if ( m_list.count() > 0 ){
152 output += "<font color=" + m_headlineColor + ">" 176 output += "<font color=" + m_headlineColor + ">"
153 + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ).arg( m_daysLookAhead ) 177 + QObject::tr( "Next anniversaries in <b> %1 </b> days:" )
178 .arg( m_daysLookAhead )
154 + "</font> <br>"; 179 + "</font> <br>";
155 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 180 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
156 if ( ammount++ < m_maxLinesTask ){ 181 if ( ammount++ < m_maxLinesTask ){
157 // Now we want to calculate how many days until anniversary. We have to set 182 // Now we want to calculate how many days until anniversary.
158 // the correct year to calculate the day diff... 183 // We have to set the correct year to calculate the day diff...
159 QDate destdate = (*m_it).anniversary(); 184 QDate destdate = (*m_it).anniversary();
160 destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); 185 destdate.setYMD( QDate::currentDate().year(), destdate.month(),
186 destdate.day() );
161 if ( QDate::currentDate().daysTo(destdate) < 0 ) 187 if ( QDate::currentDate().daysTo(destdate) < 0 )
162 destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); 188 destdate.setYMD( QDate::currentDate().year()+1,
189 destdate.month(), destdate.day() );
163 190
164 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) 191 if ( QDate::currentDate().daysTo(destdate) < m_urgentDays )
165 output += "<font color=" + m_urgentColor + "><b>-" + (*m_it).fullName() 192 output += "<font color=" + m_urgentColor + "><b>-"
193 + (*m_it).fullName()
166 + " (" 194 + " ("
167 + QString::number(QDate::currentDate().daysTo( destdate ) ) 195 + QString::number(QDate::currentDate()
196 .daysTo( destdate ) )
168 + " Days) </b></font><br>"; 197 + " Days) </b></font><br>";
169 else 198 else
170 output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() 199 output += "<font color=" + m_entryColor + "><b>-"
200 + (*m_it).fullName()
171 + " (" 201 + " ("
172 + QString::number(QDate::currentDate().daysTo( destdate ) ) 202 + QString::number(QDate::currentDate()
203 .daysTo( destdate ) )
173 + " Days) </b></font><br>"; 204 + " Days) </b></font><br>";
174 } 205 }
175 } 206 }
176 } else { 207 } else {
177 output += "<font color=" + m_headlineColor + ">" 208 output += "<font color=" + m_headlineColor + ">"
178 + QObject::tr( "No anniversaries in <b> %1 </b> days!" ).arg( m_daysLookAhead ) 209 + QObject::tr( "No anniversaries in <b> %1 </b> days!" )
210 .arg( m_daysLookAhead )
179 + "</font> <br>"; 211 + "</font> <br>";
180 } 212 }
181
182
183 }else{
184 // Libopie seems to be old..
185 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" );
186 } 213 }
187 214
188 addressLabel->setText( output ); 215 addressLabel->setText( output );
189} 216}
190 217
191/** 218/**
192 * start the todolist 219 * start the todolist
193 */ 220 */
194void AddressBookPluginWidget::startAddressBook() { 221void AddressBookPluginWidget::startAddressBook() {
195 QCopEnvelope e( "QPE/System", "execute(QString)" ); 222 QCopEnvelope e( "QPE/System", "execute(QString)" );
196 e << QString( "addressbook" ); 223 e << QString( "addressbook" );
197} 224}
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.h b/core/pim/today/plugins/addressbook/addresspluginwidget.h
index 63f2a2b..cf2ecce 100644
--- a/core/pim/today/plugins/addressbook/addresspluginwidget.h
+++ b/core/pim/today/plugins/addressbook/addresspluginwidget.h
@@ -29,35 +29,37 @@
29 29
30class AddressBookPluginWidget : public QWidget { 30class AddressBookPluginWidget : public QWidget {
31 31
32 Q_OBJECT 32 Q_OBJECT
33 33
34public: 34public:
35 AddressBookPluginWidget( QWidget *parent, const char *name ); 35 AddressBookPluginWidget( QWidget *parent, const char *name );
36 ~AddressBookPluginWidget(); 36 ~AddressBookPluginWidget();
37 37
38public slots: 38public slots:
39 void refresh( const OContactAccess* db ); 39 void refresh( const OContactAccess* db );
40 40
41protected slots: 41protected slots:
42 void startAddressBook(); 42 void startAddressBook();
43 43
44private: 44private:
45 OClickableLabel* addressLabel; 45 OClickableLabel* addressLabel;
46 QVBoxLayout* layoutTodo; 46 QVBoxLayout* layoutTodo;
47 OContactAccess * m_contactdb; 47 OContactAccess * m_contactdb;
48 48
49 OContactAccess::List m_list; 49 OContactAccess::List m_list;
50 OContactAccess::List::Iterator m_it; 50 OContactAccess::List::Iterator m_it;
51 51
52 void readConfig(); 52 void readConfig();
53 void getAddress(); 53 void getAddress();
54 int m_maxLinesTask; 54 int m_maxLinesTask;
55 int m_maxCharClip; 55 int m_maxCharClip;
56 int m_daysLookAhead; 56 int m_daysLookAhead;
57 int m_urgentDays; 57 int m_urgentDays;
58 QString m_entryColor; 58 QString m_entryColor;
59 QString m_headlineColor; 59 QString m_headlineColor;
60 QString m_urgentColor; 60 QString m_urgentColor;
61 bool m_showBirthdays;
62 bool m_showAnniversaries;
61}; 63};
62 64
63#endif 65#endif