author | umopapisdn <umopapisdn> | 2003-04-13 22:25:35 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-04-13 22:25:35 (UTC) |
commit | 053c38bb48ae8e7563293bc029f3c9d029b947f7 (patch) (unidiff) | |
tree | 4277c6ba37ceed2233df07bf8ead89b049977f2f | |
parent | 1745c6565e18506d5cb5631ae13cfc5fab060fee (diff) | |
download | opie-053c38bb48ae8e7563293bc029f3c9d029b947f7.zip opie-053c38bb48ae8e7563293bc029f3c9d029b947f7.tar.gz opie-053c38bb48ae8e7563293bc029f3c9d029b947f7.tar.bz2 |
New Feature: Quick entries now honors the duration selected.
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 0a40ea9..e212807 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -81,198 +81,207 @@ void DateBookDayView::initHeader() | |||
81 | strTmp = QString::number( i - 12 ) + tr(":00p"); | 81 | strTmp = QString::number( i - 12 ) + tr(":00p"); |
82 | else | 82 | else |
83 | strTmp = QString::number(i) + ":00"; | 83 | strTmp = QString::number(i) + ":00"; |
84 | } else { | 84 | } else { |
85 | if ( i < 10 ) | 85 | if ( i < 10 ) |
86 | strTmp = "0" + QString::number(i) + ":00"; | 86 | strTmp = "0" + QString::number(i) + ":00"; |
87 | else | 87 | else |
88 | strTmp = QString::number(i) + ":00"; | 88 | strTmp = QString::number(i) + ":00"; |
89 | } | 89 | } |
90 | strTmp = strTmp.rightJustify( 6, ' ' ); | 90 | strTmp = strTmp.rightJustify( 6, ' ' ); |
91 | verticalHeader()->setLabel( i, strTmp ); | 91 | verticalHeader()->setLabel( i, strTmp ); |
92 | setRowStretchable( i, FALSE ); | 92 | setRowStretchable( i, FALSE ); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void DateBookDayView::slotDateChanged( int y, int m, int d ) | 96 | void DateBookDayView::slotDateChanged( int y, int m, int d ) |
97 | { | 97 | { |
98 | currDate.setYMD(y,m,d); | 98 | currDate.setYMD(y,m,d); |
99 | } | 99 | } |
100 | 100 | ||
101 | void DateBookDayView::slotChangeClock( bool newClock ) | 101 | void DateBookDayView::slotChangeClock( bool newClock ) |
102 | { | 102 | { |
103 | ampm = newClock; | 103 | ampm = newClock; |
104 | initHeader(); | 104 | initHeader(); |
105 | } | 105 | } |
106 | 106 | ||
107 | bool DateBookDayView::whichClock() const | 107 | bool DateBookDayView::whichClock() const |
108 | { | 108 | { |
109 | return ampm; | 109 | return ampm; |
110 | } | 110 | } |
111 | 111 | ||
112 | void DateBookDayView::moveUp() | 112 | void DateBookDayView::moveUp() |
113 | { | 113 | { |
114 | scrollBy(0, -20); | 114 | scrollBy(0, -20); |
115 | } | 115 | } |
116 | 116 | ||
117 | void DateBookDayView::moveDown() | 117 | void DateBookDayView::moveDown() |
118 | { | 118 | { |
119 | scrollBy(0, 20); | 119 | scrollBy(0, 20); |
120 | } | 120 | } |
121 | 121 | ||
122 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | 122 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) |
123 | { | 123 | { |
124 | int w = cr.width(); | 124 | int w = cr.width(); |
125 | int h = cr.height(); | 125 | int h = cr.height(); |
126 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); | 126 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); |
127 | if ( showGrid() ) { | 127 | if ( showGrid() ) { |
128 | // Draw our lines | 128 | // Draw our lines |
129 | int x2 = w - 1; | 129 | int x2 = w - 1; |
130 | int y2 = h - 1; | 130 | int y2 = h - 1; |
131 | QPen pen( p->pen() ); | 131 | QPen pen( p->pen() ); |
132 | p->setPen( colorGroup().dark() ); | 132 | p->setPen( colorGroup().dark() ); |
133 | p->drawLine( x2, 0, x2, y2 ); | 133 | p->drawLine( x2, 0, x2, y2 ); |
134 | p->drawLine( 0, y2, x2, y2 ); | 134 | p->drawLine( 0, y2, x2, y2 ); |
135 | 135 | ||
136 | p->setPen( colorGroup().midlight() ); | 136 | p->setPen( colorGroup().midlight() ); |
137 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); | 137 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); |
138 | 138 | ||
139 | p->setPen( pen ); | 139 | p->setPen( pen ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 143 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
144 | { | 144 | { |
145 | } | 145 | } |
146 | 146 | ||
147 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 147 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
148 | { | 148 | { |
149 | QTable::resizeEvent( e ); | 149 | QTable::resizeEvent( e ); |
150 | columnWidthChanged( 0 ); | 150 | columnWidthChanged( 0 ); |
151 | emit sigColWidthChanged(); | 151 | emit sigColWidthChanged(); |
152 | } | 152 | } |
153 | 153 | ||
154 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) | 154 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) |
155 | { | 155 | { |
156 | QString txt = e->text(); | 156 | QString txt = e->text(); |
157 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { | 157 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { |
158 | // we this is some sort of thing we know about... | 158 | // we this is some sort of thing we know about... |
159 | e->accept(); | 159 | e->accept(); |
160 | emit sigCapturedKey( txt ); | 160 | emit sigCapturedKey( txt ); |
161 | } else { | 161 | } else { |
162 | // I don't know what this key is, do you? | 162 | // I don't know what this key is, do you? |
163 | e->ignore(); | 163 | e->ignore(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | void DateBookDayView::setRowStyle( int style ) | 167 | void DateBookDayView::setRowStyle( int style ) |
168 | { | 168 | { |
169 | if (style<0) style = 0; | 169 | if (style<0) style = 0; |
170 | 170 | ||
171 | for (int i=0; i<numRows(); i++) | 171 | for (int i=0; i<numRows(); i++) |
172 | setRowHeight(i, style*10+20); | 172 | setRowHeight(i, style*10+20); |
173 | } | 173 | } |
174 | 174 | ||
175 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) | 175 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) |
176 | { | 176 | { |
177 | int y=e->y(); | 177 | int sh=99,eh=-1; |
178 | int diff=y%(this->rowHeight(0)); | 178 | |
179 | int hour=y/this->rowHeight(0); | 179 | for(int i=0;i<this->numSelections();i++) { |
180 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(hour,0,0,0)),QDateTime(currDate,QTime(hour,59,0,0)),this->viewport(),"quickedit"); | 180 | QTableSelection sel = this->selection( i ); |
181 | sh = QMIN(sh,sel.topRow()); | ||
182 | eh = QMAX(sh,sel.bottomRow()+1); | ||
183 | } | ||
184 | if (sh > 23 || eh < 1) { | ||
185 | sh=8; | ||
186 | eh=9; | ||
187 | } | ||
188 | |||
189 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); | ||
181 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | 190 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); |
182 | this->moveChild(quickLineEdit,0,y-diff); | 191 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); |
183 | quickLineEdit->setFocus(); | 192 | quickLineEdit->setFocus(); |
184 | quickLineEdit->show(); | 193 | quickLineEdit->show(); |
185 | } | 194 | } |
186 | 195 | ||
187 | //=========================================================================== | 196 | //=========================================================================== |
188 | 197 | ||
189 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0) : QLineEdit(parent,name) | 198 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0) : QLineEdit(parent,name) |
190 | { | 199 | { |
191 | active=1; | 200 | active=1; |
192 | quickEvent.setStart(start); | 201 | quickEvent.setStart(start); |
193 | quickEvent.setEnd(end); | 202 | quickEvent.setEnd(end); |
194 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); | 203 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
195 | } | 204 | } |
196 | 205 | ||
197 | void DateBookDayViewQuickLineEdit::slotReturnPressed() | 206 | void DateBookDayViewQuickLineEdit::slotReturnPressed() |
198 | { | 207 | { |
199 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. | 208 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. |
200 | quickEvent.setDescription(this->text()); | 209 | quickEvent.setDescription(this->text()); |
201 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); | 210 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); |
202 | emit(insertEvent(quickEvent)); | 211 | emit(insertEvent(quickEvent)); |
203 | active=0; | 212 | active=0; |
204 | } | 213 | } |
205 | this->close(true);// Close and also delete this widget | 214 | this->close(true);// Close and also delete this widget |
206 | } | 215 | } |
207 | 216 | ||
208 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) | 217 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) |
209 | { | 218 | { |
210 | slotReturnPressed(); // Reuse code to add event and close this widget. | 219 | slotReturnPressed(); // Reuse code to add event and close this widget. |
211 | } | 220 | } |
212 | 221 | ||
213 | //=========================================================================== | 222 | //=========================================================================== |
214 | 223 | ||
215 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) | 224 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) |
216 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | 225 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) |
217 | { | 226 | { |
218 | widgetList.setAutoDelete( true ); | 227 | widgetList.setAutoDelete( true ); |
219 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 228 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
220 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 229 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); |
221 | view = new DateBookDayView( ampm, this, "day view" ); | 230 | view = new DateBookDayView( ampm, this, "day view" ); |
222 | 231 | ||
223 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); | 232 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); |
224 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); | 233 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); |
225 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); | 234 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); |
226 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | 235 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
227 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); | 236 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); |
228 | 237 | ||
229 | QTimer *timer = new QTimer( this ); | 238 | QTimer *timer = new QTimer( this ); |
230 | 239 | ||
231 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | 240 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors |
232 | timer->start( 1000*60*5, FALSE ); //update every 5min | 241 | timer->start( 1000*60*5, FALSE ); //update every 5min |
233 | 242 | ||
234 | selectedWidget = 0; | 243 | selectedWidget = 0; |
235 | 244 | ||
236 | timeMarker = new DateBookDayTimeMarker( this ); | 245 | timeMarker = new DateBookDayTimeMarker( this ); |
237 | timeMarker->setTime( QTime::currentTime() ); | 246 | timeMarker->setTime( QTime::currentTime() ); |
238 | rowStyle = -1; // initialize with bogus values | 247 | rowStyle = -1; // initialize with bogus values |
239 | } | 248 | } |
240 | 249 | ||
241 | void DateBookDay::setJumpToCurTime( bool bJump ) | 250 | void DateBookDay::setJumpToCurTime( bool bJump ) |
242 | { | 251 | { |
243 | jumpToCurTime = bJump; | 252 | jumpToCurTime = bJump; |
244 | } | 253 | } |
245 | 254 | ||
246 | void DateBookDay::setRowStyle( int style ) | 255 | void DateBookDay::setRowStyle( int style ) |
247 | { | 256 | { |
248 | if (rowStyle != style) view->setRowStyle( style ); | 257 | if (rowStyle != style) view->setRowStyle( style ); |
249 | rowStyle = style; | 258 | rowStyle = style; |
250 | } | 259 | } |
251 | 260 | ||
252 | void DateBookDay::updateView( void ) | 261 | void DateBookDay::updateView( void ) |
253 | { | 262 | { |
254 | timeMarker->setTime( QTime::currentTime() ); | 263 | timeMarker->setTime( QTime::currentTime() ); |
255 | //need to find a way to update all DateBookDayWidgets | 264 | //need to find a way to update all DateBookDayWidgets |
256 | } | 265 | } |
257 | 266 | ||
258 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) | 267 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) |
259 | { | 268 | { |
260 | selectedWidget = w; | 269 | selectedWidget = w; |
261 | } | 270 | } |
262 | 271 | ||
263 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) | 272 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) |
264 | { | 273 | { |
265 | return selectedWidget; | 274 | return selectedWidget; |
266 | } | 275 | } |
267 | 276 | ||
268 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | 277 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) |
269 | { | 278 | { |
270 | start.setDate( currDate ); | 279 | start.setDate( currDate ); |
271 | end.setDate( currDate ); | 280 | end.setDate( currDate ); |
272 | 281 | ||
273 | int sh=99,eh=-1; | 282 | int sh=99,eh=-1; |
274 | 283 | ||
275 | int n = dayView()->numSelections(); | 284 | int n = dayView()->numSelections(); |
276 | 285 | ||
277 | for (int i=0; i<n; i++) { | 286 | for (int i=0; i<n; i++) { |
278 | QTableSelection sel = dayView()->selection( i ); | 287 | QTableSelection sel = dayView()->selection( i ); |