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
@@ -25,6 +25,7 @@
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)
@@ -33,53 +34,66 @@ AddressBookPluginConfig::AddressBookPluginConfig( QWidget *parent, const char*
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" );
@@ -91,9 +105,10 @@ AddressBookPluginConfig::AddressBookPluginConfig( QWidget *parent, const char*
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 );
@@ -108,8 +123,8 @@ void AddressBookPluginConfig::readConfig() {
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 );
@@ -121,6 +136,10 @@ void AddressBookPluginConfig::readConfig() {
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
@@ -129,8 +148,8 @@ void AddressBookPluginConfig::writeConfig() {
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();
@@ -144,6 +163,10 @@ void AddressBookPluginConfig::writeConfig() {
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
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
@@ -21,6 +21,7 @@
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>
@@ -48,6 +49,8 @@ private:
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;
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
@@ -75,6 +75,8 @@ void AddressBookPluginWidget::readConfig() {
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
@@ -96,51 +98,73 @@ void AddressBookPluginWidget::getAddress() {
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 );
@@ -150,41 +174,44 @@ void AddressBookPluginWidget::getAddress() {
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
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
@@ -58,6 +58,8 @@ private:
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