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.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 2d97c8c..4271b55 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -765,104 +765,109 @@ void KDateTable::virtual_hook( int, void* )
//#include "kdatetbl.moc"
KDateInternalWeekPicker::KDateInternalWeekPicker
(QWidget* parent, const char* name)
: QGridView(parent, name),
result(0) // invalid
{
QRect rect;
QFont font;
// -----
activeCol = -1;
activeRow = -1;
font=KGlobalSettings::generalFont();
int fontsize = 10;
int add = 2;
if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
add += 6;
font.setPointSize(fontsize+add);
setFont(font);
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
setFrameStyle(QFrame::NoFrame);
- setNumRows(13);
- setNumCols(4);
+ if ( QApplication::desktop()->height() > 240 ) {
+ setNumRows(13);
+ setNumCols(4);
+ } else {
+ setNumRows(4);
+ setNumCols(13);
+ }
// 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*)
{
- setCellWidth(width()/4);
- setCellHeight(height()/13);
+ setCellWidth(width()/ numCols());
+ setCellHeight(height()/ numRows());
}
void
KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
{
int index;
QString text;
// ----- find the number of the cell:
- index=4*row+col+1;
+ index=numCols()*row+col+1;
text=QString::number( index );
painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
if ( activeCol == col && activeRow == row )
painter->drawRect( 0, 0, cellWidth(), cellHeight() );
}
void
KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
{
if(!isEnabled() || e->button() != LeftButton)
{
KNotifyClient::beep();
return;
}
// -----
int row, col;
QPoint mouseCoord;
// -----
mouseCoord = e->pos();
row=rowAt(mouseCoord.y());
col=columnAt(mouseCoord.x());
if(row<0 || col<0)
{ // the user clicked on the frame of the table
@@ -912,28 +917,28 @@ KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e)
}
if ( tmpRow > -1 ) // repaint the former active cell
updateCell( tmpRow, tmpCol /*, true */ );
}
}
void
KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e)
{
if(!isEnabled())
{
return;
}
// -----
int row, col, pos;
QPoint mouseCoord;
// -----
mouseCoord = e->pos();
row=rowAt(mouseCoord.y());
col=columnAt(mouseCoord.x());
if(row<0 || col<0)
{ // the user clicked on the frame of the table
emit(closeMe(0));
}
- pos=4*row+col+1;
+ pos=numCols()*row+col+1;
result=pos;
emit(closeMe(1));
}