summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-20 20:24:06 (UTC)
committer zautrix <zautrix>2005-03-20 20:24:06 (UTC)
commitb32c8de5dcd6c4f8dce9415fb686970e2c991ebb (patch) (side-by-side diff)
treeee5ba00bcc830d011a816981fd20dcf781b9cbf5
parent64068741e3b82a34c1b8a67da412ac88841b640c (diff)
downloadkdepimpi-b32c8de5dcd6c4f8dce9415fb686970e2c991ebb.zip
kdepimpi-b32c8de5dcd6c4f8dce9415fb686970e2c991ebb.tar.gz
kdepimpi-b32c8de5dcd6c4f8dce9415fb686970e2c991ebb.tar.bz2
nf
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index f864022..ae0a051 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -422,50 +422,60 @@ void KODayMatrix::updateEvents()
events[ i ] = numEvents;
}
}
const QDate& KODayMatrix::getDate(int offset)
{
if (offset < 0 || offset > NUMDAYS-1) {
qDebug("Wrong offset2 ");
return days[0];
}
return days[offset];
}
QString KODayMatrix::getHolidayLabel(int offset)
{
if (offset < 0 || offset > NUMDAYS-1) {
qDebug("Wrong offset1 ");
return 0;
}
return mHolidays[offset];
}
int KODayMatrix::getDayIndexFrom(int x, int y)
{
+ int colModulo = (width()-2) % 7;
+ int rowModulo = (height()-2) % 6;
+#if 0
return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
6 - x/daysize.width() : x/daysize.width());
+#endif
+ int xVal = (x-colModulo/2-2)/daysize.width();
+ int yVal = (y-rowModulo/2-2)/daysize.height();
+
+
+ return 7*(yVal) + xVal;
+
}
// ----------------------------------------------------------------------------
// M O U S E E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::mousePressEvent (QMouseEvent* e)
{
if ( e->button() == LeftButton )
mouseDown = true;
mSelStart = getDayIndexFrom(e->x(), e->y());
if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
mSelInit = mSelStart;
mSelEnd = mSelStart;
repaint(false);
}
void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
{
if ( e->button() == LeftButton )
if ( ! mouseDown ) {
return;
}
@@ -621,49 +631,49 @@ void KODayMatrix::dropEvent(QDropEvent *e)
void KODayMatrix::paintEvent(QPaintEvent * pevent)
{
QRect sz = frameRect();
if ( sz.width() <= 0 || sz.height() <= 0 )
return;
if ( mPendingUpdateBeforeRepaint ) {
updateViewTimed();
mPendingUpdateBeforeRepaint = false;
}
if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) {
myPix.resize(sz.size() );
}
QPainter p(&myPix);
p.setFont(font());
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("col %d row %d ",colModulo,rowModulo );
+ //qDebug("col %d row %d ",colModulo,rowModulo );
bool isRTL = KOGlobals::self()->reverseLayout();
// draw background and topleft frame
p.fillRect(pevent->rect(), mDefaultBackColor);
p.setPen(mDefaultTextColor);
p.drawRect(0, 0, sz.width()+1, sz.height()+1);
int mSelStartT = mSelStart;
int mSelEndT = mSelEnd;
if ( mSelEndT >= NUMDAYS )
mSelEndT = NUMDAYS-1;
// draw selected days with highlighted background color
if (mSelStart != NOSELECTION) {
bool skip = false;
if ( ! mouseDown ) {
int mo = days[20].month();
//qDebug("-- %d %d ", mSelStartT, mSelEndT);
//qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) {
skip = true;
} else {
if ( days[mSelStartT].month() != mo ) {
int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
mSelStartT += add +1;