-rw-r--r-- | korganizer/calendarview.cpp | 42 | ||||
-rw-r--r-- | korganizer/calendarview.h | 5 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 8 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 1 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 16 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 7 |
8 files changed, 52 insertions, 34 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 28b17a5..31e103d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -305,128 +305,133 @@ class KOBeamPrefs : public QDialog 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 there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), 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("Change category list now!"), 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() { + flag_blockConflict = false; + flag_blockScrollBar = false; + flag_checkFileFirsttime = true; + flag_clearallviewsEventDisplay = false; + flag_clearallviewsupdateView = false; mNextAlarmDateTime = QDateTime::currentDateTime(); setFocusPolicy (NoFocus ); mViewerCallerIsSearchDialog = false; mBlockShowDates = false; mConflictingEvent = 0; mDatePickerMode = 0; mCurrentSyncDevice = ""; 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 ) { @@ -600,309 +605,306 @@ void CalendarView::init() 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 mEventViewerDialog; //kdDebug() << "~CalendarView() done" << endl; } void CalendarView::nextConflict( bool all, bool allday ) { - static bool block = false; - if ( block ) return; - block = true; + if ( flag_blockConflict ) return; + flag_blockConflict = true; QPtrList<Event> testlist = mCalendar->events(); Event * test = testlist.first(); while ( test ) { test->setTagged( false ); test = testlist.next(); } QTime st ( 0,0,0); if ( mViewManager->currentView() == mViewManager->agendaView() ) st = mViewManager->agendaView()->agenda()->getEndTime(); //qDebug("time %s ", st.toString().latin1()); QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); QDateTime conflict; QDateTime retVal; bool found = false; Event * cE = 0; Event * cE2 = 0; QPtrList<Event> testlist2 = testlist; test = testlist.first(); bool skip = false; topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); //QTime tm; //tm.start(); while ( test ) { qApp->processEvents(); skip = false; if ( !all ) skip = ( allday != test->doesFloat() ); if ( !skip ) { if ( found ) skip = !test->matchTime( &startDT, &conflict ); else skip = !test->matchTime( &startDT, 0 ); } if ( !skip ) { Event * test2 = testlist2.first(); while ( test2 ) { skip = test2->isTagged(); if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); if ( !skip ) { if ( found ) skip = !test2->matchTime( &startDT, &conflict ); else skip = !test2->matchTime( &startDT, 0 ); } if ( !skip ) { if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { //qDebug("overlap "); if ( ! found ) { if ( retVal >= startDT ) { conflict = retVal; cE = test; cE2 = test2; found = true; } } else { if ( retVal >= startDT && retVal < conflict ) { conflict = retVal; cE = test; cE2 = test2; } } } } test2 = testlist2.next(); } } test->setTagged( true ); test = testlist.next(); } //qDebug("Search time : %d", tm.elapsed()); if ( found ) { if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) mViewManager->showDayView(); mNavigator->slotDaySelect( conflict.date() ); int hour = conflict.time().hour(); mViewManager->agendaView()->setStartHour( hour ); topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); - block = false; + flag_blockConflict = false; return; } topLevelWidget()->setCaption( i18n("No conflict found") ); //qDebug("No conflict found "); - block = false; + flag_blockConflict = false; return; } void CalendarView::conflictAll() { nextConflict ( true, true ); } void CalendarView::conflictAllday() { nextConflict ( false, true ); } void CalendarView::conflictNotAll() { nextConflict ( false, false ); } void CalendarView::setCalReadOnly( int id, bool readO ) { if ( readO ) { emit save(); } mCalendar->setReadOnly( id, readO ); } void CalendarView::setScrollBarStep(int val ) { #ifdef DESKTOP_VERSION mDateScrollBar->setLineStep ( val ); #endif } void CalendarView::scrollBarValue(int val ) { #ifdef DESKTOP_VERSION if ( QApplication::desktop()->width() < 800 ) return; - static bool block = false; - if ( block ) return; - block = true; + if ( flag_blockScrollBar ) return; + flag_blockScrollBar = true; int count = mNavigator->selectedDates().count(); int day = mNavigator->selectedDates().first().dayOfYear(); int stepdays = val; if ( mDateScrollBar->lineStep () <= count ) { //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); //qDebug("VAL %d ",val ); stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); stepdays = day+stepdays; if ( stepdays < 0 ) stepdays = 0; } if ( stepdays == day ) { - block = false; + flag_blockScrollBar = false; return; } int year = mNavigator->selectedDates().first().year(); QDate d ( year,1,1 ); mNavigator->selectDates( d.addDays( stepdays-1) , count ); - block = false; + flag_blockScrollBar = false; #endif } void CalendarView::updateView(const QDate &start, const QDate &end) { #ifdef DESKTOP_VERSION if ( ! mDateScrollBar->draggingSlider () ) { int dof = start.dayOfYear(); //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); if ( dof != mDateScrollBar->value() ) { mDateScrollBar->blockSignals( true ); mDateScrollBar->setValue( start.dayOfYear()); mDateScrollBar->blockSignals( false ); } } #endif mTodoList->updateView(); mViewManager->updateView(start, end); //mDateNavigator->updateView(); } void CalendarView::checkFiles() { QString message; QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; KopiCalendarFile * cal = calendars.first(); while ( cal ) { if ( cal->mErrorOnLoad ) { message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; } cal = calendars.next(); } if ( !message.isEmpty() ) { message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); } - static bool firstTime = true; - if ( firstTime ) { - firstTime = false; + if ( flag_checkFileFirsttime ) { + flag_checkFileFirsttime = false; QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); } } 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(); } #if 0 // for creating timetracker test data qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); Todo * nt; @@ -2955,137 +2957,136 @@ void CalendarView::updateConfig() { if ( KOPrefs::instance()->mUseAppColors ) QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); emit configChanged(); mTodoList->updateConfig(); // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); // To make the "fill window" configurations work //mViewManager->raiseCurrentView(); } void CalendarView::eventChanged(Event *event) { changeEventDisplay(event,KOGlobals::EVENTEDITED); //updateUnmanagedViews(); } void CalendarView::eventAdded(Event *event) { changeEventDisplay(event,KOGlobals::EVENTADDED); } void CalendarView::eventToBeDeleted(Event *) { kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; } void CalendarView::eventDeleted() { changeEventDisplay(0,KOGlobals::EVENTDELETED); } void CalendarView::changeTodoDisplay(Todo *which, int action) { changeIncidenceDisplay((Incidence *)which, action); mDateNavigator->updateView(); //LR //mDialogManager->updateSearchDialog(); if (which) { mViewManager->updateWNview(); //mTodoList->updateView(); } } void CalendarView::changeIncidenceDisplay(Incidence *which, int action) { updateUnmanagedViews(); //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); if ( action == KOGlobals::EVENTDELETED ) { //delete mCalendar->checkAlarmForIncidence( 0, true ); if ( mEventViewerDialog ) mEventViewerDialog->hide(); } else mCalendar->checkAlarmForIncidence( which , false ); } // most of the changeEventDisplays() right now just call the view's // total update mode, but they SHOULD be recoded to be more refresh-efficient. void CalendarView::changeEventDisplay(Event *which, int action) { // kdDebug() << "CalendarView::changeEventDisplay" << endl; changeIncidenceDisplay((Incidence *)which, action); - static bool clearallviews = false; if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { - if ( clearallviews ) { + if ( flag_clearallviewsEventDisplay ) { clearAllViews(); - clearallviews = false; + flag_clearallviewsEventDisplay = false; } return; } - clearallviews = true; + flag_clearallviewsEventDisplay = true; mDateNavigator->updateView(); //mDialogManager->updateSearchDialog(); if (which) { // If there is an event view visible update the display mViewManager->currentView()->changeEventDisplay(which,action); // TODO: check, if update needed // if (which->getTodoStatus()) { mTodoList->updateView(); if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { mConflictingEvent = which ; int time = 1000; #ifdef DESKTOP_VERSION time = 500; #endif bool checkC = false; if ( mConflictingEvent->doesFloat() ) { checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay || KOPrefs::instance()->mCheckConflictsAllDayNonAD; } else { checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay || KOPrefs::instance()->mCheckConflictsNonADNonAD; } if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) checkC = false; if ( checkC ) QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); } // } } else { mViewManager->currentView()->updateView(); } } void CalendarView::checkConflictForEvent() { if (!KOPrefs::instance()->mConfirm) return; if ( ! mConflictingEvent ) return; Event * conflictingEvent = mConflictingEvent; mConflictingEvent = 0; QDateTime current = QDateTime::currentDateTime(); if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { return; } CalFilter *filterIN = 0; CalFilter *filterALL = 0; CalFilter *filter = mFilters.first(); while(filter) { if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) filterIN = filter; if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) filterALL = filter; filter = mFilters.next(); } if ( filterIN ) { if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { return; } } QPtrList<Event> testlist = mCalendar->events(); Event * test = testlist.first(); QDateTime conflict; QDateTime retVal; bool found = false; @@ -3116,137 +3117,136 @@ void CalendarView::checkConflictForEvent() skip = !test->matchTime( ¤t, &conflict ); else skip = !test->matchTime( ¤t, 0 ); if ( !skip ) { if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { if ( ! found ) { conflict = retVal; cE = test; } else { if ( retVal < conflict ) { conflict = retVal; cE = test; } } found = true; } } } } test = testlist.next(); } topLevelWidget()->setCaption( i18n("KO/Pi") ); if ( found ) { QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; qApp->processEvents(); int km = KMessageBox::warningContinueCancel(this,mess, i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); if ( km != KMessageBox::Continue ) { return; } if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) mViewManager->showDayView(); mNavigator->slotDaySelect( conflict.date() ); int hour = conflict.time().hour(); mViewManager->agendaView()->setStartHour( hour ); topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); } else topLevelWidget()->setCaption( i18n("No conflict found") ); return; } void CalendarView::updateTodoViews() { mTodoList->updateView(); mViewManager->currentView()->updateView(); } void CalendarView::clearAllViews() { mTodoList->clearList(); mViewManager->clearAllViews(); SearchDialog * sd = mDialogManager->getSearchDialog(); if ( sd ) { KOListView* kol = sd->listview(); if ( kol ) kol->clearList(); } } void CalendarView::updateView() { - static bool clearallviews = false; if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { - if ( clearallviews ) { + if ( flag_clearallviewsupdateView ) { clearAllViews(); - clearallviews = false; + flag_clearallviewsupdateView = false; } return; } - clearallviews = true; + flag_clearallviewsupdateView = true; DateList tmpList = mNavigator->selectedDates(); if ( KOPrefs::instance()->mHideNonStartedTodos ) mTodoList->updateView(); // We assume that the navigator only selects consecutive days. updateView( tmpList.first(), tmpList.last() ); } void CalendarView::updateUnmanagedViews() { mDateNavigator->updateDayMatrix(); } int CalendarView::msgItemDelete(const QString name) { return KMessageBox::warningContinueCancel(this,name +"\n\n"+ i18n("This item will be\npermanently deleted."), i18n("KO/Pi Confirmation"),i18n("Delete")); } void CalendarView::edit_cut() { Event *anEvent=0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } DndFactory factory( mCalendar ); factory.cutIncidence(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); } void CalendarView::edit_copy() { Event *anEvent=0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } DndFactory factory( mCalendar ); factory.copyIncidence(anEvent); } void CalendarView::edit_paste() { diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 0924f07..80f7ed4 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -490,128 +490,133 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void showDatePickerPopup() ; void moveIncidence(Incidence *) ; void beamIncidence(Incidence *) ; void beamCalendar() ; void beamFilteredCalendar() ; void beamIncidenceList(QPtrList<Incidence>) ; void manageCategories(); void editCategories(); int addCategories(); void removeCategories(); void setSyncDevice( QString ); void setSyncName( QString ); void showDay( QDate ); void undo_delete(); protected slots: void resetFocus(); void scrollBarValue(int); void slotViewerClosed(); void timerAlarm(); void suspendAlarm(); void beamDone( Ir *ir ); /** Select a view or adapt the current view to display the specified dates. */ void showDates( const KCal::DateList & ); void selectWeekNum ( int ); void checkConflictForEvent(); public: void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); // show a standard warning // returns KMsgBox::yesNoCancel() int msgCalModified(); virtual bool sync(KSyncManager* manager, QString filename, int mode); virtual bool syncExternal(KSyncManager* manager, QString resource); virtual void removeSyncInfo( QString syncProfile); void setSyncManager(KSyncManager* manager); void setLoadedFileVersion(QDateTime); bool checkFileVersion(QString fn); bool checkAllFileVersions(); bool checkFileChanged(QString fn); Event* getLastSyncEvent(); /** Adapt navigation units correpsonding to step size of navigation of the * current view. */ void adaptNavigationUnits(); bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); //Attendee* getYourAttendee(Event *event); void setBlockShowDates( bool b ) { mBlockShowDates = b ;} void setScrollBarStep(int val ); protected: Event *mConflictingEvent; void schedule(Scheduler::Method, Incidence *incidence = 0); // returns KMsgBox::OKCandel() int msgItemDelete(const QString name); void showEventEditor(); void showTodoEditor(); Todo *selectedTodo(); private: #ifdef DESKTOP_VERSION QScrollBar * mDateScrollBar; #endif + bool flag_blockConflict; + bool flag_blockScrollBar; + bool flag_checkFileFirsttime; + bool flag_clearallviewsEventDisplay; + bool flag_clearallviewsupdateView; QDateTime mNextAlarmDateTime; bool mViewerCallerIsSearchDialog; bool mBlockShowDates; KSyncManager* mSyncManager; AlarmDialog * mAlarmDialog; QString mAlarmNotification; QString mSuspendAlarmNotification; QTimer* mSuspendTimer; QTimer* mAlarmTimer; QTimer* mRecheckAlarmTimer; void computeAlarm( QString ); void startAlarm( QString, QString ); void setSyncEventsReadOnly(); QDateTime loadedFileVersion; void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); void checkExternalId( Incidence * inc ); int mGlobalSyncMode; QString mCurrentSyncDevice; QString mCurrentSyncName; void init(); int mDatePickerMode; bool mFlagEditDescription; QDateTime mLastCalendarSync; void createPrinter(); void calendarModified( bool, Calendar * ); CalPrinter *mCalPrinter; QSplitter *mPanner; QSplitter *mLeftSplitter; KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; QWidgetStack *mRightFrame; KDatePicker* mDatePicker; QVBox* mDateFrame; DateNavigatorContainer *mDateNavigator; // widget showing small month view. KOFilterView *mFilterView; KOCalEditView *mCalEditView; ResourceView *mResourceView; // calendar object for this viewing instance Calendar *mCalendar; CalendarResourceManager *mResourceManager; FileStorage *mStorage; DateNavigator *mNavigator; KOViewManager *mViewManager; KODialogManager *mDialogManager; // Calendar filters QPtrList<CalFilter> mFilters; // various housekeeping variables. bool mModified; // flag indicating if calendar is modified bool mReadOnly; // flag indicating if calendar is read-only QDate mSaveSingleDate; diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index c1b149f..6e65a03 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -316,128 +316,129 @@ void EventIndicator::drawContents(QPainter *p) int cellWidth = contentsRect().right()/mColumns; int xOffset = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : i*cellWidth + (cellWidth -mPixmap.width()) /2; p->drawPixmap(QPoint(1+xOffset,0),mPixmap); } } } else { han->repaint(); //mPaintWidget->setBackgroundColor( red ); QPainter pa( han ); int i; bool setColor = false; for(i=0;i<mColumns;++i) { if (mEnabled[i]) { setColor = true; int cellWidth = contentsRect().right()/mColumns; int xOffset = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : i*cellWidth + cellWidth/2 -mPixmap.width()/2; pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); //qDebug("222draw pix %d ",xOffset ); } } pa.end(); } } void EventIndicator::setXOffset( int x ) { mXOffset = x; } void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) { mPaintWidget = w; setMaximumHeight(0); setMinimumHeight(0); } void EventIndicator::changeColumns(int columns) { mColumns = columns; mEnabled.resize(mColumns); update(); } void EventIndicator::enableColumn(int column, bool enable) { mEnabled[column] = enable; } //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : KOEventView (cal,parent,name) { + flag_blockfillAgenda = false; mBlockUpdating = true; mStartHour = 8; mSelectedDates.append(QDate::currentDate()); mLayoutDayLabels = 0; mDayLabelsFrame = 0; mDayLabels = 0; bool isRTL = KOGlobals::self()->reverseLayout(); QPixmap expandPix; if ( KOPrefs::instance()->mVerticalScreen ) { expandPix = SmallIcon( "1updownarrow" ); } else { expandPix = SmallIcon("1leftrightarrow" ); } QBoxLayout *topLayout = new QVBoxLayout(this); // Create day name labels for agenda columns // Create agenda splitter mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); topLayout->addWidget( mSplitterAgenda ); mAllDayFrame = new QHBox(mSplitterAgenda); mAllDayFrame->setFocusPolicy(NoFocus); QWidget *agendaFrame = new QWidget(mSplitterAgenda); agendaFrame->setFocusPolicy(NoFocus); // Create all-day agenda widget mDummyAllDayLeft = new QVBox( mAllDayFrame ); mExpandButton = new QPushButton(mDummyAllDayLeft); mExpandButton->setPixmap( expandPix ); int widebut = mExpandButton->sizeHint().width()+4; int heibut = mExpandButton->sizeHint().height()+4; if ( heibut > widebut ) widebut = heibut ; //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, // QSizePolicy::Fixed ) ); mExpandButton->setFixedSize( widebut, widebut); connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); mExpandButton->setFocusPolicy(NoFocus); mAllDayAgenda = new KOAgenda(1,mAllDayFrame); mAllDayAgenda->setFocusPolicy(NoFocus); QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); // Create event context menu for all day agenda //mAllDayAgendaPopup = eventPopup(); // Create agenda frame QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); // QHBox *agendaFrame = new QHBox(splitterAgenda); // create event indicator bars mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); #ifndef DESKTOP_VERSION mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); #endif mDayLabelsFrame = new QHBox(agendaFrame); //topLayout->addWidget(mDayLabelsFrame); mDayLabels = new QFrame (mDayLabelsFrame); mLayoutDayLabels = new QHBoxLayout(mDayLabels); agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); @@ -1081,132 +1082,131 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) to->setDtDue(endDt); if ( to->hasStartDate() ) { if (to->dtStart() >= to->dtDue() ) to->setDtStart(to->dtDue().addDays( -2 )); } } //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); item->incidence()->setRevision(item->incidence()->revision()+1); item->setItemDate(startDt.date()); //item->updateItem(); if ( item->incidence()->typeID() == todoID ) { emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); } else emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); item->updateItem(); } void KOAgendaView::showDates( const QDate &start, const QDate &end ) { // kdDebug() << "KOAgendaView::selectDates" << endl; mSelectedDates.clear(); // qDebug("KOAgendaView::showDates "); QDate d = start; while (d <= end) { mSelectedDates.append(d); d = d.addDays( 1 ); } // and update the view fillAgenda(); } void KOAgendaView::showEvents(QPtrList<Event>) { kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; } void KOAgendaView::changeEventDisplay(Event *, int) { // qDebug("KOAgendaView::changeEventDisplay "); // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; // this should be re-written to be MUCH smarter. Right now we // are just playing dumb. fillAgenda(); } void KOAgendaView::fillAgenda(const QDate &) { // qDebug("KOAgendaView::fillAgenda "); fillAgenda(); } void KOAgendaView::fillAgenda() { if ( globalFlagBlockStartup ) return; if ( globalFlagBlockAgenda == 1 ) return; - static bool onlyOne = false; - if ( onlyOne ) + if ( flag_blockfillAgenda ) return; - onlyOne = true; + flag_blockfillAgenda = true; //if ( globalFlagBlockAgenda == 2 ) //globalFlagBlockAgenda = 0; // globalFlagBlockPainting = false; if ( globalFlagBlockAgenda == 0 ) globalFlagBlockAgenda = 1; // clearView(); //qDebug("fillAgenda()++++ "); globalFlagBlockAgendaItemPaint = 1; mAllDayAgenda->changeColumns(mSelectedDates.count()); mAgenda->changeColumns(mSelectedDates.count()); qApp->processEvents(); mEventIndicatorTop->changeColumns(mSelectedDates.count()); mEventIndicatorBottom->changeColumns(mSelectedDates.count()); setHolidayMasks(); mMinY.resize(mSelectedDates.count()); mMaxY.resize(mSelectedDates.count()); QPtrList<Event> dayEvents; // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. // Therefore, gtodoset all of them. QPtrList<Todo> todos = calendar()->todos(); mAgenda->setDateList(mSelectedDates); QDate today = QDate::currentDate(); DateList::ConstIterator dit; int curCol = 0; int maxCol = mSelectedDates.count()-1; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { QDate currentDate = *dit; // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() // << endl; dayEvents = calendar()->events(currentDate,false); // Default values, which can never be reached mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; unsigned int numEvent; //qDebug("+++++NUMEVENT %d", dayEvents.count()); for(numEvent=0;numEvent<dayEvents.count();++numEvent) { Event *event = dayEvents.at(numEvent); if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) if ( event->uid().left(15) == QString("last-syncEvent-") ) continue; // kdDebug() << " Event: " << event->summary() << endl; int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; if (event->doesFloat()) { if (event->doesRecur()) { if (event->isMultiDay() ) { endX = endX - beginX;// endX is now number of days if ( event->recursOn( currentDate ) ) { endX += curCol; beginX = curCol; @@ -1293,129 +1293,129 @@ void KOAgendaView::fillAgenda() // ---------- [display Todos -------------- unsigned int numTodo; for (numTodo = 0; numTodo < todos.count(); ++numTodo) { Todo *todo = todos.at(numTodo); if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. // Already completed items can be displayed on their original due date //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; bool fillIn = false; if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) fillIn = true; if ( ! fillIn && !todo->hasCompletedDate() ) fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); if ( fillIn ) { if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue if ( KOPrefs::instance()->mShowTodoInAgenda ) mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); } else { QDateTime dt; if ( todo->hasCompletedDate() ) dt = todo->completed(); else dt = todo->dtDue();; int endY = mAgenda->timeToY(dt.time()) - 1; int hi = (18/KOPrefs::instance()->mHourSize); //qDebug("hei %d ",KOPrefs::instance()->mHourSize); int startY = endY -hi; mAgenda->insertItem(todo,currentDate,curCol,startY,endY); if (startY < mMinY[curCol]) mMinY[curCol] = startY; if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } } } // ---------- display Todos] -------------- ++curCol; } mAgenda->hideUnused(); mAllDayAgenda->hideUnused(); mAgenda->checkScrollBoundaries(); deleteSelectedDateTime(); createDayLabels(); emit incidenceSelected( 0 ); if ( globalFlagBlockAgenda == 2 ) { if ( KOPrefs::instance()->mSetTimeToDayStartAt ) setStartHour( KOPrefs::instance()->mDayBegins ); else if ( KOPrefs::instance()->mCenterOnCurrentTime ) setStartHour( QTime::currentTime ().hour() ); } qApp->processEvents(); globalFlagBlockAgenda = 0; mAllDayAgenda->drawContentsToPainter(); mAgenda->drawContentsToPainter(); repaintAgenda(); startIdleTimeout(); - onlyOne = false; + flag_blockfillAgenda = false; } void KOAgendaView::repaintAgenda() { mAgenda->viewport()->repaint( false ); mAllDayAgenda->viewport()->repaint( false ); mAgenda->finishUpdate(); mAllDayAgenda->finishUpdate(); } void KOAgendaView::clearView() { mAllDayAgenda->clear(); mAgenda->clear(); } void KOAgendaView::clearList() { clearView(); mAllDayAgenda->hideUnused(); mAgenda->hideUnused(); } void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER if (fd == td) calPrinter->preview(CalPrinter::Day, fd, td); else calPrinter->preview(CalPrinter::Week, fd, td); #endif } // void KOAgendaView::updateMovedTodo() // { // // updateConfig(); // // emit updateTodoViews(); // } void KOAgendaView::slotShowDateView( int mode , int d ) { if ( d >= mSelectedDates.count() ) { qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); } else { QDate day = mSelectedDates[d]; emit showDateView(mode , day ); } } void KOAgendaView::newEvent(int gx, int gy) { if (!mSelectedDates.count()) return; QDate day = mSelectedDates[gx]; QTime time = mAgenda->gyToTime(gy); QDateTime dt(day,time); // if ( dt < QDateTime::currentDateTime () ) // dt = QDateTime::currentDateTime ().addSecs( 3600 ); emit newEventSignal(dt); } void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index 4b7ef5b..5e68146 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -195,104 +195,105 @@ class KOAgendaView : public KOEventView { void newTodo(int gx,int gy); void newEvent(int gx,int gy); void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); void newEventAllDay(int gx, int gy); void newTodoAllDay(int gx, int gy); void startDrag(Event *); void readSettings(); void readSettings(KConfig *); void writeSettings(KConfig *); void setContentsPos(int y); void scrollOneHourUp(); void scrollOneHourDown(); void addToCalSlot(Incidence *, Incidence *); void slotShowDateView( int, int ); void fillAgenda(); void startIdleTimeout(); signals: void showDateView( int, QDate ); void newTodoSignal( QDateTime ,bool ); void toggleExpand(); void selectWeekNum( int ); void todoMoved( Todo *, int ); void incidenceChanged(Incidence * , int ); // void cloneIncidenceSignal(Incidence *); protected: KOAgendaButton* getNewDaylabel(); bool mBlockUpdating; int mUpcomingWidth; /** Fill agenda beginning with date startDate */ void fillAgenda(const QDate &startDate); void resizeEvent( QResizeEvent* e ); /** Fill agenda using the current set value for the start date */ /** Create labels for the selected dates. */ void createDayLabels(); /** Set the masks on the agenda widgets indicating, which days are holidays. */ void setHolidayMasks(); protected slots: void slotIdleTimeout(); void categoryChanged( Incidence * ); void slotDaylabelClicked( int ); /** Update event belonging to agenda item */ void updateEventDates(KOAgendaItem *item, int mode = -1); //void updateMovedTodo(); void updateEventIndicatorTop(int newY); void updateEventIndicatorBottom(int newY); /** Updates data for selected timespan */ void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); /** Updates data for selected timespan for all day event*/ void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); private: + bool flag_blockfillAgenda; QTimer* mIdleTimer; QDateTime mIdleStart; // view widgets QFrame *mDayLabels; QHBox *mDayLabelsFrame; QBoxLayout *mLayoutDayLabels; QFrame *mAllDayFrame; KOAgenda *mAllDayAgenda; KOAgenda *mAgenda; TimeLabels *mTimeLabels; QWidget *mDummyAllDayLeft; KDGanttMinimizeSplitter* mSplitterAgenda; QPushButton *mExpandButton; DateList mSelectedDates; // List of dates to be displayed int mViewType; bool mWeekStartsMonday; int mStartHour; KOEventPopupMenu *mAllAgendaPopup; //KOEventPopupMenu *mAllDayAgendaPopup; EventIndicator *mEventIndicatorTop; EventIndicator *mEventIndicatorBottom; QMemArray<int> mMinY; QMemArray<int> mMaxY; QMemArray<bool> mHolidayMask; QPtrList<KOAgendaButton> mDayLabelsList; QDateTime mTimeSpanBegin; QDateTime mTimeSpanEnd; bool mTimeSpanInAllDay; void keyPressEvent ( QKeyEvent * e ); }; #endif // KOAGENDAVIEW_H diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index a12c43e..d79a9b9 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -452,129 +452,129 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) QListView::keyPressEvent ( e ); e->accept(); break; case Qt::Key_Left: case Qt::Key_Right: QListView::keyPressEvent ( e ); e->accept(); return; break; default: e->ignore(); break; } return; } e->ignore(); } void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) { QListView::contentsMouseReleaseEvent(e); mMousePressed = false; } void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) { if (!e) return; QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt(vp); emit double_Clicked(item); if (!item) return; emit doubleClicked(item,vp,0); } ///////////////////////////////////////////////////////////////////////////// KOQuickTodo::KOQuickTodo(QWidget *parent) : QLineEdit(parent) { setText(i18n("Click to add new Todo")); setFocusPolicy ( QWidget::ClickFocus ); } void KOQuickTodo::focusInEvent(QFocusEvent *ev) { if ( text()==i18n("Click to add new Todo") ) setText(""); QLineEdit::focusInEvent(ev); } void KOQuickTodo::focusOutEvent(QFocusEvent *ev) { setText(i18n("Click to add new Todo")); QLineEdit::focusOutEvent(ev); } ///////////////////////////////////////////////////////////////////////////// KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : KOrg::BaseView(calendar,parent,name) { - + mIsActiveWindow = false; mCurItem = 0; mCurItemRootParent = 0; mCurItemParent = 0; mCurItemAbove = 0; mActiveItem = 0; mCategoryPopupMenu = 0; mPendingUpdateBeforeRepaint = false; isFlatDisplay = false; mNavigator = 0; QBoxLayout *topLayout = new QVBoxLayout(this); mName = QString ( name ); mBlockUpdate = false; mQuickBar = new QWidget( this ); topLayout->addWidget(mQuickBar); mQuickAdd = new KOQuickTodo(mQuickBar); QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); quickLayout->addWidget( mQuickAdd ); mNewSubBut = new QPushButton( "sub",mQuickBar ); QPushButton * s_done = new QPushButton( "D",mQuickBar ); QPushButton * s_run = new QPushButton( "R",mQuickBar ); QPushButton * allopen = new QPushButton( "O",mQuickBar ); QPushButton * allclose = new QPushButton( "C",mQuickBar ); QPushButton * flat = new QPushButton( "F",mQuickBar ); int fixwid = mQuickAdd->sizeHint().height(); int fixhei = fixwid; if ( QApplication::desktop()->width() > 800 ) fixwid = (fixwid*3)/2; connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); s_done->setPixmap( SmallIcon("greenhook16")); connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); s_run->setPixmap( SmallIcon("ko16old")); connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); mNewSubBut->setEnabled( false ); flat->setFixedWidth( fixwid ); s_done->setFixedWidth( fixwid ); allopen->setFixedWidth( fixwid ); allclose->setFixedWidth( fixwid ); s_run->setFixedWidth( fixwid ); flat->setFixedHeight(fixhei ); s_done->setFixedHeight(fixhei ); allopen->setFixedHeight(fixhei ); allclose->setFixedHeight(fixhei ); s_run->setFixedHeight(fixhei ); mNewSubBut->setFixedHeight(fixhei ); flat->setFocusPolicy( NoFocus ); s_done->setFocusPolicy( NoFocus ); allopen->setFocusPolicy( NoFocus ); allclose->setFocusPolicy( NoFocus ); s_run->setFocusPolicy( NoFocus ); mNewSubBut->setFocusPolicy( NoFocus ); QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) ); QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) ); QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) ); @@ -889,197 +889,199 @@ void KOTodoView::updateView() for(t = todoList.first(); t; t = todoList.next()) { kdDebug() << " " << t->getSummary() << endl; if (t->getRelatedTo()) { kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; } QPtrList<Event> l = t->getRelations(); Event *c; for(c=l.first();c;c=l.next()) { kdDebug() << " - relation: " << c->getSummary() << endl; } } */ // Put for each Event a KOTodoViewItem in the list view. Don't rely on a // specific order of events. That means that we have to generate parent items // recursively for proper hierarchical display of Todos. Todo *todo; todo = todoList.first();// todo; todo = todoList.next()) { while ( todo ) { bool next = true; // qDebug("todo %s ", todo->summary().latin1()); Incidence *incidence = todo->relatedTo(); while ( incidence ) { if ( incidence->typeID() == todoID ) { //qDebug("related %s ",incidence->summary().latin1() ); if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { //qDebug("related not found "); todoList.remove( ); todo = todoList.current(); next = false; incidence = 0; } else { //qDebug("related found "); incidence = incidence->relatedTo(); } } else incidence = 0; } if ( next ) todo = todoList.next(); } for(todo = todoList.first(); todo; todo = todoList.next()) { if (!mTodoMap.contains(todo) && checkTodo( todo ) ) { insertTodoItem(todo); } } // Restore opened/closed state mTodoListView->blockSignals( true ); if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); mTodoListView->blockSignals( false ); resetCurrentItem(); } void KOTodoView::storeCurrentItem() { mCurItem = 0; mCurItemRootParent = 0; mCurItemParent = 0; mCurItemAbove = 0; + mIsActiveWindow = topLevelWidget()->isActiveWindow(); mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); if (mActiveItem) { mCurItem = mActiveItem->todo(); KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); if ( activeItemAbove ) mCurItemAbove = activeItemAbove->todo(); mCurItemRootParent = mCurItem; mCurItemParent = mCurItemRootParent->relatedTo(); while ( mCurItemRootParent->relatedTo() != 0 ) mCurItemRootParent = mCurItemRootParent->relatedTo(); } mActiveItem = 0; } void KOTodoView::resetCurrentItem() { //mTodoListView->setFocus(); KOTodoViewItem* foundItem = 0; KOTodoViewItem* foundItemRoot = 0; KOTodoViewItem* foundItemParent = 0; KOTodoViewItem* foundItemAbove = 0; if ( mTodoListView->firstChild () ) { if ( mCurItem ) { KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); while ( item ) { if ( item->todo() == mCurItem ) { foundItem = item; break; } else if ( item->todo() == mCurItemAbove ) { foundItemAbove = item; } if ( item->todo() == mCurItemRootParent ) { foundItemRoot = item; } if ( item->todo() == mCurItemParent ) { foundItemParent = item; } item = (KOTodoViewItem*)item->itemBelow(); } if ( ! foundItem ) { if ( foundItemParent ) { foundItem = foundItemParent; } else { if ( foundItemRoot ) foundItem = foundItemRoot; else foundItem = foundItemAbove; } } } if ( foundItem ) { mTodoListView->setSelected ( foundItem, true ); mTodoListView->setCurrentItem( foundItem ); mTodoListView->ensureItemVisible( foundItem ); } else { if ( mTodoListView->firstChild () ) { mTodoListView->setSelected ( mTodoListView->firstChild (), true ); mTodoListView->setCurrentItem( mTodoListView->firstChild () ); } } } processSelectionChange(); if ( mName != "todolistsmall" ) QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); } void KOTodoView::resetFocusToList() { - topLevelWidget()->setActiveWindow(); + if ( mIsActiveWindow ) + topLevelWidget()->setActiveWindow(); mTodoListView->setFocus(); } //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; bool KOTodoView::checkTodo( Todo * todo ) { if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) return false; if ( !todo->isCompleted() ) { if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) return true; } if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { if ( todo->hasStartDate() ) if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) return false; if ( todo->hasDueDate() ) if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) return false; } return true; } void KOTodoView::restoreItemState( QListViewItem *item ) { pendingSubtodo = 0; while( item ) { KOTodoViewItem *todoItem = (KOTodoViewItem *)item; todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); item = item->nextSibling(); } } QMap<Todo *,KOTodoViewItem *>::ConstIterator KOTodoView::insertTodoItem(Todo *todo) { // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; // TODO: Check, if dynmaic cast is necessary pendingSubtodo = 0; Incidence *incidence = todo->relatedTo(); while ( incidence && !incidence->calEnabled() ) incidence = incidence->relatedTo(); if (incidence && incidence->typeID() == todoID ) { Todo *relatedTodo = static_cast<Todo *>(incidence); // kdDebug() << " has Related" << endl; QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; itemIterator = mTodoMap.find(relatedTodo); if (itemIterator == mTodoMap.end()) { // kdDebug() << " related not yet in list" << endl; itemIterator = insertTodoItem (relatedTodo); } // isn't this pretty stupid? We give one Todo to the KOTodoViewItem // and one into the map. Sure finding is more easy but why? -zecke KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); return mTodoMap.insert(todo,todoItem); } else { // kdDebug() << " no Related" << endl; // see above -zecke KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index ecd0ad9..161ecb0 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -194,116 +194,117 @@ class KOTodoView : public KOrg::BaseView void popupMenu(QListViewItem *item,const QPoint &,int); void newTodo(); void newSubTodo(); void unparentTodo(); void reparentTodo(); void showTodo(); void editTodo(); void cloneTodo(); void cancelTodo(); void moveTodo(); void beamTodo(); void deleteTodo(); void setNewPriority(int); void setNewPercentage(int); void changedCategories(int); void setAllOpen(); void setAllClose(); void setAllFlat(); void displayAllFlat(); void purgeCompleted(); void toggleCompleted(); void toggleRunning(); void toggleQuickTodo(); void updateTodo( Todo *, int ); void itemClicked(QListViewItem *); void itemStateChanged(QListViewItem *); void modified(bool); void itemDoubleClicked(QListViewItem *item); void resetFocusToList(); void fillCategories (); void fillCal (); void changedCal (int); signals: void newTodoSignal(); void newSubTodoSignal(Todo *); void unparentTodoSignal(Todo *); void reparentTodoSignal( Todo *,Todo * ); void showTodoSignal(Todo *); void editTodoSignal(Todo *); void deleteTodoSignal(Todo *); void todoModifiedSignal (Todo *, int); void isModified(bool); void cloneTodoSignal( Incidence * ); void cancelTodoSignal( Incidence * ); void moveTodoSignal( Incidence * ); void beamTodoSignal( Incidence * ); void purgeCompletedSignal(); protected slots: void toggleRunningItem(); void paintNeeded(); void processSelectionChange(); void addQuickTodo(); void setTodoModified( Todo* ); void todoModified(Todo *, int ); private: + bool mIsActiveWindow; void addQuickTodoPar( Todo * parentTodo); /* * the TodoEditor approach is rather unscaling in the long * run. * Korganizer keeps it in memory and we need to update * 1. make KOTodoViewItem a QObject again? * 2. add a public method for setting one todo modified? * 3. add a private method for setting a todo modified + friend here? * -- zecke 2002-07-08 */ KOTodoViewWhatsThis* mKOTodoViewWhatsThis; friend class KOTodoListView; void paintEvent(QPaintEvent * pevent); bool mPendingUpdateBeforeRepaint; friend class KOTodoViewItem; QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); void restoreItemState( QListViewItem * ); bool checkTodo( Todo * ); bool isFlatDisplay; void setOpen( QListViewItem*, bool setOpen); KOTodoListView *mTodoListView; QPopupMenu *mItemPopupMenu; QPopupMenu *mPopupMenu; QPopupMenu *mPriorityPopupMenu; QPopupMenu *mPercentageCompletedPopupMenu; QPopupMenu *mCategoryPopupMenu; QPopupMenu *mCalPopupMenu; QMap<int, int> mPercentage; QMap<int, int> mPriority; QMap<int, QString> mCategory; KOTodoViewItem *mActiveItem; QMap<Todo *,KOTodoViewItem *> mTodoMap; QString mName; QWidget* mQuickBar; DocPrefs *mDocPrefs; QString mCurrentDoc; KOQuickTodo *mQuickAdd; bool mBlockUpdate; void keyPressEvent ( QKeyEvent * ) ; KOTodoViewItem * pendingSubtodo; DateNavigator* mNavigator; void storeCurrentItem(); void resetCurrentItem(); Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; QPushButton * mNewSubBut; }; #endif diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index ba3bc05..4057ae0 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -1,270 +1,272 @@ /* 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 ) { + + lastMode = 0; + lastCount = 0; + lastNDMode = false; + selecteddatescount = 0; + selecteddate = QDate ( 2000, 1, 1 ); + baseCycleDate = QDate ( 2000, 1, 1 ); 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 ;} diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index 2e6aaed..2aa46d0 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h @@ -43,87 +43,94 @@ 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; } KOJournalView *journalView() const { return mJournalView; } 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: + int lastMode; + int lastCount; + bool lastNDMode; + QDate lastDate; + int selecteddatescount; + QDate selecteddate; + QDate baseCycleDate; 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 |