summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-20 16:15:56 (UTC)
committer zautrix <zautrix>2005-03-20 16:15:56 (UTC)
commita9e08041c8978d52cfcabc84f579784af45eb8d9 (patch) (side-by-side diff)
tree6448348326db4325938679350c58d87176d90771
parent69d75020eea5f95b9f5d77d97ed85ec8869d32db (diff)
downloadkdepimpi-a9e08041c8978d52cfcabc84f579784af45eb8d9.zip
kdepimpi-a9e08041c8978d52cfcabc84f579784af45eb8d9.tar.gz
kdepimpi-a9e08041c8978d52cfcabc84f579784af45eb8d9.tar.bz2
layout fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp121
-rw-r--r--korganizer/kodaymatrix.h2
2 files changed, 92 insertions, 31 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 9181936..15a1cb4 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -619,23 +619,29 @@ void KODayMatrix::dropEvent(QDropEvent *e)
void KODayMatrix::paintEvent(QPaintEvent * pevent)
{
- if ( width() <= 0 || height() <= 0 )
+ QRect sz = frameRect();
+ if ( sz.width() <= 0 || sz.height() <= 0 )
return;
if ( mPendingUpdateBeforeRepaint ) {
updateViewTimed();
mPendingUpdateBeforeRepaint = false;
}
- if ( myPix.width() != width() || myPix.height()!=height() ) {
- myPix.resize(size() );
+ if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) {
+ myPix.resize(sz.size() );
}
QPainter p(&myPix);
p.setFont(font());
- QRect sz = frameRect();
+
int dheight = daysize.height();
int dwidth = daysize.width();
int row,col;
int selw, selh;
+ int xyOff = frameWidth();
+ int colModulo = sz.width() % 7;
+ int rowModulo = sz.height() % 6;
+ qDebug("off %d col %d row %d ",xyOff,colModulo,rowModulo );
+
bool isRTL = KOGlobals::self()->reverseLayout();
// draw background and topleft frame
@@ -667,28 +673,69 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
}
}
if ( ! skip ) {
- row = mSelStartT/7;
- col = mSelStartT -row*7;
- QColor selcol = KOPrefs::instance()->mHighlightColor;
-
- if (row == mSelEndT/7) {
- // Single row selection
- p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth,
- row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol);
- } else {
- // draw first row to the right
- p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth,
- dheight, selcol);
- // draw full block till last line
- selh = mSelEndT/7-row;
- if (selh > 1) {
- p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol);
- }
- // draw last block from left to mSelEndT
- selw = mSelEndT-7*(mSelEndT/7)+1;
- p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
- selw*dwidth, dheight, selcol);
- }
+ row = mSelStartT/7;
+ col = mSelStartT -row*7;
+ QColor selcol = KOPrefs::instance()->mHighlightColor;
+
+
+
+ int addCol = 0;
+ int addRow = 0;
+#if 0
+ if ( colModulo ) {
+ if ( col >= 7 - colModulo )
+ addCol = col - 7 + colModulo;
+ }
+ if ( rowModulo ) {
+ if ( row >= 6 - rowModulo )
+ addRow = row - 5 + rowModulo;
+ }
+#endif
+
+
+
+
+
+ if (row == mSelEndT/7) {
+ if ( rowModulo ) {
+ if ( row >= 6 - rowModulo )
+ addRow = row - 5 + rowModulo;
+ }
+ if ( colModulo ) {
+ if ( mSelEndT-mSelStartT+1 >= 7 - colModulo )
+ addCol = mSelEndT-mSelStartT+1 - 7 + colModulo;
+ }
+ // Single row selection
+ if ( row == 0)
+ addRow = 1;
+ p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1,
+ row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
+ } else {
+ // draw first row to the right
+ if ( row == 0)
+ addRow = 1;
+ p.fillRect(isRTL ? 0 : col*dwidth+1, row*dheight+addRow, (7-col)*dwidth+colModulo,
+ dheight, selcol);
+ // draw full block till last line
+ selh = mSelEndT/7-row;
+ if (selh > 1) {
+ p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight,selcol);
+ }
+ // draw last block from left to mSelEndT
+ selw = mSelEndT-7*(mSelEndT/7)+1;
+ //qDebug("esl %d ",selw );
+ int add = 0;
+ if ( colModulo ) {
+ add = 7 - colModulo;
+ if ( selw > add )
+ add = selw - add;
+ else
+ add = 0;
+ }
+ //qDebug("add %d ", add);
+ p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight,
+ selw*dwidth+add, dheight, selcol);
+ }
}
}
@@ -769,7 +816,19 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
;//p.setPen(mSelectedDaysColor);
}
- p.drawText(col*dwidth, row*dheight, dwidth, dheight,
+ int addCol = 0;
+ int addRow = 0;
+ if ( colModulo ) {
+ if ( col >= 7 - colModulo )
+ addCol = col - 7 + colModulo;
+ }
+ if ( rowModulo ) {
+ if ( row >= 6 - rowModulo )
+ addRow = row - 5 + rowModulo;
+ }
+ //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
+ ++addCol;++addCol;
+ p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
// reset color to actual color
@@ -783,7 +842,9 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
p.setFont(myFont);
}
}
- bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
+ int off = xyOff;
+ bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP);
+ //qDebug("ffffffffff %d ", off);
}
// ----------------------------------------------------------------------------
@@ -801,8 +862,8 @@ QSize KODayMatrix::sizeHint() const
{
QFontMetrics fm ( font() );
- int wid = fm.width( "30") *7+7;
- int hei = fm.height() * 6+4;
+ int wid = fm.width( "30") *7+3;
+ int hei = fm.height() * 6+3;
//qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
return QSize ( wid, hei );
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index 39946de..f4016b6 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -171,7 +171,7 @@ public:
bool isEndOfMonth() const { return today>=27; } ;
QString getWhatsThisText( QPoint ) ;
QSize sizeHint() const;
-
+ QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);}
public slots:
/** Recalculates all the flags of the days in the matrix like holidays or events
* on a day (Actually calls above method with the actual startdate).