-rw-r--r-- | korganizer/kodaymatrix.cpp | 30 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 2 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 17 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 4 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 1 |
6 files changed, 39 insertions, 21 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index ca896b5..549ef2a 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -199,69 +199,62 @@ void KODayMatrix::recalculateToday() // 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() { - qDebug("KODayMatrix::repaintViewTimed "); mRepaintTimer->stop(); repaint(false); } void KODayMatrix::updateViewTimed() { mUpdateTimer->stop(); - qDebug("KODayMatrix::updateView(QDate actdate)"); 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 = ""; 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)) { numEvents--; } + if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { + if ( !holiStr.isEmpty() ) + holiStr += "\n"; + holiStr += event->summary(); + } } events[i] = numEvents; - //if it is a holy day then draw it red. Sundays are consider holidays, too -#ifndef KORG_NOPLUGINS - QString holiStr = KOCore::self()->holiday(days[i]); -#else - QString holiStr = QString::null; -#endif if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || !holiStr.isEmpty()) { - if (holiStr.isNull()) holiStr = ""; mHolidays[i] = holiStr; - } else { mHolidays[i] = QString::null; } } if ( ! mPendingUpdateBeforeRepaint ) repaint(false); } void KODayMatrix::updateView(QDate actdate) { if ( ! actdate.isValid() ) { //qDebug("date not valid "); return; } mDayChanged = false; //flag to indicate if the starting day of the matrix has changed by this call @@ -275,33 +268,33 @@ void KODayMatrix::updateView(QDate actdate) //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; // shift selection if new one would be visible at least partly ! if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { // nested if is required for next X display pushed from a different month - correction required // otherwise, for month forward and backward, it must be avoided if( mSelStart > NUMDAYS || mSelStart < 0 ) mSelStart = mSelStart + tmp; if( mSelEnd > NUMDAYS || mSelEnd < 0 ) mSelEnd = mSelEnd + tmp; } } startdate = actdate; mDayChanged = true; recalculateToday(); } - qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); + //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); if ( !isVisible() ) { mPendingUpdateBeforeRepaint = true; } else { #ifdef DESKTOP_VERSION //mRepaintTimer->start( 250 ); mUpdateTimer->start( 250 ); #else mRepaintTimer->start( 350 ); mUpdateTimer->start( 2000 ); #endif } } const QDate& KODayMatrix::getDate(int offset) { if (offset < 0 || offset > NUMDAYS-1) { @@ -474,38 +467,42 @@ void KODayMatrix::dropEvent(QDropEvent *e) 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) { -//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; + if ( width() <= 0 || height() <= 0 ) + return; if ( mPendingUpdateBeforeRepaint ) { updateViewTimed(); mPendingUpdateBeforeRepaint = false; } - QPainter p(this); + if ( myPix.width() != width() || myPix.height()!=height() ) { + myPix.resize(size() ); + } + QPainter p(&myPix); QRect sz = frameRect(); int dheight = daysize.height(); int dwidth = daysize.width(); int row,col; int selw, selh; 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); // draw selected days with highlighted background color if (mSelStart != NOSELECTION) { @@ -603,28 +600,29 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) } p.drawText(col*dwidth, row*dheight, 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 (events[i] > 0) { QFont myFont = font(); myFont.setBold(false); p.setFont(myFont); } } + bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); } // ---------------------------------------------------------------------------- // 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); } diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index ac2f59c..2dd112a 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h @@ -18,32 +18,33 @@ As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef _KODAYMAT_H #define _KODAYMAT_H #include <libkcal/calendar.h> #include <qstring.h> #include <qframe.h> #include <qcolor.h> #include <qpen.h> #include <qdatetime.h> #include <qtooltip.h> +#include <qpixmap.h> #include <qmap.h> class QDragEnterEvent; class QDragMoveEvent; class QDragLeaveEvent; class QDropEvent; class KODayMatrix; using namespace KCal; /** * small helper class to dynamically show tooltips inside the day matrix. * This class asks the day matrix object for a appropriate label which @@ -208,32 +209,33 @@ protected: void mouseReleaseEvent (QMouseEvent* e); void mouseMoveEvent (QMouseEvent* e); void dragEnterEvent(QDragEnterEvent *); void dragMoveEvent(QDragMoveEvent *); void dragLeaveEvent(QDragLeaveEvent *); void dropEvent(QDropEvent *); void resizeEvent(QResizeEvent *); private: + QPixmap myPix; QTimer* mUpdateTimer; QTimer* mRepaintTimer; bool mDayChanged; bool mPendingUpdateBeforeRepaint; /** returns the index of the day located at the matrix's widget (x,y) position. * * @param x horizontal coordinate * @param y vertical coordinate */ int getDayIndexFrom(int x, int y); /** calculates a "shaded" color from the supplied color object. * (Copied from Cornelius's kdpdatebutton.cpp) * * @param color source based on which a shaded color should be calculated. diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 4cff23a..6411156 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -963,34 +963,34 @@ void KOMonthView::showEvents(QPtrList<Event>) { qDebug("KOMonthView::selectEvents is not implemented yet. "); } void KOMonthView::changeEventDisplay(Event *, int) { // this should be re-written to be much more efficient, but this // quick-and-dirty-hack gets the job done for right now. updateView(); } void KOMonthView::updateView() { if ( !updatePossible ) return; - QTime ti; - ti.start(); + //QTime ti; + //ti.start(); #if 1 int i; for( i = 0; i < mCells.count(); ++i ) { mCells[i]->startUpdateCell(); } QPtrList<Event> events = calendar()->events(); Event *event; QDateTime dt; bool ok; int timeSpan = mCells.size()-1; QDate endDate = mStartDate.addDays( timeSpan ); for( event = events.first(); event; event = events.next() ) { // for event if ( event->doesRecur() ) { bool last; QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); @@ -1067,33 +1067,33 @@ void KOMonthView::updateView() #else // old code //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); int i; for( i = 0; i < mCells.count(); ++i ) { mCells[i]->updateCell(); } //qDebug("KOMonthView::updateView() "); processSelectionChange(); // qDebug("---------------------------------------------------------------------+ "); mCells[0]->setFocus(); #endif - qDebug("update time %d ", ti.elapsed()); + //qDebug("update time %d ", ti.elapsed()); } void KOMonthView::resizeEvent(QResizeEvent * e) { computeLayout(); mCells[0]->setFocus(); } void KOMonthView::computeLayout() { // select the appropriate heading string size. E.g. "Wednesday" or "Wed". // note this only changes the text if the requested size crosses the // threshold between big enough to support the full name and not big // enough. int daysToShow = 7; bool combinedSatSun = false; diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 82437d8..99402c4 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -196,33 +196,37 @@ void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) if (i) { // if the user clicked into the root decoration of the item, don't // try to start a drag! if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() || p.x() < header()->sectionPos(header()->mapToIndex(0))) { if (e->button()==Qt::LeftButton) { mPressPos = e->pos(); mMousePressed = true; } } } #endif QListView::contentsMousePressEvent(e); } - +void KOTodoListView::paintEvent(QPaintEvent* e) +{ + emit paintNeeded(); + QListView::paintEvent( e); +} void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) { #ifndef KORG_NODND QListView::contentsMouseMoveEvent(e); if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { mMousePressed = false; QListViewItem *item = itemAt(contentsToViewport(mPressPos)); if (item) { DndFactory factory( mCalendar ); ICalDrag *vd = factory.createDrag( ((KOTodoViewItem *)item)->todo(),viewport()); internalDrop = false; // we cannot do any senseful here, because the DnD is still broken in Qt if (vd->drag()) { @@ -488,32 +492,34 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : */ connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, const QPoint &,int ) ), SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), SLOT( itemClicked( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), SLOT( itemDoubleClicked( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), SLOT( updateView() ) ); connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), SLOT( todoModified(Todo *, int) ) ); connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), SLOT( itemStateChanged( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), SLOT( itemStateChanged( QListViewItem * ) ) ); + connect( mTodoListView, SIGNAL( paintNeeded() ), + SLOT( paintNeeded()) ); #if 0 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); #endif connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); connect( mTodoListView, SIGNAL(selectionChanged() ), SLOT( processSelectionChange() ) ); @@ -521,41 +527,48 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : SLOT( addQuickTodo() ) ); } KOTodoView::~KOTodoView() { delete mDocPrefs; } void KOTodoView::jumpToDate () { // if (mActiveItem) { // mActiveItem->todo()); // if ( mActiveItem->todo()->hasDueDate() ) // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); } +void KOTodoView::paintNeeded() +{ + if ( mPendingUpdateBeforeRepaint ) { + updateView(); + mPendingUpdateBeforeRepaint = false; + } +} void KOTodoView::paintEvent(QPaintEvent * pevent) { if ( mPendingUpdateBeforeRepaint ) { updateView(); mPendingUpdateBeforeRepaint = false; } KOrg::BaseView::paintEvent( pevent); } - bool mPendingUpdateBeforeRepaint; + void KOTodoView::updateView() { pendingSubtodo = 0; if ( mBlockUpdate ) { return; } if ( !isVisible() ) { mPendingUpdateBeforeRepaint = true; return; } //qDebug("KOTodoView::updateView() %x", this); if ( isFlatDisplay ) { setAllFlat(); return; } //qDebug("update "); diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 16bc133..2a9e737 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -47,49 +47,51 @@ class QDragEnterEvent; class QDragMoveEvent; class QDragLeaveEvent; class QDropEvent; class DocPrefs; class KOTodoListView : public KListView { Q_OBJECT public: KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); virtual ~KOTodoListView() {} signals: + void paintNeeded(); void todoDropped(Todo *, int); void double_Clicked(QListViewItem *item); void reparentTodoSignal( Todo *,Todo * ); void unparentTodoSignal(Todo *); void deleteTodo( Todo * ); protected: void contentsDragEnterEvent(QDragEnterEvent *); void contentsDragMoveEvent(QDragMoveEvent *); void contentsDragLeaveEvent(QDragLeaveEvent *); void contentsDropEvent(QDropEvent *); void contentsMousePressEvent(QMouseEvent *); void contentsMouseMoveEvent(QMouseEvent *); void contentsMouseReleaseEvent(QMouseEvent *); void contentsMouseDoubleClickEvent(QMouseEvent *); private: + void paintEvent(QPaintEvent * pevent); bool internalDrop; QString mName; Calendar *mCalendar; QPoint mPressPos; bool mMousePressed; QListViewItem *mOldCurrent; void keyPressEvent ( QKeyEvent * ) ; }; /** This is the line-edit on top of the todoview for fast addition of new todos */ class KOQuickTodo : public QLineEdit { public: @@ -185,47 +187,49 @@ class KOTodoView : public KOrg::BaseView void unparentTodoSignal(Todo *); void reparentTodoSignal( Todo *,Todo * ); void showTodoSignal(Todo *); void editTodoSignal(Todo *); void deleteTodoSignal(Todo *); void todoModifiedSignal (Todo *, int); void isModified(bool); void cloneTodoSignal( Incidence * ); void cancelTodoSignal( Incidence * ); void moveTodoSignal( Incidence * ); void beamTodoSignal( Incidence * ); void purgeCompletedSignal(); protected slots: + void paintNeeded(); void processSelectionChange(); void addQuickTodo(); void setTodoModified( Todo* ); void todoModified(Todo *, int ); private: /* * the TodoEditor approach is rather unscaling in the long * run. * Korganizer keeps it in memory and we need to update * 1. make KOTodoViewItem a QObject again? * 2. add a public method for setting one todo modified? * 3. add a private method for setting a todo modified + friend here? * -- zecke 2002-07-08 */ + friend class KOTodoListView; void paintEvent(QPaintEvent * pevent); bool mPendingUpdateBeforeRepaint; friend class KOTodoViewItem; QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); void restoreItemState( QListViewItem * ); bool checkTodo( Todo * ); bool isFlatDisplay; void setOpen( QListViewItem*, bool setOpen); KOTodoListView *mTodoListView; QPopupMenu *mItemPopupMenu; QPopupMenu *mPopupMenu; QPopupMenu *mPriorityPopupMenu; QPopupMenu *mPercentageCompletedPopupMenu; QPopupMenu *mCategoryPopupMenu; diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 30f5fb1..188ad23 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -591,32 +591,33 @@ void KOViewManager::showTodoView() } void KOViewManager::showJournalView() { //mFlagShowNextxDays = false; if (!mJournalView) { mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::JournalView"); connect( mMainView, SIGNAL( configChanged() ), mJournalView, SLOT( updateConfig() ) ); connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); addView(mJournalView); } showView(mJournalView); + mMainView->dateNavigator()->selectDates( 1 ); } void KOViewManager::showTimeSpanView() { //mFlagShowNextxDays = false; if (!mTimeSpanView) { mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::TimeSpanView"); addView(mTimeSpanView); mTimeSpanView->readSettings(); } showView(mTimeSpanView); } |