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.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index fce0e5a..e827412 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -177,50 +177,54 @@ KDateTable::paintCell(QPainter *painter, int row, int col)
painter->setPen(red);
if(hasFocus())
{
painter->setBrush(darkRed);
pen=white;
} else {
painter->setBrush(darkGray);
pen=white;
}
} else {
if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
{
painter->setPen(green);
painter->setBrush(darkGreen);
pen=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);
}
- if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
- if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height());
+ /*
+ if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
+ if(rect.height()>maxCell.height()) {
+ maxCell.setHeight(rect.height());
+ }
+ */
}
void
KDateTable::keyPressEvent( QKeyEvent *e )
{
/*
// not working properly
if ( e->key() == Qt::Key_Prior ) {
if ( date.month() == 1 ) {
KNotifyClient::beep();
return;
}
int day = date.day();
if ( day > 27 )
while ( !QDate::isValid( date.year(), date.month()-1, day ) )
day--;
setDate(QDate(date.year(), date.month()-1, day));
return;
}
if ( e->key() == Qt::Key_Next ) {
if ( date.month() == 12 ) {
KNotifyClient::beep();
return;
}
@@ -292,51 +296,57 @@ KDateTable::viewportResizeEvent(QResizeEvent * e)
void
KDateTable::setFontSize(int size)
{
int count;
QRect rect;
// ----- store rectangles:
fontsize=size;
QFont font = KGlobalSettings::generalFont();
font.setPointSize(fontsize);
font.setBold( true );
QFontMetrics metrics(font);
// ----- find largest day name:
maxCell.setWidth(0);
maxCell.setHeight(0);
for(count=0; count<7; ++count)
{
rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
}
// ----- compare with a real wide number and add some space:
rect=metrics.boundingRect(QString::fromLatin1("88"));
maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
+#ifdef DESKTOP_VERSION
+ maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
+#else
maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
- if ( maxCell.width() * 1000 / maxCell.height() > 1900 )
+#endif
+ if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
maxCell.setHeight(maxCell.width() * 1000 / 1900 );
+ qDebug("setmax ");
+ }
}
void
KDateTable::contentsMousePressEvent(QMouseEvent *e)
{
if(e->type()!=QEvent::MouseButtonPress)
{ // the KDatePicker only reacts on mouse press events:
return;
}
if(!isEnabled())
{
KNotifyClient::beep();
return;
}
int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
// -----
int row, col, pos, temp;
QPoint mouseCoord;
// -----
mouseCoord = e->pos();
row=rowAt(mouseCoord.y());
col=columnAt(mouseCoord.x());
if(row<0 || col<0)
@@ -422,49 +432,49 @@ void KDateTable::focusOutEvent( QFocusEvent *e )
QSize
KDateTable::sizeHint() const
{
if(maxCell.height()>0 && maxCell.width()>0)
{
return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
(maxCell.height()+4)*numRows()+2*frameWidth());
} else {
return QSize(-1, -1);
}
}
KDateInternalMonthPicker::KDateInternalMonthPicker
(int fontsize, QWidget* parent, const char* name)
: QGridView(parent, name),
result(0) // invalid
{
QRect rect;
QFont font;
// -----
activeCol = -1;
activeRow = -1;
font=KGlobalSettings::generalFont();
- font.setPointSize(fontsize);
+ //font.setPointSize(fontsize);
setFont(font);
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
setFrameStyle(QFrame::NoFrame);
setNumRows(4);
setNumCols(3);
// enable to find drawing failures:
// setTableFlags(Tbl_clipCellPainting);
#if 0
viewport()->setEraseColor(lightGray); // for consistency with the datepicker
#endif
// ----- find the preferred size
// (this is slow, possibly, but unfortunatly it is needed here):
QFontMetrics metrics(font);
for(int i=1; i <= 12; ++i)
{
rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
if(max.width()<rect.width()) max.setWidth(rect.width());
if(max.height()<rect.height()) max.setHeight(rect.height());
}
}
QSize
@@ -740,70 +750,74 @@ KPopupFrame::exec(int x, int y)
{
return exec(QPoint(x, y));
}
void KPopupFrame::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
void KDateTable::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
//#include "kdatetbl.moc"
KDateInternalWeekPicker::KDateInternalWeekPicker
(int fontsize, QWidget* parent, const char* name)
: QGridView(parent, name),
result(0) // invalid
{
QRect rect;
QFont font;
// -----
activeCol = -1;
activeRow = -1;
font=KGlobalSettings::generalFont();
- font.setPointSize(fontsize);
+ //font.setPointSize(fontsize);
setFont(font);
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
setFrameStyle(QFrame::NoFrame);
setNumRows(13);
setNumCols(4);
// enable to find drawing failures:
// setTableFlags(Tbl_clipCellPainting);
#if 0
viewport()->setEraseColor(lightGray); // for consistency with the datepicker
#endif
// ----- find the preferred size
// (this is slow, possibly, but unfortunatly it is needed here):
QFontMetrics metrics(font);
for(int i=1; i <= 52; ++i)
{
rect=metrics.boundingRect(QString::number( i ));
if(max.width()<rect.width()) max.setWidth(rect.width());
if(max.height()<rect.height()) max.setHeight(rect.height());
}
-
+ if ( QApplication::desktop()->width() > 640 ) {
+
+ max.setWidth(max.width()+6);
+ max.setHeight(max.height()+8);
+ }
}
QSize
KDateInternalWeekPicker::sizeHint() const
{
return QSize((max.width()+6)*numCols()+2*frameWidth(),
(max.height()+6)*numRows()+2*frameWidth());
}
int
KDateInternalWeekPicker::getResult() const
{
return result;
}
void
KDateInternalWeekPicker::setupPainter(QPainter *p)
{
p->setPen(black);
}
void
KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
{