-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 @@ -43,8 +43,16 @@ #include <qstring.h> #include <qpen.h> #include <qpainter.h> #include <qdialog.h> +#include <QDesktopWidget> +//Added by qt3to4: +#include <QResizeEvent> +#include <QFocusEvent> +#include <Q3Frame> +#include <QMouseEvent> +#include <QKeyEvent> +#include <QEvent> #include <assert.h> #include <qapplication.h> KDateValidator::KDateValidator(QWidget* parent, const char* name) @@ -68,33 +76,33 @@ KDateValidator::date(const QString& text, QDate& d) const { d = tmp; return Acceptable; } else - return Valid; + return QValidator::Intermediate; } void KDateValidator::fixup( QString& ) const { } -KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) - : QGridView(parent, name, f) +KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, Qt::WFlags f) + : Q3GridView(parent, name, f) { setFont( KGlobalSettings::generalFont() ); if(!date_.isValid()) { date_=QDate::currentDate(); } - setFocusPolicy( QWidget::StrongFocus ); + setFocusPolicy( Qt::StrongFocus ); setNumRows(7); // 6 weeks max + headline setNumCols(7); // 7 days a week setHScrollBarMode(AlwaysOff); setVScrollBarMode(AlwaysOff); viewport()->setBackgroundColor(QColor(220,245,255)); #if 0 - viewport()->setEraseColor(lightGray); + viewport()->setEraseColor(Qt::lightGray); #endif mMarkCurrent = false; setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth } @@ -107,9 +115,9 @@ KDateTable::paintCell(QPainter *painter, int row, int col) QPen pen; int w=cellWidth(); int h=cellHeight(); int pos; - QBrush brushBlue(blue); + QBrush brushBlue(Qt::blue); QBrush brushLightblue(QColor(220,245,255)); QFont _font=font(); // ----- if(row==0) @@ -132,20 +140,19 @@ KDateTable::paintCell(QPainter *painter, int row, int col) { painter->setPen(QColor(220,245,255)); painter->setBrush(brushLightblue); painter->drawRect(0, 0, w, h); - painter->setPen(blue); + painter->setPen(Qt::blue); } else { - painter->setPen(blue); + painter->setPen(Qt::blue); painter->setBrush(brushBlue); painter->drawRect(0, 0, w, h); - painter->setPen(white); + painter->setPen(Qt::white); } - painter->drawText(0, 0, w, h-1, AlignCenter, + painter->drawText(0, 0, w, h-1, Qt::AlignCenter, daystr, -1, &rect); - painter->setPen(black); - painter->moveTo(0, h-1); - painter->lineTo(w-1, h-1); + painter->setPen(Qt::black); + painter->drawLine(0, h-1, w-1, h-1); // ----- draw the weekday: } else { painter->setFont(_font); pos=7*(row-1)+col; @@ -160,43 +167,43 @@ KDateTable::paintCell(QPainter *painter, int row, int col) text.setNum(numDaysPrevMonth+pos-firstday+1); } else { // following month text.setNum(pos-firstday-numdays+1); } - painter->setPen(gray); + painter->setPen(Qt::gray); } else { // paint a day of the current month text.setNum(pos-firstday+1); - painter->setPen(black); + painter->setPen(Qt::black); } pen=painter->pen(); if(firstday+date.day()-1==pos) { if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) - painter->setPen(green); + painter->setPen(Qt::green); else - painter->setPen(red); + painter->setPen(Qt::red); if(hasFocus()) { - painter->setBrush(darkRed); - pen=white; + painter->setBrush(Qt::darkRed); + pen=QColor(Qt::white); } else { - painter->setBrush(darkGray); - pen=white; + painter->setBrush(Qt::darkGray); + pen=QColor(Qt::white); } } else { if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) { - painter->setPen(green); - painter->setBrush(darkGreen); - pen=white; + painter->setPen(Qt::green); + painter->setBrush(Qt::darkGreen); + pen=QColor(Qt::white); } else { painter->setBrush(QColor(220,245,255)); painter->setPen(QColor(220,245,255)); } } painter->drawRect(0, 0, w, h); painter->setPen(pen); - painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); + painter->drawText(0, 0, w, h, Qt::AlignCenter, text, -1, &rect); } /* if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); if(rect.height()>maxCell.height()) { @@ -273,9 +280,9 @@ KDateTable::keyPressEvent( QKeyEvent *e ) void KDateTable::viewportResizeEvent(QResizeEvent * e) { - QGridView::viewportResizeEvent(e); + Q3GridView::viewportResizeEvent(e); setCellWidth(viewport()->width()/7); setCellHeight(viewport()->height()/7); } @@ -408,15 +415,15 @@ KDateTable::getDate() const void KDateTable::focusInEvent( QFocusEvent *e ) { repaintContents(false); - QGridView::focusInEvent( e ); + Q3GridView::focusInEvent( e ); } void KDateTable::focusOutEvent( QFocusEvent *e ) { repaintContents(false); - QGridView::focusOutEvent( e ); + Q3GridView::focusOutEvent( e ); } QSize KDateTable::sizeHint() const @@ -431,9 +438,9 @@ KDateTable::sizeHint() const } KDateInternalMonthPicker::KDateInternalMonthPicker (QWidget* parent, const char* name) - : QGridView(parent, name), + : Q3GridView(parent, name), result(0) // invalid { QRect rect; QFont font; @@ -450,15 +457,15 @@ KDateInternalMonthPicker::KDateInternalMonthPicker font.setPointSize(fontsize+add); setFont(font); setHScrollBarMode(AlwaysOff); setVScrollBarMode(AlwaysOff); - setFrameStyle(QFrame::NoFrame); + setFrameStyle(Q3Frame::NoFrame); setNumRows(4); setNumCols(3); // enable to find drawing failures: // setTableFlags(Tbl_clipCellPainting); #if 0 - viewport()->setEraseColor(lightGray); // for consistency with the datepicker + viewport()->setEraseColor(Qt::lightGray); // for consistency with the datepicker #endif // ----- find the preferred size // (this is slow, possibly, but unfortunatly it is needed here): QFontMetrics metrics(font); @@ -486,9 +493,9 @@ KDateInternalMonthPicker::getResult() const void KDateInternalMonthPicker::setupPainter(QPainter *p) { - p->setPen(black); + p->setPen(Qt::black); } void KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) @@ -504,17 +511,17 @@ KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) QString text; // ----- find the number of the cell: index=3*row+col+1; text=KGlobal::locale()->monthName(index, false); - painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); + painter->drawText(0, 0, cellWidth(), cellHeight(), Qt::AlignCenter, text); if ( activeCol == col && activeRow == row ) painter->drawRect( 0, 0, cellWidth(), cellHeight() ); } void KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) { - if(!isEnabled() || e->button() != LeftButton) + if(!isEnabled() || e->button() != Qt::LeftButton) { KNotifyClient::beep(); return; } @@ -539,9 +546,9 @@ KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) void KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) { - if (e->state() & LeftButton) + if (e->state() & Qt::LeftButton) { int row, col; QPoint mouseCoord; // ----- @@ -613,9 +620,9 @@ KDateInternalYearSelector::KDateInternalYearSelector font=KGlobalSettings::generalFont(); font.setPointSize(fontsize); setFont(font); #if 0 - setFrameStyle(QFrame::NoFrame); + setFrameStyle(Q3Frame::NoFrame); #endif // we have to respect the limits of QDate here, I fear: val->setRange(0, 8000); setValidator(val); @@ -660,20 +667,20 @@ KDateInternalYearSelector::setYear(int year) setText(temp); } KPopupFrame::KPopupFrame(QWidget* parent, const char* name) - : QFrame(parent, name, WType_Popup), + : Q3Frame(parent, name, Qt::WType_Popup), result(0), // rejected main(0) { - setFrameStyle(QFrame::Box|QFrame::Raised); + setFrameStyle(Q3Frame::Box|Q3Frame::Raised); setMidLineWidth(2); } void KPopupFrame::keyPressEvent(QKeyEvent* e) { - if(e->key()==Key_Escape) + if(e->key()==Qt::Key_Escape) { result=0; // rejected qApp->exit_loop(); } @@ -755,9 +762,9 @@ void KDateTable::virtual_hook( int, void* ) KDateInternalWeekPicker::KDateInternalWeekPicker (QWidget* parent, const char* name) - : QGridView(parent, name), + : Q3GridView(parent, name), result(0) // invalid { QRect rect; QFont font; @@ -772,9 +779,9 @@ KDateInternalWeekPicker::KDateInternalWeekPicker font.setPointSize(fontsize+add); setFont(font); setHScrollBarMode(AlwaysOff); setVScrollBarMode(AlwaysOff); - setFrameStyle(QFrame::NoFrame); + setFrameStyle(Q3Frame::NoFrame); if ( QApplication::desktop()->height() > 240 ) { setNumRows(13); setNumCols(4); } else { @@ -783,9 +790,9 @@ KDateInternalWeekPicker::KDateInternalWeekPicker } // enable to find drawing failures: // setTableFlags(Tbl_clipCellPainting); #if 0 - viewport()->setEraseColor(lightGray); // for consistency with the datepicker + viewport()->setEraseColor(Qt::lightGray); // for consistency with the datepicker #endif // ----- find the preferred size // (this is slow, possibly, but unfortunatly it is needed here): QFontMetrics metrics(font); @@ -817,9 +824,9 @@ KDateInternalWeekPicker::getResult() const void KDateInternalWeekPicker::setupPainter(QPainter *p) { - p->setPen(black); + p->setPen(Qt::black); } void KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) @@ -835,17 +842,17 @@ KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) QString text; // ----- find the number of the cell: index=numCols()*row+col+1; text=QString::number( index ); - painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); + painter->drawText(0, 0, cellWidth(), cellHeight(), Qt::AlignCenter, text); if ( activeCol == col && activeRow == row ) painter->drawRect( 0, 0, cellWidth(), cellHeight() ); } void KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) { - if(!isEnabled() || e->button() != LeftButton) + if(!isEnabled() || e->button() != Qt::LeftButton) { KNotifyClient::beep(); return; } @@ -870,9 +877,9 @@ KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) void KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) { - if (e->state() & LeftButton) + if (e->state() & Qt::LeftButton) { int row, col; QPoint mouseCoord; // ----- |