4 files changed, 19 insertions, 2 deletions
diff --git a/core/pim/today/plugins/addressbook/addresspluginconfig.cpp b/core/pim/today/plugins/addressbook/addresspluginconfig.cpp index 686d72c..f00cffe 100644 --- a/core/pim/today/plugins/addressbook/addresspluginconfig.cpp +++ b/core/pim/today/plugins/addressbook/addresspluginconfig.cpp | |||
@@ -40,58 +40,70 @@ AddressBookPluginConfig::AddressBookPluginConfig( QWidget *parent, const char* | |||
40 | TextLabel6->setText( tr( "Max Lines " ) ); | 40 | TextLabel6->setText( tr( "Max Lines " ) ); |
41 | 41 | ||
42 | SpinBox2 = new QSpinBox( box1, "SpinBox2" ); | 42 | SpinBox2 = new QSpinBox( box1, "SpinBox2" ); |
43 | SpinBox2->setMaxValue( 40 ); | 43 | SpinBox2->setMaxValue( 40 ); |
44 | QWhatsThis::add( SpinBox2 , tr( "Set the maximum number of lines that should be shown for each" ) ); | 44 | QWhatsThis::add( SpinBox2 , tr( "Set the maximum number of lines that should be shown for each" ) ); |
45 | 45 | ||
46 | QHBox *box2 = new QHBox( this ); | 46 | QHBox *box2 = new QHBox( this ); |
47 | 47 | ||
48 | QLabel* clipLabel = new QLabel( box2, "" ); | 48 | QLabel* clipLabel = new QLabel( box2, "" ); |
49 | clipLabel->setText( tr( "Clip line after X chars" ) ); | 49 | clipLabel->setText( tr( "Clip line after X chars" ) ); |
50 | 50 | ||
51 | SpinBoxClip = new QSpinBox( box2, "SpinClip" ); | 51 | SpinBoxClip = new QSpinBox( box2, "SpinClip" ); |
52 | SpinBoxClip->setMaxValue( 200 ); | 52 | SpinBoxClip->setMaxValue( 200 ); |
53 | QWhatsThis::add( SpinBoxClip , tr( "After how many chars should be the info about the task be cut off" ) ); | 53 | QWhatsThis::add( SpinBoxClip , tr( "After how many chars should be the info about the task be cut off" ) ); |
54 | 54 | ||
55 | QHBox *box3 = new QHBox( this ); | 55 | QHBox *box3 = new QHBox( this ); |
56 | 56 | ||
57 | QLabel* daysLabel = new QLabel( box3, "" ); | 57 | QLabel* daysLabel = new QLabel( box3, "" ); |
58 | daysLabel->setText( tr( "Days look ahead" ) ); | 58 | daysLabel->setText( tr( "Days look ahead" ) ); |
59 | 59 | ||
60 | SpinDaysClip = new QSpinBox( box3, "SpinDays" ); | 60 | SpinDaysClip = new QSpinBox( box3, "SpinDays" ); |
61 | SpinDaysClip->setMaxValue( 200 ); | 61 | SpinDaysClip->setMaxValue( 200 ); |
62 | QWhatsThis::add( SpinDaysClip , tr( "How many days we should search forward" ) ); | 62 | QWhatsThis::add( SpinDaysClip , tr( "How many days we should search forward" ) ); |
63 | 63 | ||
64 | QHBox *box4 = new QHBox( this ); | ||
65 | |||
66 | QLabel* colorLabel = new QLabel( box4, "" ); | ||
67 | colorLabel->setText( tr( "Set Entry Color \n(restart Today \nafter change!)" ) ); | ||
68 | |||
69 | entryColor = new OColorButton( box4, red, "entryColor" ); | ||
70 | QWhatsThis::add( entryColor , tr( "What color should be used for shown birthdays/anniversaries?" ) ); | ||
71 | |||
64 | layout->addWidget( box1 ); | 72 | layout->addWidget( box1 ); |
65 | layout->addWidget( box2 ); | 73 | layout->addWidget( box2 ); |
66 | layout->addWidget( box3 ); | 74 | layout->addWidget( box3 ); |
75 | layout->addWidget( box4 ); | ||
67 | 76 | ||
68 | readConfig(); | 77 | readConfig(); |
69 | } | 78 | } |
70 | 79 | ||
71 | void AddressBookPluginConfig::readConfig() { | 80 | void AddressBookPluginConfig::readConfig() { |
72 | Config cfg( "todayaddressplugin" ); | 81 | Config cfg( "todayaddressplugin" ); |
73 | cfg.setGroup( "config" ); | 82 | cfg.setGroup( "config" ); |
74 | m_max_lines_task = cfg.readNumEntry( "maxlinestask", 5 ); | 83 | m_max_lines_task = cfg.readNumEntry( "maxlinestask", 5 ); |
75 | SpinBox2->setValue( m_max_lines_task ); | 84 | SpinBox2->setValue( m_max_lines_task ); |
76 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); | 85 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); |
77 | SpinBoxClip->setValue( m_maxCharClip ); | 86 | SpinBoxClip->setValue( m_maxCharClip ); |
78 | m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); | 87 | m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); |
79 | SpinDaysClip->setValue( m_daysLookAhead ); | 88 | SpinDaysClip->setValue( m_daysLookAhead ); |
89 | m_entryColor = cfg.readEntry( "entrycolor", Qt::red.name() ); | ||
80 | } | 90 | } |
81 | 91 | ||
82 | 92 | ||
83 | void AddressBookPluginConfig::writeConfig() { | 93 | void AddressBookPluginConfig::writeConfig() { |
84 | Config cfg( "todayaddressplugin" ); | 94 | Config cfg( "todayaddressplugin" ); |
85 | cfg.setGroup( "config" ); | 95 | cfg.setGroup( "config" ); |
86 | m_max_lines_task = SpinBox2->value(); | 96 | m_max_lines_task = SpinBox2->value(); |
87 | cfg.writeEntry( "maxlinestask", m_max_lines_task ); | 97 | cfg.writeEntry( "maxlinestask", m_max_lines_task ); |
88 | m_maxCharClip = SpinBoxClip->value(); | 98 | m_maxCharClip = SpinBoxClip->value(); |
89 | cfg.writeEntry( "maxcharclip", m_maxCharClip ); | 99 | cfg.writeEntry( "maxcharclip", m_maxCharClip ); |
90 | m_daysLookAhead = SpinDaysClip->value(); | 100 | m_daysLookAhead = SpinDaysClip->value(); |
91 | cfg.writeEntry( "dayslookahead", m_daysLookAhead ); | 101 | cfg.writeEntry( "dayslookahead", m_daysLookAhead ); |
102 | m_entryColor = entryColor->color().name(); | ||
103 | cfg.writeEntry( "entrycolor", m_entryColor ); | ||
92 | cfg.write(); | 104 | cfg.write(); |
93 | } | 105 | } |
94 | 106 | ||
95 | 107 | ||
96 | AddressBookPluginConfig::~AddressBookPluginConfig() { | 108 | AddressBookPluginConfig::~AddressBookPluginConfig() { |
97 | } | 109 | } |
diff --git a/core/pim/today/plugins/addressbook/addresspluginconfig.h b/core/pim/today/plugins/addressbook/addresspluginconfig.h index 6f128d4..54c8b4f 100644 --- a/core/pim/today/plugins/addressbook/addresspluginconfig.h +++ b/core/pim/today/plugins/addressbook/addresspluginconfig.h | |||
@@ -2,59 +2,62 @@ | |||
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 | 24 | ||
25 | #include <opie/todayconfigwidget.h> | 25 | #include <opie/todayconfigwidget.h> |
26 | #include <opie/ocolorbutton.h> | ||
26 | 27 | ||
27 | class AddressBookPluginConfig : public TodayConfigWidget { | 28 | class AddressBookPluginConfig : public TodayConfigWidget { |
28 | 29 | ||
29 | 30 | ||
30 | public: | 31 | public: |
31 | 32 | ||
32 | AddressBookPluginConfig( QWidget *parent, const char *name ); | 33 | AddressBookPluginConfig( QWidget *parent, const char *name ); |
33 | ~AddressBookPluginConfig(); | 34 | ~AddressBookPluginConfig(); |
34 | 35 | ||
35 | private: | 36 | private: |
36 | /** | 37 | /** |
37 | * if changed then save | 38 | * if changed then save |
38 | */ | 39 | */ |
39 | bool changed(); | 40 | bool changed(); |
40 | void readConfig(); | 41 | void readConfig(); |
41 | void writeConfig(); | 42 | void writeConfig(); |
42 | 43 | ||
43 | QSpinBox* SpinBox2; | 44 | QSpinBox* SpinBox2; |
44 | QSpinBox* SpinBoxClip; | 45 | QSpinBox* SpinBoxClip; |
45 | QSpinBox* SpinDaysClip; | 46 | QSpinBox* SpinDaysClip; |
47 | OColorButton* entryColor; | ||
46 | 48 | ||
47 | // how many lines should be showed in the AddressBook section | 49 | // how many lines should be showed in the AddressBook section |
48 | int m_max_lines_task; | 50 | int m_max_lines_task; |
49 | // clip the lines after X chars | 51 | // clip the lines after X chars |
50 | int m_maxCharClip; | 52 | int m_maxCharClip; |
51 | // How many days look ahead | 53 | // How many days look ahead |
52 | int m_daysLookAhead; | 54 | int m_daysLookAhead; |
53 | 55 | // Entry Color | |
56 | QString m_entryColor; | ||
54 | }; | 57 | }; |
55 | 58 | ||
56 | 59 | ||
57 | 60 | ||
58 | 61 | ||
59 | 62 | ||
60 | #endif | 63 | #endif |
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp index 0d4cec8..c81beee 100644 --- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp +++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp | |||
@@ -50,93 +50,94 @@ AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* | |||
50 | 50 | ||
51 | 51 | ||
52 | readConfig(); | 52 | readConfig(); |
53 | getAddress(); | 53 | getAddress(); |
54 | } | 54 | } |
55 | 55 | ||
56 | AddressBookPluginWidget::~AddressBookPluginWidget() { | 56 | AddressBookPluginWidget::~AddressBookPluginWidget() { |
57 | delete m_contactdb; | 57 | delete m_contactdb; |
58 | } | 58 | } |
59 | 59 | ||
60 | void AddressBookPluginWidget::refresh( const OContactAccess* ) | 60 | void 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 | ||
68 | void AddressBookPluginWidget::readConfig() { | 68 | void 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_entryColor = cfg.readEntry("entrycolor", Qt::red.name() ); | ||
74 | } | 75 | } |
75 | 76 | ||
76 | 77 | ||
77 | /** | 78 | /** |
78 | * Get the addresss | 79 | * Get the addresss |
79 | */ | 80 | */ |
80 | void AddressBookPluginWidget::getAddress() { | 81 | void AddressBookPluginWidget::getAddress() { |
81 | 82 | ||
82 | if ( ! layoutTodo ){ | 83 | if ( ! layoutTodo ){ |
83 | layoutTodo = new QVBoxLayout( this ); | 84 | layoutTodo = new QVBoxLayout( this ); |
84 | } | 85 | } |
85 | 86 | ||
86 | if ( ! addressLabel ) { | 87 | if ( ! addressLabel ) { |
87 | addressLabel = new OClickableLabel( this ); | 88 | addressLabel = new OClickableLabel( this ); |
88 | connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); | 89 | connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); |
89 | layoutTodo->addWidget( addressLabel ); | 90 | layoutTodo->addWidget( addressLabel ); |
90 | } | 91 | } |
91 | 92 | ||
92 | QString output; | 93 | QString output; |
93 | 94 | ||
94 | // Check whether the database provide the search option.. | 95 | // Check whether the database provide the search option.. |
95 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ | 96 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ |
96 | 97 | ||
97 | // Define the query for birthdays and start search.. | 98 | // Define the query for birthdays and start search.. |
98 | QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); | 99 | QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); |
99 | qWarning("Searching from now (%s) until %s ! ", QDate::currentDate().toString().latin1(), | 100 | qWarning("Searching from now (%s) until %s ! ", QDate::currentDate().toString().latin1(), |
100 | lookAheadDate.toString().latin1() ); | 101 | lookAheadDate.toString().latin1() ); |
101 | OContact querybirthdays; | 102 | OContact querybirthdays; |
102 | querybirthdays.setBirthday( lookAheadDate ); | 103 | querybirthdays.setBirthday( lookAheadDate ); |
103 | 104 | ||
104 | int ammount = 0; | 105 | int ammount = 0; |
105 | 106 | ||
106 | m_list = m_contactdb->queryByExample( querybirthdays, OContactAccess::DateDiff ); | 107 | m_list = m_contactdb->queryByExample( querybirthdays, OContactAccess::DateDiff ); |
107 | if ( m_list.count() > 0 ){ | 108 | if ( m_list.count() > 0 ){ |
108 | output = QObject::tr( "Next birthdays in <b> %1 </b> days: <br>" ).arg( m_daysLookAhead ); | 109 | output = QObject::tr( "Next birthdays in <b> %1 </b> days: <br>" ).arg( m_daysLookAhead ); |
109 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { | 110 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { |
110 | if ( ammount++ < m_maxLinesTask ){ | 111 | if ( ammount++ < m_maxLinesTask ){ |
111 | // Now we want to calculate how many days until birthday. We have to set | 112 | // Now we want to calculate how many days until birthday. We have to set |
112 | // the correct year to calculate the day diff... | 113 | // the correct year to calculate the day diff... |
113 | QDate destdate = (*m_it).birthday(); | 114 | QDate destdate = (*m_it).birthday(); |
114 | destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); | 115 | destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); |
115 | if ( QDate::currentDate().daysTo(destdate) < 0 ) | 116 | if ( QDate::currentDate().daysTo(destdate) < 0 ) |
116 | destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); | 117 | destdate.setYMD( QDate::currentDate().year()+1, destdate.month(), destdate.day() ); |
117 | 118 | ||
118 | output += "<font color=#e00000><b>-" + (*m_it).fullName() | 119 | output += "<font color=" + m_entryColor + "><b>-" + (*m_it).fullName() |
119 | + " (" | 120 | + " (" |
120 | + QString::number(QDate::currentDate().daysTo(destdate)) | 121 | + QString::number(QDate::currentDate().daysTo(destdate)) |
121 | + " Days) </b></font><br>"; | 122 | + " Days) </b></font><br>"; |
122 | } | 123 | } |
123 | } | 124 | } |
124 | } else { | 125 | } else { |
125 | output = QObject::tr( "No birthdays in <b> %1 </b> days! <br>" ).arg( m_daysLookAhead ); | 126 | output = QObject::tr( "No birthdays in <b> %1 </b> days! <br>" ).arg( m_daysLookAhead ); |
126 | } | 127 | } |
127 | 128 | ||
128 | // Define the query for anniversaries and start search.. | 129 | // Define the query for anniversaries and start search.. |
129 | OContact queryanniversaries; | 130 | OContact queryanniversaries; |
130 | queryanniversaries.setAnniversary( lookAheadDate ); | 131 | queryanniversaries.setAnniversary( lookAheadDate ); |
131 | 132 | ||
132 | m_list = m_contactdb->queryByExample( queryanniversaries, OContactAccess::DateDiff ); | 133 | m_list = m_contactdb->queryByExample( queryanniversaries, OContactAccess::DateDiff ); |
133 | 134 | ||
134 | ammount = 0; | 135 | ammount = 0; |
135 | if ( m_list.count() > 0 ){ | 136 | if ( m_list.count() > 0 ){ |
136 | output += QObject::tr( "Next anniversaries in <b> %1 </b> days: <br>" ).arg( m_daysLookAhead ); | 137 | output += QObject::tr( "Next anniversaries in <b> %1 </b> days: <br>" ).arg( m_daysLookAhead ); |
137 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { | 138 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { |
138 | if ( ammount++ < m_maxLinesTask ){ | 139 | if ( ammount++ < m_maxLinesTask ){ |
139 | // Now we want to calculate how many days until anniversary. We have to set | 140 | // Now we want to calculate how many days until anniversary. We have to set |
140 | // the correct year to calculate the day diff... | 141 | // the correct year to calculate the day diff... |
141 | QDate destdate = (*m_it).anniversary(); | 142 | QDate destdate = (*m_it).anniversary(); |
142 | destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); | 143 | destdate.setYMD( QDate::currentDate().year(), destdate.month(), destdate.day() ); |
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.h b/core/pim/today/plugins/addressbook/addresspluginwidget.h index 75e223a..fa464de 100644 --- a/core/pim/today/plugins/addressbook/addresspluginwidget.h +++ b/core/pim/today/plugins/addressbook/addresspluginwidget.h | |||
@@ -31,27 +31,28 @@ class AddressBookPluginWidget : public QWidget { | |||
31 | 31 | ||
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | 33 | ||
34 | public: | 34 | public: |
35 | AddressBookPluginWidget( QWidget *parent, const char *name ); | 35 | AddressBookPluginWidget( QWidget *parent, const char *name ); |
36 | ~AddressBookPluginWidget(); | 36 | ~AddressBookPluginWidget(); |
37 | 37 | ||
38 | protected slots: | 38 | protected slots: |
39 | void startAddressBook(); | 39 | void startAddressBook(); |
40 | void refresh( const OContactAccess* db ); | 40 | void refresh( const OContactAccess* db ); |
41 | 41 | ||
42 | private: | 42 | private: |
43 | OClickableLabel* addressLabel; | 43 | OClickableLabel* addressLabel; |
44 | QVBoxLayout* layoutTodo; | 44 | QVBoxLayout* layoutTodo; |
45 | OContactAccess * m_contactdb; | 45 | OContactAccess * m_contactdb; |
46 | 46 | ||
47 | OContactAccess::List m_list; | 47 | OContactAccess::List m_list; |
48 | OContactAccess::List::Iterator m_it; | 48 | OContactAccess::List::Iterator m_it; |
49 | 49 | ||
50 | void readConfig(); | 50 | void readConfig(); |
51 | void getAddress(); | 51 | void getAddress(); |
52 | int m_maxLinesTask; | 52 | int m_maxLinesTask; |
53 | int m_maxCharClip; | 53 | int m_maxCharClip; |
54 | int m_daysLookAhead; | 54 | int m_daysLookAhead; |
55 | QString m_entryColor; | ||
55 | }; | 56 | }; |
56 | 57 | ||
57 | #endif | 58 | #endif |