summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-03-23 20:49:17 (UTC)
committer umopapisdn <umopapisdn>2003-03-23 20:49:17 (UTC)
commit90772042f0d726149093675cede488676a94562b (patch) (unidiff)
tree853a03e23255c8b8fdfd74cc284cbd02663c94a7
parentb5606a63c9f3524f9475b6ac79f0b6bcc7162fa6 (diff)
downloadopie-90772042f0d726149093675cede488676a94562b.zip
opie-90772042f0d726149093675cede488676a94562b.tar.gz
opie-90772042f0d726149093675cede488676a94562b.tar.bz2
Bugfix: (bug #0000211) Events ending at mat the following day. Fix for weeklistview.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweeklst.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 9089fe9..e8e12ba 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -86,194 +86,196 @@ void DateBookWeekLstHeader::setDate(int y, int m, int d) {
86 86
87void DateBookWeekLstHeader::nextWeek() { 87void DateBookWeekLstHeader::nextWeek() {
88 setDate(date.addDays(7)); 88 setDate(date.addDays(7));
89} 89}
90void DateBookWeekLstHeader::prevWeek() { 90void DateBookWeekLstHeader::prevWeek() {
91 setDate(date.addDays(-7)); 91 setDate(date.addDays(-7));
92} 92}
93 93
94DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, 94DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
95 QWidget* parent, 95 QWidget* parent,
96 const char* name, 96 const char* name,
97 WFlags fl ) 97 WFlags fl )
98 : DateBookWeekLstDayHdrBase(parent, name, fl) { 98 : DateBookWeekLstDayHdrBase(parent, name, fl) {
99 99
100 date=d; 100 date=d;
101 101
102 static const char *wdays={"MTWTFSS"}; 102 static const char *wdays={"MTWTFSS"};
103 char day=wdays[d.dayOfWeek()-1]; 103 char day=wdays[d.dayOfWeek()-1];
104 104
105 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " + 105 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +
106 QString::number(d.day()) ); 106 QString::number(d.day()) );
107 add->setText("+"); 107 add->setText("+");
108 108
109 if (d == QDate::currentDate()) { 109 if (d == QDate::currentDate()) {
110 QPalette pal=label->palette(); 110 QPalette pal=label->palette();
111 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 111 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
112 label->setPalette(pal); 112 label->setPalette(pal);
113 113
114 /* 114 /*
115 QFont f=label->font(); 115 QFont f=label->font();
116 f.setItalic(true); 116 f.setItalic(true);
117 label->setFont(f); 117 label->setFont(f);
118 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 118 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
119 */ 119 */
120 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 120 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
121 QPalette pal=label->palette(); 121 QPalette pal=label->palette();
122 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 122 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
123 label->setPalette(pal); 123 label->setPalette(pal);
124 } 124 }
125 125
126 126
127 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 127 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
128 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 128 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
129} 129}
130 130
131void DateBookWeekLstDayHdr::showDay() { 131void DateBookWeekLstDayHdr::showDay() {
132 emit showDate(date.year(), date.month(), date.day()); 132 emit showDate(date.year(), date.month(), date.day());
133} 133}
134void DateBookWeekLstDayHdr::newEvent() { 134void DateBookWeekLstDayHdr::newEvent() {
135 QDateTime start, stop; 135 QDateTime start, stop;
136 start=stop=date; 136 start=stop=date;
137 start.setTime(QTime(10,0)); 137 start.setTime(QTime(10,0));
138 stop.setTime(QTime(12,0)); 138 stop.setTime(QTime(12,0));
139 139
140 emit addEvent(start,stop,""); 140 emit addEvent(start,stop,"");
141} 141}
142DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 142DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
143 QWidget* parent, 143 QWidget* parent,
144 const char* name, 144 const char* name,
145 WFlags fl) : 145 WFlags fl) :
146 OClickableLabel(parent,name,fl), 146 OClickableLabel(parent,name,fl),
147 event(ev) 147 event(ev)
148{ 148{
149 char s[10]; 149 char s[10];
150 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 150 if ( ev.startDate() != ev.date() ) { // multiday event (not first day)
151 if ( ev.endDate() == ev.date() ) { // last day 151 if ( ev.endDate() == ev.date() ) { // last day
152 strcpy(s, "__|__"); 152 strcpy(s, "__|__");
153 } else { 153 } else {
154 strcpy(s, " |---"); 154 strcpy(s, " |---");
155 } 155 }
156 } else { 156 } else {
157 if(ev.event().type() == Event::Normal ) 157 if(ev.event().type() == Event::Normal )
158 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); 158 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
159 else 159 else
160 sprintf(s," "); 160 sprintf(s," ");
161 } 161 }
162 setText(QString(s) + " " + ev.description()); 162 setText(QString(s) + " " + ev.description());
163 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 163 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
164 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 164 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
165} 165}
166void DateBookWeekLstEvent::editMe() { 166void DateBookWeekLstEvent::editMe() {
167 emit editEvent(event.event()); 167 emit editEvent(event.event());
168} 168}
169 169
170 170
171DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 171DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
172 const QDate &d, bool onM, 172 const QDate &d, bool onM,
173 QWidget* parent, 173 QWidget* parent,
174 const char* name, WFlags fl) 174 const char* name, WFlags fl)
175 : QWidget( parent, name, fl ) 175 : QWidget( parent, name, fl )
176{ 176{
177 onMonday=onM; 177 onMonday=onM;
178 setPalette(white); 178 setPalette(white);
179 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 179 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
180 180
181 QVBoxLayout *layout = new QVBoxLayout( this ); 181 QVBoxLayout *layout = new QVBoxLayout( this );
182 182
183 qBubbleSort(ev); 183 qBubbleSort(ev);
184 QValueListIterator<EffectiveEvent> it; 184 QValueListIterator<EffectiveEvent> it;
185 it=ev.begin(); 185 it=ev.begin();
186 186
187 int dayOrder[7]; 187 int dayOrder[7];
188 if (onMonday) 188 if (onMonday)
189 for (int d=0; d<7; d++) dayOrder[d]=d+1; 189 for (int d=0; d<7; d++) dayOrder[d]=d+1;
190 else { 190 else {
191 for (int d=0; d<7; d++) dayOrder[d]=d; 191 for (int d=0; d<7; d++) dayOrder[d]=d;
192 dayOrder[0]=7; 192 dayOrder[0]=7;
193 } 193 }
194 194
195 for (int i=0; i<7; i++) { 195 for (int i=0; i<7; i++) {
196 // Header 196 // Header
197 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), 197 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i),
198 onMonday,this); 198 onMonday,this);
199 connect(hdr, SIGNAL(showDate(int,int,int)), 199 connect(hdr, SIGNAL(showDate(int,int,int)),
200 this, SIGNAL(showDate(int,int,int))); 200 this, SIGNAL(showDate(int,int,int)));
201 connect(hdr, SIGNAL(addEvent(const QDateTime &, 201 connect(hdr, SIGNAL(addEvent(const QDateTime &,
202 const QDateTime &, 202 const QDateTime &,
203 const QString &)), 203 const QString &)),
204 this, SIGNAL(addEvent(const QDateTime &, 204 this, SIGNAL(addEvent(const QDateTime &,
205 const QDateTime &, 205 const QDateTime &,
206 const QString &))); 206 const QString &)));
207 layout->addWidget(hdr); 207 layout->addWidget(hdr);
208 208
209 // Events 209 // Events
210 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 210 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
211 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); 211 if(!((*it).end().hour()==(*it).start().hour() && (*it).end().minute()==(*it).start().minute())) {// Skip effective events with no duration. (i.e ending at 00:00)
212 layout->addWidget(l); 212 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this);
213 connect (l, SIGNAL(editEvent(const Event &)), 213 layout->addWidget(l);
214 this, SIGNAL(editEvent(const Event &))); 214 connect (l, SIGNAL(editEvent(const Event &)),
215 it++; 215 this, SIGNAL(editEvent(const Event &)));
216 }
217 it++;
216 } 218 }
217 219
218 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 220 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
219 } 221 }
220} 222}
221DateBookWeekLstView::~DateBookWeekLstView(){} 223DateBookWeekLstView::~DateBookWeekLstView(){}
222void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 224void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
223 225
224DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 226DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
225 QValueList<EffectiveEvent> &ev2, 227 QValueList<EffectiveEvent> &ev2,
226 QDate &d, bool onM, 228 QDate &d, bool onM,
227 QWidget* parent, 229 QWidget* parent,
228 const char* name, WFlags fl) 230 const char* name, WFlags fl)
229 : QWidget( parent, name, fl ) 231 : QWidget( parent, name, fl )
230{ 232{
231 QHBoxLayout *layout = new QHBoxLayout( this ); 233 QHBoxLayout *layout = new QHBoxLayout( this );
232 234
233 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 235 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
234 layout->addWidget(w); 236 layout->addWidget(w);
235 connect (w, SIGNAL(editEvent(const Event &)), 237 connect (w, SIGNAL(editEvent(const Event &)),
236 this, SIGNAL(editEvent(const Event &))); 238 this, SIGNAL(editEvent(const Event &)));
237 connect (w, SIGNAL(showDate(int,int,int)), 239 connect (w, SIGNAL(showDate(int,int,int)),
238 this, SIGNAL(showDate(int,int,int))); 240 this, SIGNAL(showDate(int,int,int)));
239 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 241 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
240 const QString &)), 242 const QString &)),
241 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 243 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
242 const QString &))); 244 const QString &)));
243 245
244 246
245 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 247 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
246 layout->addWidget(w); 248 layout->addWidget(w);
247 connect (w, SIGNAL(editEvent(const Event &)), 249 connect (w, SIGNAL(editEvent(const Event &)),
248 this, SIGNAL(editEvent(const Event &))); 250 this, SIGNAL(editEvent(const Event &)));
249 connect (w, SIGNAL(showDate(int,int,int)), 251 connect (w, SIGNAL(showDate(int,int,int)),
250 this, SIGNAL(showDate(int,int,int))); 252 this, SIGNAL(showDate(int,int,int)));
251 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 253 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
252 const QString &)), 254 const QString &)),
253 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 255 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
254 const QString &))); 256 const QString &)));
255} 257}
256 258
257DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 259DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
258 QWidget *parent, 260 QWidget *parent,
259 const char *name ) 261 const char *name )
260 : QWidget( parent, name ), 262 : QWidget( parent, name ),
261 db( newDB ), 263 db( newDB ),
262 startTime( 0 ), 264 startTime( 0 ),
263 ampm( ap ), 265 ampm( ap ),
264 onMonday(onM) 266 onMonday(onM)
265{ 267{
266 setFocusPolicy(StrongFocus); 268 setFocusPolicy(StrongFocus);
267 layout = new QVBoxLayout( this ); 269 layout = new QVBoxLayout( this );
268 layout->setMargin(0); 270 layout->setMargin(0);
269 271
270 header=new DateBookWeekLstHeader(onM, this); 272 header=new DateBookWeekLstHeader(onM, this);
271 layout->addWidget( header ); 273 layout->addWidget( header );
272 connect(header, SIGNAL(dateChanged(int,int)), 274 connect(header, SIGNAL(dateChanged(int,int)),
273 this, SLOT(dateChanged(int,int))); 275 this, SLOT(dateChanged(int,int)));
274 connect(header, SIGNAL(setDbl(bool)), 276 connect(header, SIGNAL(setDbl(bool)),
275 this, SLOT(setDbl(bool))); 277 this, SLOT(setDbl(bool)));
276 278
277 scroll=new QScrollView(this); 279 scroll=new QScrollView(this);
278 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 280 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
279 //scroll->setHScrollBarMode(QScrollView::AlwaysOff); 281 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);