summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.cpp
authorzautrix <zautrix>2005-04-04 21:50:29 (UTC)
committer zautrix <zautrix>2005-04-04 21:50:29 (UTC)
commit768858848f466a726e2f50b777345976828cc2ff (patch) (side-by-side diff)
tree49351537d5038f4f5e22bcde2205bbabf0dbdb22 /korganizer/kodaymatrix.cpp
parentc408fcb55de18d1e3e1d20803c3885e3074cfaa4 (diff)
downloadkdepimpi-768858848f466a726e2f50b777345976828cc2ff.zip
kdepimpi-768858848f466a726e2f50b777345976828cc2ff.tar.gz
kdepimpi-768858848f466a726e2f50b777345976828cc2ff.tar.bz2
fixes
Diffstat (limited to 'korganizer/kodaymatrix.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 8affe50..c7e1b45 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -89,56 +89,59 @@ void DynamicTip::maybeTip( const QPoint &pos )
// col << "][" << row << "] => " <<(col+row*7) << endl;
//show holiday names only
QString str = matrix->getHolidayLabel(col+row*7);
if (str.isEmpty()) return;
tip(rct, str);
}
// ============================================================================
// K O D A Y M A T R I X
// ============================================================================
const int KODayMatrix::NOSELECTION = -1000;
const int KODayMatrix::NUMDAYS = 42;
KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
: QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 )
#if 0
KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
QFrame(parent, name)
#endif
{
+ oldW = 0;
+ oldH = 0;
+ myPix.resize( 150, 120 );
mRedrawNeeded = true;
mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
mPendingUpdateBeforeRepaint = false;
mouseDown = false;
// initialize dynamic arrays
bDays.resize ( NUMDAYS );
- hDays.resize ( NUMDAYS );;
- eDays.resize ( NUMDAYS );;
+ hDays.resize ( NUMDAYS );
+ eDays.resize ( NUMDAYS );
days = new QDate[NUMDAYS];
daylbls = new QString[NUMDAYS];
//events = new int[NUMDAYS];
mToolTip = new DynamicTip(this);
// set default values used for drawing the matrix
mDefaultBackColor = palette().active().base();
mDefaultTextColor = palette().active().foreground();
mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
mSelectedDaysColor = QColor("white");
mTodayMarginWidth = 2;
mSelEnd = mSelStart = NOSELECTION;
setAcceptDrops(true);
//setFont( QFont("Arial", 10) );
mUpdateTimer = new QTimer( this );
connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
mRepaintTimer = new QTimer( this );
connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
mDayChanged = false;
updateView();
}
@@ -314,48 +317,52 @@ void KODayMatrix::clearSelection()
void KODayMatrix::recalculateToday()
{
today = -1;
for (int i=0; i<NUMDAYS; i++) {
//events[i] = 0;
days[i] = startdate.addDays(i);
daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
// if today is in the currently displayed month, hilight today
if (days[i].year() == QDate::currentDate().year() &&
days[i].month() == QDate::currentDate().month() &&
days[i].day() == QDate::currentDate().day()) {
today = i;
}
}
// qDebug(QString("Today is visible at %1.").arg(today));
}
void KODayMatrix::updateView()
{
updateView(startdate);
}
void KODayMatrix::repaintViewTimed()
{
+ mRedrawNeeded = true;
+ bDays.fill( false);
+ hDays.fill( false);
+ eDays.fill( false);
mRepaintTimer->stop();
repaint(false);
}
void KODayMatrix::updateViewTimed()
{
mUpdateTimer->stop();
if ( !mCalendar ) {
qDebug("NOT CAL ");
return;
}
//qDebug("KODayMatrix::updateViewTimed ");
for(int i = 0; i < NUMDAYS; i++) {
// if events are set for the day then remember to draw it bold
QPtrList<Event> eventlist = mCalendar->events(days[i]);
Event *event;
int numEvents = eventlist.count();
QString holiStr = "";
bDays.clearBit(i);
hDays.clearBit(i);
eDays.clearBit(i);
for(event=eventlist.first();event != 0;event=eventlist.next()) {
ushort recurType = event->recurrence()->doesRecur();
if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
(recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
@@ -662,52 +669,64 @@ void KODayMatrix::dropEvent(QDropEvent *e)
event->setDtEnd(end);
mCalendar->addEvent(event);
emit eventDropped(event);
} else {
// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
e->ignore();
}
#endif
}
// ----------------------------------------------------------------------------
// P A I N T E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::paintEvent(QPaintEvent * pevent)
{
if ( width() <= 0 || height() <= 0 )
return;
if ( mPendingUpdateBeforeRepaint ) {
updateViewTimed();
mPendingUpdateBeforeRepaint = false;
}
+#if 0
if ( myPix.width() != width() || myPix.height()!=height() ) {
myPix.resize(size() );
mRedrawNeeded = true;
}
+#endif
+ if ( oldW != width() || oldH !=height() )
+ mRedrawNeeded = true;
+
+ oldH = height() ;
+ oldW = width();
+ if ( myPix.width() < width() || myPix.height() < height() ) {
+ myPix.resize(size() );
+ mRedrawNeeded = true;
+
+ }
if ( mRedrawNeeded ) {
//qDebug("REDRAW ");
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 = (width()-2) % 7;
int rowModulo = (height()-2) % 6;
//qDebug("col %d row %d ",colModulo,rowModulo );
bool isRTL = KOGlobals::self()->reverseLayout();
// draw background and topleft frame
p.fillRect(0,0,width(),height(), mDefaultBackColor);
p.setPen(mDefaultTextColor);
p.drawRect(0, 0, width(), height());
int mSelStartT = mSelStart;
int mSelEndT = mSelEnd;
@@ -926,49 +945,50 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
if ( row >= 6 - rowModulo )
addRow = row - 5 + rowModulo;
}
//qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
++addCol;//++addCol;
if ( row == 0)
addRow = 1;
p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
// reset color to actual color
if (!mHolidays[i].isNull()) {
p.setPen(actcol);
}
// reset bold font to plain font
if ( eDays.testBit(i)) {
QFont myFont = font();
myFont.setBold(false);
p.setFont(myFont);
}
}
} else {
//qDebug("NO redraw ");
}
- bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
+
+ bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP);
mRedrawNeeded = false;
}
// ----------------------------------------------------------------------------
// R E SI Z E E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::resizeEvent(QResizeEvent *)
{
QRect sz = frameRect();
daysize.setHeight(sz.height()*7 / NUMDAYS);
daysize.setWidth(sz.width() / 7);
}
QSize KODayMatrix::sizeHint() const
{
QFontMetrics fm ( font() );
int wid = fm.width( "30") *7+3;
int hei = fm.height() * 6+3;
//qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
return QSize ( wid, hei );
}