author | zautrix <zautrix> | 2005-06-29 10:36:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-29 10:36:31 (UTC) |
commit | b7044dfc9516d546683973985555c481d59fc677 (patch) (side-by-side diff) | |
tree | b521090cfc8eb6c8c6a6f6f8167c83058ea1361b | |
parent | f226b4cd2ce06a6948811fe04d80fe3ffa44f695 (diff) | |
download | kdepimpi-b7044dfc9516d546683973985555c481d59fc677.zip kdepimpi-b7044dfc9516d546683973985555c481d59fc677.tar.gz kdepimpi-b7044dfc9516d546683973985555c481d59fc677.tar.bz2 |
journal fixxx
-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | korganizer/journalentry.cpp | 59 | ||||
-rw-r--r-- | korganizer/journalentry.h | 5 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 98 | ||||
-rw-r--r-- | korganizer/kojournalview.h | 10 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 7 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 1 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 12 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 |
10 files changed, 165 insertions, 30 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a62145a..697093e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -82,768 +82,769 @@ #include "../kalarmd/alarmdialog.h" #ifndef DESKTOP_VERSION #include <libkcal/sharpformat.h> #include <externalapphandler.h> #endif #include <libkcal/phoneformat.h> #ifndef KORG_NOMAIL #include "komailclient.h" #endif #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koeventeditor.h" #include "kotodoeditor.h" #include "koprefs.h" #include "koeventviewerdialog.h" #include "publishdialog.h" #include "kofilterview.h" #include "koglobals.h" #include "koviewmanager.h" #include "koagendaview.h" #include "kodialogmanager.h" #include "outgoingdialog.h" #include "incomingdialog.h" #include "datenavigatorcontainer.h" #include "statusdialog.h" #include "kdatenavigator.h" #include "kotodoview.h" #include "datenavigator.h" #include "resourceview.h" #include "navigatorbar.h" #include "searchdialog.h" #include "mainwindow.h" #include "calendarview.h" #ifndef DESKTOP_VERSION #include <qtopia/alarmserver.h> #endif #ifndef _WIN32_ #include <stdlib.h> #include <stdio.h> #include <unistd.h> #else #include <qprocess.h> #endif #ifdef DESKTOP_VERSION #include <kabc/stdaddressbook.h> #endif using namespace KOrg; using namespace KCal; extern int globalFlagBlockAgenda; extern int globalFlagBlockStartup; MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) { mAlarms = alarms; viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); QString mText = "<table width=\"100%\">\n"; //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; #ifdef DESKTOP_VERSION mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; #else mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; #endif // mText += "<img src=\""; // mText += ipath; // mText += "\">"; //mEventDate = QDate::currentDate(); #ifdef DESKTOP_VERSION mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; #else mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; #endif //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; Incidence * inc = getNextInc( start ); int time = 0; //mText += "<table>"; while ( inc ) { QDateTime dt ; QString tempText = "<a "; bool ok; dt = inc->getNextOccurence( start, &ok ); if ( !ok ) continue; if ( inc->typeID() == eventID ) { tempText += "href=\"event:"; } else if ( inc->typeID() == todoID ) { tempText += "href=\"todo:"; } tempText += inc->uid() + "\">"; if ( inc->typeID() == todoID ) tempText += i18n("Todo: "); if ( inc->summary().length() > 0 ) tempText += inc->summary(); else tempText += i18n("-no summary-"); QString timestr; if (!inc->doesFloat()) timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; else timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; if ( dt.date() < QDate::currentDate() && time == 0 ) { mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; mText += "<table>"; time = 1; } if ( dt.date() == QDate::currentDate() && time <= 1 ) { if ( time > 0 ) mText +="</table>"; mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; mText += "<table>"; time = 2; } if ( dt.date() > QDate::currentDate() && time <= 2 ) { if ( time > 0 ) mText +="</table>"; mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; mText += "<table>"; time = 3; } mText +="<tr><td><b>"; mText += timestr; mText += "</b></td><td>"; mText += tempText; mText += "</td></tr>\n"; inc = getNextInc( start ); } mText +="</table>"; setText( mText ); } MissedAlarmTextBrowser::~MissedAlarmTextBrowser() { //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); } Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) { QDateTime dt ; Incidence * retInc; Incidence * inc = mAlarms.first(); if ( inc == 0 ) return 0; bool ok; dt = inc->getNextOccurence( start, &ok ); if ( ! ok ) return 0; QDateTime dtn ; retInc = inc; inc = mAlarms.next(); while ( inc ) { dtn = inc->getNextOccurence( start, &ok ); if ( ! ok ) return 0; if ( dtn < dt ) { dt = dtn; retInc = inc; } inc = mAlarms.next(); } mAlarms.remove( retInc ); return retInc; } void MissedAlarmTextBrowser::setSource(const QString & n) { if (n.startsWith("event:")) { #ifdef DESKTOP_VERSION emit showIncidence(n.mid(8)); #else emit showIncidence(n.mid(6)); #endif return; } else if (n.startsWith("todo:")) { #ifdef DESKTOP_VERSION emit showIncidence(n.mid(7)); #else emit showIncidence(n.mid(5)); #endif return; } } class KOBeamPrefs : public QDialog { public: KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Beam Options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); lay->addWidget( time ); time->setExclusive ( true ) ; vcal = new QRadioButton(" vCalendar ", format ); ical = new QRadioButton(" iCalendar ", format ); vcal->setChecked( true ); tz = new QRadioButton(i18n(" With timezone "), time ); local = new QRadioButton(i18n(" Local time "), time ); tz->setChecked( true ); QPushButton * ok = new QPushButton( i18n("Beam via IR!"), 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 ); } bool beamVcal() { return vcal->isChecked(); } bool beamLocal() { return local->isChecked(); } private: QRadioButton* vcal, *ical, *local, *tz; }; class KOCatPrefs : public QDialog { public: KOCatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Manage new Categories") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; addCatBut = new QRadioButton(i18n("Add to category list"), format ); new QRadioButton(i18n("Remove from Events/Todos"), format ); addCatBut->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 ); } bool addCat() { return addCatBut->isChecked(); } private: QRadioButton* addCatBut; }; CalendarView::CalendarView( CalendarResources *calendar, QWidget *parent, const char *name ) : CalendarViewBase( parent, name ), mCalendar( calendar ), mResourceManager( calendar->resourceManager() ) { mEventEditor = 0; mTodoEditor = 0; init(); } CalendarView::CalendarView( Calendar *calendar, QWidget *parent, const char *name ) : CalendarViewBase( parent, name ), mCalendar( calendar ), mResourceManager( 0 ) { mEventEditor = 0; mTodoEditor = 0; init(); } void CalendarView::init() { mNextAlarmDateTime = QDateTime::currentDateTime(); setFocusPolicy ( NoFocus ); mViewerCallerIsSearchDialog = false; mBlockShowDates = false; beamDialog = new KOBeamPrefs(); mDatePickerMode = 0; mCurrentSyncDevice = ""; writeLocale(); mViewManager = new KOViewManager( this ); mDialogManager = new KODialogManager( this ); mEventViewerDialog = 0; mModified = false; mReadOnly = false; mSelectedIncidence = 0; mCalPrinter = 0; mFilters.setAutoDelete(true); mCalendar->registerObserver( this ); // TODO: Make sure that view is updated, when calendar is changed. mStorage = new FileStorage( mCalendar ); mNavigator = new DateNavigator( this, "datevav", mViewManager ); QBoxLayout *topLayout = (QBoxLayout*)layout(); #ifndef KORG_NOSPLITTER // create the main layout frames. mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); topLayout->addWidget(mPanner); mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, "CalendarView::LeftFrame"); mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); mDateNavigator = new DateNavigatorContainer( mLeftSplitter, "CalendarView::DateNavigator" ); mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); mTodoList->setNavigator( mNavigator ); mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); #ifdef KORG_NORESOURCEVIEW mResourceView = 0; #else if ( mResourceManager ) { mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); mResourceView->updateView(); connect( mResourceView, SIGNAL( resourcesChanged() ), SLOT( updateView() ) ); } else { mResourceView = 0; } #endif QWidget *rightBox = new QWidget( mPanner ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mRightFrame, 1 ); mLeftFrame = mLeftSplitter; #else //QWidget *mainBox = new QWidget( this ); //QWidget *leftFrame = new QWidget( mainBox ); //QBoxLayout * mainBoxLayout; if ( KOPrefs::instance()->mVerticalScreen ) { //mainBoxLayout = new QVBoxLayout(mainBox); //leftFrameLayout = new QHBoxLayout(leftFrame ); mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); } else { //mainBoxLayout = new QHBoxLayout(mainBox); //leftFrameLayout = new QVBoxLayout(leftFrame ); mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); } mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); //QBoxLayout * leftFrameLayout; topLayout->addWidget( mMainFrame ); //mainBoxLayout->addWidget (mLeftFrame); mDateNavigator = new DateNavigatorContainer( mLeftFrame, "CalendarView::DateNavigator" ); #if 0 // FIXME mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, "CalendarView::DateNavigator", QDate::currentDate()); #endif // mDateNavigator->blockSignals( true ); //leftFrameLayout->addWidget( mDateNavigator ); mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); + connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); mTodoList->setNavigator( mNavigator ); #if 0 if ( QApplication::desktop()->width() < 480 ) { leftFrameLayout->addWidget(mFilterView); leftFrameLayout->addWidget(mTodoList, 2 ); } else { leftFrameLayout->addWidget(mTodoList,2 ); leftFrameLayout->addWidget(mFilterView ); } #endif mFilterView->hide(); mCalEditView->hide(); QWidget *rightBox = new QWidget( mMainFrame ); //mainBoxLayout->addWidget ( rightBox, 10 ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mRightFrame, 10 ); //mLeftFrame = (QWidget *)leftFrame; if ( KOPrefs::instance()->mVerticalScreen ) { //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); } else { //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); } if ( !KOPrefs::instance()->mShowDateNavigator) mDateNavigator->hide(); //qDebug("Calendarview Size %d %d ", width(), height()); #endif connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), SLOT( showDates( const KCal::DateList & ) ) ); connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), mViewManager, SLOT( showMonth( const QDate & ) ) ); connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), mNavigator, SLOT( selectWeek( const QDate & ) ) ); connect( mDateNavigator, SIGNAL( goPrevYear() ), mNavigator, SLOT( selectPreviousYear() ) ); connect( mDateNavigator, SIGNAL( goNextYear() ), mNavigator, SLOT( selectNextYear() ) ); connect( mDateNavigator, SIGNAL( goPrevMonth() ), mNavigator, SLOT( selectPreviousMonth() ) ); connect( mDateNavigator, SIGNAL( goNextMonth() ), mNavigator, SLOT( selectNextMonth() ) ); connect( mDateNavigator, SIGNAL( goPrevious() ), mNavigator, SLOT( selectPrevious() ) ); connect( mDateNavigator, SIGNAL( goNext() ), mNavigator, SLOT( selectNext() ) ); connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), mNavigator, SLOT( slotMonthSelect( int ) ) ); connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); #if 0 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), SLOT( incidenceAdded( Incidence *) ) ); #endif // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); connect( this, SIGNAL( configChanged() ), mDateNavigator, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( newTodoSignal() ), SLOT( newTodo() ) ); connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), SLOT( newSubTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), SLOT( editTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), SLOT( showTodo( Todo *) ) ); connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), SLOT( deleteTodo( Todo *) ) ); connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( purgeCompletedSignal() ), SLOT( purgeCompleted() ) ); connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), SIGNAL( todoModified( Todo *, int ) ) ); connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), this, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), this, SLOT (cancelIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), this, SLOT ( moveIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), this, SLOT ( beamIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), this, SLOT ( todo_unsub( Todo * ) ) ); connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), this, SLOT ( todo_resub( Todo *,Todo * ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, SLOT( updateTodo( Todo *, int ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), this, SLOT( changeTodoDisplay( Todo *, int ) ) ); connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); connect(QApplication::clipboard(),SIGNAL(dataChanged()), SLOT(checkClipboard())); connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processTodoListSelection( Incidence * ) ) ); connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); // kdDebug() << "CalendarView::CalendarView() done" << endl; mDateFrame = new QVBox(0,0,WType_Popup); //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); mDateFrame->setLineWidth(3); mDateFrame->hide(); mDateFrame->setCaption( i18n( "Pick a date to display")); mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); mEventEditor = mDialogManager->getEventEditor(); mTodoEditor = mDialogManager->getTodoEditor(); mFlagEditDescription = false; mSuspendTimer = new QTimer( this ); mAlarmTimer = new QTimer( this ); mRecheckAlarmTimer = new QTimer( this ); connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); mAlarmDialog = new AlarmDialog( this ); connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); mAlarmDialog->setServerNotification( false ); mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); #ifndef DESKTOP_VERSION //US listen for arriving address resultsets connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); #endif mDateNavigator->setCalendar( mCalendar ); } CalendarView::~CalendarView() { // kdDebug() << "~CalendarView()" << endl; //qDebug("CalendarView::~CalendarView() "); delete mDialogManager; delete mViewManager; delete mStorage; delete mDateFrame ; delete beamDialog; delete mEventViewerDialog; //kdDebug() << "~CalendarView() done" << endl; } void CalendarView::checkAlarms() { KConfig *config = KOGlobals::config(); config->setGroup( "AppRun" ); QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); int daysto = dt.daysTo( QDate::currentDate() ); int days = config->readNumEntry( "LatestProgramStopDays" , daysto); dt = dt.addDays( days ); int secto = dt.secsTo( QDateTime::currentDateTime() ); int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; //qDebug("KO: Reading program stop %d ", secs); //secs -= ( 3600 * 24*3 ); // debug only QDateTime latest = dt.addSecs ( secs ); qDebug("KO: Last termination on %s ", latest.toString().latin1()); //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); QPtrList<Incidence> el = mCalendar->rawIncidences(); QPtrList<Incidence> al; Incidence* inL = el.first(); QDateTime cur = QDateTime::currentDateTime().addSecs(-59); qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); while ( inL ) { bool ok = false; int offset = 0; QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; if ( ok ) { //qDebug("OK %s",next.toString().latin1()); if ( next < cur ) { al.append( inL ); //qDebug("found missed alarm: %s ", inL->summary().latin1() ); } } inL = el.next(); } if ( al.count() ) { QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); dia->setCaption( i18n("KO/Pi: Missing alarms!") ); QVBoxLayout* lay = new QVBoxLayout( dia ); lay->setSpacing( 0 ); lay->setMargin( 0 ); MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); lay->addWidget( matb ); if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { int wid = 210; int x = QApplication::desktop()->width() - wid - 7; int y = QApplication::desktop()->height() - wid - 70; dia->setGeometry ( x,y,wid,wid); } else { int si = 220; if ( QApplication::desktop()->width() > 470 ) si = 400; dia->resize(si,si/2); } dia->setBackgroundColor( QColor( 255, 255, 255 ) ); dia->show(); } } void CalendarView::showDay( QDate d ) { dateNavigator()->blockSignals( true ); dateNavigator()->selectDate( d ); dateNavigator()->blockSignals( false ); mViewManager->showDayView(); //dateNavigator()->selectDate( d ); } void CalendarView::timerAlarm() { //qDebug("CalendarView::timerAlarm() "); computeAlarm(mAlarmNotification ); } void CalendarView::suspendAlarm() { //qDebug(" CalendarView::suspendAlarm() "); computeAlarm(mSuspendAlarmNotification ); } void CalendarView::startAlarm( QString mess , QString filename) { topLevelWidget()->showNormal(); topLevelWidget()->setActiveWindow(); topLevelWidget()->raise(); mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); } void CalendarView::checkNextTimerAlarm() { mCalendar->checkAlarmForIncidence( 0, true ); } void CalendarView::computeAlarm( QString msg ) { QString mess = msg; QString mAlarmMessage = mess.mid( 9 ); QString filename = MainWindow::resourcePath(); filename += "koalarm.wav"; QString tempfilename; if ( mess.left( 13 ) == "suspend_alarm") { bool error = false; int len = mess.mid( 13 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 13, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 13+len+3 ); //qDebug("suspend file %s ",tempfilename.latin1() ); startAlarm( mAlarmMessage, filename); return; } if ( mess.left( 11 ) == "timer_alarm") { //mTimerTime = 0; startAlarm( mess.mid( 11 ), filename ); return; } if ( mess.left( 10 ) == "proc_alarm") { bool error = false; int len = mess.mid( 10 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 10, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( error ) { mAlarmMessage = "Procedure Alarm\nError - File not found\n"; mAlarmMessage += mess.mid( 10+len+3+9 ); } else { //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); //qDebug("-----system command %s ",tempfilename.latin1() ); #ifndef _WIN32_ if ( vfork () == 0 ) { execl ( tempfilename.latin1(), 0 ); return; } #else QProcess* p = new QProcess(); p->addArgument( tempfilename.latin1() ); p->start(); return; #endif return; } //qDebug("+++++++system command %s ",tempfilename.latin1() ); } if ( mess.left( 11 ) == "audio_alarm") { bool error = false; int len = mess.mid( 11 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 11, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 11+len+3+9 ); //qDebug("audio file command %s ",tempfilename.latin1() ); } if ( mess.left( 9 ) == "cal_alarm") { mAlarmMessage = mess.mid( 9 ) ; } startAlarm( mAlarmMessage, filename ); } void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) { //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); mSuspendAlarmNotification = noti; int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); mSuspendTimer->start( ms , true ); } void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) { mNextAlarmDateTime = qdt; //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { #ifndef DESKTOP_VERSION diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index c19a5ca..7274849 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -1,250 +1,287 @@ /* 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. 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. */ // // Journal Entry #include <qlabel.h> #include <qlayout.h> #include <qvbox.h> #include <qfile.h> #include <qdir.h> #include <qtextstream.h> #include <qtextcodec.h> #include <qpixmap.h> #include <qpushbutton.h> #include <qapplication.h> #include <kdebug.h> #include <kglobal.h> #include <klocale.h> #include <ktextedit.h> #include <kfiledialog.h> #include <kmessagebox.h> #include "koprefs.h" #include <libkcal/journal.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <kresources/resourceselectdialog.h> #include "journalentry.h" //#include "journalentry.moc" #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #endif JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : QFrame(parent) { + showOnlyMode = false; mCalendar = calendar; mJournal = 0; mDirty = false; QHBox * vb = new QHBox ( this ); + QPushButton * newJournal = new QPushButton( vb ); + QIconSet icon; + if ( QApplication::desktop()->width() < 321 ) + icon = SmallIcon("ko16old"); + else + icon = SmallIcon("ko24old"); + newJournal->setIconSet (icon ) ; + int size = newJournal->sizeHint().height(); + newJournal->setFixedSize( size, size ); + + + QPushButton * toggleJournal = new QPushButton( vb ); + icon = SmallIcon("1updownarrow"); + toggleJournal->setIconSet (icon ) ; + //int size = toggleJournal->sizeHint().height(); + toggleJournal->setFixedSize( size * 2 /3 , size ); + + + + mTitleLabel = new QLabel(i18n("Title"),vb); + mTitleLabel->setMargin(2); + mTitleLabel->setAlignment(AlignCenter); QPushButton * loadTemplate = new QPushButton( vb ); QPushButton * saveTemplate = new QPushButton( vb ); - QIconSet icon; if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("fileexport16"); else icon = SmallIcon("fileexport"); saveTemplate->setIconSet (icon ) ; - int size = saveTemplate->sizeHint().height(); + //size = saveTemplate->sizeHint().height(); saveTemplate->setFixedSize( size, size ); if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("fileimport16"); else icon = SmallIcon("fileimport"); loadTemplate->setIconSet (icon ) ; loadTemplate->setFixedSize( size, size ); - - mTitleLabel = new QLabel(i18n("Title"),vb); - mTitleLabel->setMargin(2); - mTitleLabel->setAlignment(AlignCenter); - mEditor = new KTextEdit(this); connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); #endif mEditor->setWordWrap( KTextEdit::WidgetWidth ); QBoxLayout *topLayout = new QVBoxLayout(this); topLayout->addWidget(vb); topLayout->addWidget(mEditor); mEditor->installEventFilter(this); connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); + connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) ); + connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); } JournalEntry::~JournalEntry() { } void JournalEntry::slotSaveTemplate() { QString fileName =locateLocal( "templates", "journals" ); QDir t_dir; if ( !t_dir.exists(fileName) ) t_dir.mkdir ( fileName ); fileName += "/journal"; fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); if ( fileName.length() == 0 ) return; QFile fileIn( fileName ); if (!fileIn.open( IO_WriteOnly ) ) { KMessageBox::error( this, i18n("Error saving template file\n '%1'.") .arg( fileName ) ); return; } // QString text; QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); tsIn << mEditor->text(); fileIn.close(); } void JournalEntry::slotLoadTemplate() { QString fileName =locateLocal( "templates", "journals" ); QDir t_dir; if ( !t_dir.exists(fileName) ) t_dir.mkdir ( fileName ); fileName += "/journal"; fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); if ( fileName.length() == 0 ) return; QFile fileIn( fileName ); if (!fileIn.open( IO_ReadOnly ) ) { KMessageBox::error( this, i18n("Error loading template file\n '%1'.") .arg( fileName ) ); return; } QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); QString text = tsIn.read(); fileIn.close(); int line, col; mEditor->getCursorPosition (& line, & col ); mEditor-> insertAt ( text, line, col, true ); //mEditor->setIgnoreMark( true ); setDirty(); } void JournalEntry::setDate(const QDate &date) { + showOnlyMode = false; + mDate = date; writeJournal(); - + int id = mCalendar->defaultCalendar(); + if ( id == 1 ) { mTitleLabel->setText(KGlobal::locale()->formatDate(date)); + } else { + QString calname = KOPrefs::instance()->getCalendar( id )->mName; + mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); + } +} - - mDate = date; +void JournalEntry::toggleShowJournal() +{ + if ( showOnlyMode ) + emit showJournalOnly( 0 ); + else + emit showJournalOnly( mJournal ); } void JournalEntry::setJournal(Journal *journal) { writeJournal(); mJournal = journal; mEditor->setText(mJournal->description()); - + int id = mJournal->calID(); + if ( id > 1 ) { + QString calname = KOPrefs::instance()->getCalendar( id )->mName; + mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); + } else { + mTitleLabel->setText(KGlobal::locale()->formatDate(mDate)); + } mDirty = false; } Journal *JournalEntry::journal() const { return mJournal; } void JournalEntry::setDirty() { mDirty = true; // kdDebug() << "JournalEntry::setDirty()" << endl; } void JournalEntry::clear() { mJournal = 0; mEditor->setText(""); } bool JournalEntry::eventFilter( QObject *o, QEvent *e ) { // kdDebug() << "JournalEntry::event received " << e->type() << endl; if ( e->type() == QEvent::FocusOut ) { writeJournal(); } if ( e->type() == QEvent::KeyPress ) { QKeyEvent * k = (QKeyEvent *) e; if ( k->state() == Qt::ControlButton ) { k->ignore(); //return true; } } return QFrame::eventFilter( o, e ); // standard event processing } void JournalEntry::writeJournal() { // kdDebug() << "JournalEntry::writeJournal()" << endl; if (!mDirty) return; if (mEditor->text().isEmpty()) { if ( mJournal ) { mDirty = false; bool conf = KOPrefs::instance()->mConfirm; KOPrefs::instance()->mConfirm = false; emit deleteJournal(mJournal); KOPrefs::instance()->mConfirm = conf; mJournal = 0; } return; } // kdDebug() << "JournalEntry::writeJournal()..." << endl; if (!mJournal) { mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); } mJournal->setDescription(mEditor->text()); //qDebug("tttt%s ", mEditor->text().latin1()); mDirty = false; } void JournalEntry::flushEntry() { if (!mDirty) return; writeJournal(); } void JournalEntry::keyPressEvent ( QKeyEvent * e ) { e->ignore(); } diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index f1a1fef..85ad5df 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h @@ -1,75 +1,80 @@ /* 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. 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 JOURNALENTRY_H #define JOURNALENTRY_H // // Widget showing one Journal entry #include <qframe.h> #include <libkcal/calendar.h> class QLabel; class KTextEdit; using namespace KCal; class JournalEntry : public QFrame { Q_OBJECT public: JournalEntry(Calendar *,QWidget *parent); virtual ~JournalEntry(); void setJournal(Journal *); Journal *journal() const; void setDate(const QDate &); void clear(); void flushEntry(); + void setShowOnly() {showOnlyMode = true;} protected slots: void slotSaveTemplate(); void slotLoadTemplate(); void setDirty(); + void toggleShowJournal(); signals: void deleteJournal(Journal *); + void newJournal(); + void showJournalOnly( Journal * ); protected: bool eventFilter( QObject *o, QEvent *e ); void writeJournal(); private: + bool showOnlyMode; Calendar *mCalendar; Journal *mJournal; QDate mDate; void keyPressEvent ( QKeyEvent * ) ; QLabel *mTitleLabel; KTextEdit *mEditor; bool mDirty; }; #endif diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index bc16037..fae59d6 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -1,116 +1,188 @@ /* 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. 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. */ // // View of Journal entries #include <qlayout.h> #include <qpopupmenu.h> #include <klocale.h> #include <kdebug.h> #include "koprefs.h" #include <libkcal/calendar.h> #include "journalentry.h" #include "kojournalview.h" using namespace KOrg; KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, const char *name) : KOrg::BaseView(calendar, parent, name) { - mEntry = new JournalEntry(calendar,this); - mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); - QBoxLayout *topLayout = new QVBoxLayout(this); - topLayout->addWidget(mEntry); - connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; + mCalendar = calendar; + mTopLayout = new QVBoxLayout(this); + getNewEntry(); } KOJournalView::~KOJournalView() { } int KOJournalView::currentDateCount() { return 0; } +JournalEntry* KOJournalView::getNewEntry() +{ + JournalEntry* Entry = new JournalEntry(mCalendar,this); + jEntries.append( Entry ); + mTopLayout->addWidget(Entry); + Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); + connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; + connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; + connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; + return Entry; +} QPtrList<Incidence> KOJournalView::selectedIncidences() { QPtrList<Incidence> eventList; return eventList; } void KOJournalView::updateConfig() { + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + mEntry = jEntries.next(); + } } void KOJournalView::updateView() { + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + mEntry = jEntries.next(); + } + showDates( mDate, QDate() ); } void KOJournalView::flushView() { + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { mEntry->flushEntry(); + mEntry = jEntries.next(); + } } void KOJournalView::clearList() { + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { mEntry->clear(); + mEntry = jEntries.next(); } -void KOJournalView::showDates(const QDate &start, const QDate &) +} +void KOJournalView::newJournal() { -// kdDebug() << "KOJournalView::selectDates()" << endl; - - mEntry->setDate(start); + Journal* mJournal = new Journal; + mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); + mCalendar->addJournal(mJournal); + showDates( mDate, QDate() ); +} - Journal *j = calendar()->journal(start); - if (j) mEntry->setJournal(j); - else mEntry->clear(); +void KOJournalView::showOnly ( Journal* j ) +{ + if ( j == 0 ) { + showDates( mDate, QDate() ); + return; + } + QPtrList<Journal> jl; + jl.append ( j ); + showList( jl ); + JournalEntry* mEntry = jEntries.first(); + mEntry->setShowOnly(); +} +void KOJournalView::showList(QPtrList<Journal> jl) +{ + JournalEntry* mEntry = jEntries.first(); + JournalEntry* firstEntry = mEntry; + int count = jl.count(); + int iii = 0; + while ( iii < count ) { + if ( !mEntry ) { + mEntry = getNewEntry(); + mEntry->show(); + mEntry->setDate(mDate); + mEntry->setJournal(jl.at(iii)); + mEntry = 0; + } else { + mEntry->setDate(mDate); + mEntry->setJournal(jl.at(iii)); + mEntry->show(); + mEntry = jEntries.next(); + } + ++iii; + } + while ( mEntry ) { + mEntry->setDate(mDate); + mEntry->clear(); + if ( mEntry != firstEntry ) + mEntry->hide(); + else + mEntry->show(); + mEntry = jEntries.next(); + } +} -// emit incidenceSelected( 0 ); +void KOJournalView::showDates(const QDate &start, const QDate &) +{ + mDate = start; + QPtrList<Journal> jl = calendar()->journals4Date( start ); + showList( jl ); } void KOJournalView::showEvents(QPtrList<Event>) { // After new creation of list view no events are selected. // emit incidenceSelected( 0 ); } void KOJournalView::changeEventDisplay(Event *, int /*action*/) { updateView(); } void KOJournalView::keyPressEvent ( QKeyEvent * e ) { //qDebug("keyPressEven "); if ( e->state() == Qt::ControlButton ) { if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) e->ignore(); } } diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h index 445f940..aabf11c 100644 --- a/korganizer/kojournalview.h +++ b/korganizer/kojournalview.h @@ -1,68 +1,76 @@ /* 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. 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 _KOJOURNALVIEW_H #define _KOJOURNALVIEW_H #include <korganizer/baseview.h> +#include <qlayout.h> class JournalEntry; /** * This class provides a journal view. * @short View for Journal components. * @author Cornelius Schumacher <schumacher@kde.org> * @see KOBaseView */ class KOJournalView : public KOrg::BaseView { Q_OBJECT public: KOJournalView(Calendar *calendar, QWidget *parent = 0, const char *name = 0); ~KOJournalView(); virtual int currentDateCount(); void clearList(); virtual QPtrList<Incidence> selectedIncidences(); DateList selectedDates() {DateList q; return q;}; signals: void deleteJournal(Journal *); public slots: + void showOnly ( Journal* ); + void newJournal(); void updateView(); void flushView(); void updateConfig(); void showDates( const QDate &start, const QDate &end ); void showEvents(QPtrList<Event> eventList); void changeEventDisplay(Event *, int); private: - JournalEntry *mEntry; + void showList(QPtrList<Journal> jl); + Calendar *mCalendar; + JournalEntry* getNewEntry(); + QPtrList<JournalEntry> jEntries; void keyPressEvent ( QKeyEvent * ) ; + QBoxLayout *mTopLayout; + QDate mDate; }; #endif diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 5d9af6d..7b307f7 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -1,668 +1,675 @@ /* 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. 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. */ #include <qwidgetstack.h> #include <kconfig.h> #include <kglobal.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #include <qdatetime.h> #include "calendarview.h" #include "datenavigator.h" #include "kotodoview.h" #include "koagendaview.h" #include "kodialogmanager.h" #include "komonthview.h" #include "kolistview.h" #include "kowhatsnextview.h" #include "kojournalview.h" #include "kotimespanview.h" #include "koprefs.h" #include "navigatorbar.h" #include "kdatenavigator.h" #include "koviewmanager.h" //extern bool externFlagMonthviewBlockPainting; //bool globalFlagBlockPainting = false; int globalFlagBlockAgenda = 0; int globalFlagBlockLabel = 0; int globalFlagBlockAgendaItemPaint = 1; int globalFlagBlockAgendaItemUpdate = 1; KOViewManager::KOViewManager( CalendarView *mainView ) : QObject(), mMainView( mainView ) { mCurrentView = 0; flagResetViewChangeDate = 0; mWhatsNextView = 0; mTodoView = 0; mAgendaView = 0; mMonthView = 0; mListView = 0; mJournalView = 0; mTimeSpanView = 0; mCurrentAgendaView = 0 ; mFlagShowNextxDays = false; } KOViewManager::~KOViewManager() { } KOrg::BaseView *KOViewManager::currentView() { return mCurrentView; } void KOViewManager::readSettings(KConfig *config) { config->setGroup("General"); QString view = config->readEntry("Current View"); if (view == "WhatsNext") showWhatsNextView(); else if (view == "Month") { if ( !KOPrefs::instance()->mMonthViewWeek ) showMonthView(); else showMonthViewWeek(); } else if (view == "List") showListView(); else if (view == "Journal") showJournalView(); else if (view == "TimeSpan") showTimeSpanView(); else if (view == "Todo") showTodoView(); else { config->setGroup( "Views" ); int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); mCurrentAgendaView = dateCount; showAgendaView(); mCurrentAgendaView = dateCount; #ifdef DESKTOP_VERSION QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); #endif } } + void KOViewManager::showDateView( int view, QDate date) { static int lastMode = 0; static int lastCount = 0; static bool lastNDMode = false; static QDate lastDate; //qDebug("date %d %s", view, date.toString().latin1()); if (view != 9) lastMode = 0; //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); bool savemFlagShowNextxDays = mFlagShowNextxDays; mFlagShowNextxDays = false; if ( view == 3 ) { //mCurrentAgendaView = 1 ; lastDate = mMainView->dateNavigator()->selectedDates().first(); lastCount = mMainView->dateNavigator()->selectedDates().count(); lastNDMode = savemFlagShowNextxDays; mMainView->dateNavigator()->selectDate( date ); lastMode = 1; mCurrentAgendaView = 1 ; } else if (view == 4 ) { mCurrentAgendaView = 7 ; mMainView->dateNavigator()->selectDates( date, 7 ); } else if (view == 5 ) { mCurrentAgendaView = 14 ; mMainView->dateNavigator()->selectDates( date, 14); } else if (view == 6 ) { resetDateSilent( date,1); showMonthView(); } else if (view == 7 ) { mMainView->dateNavigator()->selectDate( date ); showJournalView(); } else if (view == 8 ) { globalFlagBlockAgenda = 1; if ( mCurrentAgendaView != 3 ) mCurrentAgendaView = -1; showAgendaView(KOPrefs::instance()->mFullViewMonth); globalFlagBlockAgenda = 2; mMainView->dateNavigator()->selectDates( date , KOPrefs::instance()->mNextXDays ); mFlagShowNextxDays = true; mCurrentAgendaView = 3 ; } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) if ( lastMode ) { mCurrentAgendaView = lastCount ; mMainView->dateNavigator()->selectDates( lastDate, lastCount); mFlagShowNextxDays = lastNDMode; if ( mFlagShowNextxDays ) { mCurrentAgendaView = 3 ; } } else showWeekView(); } else if (view == 10) { mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); } } void KOViewManager::writeSettings(KConfig *config) { config->setGroup("General"); QString view; if (mCurrentView == mWhatsNextView) view = "WhatsNext"; else if (mCurrentView == mMonthView) view = "Month"; else if (mCurrentView == mListView) view = "List"; else if (mCurrentView == mJournalView) view = "Journal"; else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; else if (mCurrentView == mTodoView) view = "Todo"; else view = "Agenda"; config->writeEntry("Current View",view); if (mAgendaView) { mAgendaView->writeSettings(config); } if (mTimeSpanView) { mTimeSpanView->writeSettings(config); } if (mListView) { mListView->writeSettings(config); } if (mTodoView) { mTodoView->saveLayout(config,"Todo View"); } } void KOViewManager::showNextView() { static int selecteddatescount = 0; static QDate selecteddate = QDate ( 2000, 1, 1 ); static QDate baseCycleDate = QDate ( 2000, 1, 1 ); int newCount = mMainView->dateNavigator()->selectedDates().count(); if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { flagResetViewChangeDate = 1; } if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) flagResetViewChangeDate = 1; if ( flagResetViewChangeDate > 0 ) { baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); //qDebug("newCycle "); } if (mCurrentView == mWhatsNextView) goto NEXT_X; if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; if (mCurrentView == mJournalView ) goto DAY_1; if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; if (mCurrentView == mAgendaView ) goto DAY_6; if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; if (mCurrentView == mMonthView ) goto LIST; if (mCurrentView == mListView ) goto TODO; // if (mCurrentView == mTodoView ) goto NEXT; NEXT: if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} NEXT_X: if ( KOPrefs::instance()->mShowIconNextDays ) { showNextXView(); goto ENTE ; } JOURNAL: if ( KOPrefs::instance()->mShowIconJournal ) { resetDateSilent( baseCycleDate , 1 ); showJournalView() ;goto ENTE ;} DAY_1: if ( KOPrefs::instance()->mShowIconDay1 ) { resetDateSilent( baseCycleDate , 2 ); showDayView() ;goto ENTE ;} DAY_5: if ( KOPrefs::instance()->mShowIconDay5 ) { resetDateSilent( baseCycleDate , 2 ); showWorkWeekView() ;goto ENTE ;} DAY_7: if ( KOPrefs::instance()->mShowIconDay7 ) { resetDateSilent( baseCycleDate , 2 ); showWeekView();goto ENTE ;} DAY_6: if ( KOPrefs::instance()->mShowIconDay6 ) { resetDateSilent( baseCycleDate , 2 ); showMonthViewWeek();goto ENTE ;} MONTH: if ( KOPrefs::instance()->mShowIconMonth ) { resetDateSilent( baseCycleDate , 2 ); showMonthView();goto ENTE ;} LIST: if ( KOPrefs::instance()->mShowIconList ) { resetDateSilent( baseCycleDate , 2 ); showListView() ;goto ENTE ;} TODO: if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} ENTE: flagResetViewChangeDate = 0; selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); selecteddate = mMainView->dateNavigator()->selectedDates().first(); } void KOViewManager::resetDateSilent( QDate date , int days ) { mMainView->dateNavigator()->blockSignals( true ); mMainView->dateNavigator()->selectDates( date , days ); mMainView->dateNavigator()->blockSignals( false ); } +void KOViewManager::setDefaultCalendar(int) +{ + if ( mJournalView && mCurrentView == mJournalView ) + mJournalView->updateView(); +} + void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) { if ( flagResetViewChangeDate < 10 ) ++flagResetViewChangeDate; //mFlagShowNextxDays = false; //if(view == mCurrentView) return; if ( view == 0 ) { view = mCurrentView; if ( view == 0 ) return; } bool callupdate = !(view == mCurrentView); bool full = fullScreen; if(view == mCurrentView && view != mWhatsNextView ) { if ( mCurrentAgendaView < 0 ) return; if ( view != mMonthView ) full = mMainView->leftFrame()->isVisible(); } else { if ( view == mMonthView && mMonthView) ;//mMonthView->skipResize = true ; mCurrentView = view; // bool full = fullScreen; bool isFull = !mMainView->leftFrame()->isVisible(); if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) full = true; if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) full = false; } if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); //raiseCurrentView( full ); mMainView->processIncidenceSelection( 0 ); //mMainView->updateView(); raiseCurrentView( full, callupdate ); mMainView->adaptNavigationUnits(); mMainView->updateUnmanagedViews(); } void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) { mCurrentAgendaView = 0; if ( fullScreen ) { mMainView->leftFrame()->hide(); } else { mMainView->leftFrame()->show(); } //if ( mCurrentView == mMonthView ) qApp->processEvents(); emit signalFullScreen( !fullScreen ); if ( callUpdateView ) mMainView->updateView(); if ( globalFlagBlockAgenda == 5 ) { globalFlagBlockAgenda = 4; globalFlagBlockAgendaItemPaint = 1; } mMainView->viewStack()->raiseWidget(mCurrentView); if ( globalFlagBlockAgenda == 4 ) { if ( mCurrentView == mAgendaView ) { //globalFlagBlockAgenda =1 ; if ( KOPrefs::instance()->mSetTimeToDayStartAt ) mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); else if ( KOPrefs::instance()->mCenterOnCurrentTime ) mAgendaView->setStartHour( QTime::currentTime ().hour() ); qApp->processEvents(); //qDebug("qApp->processEvents() "); globalFlagBlockAgenda = 0; mAgendaView->repaintAgenda(); } globalFlagBlockAgenda = 0; } emit signalAgendaView( mCurrentView == mAgendaView ); //qDebug("raiseCurrentView ende "); } void KOViewManager::clearAllViews() { if ( mTodoView ) mTodoView->clearList(); if ( mListView ) mListView->clearList(); if ( mAgendaView ) mAgendaView->clearList(); if ( mMonthView ) mMonthView->clearList(); if ( mWhatsNextView ) mWhatsNextView->clearList(); if ( mJournalView ) mJournalView->clearList(); } void KOViewManager::updateView() { // qDebug("KOViewManager::updateView() "); // if we are updating mTodoView, we get endless recursion if ( mTodoView == mCurrentView ) return; if ( mCurrentView ) mCurrentView->updateView(); } void KOViewManager::updateView(const QDate &start, const QDate &end) { // kdDebug() << "KOViewManager::updateView()" << endl; if (mCurrentView) mCurrentView->showDates(start, end); if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); } void KOViewManager::updateWNview() { if ( mCurrentView == mWhatsNextView && mWhatsNextView ) mWhatsNextView->updateView(); if ( mCurrentView == mMonthView && mMonthView ) mMonthView->updateView(); } void KOViewManager::showWhatsNextView() { if (!mWhatsNextView) { mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::WhatsNextView"); mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); addView(mWhatsNextView); connect(this, SIGNAL( printWNV() ), mWhatsNextView, SLOT( printMe() ) ); } globalFlagBlockAgenda = 1; KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; showView(mWhatsNextView, true ); //mWhatsNextView->updateView(); KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; } void KOViewManager::slotprintWNV() { if (!mWhatsNextView) showWhatsNextView(); emit printWNV(); } void KOViewManager::showListView() { if (!mListView) { mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); addView(mListView); connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), mMainView, SLOT(showIncidence(Incidence *))); connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), mMainView, SLOT(editIncidence(Incidence *))); connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), mMainView, SLOT(deleteIncidence(Incidence *))); connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect( mListView, SIGNAL( signalNewEvent() ), mMainView, SLOT( newEvent() ) ); connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); } // bool temp = mFlagShowNextxDays; //globalFlagBlockPainting = true; globalFlagBlockAgenda = 1; if ( KOPrefs::instance()->mListViewMonthTimespan ) { mMainView->setBlockShowDates( true ); mMainView->dateNavigator()->selectMonth(); mMainView->setBlockShowDates( false ); } KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; showView(mListView, KOPrefs::instance()->mFullViewTodo); //mFlagShowNextxDays = temp; KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; } void KOViewManager::showAgendaView( bool fullScreen ) { mMainView->dialogManager()->hideSearchDialog(); // qDebug("KOViewManager::showAgendaView "); bool full; full = fullScreen; if (!mAgendaView) { full = false; mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); addView(mAgendaView); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); #endif connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); // SIGNALS/SLOTS FOR DAY/WEEK VIEW connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), mMainView, SLOT(newTodoDateTime(QDateTime,bool))); connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), mMainView, SLOT(newEvent(QDateTime))); connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), mMainView, SLOT(newEvent(QDateTime,QDateTime))); connect(mAgendaView,SIGNAL(newEventSignal(QDate)), mMainView, SLOT(newEvent(QDate))); connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), mMainView, SLOT(editIncidence(Incidence *))); connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), mMainView, SLOT(showIncidence(Incidence *))); connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), mMainView, SLOT(deleteIncidence(Incidence *))); connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect(mAgendaView, SIGNAL( toggleExpand() ), mMainView, SLOT( toggleExpand() ) ); connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, SLOT( updateTodo( Todo *, int ) ) ); connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), mMainView, SIGNAL( todoModified( Todo *, int ))); connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); mAgendaView->readSettings(); mAgendaView->updateConfig(); } KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; showView( mAgendaView, full); KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; } void KOViewManager::showDayView() { mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); mFlagShowNextxDays = false; globalFlagBlockLabel = 1; globalFlagBlockAgenda = 1; if ( mCurrentAgendaView != 1 ) mCurrentAgendaView = -1; showAgendaView(); qApp->processEvents(); globalFlagBlockAgenda = 2; globalFlagBlockLabel = 0; mMainView->dateNavigator()->selectDates( 1 ); mCurrentAgendaView = 1 ; } void KOViewManager::showWorkWeekView() { mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); mFlagShowNextxDays = false; globalFlagBlockAgenda = 1; globalFlagBlockLabel = 1; if ( mCurrentAgendaView != 5 ) mCurrentAgendaView = -1; showAgendaView(); qApp->processEvents(); globalFlagBlockAgenda = 2; globalFlagBlockLabel = 0; mMainView->dateNavigator()->selectWorkWeek(); mCurrentAgendaView = 5 ; } void KOViewManager::showWeekView() { mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); mFlagShowNextxDays = false; globalFlagBlockAgenda = 1; globalFlagBlockLabel = 1; if ( mCurrentAgendaView != 7 ) mCurrentAgendaView = -1; showAgendaView(); qApp->processEvents(); globalFlagBlockAgenda = 2; globalFlagBlockLabel = 0; mMainView->dateNavigator()->selectWeek(); mCurrentAgendaView = 7 ; } void KOViewManager::showNextXView() { KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; globalFlagBlockAgenda = 1; if ( mCurrentAgendaView != 3 ) mCurrentAgendaView = -1; showAgendaView(KOPrefs::instance()->mFullViewMonth); globalFlagBlockAgenda = 2; mMainView->dateNavigator()->selectDates( QDate::currentDate(), KOPrefs::instance()->mNextXDays ); mFlagShowNextxDays = true; mCurrentAgendaView = 3 ; KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; } bool KOViewManager::showsNextDays() { return mFlagShowNextxDays; } void KOViewManager::createMonthView() { if (!mMonthView) { mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); addView(mMonthView); // mMonthView->show(); // SIGNALS/SLOTS FOR MONTH VIEW connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), mMainView, SLOT(newTodoDateTime(QDateTime, bool))); connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), mMainView, SLOT(newEvent(QDateTime))); connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), mMainView, SLOT(showIncidence(Incidence *))); connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), mMainView, SLOT(editIncidence(Incidence *))); connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), mMainView, SLOT(deleteIncidence(Incidence *))); connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( selectWeekNum( int ) ), mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); connect( mMonthView, SIGNAL( selectMonth() ), mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), mMainView, SLOT ( showDay( QDate ) ) ); connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); connect( mMonthView, SIGNAL(nextMonth() ), mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); connect( mMonthView, SIGNAL(prevMonth() ), mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), mMainView->dateNavigator(), SLOT( selectNextYear() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index 838583b..d5a8e3b 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h @@ -1,127 +1,128 @@ /* 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. 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 KOVIEWMANAGER_H #define KOVIEWMANAGER_H #include <qobject.h> #include <korganizer/baseview.h> class CalendarView; class KOListView; class KOAgendaView; class KOMonthView; class KOTimeSpanView; class KOTodoView; class KOWhatsNextView; class KOJournalView; using namespace KCal; /** This class manages the views of the calendar. It owns the objects and handles creation and selection. */ class KOViewManager : public QObject { Q_OBJECT public: KOViewManager( CalendarView * ); virtual ~KOViewManager(); /** changes the view to be the currently selected view */ void showView(KOrg::BaseView *, bool fullScreen = false ); void updateWNview(); void readSettings(KConfig *config); void writeSettings(KConfig *config); bool showsNextDays(); /** Read which view was shown last from config file */ void readCurrentView(KConfig *); /** Write which view is currently shown to config file */ void writeCurrentView(KConfig *); KOrg::BaseView *currentView(); void setDocumentId( const QString & ); void updateView( const QDate &start, const QDate &end ); void clearAllViews(); void raiseCurrentView( bool fullScreen = false , bool updateView = false); void addView(KOrg::BaseView *); Incidence *currentSelection(); QDate currentSelectionDate(); KOAgendaView *agendaView() const { return mAgendaView; } signals: void printWNV(); void signalFullScreen( bool ); void signalAgendaView( bool ); public slots: + void setDefaultCalendar(int); void slotprintWNV(); void showNextView(); void showMonth( const QDate & ); void showDateView( int, QDate ); void updateView(); void showWhatsNextView(); void showListView(); void showAgendaView( bool fullScreen = false ); void showDayView(); void showWorkWeekView(); void showWeekView(); void showNextXView(); void showMonthView(); void showMonthViewWeek(); void showTodoView(); void showJournalView(); void showTimeSpanView(); private: void resetDateSilent( QDate date , int days ); int flagResetViewChangeDate; QDate currentViewChangeDate; void createMonthView(); CalendarView *mMainView; int mCurrentAgendaView; KOAgendaView *mAgendaView; KOListView *mListView; KOMonthView *mMonthView; KOTodoView *mTodoView; KOWhatsNextView *mWhatsNextView; KOJournalView *mJournalView; KOTimeSpanView *mTimeSpanView; KOrg::BaseView *mCurrentView; // currently active event view int mAgendaViewMode; bool mFlagShowNextxDays; }; #endif diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2efa355..4652fe5 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -1,376 +1,377 @@ /* This file is part of libkcal. Copyright (c) 1998 Preston Brown Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef CALENDAR_H #define CALENDAR_H #include <qobject.h> #include <qstring.h> #include <qdatetime.h> #include <qptrlist.h> #include <qdict.h> #include "customproperties.h" #include "event.h" #include "todo.h" #include "journal.h" #include "calfilter.h" //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ class KConfig; namespace KCal { /** This is the main "calendar" object class for KOrganizer. It holds information like all appointments/events, user information, etc. etc. one calendar is associated with each CalendarView (@see calendarview.h). This is an abstract base class defining the interface to a calendar. It is implemented by subclasses like @see CalendarLocal, which use different methods to store and access the data. Ownership of events etc. is handled by the following policy: As soon as an event (or any other subclass of IncidenceBase) object is added to the Calendar by addEvent() it is owned by the Calendar object. The Calendar takes care of deleting it. All Events returned by the query functions are returned as pointers, that means all changes to the returned events are immediately visible in the Calendar. You shouldn't delete any Event object you get from Calendar. */ class Calendar : public QObject, public CustomProperties, public IncidenceBase::Observer { Q_OBJECT public: Calendar(); Calendar(const QString &timeZoneId); virtual ~Calendar(); Incidence * undoIncidence() { return mUndoIncidence; }; bool undoDeleteIncidence(); void deleteIncidence(Incidence *in); void resetTempSyncStat(); void resetPilotStat(int id); /** Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; virtual void addCalendar( Calendar* ) = 0; virtual bool addCalendarFile( QString name, int id ) = 0; virtual void setSyncEventsReadOnly() = 0; virtual void stopAllTodos() = 0; /** Sync changes in memory to persistant storage. */ virtual void save() = 0; virtual QPtrList<Event> getExternLastSyncEvents() = 0; virtual void removeSyncInfo( QString syncProfile) = 0; virtual bool isSaving() { return false; } /** Return the owner of the calendar's full name. */ const QString &getOwner() const; /** Set the owner of the calendar. Should be owner's full name. */ void setOwner( const QString &os ); /** Return the email address of the calendar owner. */ const QString &getEmail(); /** Set the email address of the calendar owner. */ void setEmail( const QString & ); /** Set time zone from a timezone string (e.g. -2:00) */ void setTimeZone( const QString &tz ); /** Set time zone from a minutes value (e.g. -60) */ void setTimeZone( int tz ); /** Return time zone as offest in minutes. */ int getTimeZone() const; /** Compute an ISO 8601 format string from the time zone. */ QString getTimeZoneStr() const; /** Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal values). */ void setTimeZoneId( const QString & ); /** Return time zone id. */ QString timeZoneId() const; /** Use local time, not UTC or a time zone. */ void setLocalTime(); /** Return whether local time is being used. */ bool isLocalTime() const; /** Add an incidence to calendar. @return true on success, false on error. */ virtual bool addIncidence( Incidence * ); // Adds an incidence and all relatedto incidences to the cal void addIncidenceBranch( Incidence * ); /** Return filtered list of all incidences of this calendar. */ virtual QPtrList<Incidence> incidences(); /** Return unfiltered list of all incidences of this calendar. */ virtual QPtrList<Incidence> rawIncidences(); /** Adds a Event to this calendar object. @param anEvent a pointer to the event to add @return true on success, false on error. */ virtual bool addEventNoDup( Event *event ) = 0; virtual bool addAnniversaryNoDup( Event *event ) = 0; virtual bool addEvent( Event *anEvent ) = 0; /** Delete event from calendar. */ virtual void deleteEvent( Event * ) = 0; /** Retrieves an event on the basis of the unique string ID. */ virtual Event *event( const QString &UniqueStr ) = 0; virtual Event *event( QString, QString ) = 0; /** Builds and then returns a list of all events that match for the date specified. useful for dayView, etc. etc. The calendar filter is applied. */ QPtrList<Event> events( const QDate &date, bool sorted = false); /** Get events, which occur on the given date. The calendar filter is applied. */ QPtrList<Event> events( const QDateTime &qdt ); /** Get events in a range of dates. If inclusive is set to true, only events are returned, which are completely included in the range. The calendar filter is applied. */ QPtrList<Event> events( const QDate &start, const QDate &end, bool inclusive = false); /** Return filtered list of all events in calendar. */ virtual QPtrList<Event> events(); /** Return unfiltered list of all events in calendar. */ virtual QPtrList<Event> rawEvents() = 0; /** Add a todo to the todolist. @return true on success, false on error. */ virtual bool addTodo( Todo *todo ) = 0; virtual bool addTodoNoDup( Todo *todo ) = 0; /** Remove a todo from the todolist. */ virtual void deleteTodo( Todo * ) = 0; virtual void deleteJournal( Journal * ) = 0; /** Return filterd list of todos. */ virtual QPtrList<Todo> todos(); /** Searches todolist for an event with this unique string identifier, returns a pointer or null. */ virtual Todo *todo( const QString &uid ) = 0; virtual Todo *todo( QString, QString ) = 0; /** Returns list of todos due on the specified date. */ virtual QPtrList<Todo> todos( const QDate &date ) = 0; /** Return unfiltered list of todos. */ virtual QPtrList<Todo> rawTodos() = 0; /** Add a Journal entry to calendar. @return true on success, false on error. */ virtual bool addJournal( Journal * ) = 0; /** Return Journal for given date. */ virtual Journal *journal( const QDate & ) = 0; + virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; /** Return Journal with given UID. */ virtual Journal *journal( const QString &UID ) = 0; /** Return list of all Journal entries. */ virtual QPtrList<Journal> journals() = 0; /** Searches all incidence types for an incidence with this unique string identifier, returns a pointer or null. */ Incidence* incidence( const QString&UID ); /** Setup relations for an incidence. */ virtual void setupRelations( Incidence * ); /** Remove all relations to an incidence */ virtual void removeRelations( Incidence * ); /** Set calendar filter, which filters events for the events() functions. The Filter object is owned by the caller. */ void setFilter( CalFilter * ); /** Return calendar filter. */ CalFilter *filter(); virtual QDateTime nextAlarm( int daysTo ) = 0; virtual QString nextSummary( ) const = 0; virtual void reInitAlarmSettings() = 0; virtual QDateTime nextAlarmEventDateTime() const = 0; virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; /** Return all alarms, which ocur in the given time interval. */ virtual Alarm::List alarms( const QDateTime &from, const QDateTime &to ) = 0; class Observer { public: virtual void calendarModified( bool, Calendar * ) = 0; }; void registerObserver( Observer * ); void setModified( bool ); /** Set product id returned by loadedProductId(). This function is only useful for the calendar loading code. */ void setLoadedProductId( const QString & ); /** Return product id taken from file that has been loaded. Returns QString::null, if no calendar has been loaded. */ QString loadedProductId(); int defaultCalendar(); void setDontDeleteIncidencesOnClose (); public slots: void setDefaultCalendar( int ); virtual void setCalendarEnabled( int id, bool enable ) = 0; virtual void setAlarmEnabled( int id, bool enable ) = 0; virtual void setReadOnly( int id, bool enable ) = 0; virtual void setDefaultCalendarEnabledOnly() = 0; virtual void setCalendarRemove( int id ) = 0; signals: void calendarChanged(); void calendarSaved(); void calendarLoaded(); void addAlarm(const QDateTime &qdt, const QString ¬i ); void removeAlarm(const QDateTime &qdt, const QString ¬i ); protected: /** Get unfiltered events, which occur on the given date. */ virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; /** Get unfiltered events, which occur on the given date. */ virtual QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ) = 0; /** Get events in a range of dates. If inclusive is set to true, only events are returned, which are completely included in the range. */ virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, bool inclusive = false ) = 0; Incidence *mNextAlarmIncidence; Incidence *mUndoIncidence; int mDefaultCalendar; bool mDeleteIncidencesOnClose; private: void init(); QString mOwner; // who the calendar belongs to QString mOwnerEmail; // email address of the owner int mTimeZone; // timezone OFFSET from GMT (MINUTES) bool mLocalTime; // use local time, not UTC or a time zone CalFilter *mFilter; CalFilter *mDefaultFilter; QString mTimeZoneId; Observer *mObserver; bool mNewObserver; bool mModified; QString mLoadedProductId; // This list is used to put together related todos QDict<Incidence> mOrphans; QDict<Incidence> mOrphanUids; }; } #endif diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 418bfca..ca64e66 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -395,531 +395,533 @@ void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted //QDateTime nextEvent; if ( mNextAlarmIncidence == 0 || incidence == 0 ) { computeNextAlarm = true; } else { if ( ! deleted ) { nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; if ( ok ) { if ( nextA < mNextAlarmDateTime ) { deRegisterAlarm(); mNextAlarmDateTime = nextA; mNextSummary = incidence->summary(); mNextAlarmEventDateTime = nextA.addSecs(offset ) ; mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); newNextAlarm = true; mNextAlarmIncidence = incidence; } else { if ( incidence == mNextAlarmIncidence ) { computeNextAlarm = true; } } } else { if ( mNextAlarmIncidence == incidence ) { computeNextAlarm = true; } } } else { // deleted if ( incidence == mNextAlarmIncidence ) { computeNextAlarm = true; } } } if ( computeNextAlarm ) { deRegisterAlarm(); nextA = nextAlarm( 1000 ); if (! mNextAlarmIncidence ) { return; } newNextAlarm = true; } if ( newNextAlarm ) registerAlarm(); } QString CalendarLocal:: getAlarmNotification() { QString ret; // this should not happen if (! mNextAlarmIncidence ) return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; Alarm* alarm = mNextAlarmIncidence->alarms().first(); if ( alarm->type() == Alarm::Procedure ) { ret = "proc_alarm" + alarm->programFile()+"+++"; } else { ret = "audio_alarm" +alarm->audioFile() +"+++"; } ret += "cal_alarm"+ mNextSummary.left( 25 ); if ( mNextSummary.length() > 25 ) ret += "\n" + mNextSummary.mid(25, 25 ); ret+= "\n"+mNextAlarmEventDateTimeString; return ret; } void CalendarLocal::registerAlarm() { mLastAlarmNotificationString = getAlarmNotification(); // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); // #ifndef DESKTOP_VERSION // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); // #endif } void CalendarLocal::deRegisterAlarm() { if ( mLastAlarmNotificationString.isNull() ) return; //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); mNextAlarmEventDateTime = QDateTime(); // #ifndef DESKTOP_VERSION // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); // #endif } QPtrList<Todo> CalendarLocal::todos( const QDate &date ) { QPtrList<Todo> todos; Todo *todo; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( !todo->calEnabled() ) continue; if ( todo->hasDueDate() && todo->dtDue().date() == date ) { todos.append( todo ); } } filter()->apply( &todos ); return todos; } void CalendarLocal::reInitAlarmSettings() { if ( !mNextAlarmIncidence ) { nextAlarm( 1000 ); } deRegisterAlarm(); mNextAlarmIncidence = 0; checkAlarmForIncidence( 0, false ); } QDateTime CalendarLocal::nextAlarm( int daysTo ) { QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); QDateTime next; Event *e; bool ok; bool found = false; int offset; mNextAlarmIncidence = 0; for( e = mEventList.first(); e; e = mEventList.next() ) { if ( !e->calEnabled() ) continue; next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; if ( ok ) { if ( next < nextA ) { nextA = next; found = true; mNextSummary = e->summary(); mNextAlarmEventDateTime = next.addSecs(offset ) ; mNextAlarmIncidence = (Incidence *) e; } } } Todo *t; for( t = mTodoList.first(); t; t = mTodoList.next() ) { if ( !t->calEnabled() ) continue; next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; if ( ok ) { if ( next < nextA ) { nextA = next; found = true; mNextSummary = t->summary(); mNextAlarmEventDateTime = next.addSecs(offset ); mNextAlarmIncidence = (Incidence *) t; } } } if ( mNextAlarmIncidence ) { mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); mNextAlarmDateTime = nextA; } return nextA; } Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) { return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); } Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) { Alarm::List alarms; Event *e; for( e = mEventList.first(); e; e = mEventList.next() ) { if ( !e->calEnabled() ) continue; if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); else appendAlarms( alarms, e, from, to ); } Todo *t; for( t = mTodoList.first(); t; t = mTodoList.next() ) { if ( !t->calEnabled() ) continue; appendAlarms( alarms, t, from, to ); } return alarms; } void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, const QDateTime &from, const QDateTime &to ) { QPtrList<Alarm> alarmList = incidence->alarms(); Alarm *alarm; for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; if ( alarm->enabled() ) { if ( alarm->time() >= from && alarm->time() <= to ) { alarms.append( alarm ); } } } } void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, const QDateTime &from, const QDateTime &to ) { QPtrList<Alarm> alarmList = incidence->alarms(); Alarm *alarm; QDateTime qdt; for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { if (incidence->recursOn(from.date())) { qdt.setTime(alarm->time().time()); qdt.setDate(from.date()); } else qdt = alarm->time(); // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); if ( alarm->enabled() ) { if ( qdt >= from && qdt <= to ) { alarms.append( alarm ); } } } } /****************************** PROTECTED METHODS ****************************/ // after changes are made to an event, this should be called. void CalendarLocal::update( IncidenceBase *incidence ) { incidence->setSyncStatus( Event::SYNCMOD ); incidence->setLastModified( QDateTime::currentDateTime() ); // we should probably update the revision number here, // or internally in the Event itself when certain things change. // need to verify with ical documentation. setModified( true ); } void CalendarLocal::insertEvent( Event *event ) { if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); } QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) { QPtrList<Event> eventList; Event *event; for( event = mEventList.first(); event; event = mEventList.next() ) { if ( !event->calEnabled() ) continue; if ( event->doesRecur() ) { if ( event->isMultiDay() ) { int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); int i; for ( i = 0; i <= extraDays; i++ ) { if ( event->recursOn( qd.addDays( -i ) ) ) { eventList.append( event ); break; } } } else { if ( event->recursOn( qd ) ) eventList.append( event ); } } else { if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { eventList.append( event ); } } } if ( !sorted ) { return eventList; } // kdDebug(5800) << "Sorting events for date\n" << endl; // now, we have to sort it based on dtStart.time() QPtrList<Event> eventListSorted; Event *sortEvent; for ( event = eventList.first(); event; event = eventList.next() ) { sortEvent = eventListSorted.first(); int i = 0; while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) { i++; sortEvent = eventListSorted.next(); } eventListSorted.insert( i, event ); } return eventListSorted; } QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, bool inclusive ) { Event *event = 0; QPtrList<Event> eventList; // Get non-recurring events for( event = mEventList.first(); event; event = mEventList.next() ) { if ( !event->calEnabled() ) continue; if ( event->doesRecur() ) { QDate rStart = event->dtStart().date(); bool found = false; if ( inclusive ) { if ( rStart >= start && rStart <= end ) { // Start date of event is in range. Now check for end date. // if duration is negative, event recurs forever, so do not include it. if ( event->recurrence()->duration() == 0 ) { // End date set QDate rEnd = event->recurrence()->endDate(); if ( rEnd >= start && rEnd <= end ) { // End date within range found = true; } } else if ( event->recurrence()->duration() > 0 ) { // Duration set // TODO: Calculate end date from duration. Should be done in Event // For now exclude all events with a duration. } } } else { bool founOne; QDate next = event->getNextOccurence( start, &founOne ).date(); if ( founOne ) { if ( next <= end ) { found = true; } } /* // crap !!! if ( rStart <= end ) { // Start date not after range if ( rStart >= start ) { // Start date within range found = true; } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever found = true; } else if ( event->recurrence()->duration() == 0 ) { // End date set QDate rEnd = event->recurrence()->endDate(); if ( rEnd >= start && rEnd <= end ) { // End date within range found = true; } } else { // Duration set // TODO: Calculate end date from duration. Should be done in Event // For now include all events with a duration. found = true; } } */ } if ( found ) eventList.append( event ); } else { QDate s = event->dtStart().date(); QDate e = event->dtEnd().date(); if ( inclusive ) { if ( s >= start && e <= end ) { eventList.append( event ); } } else { if ( ( e >= start && s <= end ) ) { eventList.append( event ); } } } } return eventList; } QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) { return rawEventsForDate( qdt.date() ); } QPtrList<Event> CalendarLocal::rawEvents() { QPtrList<Event> el; for ( Event *it = mEventList.first(); it; it = mEventList.next() ) if ( it->calEnabled() ) el.append( it ); return el; } bool CalendarLocal::addJournal(Journal *journal) { - if ( journal->dtStart().isValid()) - kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; - else - kdDebug(5800) << "Adding Journal without a DTSTART" << endl; - mJournalList.append(journal); journal->registerObserver( this ); setModified( true ); journal->setCalID( mDefaultCalendar ); journal->setCalEnabled( true ); return true; } void CalendarLocal::deleteJournal( Journal *journal ) { if ( mUndoIncidence ) delete mUndoIncidence; mUndoIncidence = journal->clone(); mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); if ( mJournalList.removeRef(journal) ) { setModified( true ); } } +QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) +{ + QPtrList<Journal> el; + for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) + if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); + return el; +} Journal *CalendarLocal::journal( const QDate &date ) { // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->calEnabled() && it->dtStart().date() == date ) return it; return 0; } Journal *CalendarLocal::journal( const QString &uid ) { Journal * retVal = 0; for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->calEnabled() && it->uid() == uid ) { if ( retVal ) { if ( retVal->calID() > it->calID() ) { retVal = it; } } else { retVal = it; } } return retVal; } QPtrList<Journal> CalendarLocal::journals() { QPtrList<Journal> el; for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->calEnabled() ) el.append( it ); return el; } void CalendarLocal::setCalendarRemove( int id ) { { QPtrList<Event> EventList = mEventList; Event * ev = EventList.first(); while ( ev ) { if ( ev->calID() == id ) deleteEvent( ev ); ev = EventList.next(); } } { QPtrList<Todo> TodoList = mTodoList; Todo * ev = TodoList.first(); while ( ev ) { if ( ev->calID() == id ) deleteTodo( ev ); ev = TodoList.next(); } } { QPtrList<Journal> JournalList = mJournalList; Journal * ev = JournalList.first(); while ( ev ) { if ( ev->calID() == id ) deleteJournal( ev ); ev = JournalList.next(); } } if ( mUndoIncidence ) delete mUndoIncidence; mUndoIncidence = 0; } void CalendarLocal::setCalendarEnabled( int id, bool enable ) { for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->calID() == id ) it->setCalEnabled( enable ); for ( Event *it = mEventList.first(); it; it = mEventList.next() ) if ( it->calID() == id ) it->setCalEnabled( enable ); for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) if ( it->calID() == id ) it->setCalEnabled( enable ); } void CalendarLocal::setReadOnly( int id, bool enable ) { for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->calID() == id ) it->setReadOnly( enable ); for ( Event *it = mEventList.first(); it; it = mEventList.next() ) if ( it->calID() == id ) it->setReadOnly( enable ); for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) if ( it->calID() == id ) it->setReadOnly( enable ); } void CalendarLocal::setAlarmEnabled( int id, bool enable ) { for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->calID() == id ) it->setAlarmEnabled( enable ); for ( Event *it = mEventList.first(); it; it = mEventList.next() ) if ( it->calID() == id ) it->setAlarmEnabled( enable ); for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) if ( it->calID() == id ) it->setAlarmEnabled( enable ); reInitAlarmSettings(); } void CalendarLocal::setDefaultCalendarEnabledOnly() { for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) it->setCalEnabled( it->calID() == mDefaultCalendar ); for ( Event *it = mEventList.first(); it; it = mEventList.next() ) it->setCalEnabled( it->calID() == mDefaultCalendar); for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) it->setCalEnabled( it->calID() == mDefaultCalendar); } diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index d32597f..98d16a3 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -1,226 +1,227 @@ /* This file is part of libkcal. Copyright (c) 1998 Preston Brown Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef KCAL_CALENDARLOCAL_H #define KCAL_CALENDARLOCAL_H #include "calendar.h" namespace KCal { class CalFormat; /** This class provides a calendar stored as a local file. */ class CalendarLocal : public Calendar { public: /** Constructs a new calendar, with variables initialized to sane values. */ CalendarLocal(); /** Constructs a new calendar, with variables initialized to sane values. */ CalendarLocal( const QString &timeZoneId ); ~CalendarLocal(); void addCalendar( Calendar* ); bool addCalendarFile( QString name, int id ); void setSyncEventsReadOnly(); void stopAllTodos(); /** Loads a calendar on disk in vCalendar or iCalendar format into the current calendar. Any information already present is lost. @return true, if successfull, false on error. @param fileName the name of the calendar on disk. */ bool load( const QString &fileName ); /** Writes out the calendar to disk in the specified \a format. CalendarLocal takes ownership of the CalFormat object. @return true, if successfull, false on error. @param fileName the name of the file */ bool save( const QString &fileName, CalFormat *format = 0 ); /** Clears out the current calendar, freeing all used memory etc. etc. */ void close(); void save() {} /** Add Event to calendar. */ void removeSyncInfo( QString syncProfile); bool addAnniversaryNoDup( Event *event ); bool addEventNoDup( Event *event ); bool addEvent( Event *event ); /** Deletes an event from this calendar. */ void deleteEvent( Event *event ); /** Retrieves an event on the basis of the unique string ID. */ Event *event( const QString &uid ); /** Return unfiltered list of all events in calendar. */ QPtrList<Event> rawEvents(); QPtrList<Event> getExternLastSyncEvents(); /** Add a todo to the todolist. */ bool addTodo( Todo *todo ); bool addTodoNoDup( Todo *todo ); /** Remove a todo from the todolist. */ void deleteTodo( Todo * ); /** Searches todolist for an event with this unique string identifier, returns a pointer or null. */ Todo *todo( const QString &uid ); /** Return list of all todos. */ QPtrList<Todo> rawTodos(); /** Returns list of todos due on the specified date. */ QPtrList<Todo> todos( const QDate &date ); /** Return list of all todos. Workaround because compiler does not recognize function of base class. */ QPtrList<Todo> todos() { return Calendar::todos(); } /** Add a Journal entry to calendar. */ bool addJournal( Journal * ); /** Remove a Journal from the calendar. */ void deleteJournal( Journal * ); /** Return Journal for given date. */ Journal *journal( const QDate & ); + QPtrList<Journal> journals4Date( const QDate & ); /** Return Journal with given UID. */ Journal *journal( const QString &uid ); /** Return list of all Journals stored in calendar. */ QPtrList<Journal> journals(); /** Return all alarms, which ocur in the given time interval. */ Alarm::List alarms( const QDateTime &from, const QDateTime &to ); /** Return all alarms, which ocur before given date. */ Alarm::List alarmsTo( const QDateTime &to ); QDateTime nextAlarm( int daysTo ) ; QDateTime nextAlarmEventDateTime() const; void checkAlarmForIncidence( Incidence *, bool deleted ) ; void registerAlarm(); void deRegisterAlarm(); QString getAlarmNotification(); QString nextSummary() const ; /** This method should be called whenever a Event is modified directly via it's pointer. It makes sure that the calendar is internally consistent. */ void update( IncidenceBase *incidence ); /** Builds and then returns a list of all events that match for the date specified. useful for dayView, etc. etc. */ QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); /** Get unfiltered events for date \a qdt. */ QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); /** Get unfiltered events in a range of dates. If inclusive is set to true, only events are returned, which are completely included in the range. */ QPtrList<Event> rawEvents( const QDate &start, const QDate &end, bool inclusive = false ); Todo *todo( QString, QString ); Event *event( QString, QString ); public slots: void setCalendarEnabled( int id, bool enable ); void setAlarmEnabled( int id, bool enable ); void setReadOnly( int id, bool enable ); void setDefaultCalendarEnabledOnly(); void setCalendarRemove( int id ); protected: // Event* mNextAlarmEvent; QString mNextSummary; QString mNextAlarmEventDateTimeString; QString mLastAlarmNotificationString; QDateTime mNextAlarmEventDateTime; QDateTime mNextAlarmDateTime; void reInitAlarmSettings(); /** Notification function of IncidenceBase::Observer. */ void incidenceUpdated( IncidenceBase *i ) { update( i ); } /** inserts an event into its "proper place" in the calendar. */ void insertEvent( Event *event ); /** Append alarms of incidence in interval to list of alarms. */ void appendAlarms( Alarm::List &alarms, Incidence *incidence, const QDateTime &from, const QDateTime &to ); /** Append alarms of recurring events in interval to list of alarms. */ void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, const QDateTime &from, const QDateTime &to ); private: void init(); QPtrList<Event> mEventList; QPtrList<Todo> mTodoList; QPtrList<Journal> mJournalList; }; } #endif |