-rw-r--r-- | microkde/kdatetbl.cpp | 99 |
1 files changed, 53 insertions, 46 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index 353f78d..10dc449 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp | |||
@@ -44,6 +44,14 @@ | |||
44 | #include <qpen.h> | 44 | #include <qpen.h> |
45 | #include <qpainter.h> | 45 | #include <qpainter.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <QDesktopWidget> | ||
48 | //Added by qt3to4: | ||
49 | #include <QResizeEvent> | ||
50 | #include <QFocusEvent> | ||
51 | #include <Q3Frame> | ||
52 | #include <QMouseEvent> | ||
53 | #include <QKeyEvent> | ||
54 | #include <QEvent> | ||
47 | #include <assert.h> | 55 | #include <assert.h> |
48 | #include <qapplication.h> | 56 | #include <qapplication.h> |
49 | 57 | ||
@@ -69,7 +77,7 @@ KDateValidator::date(const QString& text, QDate& d) const | |||
69 | d = tmp; | 77 | d = tmp; |
70 | return Acceptable; | 78 | return Acceptable; |
71 | } else | 79 | } else |
72 | return Valid; | 80 | return QValidator::Intermediate; |
73 | } | 81 | } |
74 | 82 | ||
75 | void | 83 | void |
@@ -78,22 +86,22 @@ KDateValidator::fixup( QString& ) const | |||
78 | 86 | ||
79 | } | 87 | } |
80 | 88 | ||
81 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) | 89 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, Qt::WFlags f) |
82 | : QGridView(parent, name, f) | 90 | : Q3GridView(parent, name, f) |
83 | { | 91 | { |
84 | setFont( KGlobalSettings::generalFont() ); | 92 | setFont( KGlobalSettings::generalFont() ); |
85 | if(!date_.isValid()) | 93 | if(!date_.isValid()) |
86 | { | 94 | { |
87 | date_=QDate::currentDate(); | 95 | date_=QDate::currentDate(); |
88 | } | 96 | } |
89 | setFocusPolicy( QWidget::StrongFocus ); | 97 | setFocusPolicy( Qt::StrongFocus ); |
90 | setNumRows(7); // 6 weeks max + headline | 98 | setNumRows(7); // 6 weeks max + headline |
91 | setNumCols(7); // 7 days a week | 99 | setNumCols(7); // 7 days a week |
92 | setHScrollBarMode(AlwaysOff); | 100 | setHScrollBarMode(AlwaysOff); |
93 | setVScrollBarMode(AlwaysOff); | 101 | setVScrollBarMode(AlwaysOff); |
94 | viewport()->setBackgroundColor(QColor(220,245,255)); | 102 | viewport()->setBackgroundColor(QColor(220,245,255)); |
95 | #if 0 | 103 | #if 0 |
96 | viewport()->setEraseColor(lightGray); | 104 | viewport()->setEraseColor(Qt::lightGray); |
97 | #endif | 105 | #endif |
98 | mMarkCurrent = false; | 106 | mMarkCurrent = false; |
99 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth | 107 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth |
@@ -108,7 +116,7 @@ KDateTable::paintCell(QPainter *painter, int row, int col) | |||
108 | int w=cellWidth(); | 116 | int w=cellWidth(); |
109 | int h=cellHeight(); | 117 | int h=cellHeight(); |
110 | int pos; | 118 | int pos; |
111 | QBrush brushBlue(blue); | 119 | QBrush brushBlue(Qt::blue); |
112 | QBrush brushLightblue(QColor(220,245,255)); | 120 | QBrush brushLightblue(QColor(220,245,255)); |
113 | QFont _font=font(); | 121 | QFont _font=font(); |
114 | // ----- | 122 | // ----- |
@@ -133,18 +141,17 @@ KDateTable::paintCell(QPainter *painter, int row, int col) | |||
133 | painter->setPen(QColor(220,245,255)); | 141 | painter->setPen(QColor(220,245,255)); |
134 | painter->setBrush(brushLightblue); | 142 | painter->setBrush(brushLightblue); |
135 | painter->drawRect(0, 0, w, h); | 143 | painter->drawRect(0, 0, w, h); |
136 | painter->setPen(blue); | 144 | painter->setPen(Qt::blue); |
137 | } else { | 145 | } else { |
138 | painter->setPen(blue); | 146 | painter->setPen(Qt::blue); |
139 | painter->setBrush(brushBlue); | 147 | painter->setBrush(brushBlue); |
140 | painter->drawRect(0, 0, w, h); | 148 | painter->drawRect(0, 0, w, h); |
141 | painter->setPen(white); | 149 | painter->setPen(Qt::white); |
142 | } | 150 | } |
143 | painter->drawText(0, 0, w, h-1, AlignCenter, | 151 | painter->drawText(0, 0, w, h-1, Qt::AlignCenter, |
144 | daystr, -1, &rect); | 152 | daystr, -1, &rect); |
145 | painter->setPen(black); | 153 | painter->setPen(Qt::black); |
146 | painter->moveTo(0, h-1); | 154 | painter->drawLine(0, h-1, w-1, h-1); |
147 | painter->lineTo(w-1, h-1); | ||
148 | // ----- draw the weekday: | 155 | // ----- draw the weekday: |
149 | } else { | 156 | } else { |
150 | painter->setFont(_font); | 157 | painter->setFont(_font); |
@@ -161,33 +168,33 @@ KDateTable::paintCell(QPainter *painter, int row, int col) | |||
161 | } else { // following month | 168 | } else { // following month |
162 | text.setNum(pos-firstday-numdays+1); | 169 | text.setNum(pos-firstday-numdays+1); |
163 | } | 170 | } |
164 | painter->setPen(gray); | 171 | painter->setPen(Qt::gray); |
165 | } else { // paint a day of the current month | 172 | } else { // paint a day of the current month |
166 | text.setNum(pos-firstday+1); | 173 | text.setNum(pos-firstday+1); |
167 | painter->setPen(black); | 174 | painter->setPen(Qt::black); |
168 | } | 175 | } |
169 | 176 | ||
170 | pen=painter->pen(); | 177 | pen=painter->pen(); |
171 | if(firstday+date.day()-1==pos) | 178 | if(firstday+date.day()-1==pos) |
172 | { | 179 | { |
173 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 180 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
174 | painter->setPen(green); | 181 | painter->setPen(Qt::green); |
175 | else | 182 | else |
176 | painter->setPen(red); | 183 | painter->setPen(Qt::red); |
177 | if(hasFocus()) | 184 | if(hasFocus()) |
178 | { | 185 | { |
179 | painter->setBrush(darkRed); | 186 | painter->setBrush(Qt::darkRed); |
180 | pen=white; | 187 | pen=QColor(Qt::white); |
181 | } else { | 188 | } else { |
182 | painter->setBrush(darkGray); | 189 | painter->setBrush(Qt::darkGray); |
183 | pen=white; | 190 | pen=QColor(Qt::white); |
184 | } | 191 | } |
185 | } else { | 192 | } else { |
186 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 193 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
187 | { | 194 | { |
188 | painter->setPen(green); | 195 | painter->setPen(Qt::green); |
189 | painter->setBrush(darkGreen); | 196 | painter->setBrush(Qt::darkGreen); |
190 | pen=white; | 197 | pen=QColor(Qt::white); |
191 | } else { | 198 | } else { |
192 | painter->setBrush(QColor(220,245,255)); | 199 | painter->setBrush(QColor(220,245,255)); |
193 | painter->setPen(QColor(220,245,255)); | 200 | painter->setPen(QColor(220,245,255)); |
@@ -195,7 +202,7 @@ KDateTable::paintCell(QPainter *painter, int row, int col) | |||
195 | } | 202 | } |
196 | painter->drawRect(0, 0, w, h); | 203 | painter->drawRect(0, 0, w, h); |
197 | painter->setPen(pen); | 204 | painter->setPen(pen); |
198 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); | 205 | painter->drawText(0, 0, w, h, Qt::AlignCenter, text, -1, &rect); |
199 | } | 206 | } |
200 | /* | 207 | /* |
201 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); | 208 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); |
@@ -274,7 +281,7 @@ KDateTable::keyPressEvent( QKeyEvent *e ) | |||
274 | void | 281 | void |
275 | KDateTable::viewportResizeEvent(QResizeEvent * e) | 282 | KDateTable::viewportResizeEvent(QResizeEvent * e) |
276 | { | 283 | { |
277 | QGridView::viewportResizeEvent(e); | 284 | Q3GridView::viewportResizeEvent(e); |
278 | 285 | ||
279 | setCellWidth(viewport()->width()/7); | 286 | setCellWidth(viewport()->width()/7); |
280 | setCellHeight(viewport()->height()/7); | 287 | setCellHeight(viewport()->height()/7); |
@@ -409,13 +416,13 @@ KDateTable::getDate() const | |||
409 | void KDateTable::focusInEvent( QFocusEvent *e ) | 416 | void KDateTable::focusInEvent( QFocusEvent *e ) |
410 | { | 417 | { |
411 | repaintContents(false); | 418 | repaintContents(false); |
412 | QGridView::focusInEvent( e ); | 419 | Q3GridView::focusInEvent( e ); |
413 | } | 420 | } |
414 | 421 | ||
415 | void KDateTable::focusOutEvent( QFocusEvent *e ) | 422 | void KDateTable::focusOutEvent( QFocusEvent *e ) |
416 | { | 423 | { |
417 | repaintContents(false); | 424 | repaintContents(false); |
418 | QGridView::focusOutEvent( e ); | 425 | Q3GridView::focusOutEvent( e ); |
419 | } | 426 | } |
420 | 427 | ||
421 | QSize | 428 | QSize |
@@ -432,7 +439,7 @@ KDateTable::sizeHint() const | |||
432 | 439 | ||
433 | KDateInternalMonthPicker::KDateInternalMonthPicker | 440 | KDateInternalMonthPicker::KDateInternalMonthPicker |
434 | (QWidget* parent, const char* name) | 441 | (QWidget* parent, const char* name) |
435 | : QGridView(parent, name), | 442 | : Q3GridView(parent, name), |
436 | result(0) // invalid | 443 | result(0) // invalid |
437 | { | 444 | { |
438 | QRect rect; | 445 | QRect rect; |
@@ -451,13 +458,13 @@ KDateInternalMonthPicker::KDateInternalMonthPicker | |||
451 | setFont(font); | 458 | setFont(font); |
452 | setHScrollBarMode(AlwaysOff); | 459 | setHScrollBarMode(AlwaysOff); |
453 | setVScrollBarMode(AlwaysOff); | 460 | setVScrollBarMode(AlwaysOff); |
454 | setFrameStyle(QFrame::NoFrame); | 461 | setFrameStyle(Q3Frame::NoFrame); |
455 | setNumRows(4); | 462 | setNumRows(4); |
456 | setNumCols(3); | 463 | setNumCols(3); |
457 | // enable to find drawing failures: | 464 | // enable to find drawing failures: |
458 | // setTableFlags(Tbl_clipCellPainting); | 465 | // setTableFlags(Tbl_clipCellPainting); |
459 | #if 0 | 466 | #if 0 |
460 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 467 | viewport()->setEraseColor(Qt::lightGray); // for consistency with the datepicker |
461 | #endif | 468 | #endif |
462 | // ----- find the preferred size | 469 | // ----- find the preferred size |
463 | // (this is slow, possibly, but unfortunatly it is needed here): | 470 | // (this is slow, possibly, but unfortunatly it is needed here): |
@@ -487,7 +494,7 @@ KDateInternalMonthPicker::getResult() const | |||
487 | void | 494 | void |
488 | KDateInternalMonthPicker::setupPainter(QPainter *p) | 495 | KDateInternalMonthPicker::setupPainter(QPainter *p) |
489 | { | 496 | { |
490 | p->setPen(black); | 497 | p->setPen(Qt::black); |
491 | } | 498 | } |
492 | 499 | ||
493 | void | 500 | void |
@@ -505,7 +512,7 @@ KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) | |||
505 | // ----- find the number of the cell: | 512 | // ----- find the number of the cell: |
506 | index=3*row+col+1; | 513 | index=3*row+col+1; |
507 | text=KGlobal::locale()->monthName(index, false); | 514 | text=KGlobal::locale()->monthName(index, false); |
508 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | 515 | painter->drawText(0, 0, cellWidth(), cellHeight(), Qt::AlignCenter, text); |
509 | if ( activeCol == col && activeRow == row ) | 516 | if ( activeCol == col && activeRow == row ) |
510 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | 517 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); |
511 | } | 518 | } |
@@ -513,7 +520,7 @@ KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) | |||
513 | void | 520 | void |
514 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) | 521 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) |
515 | { | 522 | { |
516 | if(!isEnabled() || e->button() != LeftButton) | 523 | if(!isEnabled() || e->button() != Qt::LeftButton) |
517 | { | 524 | { |
518 | KNotifyClient::beep(); | 525 | KNotifyClient::beep(); |
519 | return; | 526 | return; |
@@ -540,7 +547,7 @@ KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) | |||
540 | void | 547 | void |
541 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) | 548 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) |
542 | { | 549 | { |
543 | if (e->state() & LeftButton) | 550 | if (e->state() & Qt::LeftButton) |
544 | { | 551 | { |
545 | int row, col; | 552 | int row, col; |
546 | QPoint mouseCoord; | 553 | QPoint mouseCoord; |
@@ -614,7 +621,7 @@ KDateInternalYearSelector::KDateInternalYearSelector | |||
614 | font.setPointSize(fontsize); | 621 | font.setPointSize(fontsize); |
615 | setFont(font); | 622 | setFont(font); |
616 | #if 0 | 623 | #if 0 |
617 | setFrameStyle(QFrame::NoFrame); | 624 | setFrameStyle(Q3Frame::NoFrame); |
618 | #endif | 625 | #endif |
619 | // we have to respect the limits of QDate here, I fear: | 626 | // we have to respect the limits of QDate here, I fear: |
620 | val->setRange(0, 8000); | 627 | val->setRange(0, 8000); |
@@ -661,18 +668,18 @@ KDateInternalYearSelector::setYear(int year) | |||
661 | } | 668 | } |
662 | 669 | ||
663 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) | 670 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) |
664 | : QFrame(parent, name, WType_Popup), | 671 | : Q3Frame(parent, name, Qt::WType_Popup), |
665 | result(0), // rejected | 672 | result(0), // rejected |
666 | main(0) | 673 | main(0) |
667 | { | 674 | { |
668 | setFrameStyle(QFrame::Box|QFrame::Raised); | 675 | setFrameStyle(Q3Frame::Box|Q3Frame::Raised); |
669 | setMidLineWidth(2); | 676 | setMidLineWidth(2); |
670 | } | 677 | } |
671 | 678 | ||
672 | void | 679 | void |
673 | KPopupFrame::keyPressEvent(QKeyEvent* e) | 680 | KPopupFrame::keyPressEvent(QKeyEvent* e) |
674 | { | 681 | { |
675 | if(e->key()==Key_Escape) | 682 | if(e->key()==Qt::Key_Escape) |
676 | { | 683 | { |
677 | result=0; // rejected | 684 | result=0; // rejected |
678 | qApp->exit_loop(); | 685 | qApp->exit_loop(); |
@@ -756,7 +763,7 @@ void KDateTable::virtual_hook( int, void* ) | |||
756 | 763 | ||
757 | KDateInternalWeekPicker::KDateInternalWeekPicker | 764 | KDateInternalWeekPicker::KDateInternalWeekPicker |
758 | (QWidget* parent, const char* name) | 765 | (QWidget* parent, const char* name) |
759 | : QGridView(parent, name), | 766 | : Q3GridView(parent, name), |
760 | result(0) // invalid | 767 | result(0) // invalid |
761 | { | 768 | { |
762 | QRect rect; | 769 | QRect rect; |
@@ -773,7 +780,7 @@ KDateInternalWeekPicker::KDateInternalWeekPicker | |||
773 | setFont(font); | 780 | setFont(font); |
774 | setHScrollBarMode(AlwaysOff); | 781 | setHScrollBarMode(AlwaysOff); |
775 | setVScrollBarMode(AlwaysOff); | 782 | setVScrollBarMode(AlwaysOff); |
776 | setFrameStyle(QFrame::NoFrame); | 783 | setFrameStyle(Q3Frame::NoFrame); |
777 | if ( QApplication::desktop()->height() > 240 ) { | 784 | if ( QApplication::desktop()->height() > 240 ) { |
778 | setNumRows(13); | 785 | setNumRows(13); |
779 | setNumCols(4); | 786 | setNumCols(4); |
@@ -784,7 +791,7 @@ KDateInternalWeekPicker::KDateInternalWeekPicker | |||
784 | // enable to find drawing failures: | 791 | // enable to find drawing failures: |
785 | // setTableFlags(Tbl_clipCellPainting); | 792 | // setTableFlags(Tbl_clipCellPainting); |
786 | #if 0 | 793 | #if 0 |
787 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 794 | viewport()->setEraseColor(Qt::lightGray); // for consistency with the datepicker |
788 | #endif | 795 | #endif |
789 | // ----- find the preferred size | 796 | // ----- find the preferred size |
790 | // (this is slow, possibly, but unfortunatly it is needed here): | 797 | // (this is slow, possibly, but unfortunatly it is needed here): |
@@ -818,7 +825,7 @@ KDateInternalWeekPicker::getResult() const | |||
818 | void | 825 | void |
819 | KDateInternalWeekPicker::setupPainter(QPainter *p) | 826 | KDateInternalWeekPicker::setupPainter(QPainter *p) |
820 | { | 827 | { |
821 | p->setPen(black); | 828 | p->setPen(Qt::black); |
822 | } | 829 | } |
823 | 830 | ||
824 | void | 831 | void |
@@ -836,7 +843,7 @@ KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) | |||
836 | // ----- find the number of the cell: | 843 | // ----- find the number of the cell: |
837 | index=numCols()*row+col+1; | 844 | index=numCols()*row+col+1; |
838 | text=QString::number( index ); | 845 | text=QString::number( index ); |
839 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | 846 | painter->drawText(0, 0, cellWidth(), cellHeight(), Qt::AlignCenter, text); |
840 | if ( activeCol == col && activeRow == row ) | 847 | if ( activeCol == col && activeRow == row ) |
841 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | 848 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); |
842 | } | 849 | } |
@@ -844,7 +851,7 @@ KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) | |||
844 | void | 851 | void |
845 | KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) | 852 | KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) |
846 | { | 853 | { |
847 | if(!isEnabled() || e->button() != LeftButton) | 854 | if(!isEnabled() || e->button() != Qt::LeftButton) |
848 | { | 855 | { |
849 | KNotifyClient::beep(); | 856 | KNotifyClient::beep(); |
850 | return; | 857 | return; |
@@ -871,7 +878,7 @@ KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) | |||
871 | void | 878 | void |
872 | KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) | 879 | KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) |
873 | { | 880 | { |
874 | if (e->state() & LeftButton) | 881 | if (e->state() & Qt::LeftButton) |
875 | { | 882 | { |
876 | int row, col; | 883 | int row, col; |
877 | QPoint mouseCoord; | 884 | QPoint mouseCoord; |