author | umopapisdn <umopapisdn> | 2003-03-23 19:55:23 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-03-23 19:55:23 (UTC) |
commit | dfa17505b14011b50822d50c925cc6aa0299b1b4 (patch) (unidiff) | |
tree | 1445d0e8dcc4762cc93d666007564af0525aac37 | |
parent | 46c09d5732bcac4de2be5dfbf17bee054aba9478 (diff) | |
download | opie-dfa17505b14011b50822d50c925cc6aa0299b1b4.zip opie-dfa17505b14011b50822d50c925cc6aa0299b1b4.tar.gz opie-dfa17505b14011b50822d50c925cc6aa0299b1b4.tar.bz2 |
Bugfix: (bug #0000211) Events ending at midnight shouldn't be displayed at the following day. Fix for weekview.
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index e30c776..5bbf86a 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -42,200 +42,202 @@ | |||
42 | DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) | 42 | DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) |
43 | : ev( e ) | 43 | : ev( e ) |
44 | { | 44 | { |
45 | // with the current implementation change the color for all day events | 45 | // with the current implementation change the color for all day events |
46 | if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) { | 46 | if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) { |
47 | c = Qt::green; | 47 | c = Qt::green; |
48 | } else { | 48 | } else { |
49 | c = ev.event().hasAlarm() ? Qt::red : Qt::blue; | 49 | c = ev.event().hasAlarm() ? Qt::red : Qt::blue; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) | 53 | void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) |
54 | { | 54 | { |
55 | r.setRect( x, y, w, h ); | 55 | r.setRect( x, y, w, h ); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | //------------------=--------------------------------------------- | 59 | //------------------=--------------------------------------------- |
60 | 60 | ||
61 | DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, | 61 | DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, |
62 | QWidget *parent, const char *name ) | 62 | QWidget *parent, const char *name ) |
63 | : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), | 63 | : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), |
64 | showingEvent( false ) | 64 | showingEvent( false ) |
65 | { | 65 | { |
66 | items.setAutoDelete( true ); | 66 | items.setAutoDelete( true ); |
67 | 67 | ||
68 | viewport()->setBackgroundMode( PaletteBase ); | 68 | viewport()->setBackgroundMode( PaletteBase ); |
69 | 69 | ||
70 | header = new QHeader( this ); | 70 | header = new QHeader( this ); |
71 | header->addLabel( "" ); | 71 | header->addLabel( "" ); |
72 | 72 | ||
73 | header->setMovingEnabled( false ); | 73 | header->setMovingEnabled( false ); |
74 | header->setResizeEnabled( false ); | 74 | header->setResizeEnabled( false ); |
75 | header->setClickEnabled( false, 0 ); | 75 | header->setClickEnabled( false, 0 ); |
76 | initNames(); | 76 | initNames(); |
77 | 77 | ||
78 | 78 | ||
79 | connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) ); | 79 | connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) ); |
80 | 80 | ||
81 | QObject::connect(qApp, SIGNAL(clockChanged(bool)), | 81 | QObject::connect(qApp, SIGNAL(clockChanged(bool)), |
82 | this, SLOT(slotChangeClock(bool))); | 82 | this, SLOT(slotChangeClock(bool))); |
83 | 83 | ||
84 | QFontMetrics fm( font() ); | 84 | QFontMetrics fm( font() ); |
85 | rowHeight = fm.height()+2; | 85 | rowHeight = fm.height()+2; |
86 | 86 | ||
87 | resizeContents( width(), 24*rowHeight ); | 87 | resizeContents( width(), 24*rowHeight ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void DateBookWeekView::initNames() | 90 | void DateBookWeekView::initNames() |
91 | { | 91 | { |
92 | static bool bFirst = true; | 92 | static bool bFirst = true; |
93 | if ( bFirst ) { | 93 | if ( bFirst ) { |
94 | if ( bOnMonday ) { | 94 | if ( bOnMonday ) { |
95 | header->addLabel( tr("M", "Monday" ) ); | 95 | header->addLabel( tr("M", "Monday" ) ); |
96 | header->addLabel( tr("T", "Tuesday") ); | 96 | header->addLabel( tr("T", "Tuesday") ); |
97 | header->addLabel( tr("W", "Wednesday" ) ); | 97 | header->addLabel( tr("W", "Wednesday" ) ); |
98 | header->addLabel( tr("T", "Thursday" ) ); | 98 | header->addLabel( tr("T", "Thursday" ) ); |
99 | header->addLabel( tr("F", "Friday" ) ); | 99 | header->addLabel( tr("F", "Friday" ) ); |
100 | header->addLabel( tr("S", "Saturday" ) ); | 100 | header->addLabel( tr("S", "Saturday" ) ); |
101 | header->addLabel( tr("S", "Sunday" ) ); | 101 | header->addLabel( tr("S", "Sunday" ) ); |
102 | } else { | 102 | } else { |
103 | header->addLabel( tr("S", "Sunday" ) ); | 103 | header->addLabel( tr("S", "Sunday" ) ); |
104 | header->addLabel( tr("M", "Monday") ); | 104 | header->addLabel( tr("M", "Monday") ); |
105 | header->addLabel( tr("T", "Tuesday") ); | 105 | header->addLabel( tr("T", "Tuesday") ); |
106 | header->addLabel( tr("W", "Wednesday" ) ); | 106 | header->addLabel( tr("W", "Wednesday" ) ); |
107 | header->addLabel( tr("T", "Thursday" ) ); | 107 | header->addLabel( tr("T", "Thursday" ) ); |
108 | header->addLabel( tr("F", "Friday" ) ); | 108 | header->addLabel( tr("F", "Friday" ) ); |
109 | header->addLabel( tr("S", "Saturday" ) ); | 109 | header->addLabel( tr("S", "Saturday" ) ); |
110 | } | 110 | } |
111 | bFirst = false; | 111 | bFirst = false; |
112 | } else { | 112 | } else { |
113 | // we are change things... | 113 | // we are change things... |
114 | if ( bOnMonday ) { | 114 | if ( bOnMonday ) { |
115 | header->setLabel( 1, tr("M", "Monday") ); | 115 | header->setLabel( 1, tr("M", "Monday") ); |
116 | header->setLabel( 2, tr("T", "Tuesday") ); | 116 | header->setLabel( 2, tr("T", "Tuesday") ); |
117 | header->setLabel( 3, tr("W", "Wednesday" ) ); | 117 | header->setLabel( 3, tr("W", "Wednesday" ) ); |
118 | header->setLabel( 4, tr("T", "Thursday" ) ); | 118 | header->setLabel( 4, tr("T", "Thursday" ) ); |
119 | header->setLabel( 5, tr("F", "Friday" ) ); | 119 | header->setLabel( 5, tr("F", "Friday" ) ); |
120 | header->setLabel( 6, tr("S", "Saturday" ) ); | 120 | header->setLabel( 6, tr("S", "Saturday" ) ); |
121 | header->setLabel( 7, tr("S", "Sunday" ) ); | 121 | header->setLabel( 7, tr("S", "Sunday" ) ); |
122 | } else { | 122 | } else { |
123 | header->setLabel( 1, tr("S", "Sunday" ) ); | 123 | header->setLabel( 1, tr("S", "Sunday" ) ); |
124 | header->setLabel( 2, tr("M", "Monday") ); | 124 | header->setLabel( 2, tr("M", "Monday") ); |
125 | header->setLabel( 3, tr("T", "Tuesday") ); | 125 | header->setLabel( 3, tr("T", "Tuesday") ); |
126 | header->setLabel( 4, tr("W", "Wednesday" ) ); | 126 | header->setLabel( 4, tr("W", "Wednesday" ) ); |
127 | header->setLabel( 5, tr("T", "Thursday" ) ); | 127 | header->setLabel( 5, tr("T", "Thursday" ) ); |
128 | header->setLabel( 6, tr("F", "Friday" ) ); | 128 | header->setLabel( 6, tr("F", "Friday" ) ); |
129 | header->setLabel( 7, tr("S", "Saturday" ) ); | 129 | header->setLabel( 7, tr("S", "Saturday" ) ); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | 135 | ||
136 | void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) | 136 | void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) |
137 | { | 137 | { |
138 | items.clear(); | 138 | items.clear(); |
139 | QValueListIterator<EffectiveEvent> it; | 139 | QValueListIterator<EffectiveEvent> it; |
140 | for ( it = ev.begin(); it != ev.end(); ++it ) { | 140 | for ( it = ev.begin(); it != ev.end(); ++it ) { |
141 | DateBookWeekItem *i = new DateBookWeekItem( *it ); | 141 | DateBookWeekItem *i = new DateBookWeekItem( *it ); |
142 | positionItem( i ); | 142 | if(!(i->event().end().hour()==i->event().start().hour() && i->event().end().minute()==i->event().start().minute())) {// Skip effective events with no duration. (i.e ending at 00:00) |
143 | items.append( i ); | 143 | positionItem( i ); |
144 | } | 144 | items.append( i ); |
145 | viewport()->update(); | 145 | } |
146 | } | ||
147 | viewport()->update(); | ||
146 | } | 148 | } |
147 | 149 | ||
148 | void DateBookWeekView::moveToHour( int h ) | 150 | void DateBookWeekView::moveToHour( int h ) |
149 | { | 151 | { |
150 | int offset = h*rowHeight; | 152 | int offset = h*rowHeight; |
151 | setContentsPos( 0, offset ); | 153 | setContentsPos( 0, offset ); |
152 | } | 154 | } |
153 | 155 | ||
154 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) | 156 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) |
155 | { | 157 | { |
156 | e->ignore(); | 158 | e->ignore(); |
157 | } | 159 | } |
158 | 160 | ||
159 | void DateBookWeekView::slotChangeClock( bool c ) | 161 | void DateBookWeekView::slotChangeClock( bool c ) |
160 | { | 162 | { |
161 | ampm = c; | 163 | ampm = c; |
162 | viewport()->update(); | 164 | viewport()->update(); |
163 | } | 165 | } |
164 | 166 | ||
165 | static inline int db_round30min( int m ) | 167 | static inline int db_round30min( int m ) |
166 | { | 168 | { |
167 | if ( m < 15 ) | 169 | if ( m < 15 ) |
168 | m = 0; | 170 | m = 0; |
169 | else if ( m < 45 ) | 171 | else if ( m < 45 ) |
170 | m = 1; | 172 | m = 1; |
171 | else | 173 | else |
172 | m = 2; | 174 | m = 2; |
173 | 175 | ||
174 | return m; | 176 | return m; |
175 | } | 177 | } |
176 | 178 | ||
177 | void DateBookWeekView::alterDay( int day ) | 179 | void DateBookWeekView::alterDay( int day ) |
178 | { | 180 | { |
179 | if ( !bOnMonday ) { | 181 | if ( !bOnMonday ) { |
180 | day--; | 182 | day--; |
181 | } | 183 | } |
182 | emit showDay( day ); | 184 | emit showDay( day ); |
183 | } | 185 | } |
184 | 186 | ||
185 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) | 187 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) |
186 | { | 188 | { |
187 | const int Width = 8; | 189 | const int Width = 8; |
188 | const EffectiveEvent ev = i->event(); | 190 | const EffectiveEvent ev = i->event(); |
189 | 191 | ||
190 | // 30 minute intervals | 192 | // 30 minute intervals |
191 | int y = ev.start().hour() * 2; | 193 | int y = ev.start().hour() * 2; |
192 | y += db_round30min( ev.start().minute() ); | 194 | y += db_round30min( ev.start().minute() ); |
193 | int y2 = ev.end().hour() * 2; | 195 | int y2 = ev.end().hour() * 2; |
194 | y2 += db_round30min( ev.end().minute() ); | 196 | y2 += db_round30min( ev.end().minute() ); |
195 | if ( y > 47 ) | 197 | if ( y > 47 ) |
196 | y = 47; | 198 | y = 47; |
197 | if ( y2 > 48 ) | 199 | if ( y2 > 48 ) |
198 | y2 = 48; | 200 | y2 = 48; |
199 | y = y * rowHeight / 2; | 201 | y = y * rowHeight / 2; |
200 | y2 = y2 * rowHeight / 2; | 202 | y2 = y2 * rowHeight / 2; |
201 | 203 | ||
202 | int h; | 204 | int h; |
203 | if ( ev.event().type() == Event::AllDay ) { | 205 | if ( ev.event().type() == Event::AllDay ) { |
204 | h = 48 * rowHeight / 2; | 206 | h = 48 * rowHeight / 2; |
205 | y = 0; | 207 | y = 0; |
206 | } else { | 208 | } else { |
207 | h=y2-y; | 209 | h=y2-y; |
208 | if ( h < 1 ) h = 1; | 210 | if ( h < 1 ) h = 1; |
209 | } | 211 | } |
210 | 212 | ||
211 | int dow = ev.date().dayOfWeek(); | 213 | int dow = ev.date().dayOfWeek(); |
212 | if ( !bOnMonday ) { | 214 | if ( !bOnMonday ) { |
213 | if ( dow == 7 ) | 215 | if ( dow == 7 ) |
214 | dow = 1; | 216 | dow = 1; |
215 | else | 217 | else |
216 | dow++; | 218 | dow++; |
217 | } | 219 | } |
218 | int x = header->sectionPos( dow ) - 1; | 220 | int x = header->sectionPos( dow ) - 1; |
219 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); | 221 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); |
220 | DateBookWeekItem *isect = 0; | 222 | DateBookWeekItem *isect = 0; |
221 | do { | 223 | do { |
222 | i->setGeometry( x, y, Width, h ); | 224 | i->setGeometry( x, y, Width, h ); |
223 | isect = intersects( i ); | 225 | isect = intersects( i ); |
224 | x += Width - 1; | 226 | x += Width - 1; |
225 | } while ( isect && x < xlim ); | 227 | } while ( isect && x < xlim ); |
226 | } | 228 | } |
227 | 229 | ||
228 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) | 230 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) |
229 | { | 231 | { |
230 | QRect geom = item->geometry(); | 232 | QRect geom = item->geometry(); |
231 | 233 | ||
232 | // We allow the edges to overlap | 234 | // We allow the edges to overlap |
233 | geom.moveBy( 1, 1 ); | 235 | geom.moveBy( 1, 1 ); |
234 | geom.setSize( geom.size()-QSize(2,2) ); | 236 | geom.setSize( geom.size()-QSize(2,2) ); |
235 | 237 | ||
236 | QListIterator<DateBookWeekItem> it(items); | 238 | QListIterator<DateBookWeekItem> it(items); |
237 | for ( ; it.current(); ++it ) { | 239 | for ( ; it.current(); ++it ) { |
238 | DateBookWeekItem *i = it.current(); | 240 | DateBookWeekItem *i = it.current(); |
239 | if ( i != item ) { | 241 | if ( i != item ) { |
240 | if ( i->geometry().intersects( geom ) ) { | 242 | if ( i->geometry().intersects( geom ) ) { |
241 | return i; | 243 | return i; |