summaryrefslogtreecommitdiffabout
path: root/microkde/kdatetbl.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdatetbl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.cpp99
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 @@
#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>
@@ -69,7 +77,7 @@ KDateValidator::date(const QString& text, QDate& d) const
d = tmp;
return Acceptable;
} else
- return Valid;
+ return QValidator::Intermediate;
}
void
@@ -78,22 +86,22 @@ 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
@@ -108,7 +116,7 @@ KDateTable::paintCell(QPainter *painter, int row, int col)
int w=cellWidth();
int h=cellHeight();
int pos;
- QBrush brushBlue(blue);
+ QBrush brushBlue(Qt::blue);
QBrush brushLightblue(QColor(220,245,255));
QFont _font=font();
// -----
@@ -133,18 +141,17 @@ 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);
@@ -161,33 +168,33 @@ KDateTable::paintCell(QPainter *painter, int row, int col)
} 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));
@@ -195,7 +202,7 @@ KDateTable::paintCell(QPainter *painter, int row, int col)
}
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());
@@ -274,7 +281,7 @@ KDateTable::keyPressEvent( QKeyEvent *e )
void
KDateTable::viewportResizeEvent(QResizeEvent * e)
{
- QGridView::viewportResizeEvent(e);
+ Q3GridView::viewportResizeEvent(e);
setCellWidth(viewport()->width()/7);
setCellHeight(viewport()->height()/7);
@@ -409,13 +416,13 @@ 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
@@ -432,7 +439,7 @@ KDateTable::sizeHint() const
KDateInternalMonthPicker::KDateInternalMonthPicker
(QWidget* parent, const char* name)
- : QGridView(parent, name),
+ : Q3GridView(parent, name),
result(0) // invalid
{
QRect rect;
@@ -451,13 +458,13 @@ KDateInternalMonthPicker::KDateInternalMonthPicker
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):
@@ -487,7 +494,7 @@ KDateInternalMonthPicker::getResult() const
void
KDateInternalMonthPicker::setupPainter(QPainter *p)
{
- p->setPen(black);
+ p->setPen(Qt::black);
}
void
@@ -505,7 +512,7 @@ KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
// ----- 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() );
}
@@ -513,7 +520,7 @@ KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
void
KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
{
- if(!isEnabled() || e->button() != LeftButton)
+ if(!isEnabled() || e->button() != Qt::LeftButton)
{
KNotifyClient::beep();
return;
@@ -540,7 +547,7 @@ KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
void
KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e)
{
- if (e->state() & LeftButton)
+ if (e->state() & Qt::LeftButton)
{
int row, col;
QPoint mouseCoord;
@@ -614,7 +621,7 @@ KDateInternalYearSelector::KDateInternalYearSelector
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);
@@ -661,18 +668,18 @@ KDateInternalYearSelector::setYear(int year)
}
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();
@@ -756,7 +763,7 @@ void KDateTable::virtual_hook( int, void* )
KDateInternalWeekPicker::KDateInternalWeekPicker
(QWidget* parent, const char* name)
- : QGridView(parent, name),
+ : Q3GridView(parent, name),
result(0) // invalid
{
QRect rect;
@@ -773,7 +780,7 @@ KDateInternalWeekPicker::KDateInternalWeekPicker
setFont(font);
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
- setFrameStyle(QFrame::NoFrame);
+ setFrameStyle(Q3Frame::NoFrame);
if ( QApplication::desktop()->height() > 240 ) {
setNumRows(13);
setNumCols(4);
@@ -784,7 +791,7 @@ 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):
@@ -818,7 +825,7 @@ KDateInternalWeekPicker::getResult() const
void
KDateInternalWeekPicker::setupPainter(QPainter *p)
{
- p->setPen(black);
+ p->setPen(Qt::black);
}
void
@@ -836,7 +843,7 @@ KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
// ----- 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() );
}
@@ -844,7 +851,7 @@ KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
void
KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
{
- if(!isEnabled() || e->button() != LeftButton)
+ if(!isEnabled() || e->button() != Qt::LeftButton)
{
KNotifyClient::beep();
return;
@@ -871,7 +878,7 @@ KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
void
KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e)
{
- if (e->state() & LeftButton)
+ if (e->state() & Qt::LeftButton)
{
int row, col;
QPoint mouseCoord;