-rw-r--r-- | korganizer/koagendaview.cpp | 5 | ||||
-rw-r--r-- | korganizer/koeventviewer.h | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f452db0..b9909d6 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -977,379 +977,384 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) } else if ( type == KOAgenda::RESIZEBOTTOM ) { if (item->lastMultiItem()) { endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); endDt.setDate(startDate. addDays(item->lastMultiItem()->cellX() - item->cellX())); } else { endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); endDt.setDate(startDate); } } } else { // todo if (item->lastMultiItem()) { endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); endDt.setDate(startDate. addDays(item->lastMultiItem()->cellX() - item->cellX())); } else { //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); if ( item->cellYBottom() > 0 ) endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); else endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); endDt.setDate(startDate); } } } if ( item->incidence()->type() == "Event" ) { item->incidence()->setDtStart(startDt); (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); } else if ( item->incidence()->type() == "Todo" ) { Todo* to = static_cast<Todo*>(item->incidence()); to->setDtDue(endDt); if ( to->hasStartDate() ) { if (to->dtStart() >= to->dtDue() ) to->setDtStart(to->dtDue().addDays( -2 )); } } //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); item->incidence()->setRevision(item->incidence()->revision()+1); item->setItemDate(startDt.date()); //item->updateItem(); if ( item->incidence()->type() == "Todo" ) { emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); } else emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); item->updateItem(); } void KOAgendaView::showDates( const QDate &start, const QDate &end ) { // kdDebug() << "KOAgendaView::selectDates" << endl; mSelectedDates.clear(); // qDebug("KOAgendaView::showDates "); QDate d = start; while (d <= end) { mSelectedDates.append(d); d = d.addDays( 1 ); } // and update the view fillAgenda(); } void KOAgendaView::showEvents(QPtrList<Event>) { kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; } void KOAgendaView::changeEventDisplay(Event *, int) { // qDebug("KOAgendaView::changeEventDisplay "); // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; // this should be re-written to be MUCH smarter. Right now we // are just playing dumb. fillAgenda(); } void KOAgendaView::fillAgenda(const QDate &) { // qDebug("KOAgendaView::fillAgenda "); fillAgenda(); } void KOAgendaView::fillAgenda() { if ( globalFlagBlockStartup ) return; if ( globalFlagBlockAgenda == 1 ) return; + static bool onlyOne = false; + if ( onlyOne ) + return; + onlyOne = true; //if ( globalFlagBlockAgenda == 2 ) //globalFlagBlockAgenda = 0; // globalFlagBlockPainting = false; if ( globalFlagBlockAgenda == 0 ) globalFlagBlockAgenda = 1; // clearView(); //qDebug("fillAgenda()++++ "); globalFlagBlockAgendaItemPaint = 1; mAllDayAgenda->changeColumns(mSelectedDates.count()); mAgenda->changeColumns(mSelectedDates.count()); qApp->processEvents(); mEventIndicatorTop->changeColumns(mSelectedDates.count()); mEventIndicatorBottom->changeColumns(mSelectedDates.count()); setHolidayMasks(); //mAgenda->hideUnused(); //mAllDayAgenda->hideUnused(); // mAgenda->blockNextRepaint( false ); // mAgenda->viewport()->repaint(); // mAgenda->blockNextRepaint( true ); mMinY.resize(mSelectedDates.count()); mMaxY.resize(mSelectedDates.count()); QPtrList<Event> dayEvents; // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. // Therefore, gtodoset all of them. QPtrList<Todo> todos = calendar()->todos(); mAgenda->setDateList(mSelectedDates); QDate today = QDate::currentDate(); DateList::ConstIterator dit; int curCol = 0; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { QDate currentDate = *dit; // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() // << endl; dayEvents = calendar()->events(currentDate,true); // Default values, which can never be reached mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; unsigned int numEvent; for(numEvent=0;numEvent<dayEvents.count();++numEvent) { Event *event = dayEvents.at(numEvent); if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) if ( event->uid().left(15) == QString("last-syncEvent-") ) continue; // kdDebug() << " Event: " << event->summary() << endl; int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; if (event->doesFloat()) { if (event->recurrence()->doesRecur()) { mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); } else { if (beginX <= 0 && curCol == 0) { mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); } else if (beginX == curCol) { mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); } } } else if (event->isMultiDay()) { if ( event->doesRecur () ) { QDate dateit = currentDate; int count = 0; int max = event->dtStart().daysTo( event->dtEnd() ) +2; while (! event->recursOn( dateit ) && count <= max ) { ++count; dateit = dateit.addDays( -1 ); } bool ok; QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); if ( ok ) { int secs = event->dtStart().secsTo( event->dtEnd() ); QDateTime nextOcend =nextOcstart.addSecs( secs ); ; beginX = currentDate.daysTo(nextOcstart.date()) + curCol; endX = currentDate.daysTo(nextOcend.date()) + curCol; } } int startY = mAgenda->timeToY(event->dtStart().time()); int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); if ((beginX <= 0 && curCol == 0) || beginX == curCol) { //qDebug("insert!!! "); mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); } if (beginX == curCol) { mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); if (startY < mMinY[curCol]) mMinY[curCol] = startY; } else if (endX == curCol) { mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } else { mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); } } else { int startY = mAgenda->timeToY(event->dtStart().time()); int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; if (endY < startY) endY = startY; mAgenda->insertItem(event,currentDate,curCol,startY,endY); if (startY < mMinY[curCol]) mMinY[curCol] = startY; if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } } // ---------- [display Todos -------------- unsigned int numTodo; for (numTodo = 0; numTodo < todos.count(); ++numTodo) { Todo *todo = todos.at(numTodo); if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. // Already completed items can be displayed on their original due date //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; bool fillIn = false; if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) fillIn = true; if ( ! fillIn && !todo->hasCompletedDate() ) fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); if ( fillIn ) { if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue if ( KOPrefs::instance()->mShowTodoInAgenda ) mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); } else { QDateTime dt; if ( todo->hasCompletedDate() ) dt = todo->completed(); else dt = todo->dtDue();; int endY = mAgenda->timeToY(dt.time()) - 1; int hi = (18/KOPrefs::instance()->mHourSize); //qDebug("hei %d ",KOPrefs::instance()->mHourSize); int startY = endY -hi; mAgenda->insertItem(todo,currentDate,curCol,startY,endY); if (startY < mMinY[curCol]) mMinY[curCol] = startY; if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } } } // ---------- display Todos] -------------- ++curCol; } mAgenda->hideUnused(); mAllDayAgenda->hideUnused(); mAgenda->checkScrollBoundaries(); deleteSelectedDateTime(); createDayLabels(); emit incidenceSelected( 0 ); if ( globalFlagBlockAgenda == 2 ) { if ( KOPrefs::instance()->mSetTimeToDayStartAt ) setStartHour( KOPrefs::instance()->mDayBegins ); else if ( KOPrefs::instance()->mCenterOnCurrentTime ) setStartHour( QTime::currentTime ().hour() ); // qApp->processEvents(); } qApp->processEvents(); //qDebug("qApp->processEvents(); END "); globalFlagBlockAgenda = 0; // mAgenda->hideUnused(); //mAllDayAgenda->hideUnused(); mAllDayAgenda->drawContentsToPainter(); mAgenda->drawContentsToPainter(); repaintAgenda(); + onlyOne = false; // mAgenda->finishUpdate(); //mAllDayAgenda->finishUpdate(); // repaintAgenda(); //qApp->processEvents(); // globalFlagBlockAgenda = 0; } void KOAgendaView::repaintAgenda() { // mAllDayAgenda->drawContentsToPainter(); // mAllDayAgenda->viewport()->repaint( false ); // mAgenda->drawContentsToPainter(); // mAgenda->viewport()->repaint( false ); // qApp->processEvents(); //qDebug("KOAgendaView::repaintAgenda() "); //qApp->processEvents(); mAgenda->viewport()->repaint( false ); mAllDayAgenda->viewport()->repaint( false ); mAgenda->finishUpdate(); mAllDayAgenda->finishUpdate(); } void KOAgendaView::clearView() { // kdDebug() << "ClearView" << endl; mAllDayAgenda->clear(); mAgenda->clear(); } void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER if (fd == td) calPrinter->preview(CalPrinter::Day, fd, td); else calPrinter->preview(CalPrinter::Week, fd, td); #endif } // void KOAgendaView::updateMovedTodo() // { // // updateConfig(); // // emit updateTodoViews(); // } void KOAgendaView::newEvent(int gx, int gy) { if (!mSelectedDates.count()) return; QDate day = mSelectedDates[gx]; QTime time = mAgenda->gyToTime(gy); QDateTime dt(day,time); // if ( dt < QDateTime::currentDateTime () ) // dt = QDateTime::currentDateTime ().addSecs( 3600 ); emit newEventSignal(dt); } void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) { if (!mSelectedDates.count()) return; QDate dayStart = mSelectedDates[gxStart]; QDate dayEnd = mSelectedDates[gxEnd]; QTime timeStart = mAgenda->gyToTime(gyStart); QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); QDateTime dtStart(dayStart,timeStart); QDateTime dtEnd(dayEnd,timeEnd); emit newEventSignal(dtStart,dtEnd); } void KOAgendaView::newEventAllDay(int gx, int ) { if (!mSelectedDates.count()) return; QDate day = mSelectedDates[gx]; emit newEventSignal(day); } void KOAgendaView::newTodoAllDay(int gx, int ) { if (!mSelectedDates.count()) return; QDateTime day (mSelectedDates[gx] ); emit newTodoSignal(day, true); } void KOAgendaView::newTodo(int gx, int gy ) { if (!mSelectedDates.count()) return; QDate dayStart = mSelectedDates[gx]; diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h index 6ecc233..1eeb8d1 100644 --- a/korganizer/koeventviewer.h +++ b/korganizer/koeventviewer.h @@ -1,131 +1,131 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef KOEVENTVIEWER_H #define KOEVENTVIEWER_H // // Viewer widget for events. // #include <qtextbrowser.h> #include <libkcal/event.h> #include <libkcal/journal.h> using namespace KCal; #ifdef DESKTOP_VERSION #include <qradiobutton.h> #include <qpushbutton.h> #include <qlayout.h> #include <qdialog.h> #include <qlabel.h> #include <qbuttongroup.h> #include <kglobal.h> class KOPrintPrefs : public QDialog { public: KOPrintPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("KO/Pi Printout") ); QVBoxLayout* lay = new QVBoxLayout( this ); - lay->setSpacing( 3 ); - lay->setMargin( 3 ); - QLabel * lab = new QLabel( i18n("This prints the view as you see it.\n(With the complete content, of course.)\nYou may change the print layout by resizing the view.\nPrint unscaled may print several pages\ndepending on the amount of data.\nPrint scaled down will print all on one page.\nPrint scaled up/down will print all on one page,\nbut will scale up the text to page boundaries,\nif the text is smaller than the page.\nYou can select page geometry setup in the next dialog."), this ); + lay->setSpacing( 9 ); + lay->setMargin( 9 ); + QLabel * lab = new QLabel( i18n("This prints the view as you see it.\n(With the complete content, of course.)\nYou may change the print layout by resizing the view.\nPrint unscaled may print several pages\ndepending on the amount of data.\nPrint scaled down will print all on one page.\nPrint scaled up/down will print all on one page,\nbut will scale up the text to page boundaries,\nif the text is smaller than the page.\nYou can select page geometry setup in the next dialog.\n"), this ); lay->addWidget( lab ); + lab->setAlignment( AlignCenter ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Printout Mode"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; pmNo = new QRadioButton(i18n("Print unscaled"), format ); pmScaledDown = new QRadioButton(i18n("Print scaled down to fit one page"), format ); new QRadioButton(i18n("Print scaled up/down to fit one page"), format ); pmScaledDown->setChecked( true ); QPushButton * ok = new QPushButton( i18n("OK"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); - resize( 200, 200 ); } int printMode() { if ( pmNo->isChecked() ) return 0; if ( pmScaledDown->isChecked() ) return 1; return 2; } private: QRadioButton* pmNo; QRadioButton* pmScaledDown; }; #endif class KOEventViewer : public QTextBrowser { Q_OBJECT public: KOEventViewer(QWidget *parent=0,const char *name=0); virtual ~KOEventViewer(); void setSource(const QString &); void setEvent(Event *event); void addEvent(Event *event); void setTodo(Todo *event, bool clearV = true ); void setJournal(Journal *jour, bool clearV = true ); void appendEvent(Event *event, int mode = 0 ); void appendTodo(Todo *event, int mode = 0 ); void appendJournal(Journal *jour, int mode = 0 ); void clearEvents(bool now=false); void addText(QString text); void setSyncMode( bool ); void setColorMode( int ); void mailToAttendees( bool all ); void printMe(); protected: int mColorMode; void addTag(const QString & tag,const QString & text); void formatCategories(Incidence *event); void formatAttendees(Incidence *event); void formatReadOnly(Incidence *event); void keyPressEvent ( QKeyEvent * e ); private: QTextBrowser *mEventTextView; bool mSyncMode; QString deTag(QString text); QString mText; QString mMailSubject; Incidence* mCurrentIncidence; signals: void launchaddressbook(QString uid); }; #endif |