-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 17 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 2 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 13 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 2 |
6 files changed, 28 insertions, 8 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index db33017..cca73f2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -627,3073 +627,3072 @@ void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | |||
627 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 627 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
628 | mSuspendTimer->start( ms , true ); | 628 | mSuspendTimer->start( ms , true ); |
629 | 629 | ||
630 | } | 630 | } |
631 | 631 | ||
632 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 632 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
633 | { | 633 | { |
634 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 634 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
635 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 635 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
636 | #ifndef DESKTOP_VERSION | 636 | #ifndef DESKTOP_VERSION |
637 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 637 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
638 | #endif | 638 | #endif |
639 | return; | 639 | return; |
640 | } | 640 | } |
641 | int maxSec; | 641 | int maxSec; |
642 | //maxSec = 5; //testing only | 642 | //maxSec = 5; //testing only |
643 | maxSec = 86400+3600; // one day+1hour | 643 | maxSec = 86400+3600; // one day+1hour |
644 | mAlarmNotification = noti; | 644 | mAlarmNotification = noti; |
645 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 645 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
646 | if ( sec > maxSec ) { | 646 | if ( sec > maxSec ) { |
647 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 647 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
648 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 648 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
649 | return; | 649 | return; |
650 | } else { | 650 | } else { |
651 | mRecheckAlarmTimer->stop(); | 651 | mRecheckAlarmTimer->stop(); |
652 | } | 652 | } |
653 | //qDebug("Alarm timer started with secs: %d ", sec); | 653 | //qDebug("Alarm timer started with secs: %d ", sec); |
654 | mAlarmTimer->start( sec *1000 , true ); | 654 | mAlarmTimer->start( sec *1000 , true ); |
655 | 655 | ||
656 | } | 656 | } |
657 | // called by mRecheckAlarmTimer to get next alarm | 657 | // called by mRecheckAlarmTimer to get next alarm |
658 | // we need this, because a QTimer has only a max range of 25 days | 658 | // we need this, because a QTimer has only a max range of 25 days |
659 | void CalendarView::recheckTimerAlarm() | 659 | void CalendarView::recheckTimerAlarm() |
660 | { | 660 | { |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | mRecheckAlarmTimer->stop(); | 662 | mRecheckAlarmTimer->stop(); |
663 | mCalendar->checkAlarmForIncidence( 0, true ); | 663 | mCalendar->checkAlarmForIncidence( 0, true ); |
664 | } | 664 | } |
665 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 665 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
666 | { | 666 | { |
667 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 667 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
668 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 668 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
669 | #ifndef DESKTOP_VERSION | 669 | #ifndef DESKTOP_VERSION |
670 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 670 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
671 | #endif | 671 | #endif |
672 | return; | 672 | return; |
673 | } | 673 | } |
674 | mAlarmTimer->stop(); | 674 | mAlarmTimer->stop(); |
675 | } | 675 | } |
676 | void CalendarView::selectWeekNum ( int num ) | 676 | void CalendarView::selectWeekNum ( int num ) |
677 | { | 677 | { |
678 | dateNavigator()->blockSignals( true ); | 678 | dateNavigator()->blockSignals( true ); |
679 | dateNavigator()->selectWeek( num ); | 679 | dateNavigator()->selectWeek( num ); |
680 | dateNavigator()->blockSignals( false ); | 680 | dateNavigator()->blockSignals( false ); |
681 | mViewManager->showWeekView(); | 681 | mViewManager->showWeekView(); |
682 | } | 682 | } |
683 | KOViewManager *CalendarView::viewManager() | 683 | KOViewManager *CalendarView::viewManager() |
684 | { | 684 | { |
685 | return mViewManager; | 685 | return mViewManager; |
686 | } | 686 | } |
687 | 687 | ||
688 | KODialogManager *CalendarView::dialogManager() | 688 | KODialogManager *CalendarView::dialogManager() |
689 | { | 689 | { |
690 | return mDialogManager; | 690 | return mDialogManager; |
691 | } | 691 | } |
692 | 692 | ||
693 | QDate CalendarView::startDate() | 693 | QDate CalendarView::startDate() |
694 | { | 694 | { |
695 | DateList dates = mNavigator->selectedDates(); | 695 | DateList dates = mNavigator->selectedDates(); |
696 | 696 | ||
697 | return dates.first(); | 697 | return dates.first(); |
698 | } | 698 | } |
699 | 699 | ||
700 | QDate CalendarView::endDate() | 700 | QDate CalendarView::endDate() |
701 | { | 701 | { |
702 | DateList dates = mNavigator->selectedDates(); | 702 | DateList dates = mNavigator->selectedDates(); |
703 | 703 | ||
704 | return dates.last(); | 704 | return dates.last(); |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | void CalendarView::createPrinter() | 708 | void CalendarView::createPrinter() |
709 | { | 709 | { |
710 | #ifndef KORG_NOPRINTER | 710 | #ifndef KORG_NOPRINTER |
711 | if (!mCalPrinter) { | 711 | if (!mCalPrinter) { |
712 | mCalPrinter = new CalPrinter(this, mCalendar); | 712 | mCalPrinter = new CalPrinter(this, mCalendar); |
713 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 713 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
714 | } | 714 | } |
715 | #endif | 715 | #endif |
716 | } | 716 | } |
717 | 717 | ||
718 | 718 | ||
719 | //KOPrefs::instance()->mWriteBackFile | 719 | //KOPrefs::instance()->mWriteBackFile |
720 | //KOPrefs::instance()->mWriteBackExistingOnly | 720 | //KOPrefs::instance()->mWriteBackExistingOnly |
721 | 721 | ||
722 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 722 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
723 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 723 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
724 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 724 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
725 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 725 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
726 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 726 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
727 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 727 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
728 | 728 | ||
729 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 729 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
730 | { | 730 | { |
731 | 731 | ||
732 | // 0 equal | 732 | // 0 equal |
733 | // 1 take local | 733 | // 1 take local |
734 | // 2 take remote | 734 | // 2 take remote |
735 | // 3 cancel | 735 | // 3 cancel |
736 | QDateTime lastSync = mLastCalendarSync; | 736 | QDateTime lastSync = mLastCalendarSync; |
737 | QDateTime localMod = local->lastModified(); | 737 | QDateTime localMod = local->lastModified(); |
738 | QDateTime remoteMod = remote->lastModified(); | 738 | QDateTime remoteMod = remote->lastModified(); |
739 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 739 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
740 | bool remCh, locCh; | 740 | bool remCh, locCh; |
741 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 741 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
742 | //if ( remCh ) | 742 | //if ( remCh ) |
743 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 743 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
744 | locCh = ( localMod > mLastCalendarSync ); | 744 | locCh = ( localMod > mLastCalendarSync ); |
745 | if ( !remCh && ! locCh ) { | 745 | if ( !remCh && ! locCh ) { |
746 | //qDebug("both not changed "); | 746 | //qDebug("both not changed "); |
747 | lastSync = localMod.addDays(1); | 747 | lastSync = localMod.addDays(1); |
748 | if ( mode <= SYNC_PREF_ASK ) | 748 | if ( mode <= SYNC_PREF_ASK ) |
749 | return 0; | 749 | return 0; |
750 | } else { | 750 | } else { |
751 | if ( locCh ) { | 751 | if ( locCh ) { |
752 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 752 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
753 | lastSync = localMod.addDays( -1 ); | 753 | lastSync = localMod.addDays( -1 ); |
754 | if ( !remCh ) | 754 | if ( !remCh ) |
755 | remoteMod = ( lastSync.addDays( -1 ) ); | 755 | remoteMod = ( lastSync.addDays( -1 ) ); |
756 | } else { | 756 | } else { |
757 | //qDebug(" not loc changed "); | 757 | //qDebug(" not loc changed "); |
758 | lastSync = localMod.addDays( 1 ); | 758 | lastSync = localMod.addDays( 1 ); |
759 | if ( remCh ) | 759 | if ( remCh ) |
760 | remoteMod =( lastSync.addDays( 1 ) ); | 760 | remoteMod =( lastSync.addDays( 1 ) ); |
761 | 761 | ||
762 | } | 762 | } |
763 | } | 763 | } |
764 | full = true; | 764 | full = true; |
765 | if ( mode < SYNC_PREF_ASK ) | 765 | if ( mode < SYNC_PREF_ASK ) |
766 | mode = SYNC_PREF_ASK; | 766 | mode = SYNC_PREF_ASK; |
767 | } else { | 767 | } else { |
768 | if ( localMod == remoteMod ) | 768 | if ( localMod == remoteMod ) |
769 | // if ( local->revision() == remote->revision() ) | 769 | // if ( local->revision() == remote->revision() ) |
770 | return 0; | 770 | return 0; |
771 | 771 | ||
772 | } | 772 | } |
773 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 773 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
774 | 774 | ||
775 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 775 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
776 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 776 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
777 | //full = true; //debug only | 777 | //full = true; //debug only |
778 | if ( full ) { | 778 | if ( full ) { |
779 | bool equ = false; | 779 | bool equ = false; |
780 | if ( local->type() == "Event" ) { | 780 | if ( local->type() == "Event" ) { |
781 | equ = (*((Event*) local) == *((Event*) remote)); | 781 | equ = (*((Event*) local) == *((Event*) remote)); |
782 | } | 782 | } |
783 | else if ( local->type() =="Todo" ) | 783 | else if ( local->type() =="Todo" ) |
784 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 784 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
785 | else if ( local->type() =="Journal" ) | 785 | else if ( local->type() =="Journal" ) |
786 | equ = (*((Journal*) local) == *((Journal*) remote)); | 786 | equ = (*((Journal*) local) == *((Journal*) remote)); |
787 | if ( equ ) { | 787 | if ( equ ) { |
788 | //qDebug("equal "); | 788 | //qDebug("equal "); |
789 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 789 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
790 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 790 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
791 | } | 791 | } |
792 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 792 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
793 | return 0; | 793 | return 0; |
794 | 794 | ||
795 | }//else //debug only | 795 | }//else //debug only |
796 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 796 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
797 | } | 797 | } |
798 | int result; | 798 | int result; |
799 | bool localIsNew; | 799 | bool localIsNew; |
800 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 800 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
801 | 801 | ||
802 | if ( full && mode < SYNC_PREF_NEWEST ) | 802 | if ( full && mode < SYNC_PREF_NEWEST ) |
803 | mode = SYNC_PREF_ASK; | 803 | mode = SYNC_PREF_ASK; |
804 | 804 | ||
805 | switch( mode ) { | 805 | switch( mode ) { |
806 | case SYNC_PREF_LOCAL: | 806 | case SYNC_PREF_LOCAL: |
807 | if ( lastSync > remoteMod ) | 807 | if ( lastSync > remoteMod ) |
808 | return 1; | 808 | return 1; |
809 | if ( lastSync > localMod ) | 809 | if ( lastSync > localMod ) |
810 | return 2; | 810 | return 2; |
811 | return 1; | 811 | return 1; |
812 | break; | 812 | break; |
813 | case SYNC_PREF_REMOTE: | 813 | case SYNC_PREF_REMOTE: |
814 | if ( lastSync > remoteMod ) | 814 | if ( lastSync > remoteMod ) |
815 | return 1; | 815 | return 1; |
816 | if ( lastSync > localMod ) | 816 | if ( lastSync > localMod ) |
817 | return 2; | 817 | return 2; |
818 | return 2; | 818 | return 2; |
819 | break; | 819 | break; |
820 | case SYNC_PREF_NEWEST: | 820 | case SYNC_PREF_NEWEST: |
821 | if ( localMod > remoteMod ) | 821 | if ( localMod > remoteMod ) |
822 | return 1; | 822 | return 1; |
823 | else | 823 | else |
824 | return 2; | 824 | return 2; |
825 | break; | 825 | break; |
826 | case SYNC_PREF_ASK: | 826 | case SYNC_PREF_ASK: |
827 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 827 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
828 | if ( lastSync > remoteMod ) | 828 | if ( lastSync > remoteMod ) |
829 | return 1; | 829 | return 1; |
830 | if ( lastSync > localMod ) | 830 | if ( lastSync > localMod ) |
831 | return 2; | 831 | return 2; |
832 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 832 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
833 | localIsNew = localMod >= remoteMod; | 833 | localIsNew = localMod >= remoteMod; |
834 | if ( localIsNew ) | 834 | if ( localIsNew ) |
835 | getEventViewerDialog()->setColorMode( 1 ); | 835 | getEventViewerDialog()->setColorMode( 1 ); |
836 | else | 836 | else |
837 | getEventViewerDialog()->setColorMode( 2 ); | 837 | getEventViewerDialog()->setColorMode( 2 ); |
838 | getEventViewerDialog()->setIncidence(local); | 838 | getEventViewerDialog()->setIncidence(local); |
839 | if ( localIsNew ) | 839 | if ( localIsNew ) |
840 | getEventViewerDialog()->setColorMode( 2 ); | 840 | getEventViewerDialog()->setColorMode( 2 ); |
841 | else | 841 | else |
842 | getEventViewerDialog()->setColorMode( 1 ); | 842 | getEventViewerDialog()->setColorMode( 1 ); |
843 | getEventViewerDialog()->addIncidence(remote); | 843 | getEventViewerDialog()->addIncidence(remote); |
844 | getEventViewerDialog()->setColorMode( 0 ); | 844 | getEventViewerDialog()->setColorMode( 0 ); |
845 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 845 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
846 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 846 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
847 | getEventViewerDialog()->showMe(); | 847 | getEventViewerDialog()->showMe(); |
848 | result = getEventViewerDialog()->executeS( localIsNew ); | 848 | result = getEventViewerDialog()->executeS( localIsNew ); |
849 | return result; | 849 | return result; |
850 | 850 | ||
851 | break; | 851 | break; |
852 | case SYNC_PREF_FORCE_LOCAL: | 852 | case SYNC_PREF_FORCE_LOCAL: |
853 | return 1; | 853 | return 1; |
854 | break; | 854 | break; |
855 | case SYNC_PREF_FORCE_REMOTE: | 855 | case SYNC_PREF_FORCE_REMOTE: |
856 | return 2; | 856 | return 2; |
857 | break; | 857 | break; |
858 | 858 | ||
859 | default: | 859 | default: |
860 | // SYNC_PREF_TAKE_BOTH not implemented | 860 | // SYNC_PREF_TAKE_BOTH not implemented |
861 | break; | 861 | break; |
862 | } | 862 | } |
863 | return 0; | 863 | return 0; |
864 | } | 864 | } |
865 | Event* CalendarView::getLastSyncEvent() | 865 | Event* CalendarView::getLastSyncEvent() |
866 | { | 866 | { |
867 | Event* lse; | 867 | Event* lse; |
868 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 868 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
869 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 869 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
870 | if (!lse) { | 870 | if (!lse) { |
871 | lse = new Event(); | 871 | lse = new Event(); |
872 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 872 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
873 | QString sum = ""; | 873 | QString sum = ""; |
874 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 874 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
875 | sum = "E: "; | 875 | sum = "E: "; |
876 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 876 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
877 | lse->setDtStart( mLastCalendarSync ); | 877 | lse->setDtStart( mLastCalendarSync ); |
878 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 878 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
879 | lse->setCategories( i18n("SyncEvent") ); | 879 | lse->setCategories( i18n("SyncEvent") ); |
880 | lse->setReadOnly( true ); | 880 | lse->setReadOnly( true ); |
881 | mCalendar->addEvent( lse ); | 881 | mCalendar->addEvent( lse ); |
882 | } | 882 | } |
883 | 883 | ||
884 | return lse; | 884 | return lse; |
885 | 885 | ||
886 | } | 886 | } |
887 | 887 | ||
888 | // we check, if the to delete event has a id for a profile | 888 | // we check, if the to delete event has a id for a profile |
889 | // if yes, we set this id in the profile to delete | 889 | // if yes, we set this id in the profile to delete |
890 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 890 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
891 | { | 891 | { |
892 | if ( lastSync.count() == 0 ) { | 892 | if ( lastSync.count() == 0 ) { |
893 | //qDebug(" lastSync.count() == 0"); | 893 | //qDebug(" lastSync.count() == 0"); |
894 | return; | 894 | return; |
895 | } | 895 | } |
896 | if ( toDelete->type() == "Journal" ) | 896 | if ( toDelete->type() == "Journal" ) |
897 | return; | 897 | return; |
898 | 898 | ||
899 | Event* eve = lastSync.first(); | 899 | Event* eve = lastSync.first(); |
900 | 900 | ||
901 | while ( eve ) { | 901 | while ( eve ) { |
902 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 902 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
903 | if ( !id.isEmpty() ) { | 903 | if ( !id.isEmpty() ) { |
904 | QString des = eve->description(); | 904 | QString des = eve->description(); |
905 | QString pref = "e"; | 905 | QString pref = "e"; |
906 | if ( toDelete->type() == "Todo" ) | 906 | if ( toDelete->type() == "Todo" ) |
907 | pref = "t"; | 907 | pref = "t"; |
908 | des += pref+ id + ","; | 908 | des += pref+ id + ","; |
909 | eve->setReadOnly( false ); | 909 | eve->setReadOnly( false ); |
910 | eve->setDescription( des ); | 910 | eve->setDescription( des ); |
911 | //qDebug("setdes %s ", des.latin1()); | 911 | //qDebug("setdes %s ", des.latin1()); |
912 | eve->setReadOnly( true ); | 912 | eve->setReadOnly( true ); |
913 | } | 913 | } |
914 | eve = lastSync.next(); | 914 | eve = lastSync.next(); |
915 | } | 915 | } |
916 | 916 | ||
917 | } | 917 | } |
918 | void CalendarView::checkExternalId( Incidence * inc ) | 918 | void CalendarView::checkExternalId( Incidence * inc ) |
919 | { | 919 | { |
920 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 920 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
921 | checkExternSyncEvent( lastSync, inc ); | 921 | checkExternSyncEvent( lastSync, inc ); |
922 | 922 | ||
923 | } | 923 | } |
924 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 924 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
925 | { | 925 | { |
926 | bool syncOK = true; | 926 | bool syncOK = true; |
927 | int addedEvent = 0; | 927 | int addedEvent = 0; |
928 | int addedEventR = 0; | 928 | int addedEventR = 0; |
929 | int deletedEventR = 0; | 929 | int deletedEventR = 0; |
930 | int deletedEventL = 0; | 930 | int deletedEventL = 0; |
931 | int changedLocal = 0; | 931 | int changedLocal = 0; |
932 | int changedRemote = 0; | 932 | int changedRemote = 0; |
933 | int filteredIN = 0; | 933 | int filteredIN = 0; |
934 | int filteredOUT = 0; | 934 | int filteredOUT = 0; |
935 | //QPtrList<Event> el = local->rawEvents(); | 935 | //QPtrList<Event> el = local->rawEvents(); |
936 | Event* eventR; | 936 | Event* eventR; |
937 | QString uid; | 937 | QString uid; |
938 | int take; | 938 | int take; |
939 | Event* eventL; | 939 | Event* eventL; |
940 | Event* eventRSync; | 940 | Event* eventRSync; |
941 | Event* eventLSync; | 941 | Event* eventLSync; |
942 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 942 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
943 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 943 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
944 | bool fullDateRange = false; | 944 | bool fullDateRange = false; |
945 | local->resetTempSyncStat(); | 945 | local->resetTempSyncStat(); |
946 | mLastCalendarSync = QDateTime::currentDateTime(); | 946 | mLastCalendarSync = QDateTime::currentDateTime(); |
947 | if ( mSyncManager->syncWithDesktop() ) { | 947 | if ( mSyncManager->syncWithDesktop() ) { |
948 | remote->resetPilotStat(1); | 948 | remote->resetPilotStat(1); |
949 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 949 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
950 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 950 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
951 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 951 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
952 | } else { | 952 | } else { |
953 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 953 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
954 | } | 954 | } |
955 | } | 955 | } |
956 | QDateTime modifiedCalendar = mLastCalendarSync; | 956 | QDateTime modifiedCalendar = mLastCalendarSync; |
957 | eventLSync = getLastSyncEvent(); | 957 | eventLSync = getLastSyncEvent(); |
958 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 958 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
959 | if ( eventR ) { | 959 | if ( eventR ) { |
960 | eventRSync = (Event*) eventR->clone(); | 960 | eventRSync = (Event*) eventR->clone(); |
961 | remote->deleteEvent(eventR ); | 961 | remote->deleteEvent(eventR ); |
962 | 962 | ||
963 | } else { | 963 | } else { |
964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
965 | eventRSync = (Event*)eventLSync->clone(); | 965 | eventRSync = (Event*)eventLSync->clone(); |
966 | } else { | 966 | } else { |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | eventRSync = new Event(); | 968 | eventRSync = new Event(); |
969 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 969 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
970 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 970 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
971 | eventRSync->setDtStart( mLastCalendarSync ); | 971 | eventRSync->setDtStart( mLastCalendarSync ); |
972 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 972 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
973 | eventRSync->setCategories( i18n("SyncEvent") ); | 973 | eventRSync->setCategories( i18n("SyncEvent") ); |
974 | } | 974 | } |
975 | } | 975 | } |
976 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 976 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
977 | fullDateRange = true; | 977 | fullDateRange = true; |
978 | 978 | ||
979 | if ( ! fullDateRange ) { | 979 | if ( ! fullDateRange ) { |
980 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 980 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
981 | 981 | ||
982 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 982 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
983 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 983 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
984 | fullDateRange = true; | 984 | fullDateRange = true; |
985 | } | 985 | } |
986 | } | 986 | } |
987 | if ( mSyncManager->syncWithDesktop() ) { | 987 | if ( mSyncManager->syncWithDesktop() ) { |
988 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 988 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
989 | } | 989 | } |
990 | if ( fullDateRange ) | 990 | if ( fullDateRange ) |
991 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 991 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
992 | else | 992 | else |
993 | mLastCalendarSync = eventLSync->dtStart(); | 993 | mLastCalendarSync = eventLSync->dtStart(); |
994 | // for resyncing if own file has changed | 994 | // for resyncing if own file has changed |
995 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 995 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
996 | mLastCalendarSync = loadedFileVersion; | 996 | mLastCalendarSync = loadedFileVersion; |
997 | //qDebug("setting mLastCalendarSync "); | 997 | //qDebug("setting mLastCalendarSync "); |
998 | } | 998 | } |
999 | //qDebug("*************************** "); | 999 | //qDebug("*************************** "); |
1000 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1000 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1001 | QPtrList<Incidence> er = remote->rawIncidences(); | 1001 | QPtrList<Incidence> er = remote->rawIncidences(); |
1002 | Incidence* inR = er.first(); | 1002 | Incidence* inR = er.first(); |
1003 | Incidence* inL; | 1003 | Incidence* inL; |
1004 | QProgressBar bar( er.count(),0 ); | 1004 | QProgressBar bar( er.count(),0 ); |
1005 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1005 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1006 | 1006 | ||
1007 | // ************** setting up filter ************* | 1007 | // ************** setting up filter ************* |
1008 | CalFilter *filterIN = 0; | 1008 | CalFilter *filterIN = 0; |
1009 | CalFilter *filterOUT = 0; | 1009 | CalFilter *filterOUT = 0; |
1010 | CalFilter *filter = mFilters.first(); | 1010 | CalFilter *filter = mFilters.first(); |
1011 | while(filter) { | 1011 | while(filter) { |
1012 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1012 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1013 | filterIN = filter; | 1013 | filterIN = filter; |
1014 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1014 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1015 | filterOUT = filter; | 1015 | filterOUT = filter; |
1016 | filter = mFilters.next(); | 1016 | filter = mFilters.next(); |
1017 | } | 1017 | } |
1018 | int w = 300; | 1018 | int w = 300; |
1019 | if ( QApplication::desktop()->width() < 320 ) | 1019 | if ( QApplication::desktop()->width() < 320 ) |
1020 | w = 220; | 1020 | w = 220; |
1021 | int h = bar.sizeHint().height() ; | 1021 | int h = bar.sizeHint().height() ; |
1022 | int dw = QApplication::desktop()->width(); | 1022 | int dw = QApplication::desktop()->width(); |
1023 | int dh = QApplication::desktop()->height(); | 1023 | int dh = QApplication::desktop()->height(); |
1024 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1024 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1025 | bar.show(); | 1025 | bar.show(); |
1026 | int modulo = (er.count()/10)+1; | 1026 | int modulo = (er.count()/10)+1; |
1027 | int incCounter = 0; | 1027 | int incCounter = 0; |
1028 | while ( inR ) { | 1028 | while ( inR ) { |
1029 | if ( ! bar.isVisible() ) | 1029 | if ( ! bar.isVisible() ) |
1030 | return false; | 1030 | return false; |
1031 | if ( incCounter % modulo == 0 ) | 1031 | if ( incCounter % modulo == 0 ) |
1032 | bar.setProgress( incCounter ); | 1032 | bar.setProgress( incCounter ); |
1033 | ++incCounter; | 1033 | ++incCounter; |
1034 | uid = inR->uid(); | 1034 | uid = inR->uid(); |
1035 | bool skipIncidence = false; | 1035 | bool skipIncidence = false; |
1036 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1036 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1037 | skipIncidence = true; | 1037 | skipIncidence = true; |
1038 | QString idS; | 1038 | QString idS; |
1039 | qApp->processEvents(); | 1039 | qApp->processEvents(); |
1040 | if ( !skipIncidence ) { | 1040 | if ( !skipIncidence ) { |
1041 | inL = local->incidence( uid ); | 1041 | inL = local->incidence( uid ); |
1042 | if ( inL ) { // maybe conflict - same uid in both calendars | 1042 | if ( inL ) { // maybe conflict - same uid in both calendars |
1043 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1043 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1044 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1044 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1045 | if ( take == 3 ) | 1045 | if ( take == 3 ) |
1046 | return false; | 1046 | return false; |
1047 | if ( take == 1 ) {// take local ********************** | 1047 | if ( take == 1 ) {// take local ********************** |
1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1050 | else | 1050 | else |
1051 | idS = inR->IDStr(); | 1051 | idS = inR->IDStr(); |
1052 | remote->deleteIncidence( inR ); | 1052 | remote->deleteIncidence( inR ); |
1053 | inR = inL->clone(); | 1053 | inR = inL->clone(); |
1054 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1054 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1055 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1055 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1056 | inR->setIDStr( idS ); | 1056 | inR->setIDStr( idS ); |
1057 | remote->addIncidence( inR ); | 1057 | remote->addIncidence( inR ); |
1058 | if ( mSyncManager->syncWithDesktop() ) | 1058 | if ( mSyncManager->syncWithDesktop() ) |
1059 | inR->setPilotId( 2 ); | 1059 | inR->setPilotId( 2 ); |
1060 | ++changedRemote; | 1060 | ++changedRemote; |
1061 | } else {// take remote ********************** | 1061 | } else {// take remote ********************** |
1062 | idS = inL->IDStr(); | 1062 | idS = inL->IDStr(); |
1063 | int pid = inL->pilotId(); | 1063 | int pid = inL->pilotId(); |
1064 | local->deleteIncidence( inL ); | 1064 | local->deleteIncidence( inL ); |
1065 | inL = inR->clone(); | 1065 | inL = inR->clone(); |
1066 | if ( mSyncManager->syncWithDesktop() ) | 1066 | if ( mSyncManager->syncWithDesktop() ) |
1067 | inL->setPilotId( pid ); | 1067 | inL->setPilotId( pid ); |
1068 | inL->setIDStr( idS ); | 1068 | inL->setIDStr( idS ); |
1069 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1069 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1070 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1070 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1071 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1071 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1072 | } | 1072 | } |
1073 | local->addIncidence( inL ); | 1073 | local->addIncidence( inL ); |
1074 | ++changedLocal; | 1074 | ++changedLocal; |
1075 | } | 1075 | } |
1076 | } | 1076 | } |
1077 | } else { // no conflict ********** add or delete remote | 1077 | } else { // no conflict ********** add or delete remote |
1078 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1078 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1079 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1079 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1080 | QString des = eventLSync->description(); | 1080 | QString des = eventLSync->description(); |
1081 | QString pref = "e"; | 1081 | QString pref = "e"; |
1082 | if ( inR->type() == "Todo" ) | 1082 | if ( inR->type() == "Todo" ) |
1083 | pref = "t"; | 1083 | pref = "t"; |
1084 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1084 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1085 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1085 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1086 | //remote->deleteIncidence( inR ); | 1086 | //remote->deleteIncidence( inR ); |
1087 | ++deletedEventR; | 1087 | ++deletedEventR; |
1088 | } else { | 1088 | } else { |
1089 | inR->setLastModified( modifiedCalendar ); | 1089 | inR->setLastModified( modifiedCalendar ); |
1090 | inL = inR->clone(); | 1090 | inL = inR->clone(); |
1091 | inL->setIDStr( ":" ); | 1091 | inL->setIDStr( ":" ); |
1092 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1092 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1093 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1093 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1094 | local->addIncidence( inL ); | 1094 | local->addIncidence( inL ); |
1095 | ++addedEvent; | 1095 | ++addedEvent; |
1096 | 1096 | ||
1097 | } | 1097 | } |
1098 | } else { | 1098 | } else { |
1099 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1099 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1100 | inR->setLastModified( modifiedCalendar ); | 1100 | inR->setLastModified( modifiedCalendar ); |
1101 | inL = inR->clone(); | 1101 | inL = inR->clone(); |
1102 | inL->setIDStr( ":" ); | 1102 | inL->setIDStr( ":" ); |
1103 | local->addIncidence( inL ); | 1103 | local->addIncidence( inL ); |
1104 | ++addedEvent; | 1104 | ++addedEvent; |
1105 | 1105 | ||
1106 | } else { | 1106 | } else { |
1107 | checkExternSyncEvent(eventRSyncSharp, inR); | 1107 | checkExternSyncEvent(eventRSyncSharp, inR); |
1108 | remote->deleteIncidence( inR ); | 1108 | remote->deleteIncidence( inR ); |
1109 | ++deletedEventR; | 1109 | ++deletedEventR; |
1110 | } | 1110 | } |
1111 | } | 1111 | } |
1112 | } else { | 1112 | } else { |
1113 | ++filteredIN; | 1113 | ++filteredIN; |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | inR = er.next(); | 1117 | inR = er.next(); |
1118 | } | 1118 | } |
1119 | QPtrList<Incidence> el = local->rawIncidences(); | 1119 | QPtrList<Incidence> el = local->rawIncidences(); |
1120 | inL = el.first(); | 1120 | inL = el.first(); |
1121 | modulo = (el.count()/10)+1; | 1121 | modulo = (el.count()/10)+1; |
1122 | bar.setCaption (i18n("Add / remove events") ); | 1122 | bar.setCaption (i18n("Add / remove events") ); |
1123 | bar.setTotalSteps ( el.count() ) ; | 1123 | bar.setTotalSteps ( el.count() ) ; |
1124 | bar.show(); | 1124 | bar.show(); |
1125 | incCounter = 0; | 1125 | incCounter = 0; |
1126 | 1126 | ||
1127 | while ( inL ) { | 1127 | while ( inL ) { |
1128 | 1128 | ||
1129 | qApp->processEvents(); | 1129 | qApp->processEvents(); |
1130 | if ( ! bar.isVisible() ) | 1130 | if ( ! bar.isVisible() ) |
1131 | return false; | 1131 | return false; |
1132 | if ( incCounter % modulo == 0 ) | 1132 | if ( incCounter % modulo == 0 ) |
1133 | bar.setProgress( incCounter ); | 1133 | bar.setProgress( incCounter ); |
1134 | ++incCounter; | 1134 | ++incCounter; |
1135 | uid = inL->uid(); | 1135 | uid = inL->uid(); |
1136 | bool skipIncidence = false; | 1136 | bool skipIncidence = false; |
1137 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1137 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1138 | skipIncidence = true; | 1138 | skipIncidence = true; |
1139 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1139 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1140 | skipIncidence = true; | 1140 | skipIncidence = true; |
1141 | if ( !skipIncidence ) { | 1141 | if ( !skipIncidence ) { |
1142 | inR = remote->incidence( uid ); | 1142 | inR = remote->incidence( uid ); |
1143 | if ( ! inR ) { | 1143 | if ( ! inR ) { |
1144 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1144 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1145 | // no conflict ********** add or delete local | 1145 | // no conflict ********** add or delete local |
1146 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1146 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1147 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1147 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1148 | checkExternSyncEvent(eventLSyncSharp, inL); | 1148 | checkExternSyncEvent(eventLSyncSharp, inL); |
1149 | local->deleteIncidence( inL ); | 1149 | local->deleteIncidence( inL ); |
1150 | ++deletedEventL; | 1150 | ++deletedEventL; |
1151 | } else { | 1151 | } else { |
1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1153 | inL->removeID(mCurrentSyncDevice ); | 1153 | inL->removeID(mCurrentSyncDevice ); |
1154 | ++addedEventR; | 1154 | ++addedEventR; |
1155 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1155 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1156 | inL->setLastModified( modifiedCalendar ); | 1156 | inL->setLastModified( modifiedCalendar ); |
1157 | inR = inL->clone(); | 1157 | inR = inL->clone(); |
1158 | inR->setIDStr( ":" ); | 1158 | inR->setIDStr( ":" ); |
1159 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1159 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1160 | remote->addIncidence( inR ); | 1160 | remote->addIncidence( inR ); |
1161 | } | 1161 | } |
1162 | } | 1162 | } |
1163 | } else { | 1163 | } else { |
1164 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1164 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1165 | checkExternSyncEvent(eventLSyncSharp, inL); | 1165 | checkExternSyncEvent(eventLSyncSharp, inL); |
1166 | local->deleteIncidence( inL ); | 1166 | local->deleteIncidence( inL ); |
1167 | ++deletedEventL; | 1167 | ++deletedEventL; |
1168 | } else { | 1168 | } else { |
1169 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1169 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1170 | ++addedEventR; | 1170 | ++addedEventR; |
1171 | inL->setLastModified( modifiedCalendar ); | 1171 | inL->setLastModified( modifiedCalendar ); |
1172 | inR = inL->clone(); | 1172 | inR = inL->clone(); |
1173 | inR->setIDStr( ":" ); | 1173 | inR->setIDStr( ":" ); |
1174 | remote->addIncidence( inR ); | 1174 | remote->addIncidence( inR ); |
1175 | } | 1175 | } |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | } else { | 1178 | } else { |
1179 | ++filteredOUT; | 1179 | ++filteredOUT; |
1180 | } | 1180 | } |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | inL = el.next(); | 1183 | inL = el.next(); |
1184 | } | 1184 | } |
1185 | int delFut = 0; | 1185 | int delFut = 0; |
1186 | int remRem = 0; | 1186 | int remRem = 0; |
1187 | if ( mSyncManager->mWriteBackInFuture ) { | 1187 | if ( mSyncManager->mWriteBackInFuture ) { |
1188 | er = remote->rawIncidences(); | 1188 | er = remote->rawIncidences(); |
1189 | remRem = er.count(); | 1189 | remRem = er.count(); |
1190 | inR = er.first(); | 1190 | inR = er.first(); |
1191 | QDateTime dt; | 1191 | QDateTime dt; |
1192 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1192 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1193 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1193 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1194 | while ( inR ) { | 1194 | while ( inR ) { |
1195 | if ( inR->type() == "Todo" ) { | 1195 | if ( inR->type() == "Todo" ) { |
1196 | Todo * t = (Todo*)inR; | 1196 | Todo * t = (Todo*)inR; |
1197 | if ( t->hasDueDate() ) | 1197 | if ( t->hasDueDate() ) |
1198 | dt = t->dtDue(); | 1198 | dt = t->dtDue(); |
1199 | else | 1199 | else |
1200 | dt = cur.addSecs( 62 ); | 1200 | dt = cur.addSecs( 62 ); |
1201 | } | 1201 | } |
1202 | else if (inR->type() == "Event" ) { | 1202 | else if (inR->type() == "Event" ) { |
1203 | bool ok; | 1203 | bool ok; |
1204 | dt = inR->getNextOccurence( cur, &ok ); | 1204 | dt = inR->getNextOccurence( cur, &ok ); |
1205 | if ( !ok ) | 1205 | if ( !ok ) |
1206 | dt = cur.addSecs( -62 ); | 1206 | dt = cur.addSecs( -62 ); |
1207 | } | 1207 | } |
1208 | else | 1208 | else |
1209 | dt = inR->dtStart(); | 1209 | dt = inR->dtStart(); |
1210 | if ( dt < cur || dt > end ) { | 1210 | if ( dt < cur || dt > end ) { |
1211 | remote->deleteIncidence( inR ); | 1211 | remote->deleteIncidence( inR ); |
1212 | ++delFut; | 1212 | ++delFut; |
1213 | } | 1213 | } |
1214 | inR = er.next(); | 1214 | inR = er.next(); |
1215 | } | 1215 | } |
1216 | } | 1216 | } |
1217 | bar.hide(); | 1217 | bar.hide(); |
1218 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1218 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1219 | eventLSync->setReadOnly( false ); | 1219 | eventLSync->setReadOnly( false ); |
1220 | eventLSync->setDtStart( mLastCalendarSync ); | 1220 | eventLSync->setDtStart( mLastCalendarSync ); |
1221 | eventRSync->setDtStart( mLastCalendarSync ); | 1221 | eventRSync->setDtStart( mLastCalendarSync ); |
1222 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1222 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1223 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1223 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1224 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1224 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1225 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1225 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1226 | eventLSync->setReadOnly( true ); | 1226 | eventLSync->setReadOnly( true ); |
1227 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1227 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1228 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1228 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1229 | remote->addEvent( eventRSync ); | 1229 | remote->addEvent( eventRSync ); |
1230 | else | 1230 | else |
1231 | delete eventRSync; | 1231 | delete eventRSync; |
1232 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1232 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1233 | QString mes; | 1233 | QString mes; |
1234 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1234 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1235 | QString delmess; | 1235 | QString delmess; |
1236 | if ( delFut ) { | 1236 | if ( delFut ) { |
1237 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1237 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1238 | mes += delmess; | 1238 | mes += delmess; |
1239 | } | 1239 | } |
1240 | mes = i18n("Local calendar changed!\n") +mes; | 1240 | mes = i18n("Local calendar changed!\n") +mes; |
1241 | mCalendar->checkAlarmForIncidence( 0, true ); | 1241 | mCalendar->checkAlarmForIncidence( 0, true ); |
1242 | qDebug( mes ); | 1242 | qDebug( mes ); |
1243 | if ( mSyncManager->mShowSyncSummary ) { | 1243 | if ( mSyncManager->mShowSyncSummary ) { |
1244 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1244 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1245 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1245 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1246 | qDebug("KO: WB cancelled "); | 1246 | qDebug("KO: WB cancelled "); |
1247 | return false; | 1247 | return false; |
1248 | } | 1248 | } |
1249 | } | 1249 | } |
1250 | return syncOK; | 1250 | return syncOK; |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | void CalendarView::setSyncDevice( QString s ) | 1253 | void CalendarView::setSyncDevice( QString s ) |
1254 | { | 1254 | { |
1255 | mCurrentSyncDevice= s; | 1255 | mCurrentSyncDevice= s; |
1256 | } | 1256 | } |
1257 | void CalendarView::setSyncName( QString s ) | 1257 | void CalendarView::setSyncName( QString s ) |
1258 | { | 1258 | { |
1259 | mCurrentSyncName= s; | 1259 | mCurrentSyncName= s; |
1260 | } | 1260 | } |
1261 | bool CalendarView::syncCalendar(QString filename, int mode) | 1261 | bool CalendarView::syncCalendar(QString filename, int mode) |
1262 | { | 1262 | { |
1263 | //qDebug("syncCalendar %s ", filename.latin1()); | 1263 | //qDebug("syncCalendar %s ", filename.latin1()); |
1264 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1264 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1265 | CalendarLocal* calendar = new CalendarLocal(); | 1265 | CalendarLocal* calendar = new CalendarLocal(); |
1266 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1266 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1267 | FileStorage* storage = new FileStorage( calendar ); | 1267 | FileStorage* storage = new FileStorage( calendar ); |
1268 | bool syncOK = false; | 1268 | bool syncOK = false; |
1269 | storage->setFileName( filename ); | 1269 | storage->setFileName( filename ); |
1270 | // qDebug("loading ... "); | 1270 | // qDebug("loading ... "); |
1271 | if ( storage->load() ) { | 1271 | if ( storage->load() ) { |
1272 | getEventViewerDialog()->setSyncMode( true ); | 1272 | getEventViewerDialog()->setSyncMode( true ); |
1273 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1273 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1274 | getEventViewerDialog()->setSyncMode( false ); | 1274 | getEventViewerDialog()->setSyncMode( false ); |
1275 | if ( syncOK ) { | 1275 | if ( syncOK ) { |
1276 | if ( mSyncManager->mWriteBackFile ) | 1276 | if ( mSyncManager->mWriteBackFile ) |
1277 | { | 1277 | { |
1278 | storage->setSaveFormat( new ICalFormat() ); | 1278 | storage->setSaveFormat( new ICalFormat() ); |
1279 | storage->save(); | 1279 | storage->save(); |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | setModified( true ); | 1282 | setModified( true ); |
1283 | } | 1283 | } |
1284 | delete storage; | 1284 | delete storage; |
1285 | delete calendar; | 1285 | delete calendar; |
1286 | if ( syncOK ) | 1286 | if ( syncOK ) |
1287 | updateView(); | 1287 | updateView(); |
1288 | return syncOK; | 1288 | return syncOK; |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | void CalendarView::syncExternal( int mode ) | 1291 | void CalendarView::syncExternal( int mode ) |
1292 | { | 1292 | { |
1293 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1293 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1294 | 1294 | ||
1295 | qApp->processEvents(); | 1295 | qApp->processEvents(); |
1296 | CalendarLocal* calendar = new CalendarLocal(); | 1296 | CalendarLocal* calendar = new CalendarLocal(); |
1297 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1297 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1298 | bool syncOK = false; | 1298 | bool syncOK = false; |
1299 | bool loadSuccess = false; | 1299 | bool loadSuccess = false; |
1300 | PhoneFormat* phoneFormat = 0; | 1300 | PhoneFormat* phoneFormat = 0; |
1301 | emit tempDisableBR(true); | 1301 | emit tempDisableBR(true); |
1302 | #ifndef DESKTOP_VERSION | 1302 | #ifndef DESKTOP_VERSION |
1303 | SharpFormat* sharpFormat = 0; | 1303 | SharpFormat* sharpFormat = 0; |
1304 | if ( mode == 0 ) { // sharp | 1304 | if ( mode == 0 ) { // sharp |
1305 | sharpFormat = new SharpFormat () ; | 1305 | sharpFormat = new SharpFormat () ; |
1306 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1306 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1307 | 1307 | ||
1308 | } else | 1308 | } else |
1309 | #endif | 1309 | #endif |
1310 | if ( mode == 1 ) { // phone | 1310 | if ( mode == 1 ) { // phone |
1311 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1311 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1312 | mSyncManager->mPhoneDevice, | 1312 | mSyncManager->mPhoneDevice, |
1313 | mSyncManager->mPhoneConnection, | 1313 | mSyncManager->mPhoneConnection, |
1314 | mSyncManager->mPhoneModel); | 1314 | mSyncManager->mPhoneModel); |
1315 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1315 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1316 | 1316 | ||
1317 | } else { | 1317 | } else { |
1318 | emit tempDisableBR(false); | 1318 | emit tempDisableBR(false); |
1319 | return; | 1319 | return; |
1320 | } | 1320 | } |
1321 | if ( loadSuccess ) { | 1321 | if ( loadSuccess ) { |
1322 | getEventViewerDialog()->setSyncMode( true ); | 1322 | getEventViewerDialog()->setSyncMode( true ); |
1323 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1323 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1324 | getEventViewerDialog()->setSyncMode( false ); | 1324 | getEventViewerDialog()->setSyncMode( false ); |
1325 | qApp->processEvents(); | 1325 | qApp->processEvents(); |
1326 | if ( syncOK ) { | 1326 | if ( syncOK ) { |
1327 | if ( mSyncManager->mWriteBackFile ) | 1327 | if ( mSyncManager->mWriteBackFile ) |
1328 | { | 1328 | { |
1329 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1329 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1330 | Incidence* inc = iL.first(); | 1330 | Incidence* inc = iL.first(); |
1331 | if ( phoneFormat ) { | 1331 | if ( phoneFormat ) { |
1332 | while ( inc ) { | 1332 | while ( inc ) { |
1333 | inc->removeID(mCurrentSyncDevice); | 1333 | inc->removeID(mCurrentSyncDevice); |
1334 | inc = iL.next(); | 1334 | inc = iL.next(); |
1335 | } | 1335 | } |
1336 | } | 1336 | } |
1337 | #ifndef DESKTOP_VERSION | 1337 | #ifndef DESKTOP_VERSION |
1338 | if ( sharpFormat ) | 1338 | if ( sharpFormat ) |
1339 | sharpFormat->save(calendar); | 1339 | sharpFormat->save(calendar); |
1340 | #endif | 1340 | #endif |
1341 | if ( phoneFormat ) | 1341 | if ( phoneFormat ) |
1342 | phoneFormat->save(calendar); | 1342 | phoneFormat->save(calendar); |
1343 | iL = calendar->rawIncidences(); | 1343 | iL = calendar->rawIncidences(); |
1344 | inc = iL.first(); | 1344 | inc = iL.first(); |
1345 | Incidence* loc; | 1345 | Incidence* loc; |
1346 | while ( inc ) { | 1346 | while ( inc ) { |
1347 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1347 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1348 | loc = mCalendar->incidence(inc->uid() ); | 1348 | loc = mCalendar->incidence(inc->uid() ); |
1349 | if ( loc ) { | 1349 | if ( loc ) { |
1350 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1350 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1351 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1351 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1352 | } | 1352 | } |
1353 | } | 1353 | } |
1354 | inc = iL.next(); | 1354 | inc = iL.next(); |
1355 | } | 1355 | } |
1356 | Incidence* lse = getLastSyncEvent(); | 1356 | Incidence* lse = getLastSyncEvent(); |
1357 | if ( lse ) { | 1357 | if ( lse ) { |
1358 | lse->setReadOnly( false ); | 1358 | lse->setReadOnly( false ); |
1359 | lse->setDescription( "" ); | 1359 | lse->setDescription( "" ); |
1360 | lse->setReadOnly( true ); | 1360 | lse->setReadOnly( true ); |
1361 | } | 1361 | } |
1362 | } | 1362 | } |
1363 | } else { | 1363 | } else { |
1364 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1364 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1365 | } | 1365 | } |
1366 | setModified( true ); | 1366 | setModified( true ); |
1367 | } else { | 1367 | } else { |
1368 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1368 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1369 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1369 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1370 | question, i18n("Ok")) ; | 1370 | question, i18n("Ok")) ; |
1371 | 1371 | ||
1372 | } | 1372 | } |
1373 | delete calendar; | 1373 | delete calendar; |
1374 | updateView(); | 1374 | updateView(); |
1375 | emit tempDisableBR(false); | 1375 | emit tempDisableBR(false); |
1376 | return ;//syncOK; | 1376 | return ;//syncOK; |
1377 | 1377 | ||
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | bool CalendarView::importBday() | 1380 | bool CalendarView::importBday() |
1381 | { | 1381 | { |
1382 | #ifndef KORG_NOKABC | 1382 | #ifndef KORG_NOKABC |
1383 | 1383 | ||
1384 | #ifdef DESKTOP_VERSION | 1384 | #ifdef DESKTOP_VERSION |
1385 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1385 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1386 | KABC::AddressBook::Iterator it; | 1386 | KABC::AddressBook::Iterator it; |
1387 | int count = 0; | 1387 | int count = 0; |
1388 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1388 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1389 | ++count; | 1389 | ++count; |
1390 | } | 1390 | } |
1391 | QProgressBar bar(count,0 ); | 1391 | QProgressBar bar(count,0 ); |
1392 | int w = 300; | 1392 | int w = 300; |
1393 | if ( QApplication::desktop()->width() < 320 ) | 1393 | if ( QApplication::desktop()->width() < 320 ) |
1394 | w = 220; | 1394 | w = 220; |
1395 | int h = bar.sizeHint().height() ; | 1395 | int h = bar.sizeHint().height() ; |
1396 | int dw = QApplication::desktop()->width(); | 1396 | int dw = QApplication::desktop()->width(); |
1397 | int dh = QApplication::desktop()->height(); | 1397 | int dh = QApplication::desktop()->height(); |
1398 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1398 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1399 | bar.show(); | 1399 | bar.show(); |
1400 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1400 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1401 | qApp->processEvents(); | 1401 | qApp->processEvents(); |
1402 | count = 0; | 1402 | count = 0; |
1403 | int addCount = 0; | 1403 | int addCount = 0; |
1404 | KCal::Attendee* a = 0; | 1404 | KCal::Attendee* a = 0; |
1405 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1405 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1406 | if ( ! bar.isVisible() ) | 1406 | if ( ! bar.isVisible() ) |
1407 | return false; | 1407 | return false; |
1408 | bar.setProgress( count++ ); | 1408 | bar.setProgress( count++ ); |
1409 | qApp->processEvents(); | 1409 | qApp->processEvents(); |
1410 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1410 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1411 | if ( (*it).birthday().date().isValid() ){ | 1411 | if ( (*it).birthday().date().isValid() ){ |
1412 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1412 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1413 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1413 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1414 | ++addCount; | 1414 | ++addCount; |
1415 | } | 1415 | } |
1416 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1416 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1417 | if ( anni.isValid() ){ | 1417 | if ( anni.isValid() ){ |
1418 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1418 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1419 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1419 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1420 | ++addCount; | 1420 | ++addCount; |
1421 | } | 1421 | } |
1422 | } | 1422 | } |
1423 | updateView(); | 1423 | updateView(); |
1424 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1424 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1425 | #else //DESKTOP_VERSION | 1425 | #else //DESKTOP_VERSION |
1426 | 1426 | ||
1427 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1427 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1428 | // the result should now arrive through method insertBirthdays | 1428 | // the result should now arrive through method insertBirthdays |
1429 | 1429 | ||
1430 | #endif //DESKTOP_VERSION | 1430 | #endif //DESKTOP_VERSION |
1431 | 1431 | ||
1432 | #endif //KORG_NOKABC | 1432 | #endif //KORG_NOKABC |
1433 | 1433 | ||
1434 | 1434 | ||
1435 | return true; | 1435 | return true; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1438 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1439 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1439 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1440 | const QStringList& anniversaryList, const QStringList& realNameList, | 1440 | const QStringList& anniversaryList, const QStringList& realNameList, |
1441 | const QStringList& emailList, const QStringList& assembledNameList, | 1441 | const QStringList& emailList, const QStringList& assembledNameList, |
1442 | const QStringList& uidList) | 1442 | const QStringList& uidList) |
1443 | { | 1443 | { |
1444 | //qDebug("KO::CalendarView::insertBirthdays"); | 1444 | //qDebug("KO::CalendarView::insertBirthdays"); |
1445 | if (uid == this->name()) | 1445 | if (uid == this->name()) |
1446 | { | 1446 | { |
1447 | int count = birthdayList.count(); | 1447 | int count = birthdayList.count(); |
1448 | int addCount = 0; | 1448 | int addCount = 0; |
1449 | KCal::Attendee* a = 0; | 1449 | KCal::Attendee* a = 0; |
1450 | 1450 | ||
1451 | //qDebug("CalView 1 %i", count); | 1451 | //qDebug("CalView 1 %i", count); |
1452 | 1452 | ||
1453 | QProgressBar bar(count,0 ); | 1453 | QProgressBar bar(count,0 ); |
1454 | int w = 300; | 1454 | int w = 300; |
1455 | if ( QApplication::desktop()->width() < 320 ) | 1455 | if ( QApplication::desktop()->width() < 320 ) |
1456 | w = 220; | 1456 | w = 220; |
1457 | int h = bar.sizeHint().height() ; | 1457 | int h = bar.sizeHint().height() ; |
1458 | int dw = QApplication::desktop()->width(); | 1458 | int dw = QApplication::desktop()->width(); |
1459 | int dh = QApplication::desktop()->height(); | 1459 | int dh = QApplication::desktop()->height(); |
1460 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1460 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1461 | bar.show(); | 1461 | bar.show(); |
1462 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1462 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1463 | qApp->processEvents(); | 1463 | qApp->processEvents(); |
1464 | 1464 | ||
1465 | QDate birthday; | 1465 | QDate birthday; |
1466 | QDate anniversary; | 1466 | QDate anniversary; |
1467 | QString realName; | 1467 | QString realName; |
1468 | QString email; | 1468 | QString email; |
1469 | QString assembledName; | 1469 | QString assembledName; |
1470 | QString uid; | 1470 | QString uid; |
1471 | bool ok = true; | 1471 | bool ok = true; |
1472 | for ( int i = 0; i < count; i++) | 1472 | for ( int i = 0; i < count; i++) |
1473 | { | 1473 | { |
1474 | if ( ! bar.isVisible() ) | 1474 | if ( ! bar.isVisible() ) |
1475 | return; | 1475 | return; |
1476 | bar.setProgress( i ); | 1476 | bar.setProgress( i ); |
1477 | qApp->processEvents(); | 1477 | qApp->processEvents(); |
1478 | 1478 | ||
1479 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1479 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1480 | if (!ok) { | 1480 | if (!ok) { |
1481 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1481 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1484 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1485 | if (!ok) { | 1485 | if (!ok) { |
1486 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1486 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1487 | } | 1487 | } |
1488 | realName = realNameList[i]; | 1488 | realName = realNameList[i]; |
1489 | email = emailList[i]; | 1489 | email = emailList[i]; |
1490 | assembledName = assembledNameList[i]; | 1490 | assembledName = assembledNameList[i]; |
1491 | uid = uidList[i]; | 1491 | uid = uidList[i]; |
1492 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1492 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1493 | 1493 | ||
1494 | if ( birthday.isValid() ){ | 1494 | if ( birthday.isValid() ){ |
1495 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1495 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1496 | KCal::Attendee::ReqParticipant,uid) ; | 1496 | KCal::Attendee::ReqParticipant,uid) ; |
1497 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1497 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1498 | ++addCount; | 1498 | ++addCount; |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | if ( anniversary.isValid() ){ | 1501 | if ( anniversary.isValid() ){ |
1502 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1502 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1503 | KCal::Attendee::ReqParticipant,uid) ; | 1503 | KCal::Attendee::ReqParticipant,uid) ; |
1504 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1504 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1505 | ++addCount; | 1505 | ++addCount; |
1506 | } | 1506 | } |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | updateView(); | 1509 | updateView(); |
1510 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1510 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1511 | 1511 | ||
1512 | } | 1512 | } |
1513 | 1513 | ||
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | 1516 | ||
1517 | 1517 | ||
1518 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1518 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1519 | { | 1519 | { |
1520 | //qDebug("addAnni "); | 1520 | //qDebug("addAnni "); |
1521 | Event * ev = new Event(); | 1521 | Event * ev = new Event(); |
1522 | ev->setOrganizer(KOPrefs::instance()->email()); | 1522 | ev->setOrganizer(KOPrefs::instance()->email()); |
1523 | if ( a ) { | 1523 | if ( a ) { |
1524 | ev->addAttendee( a ); | 1524 | ev->addAttendee( a ); |
1525 | } | 1525 | } |
1526 | QString kind; | 1526 | QString kind; |
1527 | if ( birthday ) { | 1527 | if ( birthday ) { |
1528 | kind = i18n( "Birthday" ); | 1528 | kind = i18n( "Birthday" ); |
1529 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1529 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1530 | } | 1530 | } |
1531 | else { | 1531 | else { |
1532 | kind = i18n( "Anniversary" ); | 1532 | kind = i18n( "Anniversary" ); |
1533 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1533 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1534 | } | 1534 | } |
1535 | ev->setCategories( kind ); | 1535 | ev->setCategories( kind ); |
1536 | ev->setDtStart( QDateTime(date) ); | 1536 | ev->setDtStart( QDateTime(date) ); |
1537 | ev->setDtEnd( QDateTime(date) ); | 1537 | ev->setDtEnd( QDateTime(date) ); |
1538 | ev->setFloats( true ); | 1538 | ev->setFloats( true ); |
1539 | Recurrence * rec = ev->recurrence(); | 1539 | Recurrence * rec = ev->recurrence(); |
1540 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1540 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1541 | rec->addYearlyNum( date.month() ); | 1541 | rec->addYearlyNum( date.month() ); |
1542 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1542 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1543 | delete ev; | 1543 | delete ev; |
1544 | return false; | 1544 | return false; |
1545 | } | 1545 | } |
1546 | return true; | 1546 | return true; |
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | bool CalendarView::importQtopia( const QString &categories, | 1549 | bool CalendarView::importQtopia( const QString &categories, |
1550 | const QString &datebook, | 1550 | const QString &datebook, |
1551 | const QString &todolist ) | 1551 | const QString &todolist ) |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | QtopiaFormat qtopiaFormat; | 1554 | QtopiaFormat qtopiaFormat; |
1555 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1555 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1556 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1556 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1557 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1557 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1558 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1558 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1559 | 1559 | ||
1560 | updateView(); | 1560 | updateView(); |
1561 | return true; | 1561 | return true; |
1562 | 1562 | ||
1563 | #if 0 | 1563 | #if 0 |
1564 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1564 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1565 | mCurrentSyncDevice = "qtopia-XML"; | 1565 | mCurrentSyncDevice = "qtopia-XML"; |
1566 | if ( mSyncManager->mAskForPreferences ) | 1566 | if ( mSyncManager->mAskForPreferences ) |
1567 | edit_sync_options(); | 1567 | edit_sync_options(); |
1568 | qApp->processEvents(); | 1568 | qApp->processEvents(); |
1569 | CalendarLocal* calendar = new CalendarLocal(); | 1569 | CalendarLocal* calendar = new CalendarLocal(); |
1570 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1570 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1571 | bool syncOK = false; | 1571 | bool syncOK = false; |
1572 | QtopiaFormat qtopiaFormat; | 1572 | QtopiaFormat qtopiaFormat; |
1573 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1573 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1574 | bool loadOk = true; | 1574 | bool loadOk = true; |
1575 | if ( !categories.isEmpty() ) | 1575 | if ( !categories.isEmpty() ) |
1576 | loadOk = qtopiaFormat.load( calendar, categories ); | 1576 | loadOk = qtopiaFormat.load( calendar, categories ); |
1577 | if ( loadOk && !datebook.isEmpty() ) | 1577 | if ( loadOk && !datebook.isEmpty() ) |
1578 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1578 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1579 | if ( loadOk && !todolist.isEmpty() ) | 1579 | if ( loadOk && !todolist.isEmpty() ) |
1580 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1580 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1581 | 1581 | ||
1582 | if ( loadOk ) { | 1582 | if ( loadOk ) { |
1583 | getEventViewerDialog()->setSyncMode( true ); | 1583 | getEventViewerDialog()->setSyncMode( true ); |
1584 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1584 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1585 | getEventViewerDialog()->setSyncMode( false ); | 1585 | getEventViewerDialog()->setSyncMode( false ); |
1586 | qApp->processEvents(); | 1586 | qApp->processEvents(); |
1587 | if ( syncOK ) { | 1587 | if ( syncOK ) { |
1588 | if ( mSyncManager->mWriteBackFile ) | 1588 | if ( mSyncManager->mWriteBackFile ) |
1589 | { | 1589 | { |
1590 | // write back XML file | 1590 | // write back XML file |
1591 | 1591 | ||
1592 | } | 1592 | } |
1593 | setModified( true ); | 1593 | setModified( true ); |
1594 | } | 1594 | } |
1595 | } else { | 1595 | } else { |
1596 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1596 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1597 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1597 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1598 | question, i18n("Ok")) ; | 1598 | question, i18n("Ok")) ; |
1599 | } | 1599 | } |
1600 | delete calendar; | 1600 | delete calendar; |
1601 | updateView(); | 1601 | updateView(); |
1602 | return syncOK; | 1602 | return syncOK; |
1603 | 1603 | ||
1604 | 1604 | ||
1605 | #endif | 1605 | #endif |
1606 | 1606 | ||
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | void CalendarView::setSyncEventsReadOnly() | 1609 | void CalendarView::setSyncEventsReadOnly() |
1610 | { | 1610 | { |
1611 | Event * ev; | 1611 | Event * ev; |
1612 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1612 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1613 | ev = eL.first(); | 1613 | ev = eL.first(); |
1614 | while ( ev ) { | 1614 | while ( ev ) { |
1615 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1615 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1616 | ev->setReadOnly( true ); | 1616 | ev->setReadOnly( true ); |
1617 | ev = eL.next(); | 1617 | ev = eL.next(); |
1618 | } | 1618 | } |
1619 | } | 1619 | } |
1620 | bool CalendarView::openCalendar(QString filename, bool merge) | 1620 | bool CalendarView::openCalendar(QString filename, bool merge) |
1621 | { | 1621 | { |
1622 | 1622 | ||
1623 | if (filename.isEmpty()) { | 1623 | if (filename.isEmpty()) { |
1624 | return false; | 1624 | return false; |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | if (!QFile::exists(filename)) { | 1627 | if (!QFile::exists(filename)) { |
1628 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1628 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1629 | return false; | 1629 | return false; |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | globalFlagBlockAgenda = 1; | 1632 | globalFlagBlockAgenda = 1; |
1633 | if (!merge) mCalendar->close(); | 1633 | if (!merge) mCalendar->close(); |
1634 | 1634 | ||
1635 | mStorage->setFileName( filename ); | 1635 | mStorage->setFileName( filename ); |
1636 | 1636 | ||
1637 | if ( mStorage->load() ) { | 1637 | if ( mStorage->load() ) { |
1638 | if ( merge ) ;//setModified( true ); | 1638 | if ( merge ) ;//setModified( true ); |
1639 | else { | 1639 | else { |
1640 | //setModified( true ); | 1640 | //setModified( true ); |
1641 | mViewManager->setDocumentId( filename ); | 1641 | mViewManager->setDocumentId( filename ); |
1642 | mDialogManager->setDocumentId( filename ); | 1642 | mDialogManager->setDocumentId( filename ); |
1643 | mTodoList->setDocumentId( filename ); | 1643 | mTodoList->setDocumentId( filename ); |
1644 | } | 1644 | } |
1645 | globalFlagBlockAgenda = 2; | 1645 | globalFlagBlockAgenda = 2; |
1646 | // if ( getLastSyncEvent() ) | 1646 | // if ( getLastSyncEvent() ) |
1647 | // getLastSyncEvent()->setReadOnly( true ); | 1647 | // getLastSyncEvent()->setReadOnly( true ); |
1648 | mCalendar->reInitAlarmSettings(); | 1648 | mCalendar->reInitAlarmSettings(); |
1649 | setSyncEventsReadOnly(); | 1649 | setSyncEventsReadOnly(); |
1650 | updateUnmanagedViews(); | 1650 | updateUnmanagedViews(); |
1651 | updateView(); | 1651 | updateView(); |
1652 | if ( filename != MainWindow::defaultFileName() ) { | 1652 | if ( filename != MainWindow::defaultFileName() ) { |
1653 | saveCalendar( MainWindow::defaultFileName() ); | 1653 | saveCalendar( MainWindow::defaultFileName() ); |
1654 | } else { | 1654 | } else { |
1655 | QFileInfo finf ( MainWindow::defaultFileName()); | 1655 | QFileInfo finf ( MainWindow::defaultFileName()); |
1656 | if ( finf.exists() ) { | 1656 | if ( finf.exists() ) { |
1657 | setLoadedFileVersion( finf.lastModified () ); | 1657 | setLoadedFileVersion( finf.lastModified () ); |
1658 | } | 1658 | } |
1659 | } | 1659 | } |
1660 | return true; | 1660 | return true; |
1661 | } else { | 1661 | } else { |
1662 | // while failing to load, the calendar object could | 1662 | // while failing to load, the calendar object could |
1663 | // have become partially populated. Clear it out. | 1663 | // have become partially populated. Clear it out. |
1664 | if ( !merge ) { | 1664 | if ( !merge ) { |
1665 | mCalendar->close(); | 1665 | mCalendar->close(); |
1666 | mViewManager->setDocumentId( filename ); | 1666 | mViewManager->setDocumentId( filename ); |
1667 | mDialogManager->setDocumentId( filename ); | 1667 | mDialogManager->setDocumentId( filename ); |
1668 | mTodoList->setDocumentId( filename ); | 1668 | mTodoList->setDocumentId( filename ); |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1671 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1672 | 1672 | ||
1673 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1673 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1674 | globalFlagBlockAgenda = 2; | 1674 | globalFlagBlockAgenda = 2; |
1675 | mCalendar->reInitAlarmSettings(); | 1675 | mCalendar->reInitAlarmSettings(); |
1676 | setSyncEventsReadOnly(); | 1676 | setSyncEventsReadOnly(); |
1677 | updateUnmanagedViews(); | 1677 | updateUnmanagedViews(); |
1678 | updateView(); | 1678 | updateView(); |
1679 | } | 1679 | } |
1680 | return false; | 1680 | return false; |
1681 | } | 1681 | } |
1682 | void CalendarView::showOpenError() | 1682 | void CalendarView::showOpenError() |
1683 | { | 1683 | { |
1684 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1684 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1685 | } | 1685 | } |
1686 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1686 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1687 | { | 1687 | { |
1688 | loadedFileVersion = dt; | 1688 | loadedFileVersion = dt; |
1689 | } | 1689 | } |
1690 | bool CalendarView::checkFileChanged(QString fn) | 1690 | bool CalendarView::checkFileChanged(QString fn) |
1691 | { | 1691 | { |
1692 | QFileInfo finf ( fn ); | 1692 | QFileInfo finf ( fn ); |
1693 | if ( !finf.exists() ) | 1693 | if ( !finf.exists() ) |
1694 | return true; | 1694 | return true; |
1695 | QDateTime dt = finf.lastModified (); | 1695 | QDateTime dt = finf.lastModified (); |
1696 | if ( dt <= loadedFileVersion ) | 1696 | if ( dt <= loadedFileVersion ) |
1697 | return false; | 1697 | return false; |
1698 | return true; | 1698 | return true; |
1699 | 1699 | ||
1700 | } | 1700 | } |
1701 | void CalendarView::watchSavedFile() | 1701 | void CalendarView::watchSavedFile() |
1702 | { | 1702 | { |
1703 | QFileInfo finf ( MainWindow::defaultFileName()); | 1703 | QFileInfo finf ( MainWindow::defaultFileName()); |
1704 | if ( !finf.exists() ) | 1704 | if ( !finf.exists() ) |
1705 | return; | 1705 | return; |
1706 | QDateTime dt = finf.lastModified (); | 1706 | QDateTime dt = finf.lastModified (); |
1707 | if ( dt < loadedFileVersion ) { | 1707 | if ( dt < loadedFileVersion ) { |
1708 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1708 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1709 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1709 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1710 | return; | 1710 | return; |
1711 | } | 1711 | } |
1712 | loadedFileVersion = dt; | 1712 | loadedFileVersion = dt; |
1713 | } | 1713 | } |
1714 | 1714 | ||
1715 | bool CalendarView::checkFileVersion(QString fn) | 1715 | bool CalendarView::checkFileVersion(QString fn) |
1716 | { | 1716 | { |
1717 | QFileInfo finf ( fn ); | 1717 | QFileInfo finf ( fn ); |
1718 | if ( !finf.exists() ) | 1718 | if ( !finf.exists() ) |
1719 | return true; | 1719 | return true; |
1720 | QDateTime dt = finf.lastModified (); | 1720 | QDateTime dt = finf.lastModified (); |
1721 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1721 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1722 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1722 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1723 | if ( dt <= loadedFileVersion ) | 1723 | if ( dt <= loadedFileVersion ) |
1724 | return true; | 1724 | return true; |
1725 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1725 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1726 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1726 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1727 | i18n("Sync+save")); | 1727 | i18n("Sync+save")); |
1728 | 1728 | ||
1729 | if ( km == KMessageBox::Cancel ) | 1729 | if ( km == KMessageBox::Cancel ) |
1730 | return false; | 1730 | return false; |
1731 | if ( km == KMessageBox::Yes ) | 1731 | if ( km == KMessageBox::Yes ) |
1732 | return true; | 1732 | return true; |
1733 | 1733 | ||
1734 | setSyncDevice("deleteaftersync" ); | 1734 | setSyncDevice("deleteaftersync" ); |
1735 | mSyncManager->mAskForPreferences = true; | 1735 | mSyncManager->mAskForPreferences = true; |
1736 | mSyncManager->mSyncAlgoPrefs = 3; | 1736 | mSyncManager->mSyncAlgoPrefs = 3; |
1737 | mSyncManager->mWriteBackFile = false; | 1737 | mSyncManager->mWriteBackFile = false; |
1738 | mSyncManager->mWriteBackExistingOnly = false; | 1738 | mSyncManager->mWriteBackExistingOnly = false; |
1739 | mSyncManager->mShowSyncSummary = false; | 1739 | mSyncManager->mShowSyncSummary = false; |
1740 | syncCalendar( fn, 3 ); | 1740 | syncCalendar( fn, 3 ); |
1741 | Event * e = getLastSyncEvent(); | 1741 | Event * e = getLastSyncEvent(); |
1742 | mCalendar->deleteEvent ( e ); | 1742 | mCalendar->deleteEvent ( e ); |
1743 | updateView(); | 1743 | updateView(); |
1744 | return true; | 1744 | return true; |
1745 | } | 1745 | } |
1746 | 1746 | ||
1747 | bool CalendarView::saveCalendar( QString filename ) | 1747 | bool CalendarView::saveCalendar( QString filename ) |
1748 | { | 1748 | { |
1749 | 1749 | ||
1750 | // Store back all unsaved data into calendar object | 1750 | // Store back all unsaved data into calendar object |
1751 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1751 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1752 | if ( mViewManager->currentView() ) | 1752 | if ( mViewManager->currentView() ) |
1753 | mViewManager->currentView()->flushView(); | 1753 | mViewManager->currentView()->flushView(); |
1754 | 1754 | ||
1755 | 1755 | ||
1756 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1756 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1757 | mStorage->setSaveFormat( new ICalFormat() ); | 1757 | mStorage->setSaveFormat( new ICalFormat() ); |
1758 | mStorage->setFileName( filename ); | 1758 | mStorage->setFileName( filename ); |
1759 | bool success; | 1759 | bool success; |
1760 | success = mStorage->save(); | 1760 | success = mStorage->save(); |
1761 | if ( !success ) { | 1761 | if ( !success ) { |
1762 | return false; | 1762 | return false; |
1763 | } | 1763 | } |
1764 | if ( filename == MainWindow::defaultFileName() ) { | 1764 | if ( filename == MainWindow::defaultFileName() ) { |
1765 | setLoadedFileVersion( lfv ); | 1765 | setLoadedFileVersion( lfv ); |
1766 | watchSavedFile(); | 1766 | watchSavedFile(); |
1767 | } | 1767 | } |
1768 | return true; | 1768 | return true; |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | void CalendarView::closeCalendar() | 1771 | void CalendarView::closeCalendar() |
1772 | { | 1772 | { |
1773 | 1773 | ||
1774 | // child windows no longer valid | 1774 | // child windows no longer valid |
1775 | emit closingDown(); | 1775 | emit closingDown(); |
1776 | 1776 | ||
1777 | mCalendar->close(); | 1777 | mCalendar->close(); |
1778 | setModified(false); | 1778 | setModified(false); |
1779 | updateView(); | 1779 | updateView(); |
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | void CalendarView::archiveCalendar() | 1782 | void CalendarView::archiveCalendar() |
1783 | { | 1783 | { |
1784 | mDialogManager->showArchiveDialog(); | 1784 | mDialogManager->showArchiveDialog(); |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | 1787 | ||
1788 | void CalendarView::readSettings() | 1788 | void CalendarView::readSettings() |
1789 | { | 1789 | { |
1790 | 1790 | ||
1791 | 1791 | ||
1792 | // mViewManager->showAgendaView(); | 1792 | // mViewManager->showAgendaView(); |
1793 | QString str; | 1793 | QString str; |
1794 | //qDebug("CalendarView::readSettings() "); | 1794 | //qDebug("CalendarView::readSettings() "); |
1795 | // read settings from the KConfig, supplying reasonable | 1795 | // read settings from the KConfig, supplying reasonable |
1796 | // defaults where none are to be found | 1796 | // defaults where none are to be found |
1797 | KConfig *config = KOGlobals::config(); | 1797 | KConfig *config = KOGlobals::config(); |
1798 | #ifndef KORG_NOSPLITTER | 1798 | #ifndef KORG_NOSPLITTER |
1799 | config->setGroup("KOrganizer Geometry"); | 1799 | config->setGroup("KOrganizer Geometry"); |
1800 | 1800 | ||
1801 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1801 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1802 | if (sizes.count() != 2) { | 1802 | if (sizes.count() != 2) { |
1803 | sizes << mDateNavigator->minimumSizeHint().width(); | 1803 | sizes << mDateNavigator->minimumSizeHint().width(); |
1804 | sizes << 300; | 1804 | sizes << 300; |
1805 | } | 1805 | } |
1806 | mPanner->setSizes(sizes); | 1806 | mPanner->setSizes(sizes); |
1807 | 1807 | ||
1808 | sizes = config->readIntListEntry("Separator2"); | 1808 | sizes = config->readIntListEntry("Separator2"); |
1809 | if ( ( mResourceView && sizes.count() == 4 ) || | 1809 | if ( ( mResourceView && sizes.count() == 4 ) || |
1810 | ( !mResourceView && sizes.count() == 3 ) ) { | 1810 | ( !mResourceView && sizes.count() == 3 ) ) { |
1811 | mLeftSplitter->setSizes(sizes); | 1811 | mLeftSplitter->setSizes(sizes); |
1812 | } | 1812 | } |
1813 | #endif | 1813 | #endif |
1814 | globalFlagBlockAgenda = 1; | 1814 | globalFlagBlockAgenda = 1; |
1815 | mViewManager->showAgendaView(); | 1815 | mViewManager->showAgendaView(); |
1816 | //mViewManager->readSettings( config ); | 1816 | //mViewManager->readSettings( config ); |
1817 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1817 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1818 | readFilterSettings(config); | 1818 | readFilterSettings(config); |
1819 | config->setGroup( "Views" ); | 1819 | config->setGroup( "Views" ); |
1820 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1820 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1821 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1821 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1822 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1822 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1823 | else mNavigator->selectDates( dateCount ); | 1823 | else mNavigator->selectDates( dateCount ); |
1824 | // mViewManager->readSettings( config ); | 1824 | // mViewManager->readSettings( config ); |
1825 | updateConfig(); | 1825 | updateConfig(); |
1826 | globalFlagBlockAgenda = 2; | 1826 | globalFlagBlockAgenda = 2; |
1827 | mViewManager->readSettings( config ); | 1827 | mViewManager->readSettings( config ); |
1828 | #ifdef DESKTOP_VERSION | 1828 | #ifdef DESKTOP_VERSION |
1829 | config->setGroup("WidgetLayout"); | 1829 | config->setGroup("WidgetLayout"); |
1830 | QStringList list; | 1830 | QStringList list; |
1831 | list = config->readListEntry("MainLayout"); | 1831 | list = config->readListEntry("MainLayout"); |
1832 | int x,y,w,h; | 1832 | int x,y,w,h; |
1833 | if ( ! list.isEmpty() ) { | 1833 | if ( ! list.isEmpty() ) { |
1834 | x = list[0].toInt(); | 1834 | x = list[0].toInt(); |
1835 | y = list[1].toInt(); | 1835 | y = list[1].toInt(); |
1836 | w = list[2].toInt(); | 1836 | w = list[2].toInt(); |
1837 | h = list[3].toInt(); | 1837 | h = list[3].toInt(); |
1838 | topLevelWidget()->setGeometry(x,y,w,h); | 1838 | topLevelWidget()->setGeometry(x,y,w,h); |
1839 | 1839 | ||
1840 | } else { | 1840 | } else { |
1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1842 | } | 1842 | } |
1843 | list = config->readListEntry("EditEventLayout"); | 1843 | list = config->readListEntry("EditEventLayout"); |
1844 | if ( ! list.isEmpty() ) { | 1844 | if ( ! list.isEmpty() ) { |
1845 | x = list[0].toInt(); | 1845 | x = list[0].toInt(); |
1846 | y = list[1].toInt(); | 1846 | y = list[1].toInt(); |
1847 | w = list[2].toInt(); | 1847 | w = list[2].toInt(); |
1848 | h = list[3].toInt(); | 1848 | h = list[3].toInt(); |
1849 | mEventEditor->setGeometry(x,y,w,h); | 1849 | mEventEditor->setGeometry(x,y,w,h); |
1850 | 1850 | ||
1851 | } | 1851 | } |
1852 | list = config->readListEntry("EditTodoLayout"); | 1852 | list = config->readListEntry("EditTodoLayout"); |
1853 | if ( ! list.isEmpty() ) { | 1853 | if ( ! list.isEmpty() ) { |
1854 | x = list[0].toInt(); | 1854 | x = list[0].toInt(); |
1855 | y = list[1].toInt(); | 1855 | y = list[1].toInt(); |
1856 | w = list[2].toInt(); | 1856 | w = list[2].toInt(); |
1857 | h = list[3].toInt(); | 1857 | h = list[3].toInt(); |
1858 | mTodoEditor->setGeometry(x,y,w,h); | 1858 | mTodoEditor->setGeometry(x,y,w,h); |
1859 | 1859 | ||
1860 | } | 1860 | } |
1861 | list = config->readListEntry("ViewerLayout"); | 1861 | list = config->readListEntry("ViewerLayout"); |
1862 | if ( ! list.isEmpty() ) { | 1862 | if ( ! list.isEmpty() ) { |
1863 | x = list[0].toInt(); | 1863 | x = list[0].toInt(); |
1864 | y = list[1].toInt(); | 1864 | y = list[1].toInt(); |
1865 | w = list[2].toInt(); | 1865 | w = list[2].toInt(); |
1866 | h = list[3].toInt(); | 1866 | h = list[3].toInt(); |
1867 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1867 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1868 | } | 1868 | } |
1869 | #endif | 1869 | #endif |
1870 | 1870 | ||
1871 | } | 1871 | } |
1872 | 1872 | ||
1873 | 1873 | ||
1874 | void CalendarView::writeSettings() | 1874 | void CalendarView::writeSettings() |
1875 | { | 1875 | { |
1876 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1876 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1877 | 1877 | ||
1878 | KConfig *config = KOGlobals::config(); | 1878 | KConfig *config = KOGlobals::config(); |
1879 | 1879 | ||
1880 | #ifndef KORG_NOSPLITTER | 1880 | #ifndef KORG_NOSPLITTER |
1881 | config->setGroup("KOrganizer Geometry"); | 1881 | config->setGroup("KOrganizer Geometry"); |
1882 | 1882 | ||
1883 | QValueList<int> list = mPanner->sizes(); | 1883 | QValueList<int> list = mPanner->sizes(); |
1884 | config->writeEntry("Separator1",list); | 1884 | config->writeEntry("Separator1",list); |
1885 | 1885 | ||
1886 | list = mLeftSplitter->sizes(); | 1886 | list = mLeftSplitter->sizes(); |
1887 | config->writeEntry("Separator2",list); | 1887 | config->writeEntry("Separator2",list); |
1888 | #endif | 1888 | #endif |
1889 | 1889 | ||
1890 | mViewManager->writeSettings( config ); | 1890 | mViewManager->writeSettings( config ); |
1891 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1891 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1892 | mDialogManager->writeSettings( config ); | 1892 | mDialogManager->writeSettings( config ); |
1893 | //KOPrefs::instance()->usrWriteConfig(); | 1893 | //KOPrefs::instance()->usrWriteConfig(); |
1894 | KOPrefs::instance()->writeConfig(); | 1894 | KOPrefs::instance()->writeConfig(); |
1895 | 1895 | ||
1896 | writeFilterSettings(config); | 1896 | writeFilterSettings(config); |
1897 | 1897 | ||
1898 | config->setGroup( "Views" ); | 1898 | config->setGroup( "Views" ); |
1899 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1899 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1900 | 1900 | ||
1901 | #ifdef DESKTOP_VERSION | 1901 | #ifdef DESKTOP_VERSION |
1902 | config->setGroup("WidgetLayout"); | 1902 | config->setGroup("WidgetLayout"); |
1903 | QStringList list ;//= config->readListEntry("MainLayout"); | 1903 | QStringList list ;//= config->readListEntry("MainLayout"); |
1904 | int x,y,w,h; | 1904 | int x,y,w,h; |
1905 | QWidget* wid; | 1905 | QWidget* wid; |
1906 | wid = topLevelWidget(); | 1906 | wid = topLevelWidget(); |
1907 | x = wid->geometry().x(); | 1907 | x = wid->geometry().x(); |
1908 | y = wid->geometry().y(); | 1908 | y = wid->geometry().y(); |
1909 | w = wid->width(); | 1909 | w = wid->width(); |
1910 | h = wid->height(); | 1910 | h = wid->height(); |
1911 | list.clear(); | 1911 | list.clear(); |
1912 | list << QString::number( x ); | 1912 | list << QString::number( x ); |
1913 | list << QString::number( y ); | 1913 | list << QString::number( y ); |
1914 | list << QString::number( w ); | 1914 | list << QString::number( w ); |
1915 | list << QString::number( h ); | 1915 | list << QString::number( h ); |
1916 | config->writeEntry("MainLayout",list ); | 1916 | config->writeEntry("MainLayout",list ); |
1917 | 1917 | ||
1918 | wid = mEventEditor; | 1918 | wid = mEventEditor; |
1919 | x = wid->geometry().x(); | 1919 | x = wid->geometry().x(); |
1920 | y = wid->geometry().y(); | 1920 | y = wid->geometry().y(); |
1921 | w = wid->width(); | 1921 | w = wid->width(); |
1922 | h = wid->height(); | 1922 | h = wid->height(); |
1923 | list.clear(); | 1923 | list.clear(); |
1924 | list << QString::number( x ); | 1924 | list << QString::number( x ); |
1925 | list << QString::number( y ); | 1925 | list << QString::number( y ); |
1926 | list << QString::number( w ); | 1926 | list << QString::number( w ); |
1927 | list << QString::number( h ); | 1927 | list << QString::number( h ); |
1928 | config->writeEntry("EditEventLayout",list ); | 1928 | config->writeEntry("EditEventLayout",list ); |
1929 | 1929 | ||
1930 | wid = mTodoEditor; | 1930 | wid = mTodoEditor; |
1931 | x = wid->geometry().x(); | 1931 | x = wid->geometry().x(); |
1932 | y = wid->geometry().y(); | 1932 | y = wid->geometry().y(); |
1933 | w = wid->width(); | 1933 | w = wid->width(); |
1934 | h = wid->height(); | 1934 | h = wid->height(); |
1935 | list.clear(); | 1935 | list.clear(); |
1936 | list << QString::number( x ); | 1936 | list << QString::number( x ); |
1937 | list << QString::number( y ); | 1937 | list << QString::number( y ); |
1938 | list << QString::number( w ); | 1938 | list << QString::number( w ); |
1939 | list << QString::number( h ); | 1939 | list << QString::number( h ); |
1940 | config->writeEntry("EditTodoLayout",list ); | 1940 | config->writeEntry("EditTodoLayout",list ); |
1941 | wid = getEventViewerDialog(); | 1941 | wid = getEventViewerDialog(); |
1942 | x = wid->geometry().x(); | 1942 | x = wid->geometry().x(); |
1943 | y = wid->geometry().y(); | 1943 | y = wid->geometry().y(); |
1944 | w = wid->width(); | 1944 | w = wid->width(); |
1945 | h = wid->height(); | 1945 | h = wid->height(); |
1946 | list.clear(); | 1946 | list.clear(); |
1947 | list << QString::number( x ); | 1947 | list << QString::number( x ); |
1948 | list << QString::number( y ); | 1948 | list << QString::number( y ); |
1949 | list << QString::number( w ); | 1949 | list << QString::number( w ); |
1950 | list << QString::number( h ); | 1950 | list << QString::number( h ); |
1951 | config->writeEntry("ViewerLayout",list ); | 1951 | config->writeEntry("ViewerLayout",list ); |
1952 | wid = mDialogManager->getSearchDialog(); | 1952 | wid = mDialogManager->getSearchDialog(); |
1953 | if ( wid ) { | 1953 | if ( wid ) { |
1954 | x = wid->geometry().x(); | 1954 | x = wid->geometry().x(); |
1955 | y = wid->geometry().y(); | 1955 | y = wid->geometry().y(); |
1956 | w = wid->width(); | 1956 | w = wid->width(); |
1957 | h = wid->height(); | 1957 | h = wid->height(); |
1958 | list.clear(); | 1958 | list.clear(); |
1959 | list << QString::number( x ); | 1959 | list << QString::number( x ); |
1960 | list << QString::number( y ); | 1960 | list << QString::number( y ); |
1961 | list << QString::number( w ); | 1961 | list << QString::number( w ); |
1962 | list << QString::number( h ); | 1962 | list << QString::number( h ); |
1963 | config->writeEntry("SearchLayout",list ); | 1963 | config->writeEntry("SearchLayout",list ); |
1964 | } | 1964 | } |
1965 | #endif | 1965 | #endif |
1966 | 1966 | ||
1967 | 1967 | ||
1968 | config->sync(); | 1968 | config->sync(); |
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | void CalendarView::readFilterSettings(KConfig *config) | 1971 | void CalendarView::readFilterSettings(KConfig *config) |
1972 | { | 1972 | { |
1973 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1973 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1974 | 1974 | ||
1975 | mFilters.clear(); | 1975 | mFilters.clear(); |
1976 | 1976 | ||
1977 | config->setGroup("General"); | 1977 | config->setGroup("General"); |
1978 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1978 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1979 | 1979 | ||
1980 | QStringList::ConstIterator it = filterList.begin(); | 1980 | QStringList::ConstIterator it = filterList.begin(); |
1981 | QStringList::ConstIterator end = filterList.end(); | 1981 | QStringList::ConstIterator end = filterList.end(); |
1982 | while(it != end) { | 1982 | while(it != end) { |
1983 | // kdDebug() << " filter: " << (*it) << endl; | 1983 | // kdDebug() << " filter: " << (*it) << endl; |
1984 | 1984 | ||
1985 | CalFilter *filter; | 1985 | CalFilter *filter; |
1986 | filter = new CalFilter(*it); | 1986 | filter = new CalFilter(*it); |
1987 | config->setGroup("Filter_" + (*it)); | 1987 | config->setGroup("Filter_" + (*it)); |
1988 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1988 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1989 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1989 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1990 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1990 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1991 | mFilters.append(filter); | 1991 | mFilters.append(filter); |
1992 | 1992 | ||
1993 | ++it; | 1993 | ++it; |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | if (mFilters.count() == 0) { | 1996 | if (mFilters.count() == 0) { |
1997 | CalFilter *filter = new CalFilter(i18n("Default")); | 1997 | CalFilter *filter = new CalFilter(i18n("Default")); |
1998 | mFilters.append(filter); | 1998 | mFilters.append(filter); |
1999 | } | 1999 | } |
2000 | mFilterView->updateFilters(); | 2000 | mFilterView->updateFilters(); |
2001 | config->setGroup("FilterView"); | 2001 | config->setGroup("FilterView"); |
2002 | 2002 | ||
2003 | mFilterView->blockSignals(true); | 2003 | mFilterView->blockSignals(true); |
2004 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2004 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2005 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2005 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2006 | mFilterView->blockSignals(false); | 2006 | mFilterView->blockSignals(false); |
2007 | // We do it manually to avoid it being done twice by the above calls | 2007 | // We do it manually to avoid it being done twice by the above calls |
2008 | updateFilter(); | 2008 | updateFilter(); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void CalendarView::writeFilterSettings(KConfig *config) | 2011 | void CalendarView::writeFilterSettings(KConfig *config) |
2012 | { | 2012 | { |
2013 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2013 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2014 | 2014 | ||
2015 | QStringList filterList; | 2015 | QStringList filterList; |
2016 | 2016 | ||
2017 | CalFilter *filter = mFilters.first(); | 2017 | CalFilter *filter = mFilters.first(); |
2018 | while(filter) { | 2018 | while(filter) { |
2019 | // kdDebug() << " fn: " << filter->name() << endl; | 2019 | // kdDebug() << " fn: " << filter->name() << endl; |
2020 | filterList << filter->name(); | 2020 | filterList << filter->name(); |
2021 | config->setGroup("Filter_" + filter->name()); | 2021 | config->setGroup("Filter_" + filter->name()); |
2022 | config->writeEntry("Criteria",filter->criteria()); | 2022 | config->writeEntry("Criteria",filter->criteria()); |
2023 | config->writeEntry("CategoryList",filter->categoryList()); | 2023 | config->writeEntry("CategoryList",filter->categoryList()); |
2024 | filter = mFilters.next(); | 2024 | filter = mFilters.next(); |
2025 | } | 2025 | } |
2026 | config->setGroup("General"); | 2026 | config->setGroup("General"); |
2027 | config->writeEntry("CalendarFilters",filterList); | 2027 | config->writeEntry("CalendarFilters",filterList); |
2028 | 2028 | ||
2029 | config->setGroup("FilterView"); | 2029 | config->setGroup("FilterView"); |
2030 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2030 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2031 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2031 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2032 | } | 2032 | } |
2033 | 2033 | ||
2034 | 2034 | ||
2035 | void CalendarView::goToday() | 2035 | void CalendarView::goToday() |
2036 | { | 2036 | { |
2037 | if ( mViewManager->currentView()->isMonthView() ) | 2037 | if ( mViewManager->currentView()->isMonthView() ) |
2038 | mNavigator->selectTodayMonth(); | 2038 | mNavigator->selectTodayMonth(); |
2039 | else | 2039 | else |
2040 | mNavigator->selectToday(); | 2040 | mNavigator->selectToday(); |
2041 | } | 2041 | } |
2042 | 2042 | ||
2043 | void CalendarView::goNext() | 2043 | void CalendarView::goNext() |
2044 | { | 2044 | { |
2045 | mNavigator->selectNext(); | 2045 | mNavigator->selectNext(); |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | void CalendarView::goPrevious() | 2048 | void CalendarView::goPrevious() |
2049 | { | 2049 | { |
2050 | mNavigator->selectPrevious(); | 2050 | mNavigator->selectPrevious(); |
2051 | } | 2051 | } |
2052 | void CalendarView::goNextMonth() | 2052 | void CalendarView::goNextMonth() |
2053 | { | 2053 | { |
2054 | mNavigator->selectNextMonth(); | 2054 | mNavigator->selectNextMonth(); |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void CalendarView::goPreviousMonth() | 2057 | void CalendarView::goPreviousMonth() |
2058 | { | 2058 | { |
2059 | mNavigator->selectPreviousMonth(); | 2059 | mNavigator->selectPreviousMonth(); |
2060 | } | 2060 | } |
2061 | void CalendarView::writeLocale() | 2061 | void CalendarView::writeLocale() |
2062 | { | 2062 | { |
2063 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2063 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2064 | #if 0 | 2064 | #if 0 |
2065 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2065 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2066 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2066 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2067 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2067 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2068 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2068 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2069 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2069 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2070 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2070 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2071 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2071 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2072 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2072 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2073 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2073 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2074 | KOPrefs::instance()->mDaylightsavingStart, | 2074 | KOPrefs::instance()->mDaylightsavingStart, |
2075 | KOPrefs::instance()->mDaylightsavingEnd ); | 2075 | KOPrefs::instance()->mDaylightsavingEnd ); |
2076 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2076 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2077 | #endif | 2077 | #endif |
2078 | } | 2078 | } |
2079 | void CalendarView::updateConfig() | 2079 | void CalendarView::updateConfig() |
2080 | { | 2080 | { |
2081 | writeLocale(); | 2081 | writeLocale(); |
2082 | if ( KOPrefs::instance()->mUseAppColors ) | 2082 | if ( KOPrefs::instance()->mUseAppColors ) |
2083 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2083 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2084 | emit configChanged(); | 2084 | emit configChanged(); |
2085 | mTodoList->updateConfig(); | 2085 | mTodoList->updateConfig(); |
2086 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2086 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2087 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2087 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2088 | // To make the "fill window" configurations work | 2088 | // To make the "fill window" configurations work |
2089 | //mViewManager->raiseCurrentView(); | 2089 | //mViewManager->raiseCurrentView(); |
2090 | } | 2090 | } |
2091 | 2091 | ||
2092 | 2092 | ||
2093 | void CalendarView::eventChanged(Event *event) | 2093 | void CalendarView::eventChanged(Event *event) |
2094 | { | 2094 | { |
2095 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2095 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2096 | //updateUnmanagedViews(); | 2096 | //updateUnmanagedViews(); |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | void CalendarView::eventAdded(Event *event) | 2099 | void CalendarView::eventAdded(Event *event) |
2100 | { | 2100 | { |
2101 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2101 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2102 | } | 2102 | } |
2103 | 2103 | ||
2104 | void CalendarView::eventToBeDeleted(Event *) | 2104 | void CalendarView::eventToBeDeleted(Event *) |
2105 | { | 2105 | { |
2106 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2106 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::eventDeleted() | 2109 | void CalendarView::eventDeleted() |
2110 | { | 2110 | { |
2111 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2111 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2112 | } | 2112 | } |
2113 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2113 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2114 | { | 2114 | { |
2115 | changeIncidenceDisplay((Incidence *)which, action); | 2115 | changeIncidenceDisplay((Incidence *)which, action); |
2116 | mDateNavigator->updateView(); //LR | 2116 | mDateNavigator->updateView(); //LR |
2117 | //mDialogManager->updateSearchDialog(); | 2117 | //mDialogManager->updateSearchDialog(); |
2118 | 2118 | ||
2119 | if (which) { | 2119 | if (which) { |
2120 | mViewManager->updateWNview(); | 2120 | mViewManager->updateWNview(); |
2121 | //mTodoList->updateView(); | 2121 | //mTodoList->updateView(); |
2122 | } | 2122 | } |
2123 | 2123 | ||
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2126 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2127 | { | 2127 | { |
2128 | updateUnmanagedViews(); | 2128 | updateUnmanagedViews(); |
2129 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2129 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2130 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2130 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2131 | mCalendar->checkAlarmForIncidence( 0, true ); | 2131 | mCalendar->checkAlarmForIncidence( 0, true ); |
2132 | if ( mEventViewerDialog ) | 2132 | if ( mEventViewerDialog ) |
2133 | mEventViewerDialog->hide(); | 2133 | mEventViewerDialog->hide(); |
2134 | } | 2134 | } |
2135 | else | 2135 | else |
2136 | mCalendar->checkAlarmForIncidence( which , false ); | 2136 | mCalendar->checkAlarmForIncidence( which , false ); |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | // most of the changeEventDisplays() right now just call the view's | 2139 | // most of the changeEventDisplays() right now just call the view's |
2140 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2140 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2141 | void CalendarView::changeEventDisplay(Event *which, int action) | 2141 | void CalendarView::changeEventDisplay(Event *which, int action) |
2142 | { | 2142 | { |
2143 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2143 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2144 | changeIncidenceDisplay((Incidence *)which, action); | 2144 | changeIncidenceDisplay((Incidence *)which, action); |
2145 | mDateNavigator->updateView(); | 2145 | mDateNavigator->updateView(); |
2146 | //mDialogManager->updateSearchDialog(); | 2146 | //mDialogManager->updateSearchDialog(); |
2147 | 2147 | ||
2148 | if (which) { | 2148 | if (which) { |
2149 | // If there is an event view visible update the display | 2149 | // If there is an event view visible update the display |
2150 | mViewManager->currentView()->changeEventDisplay(which,action); | 2150 | mViewManager->currentView()->changeEventDisplay(which,action); |
2151 | // TODO: check, if update needed | 2151 | // TODO: check, if update needed |
2152 | // if (which->getTodoStatus()) { | 2152 | // if (which->getTodoStatus()) { |
2153 | mTodoList->updateView(); | 2153 | mTodoList->updateView(); |
2154 | // } | 2154 | // } |
2155 | } else { | 2155 | } else { |
2156 | mViewManager->currentView()->updateView(); | 2156 | mViewManager->currentView()->updateView(); |
2157 | } | 2157 | } |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | 2160 | ||
2161 | void CalendarView::updateTodoViews() | 2161 | void CalendarView::updateTodoViews() |
2162 | { | 2162 | { |
2163 | |||
2164 | mTodoList->updateView(); | 2163 | mTodoList->updateView(); |
2165 | mViewManager->currentView()->updateView(); | 2164 | mViewManager->currentView()->updateView(); |
2166 | 2165 | ||
2167 | } | 2166 | } |
2168 | 2167 | ||
2169 | 2168 | ||
2170 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2169 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2171 | { | 2170 | { |
2172 | mTodoList->updateView(); | 2171 | mTodoList->updateView(); |
2173 | mViewManager->updateView(start, end); | 2172 | mViewManager->updateView(start, end); |
2174 | //mDateNavigator->updateView(); | 2173 | //mDateNavigator->updateView(); |
2175 | } | 2174 | } |
2176 | 2175 | ||
2177 | void CalendarView::updateView() | 2176 | void CalendarView::updateView() |
2178 | { | 2177 | { |
2179 | DateList tmpList = mNavigator->selectedDates(); | 2178 | DateList tmpList = mNavigator->selectedDates(); |
2180 | 2179 | ||
2181 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2180 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2182 | mTodoList->updateView(); | 2181 | mTodoList->updateView(); |
2183 | // We assume that the navigator only selects consecutive days. | 2182 | // We assume that the navigator only selects consecutive days. |
2184 | updateView( tmpList.first(), tmpList.last() ); | 2183 | updateView( tmpList.first(), tmpList.last() ); |
2185 | } | 2184 | } |
2186 | 2185 | ||
2187 | void CalendarView::updateUnmanagedViews() | 2186 | void CalendarView::updateUnmanagedViews() |
2188 | { | 2187 | { |
2189 | mDateNavigator->updateDayMatrix(); | 2188 | mDateNavigator->updateDayMatrix(); |
2190 | } | 2189 | } |
2191 | 2190 | ||
2192 | int CalendarView::msgItemDelete(const QString name) | 2191 | int CalendarView::msgItemDelete(const QString name) |
2193 | { | 2192 | { |
2194 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2193 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2195 | i18n("This item will be\npermanently deleted."), | 2194 | i18n("This item will be\npermanently deleted."), |
2196 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2195 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2197 | } | 2196 | } |
2198 | 2197 | ||
2199 | 2198 | ||
2200 | void CalendarView::edit_cut() | 2199 | void CalendarView::edit_cut() |
2201 | { | 2200 | { |
2202 | Event *anEvent=0; | 2201 | Event *anEvent=0; |
2203 | 2202 | ||
2204 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2203 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2205 | 2204 | ||
2206 | if (mViewManager->currentView()->isEventView()) { | 2205 | if (mViewManager->currentView()->isEventView()) { |
2207 | if ( incidence && incidence->type() == "Event" ) { | 2206 | if ( incidence && incidence->type() == "Event" ) { |
2208 | anEvent = static_cast<Event *>(incidence); | 2207 | anEvent = static_cast<Event *>(incidence); |
2209 | } | 2208 | } |
2210 | } | 2209 | } |
2211 | 2210 | ||
2212 | if (!anEvent) { | 2211 | if (!anEvent) { |
2213 | KNotifyClient::beep(); | 2212 | KNotifyClient::beep(); |
2214 | return; | 2213 | return; |
2215 | } | 2214 | } |
2216 | DndFactory factory( mCalendar ); | 2215 | DndFactory factory( mCalendar ); |
2217 | factory.cutIncidence(anEvent); | 2216 | factory.cutIncidence(anEvent); |
2218 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2217 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2219 | } | 2218 | } |
2220 | 2219 | ||
2221 | void CalendarView::edit_copy() | 2220 | void CalendarView::edit_copy() |
2222 | { | 2221 | { |
2223 | Event *anEvent=0; | 2222 | Event *anEvent=0; |
2224 | 2223 | ||
2225 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2224 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2226 | 2225 | ||
2227 | if (mViewManager->currentView()->isEventView()) { | 2226 | if (mViewManager->currentView()->isEventView()) { |
2228 | if ( incidence && incidence->type() == "Event" ) { | 2227 | if ( incidence && incidence->type() == "Event" ) { |
2229 | anEvent = static_cast<Event *>(incidence); | 2228 | anEvent = static_cast<Event *>(incidence); |
2230 | } | 2229 | } |
2231 | } | 2230 | } |
2232 | 2231 | ||
2233 | if (!anEvent) { | 2232 | if (!anEvent) { |
2234 | KNotifyClient::beep(); | 2233 | KNotifyClient::beep(); |
2235 | return; | 2234 | return; |
2236 | } | 2235 | } |
2237 | DndFactory factory( mCalendar ); | 2236 | DndFactory factory( mCalendar ); |
2238 | factory.copyIncidence(anEvent); | 2237 | factory.copyIncidence(anEvent); |
2239 | } | 2238 | } |
2240 | 2239 | ||
2241 | void CalendarView::edit_paste() | 2240 | void CalendarView::edit_paste() |
2242 | { | 2241 | { |
2243 | QDate date = mNavigator->selectedDates().first(); | 2242 | QDate date = mNavigator->selectedDates().first(); |
2244 | 2243 | ||
2245 | DndFactory factory( mCalendar ); | 2244 | DndFactory factory( mCalendar ); |
2246 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2245 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2247 | 2246 | ||
2248 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2247 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2249 | } | 2248 | } |
2250 | 2249 | ||
2251 | void CalendarView::edit_options() | 2250 | void CalendarView::edit_options() |
2252 | { | 2251 | { |
2253 | mDialogManager->showOptionsDialog(); | 2252 | mDialogManager->showOptionsDialog(); |
2254 | //writeSettings(); | 2253 | //writeSettings(); |
2255 | } | 2254 | } |
2256 | 2255 | ||
2257 | 2256 | ||
2258 | void CalendarView::slotSelectPickerDate( QDate d) | 2257 | void CalendarView::slotSelectPickerDate( QDate d) |
2259 | { | 2258 | { |
2260 | mDateFrame->hide(); | 2259 | mDateFrame->hide(); |
2261 | if ( mDatePickerMode == 1 ) { | 2260 | if ( mDatePickerMode == 1 ) { |
2262 | mNavigator->slotDaySelect( d ); | 2261 | mNavigator->slotDaySelect( d ); |
2263 | } else if ( mDatePickerMode == 2 ) { | 2262 | } else if ( mDatePickerMode == 2 ) { |
2264 | if ( mMoveIncidence->type() == "Todo" ) { | 2263 | if ( mMoveIncidence->type() == "Todo" ) { |
2265 | Todo * to = (Todo *) mMoveIncidence; | 2264 | Todo * to = (Todo *) mMoveIncidence; |
2266 | QTime tim; | 2265 | QTime tim; |
2267 | if ( to->hasDueDate() ) | 2266 | if ( to->hasDueDate() ) |
2268 | tim = to->dtDue().time(); | 2267 | tim = to->dtDue().time(); |
2269 | else { | 2268 | else { |
2270 | tim = QTime ( 0,0,0 ); | 2269 | tim = QTime ( 0,0,0 ); |
2271 | to->setFloats( true ); | 2270 | to->setFloats( true ); |
2272 | to->setHasDueDate( true ); | 2271 | to->setHasDueDate( true ); |
2273 | } | 2272 | } |
2274 | QDateTime dt ( d,tim ); | 2273 | QDateTime dt ( d,tim ); |
2275 | to->setDtDue( dt ); | 2274 | to->setDtDue( dt ); |
2276 | todoChanged( to ); | 2275 | todoChanged( to ); |
2277 | } else { | 2276 | } else { |
2278 | if ( mMoveIncidence->doesRecur() ) { | 2277 | if ( mMoveIncidence->doesRecur() ) { |
2279 | #if 0 | 2278 | #if 0 |
2280 | // PENDING implement this | 2279 | // PENDING implement this |
2281 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2280 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2282 | mCalendar()->addIncidence( newInc ); | 2281 | mCalendar()->addIncidence( newInc ); |
2283 | if ( mMoveIncidence->type() == "Todo" ) | 2282 | if ( mMoveIncidence->type() == "Todo" ) |
2284 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2283 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2285 | else | 2284 | else |
2286 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2285 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2287 | mMoveIncidence = newInc; | 2286 | mMoveIncidence = newInc; |
2288 | 2287 | ||
2289 | #endif | 2288 | #endif |
2290 | } | 2289 | } |
2291 | QTime tim = mMoveIncidence->dtStart().time(); | 2290 | QTime tim = mMoveIncidence->dtStart().time(); |
2292 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2291 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2293 | QDateTime dt ( d,tim ); | 2292 | QDateTime dt ( d,tim ); |
2294 | mMoveIncidence->setDtStart( dt ); | 2293 | mMoveIncidence->setDtStart( dt ); |
2295 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2294 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2296 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2295 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2297 | } | 2296 | } |
2298 | 2297 | ||
2299 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2298 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2300 | } | 2299 | } |
2301 | } | 2300 | } |
2302 | 2301 | ||
2303 | void CalendarView::removeCategories() | 2302 | void CalendarView::removeCategories() |
2304 | { | 2303 | { |
2305 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2304 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2306 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2305 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2307 | QStringList catIncList; | 2306 | QStringList catIncList; |
2308 | QStringList newCatList; | 2307 | QStringList newCatList; |
2309 | Incidence* inc = incList.first(); | 2308 | Incidence* inc = incList.first(); |
2310 | int i; | 2309 | int i; |
2311 | int count = 0; | 2310 | int count = 0; |
2312 | while ( inc ) { | 2311 | while ( inc ) { |
2313 | newCatList.clear(); | 2312 | newCatList.clear(); |
2314 | catIncList = inc->categories() ; | 2313 | catIncList = inc->categories() ; |
2315 | for( i = 0; i< catIncList.count(); ++i ) { | 2314 | for( i = 0; i< catIncList.count(); ++i ) { |
2316 | if ( catList.contains (catIncList[i])) | 2315 | if ( catList.contains (catIncList[i])) |
2317 | newCatList.append( catIncList[i] ); | 2316 | newCatList.append( catIncList[i] ); |
2318 | } | 2317 | } |
2319 | newCatList.sort(); | 2318 | newCatList.sort(); |
2320 | inc->setCategories( newCatList.join(",") ); | 2319 | inc->setCategories( newCatList.join(",") ); |
2321 | inc = incList.next(); | 2320 | inc = incList.next(); |
2322 | } | 2321 | } |
2323 | } | 2322 | } |
2324 | 2323 | ||
2325 | int CalendarView::addCategories() | 2324 | int CalendarView::addCategories() |
2326 | { | 2325 | { |
2327 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2326 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2328 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2327 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2329 | QStringList catIncList; | 2328 | QStringList catIncList; |
2330 | Incidence* inc = incList.first(); | 2329 | Incidence* inc = incList.first(); |
2331 | int i; | 2330 | int i; |
2332 | int count = 0; | 2331 | int count = 0; |
2333 | while ( inc ) { | 2332 | while ( inc ) { |
2334 | catIncList = inc->categories() ; | 2333 | catIncList = inc->categories() ; |
2335 | for( i = 0; i< catIncList.count(); ++i ) { | 2334 | for( i = 0; i< catIncList.count(); ++i ) { |
2336 | if ( !catList.contains (catIncList[i])) { | 2335 | if ( !catList.contains (catIncList[i])) { |
2337 | catList.append( catIncList[i] ); | 2336 | catList.append( catIncList[i] ); |
2338 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2337 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2339 | ++count; | 2338 | ++count; |
2340 | } | 2339 | } |
2341 | } | 2340 | } |
2342 | inc = incList.next(); | 2341 | inc = incList.next(); |
2343 | } | 2342 | } |
2344 | catList.sort(); | 2343 | catList.sort(); |
2345 | KOPrefs::instance()->mCustomCategories = catList; | 2344 | KOPrefs::instance()->mCustomCategories = catList; |
2346 | return count; | 2345 | return count; |
2347 | } | 2346 | } |
2348 | 2347 | ||
2349 | void CalendarView::manageCategories() | 2348 | void CalendarView::manageCategories() |
2350 | { | 2349 | { |
2351 | KOCatPrefs* cp = new KOCatPrefs(); | 2350 | KOCatPrefs* cp = new KOCatPrefs(); |
2352 | cp->show(); | 2351 | cp->show(); |
2353 | int w =cp->sizeHint().width() ; | 2352 | int w =cp->sizeHint().width() ; |
2354 | int h = cp->sizeHint().height() ; | 2353 | int h = cp->sizeHint().height() ; |
2355 | int dw = QApplication::desktop()->width(); | 2354 | int dw = QApplication::desktop()->width(); |
2356 | int dh = QApplication::desktop()->height(); | 2355 | int dh = QApplication::desktop()->height(); |
2357 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2356 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2358 | if ( !cp->exec() ) { | 2357 | if ( !cp->exec() ) { |
2359 | delete cp; | 2358 | delete cp; |
2360 | return; | 2359 | return; |
2361 | } | 2360 | } |
2362 | int count = 0; | 2361 | int count = 0; |
2363 | if ( cp->addCat() ) { | 2362 | if ( cp->addCat() ) { |
2364 | count = addCategories(); | 2363 | count = addCategories(); |
2365 | if ( count ) { | 2364 | if ( count ) { |
2366 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2365 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2367 | writeSettings(); | 2366 | writeSettings(); |
2368 | } else | 2367 | } else |
2369 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2368 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2370 | } else { | 2369 | } else { |
2371 | removeCategories(); | 2370 | removeCategories(); |
2372 | updateView(); | 2371 | updateView(); |
2373 | } | 2372 | } |
2374 | delete cp; | 2373 | delete cp; |
2375 | } | 2374 | } |
2376 | 2375 | ||
2377 | void CalendarView::beamIncidence(Incidence * Inc) | 2376 | void CalendarView::beamIncidence(Incidence * Inc) |
2378 | { | 2377 | { |
2379 | QPtrList<Incidence> delSel ; | 2378 | QPtrList<Incidence> delSel ; |
2380 | delSel.append(Inc); | 2379 | delSel.append(Inc); |
2381 | beamIncidenceList( delSel ); | 2380 | beamIncidenceList( delSel ); |
2382 | } | 2381 | } |
2383 | void CalendarView::beamCalendar() | 2382 | void CalendarView::beamCalendar() |
2384 | { | 2383 | { |
2385 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2384 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2386 | //qDebug("beamCalendar() "); | 2385 | //qDebug("beamCalendar() "); |
2387 | beamIncidenceList( delSel ); | 2386 | beamIncidenceList( delSel ); |
2388 | } | 2387 | } |
2389 | void CalendarView::beamFilteredCalendar() | 2388 | void CalendarView::beamFilteredCalendar() |
2390 | { | 2389 | { |
2391 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2390 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2392 | //qDebug("beamFilteredCalendar() "); | 2391 | //qDebug("beamFilteredCalendar() "); |
2393 | beamIncidenceList( delSel ); | 2392 | beamIncidenceList( delSel ); |
2394 | } | 2393 | } |
2395 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2394 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2396 | { | 2395 | { |
2397 | if ( beamDialog->exec () == QDialog::Rejected ) | 2396 | if ( beamDialog->exec () == QDialog::Rejected ) |
2398 | return; | 2397 | return; |
2399 | #ifdef DESKTOP_VERSION | 2398 | #ifdef DESKTOP_VERSION |
2400 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2399 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2401 | #else | 2400 | #else |
2402 | QString fn = "/tmp/kopibeamfile"; | 2401 | QString fn = "/tmp/kopibeamfile"; |
2403 | #endif | 2402 | #endif |
2404 | QString mes; | 2403 | QString mes; |
2405 | bool createbup = true; | 2404 | bool createbup = true; |
2406 | if ( createbup ) { | 2405 | if ( createbup ) { |
2407 | QString description = "\n"; | 2406 | QString description = "\n"; |
2408 | CalendarLocal* cal = new CalendarLocal(); | 2407 | CalendarLocal* cal = new CalendarLocal(); |
2409 | if ( beamDialog->beamLocal() ) | 2408 | if ( beamDialog->beamLocal() ) |
2410 | cal->setLocalTime(); | 2409 | cal->setLocalTime(); |
2411 | else | 2410 | else |
2412 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2411 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2413 | Incidence *incidence = delSel.first(); | 2412 | Incidence *incidence = delSel.first(); |
2414 | bool addText = false; | 2413 | bool addText = false; |
2415 | if ( delSel.count() < 10 ) | 2414 | if ( delSel.count() < 10 ) |
2416 | addText = true; | 2415 | addText = true; |
2417 | else { | 2416 | else { |
2418 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2417 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2419 | } | 2418 | } |
2420 | while ( incidence ) { | 2419 | while ( incidence ) { |
2421 | Incidence *in = incidence->clone(); | 2420 | Incidence *in = incidence->clone(); |
2422 | if ( ! in->summary().isEmpty() ) { | 2421 | if ( ! in->summary().isEmpty() ) { |
2423 | in->setDescription(""); | 2422 | in->setDescription(""); |
2424 | } else { | 2423 | } else { |
2425 | in->setSummary( in->description().left(20)); | 2424 | in->setSummary( in->description().left(20)); |
2426 | in->setDescription(""); | 2425 | in->setDescription(""); |
2427 | } | 2426 | } |
2428 | if ( addText ) | 2427 | if ( addText ) |
2429 | description += in->summary() + "\n"; | 2428 | description += in->summary() + "\n"; |
2430 | cal->addIncidence( in ); | 2429 | cal->addIncidence( in ); |
2431 | incidence = delSel.next(); | 2430 | incidence = delSel.next(); |
2432 | } | 2431 | } |
2433 | if ( beamDialog->beamVcal() ) { | 2432 | if ( beamDialog->beamVcal() ) { |
2434 | fn += ".vcs"; | 2433 | fn += ".vcs"; |
2435 | FileStorage storage( cal, fn, new VCalFormat ); | 2434 | FileStorage storage( cal, fn, new VCalFormat ); |
2436 | storage.save(); | 2435 | storage.save(); |
2437 | } else { | 2436 | } else { |
2438 | fn += ".ics"; | 2437 | fn += ".ics"; |
2439 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2438 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2440 | storage.save(); | 2439 | storage.save(); |
2441 | } | 2440 | } |
2442 | delete cal; | 2441 | delete cal; |
2443 | mes = i18n("KO/Pi: Ready for beaming"); | 2442 | mes = i18n("KO/Pi: Ready for beaming"); |
2444 | topLevelWidget()->setCaption(mes); | 2443 | topLevelWidget()->setCaption(mes); |
2445 | KApplication::convert2latin1( fn ); | 2444 | KApplication::convert2latin1( fn ); |
2446 | #ifndef DESKTOP_VERSION | 2445 | #ifndef DESKTOP_VERSION |
2447 | Ir *ir = new Ir( this ); | 2446 | Ir *ir = new Ir( this ); |
2448 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2447 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2449 | ir->send( fn, description, "text/x-vCalendar" ); | 2448 | ir->send( fn, description, "text/x-vCalendar" ); |
2450 | #endif | 2449 | #endif |
2451 | } | 2450 | } |
2452 | } | 2451 | } |
2453 | void CalendarView::beamDone( Ir *ir ) | 2452 | void CalendarView::beamDone( Ir *ir ) |
2454 | { | 2453 | { |
2455 | #ifndef DESKTOP_VERSION | 2454 | #ifndef DESKTOP_VERSION |
2456 | delete ir; | 2455 | delete ir; |
2457 | #endif | 2456 | #endif |
2458 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2457 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2459 | topLevelWidget()->raise(); | 2458 | topLevelWidget()->raise(); |
2460 | } | 2459 | } |
2461 | 2460 | ||
2462 | void CalendarView::moveIncidence(Incidence * inc ) | 2461 | void CalendarView::moveIncidence(Incidence * inc ) |
2463 | { | 2462 | { |
2464 | if ( !inc ) return; | 2463 | if ( !inc ) return; |
2465 | // qDebug("showDatePickerForIncidence( ) "); | 2464 | // qDebug("showDatePickerForIncidence( ) "); |
2466 | if ( mDateFrame->isVisible() ) | 2465 | if ( mDateFrame->isVisible() ) |
2467 | mDateFrame->hide(); | 2466 | mDateFrame->hide(); |
2468 | else { | 2467 | else { |
2469 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2468 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2470 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2469 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2471 | int dw = QApplication::desktop()->width(); | 2470 | int dw = QApplication::desktop()->width(); |
2472 | int dh = QApplication::desktop()->height(); | 2471 | int dh = QApplication::desktop()->height(); |
2473 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2472 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2474 | mDateFrame->show(); | 2473 | mDateFrame->show(); |
2475 | } | 2474 | } |
2476 | mDatePickerMode = 2; | 2475 | mDatePickerMode = 2; |
2477 | mMoveIncidence = inc ; | 2476 | mMoveIncidence = inc ; |
2478 | QDate da; | 2477 | QDate da; |
2479 | if ( mMoveIncidence->type() == "Todo" ) { | 2478 | if ( mMoveIncidence->type() == "Todo" ) { |
2480 | Todo * to = (Todo *) mMoveIncidence; | 2479 | Todo * to = (Todo *) mMoveIncidence; |
2481 | if ( to->hasDueDate() ) | 2480 | if ( to->hasDueDate() ) |
2482 | da = to->dtDue().date(); | 2481 | da = to->dtDue().date(); |
2483 | else | 2482 | else |
2484 | da = QDate::currentDate(); | 2483 | da = QDate::currentDate(); |
2485 | } else { | 2484 | } else { |
2486 | da = mMoveIncidence->dtStart().date(); | 2485 | da = mMoveIncidence->dtStart().date(); |
2487 | } | 2486 | } |
2488 | //PENDING set date for recurring incidence to date of recurrence | 2487 | //PENDING set date for recurring incidence to date of recurrence |
2489 | //mMoveIncidenceOldDate; | 2488 | //mMoveIncidenceOldDate; |
2490 | mDatePicker->setDate( da ); | 2489 | mDatePicker->setDate( da ); |
2491 | } | 2490 | } |
2492 | void CalendarView::showDatePicker( ) | 2491 | void CalendarView::showDatePicker( ) |
2493 | { | 2492 | { |
2494 | //qDebug("CalendarView::showDatePicker( ) "); | 2493 | //qDebug("CalendarView::showDatePicker( ) "); |
2495 | if ( mDateFrame->isVisible() ) | 2494 | if ( mDateFrame->isVisible() ) |
2496 | mDateFrame->hide(); | 2495 | mDateFrame->hide(); |
2497 | else { | 2496 | else { |
2498 | int w =mDatePicker->sizeHint().width() ; | 2497 | int w =mDatePicker->sizeHint().width() ; |
2499 | int h = mDatePicker->sizeHint().height() ; | 2498 | int h = mDatePicker->sizeHint().height() ; |
2500 | int dw = QApplication::desktop()->width(); | 2499 | int dw = QApplication::desktop()->width(); |
2501 | int dh = QApplication::desktop()->height(); | 2500 | int dh = QApplication::desktop()->height(); |
2502 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2501 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2503 | mDateFrame->show(); | 2502 | mDateFrame->show(); |
2504 | } | 2503 | } |
2505 | mDatePickerMode = 1; | 2504 | mDatePickerMode = 1; |
2506 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2505 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2507 | } | 2506 | } |
2508 | 2507 | ||
2509 | void CalendarView::showEventEditor() | 2508 | void CalendarView::showEventEditor() |
2510 | { | 2509 | { |
2511 | #ifdef DESKTOP_VERSION | 2510 | #ifdef DESKTOP_VERSION |
2512 | mEventEditor->show(); | 2511 | mEventEditor->show(); |
2513 | #else | 2512 | #else |
2514 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2513 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2515 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2514 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2516 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2515 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2517 | qApp->processEvents(); | 2516 | qApp->processEvents(); |
2518 | delete mEventEditor; | 2517 | delete mEventEditor; |
2519 | mEventEditor = mDialogManager->getEventEditor(); | 2518 | mEventEditor = mDialogManager->getEventEditor(); |
2520 | topLevelWidget()->setCaption( i18n("") ); | 2519 | topLevelWidget()->setCaption( i18n("") ); |
2521 | } | 2520 | } |
2522 | mEventEditor->showMaximized(); | 2521 | mEventEditor->showMaximized(); |
2523 | #endif | 2522 | #endif |
2524 | } | 2523 | } |
2525 | void CalendarView::showTodoEditor() | 2524 | void CalendarView::showTodoEditor() |
2526 | { | 2525 | { |
2527 | #ifdef DESKTOP_VERSION | 2526 | #ifdef DESKTOP_VERSION |
2528 | mTodoEditor->show(); | 2527 | mTodoEditor->show(); |
2529 | #else | 2528 | #else |
2530 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2529 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2531 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2530 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2532 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2531 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2533 | qApp->processEvents(); | 2532 | qApp->processEvents(); |
2534 | delete mTodoEditor; | 2533 | delete mTodoEditor; |
2535 | mTodoEditor = mDialogManager->getTodoEditor(); | 2534 | mTodoEditor = mDialogManager->getTodoEditor(); |
2536 | topLevelWidget()->setCaption( i18n("") ); | 2535 | topLevelWidget()->setCaption( i18n("") ); |
2537 | } | 2536 | } |
2538 | mTodoEditor->showMaximized(); | 2537 | mTodoEditor->showMaximized(); |
2539 | #endif | 2538 | #endif |
2540 | } | 2539 | } |
2541 | 2540 | ||
2542 | void CalendarView::cloneIncidence() | 2541 | void CalendarView::cloneIncidence() |
2543 | { | 2542 | { |
2544 | Incidence *incidence = currentSelection(); | 2543 | Incidence *incidence = currentSelection(); |
2545 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2544 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2546 | if ( incidence ) { | 2545 | if ( incidence ) { |
2547 | cloneIncidence(incidence); | 2546 | cloneIncidence(incidence); |
2548 | } | 2547 | } |
2549 | } | 2548 | } |
2550 | void CalendarView::moveIncidence() | 2549 | void CalendarView::moveIncidence() |
2551 | { | 2550 | { |
2552 | Incidence *incidence = currentSelection(); | 2551 | Incidence *incidence = currentSelection(); |
2553 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2552 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2554 | if ( incidence ) { | 2553 | if ( incidence ) { |
2555 | moveIncidence(incidence); | 2554 | moveIncidence(incidence); |
2556 | } | 2555 | } |
2557 | } | 2556 | } |
2558 | void CalendarView::beamIncidence() | 2557 | void CalendarView::beamIncidence() |
2559 | { | 2558 | { |
2560 | Incidence *incidence = currentSelection(); | 2559 | Incidence *incidence = currentSelection(); |
2561 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2560 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2562 | if ( incidence ) { | 2561 | if ( incidence ) { |
2563 | beamIncidence(incidence); | 2562 | beamIncidence(incidence); |
2564 | } | 2563 | } |
2565 | } | 2564 | } |
2566 | void CalendarView::toggleCancelIncidence() | 2565 | void CalendarView::toggleCancelIncidence() |
2567 | { | 2566 | { |
2568 | Incidence *incidence = currentSelection(); | 2567 | Incidence *incidence = currentSelection(); |
2569 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2568 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2570 | if ( incidence ) { | 2569 | if ( incidence ) { |
2571 | cancelIncidence(incidence); | 2570 | cancelIncidence(incidence); |
2572 | } | 2571 | } |
2573 | } | 2572 | } |
2574 | 2573 | ||
2575 | 2574 | ||
2576 | void CalendarView::cancelIncidence(Incidence * inc ) | 2575 | void CalendarView::cancelIncidence(Incidence * inc ) |
2577 | { | 2576 | { |
2578 | inc->setCancelled( ! inc->cancelled() ); | 2577 | inc->setCancelled( ! inc->cancelled() ); |
2579 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2578 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2580 | updateView(); | 2579 | updateView(); |
2581 | } | 2580 | } |
2582 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2581 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2583 | { | 2582 | { |
2584 | Incidence * newInc = orgInc->clone(); | 2583 | Incidence * newInc = orgInc->clone(); |
2585 | newInc->recreate(); | 2584 | newInc->recreate(); |
2586 | 2585 | ||
2587 | if ( newInc->type() == "Todo" ) { | 2586 | if ( newInc->type() == "Todo" ) { |
2588 | Todo* t = (Todo*) newInc; | 2587 | Todo* t = (Todo*) newInc; |
2589 | showTodoEditor(); | 2588 | showTodoEditor(); |
2590 | mTodoEditor->editTodo( t ); | 2589 | mTodoEditor->editTodo( t ); |
2591 | if ( mTodoEditor->exec() ) { | 2590 | if ( mTodoEditor->exec() ) { |
2592 | mCalendar->addTodo( t ); | 2591 | mCalendar->addTodo( t ); |
2593 | updateView(); | 2592 | updateView(); |
2594 | } else { | 2593 | } else { |
2595 | delete t; | 2594 | delete t; |
2596 | } | 2595 | } |
2597 | } | 2596 | } |
2598 | else { | 2597 | else { |
2599 | Event* e = (Event*) newInc; | 2598 | Event* e = (Event*) newInc; |
2600 | showEventEditor(); | 2599 | showEventEditor(); |
2601 | mEventEditor->editEvent( e ); | 2600 | mEventEditor->editEvent( e ); |
2602 | if ( mEventEditor->exec() ) { | 2601 | if ( mEventEditor->exec() ) { |
2603 | mCalendar->addEvent( e ); | 2602 | mCalendar->addEvent( e ); |
2604 | updateView(); | 2603 | updateView(); |
2605 | } else { | 2604 | } else { |
2606 | delete e; | 2605 | delete e; |
2607 | } | 2606 | } |
2608 | } | 2607 | } |
2609 | } | 2608 | } |
2610 | 2609 | ||
2611 | void CalendarView::newEvent() | 2610 | void CalendarView::newEvent() |
2612 | { | 2611 | { |
2613 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2612 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2614 | KOAgendaView *aView = mViewManager->agendaView(); | 2613 | KOAgendaView *aView = mViewManager->agendaView(); |
2615 | if (aView) { | 2614 | if (aView) { |
2616 | if (aView->selectionStart().isValid()) { | 2615 | if (aView->selectionStart().isValid()) { |
2617 | if (aView->selectedIsAllDay()) { | 2616 | if (aView->selectedIsAllDay()) { |
2618 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2617 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2619 | } else { | 2618 | } else { |
2620 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2619 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2621 | } | 2620 | } |
2622 | return; | 2621 | return; |
2623 | } | 2622 | } |
2624 | } | 2623 | } |
2625 | 2624 | ||
2626 | QDate date = mNavigator->selectedDates().first(); | 2625 | QDate date = mNavigator->selectedDates().first(); |
2627 | QDateTime current = QDateTime::currentDateTime(); | 2626 | QDateTime current = QDateTime::currentDateTime(); |
2628 | if ( date <= current.date() ) { | 2627 | if ( date <= current.date() ) { |
2629 | int hour = current.time().hour() +1; | 2628 | int hour = current.time().hour() +1; |
2630 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2629 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2631 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2630 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2632 | } else | 2631 | } else |
2633 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2632 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2634 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2633 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2635 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2634 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2636 | } | 2635 | } |
2637 | 2636 | ||
2638 | void CalendarView::newEvent(QDateTime fh) | 2637 | void CalendarView::newEvent(QDateTime fh) |
2639 | { | 2638 | { |
2640 | newEvent(fh, | 2639 | newEvent(fh, |
2641 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2640 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2642 | } | 2641 | } |
2643 | 2642 | ||
2644 | void CalendarView::newEvent(QDate dt) | 2643 | void CalendarView::newEvent(QDate dt) |
2645 | { | 2644 | { |
2646 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2645 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2647 | QDateTime(dt, QTime(0,0,0)), true); | 2646 | QDateTime(dt, QTime(0,0,0)), true); |
2648 | } | 2647 | } |
2649 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2648 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2650 | { | 2649 | { |
2651 | newEvent(fromHint, toHint, false); | 2650 | newEvent(fromHint, toHint, false); |
2652 | } | 2651 | } |
2653 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2652 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2654 | { | 2653 | { |
2655 | 2654 | ||
2656 | showEventEditor(); | 2655 | showEventEditor(); |
2657 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2656 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2658 | if ( mFilterView->filtersEnabled() ) { | 2657 | if ( mFilterView->filtersEnabled() ) { |
2659 | CalFilter *filter = mFilterView->selectedFilter(); | 2658 | CalFilter *filter = mFilterView->selectedFilter(); |
2660 | if (filter && filter->showCategories()) { | 2659 | if (filter && filter->showCategories()) { |
2661 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2660 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2662 | } | 2661 | } |
2663 | if ( filter ) | 2662 | if ( filter ) |
2664 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2663 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2665 | } | 2664 | } |
2666 | } | 2665 | } |
2667 | void CalendarView::todoAdded(Todo * t) | 2666 | void CalendarView::todoAdded(Todo * t) |
2668 | { | 2667 | { |
2669 | 2668 | ||
2670 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2669 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2671 | updateTodoViews(); | 2670 | updateTodoViews(); |
2672 | } | 2671 | } |
2673 | void CalendarView::todoChanged(Todo * t) | 2672 | void CalendarView::todoChanged(Todo * t) |
2674 | { | 2673 | { |
2675 | emit todoModified( t, 4 ); | 2674 | emit todoModified( t, 4 ); |
2676 | // updateTodoViews(); | 2675 | // updateTodoViews(); |
2677 | } | 2676 | } |
2678 | void CalendarView::todoToBeDeleted(Todo *) | 2677 | void CalendarView::todoToBeDeleted(Todo *) |
2679 | { | 2678 | { |
2680 | //qDebug("todoToBeDeleted(Todo *) "); | 2679 | //qDebug("todoToBeDeleted(Todo *) "); |
2681 | updateTodoViews(); | 2680 | updateTodoViews(); |
2682 | } | 2681 | } |
2683 | void CalendarView::todoDeleted() | 2682 | void CalendarView::todoDeleted() |
2684 | { | 2683 | { |
2685 | //qDebug(" todoDeleted()"); | 2684 | //qDebug(" todoDeleted()"); |
2686 | updateTodoViews(); | 2685 | updateTodoViews(); |
2687 | } | 2686 | } |
2688 | 2687 | ||
2689 | 2688 | ||
2690 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2689 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2691 | { | 2690 | { |
2692 | showTodoEditor(); | 2691 | showTodoEditor(); |
2693 | mTodoEditor->newTodo(dt,0,allday); | 2692 | mTodoEditor->newTodo(dt,0,allday); |
2694 | if ( mFilterView->filtersEnabled() ) { | 2693 | if ( mFilterView->filtersEnabled() ) { |
2695 | CalFilter *filter = mFilterView->selectedFilter(); | 2694 | CalFilter *filter = mFilterView->selectedFilter(); |
2696 | if (filter && filter->showCategories()) { | 2695 | if (filter && filter->showCategories()) { |
2697 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2696 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2698 | } | 2697 | } |
2699 | if ( filter ) | 2698 | if ( filter ) |
2700 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2699 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2701 | } | 2700 | } |
2702 | } | 2701 | } |
2703 | 2702 | ||
2704 | void CalendarView::newTodo() | 2703 | void CalendarView::newTodo() |
2705 | { | 2704 | { |
2706 | newTodoDateTime( QDateTime(),true ); | 2705 | newTodoDateTime( QDateTime(),true ); |
2707 | } | 2706 | } |
2708 | 2707 | ||
2709 | void CalendarView::newSubTodo() | 2708 | void CalendarView::newSubTodo() |
2710 | { | 2709 | { |
2711 | Todo *todo = selectedTodo(); | 2710 | Todo *todo = selectedTodo(); |
2712 | if ( todo ) newSubTodo( todo ); | 2711 | if ( todo ) newSubTodo( todo ); |
2713 | } | 2712 | } |
2714 | 2713 | ||
2715 | void CalendarView::newSubTodo(Todo *parentEvent) | 2714 | void CalendarView::newSubTodo(Todo *parentEvent) |
2716 | { | 2715 | { |
2717 | 2716 | ||
2718 | showTodoEditor(); | 2717 | showTodoEditor(); |
2719 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2718 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2720 | } | 2719 | } |
2721 | 2720 | ||
2722 | void CalendarView::newFloatingEvent() | 2721 | void CalendarView::newFloatingEvent() |
2723 | { | 2722 | { |
2724 | DateList tmpList = mNavigator->selectedDates(); | 2723 | DateList tmpList = mNavigator->selectedDates(); |
2725 | QDate date = tmpList.first(); | 2724 | QDate date = tmpList.first(); |
2726 | 2725 | ||
2727 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2726 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2728 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2727 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2729 | } | 2728 | } |
2730 | 2729 | ||
2731 | 2730 | ||
2732 | void CalendarView::editEvent( Event *event ) | 2731 | void CalendarView::editEvent( Event *event ) |
2733 | { | 2732 | { |
2734 | 2733 | ||
2735 | if ( !event ) return; | 2734 | if ( !event ) return; |
2736 | if ( event->isReadOnly() ) { | 2735 | if ( event->isReadOnly() ) { |
2737 | showEvent( event ); | 2736 | showEvent( event ); |
2738 | return; | 2737 | return; |
2739 | } | 2738 | } |
2740 | showEventEditor(); | 2739 | showEventEditor(); |
2741 | mEventEditor->editEvent( event , mFlagEditDescription); | 2740 | mEventEditor->editEvent( event , mFlagEditDescription); |
2742 | } | 2741 | } |
2743 | void CalendarView::editJournal( Journal *jour ) | 2742 | void CalendarView::editJournal( Journal *jour ) |
2744 | { | 2743 | { |
2745 | if ( !jour ) return; | 2744 | if ( !jour ) return; |
2746 | mDialogManager->hideSearchDialog(); | 2745 | mDialogManager->hideSearchDialog(); |
2747 | mViewManager->showJournalView(); | 2746 | mViewManager->showJournalView(); |
2748 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2747 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2749 | } | 2748 | } |
2750 | void CalendarView::editTodo( Todo *todo ) | 2749 | void CalendarView::editTodo( Todo *todo ) |
2751 | { | 2750 | { |
2752 | if ( !todo ) return; | 2751 | if ( !todo ) return; |
2753 | 2752 | ||
2754 | if ( todo->isReadOnly() ) { | 2753 | if ( todo->isReadOnly() ) { |
2755 | showTodo( todo ); | 2754 | showTodo( todo ); |
2756 | return; | 2755 | return; |
2757 | } | 2756 | } |
2758 | showTodoEditor(); | 2757 | showTodoEditor(); |
2759 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2758 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2760 | 2759 | ||
2761 | } | 2760 | } |
2762 | 2761 | ||
2763 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2762 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2764 | { | 2763 | { |
2765 | if ( !mEventViewerDialog ) { | 2764 | if ( !mEventViewerDialog ) { |
2766 | mEventViewerDialog = new KOEventViewerDialog(this); | 2765 | mEventViewerDialog = new KOEventViewerDialog(this); |
2767 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2766 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2768 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2767 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2769 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2768 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2770 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2769 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2771 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2770 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2772 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2771 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2773 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2772 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2774 | this, SLOT( todoChanged(Todo *) ) ); | 2773 | this, SLOT( todoChanged(Todo *) ) ); |
2775 | mEventViewerDialog->resize( 640, 480 ); | 2774 | mEventViewerDialog->resize( 640, 480 ); |
2776 | 2775 | ||
2777 | } | 2776 | } |
2778 | return mEventViewerDialog; | 2777 | return mEventViewerDialog; |
2779 | } | 2778 | } |
2780 | void CalendarView::showEvent(Event *event) | 2779 | void CalendarView::showEvent(Event *event) |
2781 | { | 2780 | { |
2782 | getEventViewerDialog()->setEvent(event); | 2781 | getEventViewerDialog()->setEvent(event); |
2783 | getEventViewerDialog()->showMe(); | 2782 | getEventViewerDialog()->showMe(); |
2784 | } | 2783 | } |
2785 | 2784 | ||
2786 | void CalendarView::showTodo(Todo *event) | 2785 | void CalendarView::showTodo(Todo *event) |
2787 | { | 2786 | { |
2788 | getEventViewerDialog()->setTodo(event); | 2787 | getEventViewerDialog()->setTodo(event); |
2789 | getEventViewerDialog()->showMe(); | 2788 | getEventViewerDialog()->showMe(); |
2790 | } | 2789 | } |
2791 | void CalendarView::showJournal( Journal *jour ) | 2790 | void CalendarView::showJournal( Journal *jour ) |
2792 | { | 2791 | { |
2793 | getEventViewerDialog()->setJournal(jour); | 2792 | getEventViewerDialog()->setJournal(jour); |
2794 | getEventViewerDialog()->showMe(); | 2793 | getEventViewerDialog()->showMe(); |
2795 | 2794 | ||
2796 | } | 2795 | } |
2797 | // void CalendarView::todoModified (Todo *event, int changed) | 2796 | // void CalendarView::todoModified (Todo *event, int changed) |
2798 | // { | 2797 | // { |
2799 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2798 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2800 | // // kdDebug() << "Todo modified and open" << endl; | 2799 | // // kdDebug() << "Todo modified and open" << endl; |
2801 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2800 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2802 | // // temp->modified (changed); | 2801 | // // temp->modified (changed); |
2803 | 2802 | ||
2804 | // // } | 2803 | // // } |
2805 | 2804 | ||
2806 | // mViewManager->updateView(); | 2805 | // mViewManager->updateView(); |
2807 | // } | 2806 | // } |
2808 | 2807 | ||
2809 | void CalendarView::appointment_show() | 2808 | void CalendarView::appointment_show() |
2810 | { | 2809 | { |
2811 | Event *anEvent = 0; | 2810 | Event *anEvent = 0; |
2812 | 2811 | ||
2813 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2812 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2814 | 2813 | ||
2815 | if (mViewManager->currentView()->isEventView()) { | 2814 | if (mViewManager->currentView()->isEventView()) { |
2816 | if ( incidence && incidence->type() == "Event" ) { | 2815 | if ( incidence && incidence->type() == "Event" ) { |
2817 | anEvent = static_cast<Event *>(incidence); | 2816 | anEvent = static_cast<Event *>(incidence); |
2818 | } | 2817 | } |
2819 | } | 2818 | } |
2820 | 2819 | ||
2821 | if (!anEvent) { | 2820 | if (!anEvent) { |
2822 | KNotifyClient::beep(); | 2821 | KNotifyClient::beep(); |
2823 | return; | 2822 | return; |
2824 | } | 2823 | } |
2825 | 2824 | ||
2826 | showEvent(anEvent); | 2825 | showEvent(anEvent); |
2827 | } | 2826 | } |
2828 | 2827 | ||
2829 | void CalendarView::appointment_edit() | 2828 | void CalendarView::appointment_edit() |
2830 | { | 2829 | { |
2831 | Event *anEvent = 0; | 2830 | Event *anEvent = 0; |
2832 | 2831 | ||
2833 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2832 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2834 | 2833 | ||
2835 | if (mViewManager->currentView()->isEventView()) { | 2834 | if (mViewManager->currentView()->isEventView()) { |
2836 | if ( incidence && incidence->type() == "Event" ) { | 2835 | if ( incidence && incidence->type() == "Event" ) { |
2837 | anEvent = static_cast<Event *>(incidence); | 2836 | anEvent = static_cast<Event *>(incidence); |
2838 | } | 2837 | } |
2839 | } | 2838 | } |
2840 | 2839 | ||
2841 | if (!anEvent) { | 2840 | if (!anEvent) { |
2842 | KNotifyClient::beep(); | 2841 | KNotifyClient::beep(); |
2843 | return; | 2842 | return; |
2844 | } | 2843 | } |
2845 | 2844 | ||
2846 | editEvent(anEvent); | 2845 | editEvent(anEvent); |
2847 | } | 2846 | } |
2848 | 2847 | ||
2849 | void CalendarView::appointment_delete() | 2848 | void CalendarView::appointment_delete() |
2850 | { | 2849 | { |
2851 | Event *anEvent = 0; | 2850 | Event *anEvent = 0; |
2852 | 2851 | ||
2853 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2852 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2854 | 2853 | ||
2855 | if (mViewManager->currentView()->isEventView()) { | 2854 | if (mViewManager->currentView()->isEventView()) { |
2856 | if ( incidence && incidence->type() == "Event" ) { | 2855 | if ( incidence && incidence->type() == "Event" ) { |
2857 | anEvent = static_cast<Event *>(incidence); | 2856 | anEvent = static_cast<Event *>(incidence); |
2858 | } | 2857 | } |
2859 | } | 2858 | } |
2860 | 2859 | ||
2861 | if (!anEvent) { | 2860 | if (!anEvent) { |
2862 | KNotifyClient::beep(); | 2861 | KNotifyClient::beep(); |
2863 | return; | 2862 | return; |
2864 | } | 2863 | } |
2865 | 2864 | ||
2866 | deleteEvent(anEvent); | 2865 | deleteEvent(anEvent); |
2867 | } | 2866 | } |
2868 | 2867 | ||
2869 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2868 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2870 | { | 2869 | { |
2871 | if (!sub) return; | 2870 | if (!sub) return; |
2872 | if (!parent) return; | 2871 | if (!parent) return; |
2873 | if ( sub->relatedTo() ) | 2872 | if ( sub->relatedTo() ) |
2874 | sub->relatedTo()->removeRelation(sub); | 2873 | sub->relatedTo()->removeRelation(sub); |
2875 | sub->setRelatedTo(parent); | 2874 | sub->setRelatedTo(parent); |
2876 | sub->setRelatedToUid(parent->uid()); | 2875 | sub->setRelatedToUid(parent->uid()); |
2877 | parent->addRelation(sub); | 2876 | parent->addRelation(sub); |
2878 | sub->updated(); | 2877 | sub->updated(); |
2879 | parent->updated(); | 2878 | parent->updated(); |
2880 | setModified(true); | 2879 | setModified(true); |
2881 | updateView(); | 2880 | updateView(); |
2882 | } | 2881 | } |
2883 | void CalendarView::todo_unsub(Todo *anTodo ) | 2882 | void CalendarView::todo_unsub(Todo *anTodo ) |
2884 | { | 2883 | { |
2885 | // Todo *anTodo = selectedTodo(); | 2884 | // Todo *anTodo = selectedTodo(); |
2886 | if (!anTodo) return; | 2885 | if (!anTodo) return; |
2887 | if (!anTodo->relatedTo()) return; | 2886 | if (!anTodo->relatedTo()) return; |
2888 | anTodo->relatedTo()->removeRelation(anTodo); | 2887 | anTodo->relatedTo()->removeRelation(anTodo); |
2889 | anTodo->setRelatedTo(0); | 2888 | anTodo->setRelatedTo(0); |
2890 | anTodo->updated(); | 2889 | anTodo->updated(); |
2891 | anTodo->setRelatedToUid(""); | 2890 | anTodo->setRelatedToUid(""); |
2892 | setModified(true); | 2891 | setModified(true); |
2893 | updateView(); | 2892 | updateView(); |
2894 | } | 2893 | } |
2895 | 2894 | ||
2896 | void CalendarView::deleteTodo(Todo *todo) | 2895 | void CalendarView::deleteTodo(Todo *todo) |
2897 | { | 2896 | { |
2898 | if (!todo) { | 2897 | if (!todo) { |
2899 | KNotifyClient::beep(); | 2898 | KNotifyClient::beep(); |
2900 | return; | 2899 | return; |
2901 | } | 2900 | } |
2902 | if (KOPrefs::instance()->mConfirm) { | 2901 | if (KOPrefs::instance()->mConfirm) { |
2903 | QString text = todo->summary().left(20); | 2902 | QString text = todo->summary().left(20); |
2904 | if (!todo->relations().isEmpty()) { | 2903 | if (!todo->relations().isEmpty()) { |
2905 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2904 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2906 | 2905 | ||
2907 | } | 2906 | } |
2908 | switch (msgItemDelete(text)) { | 2907 | switch (msgItemDelete(text)) { |
2909 | case KMessageBox::Continue: // OK | 2908 | case KMessageBox::Continue: // OK |
2910 | bool deleteT = false; | 2909 | bool deleteT = false; |
2911 | if (!todo->relations().isEmpty()) { | 2910 | if (!todo->relations().isEmpty()) { |
2912 | deleteT = removeCompletedSubTodos( todo ); | 2911 | deleteT = removeCompletedSubTodos( todo ); |
2913 | } | 2912 | } |
2914 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2913 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2915 | if ( !deleteT ) { | 2914 | if ( !deleteT ) { |
2916 | checkExternalId( todo ); | 2915 | checkExternalId( todo ); |
2917 | calendar()->deleteTodo(todo); | 2916 | calendar()->deleteTodo(todo); |
2918 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2917 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2919 | updateView(); | 2918 | updateView(); |
2920 | } | 2919 | } |
2921 | break; | 2920 | break; |
2922 | } // switch | 2921 | } // switch |
2923 | } else { | 2922 | } else { |
2924 | checkExternalId( todo ); | 2923 | checkExternalId( todo ); |
2925 | mCalendar->deleteTodo(todo); | 2924 | mCalendar->deleteTodo(todo); |
2926 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2925 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2927 | updateView(); | 2926 | updateView(); |
2928 | } | 2927 | } |
2929 | 2928 | ||
2930 | emit updateSearchDialog(); | 2929 | emit updateSearchDialog(); |
2931 | } | 2930 | } |
2932 | void CalendarView::deleteJournal(Journal *jour) | 2931 | void CalendarView::deleteJournal(Journal *jour) |
2933 | { | 2932 | { |
2934 | if (!jour) { | 2933 | if (!jour) { |
2935 | KNotifyClient::beep(); | 2934 | KNotifyClient::beep(); |
2936 | return; | 2935 | return; |
2937 | } | 2936 | } |
2938 | if (KOPrefs::instance()->mConfirm) { | 2937 | if (KOPrefs::instance()->mConfirm) { |
2939 | switch (msgItemDelete( jour->description().left(20))) { | 2938 | switch (msgItemDelete( jour->description().left(20))) { |
2940 | case KMessageBox::Continue: // OK | 2939 | case KMessageBox::Continue: // OK |
2941 | calendar()->deleteJournal(jour); | 2940 | calendar()->deleteJournal(jour); |
2942 | updateView(); | 2941 | updateView(); |
2943 | break; | 2942 | break; |
2944 | } // switch | 2943 | } // switch |
2945 | } else { | 2944 | } else { |
2946 | calendar()->deleteJournal(jour);; | 2945 | calendar()->deleteJournal(jour);; |
2947 | updateView(); | 2946 | updateView(); |
2948 | } | 2947 | } |
2949 | emit updateSearchDialog(); | 2948 | emit updateSearchDialog(); |
2950 | } | 2949 | } |
2951 | 2950 | ||
2952 | void CalendarView::deleteEvent(Event *anEvent) | 2951 | void CalendarView::deleteEvent(Event *anEvent) |
2953 | { | 2952 | { |
2954 | if (!anEvent) { | 2953 | if (!anEvent) { |
2955 | KNotifyClient::beep(); | 2954 | KNotifyClient::beep(); |
2956 | return; | 2955 | return; |
2957 | } | 2956 | } |
2958 | 2957 | ||
2959 | if (anEvent->recurrence()->doesRecur()) { | 2958 | if (anEvent->recurrence()->doesRecur()) { |
2960 | QDate itemDate = mViewManager->currentSelectionDate(); | 2959 | QDate itemDate = mViewManager->currentSelectionDate(); |
2961 | int km; | 2960 | int km; |
2962 | if (!itemDate.isValid()) { | 2961 | if (!itemDate.isValid()) { |
2963 | //kdDebug() << "Date Not Valid" << endl; | 2962 | //kdDebug() << "Date Not Valid" << endl; |
2964 | if (KOPrefs::instance()->mConfirm) { | 2963 | if (KOPrefs::instance()->mConfirm) { |
2965 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2964 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2966 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2965 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2967 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2966 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2968 | if ( km == KMessageBox::Continue ) | 2967 | if ( km == KMessageBox::Continue ) |
2969 | km = KMessageBox::No; // No = all below | 2968 | km = KMessageBox::No; // No = all below |
2970 | } else | 2969 | } else |
2971 | km = KMessageBox::No; | 2970 | km = KMessageBox::No; |
2972 | } else { | 2971 | } else { |
2973 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2972 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2974 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2973 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2975 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2974 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2976 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2975 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2977 | i18n("All")); | 2976 | i18n("All")); |
2978 | } | 2977 | } |
2979 | switch(km) { | 2978 | switch(km) { |
2980 | 2979 | ||
2981 | case KMessageBox::No: // Continue // all | 2980 | case KMessageBox::No: // Continue // all |
2982 | //qDebug("KMessageBox::No "); | 2981 | //qDebug("KMessageBox::No "); |
2983 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2982 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2984 | schedule(Scheduler::Cancel,anEvent); | 2983 | schedule(Scheduler::Cancel,anEvent); |
2985 | 2984 | ||
2986 | checkExternalId( anEvent); | 2985 | checkExternalId( anEvent); |
2987 | mCalendar->deleteEvent(anEvent); | 2986 | mCalendar->deleteEvent(anEvent); |
2988 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2987 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2989 | break; | 2988 | break; |
2990 | 2989 | ||
2991 | // Disabled because it does not work | 2990 | // Disabled because it does not work |
2992 | //#if 0 | 2991 | //#if 0 |
2993 | case KMessageBox::Yes: // just this one | 2992 | case KMessageBox::Yes: // just this one |
2994 | //QDate qd = mNavigator->selectedDates().first(); | 2993 | //QDate qd = mNavigator->selectedDates().first(); |
2995 | //if (!qd.isValid()) { | 2994 | //if (!qd.isValid()) { |
2996 | // kdDebug() << "no date selected, or invalid date" << endl; | 2995 | // kdDebug() << "no date selected, or invalid date" << endl; |
2997 | // KNotifyClient::beep(); | 2996 | // KNotifyClient::beep(); |
2998 | // return; | 2997 | // return; |
2999 | //} | 2998 | //} |
3000 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2999 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3001 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3000 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3002 | anEvent->addExDate(itemDate); | 3001 | anEvent->addExDate(itemDate); |
3003 | int duration = anEvent->recurrence()->duration(); | 3002 | int duration = anEvent->recurrence()->duration(); |
3004 | if ( duration > 0 ) { | 3003 | if ( duration > 0 ) { |
3005 | anEvent->recurrence()->setDuration( duration - 1 ); | 3004 | anEvent->recurrence()->setDuration( duration - 1 ); |
3006 | } | 3005 | } |
3007 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3006 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3008 | } | 3007 | } |
3009 | break; | 3008 | break; |
3010 | //#endif | 3009 | //#endif |
3011 | } // switch | 3010 | } // switch |
3012 | } else { | 3011 | } else { |
3013 | if (KOPrefs::instance()->mConfirm) { | 3012 | if (KOPrefs::instance()->mConfirm) { |
3014 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3013 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3015 | i18n("\nAre you sure you want\nto delete this event?"), | 3014 | i18n("\nAre you sure you want\nto delete this event?"), |
3016 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3015 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3017 | case KMessageBox::Continue: // OK | 3016 | case KMessageBox::Continue: // OK |
3018 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3017 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3019 | schedule(Scheduler::Cancel,anEvent); | 3018 | schedule(Scheduler::Cancel,anEvent); |
3020 | checkExternalId( anEvent); | 3019 | checkExternalId( anEvent); |
3021 | mCalendar->deleteEvent(anEvent); | 3020 | mCalendar->deleteEvent(anEvent); |
3022 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3021 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3023 | break; | 3022 | break; |
3024 | } // switch | 3023 | } // switch |
3025 | } else { | 3024 | } else { |
3026 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3025 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3027 | schedule(Scheduler::Cancel,anEvent); | 3026 | schedule(Scheduler::Cancel,anEvent); |
3028 | checkExternalId( anEvent); | 3027 | checkExternalId( anEvent); |
3029 | mCalendar->deleteEvent(anEvent); | 3028 | mCalendar->deleteEvent(anEvent); |
3030 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3029 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3031 | } | 3030 | } |
3032 | } // if-else | 3031 | } // if-else |
3033 | emit updateSearchDialog(); | 3032 | emit updateSearchDialog(); |
3034 | } | 3033 | } |
3035 | 3034 | ||
3036 | bool CalendarView::deleteEvent(const QString &uid) | 3035 | bool CalendarView::deleteEvent(const QString &uid) |
3037 | { | 3036 | { |
3038 | Event *ev = mCalendar->event(uid); | 3037 | Event *ev = mCalendar->event(uid); |
3039 | if (ev) { | 3038 | if (ev) { |
3040 | deleteEvent(ev); | 3039 | deleteEvent(ev); |
3041 | return true; | 3040 | return true; |
3042 | } else { | 3041 | } else { |
3043 | return false; | 3042 | return false; |
3044 | } | 3043 | } |
3045 | } | 3044 | } |
3046 | 3045 | ||
3047 | /*****************************************************************************/ | 3046 | /*****************************************************************************/ |
3048 | 3047 | ||
3049 | void CalendarView::action_mail() | 3048 | void CalendarView::action_mail() |
3050 | { | 3049 | { |
3051 | #ifndef KORG_NOMAIL | 3050 | #ifndef KORG_NOMAIL |
3052 | KOMailClient mailClient; | 3051 | KOMailClient mailClient; |
3053 | 3052 | ||
3054 | Incidence *incidence = currentSelection(); | 3053 | Incidence *incidence = currentSelection(); |
3055 | 3054 | ||
3056 | if (!incidence) { | 3055 | if (!incidence) { |
3057 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3056 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3058 | return; | 3057 | return; |
3059 | } | 3058 | } |
3060 | if(incidence->attendeeCount() == 0 ) { | 3059 | if(incidence->attendeeCount() == 0 ) { |
3061 | KMessageBox::sorry(this, | 3060 | KMessageBox::sorry(this, |
3062 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3061 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3063 | return; | 3062 | return; |
3064 | } | 3063 | } |
3065 | 3064 | ||
3066 | CalendarLocal cal_tmp; | 3065 | CalendarLocal cal_tmp; |
3067 | Event *event = 0; | 3066 | Event *event = 0; |
3068 | Event *ev = 0; | 3067 | Event *ev = 0; |
3069 | if ( incidence && incidence->type() == "Event" ) { | 3068 | if ( incidence && incidence->type() == "Event" ) { |
3070 | event = static_cast<Event *>(incidence); | 3069 | event = static_cast<Event *>(incidence); |
3071 | ev = new Event(*event); | 3070 | ev = new Event(*event); |
3072 | cal_tmp.addEvent(ev); | 3071 | cal_tmp.addEvent(ev); |
3073 | } | 3072 | } |
3074 | ICalFormat mForm(); | 3073 | ICalFormat mForm(); |
3075 | QString attachment = mForm.toString( &cal_tmp ); | 3074 | QString attachment = mForm.toString( &cal_tmp ); |
3076 | if (ev) delete(ev); | 3075 | if (ev) delete(ev); |
3077 | 3076 | ||
3078 | mailClient.mailAttendees(currentSelection(), attachment); | 3077 | mailClient.mailAttendees(currentSelection(), attachment); |
3079 | 3078 | ||
3080 | #endif | 3079 | #endif |
3081 | 3080 | ||
3082 | #if 0 | 3081 | #if 0 |
3083 | Event *anEvent = 0; | 3082 | Event *anEvent = 0; |
3084 | if (mViewManager->currentView()->isEventView()) { | 3083 | if (mViewManager->currentView()->isEventView()) { |
3085 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3084 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3086 | } | 3085 | } |
3087 | 3086 | ||
3088 | if (!anEvent) { | 3087 | if (!anEvent) { |
3089 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3088 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3090 | return; | 3089 | return; |
3091 | } | 3090 | } |
3092 | if(anEvent->attendeeCount() == 0 ) { | 3091 | if(anEvent->attendeeCount() == 0 ) { |
3093 | KMessageBox::sorry(this, | 3092 | KMessageBox::sorry(this, |
3094 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3093 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3095 | return; | 3094 | return; |
3096 | } | 3095 | } |
3097 | 3096 | ||
3098 | mailobject.emailEvent(anEvent); | 3097 | mailobject.emailEvent(anEvent); |
3099 | #endif | 3098 | #endif |
3100 | } | 3099 | } |
3101 | 3100 | ||
3102 | 3101 | ||
3103 | void CalendarView::schedule_publish(Incidence *incidence) | 3102 | void CalendarView::schedule_publish(Incidence *incidence) |
3104 | { | 3103 | { |
3105 | Event *event = 0; | 3104 | Event *event = 0; |
3106 | Todo *todo = 0; | 3105 | Todo *todo = 0; |
3107 | 3106 | ||
3108 | if (incidence == 0) { | 3107 | if (incidence == 0) { |
3109 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3108 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3110 | if (incidence == 0) { | 3109 | if (incidence == 0) { |
3111 | incidence = mTodoList->selectedIncidences().first(); | 3110 | incidence = mTodoList->selectedIncidences().first(); |
3112 | } | 3111 | } |
3113 | } | 3112 | } |
3114 | if ( incidence && incidence->type() == "Event" ) { | 3113 | if ( incidence && incidence->type() == "Event" ) { |
3115 | event = static_cast<Event *>(incidence); | 3114 | event = static_cast<Event *>(incidence); |
3116 | } else { | 3115 | } else { |
3117 | if ( incidence && incidence->type() == "Todo" ) { | 3116 | if ( incidence && incidence->type() == "Todo" ) { |
3118 | todo = static_cast<Todo *>(incidence); | 3117 | todo = static_cast<Todo *>(incidence); |
3119 | } | 3118 | } |
3120 | } | 3119 | } |
3121 | 3120 | ||
3122 | if (!event && !todo) { | 3121 | if (!event && !todo) { |
3123 | KMessageBox::sorry(this,i18n("No event selected.")); | 3122 | KMessageBox::sorry(this,i18n("No event selected.")); |
3124 | return; | 3123 | return; |
3125 | } | 3124 | } |
3126 | 3125 | ||
3127 | PublishDialog *publishdlg = new PublishDialog(); | 3126 | PublishDialog *publishdlg = new PublishDialog(); |
3128 | if (incidence->attendeeCount()>0) { | 3127 | if (incidence->attendeeCount()>0) { |
3129 | QPtrList<Attendee> attendees = incidence->attendees(); | 3128 | QPtrList<Attendee> attendees = incidence->attendees(); |
3130 | attendees.first(); | 3129 | attendees.first(); |
3131 | while ( attendees.current()!=0 ) { | 3130 | while ( attendees.current()!=0 ) { |
3132 | publishdlg->addAttendee(attendees.current()); | 3131 | publishdlg->addAttendee(attendees.current()); |
3133 | attendees.next(); | 3132 | attendees.next(); |
3134 | } | 3133 | } |
3135 | } | 3134 | } |
3136 | bool send = true; | 3135 | bool send = true; |
3137 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3136 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3138 | if ( publishdlg->exec() != QDialog::Accepted ) | 3137 | if ( publishdlg->exec() != QDialog::Accepted ) |
3139 | send = false; | 3138 | send = false; |
3140 | } | 3139 | } |
3141 | if ( send ) { | 3140 | if ( send ) { |
3142 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3141 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3143 | if ( event ) { | 3142 | if ( event ) { |
3144 | Event *ev = new Event(*event); | 3143 | Event *ev = new Event(*event); |
3145 | ev->registerObserver(0); | 3144 | ev->registerObserver(0); |
3146 | ev->clearAttendees(); | 3145 | ev->clearAttendees(); |
3147 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3146 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3148 | delete(ev); | 3147 | delete(ev); |
3149 | } | 3148 | } |
3150 | } else { | 3149 | } else { |
3151 | if ( todo ) { | 3150 | if ( todo ) { |
3152 | Todo *ev = new Todo(*todo); | 3151 | Todo *ev = new Todo(*todo); |
3153 | ev->registerObserver(0); | 3152 | ev->registerObserver(0); |
3154 | ev->clearAttendees(); | 3153 | ev->clearAttendees(); |
3155 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3154 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3156 | delete(ev); | 3155 | delete(ev); |
3157 | } | 3156 | } |
3158 | } | 3157 | } |
3159 | } | 3158 | } |
3160 | } | 3159 | } |
3161 | delete publishdlg; | 3160 | delete publishdlg; |
3162 | } | 3161 | } |
3163 | 3162 | ||
3164 | void CalendarView::schedule_request(Incidence *incidence) | 3163 | void CalendarView::schedule_request(Incidence *incidence) |
3165 | { | 3164 | { |
3166 | schedule(Scheduler::Request,incidence); | 3165 | schedule(Scheduler::Request,incidence); |
3167 | } | 3166 | } |
3168 | 3167 | ||
3169 | void CalendarView::schedule_refresh(Incidence *incidence) | 3168 | void CalendarView::schedule_refresh(Incidence *incidence) |
3170 | { | 3169 | { |
3171 | schedule(Scheduler::Refresh,incidence); | 3170 | schedule(Scheduler::Refresh,incidence); |
3172 | } | 3171 | } |
3173 | 3172 | ||
3174 | void CalendarView::schedule_cancel(Incidence *incidence) | 3173 | void CalendarView::schedule_cancel(Incidence *incidence) |
3175 | { | 3174 | { |
3176 | schedule(Scheduler::Cancel,incidence); | 3175 | schedule(Scheduler::Cancel,incidence); |
3177 | } | 3176 | } |
3178 | 3177 | ||
3179 | void CalendarView::schedule_add(Incidence *incidence) | 3178 | void CalendarView::schedule_add(Incidence *incidence) |
3180 | { | 3179 | { |
3181 | schedule(Scheduler::Add,incidence); | 3180 | schedule(Scheduler::Add,incidence); |
3182 | } | 3181 | } |
3183 | 3182 | ||
3184 | void CalendarView::schedule_reply(Incidence *incidence) | 3183 | void CalendarView::schedule_reply(Incidence *incidence) |
3185 | { | 3184 | { |
3186 | schedule(Scheduler::Reply,incidence); | 3185 | schedule(Scheduler::Reply,incidence); |
3187 | } | 3186 | } |
3188 | 3187 | ||
3189 | void CalendarView::schedule_counter(Incidence *incidence) | 3188 | void CalendarView::schedule_counter(Incidence *incidence) |
3190 | { | 3189 | { |
3191 | schedule(Scheduler::Counter,incidence); | 3190 | schedule(Scheduler::Counter,incidence); |
3192 | } | 3191 | } |
3193 | 3192 | ||
3194 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3193 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3195 | { | 3194 | { |
3196 | schedule(Scheduler::Declinecounter,incidence); | 3195 | schedule(Scheduler::Declinecounter,incidence); |
3197 | } | 3196 | } |
3198 | 3197 | ||
3199 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3198 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3200 | { | 3199 | { |
3201 | QDateTime start = QDateTime::currentDateTime(); | 3200 | QDateTime start = QDateTime::currentDateTime(); |
3202 | QDateTime end = start.addDays(daysToPublish); | 3201 | QDateTime end = start.addDays(daysToPublish); |
3203 | 3202 | ||
3204 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3203 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3205 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3204 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3206 | 3205 | ||
3207 | 3206 | ||
3208 | PublishDialog *publishdlg = new PublishDialog(); | 3207 | PublishDialog *publishdlg = new PublishDialog(); |
3209 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3208 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3210 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3209 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3211 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3210 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3212 | delete(freebusy); | 3211 | delete(freebusy); |
3213 | } | 3212 | } |
3214 | } | 3213 | } |
3215 | delete publishdlg; | 3214 | delete publishdlg; |
3216 | } | 3215 | } |
3217 | 3216 | ||
3218 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3217 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3219 | { | 3218 | { |
3220 | Event *event = 0; | 3219 | Event *event = 0; |
3221 | Todo *todo = 0; | 3220 | Todo *todo = 0; |
3222 | 3221 | ||
3223 | if (incidence == 0) { | 3222 | if (incidence == 0) { |
3224 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3223 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3225 | if (incidence == 0) { | 3224 | if (incidence == 0) { |
3226 | incidence = mTodoList->selectedIncidences().first(); | 3225 | incidence = mTodoList->selectedIncidences().first(); |
3227 | } | 3226 | } |
3228 | } | 3227 | } |
3229 | if ( incidence && incidence->type() == "Event" ) { | 3228 | if ( incidence && incidence->type() == "Event" ) { |
3230 | event = static_cast<Event *>(incidence); | 3229 | event = static_cast<Event *>(incidence); |
3231 | } | 3230 | } |
3232 | if ( incidence && incidence->type() == "Todo" ) { | 3231 | if ( incidence && incidence->type() == "Todo" ) { |
3233 | todo = static_cast<Todo *>(incidence); | 3232 | todo = static_cast<Todo *>(incidence); |
3234 | } | 3233 | } |
3235 | 3234 | ||
3236 | if (!event && !todo) { | 3235 | if (!event && !todo) { |
3237 | KMessageBox::sorry(this,i18n("No event selected.")); | 3236 | KMessageBox::sorry(this,i18n("No event selected.")); |
3238 | return; | 3237 | return; |
3239 | } | 3238 | } |
3240 | 3239 | ||
3241 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3240 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3242 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3241 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3243 | return; | 3242 | return; |
3244 | } | 3243 | } |
3245 | 3244 | ||
3246 | Event *ev = 0; | 3245 | Event *ev = 0; |
3247 | if (event) ev = new Event(*event); | 3246 | if (event) ev = new Event(*event); |
3248 | Todo *to = 0; | 3247 | Todo *to = 0; |
3249 | if (todo) to = new Todo(*todo); | 3248 | if (todo) to = new Todo(*todo); |
3250 | 3249 | ||
3251 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3250 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3252 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3251 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3253 | if (!me) { | 3252 | if (!me) { |
3254 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3253 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3255 | return; | 3254 | return; |
3256 | } | 3255 | } |
3257 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3256 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3258 | StatusDialog *statdlg = new StatusDialog(this); | 3257 | StatusDialog *statdlg = new StatusDialog(this); |
3259 | if (!statdlg->exec()==QDialog::Accepted) return; | 3258 | if (!statdlg->exec()==QDialog::Accepted) return; |
3260 | me->setStatus( statdlg->status() ); | 3259 | me->setStatus( statdlg->status() ); |
3261 | delete(statdlg); | 3260 | delete(statdlg); |
3262 | } | 3261 | } |
3263 | Attendee *menew = new Attendee(*me); | 3262 | Attendee *menew = new Attendee(*me); |
3264 | if (ev) { | 3263 | if (ev) { |
3265 | ev->clearAttendees(); | 3264 | ev->clearAttendees(); |
3266 | ev->addAttendee(menew,false); | 3265 | ev->addAttendee(menew,false); |
3267 | } else { | 3266 | } else { |
3268 | if (to) { | 3267 | if (to) { |
3269 | todo->clearAttendees(); | 3268 | todo->clearAttendees(); |
3270 | todo->addAttendee(menew,false); | 3269 | todo->addAttendee(menew,false); |
3271 | } | 3270 | } |
3272 | } | 3271 | } |
3273 | } | 3272 | } |
3274 | 3273 | ||
3275 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3274 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3276 | if (ev) { | 3275 | if (ev) { |
3277 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3276 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3278 | } else { | 3277 | } else { |
3279 | if (to) { | 3278 | if (to) { |
3280 | if ( !dlg->addMessage(to,method) ) delete(to); | 3279 | if ( !dlg->addMessage(to,method) ) delete(to); |
3281 | } | 3280 | } |
3282 | } | 3281 | } |
3283 | } | 3282 | } |
3284 | 3283 | ||
3285 | void CalendarView::openAddressbook() | 3284 | void CalendarView::openAddressbook() |
3286 | { | 3285 | { |
3287 | KRun::runCommand("kaddressbook"); | 3286 | KRun::runCommand("kaddressbook"); |
3288 | } | 3287 | } |
3289 | 3288 | ||
3290 | void CalendarView::setModified(bool modified) | 3289 | void CalendarView::setModified(bool modified) |
3291 | { | 3290 | { |
3292 | if ( modified ) | 3291 | if ( modified ) |
3293 | emit signalmodified(); | 3292 | emit signalmodified(); |
3294 | if (mModified != modified) { | 3293 | if (mModified != modified) { |
3295 | mModified = modified; | 3294 | mModified = modified; |
3296 | emit modifiedChanged(mModified); | 3295 | emit modifiedChanged(mModified); |
3297 | } | 3296 | } |
3298 | } | 3297 | } |
3299 | 3298 | ||
3300 | bool CalendarView::isReadOnly() | 3299 | bool CalendarView::isReadOnly() |
3301 | { | 3300 | { |
3302 | return mReadOnly; | 3301 | return mReadOnly; |
3303 | } | 3302 | } |
3304 | 3303 | ||
3305 | void CalendarView::setReadOnly(bool readOnly) | 3304 | void CalendarView::setReadOnly(bool readOnly) |
3306 | { | 3305 | { |
3307 | if (mReadOnly != readOnly) { | 3306 | if (mReadOnly != readOnly) { |
3308 | mReadOnly = readOnly; | 3307 | mReadOnly = readOnly; |
3309 | emit readOnlyChanged(mReadOnly); | 3308 | emit readOnlyChanged(mReadOnly); |
3310 | } | 3309 | } |
3311 | } | 3310 | } |
3312 | 3311 | ||
3313 | bool CalendarView::isModified() | 3312 | bool CalendarView::isModified() |
3314 | { | 3313 | { |
3315 | return mModified; | 3314 | return mModified; |
3316 | } | 3315 | } |
3317 | 3316 | ||
3318 | void CalendarView::printSetup() | 3317 | void CalendarView::printSetup() |
3319 | { | 3318 | { |
3320 | #ifndef KORG_NOPRINTER | 3319 | #ifndef KORG_NOPRINTER |
3321 | createPrinter(); | 3320 | createPrinter(); |
3322 | 3321 | ||
3323 | mCalPrinter->setupPrinter(); | 3322 | mCalPrinter->setupPrinter(); |
3324 | #endif | 3323 | #endif |
3325 | } | 3324 | } |
3326 | 3325 | ||
3327 | void CalendarView::print() | 3326 | void CalendarView::print() |
3328 | { | 3327 | { |
3329 | #ifndef KORG_NOPRINTER | 3328 | #ifndef KORG_NOPRINTER |
3330 | createPrinter(); | 3329 | createPrinter(); |
3331 | 3330 | ||
3332 | DateList tmpDateList = mNavigator->selectedDates(); | 3331 | DateList tmpDateList = mNavigator->selectedDates(); |
3333 | mCalPrinter->print(CalPrinter::Month, | 3332 | mCalPrinter->print(CalPrinter::Month, |
3334 | tmpDateList.first(), tmpDateList.last()); | 3333 | tmpDateList.first(), tmpDateList.last()); |
3335 | #endif | 3334 | #endif |
3336 | } | 3335 | } |
3337 | 3336 | ||
3338 | void CalendarView::printPreview() | 3337 | void CalendarView::printPreview() |
3339 | { | 3338 | { |
3340 | #ifndef KORG_NOPRINTER | 3339 | #ifndef KORG_NOPRINTER |
3341 | kdDebug() << "CalendarView::printPreview()" << endl; | 3340 | kdDebug() << "CalendarView::printPreview()" << endl; |
3342 | 3341 | ||
3343 | createPrinter(); | 3342 | createPrinter(); |
3344 | 3343 | ||
3345 | DateList tmpDateList = mNavigator->selectedDates(); | 3344 | DateList tmpDateList = mNavigator->selectedDates(); |
3346 | 3345 | ||
3347 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3346 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3348 | tmpDateList.last()); | 3347 | tmpDateList.last()); |
3349 | #endif | 3348 | #endif |
3350 | } | 3349 | } |
3351 | 3350 | ||
3352 | void CalendarView::exportICalendar() | 3351 | void CalendarView::exportICalendar() |
3353 | { | 3352 | { |
3354 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3353 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3355 | 3354 | ||
3356 | // Force correct extension | 3355 | // Force correct extension |
3357 | if (filename.right(4) != ".ics") filename += ".ics"; | 3356 | if (filename.right(4) != ".ics") filename += ".ics"; |
3358 | 3357 | ||
3359 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3358 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3360 | storage.save(); | 3359 | storage.save(); |
3361 | } | 3360 | } |
3362 | 3361 | ||
3363 | bool CalendarView::exportVCalendar( QString filename ) | 3362 | bool CalendarView::exportVCalendar( QString filename ) |
3364 | { | 3363 | { |
3365 | if (mCalendar->journals().count() > 0) { | 3364 | if (mCalendar->journals().count() > 0) { |
3366 | int result = KMessageBox::warningContinueCancel(this, | 3365 | int result = KMessageBox::warningContinueCancel(this, |
3367 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3366 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3368 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3367 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3369 | true); | 3368 | true); |
3370 | if (result != KMessageBox::Continue) return false; | 3369 | if (result != KMessageBox::Continue) return false; |
3371 | } | 3370 | } |
3372 | 3371 | ||
3373 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3372 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3374 | 3373 | ||
3375 | // Force correct extension | 3374 | // Force correct extension |
3376 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3375 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3377 | 3376 | ||
3378 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3377 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3379 | return storage.save(); | 3378 | return storage.save(); |
3380 | 3379 | ||
3381 | } | 3380 | } |
3382 | 3381 | ||
3383 | void CalendarView::eventUpdated(Incidence *) | 3382 | void CalendarView::eventUpdated(Incidence *) |
3384 | { | 3383 | { |
3385 | setModified(); | 3384 | setModified(); |
3386 | // Don't call updateView here. The code, which has caused the update of the | 3385 | // Don't call updateView here. The code, which has caused the update of the |
3387 | // event is responsible for updating the view. | 3386 | // event is responsible for updating the view. |
3388 | // updateView(); | 3387 | // updateView(); |
3389 | } | 3388 | } |
3390 | 3389 | ||
3391 | void CalendarView::adaptNavigationUnits() | 3390 | void CalendarView::adaptNavigationUnits() |
3392 | { | 3391 | { |
3393 | if (mViewManager->currentView()->isEventView()) { | 3392 | if (mViewManager->currentView()->isEventView()) { |
3394 | int days = mViewManager->currentView()->currentDateCount(); | 3393 | int days = mViewManager->currentView()->currentDateCount(); |
3395 | if (days == 1) { | 3394 | if (days == 1) { |
3396 | emit changeNavStringPrev(i18n("&Previous Day")); | 3395 | emit changeNavStringPrev(i18n("&Previous Day")); |
3397 | emit changeNavStringNext(i18n("&Next Day")); | 3396 | emit changeNavStringNext(i18n("&Next Day")); |
3398 | } else { | 3397 | } else { |
3399 | emit changeNavStringPrev(i18n("&Previous Week")); | 3398 | emit changeNavStringPrev(i18n("&Previous Week")); |
3400 | emit changeNavStringNext(i18n("&Next Week")); | 3399 | emit changeNavStringNext(i18n("&Next Week")); |
3401 | } | 3400 | } |
3402 | } | 3401 | } |
3403 | } | 3402 | } |
3404 | 3403 | ||
3405 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3404 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3406 | { | 3405 | { |
3407 | if ( incidence ) mTodoList->clearSelection(); | 3406 | if ( incidence ) mTodoList->clearSelection(); |
3408 | processIncidenceSelection( incidence ); | 3407 | processIncidenceSelection( incidence ); |
3409 | } | 3408 | } |
3410 | 3409 | ||
3411 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3410 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3412 | { | 3411 | { |
3413 | if ( incidence && mViewManager->currentView() ) { | 3412 | if ( incidence && mViewManager->currentView() ) { |
3414 | mViewManager->currentView()->clearSelection(); | 3413 | mViewManager->currentView()->clearSelection(); |
3415 | } | 3414 | } |
3416 | processIncidenceSelection( incidence ); | 3415 | processIncidenceSelection( incidence ); |
3417 | } | 3416 | } |
3418 | 3417 | ||
3419 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3418 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3420 | { | 3419 | { |
3421 | if ( incidence == mSelectedIncidence ) return; | 3420 | if ( incidence == mSelectedIncidence ) return; |
3422 | 3421 | ||
3423 | mSelectedIncidence = incidence; | 3422 | mSelectedIncidence = incidence; |
3424 | 3423 | ||
3425 | emit incidenceSelected( mSelectedIncidence ); | 3424 | emit incidenceSelected( mSelectedIncidence ); |
3426 | 3425 | ||
3427 | if ( incidence && incidence->type() == "Event" ) { | 3426 | if ( incidence && incidence->type() == "Event" ) { |
3428 | Event *event = static_cast<Event *>( incidence ); | 3427 | Event *event = static_cast<Event *>( incidence ); |
3429 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3428 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3430 | emit organizerEventsSelected( true ); | 3429 | emit organizerEventsSelected( true ); |
3431 | } else { | 3430 | } else { |
3432 | emit organizerEventsSelected(false); | 3431 | emit organizerEventsSelected(false); |
3433 | } | 3432 | } |
3434 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3433 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3435 | KOPrefs::instance()->email() ) ) { | 3434 | KOPrefs::instance()->email() ) ) { |
3436 | emit groupEventsSelected( true ); | 3435 | emit groupEventsSelected( true ); |
3437 | } else { | 3436 | } else { |
3438 | emit groupEventsSelected(false); | 3437 | emit groupEventsSelected(false); |
3439 | } | 3438 | } |
3440 | return; | 3439 | return; |
3441 | } else { | 3440 | } else { |
3442 | if ( incidence && incidence->type() == "Todo" ) { | 3441 | if ( incidence && incidence->type() == "Todo" ) { |
3443 | emit todoSelected( true ); | 3442 | emit todoSelected( true ); |
3444 | Todo *event = static_cast<Todo *>( incidence ); | 3443 | Todo *event = static_cast<Todo *>( incidence ); |
3445 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3444 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3446 | emit organizerEventsSelected( true ); | 3445 | emit organizerEventsSelected( true ); |
3447 | } else { | 3446 | } else { |
3448 | emit organizerEventsSelected(false); | 3447 | emit organizerEventsSelected(false); |
3449 | } | 3448 | } |
3450 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3449 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3451 | KOPrefs::instance()->email() ) ) { | 3450 | KOPrefs::instance()->email() ) ) { |
3452 | emit groupEventsSelected( true ); | 3451 | emit groupEventsSelected( true ); |
3453 | } else { | 3452 | } else { |
3454 | emit groupEventsSelected(false); | 3453 | emit groupEventsSelected(false); |
3455 | } | 3454 | } |
3456 | return; | 3455 | return; |
3457 | } else { | 3456 | } else { |
3458 | emit todoSelected( false ); | 3457 | emit todoSelected( false ); |
3459 | emit organizerEventsSelected(false); | 3458 | emit organizerEventsSelected(false); |
3460 | emit groupEventsSelected(false); | 3459 | emit groupEventsSelected(false); |
3461 | } | 3460 | } |
3462 | return; | 3461 | return; |
3463 | } | 3462 | } |
3464 | 3463 | ||
3465 | /* if ( incidence && incidence->type() == "Todo" ) { | 3464 | /* if ( incidence && incidence->type() == "Todo" ) { |
3466 | emit todoSelected( true ); | 3465 | emit todoSelected( true ); |
3467 | } else { | 3466 | } else { |
3468 | emit todoSelected( false ); | 3467 | emit todoSelected( false ); |
3469 | }*/ | 3468 | }*/ |
3470 | } | 3469 | } |
3471 | 3470 | ||
3472 | 3471 | ||
3473 | void CalendarView::checkClipboard() | 3472 | void CalendarView::checkClipboard() |
3474 | { | 3473 | { |
3475 | #ifndef KORG_NODND | 3474 | #ifndef KORG_NODND |
3476 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3475 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3477 | emit pasteEnabled(true); | 3476 | emit pasteEnabled(true); |
3478 | } else { | 3477 | } else { |
3479 | emit pasteEnabled(false); | 3478 | emit pasteEnabled(false); |
3480 | } | 3479 | } |
3481 | #endif | 3480 | #endif |
3482 | } | 3481 | } |
3483 | 3482 | ||
3484 | void CalendarView::showDates(const DateList &selectedDates) | 3483 | void CalendarView::showDates(const DateList &selectedDates) |
3485 | { | 3484 | { |
3486 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3485 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3487 | 3486 | ||
3488 | 3487 | ||
3489 | if ( !mBlockShowDates ) { | 3488 | if ( !mBlockShowDates ) { |
3490 | if ( mViewManager->currentView() ) { | 3489 | if ( mViewManager->currentView() ) { |
3491 | updateView( selectedDates.first(), selectedDates.last() ); | 3490 | updateView( selectedDates.first(), selectedDates.last() ); |
3492 | } else { | 3491 | } else { |
3493 | mViewManager->showAgendaView(); | 3492 | mViewManager->showAgendaView(); |
3494 | } | 3493 | } |
3495 | } | 3494 | } |
3496 | 3495 | ||
3497 | QString selDates; | 3496 | QString selDates; |
3498 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3497 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3499 | if (selectedDates.first() < selectedDates.last() ) | 3498 | if (selectedDates.first() < selectedDates.last() ) |
3500 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3499 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3501 | else { | 3500 | else { |
3502 | QString addString; | 3501 | QString addString; |
3503 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3502 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3504 | addString = i18n("Today"); | 3503 | addString = i18n("Today"); |
3505 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3504 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3506 | addString = i18n("Tomorrow"); | 3505 | addString = i18n("Tomorrow"); |
3507 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3506 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3508 | addString = i18n("Yesterday"); | 3507 | addString = i18n("Yesterday"); |
3509 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3508 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3510 | addString = i18n("Day before yesterday"); | 3509 | addString = i18n("Day before yesterday"); |
3511 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3510 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3512 | addString = i18n("Day after tomorrow"); | 3511 | addString = i18n("Day after tomorrow"); |
3513 | if ( !addString.isEmpty() ) { | 3512 | if ( !addString.isEmpty() ) { |
3514 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3513 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3515 | return; | 3514 | return; |
3516 | } | 3515 | } |
3517 | } | 3516 | } |
3518 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3517 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3519 | 3518 | ||
3520 | } | 3519 | } |
3521 | 3520 | ||
3522 | QPtrList<CalFilter> CalendarView::filters() | 3521 | QPtrList<CalFilter> CalendarView::filters() |
3523 | { | 3522 | { |
3524 | return mFilters; | 3523 | return mFilters; |
3525 | 3524 | ||
3526 | } | 3525 | } |
3527 | void CalendarView::editFilters() | 3526 | void CalendarView::editFilters() |
3528 | { | 3527 | { |
3529 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3528 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3530 | 3529 | ||
3531 | CalFilter *filter = mFilters.first(); | 3530 | CalFilter *filter = mFilters.first(); |
3532 | while(filter) { | 3531 | while(filter) { |
3533 | kdDebug() << " Filter: " << filter->name() << endl; | 3532 | kdDebug() << " Filter: " << filter->name() << endl; |
3534 | filter = mFilters.next(); | 3533 | filter = mFilters.next(); |
3535 | } | 3534 | } |
3536 | 3535 | ||
3537 | mDialogManager->showFilterEditDialog(&mFilters); | 3536 | mDialogManager->showFilterEditDialog(&mFilters); |
3538 | } | 3537 | } |
3539 | void CalendarView::toggleFilter() | 3538 | void CalendarView::toggleFilter() |
3540 | { | 3539 | { |
3541 | showFilter(! mFilterView->isVisible()); | 3540 | showFilter(! mFilterView->isVisible()); |
3542 | } | 3541 | } |
3543 | 3542 | ||
3544 | KOFilterView *CalendarView::filterView() | 3543 | KOFilterView *CalendarView::filterView() |
3545 | { | 3544 | { |
3546 | return mFilterView; | 3545 | return mFilterView; |
3547 | } | 3546 | } |
3548 | void CalendarView::selectFilter( int fil ) | 3547 | void CalendarView::selectFilter( int fil ) |
3549 | { | 3548 | { |
3550 | mFilterView->setSelectedFilter( fil ); | 3549 | mFilterView->setSelectedFilter( fil ); |
3551 | } | 3550 | } |
3552 | void CalendarView::showFilter(bool visible) | 3551 | void CalendarView::showFilter(bool visible) |
3553 | { | 3552 | { |
3554 | if (visible) mFilterView->show(); | 3553 | if (visible) mFilterView->show(); |
3555 | else mFilterView->hide(); | 3554 | else mFilterView->hide(); |
3556 | } | 3555 | } |
3557 | void CalendarView::toggleFilerEnabled( ) | 3556 | void CalendarView::toggleFilerEnabled( ) |
3558 | { | 3557 | { |
3559 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3558 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3560 | if ( !mFilterView->filtersEnabled() ) | 3559 | if ( !mFilterView->filtersEnabled() ) |
3561 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3560 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3562 | 3561 | ||
3563 | } | 3562 | } |
3564 | void CalendarView::updateFilter() | 3563 | void CalendarView::updateFilter() |
3565 | { | 3564 | { |
3566 | CalFilter *filter = mFilterView->selectedFilter(); | 3565 | CalFilter *filter = mFilterView->selectedFilter(); |
3567 | if (filter) { | 3566 | if (filter) { |
3568 | if (mFilterView->filtersEnabled()) { | 3567 | if (mFilterView->filtersEnabled()) { |
3569 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3568 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3570 | filter->setEnabled(true); | 3569 | filter->setEnabled(true); |
3571 | } | 3570 | } |
3572 | else filter->setEnabled(false); | 3571 | else filter->setEnabled(false); |
3573 | mCalendar->setFilter(filter); | 3572 | mCalendar->setFilter(filter); |
3574 | updateView(); | 3573 | updateView(); |
3575 | } | 3574 | } |
3576 | } | 3575 | } |
3577 | 3576 | ||
3578 | void CalendarView::filterEdited() | 3577 | void CalendarView::filterEdited() |
3579 | { | 3578 | { |
3580 | mFilterView->updateFilters(); | 3579 | mFilterView->updateFilters(); |
3581 | updateFilter(); | 3580 | updateFilter(); |
3582 | writeSettings(); | 3581 | writeSettings(); |
3583 | } | 3582 | } |
3584 | 3583 | ||
3585 | 3584 | ||
3586 | void CalendarView::takeOverEvent() | 3585 | void CalendarView::takeOverEvent() |
3587 | { | 3586 | { |
3588 | Incidence *incidence = currentSelection(); | 3587 | Incidence *incidence = currentSelection(); |
3589 | 3588 | ||
3590 | if (!incidence) return; | 3589 | if (!incidence) return; |
3591 | 3590 | ||
3592 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3591 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3593 | incidence->recreate(); | 3592 | incidence->recreate(); |
3594 | incidence->setReadOnly(false); | 3593 | incidence->setReadOnly(false); |
3595 | 3594 | ||
3596 | updateView(); | 3595 | updateView(); |
3597 | } | 3596 | } |
3598 | 3597 | ||
3599 | void CalendarView::takeOverCalendar() | 3598 | void CalendarView::takeOverCalendar() |
3600 | { | 3599 | { |
3601 | // TODO: Create Calendar::allIncidences() function and use it here | 3600 | // TODO: Create Calendar::allIncidences() function and use it here |
3602 | 3601 | ||
3603 | QPtrList<Event> events = mCalendar->events(); | 3602 | QPtrList<Event> events = mCalendar->events(); |
3604 | for(uint i=0; i<events.count(); ++i) { | 3603 | for(uint i=0; i<events.count(); ++i) { |
3605 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3604 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3606 | events.at(i)->recreate(); | 3605 | events.at(i)->recreate(); |
3607 | events.at(i)->setReadOnly(false); | 3606 | events.at(i)->setReadOnly(false); |
3608 | } | 3607 | } |
3609 | 3608 | ||
3610 | QPtrList<Todo> todos = mCalendar->todos(); | 3609 | QPtrList<Todo> todos = mCalendar->todos(); |
3611 | for(uint i=0; i<todos.count(); ++i) { | 3610 | for(uint i=0; i<todos.count(); ++i) { |
3612 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3611 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3613 | todos.at(i)->recreate(); | 3612 | todos.at(i)->recreate(); |
3614 | todos.at(i)->setReadOnly(false); | 3613 | todos.at(i)->setReadOnly(false); |
3615 | } | 3614 | } |
3616 | 3615 | ||
3617 | QPtrList<Journal> journals = mCalendar->journals(); | 3616 | QPtrList<Journal> journals = mCalendar->journals(); |
3618 | for(uint i=0; i<journals.count(); ++i) { | 3617 | for(uint i=0; i<journals.count(); ++i) { |
3619 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3618 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3620 | journals.at(i)->recreate(); | 3619 | journals.at(i)->recreate(); |
3621 | journals.at(i)->setReadOnly(false); | 3620 | journals.at(i)->setReadOnly(false); |
3622 | } | 3621 | } |
3623 | 3622 | ||
3624 | updateView(); | 3623 | updateView(); |
3625 | } | 3624 | } |
3626 | 3625 | ||
3627 | void CalendarView::showIntro() | 3626 | void CalendarView::showIntro() |
3628 | { | 3627 | { |
3629 | kdDebug() << "To be implemented." << endl; | 3628 | kdDebug() << "To be implemented." << endl; |
3630 | } | 3629 | } |
3631 | 3630 | ||
3632 | QWidgetStack *CalendarView::viewStack() | 3631 | QWidgetStack *CalendarView::viewStack() |
3633 | { | 3632 | { |
3634 | return mRightFrame; | 3633 | return mRightFrame; |
3635 | } | 3634 | } |
3636 | 3635 | ||
3637 | QWidget *CalendarView::leftFrame() | 3636 | QWidget *CalendarView::leftFrame() |
3638 | { | 3637 | { |
3639 | return mLeftFrame; | 3638 | return mLeftFrame; |
3640 | } | 3639 | } |
3641 | 3640 | ||
3642 | DateNavigator *CalendarView::dateNavigator() | 3641 | DateNavigator *CalendarView::dateNavigator() |
3643 | { | 3642 | { |
3644 | return mNavigator; | 3643 | return mNavigator; |
3645 | } | 3644 | } |
3646 | 3645 | ||
3647 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3646 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3648 | { | 3647 | { |
3649 | return mDateNavigator; | 3648 | return mDateNavigator; |
3650 | } | 3649 | } |
3651 | void CalendarView::toggleDateNavigatorWidget() | 3650 | void CalendarView::toggleDateNavigatorWidget() |
3652 | { | 3651 | { |
3653 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3652 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3654 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3653 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3655 | mDateNavigator->hide(); | 3654 | mDateNavigator->hide(); |
3656 | else | 3655 | else |
3657 | mDateNavigator->show(); | 3656 | mDateNavigator->show(); |
3658 | } | 3657 | } |
3659 | void CalendarView::addView(KOrg::BaseView *view) | 3658 | void CalendarView::addView(KOrg::BaseView *view) |
3660 | { | 3659 | { |
3661 | mViewManager->addView(view); | 3660 | mViewManager->addView(view); |
3662 | } | 3661 | } |
3663 | 3662 | ||
3664 | void CalendarView::showView(KOrg::BaseView *view) | 3663 | void CalendarView::showView(KOrg::BaseView *view) |
3665 | { | 3664 | { |
3666 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3665 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3667 | } | 3666 | } |
3668 | 3667 | ||
3669 | Incidence *CalendarView::currentSelection() | 3668 | Incidence *CalendarView::currentSelection() |
3670 | { | 3669 | { |
3671 | return mViewManager->currentSelection(); | 3670 | return mViewManager->currentSelection(); |
3672 | } | 3671 | } |
3673 | void CalendarView::toggleAllDaySize() | 3672 | void CalendarView::toggleAllDaySize() |
3674 | { | 3673 | { |
3675 | /* | 3674 | /* |
3676 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3675 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3677 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3676 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3678 | else | 3677 | else |
3679 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3678 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3680 | */ | 3679 | */ |
3681 | viewManager()->agendaView()->toggleAllDay(); | 3680 | viewManager()->agendaView()->toggleAllDay(); |
3682 | } | 3681 | } |
3683 | void CalendarView::toggleExpand() | 3682 | void CalendarView::toggleExpand() |
3684 | { | 3683 | { |
3685 | // if ( mLeftFrame->isHidden() ) { | 3684 | // if ( mLeftFrame->isHidden() ) { |
3686 | // mLeftFrame->show(); | 3685 | // mLeftFrame->show(); |
3687 | // emit calendarViewExpanded( false ); | 3686 | // emit calendarViewExpanded( false ); |
3688 | // } else { | 3687 | // } else { |
3689 | // mLeftFrame->hide(); | 3688 | // mLeftFrame->hide(); |
3690 | // emit calendarViewExpanded( true ); | 3689 | // emit calendarViewExpanded( true ); |
3691 | // } | 3690 | // } |
3692 | //qDebug(" CalendarView::toggleExpand()"); | 3691 | //qDebug(" CalendarView::toggleExpand()"); |
3693 | globalFlagBlockAgenda = 1; | 3692 | globalFlagBlockAgenda = 1; |
3694 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3693 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3695 | globalFlagBlockAgenda = 5; | 3694 | globalFlagBlockAgenda = 5; |
3696 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3695 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3697 | //mViewManager->showView( 0, true ); | 3696 | //mViewManager->showView( 0, true ); |
3698 | } | 3697 | } |
3699 | 3698 | ||
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 4cefb26..770a42b 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1155 +1,1156 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | #include "calprinter.h" | 45 | #include "calprinter.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #ifndef KORG_NOPLUGINS | 48 | #ifndef KORG_NOPLUGINS |
49 | #include "kocore.h" | 49 | #include "kocore.h" |
50 | #endif | 50 | #endif |
51 | #include "koglobals.h" | 51 | #include "koglobals.h" |
52 | #include <libkcal/kincidenceformatter.h> | 52 | #include <libkcal/kincidenceformatter.h> |
53 | 53 | ||
54 | #include "komonthview.h" | 54 | #include "komonthview.h" |
55 | 55 | ||
56 | #define PIXMAP_SIZE 5 | 56 | #define PIXMAP_SIZE 5 |
57 | #ifdef DESKTOP_VERSION | 57 | #ifdef DESKTOP_VERSION |
58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
59 | #endif | 59 | #endif |
60 | class KNOWhatsThis :public QWhatsThis | 60 | class KNOWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | virtual QString text( const QPoint& p) | 67 | virtual QString text( const QPoint& p) |
68 | { | 68 | { |
69 | return _wid->getWhatsThisText(p) ; | 69 | return _wid->getWhatsThisText(p) ; |
70 | }; | 70 | }; |
71 | private: | 71 | private: |
72 | KNoScrollListBox* _wid; | 72 | KNoScrollListBox* _wid; |
73 | 73 | ||
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
78 | : QListBox(parent, name, WRepaintNoErase) | 78 | : QListBox(parent, name, WRepaintNoErase) |
79 | { | 79 | { |
80 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
82 | #endif | 82 | #endif |
83 | mWT = new KNOWhatsThis(this); | 83 | mWT = new KNOWhatsThis(this); |
84 | } | 84 | } |
85 | KNoScrollListBox::~KNoScrollListBox() | 85 | KNoScrollListBox::~KNoScrollListBox() |
86 | { | 86 | { |
87 | 87 | ||
88 | } | 88 | } |
89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
90 | { | 90 | { |
91 | QListBoxItem* item = itemAt ( p ); | 91 | QListBoxItem* item = itemAt ( p ); |
92 | if ( ! item ) { | 92 | if ( ! item ) { |
93 | return i18n("Click in the cell\nto add an event!"); | 93 | return i18n("Click in the cell\nto add an event!"); |
94 | } | 94 | } |
95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
96 | } | 96 | } |
97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
98 | { | 98 | { |
99 | 99 | ||
100 | switch(e->key()) { | 100 | switch(e->key()) { |
101 | case Key_Right: | 101 | case Key_Right: |
102 | // if ( e->state() == Qt::ControlButton ) | 102 | // if ( e->state() == Qt::ControlButton ) |
103 | { | 103 | { |
104 | e->ignore(); | 104 | e->ignore(); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | scrollBy(4,0); | 107 | scrollBy(4,0); |
108 | break; | 108 | break; |
109 | case Key_Left: | 109 | case Key_Left: |
110 | // if ( e->state() == Qt::ControlButton ) | 110 | // if ( e->state() == Qt::ControlButton ) |
111 | { | 111 | { |
112 | e->ignore(); | 112 | e->ignore(); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | scrollBy(-4,0); | 115 | scrollBy(-4,0); |
116 | break; | 116 | break; |
117 | case Key_Up: | 117 | case Key_Up: |
118 | if(count() < 2) { | 118 | if(count() < 2) { |
119 | e->ignore(); | 119 | e->ignore(); |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | setCurrentItem((currentItem()+count()-1)%count()); | 122 | setCurrentItem((currentItem()+count()-1)%count()); |
123 | if(!itemVisible(currentItem())) { | 123 | if(!itemVisible(currentItem())) { |
124 | if((unsigned int) currentItem() == (count()-1)) { | 124 | if((unsigned int) currentItem() == (count()-1)) { |
125 | setTopItem(currentItem()-numItemsVisible()+1); | 125 | setTopItem(currentItem()-numItemsVisible()+1); |
126 | } else { | 126 | } else { |
127 | setTopItem(topItem()-1); | 127 | setTopItem(topItem()-1); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | break; | 130 | break; |
131 | case Key_Down: | 131 | case Key_Down: |
132 | if(count() < 2) { | 132 | if(count() < 2) { |
133 | e->ignore(); | 133 | e->ignore(); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | setCurrentItem((currentItem()+1)%count()); | 136 | setCurrentItem((currentItem()+1)%count()); |
137 | if(!itemVisible(currentItem())) { | 137 | if(!itemVisible(currentItem())) { |
138 | if(currentItem() == 0) { | 138 | if(currentItem() == 0) { |
139 | setTopItem(0); | 139 | setTopItem(0); |
140 | } else { | 140 | } else { |
141 | setTopItem(topItem()+1); | 141 | setTopItem(topItem()+1); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | break; | 144 | break; |
145 | case Key_Shift: | 145 | case Key_Shift: |
146 | emit shiftDown(); | 146 | emit shiftDown(); |
147 | break; | 147 | break; |
148 | default: | 148 | default: |
149 | e->ignore(); | 149 | e->ignore(); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
155 | { | 155 | { |
156 | switch(e->key()) { | 156 | switch(e->key()) { |
157 | case Key_Shift: | 157 | case Key_Shift: |
158 | emit shiftUp(); | 158 | emit shiftUp(); |
159 | break; | 159 | break; |
160 | default: | 160 | default: |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
166 | { | 166 | { |
167 | QListBox::mousePressEvent(e); | 167 | QListBox::mousePressEvent(e); |
168 | 168 | ||
169 | if(e->button() == RightButton) { | 169 | if(e->button() == RightButton) { |
170 | emit rightClick(); | 170 | emit rightClick(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
175 | : QListBoxItem() | 175 | : QListBoxItem() |
176 | { | 176 | { |
177 | setText( s ); | 177 | setText( s ); |
178 | 178 | ||
179 | mIncidence = incidence; | 179 | mIncidence = incidence; |
180 | mDate = qd; | 180 | mDate = qd; |
181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
182 | mRecur = false; | 182 | mRecur = false; |
183 | mAlarm = false; | 183 | mAlarm = false; |
184 | mReply = false; | 184 | mReply = false; |
185 | mInfo = false; | 185 | mInfo = false; |
186 | } | 186 | } |
187 | 187 | ||
188 | void MonthViewItem::paint(QPainter *p) | 188 | void MonthViewItem::paint(QPainter *p) |
189 | { | 189 | { |
190 | #if QT_VERSION >= 0x030000 | 190 | #if QT_VERSION >= 0x030000 |
191 | bool sel = isSelected(); | 191 | bool sel = isSelected(); |
192 | #else | 192 | #else |
193 | bool sel = selected(); | 193 | bool sel = selected(); |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | 196 | ||
197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
198 | { | 198 | { |
199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
202 | } | 202 | } |
203 | int x = 1; | 203 | int x = 1; |
204 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 204 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
205 | int size = PIXMAP_SIZE; | 205 | int size = PIXMAP_SIZE; |
206 | if ( QApplication::desktop()->width() < 300 ) | 206 | if ( QApplication::desktop()->width() < 300 ) |
207 | size = 3; | 207 | size = 3; |
208 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 208 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
209 | if ( mInfo ) { | 209 | if ( mInfo ) { |
210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
211 | x += size + 1; | 211 | x += size + 1; |
212 | } | 212 | } |
213 | if ( mRecur ) { | 213 | if ( mRecur ) { |
214 | p->fillRect ( x, y,size,size, Qt::blue ); | 214 | p->fillRect ( x, y,size,size, Qt::blue ); |
215 | x += size + 1; | 215 | x += size + 1; |
216 | } | 216 | } |
217 | if ( mAlarm ) { | 217 | if ( mAlarm ) { |
218 | p->fillRect ( x, y,size,size, Qt::red ); | 218 | p->fillRect ( x, y,size,size, Qt::red ); |
219 | x += size + 1; | 219 | x += size + 1; |
220 | } | 220 | } |
221 | if ( mReply ) { | 221 | if ( mReply ) { |
222 | p->fillRect ( x, y,size,size, Qt::yellow ); | 222 | p->fillRect ( x, y,size,size, Qt::yellow ); |
223 | x += size + 1; | 223 | x += size + 1; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | QFontMetrics fm = p->fontMetrics(); | 226 | QFontMetrics fm = p->fontMetrics(); |
227 | int yPos; | 227 | int yPos; |
228 | int pmheight = size; | 228 | int pmheight = size; |
229 | if( pmheight < fm.height() ) | 229 | if( pmheight < fm.height() ) |
230 | yPos = fm.ascent() + fm.leading()/2; | 230 | yPos = fm.ascent() + fm.leading()/2; |
231 | else | 231 | else |
232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
233 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 233 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
235 | p->drawText( x, yPos, text() ); | 235 | p->drawText( x, yPos, text() ); |
236 | if ( mIncidence->cancelled() ) { | 236 | if ( mIncidence->cancelled() ) { |
237 | int wid = fm.width( text() ); | 237 | int wid = fm.width( text() ); |
238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
239 | } | 239 | } |
240 | 240 | ||
241 | } | 241 | } |
242 | 242 | ||
243 | int MonthViewItem::height(const QListBox *lb) const | 243 | int MonthViewItem::height(const QListBox *lb) const |
244 | { | 244 | { |
245 | return lb->fontMetrics().lineSpacing()+1; | 245 | return lb->fontMetrics().lineSpacing()+1; |
246 | } | 246 | } |
247 | 247 | ||
248 | int MonthViewItem::width(const QListBox *lb) const | 248 | int MonthViewItem::width(const QListBox *lb) const |
249 | { | 249 | { |
250 | int size = PIXMAP_SIZE; | 250 | int size = PIXMAP_SIZE; |
251 | if ( QApplication::desktop()->width() < 300 ) | 251 | if ( QApplication::desktop()->width() < 300 ) |
252 | size = 3; | 252 | size = 3; |
253 | int x = 1; | 253 | int x = 1; |
254 | if ( mInfo ) { | 254 | if ( mInfo ) { |
255 | x += size + 1; | 255 | x += size + 1; |
256 | } | 256 | } |
257 | if( mRecur ) { | 257 | if( mRecur ) { |
258 | x += size+1; | 258 | x += size+1; |
259 | } | 259 | } |
260 | if( mAlarm ) { | 260 | if( mAlarm ) { |
261 | x += size+1; | 261 | x += size+1; |
262 | } | 262 | } |
263 | if( mReply ) { | 263 | if( mReply ) { |
264 | x += size+1; | 264 | x += size+1; |
265 | } | 265 | } |
266 | 266 | ||
267 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 267 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 271 | MonthViewCell::MonthViewCell( KOMonthView *parent) |
272 | : QWidget( parent ), | 272 | : QWidget( parent ), |
273 | mMonthView( parent ) | 273 | mMonthView( parent ) |
274 | { | 274 | { |
275 | 275 | ||
276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
277 | 277 | ||
278 | // mLabel = new QLabel( this );QPushButton | 278 | // mLabel = new QLabel( this );QPushButton |
279 | mLabel = new QPushButton( this ); | 279 | mLabel = new QPushButton( this ); |
280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
281 | //mLabel->setLineWidth( 1 ); | 281 | //mLabel->setLineWidth( 1 ); |
282 | //mLabel->setAlignment( AlignCenter ); | 282 | //mLabel->setAlignment( AlignCenter ); |
283 | mLabel->setFlat( true ); | 283 | mLabel->setFlat( true ); |
284 | mItemList = new KNoScrollListBox( this ); | 284 | mItemList = new KNoScrollListBox( this ); |
285 | mItemList->setMinimumSize( 10, 10 ); | 285 | mItemList->setMinimumSize( 10, 10 ); |
286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
287 | mItemList->setLineWidth( 1 ); | 287 | mItemList->setLineWidth( 1 ); |
288 | topLayout->addWidget( mItemList ); | 288 | topLayout->addWidget( mItemList ); |
289 | mLabel->raise(); | 289 | mLabel->raise(); |
290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
291 | mStandardPalette = palette(); | 291 | mStandardPalette = palette(); |
292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
293 | 293 | ||
294 | enableScrollBars( false ); | 294 | enableScrollBars( false ); |
295 | updateConfig(); | 295 | updateConfig(); |
296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
299 | SLOT( defaultAction( QListBoxItem * ) ) ); | 299 | SLOT( defaultAction( QListBoxItem * ) ) ); |
300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
301 | const QPoint &) ), | 301 | const QPoint &) ), |
302 | SLOT( contextMenu( QListBoxItem * ) ) ); | 302 | SLOT( contextMenu( QListBoxItem * ) ) ); |
303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
304 | SLOT( selection( QListBoxItem * ) ) ); | 304 | SLOT( selection( QListBoxItem * ) ) ); |
305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
306 | SLOT( cellClicked( QListBoxItem * ) ) ); | 306 | SLOT( cellClicked( QListBoxItem * ) ) ); |
307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
308 | SLOT( selection( QListBoxItem * ) ) ); | 308 | SLOT( selection( QListBoxItem * ) ) ); |
309 | } | 309 | } |
310 | #ifdef DESKTOP_VERSION | 310 | #ifdef DESKTOP_VERSION |
311 | QToolTipGroup *MonthViewCell::toolTipGroup() | 311 | QToolTipGroup *MonthViewCell::toolTipGroup() |
312 | { | 312 | { |
313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
314 | return mToolTipGroup; | 314 | return mToolTipGroup; |
315 | } | 315 | } |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | void MonthViewCell::setDate( const QDate &date ) | 318 | void MonthViewCell::setDate( const QDate &date ) |
319 | { | 319 | { |
320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
321 | mDate = date; | 321 | mDate = date; |
322 | 322 | ||
323 | 323 | ||
324 | 324 | ||
325 | //resizeEvent( 0 ); | 325 | //resizeEvent( 0 ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QDate MonthViewCell::date() const | 328 | QDate MonthViewCell::date() const |
329 | { | 329 | { |
330 | return mDate; | 330 | return mDate; |
331 | } | 331 | } |
332 | 332 | ||
333 | void MonthViewCell::setPrimary( bool primary ) | 333 | void MonthViewCell::setPrimary( bool primary ) |
334 | { | 334 | { |
335 | mPrimary = primary; | 335 | mPrimary = primary; |
336 | //setMyPalette(); | 336 | //setMyPalette(); |
337 | } | 337 | } |
338 | void MonthViewCell::setMyPalette() | 338 | void MonthViewCell::setMyPalette() |
339 | { | 339 | { |
340 | 340 | ||
341 | if ( mHoliday) { | 341 | if ( mHoliday) { |
342 | setPalette( mHolidayPalette ); | 342 | setPalette( mHolidayPalette ); |
343 | } else { | 343 | } else { |
344 | if ( mPrimary ) { | 344 | if ( mPrimary ) { |
345 | setPalette( mPrimaryPalette ); | 345 | setPalette( mPrimaryPalette ); |
346 | } else { | 346 | } else { |
347 | setPalette( mNonPrimaryPalette ); | 347 | setPalette( mNonPrimaryPalette ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | QPalette pal = palette(); | 350 | QPalette pal = palette(); |
351 | 351 | ||
352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
353 | } | 353 | } |
354 | QPalette MonthViewCell::getPalette () | 354 | QPalette MonthViewCell::getPalette () |
355 | { | 355 | { |
356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
357 | return mStandardPalette; | 357 | return mStandardPalette; |
358 | if ( mHoliday) { | 358 | if ( mHoliday) { |
359 | return mHolidayPalette ; | 359 | return mHolidayPalette ; |
360 | } else { | 360 | } else { |
361 | if ( mPrimary ) { | 361 | if ( mPrimary ) { |
362 | return mPrimaryPalette ; | 362 | return mPrimaryPalette ; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | return mNonPrimaryPalette; | 365 | return mNonPrimaryPalette; |
366 | } | 366 | } |
367 | bool MonthViewCell::isPrimary() const | 367 | bool MonthViewCell::isPrimary() const |
368 | { | 368 | { |
369 | return mPrimary; | 369 | return mPrimary; |
370 | } | 370 | } |
371 | 371 | ||
372 | void MonthViewCell::setHoliday( bool holiday ) | 372 | void MonthViewCell::setHoliday( bool holiday ) |
373 | { | 373 | { |
374 | mHoliday = holiday; | 374 | mHoliday = holiday; |
375 | //setMyPalette(); | 375 | //setMyPalette(); |
376 | } | 376 | } |
377 | 377 | ||
378 | void MonthViewCell::setHoliday( const QString &holiday ) | 378 | void MonthViewCell::setHoliday( const QString &holiday ) |
379 | { | 379 | { |
380 | mHolidayString = holiday; | 380 | mHolidayString = holiday; |
381 | 381 | ||
382 | if ( !holiday.isEmpty() ) { | 382 | if ( !holiday.isEmpty() ) { |
383 | setHoliday( true ); | 383 | setHoliday( true ); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
387 | { | 387 | { |
388 | 388 | ||
389 | e->ignore(); | 389 | e->ignore(); |
390 | 390 | ||
391 | } | 391 | } |
392 | void MonthViewCell::clear() | 392 | void MonthViewCell::clear() |
393 | { | 393 | { |
394 | mItemList->clear(); | 394 | mItemList->clear(); |
395 | QApplication::removePostedEvents ( mItemList ); | 395 | QApplication::removePostedEvents ( mItemList ); |
396 | QApplication::removePostedEvents ( mLabel ); | 396 | QApplication::removePostedEvents ( mLabel ); |
397 | QApplication::removePostedEvents ( this ); | 397 | QApplication::removePostedEvents ( this ); |
398 | } | 398 | } |
399 | void MonthViewCell::updateCell() | 399 | void MonthViewCell::updateCell() |
400 | { | 400 | { |
401 | if ( !mMonthView->isUpdatePossible() ) | 401 | if ( !mMonthView->isUpdatePossible() ) |
402 | return; | 402 | return; |
403 | /* | 403 | /* |
404 | if ( !isVisible() ){ | 404 | if ( !isVisible() ){ |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | */ | 407 | */ |
408 | // qDebug("MonthViewCell::updateCell() "); | 408 | // qDebug("MonthViewCell::updateCell() "); |
409 | setPrimary( mDate.month()%2 ); | 409 | setPrimary( mDate.month()%2 ); |
410 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 410 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
411 | if ( mDate == QDate::currentDate() ) { | 411 | if ( mDate == QDate::currentDate() ) { |
412 | mItemList->setLineWidth( 3 ); | 412 | mItemList->setLineWidth( 3 ); |
413 | } else { | 413 | } else { |
414 | mItemList->setLineWidth( 1 ); | 414 | mItemList->setLineWidth( 1 ); |
415 | } | 415 | } |
416 | mItemList->clear(); | 416 | mItemList->clear(); |
417 | 417 | ||
418 | #ifdef DESKTOP_VERSION | 418 | #ifdef DESKTOP_VERSION |
419 | QToolTip::remove(this); | 419 | QToolTip::remove(this); |
420 | #endif | 420 | #endif |
421 | QString tipText(""); | 421 | QString tipText(""); |
422 | //qApp->processEvents(); | 422 | //qApp->processEvents(); |
423 | if ( !mHolidayString.isEmpty() ) { | 423 | if ( !mHolidayString.isEmpty() ) { |
424 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 424 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
425 | item->setPalette( mHolidayPalette ); | 425 | item->setPalette( mHolidayPalette ); |
426 | mItemList->insertItem( item ); | 426 | mItemList->insertItem( item ); |
427 | tipText += mHolidayString+"\n"; | 427 | tipText += mHolidayString+"\n"; |
428 | } | 428 | } |
429 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 429 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
430 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 430 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
431 | Event *event; | 431 | Event *event; |
432 | for( event = events.first(); event; event = events.next() ) { // for event | 432 | for( event = events.first(); event; event = events.next() ) { // for event |
433 | 433 | ||
434 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 434 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
435 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 435 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
436 | continue; | 436 | continue; |
437 | else | 437 | else |
438 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 438 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
439 | continue; | 439 | continue; |
440 | } | 440 | } |
441 | 441 | ||
442 | if ( event->categories().contains("Holiday") || | 442 | if ( event->categories().contains("Holiday") || |
443 | event->categories().contains(i18n("Holiday"))) { | 443 | event->categories().contains(i18n("Holiday"))) { |
444 | setHoliday( true ); | 444 | setHoliday( true ); |
445 | if ( mDate.dayOfWeek() == 7 ) | 445 | if ( mDate.dayOfWeek() == 7 ) |
446 | mItemList->setLineWidth( 3 ); | 446 | mItemList->setLineWidth( 3 ); |
447 | } | 447 | } |
448 | QString text; | 448 | QString text; |
449 | if (event->isMultiDay()) { | 449 | if (event->isMultiDay()) { |
450 | QString prefix = "<->"; | 450 | QString prefix = "<->"; |
451 | if ( event->doesRecur() ) { | 451 | if ( event->doesRecur() ) { |
452 | if ( event->recursOn( mDate) ) | 452 | if ( event->recursOn( mDate) ) |
453 | prefix ="->" ; | 453 | prefix ="->" ; |
454 | else { | 454 | else { |
455 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 455 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
456 | if ( event->recursOn( mDate.addDays( -days)) ) | 456 | if ( event->recursOn( mDate.addDays( -days)) ) |
457 | prefix ="<-" ; | 457 | prefix ="<-" ; |
458 | } | 458 | } |
459 | 459 | ||
460 | } else { | 460 | } else { |
461 | if (mDate == event->dtStart().date()) { | 461 | if (mDate == event->dtStart().date()) { |
462 | prefix ="->" ; | 462 | prefix ="->" ; |
463 | } else if (mDate == event->dtEnd().date()) { | 463 | } else if (mDate == event->dtEnd().date()) { |
464 | prefix ="<-" ; | 464 | prefix ="<-" ; |
465 | } | 465 | } |
466 | } | 466 | } |
467 | text = prefix + event->summary(); | 467 | text = prefix + event->summary(); |
468 | tipText += text; | 468 | tipText += text; |
469 | } else { | 469 | } else { |
470 | if (event->doesFloat()) { | 470 | if (event->doesFloat()) { |
471 | text = event->summary(); | 471 | text = event->summary(); |
472 | tipText += text; | 472 | tipText += text; |
473 | } | 473 | } |
474 | else { | 474 | else { |
475 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 475 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
476 | text += " " + event->summary(); | 476 | text += " " + event->summary(); |
477 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 477 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 481 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
482 | QPalette pal; | 482 | QPalette pal; |
483 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 483 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
484 | QStringList categories = event->categories(); | 484 | QStringList categories = event->categories(); |
485 | QString cat = categories.first(); | 485 | QString cat = categories.first(); |
486 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 486 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
487 | pal = getPalette(); | 487 | pal = getPalette(); |
488 | if (cat.isEmpty()) { | 488 | if (cat.isEmpty()) { |
489 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 489 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
490 | } else { | 490 | } else { |
491 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 491 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
492 | } | 492 | } |
493 | 493 | ||
494 | } else { | 494 | } else { |
495 | if (cat.isEmpty()) { | 495 | if (cat.isEmpty()) { |
496 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 496 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
497 | } else { | 497 | } else { |
498 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 498 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | } else { | 502 | } else { |
503 | pal = mStandardPalette ; | 503 | pal = mStandardPalette ; |
504 | } | 504 | } |
505 | item->setPalette( pal ); | 505 | item->setPalette( pal ); |
506 | item->setRecur( event->recurrence()->doesRecur() ); | 506 | item->setRecur( event->recurrence()->doesRecur() ); |
507 | item->setAlarm( event->isAlarmEnabled() ); | 507 | item->setAlarm( event->isAlarmEnabled() ); |
508 | item->setMoreInfo( event->description().length() > 0 ); | 508 | item->setMoreInfo( event->description().length() > 0 ); |
509 | #ifdef DESKTOP_VERSION | 509 | #ifdef DESKTOP_VERSION |
510 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 510 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
511 | KOPrefs::instance()->email()); | 511 | KOPrefs::instance()->email()); |
512 | if ( me != 0 ) { | 512 | if ( me != 0 ) { |
513 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 513 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
514 | item->setReply(true); | 514 | item->setReply(true); |
515 | else | 515 | else |
516 | item->setReply(false); | 516 | item->setReply(false); |
517 | } else | 517 | } else |
518 | item->setReply(false); | 518 | item->setReply(false); |
519 | #endif | 519 | #endif |
520 | mItemList->insertItem( item ); | 520 | mItemList->insertItem( item ); |
521 | tipText += "\n"; | 521 | tipText += "\n"; |
522 | 522 | ||
523 | } | 523 | } |
524 | 524 | ||
525 | // insert due todos | 525 | // insert due todos |
526 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 526 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
527 | Todo *todo; | 527 | Todo *todo; |
528 | for(todo = todos.first(); todo; todo = todos.next()) { | 528 | for(todo = todos.first(); todo; todo = todos.next()) { |
529 | QString text; | 529 | QString text; |
530 | if (todo->hasDueDate()) { | 530 | if (todo->hasDueDate()) { |
531 | if (!todo->doesFloat()) { | 531 | if (!todo->doesFloat()) { |
532 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 532 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
533 | text += " "; | 533 | text += " "; |
534 | } | 534 | } |
535 | } | 535 | } |
536 | text += i18n("To-Do: %1").arg(todo->summary()); | 536 | text += i18n("To-Do: %1").arg(todo->summary()); |
537 | 537 | ||
538 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 538 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
539 | //item->setPalette( mStandardPalette ); | 539 | //item->setPalette( mStandardPalette ); |
540 | QPalette pal; | 540 | QPalette pal; |
541 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 541 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
542 | QStringList categories = todo->categories(); | 542 | QStringList categories = todo->categories(); |
543 | QString cat = categories.first(); | 543 | QString cat = categories.first(); |
544 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 544 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
545 | pal = getPalette(); | 545 | pal = getPalette(); |
546 | if (cat.isEmpty()) { | 546 | if (cat.isEmpty()) { |
547 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 547 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
548 | } else { | 548 | } else { |
549 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 549 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
550 | } | 550 | } |
551 | 551 | ||
552 | } else { | 552 | } else { |
553 | if (cat.isEmpty()) { | 553 | if (cat.isEmpty()) { |
554 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 554 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
555 | } else { | 555 | } else { |
556 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 556 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
557 | } | 557 | } |
558 | } | 558 | } |
559 | 559 | ||
560 | } else { | 560 | } else { |
561 | pal = mStandardPalette ; | 561 | pal = mStandardPalette ; |
562 | } | 562 | } |
563 | item->setPalette( pal ); | 563 | item->setPalette( pal ); |
564 | mItemList->insertItem( item ); | 564 | mItemList->insertItem( item ); |
565 | tipText += text+"\n"; | 565 | tipText += text+"\n"; |
566 | } | 566 | } |
567 | #ifdef DESKTOP_VERSION | 567 | #ifdef DESKTOP_VERSION |
568 | if (tipText != "") | 568 | if (tipText != "") |
569 | QToolTip::add(this,tipText,toolTipGroup(),""); | 569 | QToolTip::add(this,tipText,toolTipGroup(),""); |
570 | #endif | 570 | #endif |
571 | 571 | ||
572 | //setMyPalette(); | 572 | //setMyPalette(); |
573 | setMyPalette(); | 573 | setMyPalette(); |
574 | QString text; | 574 | QString text; |
575 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 575 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
576 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 576 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
577 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 577 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
578 | mLabel->resize( mLabelBigSize ); | 578 | mLabel->resize( mLabelBigSize ); |
579 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 579 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
580 | } else { | 580 | } else { |
581 | mLabel->resize( mLabelSize ); | 581 | mLabel->resize( mLabelSize ); |
582 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 582 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
583 | } | 583 | } |
584 | 584 | ||
585 | mLabel->setText( text ); | 585 | mLabel->setText( text ); |
586 | resizeEvent( 0 ); | 586 | resizeEvent( 0 ); |
587 | // if ( isVisible()) | 587 | // if ( isVisible()) |
588 | //qApp->processEvents(); | 588 | //qApp->processEvents(); |
589 | } | 589 | } |
590 | 590 | ||
591 | void MonthViewCell::updateConfig() | 591 | void MonthViewCell::updateConfig() |
592 | { | 592 | { |
593 | 593 | ||
594 | setFont( KOPrefs::instance()->mMonthViewFont ); | 594 | setFont( KOPrefs::instance()->mMonthViewFont ); |
595 | 595 | ||
596 | QFontMetrics fm( font() ); | 596 | QFontMetrics fm( font() ); |
597 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 597 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
598 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 598 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
599 | mHolidayPalette = mStandardPalette; | 599 | mHolidayPalette = mStandardPalette; |
600 | mPrimaryPalette = mStandardPalette; | 600 | mPrimaryPalette = mStandardPalette; |
601 | mNonPrimaryPalette = mStandardPalette; | 601 | mNonPrimaryPalette = mStandardPalette; |
602 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 602 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
603 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 603 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
604 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 604 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
605 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 605 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
606 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 606 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
607 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 607 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
608 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 608 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
609 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 609 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
610 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 610 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
611 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 611 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
612 | } | 612 | } |
613 | updateCell(); | 613 | updateCell(); |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::enableScrollBars( bool enabled ) | 616 | void MonthViewCell::enableScrollBars( bool enabled ) |
617 | { | 617 | { |
618 | if ( enabled ) { | 618 | if ( enabled ) { |
619 | mItemList->setVScrollBarMode(QScrollView::Auto); | 619 | mItemList->setVScrollBarMode(QScrollView::Auto); |
620 | mItemList->setHScrollBarMode(QScrollView::Auto); | 620 | mItemList->setHScrollBarMode(QScrollView::Auto); |
621 | } else { | 621 | } else { |
622 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 622 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
623 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 623 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | Incidence *MonthViewCell::selectedIncidence() | 627 | Incidence *MonthViewCell::selectedIncidence() |
628 | { | 628 | { |
629 | int index = mItemList->currentItem(); | 629 | int index = mItemList->currentItem(); |
630 | if ( index < 0 ) return 0; | 630 | if ( index < 0 ) return 0; |
631 | 631 | ||
632 | MonthViewItem *item = | 632 | MonthViewItem *item = |
633 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 633 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
634 | 634 | ||
635 | if ( !item ) return 0; | 635 | if ( !item ) return 0; |
636 | 636 | ||
637 | return item->incidence(); | 637 | return item->incidence(); |
638 | } | 638 | } |
639 | 639 | ||
640 | QDate MonthViewCell::selectedIncidenceDate() | 640 | QDate MonthViewCell::selectedIncidenceDate() |
641 | { | 641 | { |
642 | QDate qd; | 642 | QDate qd; |
643 | int index = mItemList->currentItem(); | 643 | int index = mItemList->currentItem(); |
644 | if ( index < 0 ) return qd; | 644 | if ( index < 0 ) return qd; |
645 | 645 | ||
646 | MonthViewItem *item = | 646 | MonthViewItem *item = |
647 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 647 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
648 | 648 | ||
649 | if ( !item ) return qd; | 649 | if ( !item ) return qd; |
650 | 650 | ||
651 | return item->incidenceDate(); | 651 | return item->incidenceDate(); |
652 | } | 652 | } |
653 | 653 | ||
654 | void MonthViewCell::deselect() | 654 | void MonthViewCell::deselect() |
655 | { | 655 | { |
656 | mItemList->clearSelection(); | 656 | mItemList->clearSelection(); |
657 | enableScrollBars( false ); | 657 | enableScrollBars( false ); |
658 | // updateCell(); | 658 | // updateCell(); |
659 | } | 659 | } |
660 | void MonthViewCell::select() | 660 | void MonthViewCell::select() |
661 | { | 661 | { |
662 | ;// updateCell(); | 662 | ;// updateCell(); |
663 | } | 663 | } |
664 | 664 | ||
665 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 665 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
666 | { | 666 | { |
667 | if ( !mMonthView->isUpdatePossible() ) | 667 | if ( !mMonthView->isUpdatePossible() ) |
668 | return; | 668 | return; |
669 | #ifndef DESKTOP_VERSION | 669 | #ifndef DESKTOP_VERSION |
670 | if ( !isVisible() ){ | 670 | if ( !isVisible() ){ |
671 | return; | 671 | return; |
672 | } | 672 | } |
673 | #endif | 673 | #endif |
674 | int size = height() - mLabel->height(); | 674 | int size = height() - mLabel->height(); |
675 | if ( size > 0 ) | 675 | if ( size > 0 ) |
676 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 676 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
677 | size = width() - mLabel->width(); | 677 | size = width() - mLabel->width(); |
678 | if ( size > 0 ) | 678 | if ( size > 0 ) |
679 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 679 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
680 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 680 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
681 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 681 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
682 | } | 682 | } |
683 | 683 | ||
684 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 684 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
685 | { | 685 | { |
686 | if ( !item ) return; | 686 | if ( !item ) return; |
687 | 687 | ||
688 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 688 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
689 | Incidence *incidence = eventItem->incidence(); | 689 | Incidence *incidence = eventItem->incidence(); |
690 | if ( incidence ) mMonthView->defaultAction( incidence ); | 690 | if ( incidence ) mMonthView->defaultAction( incidence ); |
691 | } | 691 | } |
692 | void MonthViewCell::showDay() | 692 | void MonthViewCell::showDay() |
693 | { | 693 | { |
694 | emit showDaySignal( date() ); | 694 | emit showDaySignal( date() ); |
695 | } | 695 | } |
696 | void MonthViewCell::newEvent() | 696 | void MonthViewCell::newEvent() |
697 | { | 697 | { |
698 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 698 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
699 | emit newEventSignal( dt ); | 699 | emit newEventSignal( dt ); |
700 | } | 700 | } |
701 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 701 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
702 | { | 702 | { |
703 | static QListBoxItem * lastClicked = 0; | 703 | static QListBoxItem * lastClicked = 0; |
704 | if ( item == 0 ) { | 704 | if ( item == 0 ) { |
705 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 705 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
706 | emit newEventSignal( dt ); | 706 | emit newEventSignal( dt ); |
707 | return; | 707 | return; |
708 | } | 708 | } |
709 | /* | 709 | /* |
710 | if ( lastClicked ) | 710 | if ( lastClicked ) |
711 | if ( ! item ) { | 711 | if ( ! item ) { |
712 | if ( lastClicked->listBox() != item->listBox() ) | 712 | if ( lastClicked->listBox() != item->listBox() ) |
713 | lastClicked->listBox()->clearSelection(); | 713 | lastClicked->listBox()->clearSelection(); |
714 | } | 714 | } |
715 | */ | 715 | */ |
716 | 716 | ||
717 | mMonthView->setSelectedCell( this ); | 717 | mMonthView->setSelectedCell( this ); |
718 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); | 718 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); |
719 | select(); | 719 | select(); |
720 | } | 720 | } |
721 | 721 | ||
722 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 722 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
723 | { | 723 | { |
724 | if ( !item ) return; | 724 | if ( !item ) return; |
725 | 725 | ||
726 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 726 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
727 | Incidence *incidence = eventItem->incidence(); | 727 | Incidence *incidence = eventItem->incidence(); |
728 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 728 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
729 | } | 729 | } |
730 | 730 | ||
731 | void MonthViewCell::selection( QListBoxItem *item ) | 731 | void MonthViewCell::selection( QListBoxItem *item ) |
732 | { | 732 | { |
733 | if ( !item ) return; | 733 | if ( !item ) return; |
734 | 734 | ||
735 | mMonthView->setSelectedCell( this ); | 735 | mMonthView->setSelectedCell( this ); |
736 | } | 736 | } |
737 | 737 | ||
738 | 738 | ||
739 | // ******************************************************************************* | 739 | // ******************************************************************************* |
740 | // ******************************************************************************* | 740 | // ******************************************************************************* |
741 | // ******************************************************************************* | 741 | // ******************************************************************************* |
742 | 742 | ||
743 | 743 | ||
744 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 744 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
745 | : KOEventView( calendar, parent, name ), | 745 | : KOEventView( calendar, parent, name ), |
746 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 746 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
747 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 747 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
748 | { | 748 | { |
749 | 749 | ||
750 | updatePossible = false; | 750 | updatePossible = false; |
751 | mCells.setAutoDelete( true ); | 751 | mCells.setAutoDelete( true ); |
752 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 752 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
753 | // mDayLayout = new QGridLayout( this ); | 753 | // mDayLayout = new QGridLayout( this ); |
754 | // create the day of the week labels (Sun, Mon, etc) and add them to | 754 | // create the day of the week labels (Sun, Mon, etc) and add them to |
755 | // the layout. | 755 | // the layout. |
756 | mDayLabels.resize( mDaysPerWeek ); | 756 | mDayLabels.resize( mDaysPerWeek ); |
757 | QFont bfont = font(); | 757 | QFont bfont = font(); |
758 | if ( QApplication::desktop()->width() < 650 ) { | 758 | if ( QApplication::desktop()->width() < 650 ) { |
759 | bfont.setPointSize( bfont.pointSize() - 2 ); | 759 | bfont.setPointSize( bfont.pointSize() - 2 ); |
760 | } | 760 | } |
761 | bfont.setBold( true ); | 761 | bfont.setBold( true ); |
762 | int i; | 762 | int i; |
763 | 763 | ||
764 | for( i = 0; i < mDaysPerWeek; i++ ) { | 764 | for( i = 0; i < mDaysPerWeek; i++ ) { |
765 | QLabel *label = new QLabel( this ); | 765 | QLabel *label = new QLabel( this ); |
766 | label->setFont(bfont); | 766 | label->setFont(bfont); |
767 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 767 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
768 | label->setLineWidth(1); | 768 | label->setLineWidth(1); |
769 | label->setAlignment(AlignCenter); | 769 | label->setAlignment(AlignCenter); |
770 | mDayLabels.insert( i, label ); | 770 | mDayLabels.insert( i, label ); |
771 | } | 771 | } |
772 | 772 | ||
773 | bfont.setBold( false ); | 773 | bfont.setBold( false ); |
774 | mWeekLabels.resize( mNumWeeks+1 ); | 774 | mWeekLabels.resize( mNumWeeks+1 ); |
775 | for( i = 0; i < mNumWeeks+1; i++ ) { | 775 | for( i = 0; i < mNumWeeks+1; i++ ) { |
776 | KOWeekButton *label = new KOWeekButton( this ); | 776 | KOWeekButton *label = new KOWeekButton( this ); |
777 | label->setFont(bfont); | 777 | label->setFont(bfont); |
778 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | 778 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); |
779 | label->setFlat(true); | 779 | label->setFlat(true); |
780 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | 780 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); |
781 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 781 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
782 | //label->setLineWidth(1); | 782 | //label->setLineWidth(1); |
783 | //label->setAlignment(AlignCenter); | 783 | //label->setAlignment(AlignCenter); |
784 | mWeekLabels.insert( i, label ); | 784 | mWeekLabels.insert( i, label ); |
785 | } | 785 | } |
786 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 786 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
787 | int row, col; | 787 | int row, col; |
788 | mCells.resize( mNumCells ); | 788 | mCells.resize( mNumCells ); |
789 | for( row = 0; row < mNumWeeks; ++row ) { | 789 | for( row = 0; row < mNumWeeks; ++row ) { |
790 | for( col = 0; col < mDaysPerWeek; ++col ) { | 790 | for( col = 0; col < mDaysPerWeek; ++col ) { |
791 | MonthViewCell *cell = new MonthViewCell( this ); | 791 | MonthViewCell *cell = new MonthViewCell( this ); |
792 | mCells.insert( row * mDaysPerWeek + col, cell ); | 792 | mCells.insert( row * mDaysPerWeek + col, cell ); |
793 | 793 | ||
794 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 794 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
795 | SLOT( defaultAction( Incidence * ) ) ); | 795 | SLOT( defaultAction( Incidence * ) ) ); |
796 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 796 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
797 | SIGNAL( newEventSignal( QDateTime ) ) ); | 797 | SIGNAL( newEventSignal( QDateTime ) ) ); |
798 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 798 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
799 | SIGNAL( showDaySignal( QDate ) ) ); | 799 | SIGNAL( showDaySignal( QDate ) ) ); |
800 | } | 800 | } |
801 | } | 801 | } |
802 | 802 | ||
803 | mContextMenu = eventPopup(); | 803 | mContextMenu = eventPopup(); |
804 | // updateConfig(); //useless here | 804 | // updateConfig(); //useless here |
805 | 805 | ||
806 | emit incidenceSelected( 0 ); | 806 | emit incidenceSelected( 0 ); |
807 | } | 807 | } |
808 | 808 | ||
809 | KOMonthView::~KOMonthView() | 809 | KOMonthView::~KOMonthView() |
810 | { | 810 | { |
811 | delete mContextMenu; | 811 | delete mContextMenu; |
812 | } | 812 | } |
813 | 813 | ||
814 | int KOMonthView::maxDatesHint() | 814 | int KOMonthView::maxDatesHint() |
815 | { | 815 | { |
816 | return mNumCells; | 816 | return mNumCells; |
817 | } | 817 | } |
818 | 818 | ||
819 | int KOMonthView::currentDateCount() | 819 | int KOMonthView::currentDateCount() |
820 | { | 820 | { |
821 | return mNumCells; | 821 | return mNumCells; |
822 | } | 822 | } |
823 | 823 | ||
824 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 824 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
825 | { | 825 | { |
826 | QPtrList<Incidence> selected; | 826 | QPtrList<Incidence> selected; |
827 | 827 | ||
828 | if ( mSelectedCell ) { | 828 | if ( mSelectedCell ) { |
829 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 829 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
830 | if ( incidence ) selected.append( incidence ); | 830 | if ( incidence ) selected.append( incidence ); |
831 | } | 831 | } |
832 | 832 | ||
833 | return selected; | 833 | return selected; |
834 | } | 834 | } |
835 | 835 | ||
836 | DateList KOMonthView::selectedDates() | 836 | DateList KOMonthView::selectedDates() |
837 | { | 837 | { |
838 | DateList selected; | 838 | DateList selected; |
839 | 839 | ||
840 | if ( mSelectedCell ) { | 840 | if ( mSelectedCell ) { |
841 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 841 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
842 | if ( qd.isValid() ) selected.append( qd ); | 842 | if ( qd.isValid() ) selected.append( qd ); |
843 | } | 843 | } |
844 | 844 | ||
845 | return selected; | 845 | return selected; |
846 | } | 846 | } |
847 | 847 | ||
848 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 848 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
849 | const QDate &td) | 849 | const QDate &td) |
850 | { | 850 | { |
851 | #ifndef KORG_NOPRINTER | 851 | #ifndef KORG_NOPRINTER |
852 | calPrinter->preview(CalPrinter::Month, fd, td); | 852 | calPrinter->preview(CalPrinter::Month, fd, td); |
853 | #endif | 853 | #endif |
854 | } | 854 | } |
855 | 855 | ||
856 | void KOMonthView::updateConfig() | 856 | void KOMonthView::updateConfig() |
857 | { | 857 | { |
858 | 858 | ||
859 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 859 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
860 | 860 | ||
861 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 861 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
862 | mWidthLongDayLabel = 0; | 862 | mWidthLongDayLabel = 0; |
863 | 863 | ||
864 | for (int i = 0; i < 7; i++) { | 864 | for (int i = 0; i < 7; i++) { |
865 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 865 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
866 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 866 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
867 | } | 867 | } |
868 | bool temp = mShowSatSunComp ; | 868 | bool temp = mShowSatSunComp ; |
869 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 869 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
870 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 870 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
871 | computeLayout(); | 871 | computeLayout(); |
872 | updateDayLabels(); | 872 | updateDayLabels(); |
873 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 873 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
874 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 874 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
875 | //resizeEvent( 0 ); | 875 | //resizeEvent( 0 ); |
876 | for (uint i = 0; i < mCells.count(); ++i) { | 876 | for (uint i = 0; i < mCells.count(); ++i) { |
877 | mCells[i]->updateConfig(); | 877 | mCells[i]->updateConfig(); |
878 | } | 878 | } |
879 | #ifdef DESKTOP_VERSION | 879 | #ifdef DESKTOP_VERSION |
880 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 880 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
881 | #endif | 881 | #endif |
882 | } | 882 | } |
883 | 883 | ||
884 | void KOMonthView::updateDayLabels() | 884 | void KOMonthView::updateDayLabels() |
885 | { | 885 | { |
886 | 886 | ||
887 | for (int i = 0; i < 7; i++) { | 887 | for (int i = 0; i < 7; i++) { |
888 | if (mWeekStartsMonday) { | 888 | if (mWeekStartsMonday) { |
889 | bool show = mShortDayLabels; | 889 | bool show = mShortDayLabels; |
890 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 890 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
891 | show = true; | 891 | show = true; |
892 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 892 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
893 | } else { | 893 | } else { |
894 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 894 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
895 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 895 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
896 | 896 | ||
897 | } | 897 | } |
898 | } | 898 | } |
899 | } | 899 | } |
900 | 900 | ||
901 | void KOMonthView::showDates(const QDate &start, const QDate &) | 901 | void KOMonthView::showDates(const QDate &start, const QDate &) |
902 | { | 902 | { |
903 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 903 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
904 | 904 | ||
905 | 905 | ||
906 | mStartDate = start; | 906 | mStartDate = start; |
907 | 907 | ||
908 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 908 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
909 | 909 | ||
910 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 910 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
911 | mStartDate = mStartDate.addDays( -1 ); | 911 | mStartDate = mStartDate.addDays( -1 ); |
912 | } | 912 | } |
913 | 913 | ||
914 | bool primary = false; | 914 | bool primary = false; |
915 | uint i; | 915 | uint i; |
916 | for( i = 0; i < mCells.size(); ++i ) { | 916 | for( i = 0; i < mCells.size(); ++i ) { |
917 | QDate date = mStartDate.addDays( i ); | 917 | QDate date = mStartDate.addDays( i ); |
918 | mCells[i]->setDate( date ); | 918 | mCells[i]->setDate( date ); |
919 | 919 | ||
920 | #ifndef KORG_NOPLUGINS | 920 | #ifndef KORG_NOPLUGINS |
921 | // add holiday, if present | 921 | // add holiday, if present |
922 | QString hstring(KOCore::self()->holiday(date)); | 922 | QString hstring(KOCore::self()->holiday(date)); |
923 | mCells[i]->setHoliday( hstring ); | 923 | mCells[i]->setHoliday( hstring ); |
924 | #endif | 924 | #endif |
925 | 925 | ||
926 | } | 926 | } |
927 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 927 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
928 | for( i = 0; i < 6; ++i ) { | 928 | for( i = 0; i < 6; ++i ) { |
929 | int wno; | 929 | int wno; |
930 | // remember, according to ISO 8601, the first week of the year is the | 930 | // remember, according to ISO 8601, the first week of the year is the |
931 | // first week that contains a thursday. Thus we must subtract off 4, | 931 | // first week that contains a thursday. Thus we must subtract off 4, |
932 | // not just 1. | 932 | // not just 1. |
933 | int dayOfYear = date.dayOfYear(); | 933 | int dayOfYear = date.dayOfYear(); |
934 | if (dayOfYear % 7 != 0) | 934 | if (dayOfYear % 7 != 0) |
935 | wno = dayOfYear / 7 + 1; | 935 | wno = dayOfYear / 7 + 1; |
936 | else | 936 | else |
937 | wno =dayOfYear / 7; | 937 | wno =dayOfYear / 7; |
938 | mWeekLabels[i]->setWeekNum( wno ); | 938 | mWeekLabels[i]->setWeekNum( wno ); |
939 | date = date.addDays( 7 ); | 939 | date = date.addDays( 7 ); |
940 | } | 940 | } |
941 | updateView(); | 941 | updateView(); |
942 | } | 942 | } |
943 | 943 | ||
944 | void KOMonthView::showEvents(QPtrList<Event>) | 944 | void KOMonthView::showEvents(QPtrList<Event>) |
945 | { | 945 | { |
946 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 946 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
947 | } | 947 | } |
948 | 948 | ||
949 | void KOMonthView::changeEventDisplay(Event *, int) | 949 | void KOMonthView::changeEventDisplay(Event *, int) |
950 | { | 950 | { |
951 | // this should be re-written to be much more efficient, but this | 951 | // this should be re-written to be much more efficient, but this |
952 | // quick-and-dirty-hack gets the job done for right now. | 952 | // quick-and-dirty-hack gets the job done for right now. |
953 | updateView(); | 953 | updateView(); |
954 | } | 954 | } |
955 | 955 | ||
956 | void KOMonthView::updateView() | 956 | void KOMonthView::updateView() |
957 | { | 957 | { |
958 | 958 | ||
959 | if ( !updatePossible ) | 959 | if ( !updatePossible ) |
960 | return; | 960 | return; |
961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
962 | int i; | 962 | int i; |
963 | for( i = 0; i < mCells.count(); ++i ) { | 963 | for( i = 0; i < mCells.count(); ++i ) { |
964 | mCells[i]->updateCell(); | 964 | mCells[i]->updateCell(); |
965 | } | 965 | } |
966 | 966 | ||
967 | //qDebug("KOMonthView::updateView() "); | 967 | //qDebug("KOMonthView::updateView() "); |
968 | processSelectionChange(); | 968 | processSelectionChange(); |
969 | // qDebug("---------------------------------------------------------------------+ "); | 969 | // qDebug("---------------------------------------------------------------------+ "); |
970 | mCells[0]->setFocus(); | 970 | mCells[0]->setFocus(); |
971 | } | 971 | } |
972 | 972 | ||
973 | void KOMonthView::resizeEvent(QResizeEvent * e) | 973 | void KOMonthView::resizeEvent(QResizeEvent * e) |
974 | { | 974 | { |
975 | computeLayout(); | 975 | computeLayout(); |
976 | mCells[0]->setFocus(); | ||
976 | } | 977 | } |
977 | void KOMonthView::computeLayout() | 978 | void KOMonthView::computeLayout() |
978 | { | 979 | { |
979 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 980 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
980 | // note this only changes the text if the requested size crosses the | 981 | // note this only changes the text if the requested size crosses the |
981 | // threshold between big enough to support the full name and not big | 982 | // threshold between big enough to support the full name and not big |
982 | // enough. | 983 | // enough. |
983 | 984 | ||
984 | int daysToShow = 7; | 985 | int daysToShow = 7; |
985 | bool combinedSatSun = false; | 986 | bool combinedSatSun = false; |
986 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 987 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
987 | daysToShow = 6; | 988 | daysToShow = 6; |
988 | combinedSatSun = true; | 989 | combinedSatSun = true; |
989 | } | 990 | } |
990 | int tWid = topLevelWidget()->size().width(); | 991 | int tWid = topLevelWidget()->size().width(); |
991 | int tHei = topLevelWidget()->size().height(); | 992 | int tHei = topLevelWidget()->size().height(); |
992 | 993 | ||
993 | int wid = size().width();//e | 994 | int wid = size().width();//e |
994 | int hei = size().height()-1; | 995 | int hei = size().height()-1; |
995 | 996 | ||
996 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 997 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
997 | return; | 998 | return; |
998 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 999 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
999 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1000 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1000 | int weeklabelwid = fm.width( "888" ); | 1001 | int weeklabelwid = fm.width( "888" ); |
1001 | wid -= weeklabelwid; | 1002 | wid -= weeklabelwid; |
1002 | 1003 | ||
1003 | int colWid = wid / daysToShow; | 1004 | int colWid = wid / daysToShow; |
1004 | int lastCol = wid - ( colWid*6 ); | 1005 | int lastCol = wid - ( colWid*6 ); |
1005 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1006 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1006 | int cellHei = (hei - dayLabelHei) /6; | 1007 | int cellHei = (hei - dayLabelHei) /6; |
1007 | int colModulo = wid % daysToShow; | 1008 | int colModulo = wid % daysToShow; |
1008 | int rowModulo = (hei- dayLabelHei) % 6; | 1009 | int rowModulo = (hei- dayLabelHei) % 6; |
1009 | //qDebug("rowmod %d ", rowModulo); | 1010 | //qDebug("rowmod %d ", rowModulo); |
1010 | int i; | 1011 | int i; |
1011 | int x,y,w,h; | 1012 | int x,y,w,h; |
1012 | x= 0; | 1013 | x= 0; |
1013 | y= 0; | 1014 | y= 0; |
1014 | w = colWid; | 1015 | w = colWid; |
1015 | h = dayLabelHei ; | 1016 | h = dayLabelHei ; |
1016 | for ( i = 0; i < 7; i++) { | 1017 | for ( i = 0; i < 7; i++) { |
1017 | if ( i == daysToShow-colModulo ) | 1018 | if ( i == daysToShow-colModulo ) |
1018 | ++w; | 1019 | ++w; |
1019 | if ( combinedSatSun ) { | 1020 | if ( combinedSatSun ) { |
1020 | if ( i >= daysToShow-1 ) { | 1021 | if ( i >= daysToShow-1 ) { |
1021 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1022 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1022 | x -= w/2 ; | 1023 | x -= w/2 ; |
1023 | } | 1024 | } |
1024 | else | 1025 | else |
1025 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1026 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1026 | } else | 1027 | } else |
1027 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1028 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1028 | x += w; | 1029 | x += w; |
1029 | } | 1030 | } |
1030 | x= 0; | 1031 | x= 0; |
1031 | y= dayLabelHei; | 1032 | y= dayLabelHei; |
1032 | w = colWid; | 1033 | w = colWid; |
1033 | h = cellHei ; | 1034 | h = cellHei ; |
1034 | for ( i = 0; i < mCells.count(); ++i) { | 1035 | for ( i = 0; i < mCells.count(); ++i) { |
1035 | 1036 | ||
1036 | w = colWid; | 1037 | w = colWid; |
1037 | if ( ((i) % 7) >= 7-colModulo ) { | 1038 | if ( ((i) % 7) >= 7-colModulo ) { |
1038 | ++w; | 1039 | ++w; |
1039 | } | 1040 | } |
1040 | if ( i == (6-rowModulo)*7) | 1041 | if ( i == (6-rowModulo)*7) |
1041 | ++h; | 1042 | ++h; |
1042 | if ( combinedSatSun ) { | 1043 | if ( combinedSatSun ) { |
1043 | if ( (i)%7 >= daysToShow-1 ) { | 1044 | if ( (i)%7 >= daysToShow-1 ) { |
1044 | if ( (i)%7 == daysToShow-1 ) { | 1045 | if ( (i)%7 == daysToShow-1 ) { |
1045 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1046 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1046 | x -= w ;y += h/2; | 1047 | x -= w ;y += h/2; |
1047 | } else { | 1048 | } else { |
1048 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1049 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1049 | y -= h/2; | 1050 | y -= h/2; |
1050 | } | 1051 | } |
1051 | } else | 1052 | } else |
1052 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1053 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1053 | 1054 | ||
1054 | } | 1055 | } |
1055 | else | 1056 | else |
1056 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1057 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1057 | x += w; | 1058 | x += w; |
1058 | if ( x + w/2 > wid ) { | 1059 | if ( x + w/2 > wid ) { |
1059 | x = 0; | 1060 | x = 0; |
1060 | y += h; | 1061 | y += h; |
1061 | } | 1062 | } |
1062 | } | 1063 | } |
1063 | y= dayLabelHei; | 1064 | y= dayLabelHei; |
1064 | h = cellHei ; | 1065 | h = cellHei ; |
1065 | for ( i = 0; i < 6; i++) { | 1066 | for ( i = 0; i < 6; i++) { |
1066 | if ( i == (6-rowModulo)) | 1067 | if ( i == (6-rowModulo)) |
1067 | ++h; | 1068 | ++h; |
1068 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1069 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1069 | y += h; | 1070 | y += h; |
1070 | } | 1071 | } |
1071 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1072 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1072 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1073 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1073 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1074 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1074 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1075 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1075 | updateDayLabels(); | 1076 | updateDayLabels(); |
1076 | bool forceUpdate = !updatePossible; | 1077 | bool forceUpdate = !updatePossible; |
1077 | updatePossible = true; | 1078 | updatePossible = true; |
1078 | if ( forceUpdate ) | 1079 | if ( forceUpdate ) |
1079 | updateView(); | 1080 | updateView(); |
1080 | } | 1081 | } |
1081 | 1082 | ||
1082 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1083 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1083 | { | 1084 | { |
1084 | mContextMenu->showIncidencePopup(incidence); | 1085 | mContextMenu->showIncidencePopup(incidence); |
1085 | /* | 1086 | /* |
1086 | if( incidence && incidence->type() == "Event" ) { | 1087 | if( incidence && incidence->type() == "Event" ) { |
1087 | Event *event = static_cast<Event *>(incidence); | 1088 | Event *event = static_cast<Event *>(incidence); |
1088 | mContextMenu->showEventPopup(event); | 1089 | mContextMenu->showEventPopup(event); |
1089 | } else { | 1090 | } else { |
1090 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1091 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1091 | } | 1092 | } |
1092 | */ | 1093 | */ |
1093 | } | 1094 | } |
1094 | MonthViewCell * KOMonthView::selectedCell( ) | 1095 | MonthViewCell * KOMonthView::selectedCell( ) |
1095 | { | 1096 | { |
1096 | return mSelectedCell; | 1097 | return mSelectedCell; |
1097 | } | 1098 | } |
1098 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1099 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1099 | { | 1100 | { |
1100 | // qDebug("KOMonthView::setSelectedCell "); | 1101 | // qDebug("KOMonthView::setSelectedCell "); |
1101 | if ( mSelectedCell && mSelectedCell != cell ) { | 1102 | if ( mSelectedCell && mSelectedCell != cell ) { |
1102 | MonthViewCell * mvc = mSelectedCell; | 1103 | MonthViewCell * mvc = mSelectedCell; |
1103 | mSelectedCell = cell; | 1104 | mSelectedCell = cell; |
1104 | mvc->deselect(); | 1105 | mvc->deselect(); |
1105 | } else | 1106 | } else |
1106 | mSelectedCell = cell; | 1107 | mSelectedCell = cell; |
1107 | // if ( mSelectedCell ) | 1108 | // if ( mSelectedCell ) |
1108 | // mSelectedCell->select(); | 1109 | // mSelectedCell->select(); |
1109 | if ( !mSelectedCell ) | 1110 | if ( !mSelectedCell ) |
1110 | emit incidenceSelected( 0 ); | 1111 | emit incidenceSelected( 0 ); |
1111 | else | 1112 | else |
1112 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1113 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | void KOMonthView::processSelectionChange() | 1116 | void KOMonthView::processSelectionChange() |
1116 | { | 1117 | { |
1117 | QPtrList<Incidence> incidences = selectedIncidences(); | 1118 | QPtrList<Incidence> incidences = selectedIncidences(); |
1118 | if (incidences.count() > 0) { | 1119 | if (incidences.count() > 0) { |
1119 | emit incidenceSelected( incidences.first() ); | 1120 | emit incidenceSelected( incidences.first() ); |
1120 | } else { | 1121 | } else { |
1121 | emit incidenceSelected( 0 ); | 1122 | emit incidenceSelected( 0 ); |
1122 | } | 1123 | } |
1123 | } | 1124 | } |
1124 | 1125 | ||
1125 | void KOMonthView::clearSelection() | 1126 | void KOMonthView::clearSelection() |
1126 | { | 1127 | { |
1127 | if ( mSelectedCell ) { | 1128 | if ( mSelectedCell ) { |
1128 | mSelectedCell->deselect(); | 1129 | mSelectedCell->deselect(); |
1129 | mSelectedCell = 0; | 1130 | mSelectedCell = 0; |
1130 | } | 1131 | } |
1131 | } | 1132 | } |
1132 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1133 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1133 | { | 1134 | { |
1134 | //qDebug("KOMonthView::keyPressEvent "); | 1135 | //qDebug("KOMonthView::keyPressEvent "); |
1135 | switch(e->key()) { | 1136 | switch(e->key()) { |
1136 | case Key_Up: | 1137 | case Key_Up: |
1137 | { | 1138 | { |
1138 | emit prevMonth(); | 1139 | emit prevMonth(); |
1139 | mCells[0]->setFocus(); | 1140 | mCells[0]->setFocus(); |
1140 | } | 1141 | } |
1141 | e->accept(); | 1142 | e->accept(); |
1142 | break; | 1143 | break; |
1143 | case Key_Down: | 1144 | case Key_Down: |
1144 | { | 1145 | { |
1145 | emit nextMonth(); | 1146 | emit nextMonth(); |
1146 | mCells[0]->setFocus(); | 1147 | mCells[0]->setFocus(); |
1147 | 1148 | ||
1148 | } | 1149 | } |
1149 | e->accept(); | 1150 | e->accept(); |
1150 | break; | 1151 | break; |
1151 | default: | 1152 | default: |
1152 | e->ignore(); | 1153 | e->ignore(); |
1153 | break; | 1154 | break; |
1154 | } | 1155 | } |
1155 | } | 1156 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 8d8fc2a..82437d8 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1245 +1,1258 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | 27 | ||
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <kdebug.h> | 29 | #include <kdebug.h> |
30 | #include "koprefs.h" | 30 | #include "koprefs.h" |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/vcaldrag.h> | 37 | #include <libkcal/vcaldrag.h> |
38 | #include <libkcal/calfilter.h> | 38 | #include <libkcal/calfilter.h> |
39 | #include <libkcal/dndfactory.h> | 39 | #include <libkcal/dndfactory.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <kresources/resourceselectdialog.h> | 42 | #include <kresources/resourceselectdialog.h> |
43 | #ifndef DESKTOP_VERSION | 43 | #ifndef DESKTOP_VERSION |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #else | 45 | #else |
46 | #include <qapplication.h> | 46 | #include <qapplication.h> |
47 | #endif | 47 | #endif |
48 | #ifndef KORG_NOPRINTER | 48 | #ifndef KORG_NOPRINTER |
49 | #include "calprinter.h" | 49 | #include "calprinter.h" |
50 | #endif | 50 | #endif |
51 | #include "docprefs.h" | 51 | #include "docprefs.h" |
52 | 52 | ||
53 | #include "kotodoview.h" | 53 | #include "kotodoview.h" |
54 | using namespace KOrg; | 54 | using namespace KOrg; |
55 | 55 | ||
56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
57 | const char *name) : | 57 | const char *name) : |
58 | KListView(parent,name) | 58 | KListView(parent,name) |
59 | { | 59 | { |
60 | mName = QString ( name ); | 60 | mName = QString ( name ); |
61 | mCalendar = calendar; | 61 | mCalendar = calendar; |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
64 | #endif | 64 | #endif |
65 | mOldCurrent = 0; | 65 | mOldCurrent = 0; |
66 | mMousePressed = false; | 66 | mMousePressed = false; |
67 | 67 | ||
68 | setAcceptDrops(true); | 68 | setAcceptDrops(true); |
69 | viewport()->setAcceptDrops(true); | 69 | viewport()->setAcceptDrops(true); |
70 | int size = 16; | 70 | int size = 16; |
71 | if (qApp->desktop()->width() < 300 ) | 71 | if (qApp->desktop()->width() < 300 ) |
72 | size = 12; | 72 | size = 12; |
73 | setTreeStepSize( size + 6 ); | 73 | setTreeStepSize( size + 6 ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
78 | { | 78 | { |
79 | #ifndef KORG_NODND | 79 | #ifndef KORG_NODND |
80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
82 | !QTextDrag::canDecode( e ) ) { | 82 | !QTextDrag::canDecode( e ) ) { |
83 | e->ignore(); | 83 | e->ignore(); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | mOldCurrent = currentItem(); | 87 | mOldCurrent = currentItem(); |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
93 | { | 93 | { |
94 | #ifndef KORG_NODND | 94 | #ifndef KORG_NODND |
95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
96 | 96 | ||
97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
98 | !QTextDrag::canDecode( e ) ) { | 98 | !QTextDrag::canDecode( e ) ) { |
99 | e->ignore(); | 99 | e->ignore(); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | e->accept(); | 103 | e->accept(); |
104 | #endif | 104 | #endif |
105 | } | 105 | } |
106 | 106 | ||
107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
108 | { | 108 | { |
109 | #ifndef KORG_NODND | 109 | #ifndef KORG_NODND |
110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
111 | 111 | ||
112 | setCurrentItem(mOldCurrent); | 112 | setCurrentItem(mOldCurrent); |
113 | setSelected(mOldCurrent,true); | 113 | setSelected(mOldCurrent,true); |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
118 | { | 118 | { |
119 | #ifndef KORG_NODND | 119 | #ifndef KORG_NODND |
120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | Incidence *to = destinationEvent; | 142 | Incidence *to = destinationEvent; |
143 | while(to) { | 143 | while(to) { |
144 | if (to->uid() == todo->uid()) { | 144 | if (to->uid() == todo->uid()) { |
145 | KMessageBox::sorry(this, | 145 | KMessageBox::sorry(this, |
146 | i18n("Cannot move To-Do to itself\nor a child of itself"), | 146 | i18n("Cannot move To-Do to itself\nor a child of itself"), |
147 | i18n("Drop To-Do")); | 147 | i18n("Drop To-Do")); |
148 | delete todo; | 148 | delete todo; |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | to = to->relatedTo(); | 151 | to = to->relatedTo(); |
152 | } | 152 | } |
153 | internalDrop = true; | 153 | internalDrop = true; |
154 | if ( destinationEvent ) | 154 | if ( destinationEvent ) |
155 | reparentTodoSignal( destinationEvent, existingTodo ); | 155 | reparentTodoSignal( destinationEvent, existingTodo ); |
156 | else | 156 | else |
157 | unparentTodoSignal(existingTodo); | 157 | unparentTodoSignal(existingTodo); |
158 | delete todo; | 158 | delete todo; |
159 | } else { | 159 | } else { |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 161 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
162 | if ( destinationEvent ) | 162 | if ( destinationEvent ) |
163 | reparentTodoSignal( destinationEvent, todo ); | 163 | reparentTodoSignal( destinationEvent, todo ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | QString text; | 167 | QString text; |
168 | if (QTextDrag::decode(e,text)) { | 168 | if (QTextDrag::decode(e,text)) { |
169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
171 | qDebug("Dropped : " + text); | 171 | qDebug("Dropped : " + text); |
172 | QStringList emails = QStringList::split(",",text); | 172 | QStringList emails = QStringList::split(",",text); |
173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 183 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | #ifndef KORG_NODND | 192 | #ifndef KORG_NODND |
193 | QPoint p(contentsToViewport(e->pos())); | 193 | QPoint p(contentsToViewport(e->pos())); |
194 | QListViewItem *i = itemAt(p); | 194 | QListViewItem *i = itemAt(p); |
195 | mMousePressed = false; | 195 | mMousePressed = false; |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | QListView::contentsMousePressEvent(e); | 210 | QListView::contentsMousePressEvent(e); |
211 | } | 211 | } |
212 | 212 | ||
213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
214 | { | 214 | { |
215 | 215 | ||
216 | #ifndef KORG_NODND | 216 | #ifndef KORG_NODND |
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | DndFactory factory( mCalendar ); | 223 | DndFactory factory( mCalendar ); |
224 | ICalDrag *vd = factory.createDrag( | 224 | ICalDrag *vd = factory.createDrag( |
225 | ((KOTodoViewItem *)item)->todo(),viewport()); | 225 | ((KOTodoViewItem *)item)->todo(),viewport()); |
226 | internalDrop = false; | 226 | internalDrop = false; |
227 | // we cannot do any senseful here, because the DnD is still broken in Qt | 227 | // we cannot do any senseful here, because the DnD is still broken in Qt |
228 | if (vd->drag()) { | 228 | if (vd->drag()) { |
229 | if ( !internalDrop ) { | 229 | if ( !internalDrop ) { |
230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
231 | qDebug("Dnd: External move: Delete drag source "); | 231 | qDebug("Dnd: External move: Delete drag source "); |
232 | } else | 232 | } else |
233 | qDebug("Dnd: Internal move "); | 233 | qDebug("Dnd: Internal move "); |
234 | 234 | ||
235 | } else { | 235 | } else { |
236 | if ( !internalDrop ) { | 236 | if ( !internalDrop ) { |
237 | qDebug("Dnd: External Copy"); | 237 | qDebug("Dnd: External Copy"); |
238 | } else | 238 | } else |
239 | qDebug("DnD: Internal copy: Copy pending"); | 239 | qDebug("DnD: Internal copy: Copy pending"); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | #endif | 243 | #endif |
244 | } | 244 | } |
245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
246 | { | 246 | { |
247 | 247 | ||
248 | QListViewItem* cn; | 248 | QListViewItem* cn; |
249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
250 | cn = currentItem(); | 250 | cn = currentItem(); |
251 | if ( cn ) { | 251 | if ( cn ) { |
252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
253 | if ( ci ){ | 253 | if ( ci ){ |
254 | if ( e->state() == ShiftButton ) | 254 | if ( e->state() == ShiftButton ) |
255 | ci->setOn( false ); | 255 | ci->setOn( false ); |
256 | else | 256 | else |
257 | ci->setOn( true ); | 257 | ci->setOn( true ); |
258 | cn = cn->itemBelow(); | 258 | cn = cn->itemBelow(); |
259 | if ( cn ) { | 259 | if ( cn ) { |
260 | setCurrentItem ( cn ); | 260 | setCurrentItem ( cn ); |
261 | ensureItemVisible ( cn ); | 261 | ensureItemVisible ( cn ); |
262 | } | 262 | } |
263 | 263 | ||
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | 269 | ||
270 | // qDebug("KOTodoListView::keyPressEvent "); | 270 | // qDebug("KOTodoListView::keyPressEvent "); |
271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
272 | switch ( e->key() ) { | 272 | switch ( e->key() ) { |
273 | case Qt::Key_Down: | 273 | case Qt::Key_Down: |
274 | case Qt::Key_Up: | 274 | case Qt::Key_Up: |
275 | QListView::keyPressEvent ( e ); | 275 | QListView::keyPressEvent ( e ); |
276 | break; | 276 | break; |
277 | case Qt::Key_Left: | 277 | case Qt::Key_Left: |
278 | case Qt::Key_Right: | 278 | case Qt::Key_Right: |
279 | QListView::keyPressEvent ( e ); | 279 | QListView::keyPressEvent ( e ); |
280 | e->accept(); | 280 | e->accept(); |
281 | return; | 281 | return; |
282 | break; | 282 | break; |
283 | default: | 283 | default: |
284 | e->ignore(); | 284 | e->ignore(); |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | e->ignore(); | 289 | e->ignore(); |
290 | } | 290 | } |
291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
292 | { | 292 | { |
293 | QListView::contentsMouseReleaseEvent(e); | 293 | QListView::contentsMouseReleaseEvent(e); |
294 | mMousePressed = false; | 294 | mMousePressed = false; |
295 | } | 295 | } |
296 | 296 | ||
297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
298 | { | 298 | { |
299 | if (!e) return; | 299 | if (!e) return; |
300 | 300 | ||
301 | QPoint vp = contentsToViewport(e->pos()); | 301 | QPoint vp = contentsToViewport(e->pos()); |
302 | 302 | ||
303 | QListViewItem *item = itemAt(vp); | 303 | QListViewItem *item = itemAt(vp); |
304 | 304 | ||
305 | emit double_Clicked(item); | 305 | emit double_Clicked(item); |
306 | if (!item) return; | 306 | if (!item) return; |
307 | 307 | ||
308 | emit doubleClicked(item,vp,0); | 308 | emit doubleClicked(item,vp,0); |
309 | } | 309 | } |
310 | 310 | ||
311 | ///////////////////////////////////////////////////////////////////////////// | 311 | ///////////////////////////////////////////////////////////////////////////// |
312 | 312 | ||
313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
314 | QLineEdit(parent) | 314 | QLineEdit(parent) |
315 | { | 315 | { |
316 | setText(i18n("Click to add a new Todo")); | 316 | setText(i18n("Click to add a new Todo")); |
317 | } | 317 | } |
318 | 318 | ||
319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
320 | { | 320 | { |
321 | if ( text()==i18n("Click to add a new Todo") ) | 321 | if ( text()==i18n("Click to add a new Todo") ) |
322 | setText(""); | 322 | setText(""); |
323 | QLineEdit::focusInEvent(ev); | 323 | QLineEdit::focusInEvent(ev); |
324 | } | 324 | } |
325 | 325 | ||
326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
327 | { | 327 | { |
328 | setText(i18n("Click to add a new Todo")); | 328 | setText(i18n("Click to add a new Todo")); |
329 | QLineEdit::focusOutEvent(ev); | 329 | QLineEdit::focusOutEvent(ev); |
330 | } | 330 | } |
331 | 331 | ||
332 | ///////////////////////////////////////////////////////////////////////////// | 332 | ///////////////////////////////////////////////////////////////////////////// |
333 | 333 | ||
334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
335 | KOrg::BaseView(calendar,parent,name) | 335 | KOrg::BaseView(calendar,parent,name) |
336 | { | 336 | { |
337 | mPendingUpdateBeforeRepaint = false; | ||
337 | isFlatDisplay = false; | 338 | isFlatDisplay = false; |
338 | mNavigator = 0; | 339 | mNavigator = 0; |
339 | QBoxLayout *topLayout = new QVBoxLayout(this); | 340 | QBoxLayout *topLayout = new QVBoxLayout(this); |
340 | mName = QString ( name ); | 341 | mName = QString ( name ); |
341 | mBlockUpdate = false; | 342 | mBlockUpdate = false; |
342 | mQuickAdd = new KOQuickTodo(this); | 343 | mQuickAdd = new KOQuickTodo(this); |
343 | topLayout->addWidget(mQuickAdd); | 344 | topLayout->addWidget(mQuickAdd); |
344 | 345 | ||
345 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 346 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
346 | 347 | ||
347 | mTodoListView = new KOTodoListView(calendar,this, name ); | 348 | mTodoListView = new KOTodoListView(calendar,this, name ); |
348 | topLayout->addWidget(mTodoListView); | 349 | topLayout->addWidget(mTodoListView); |
349 | //mTodoListView->header()->setMaximumHeight(30); | 350 | //mTodoListView->header()->setMaximumHeight(30); |
350 | mTodoListView->setRootIsDecorated(true); | 351 | mTodoListView->setRootIsDecorated(true); |
351 | mTodoListView->setAllColumnsShowFocus(true); | 352 | mTodoListView->setAllColumnsShowFocus(true); |
352 | 353 | ||
353 | mTodoListView->setShowSortIndicator(true); | 354 | mTodoListView->setShowSortIndicator(true); |
354 | 355 | ||
355 | mTodoListView->addColumn(i18n("Todo")); | 356 | mTodoListView->addColumn(i18n("Todo")); |
356 | mTodoListView->addColumn(i18n("Prio")); | 357 | mTodoListView->addColumn(i18n("Prio")); |
357 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 358 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
358 | mTodoListView->addColumn(i18n("Complete")); | 359 | mTodoListView->addColumn(i18n("Complete")); |
359 | mTodoListView->setColumnAlignment(2,AlignCenter); | 360 | mTodoListView->setColumnAlignment(2,AlignCenter); |
360 | 361 | ||
361 | mTodoListView->addColumn(i18n("Due Date")); | 362 | mTodoListView->addColumn(i18n("Due Date")); |
362 | mTodoListView->setColumnAlignment(3,AlignLeft); | 363 | mTodoListView->setColumnAlignment(3,AlignLeft); |
363 | mTodoListView->addColumn(i18n("Due Time")); | 364 | mTodoListView->addColumn(i18n("Due Time")); |
364 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 365 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
365 | 366 | ||
366 | mTodoListView->addColumn(i18n("Start Date")); | 367 | mTodoListView->addColumn(i18n("Start Date")); |
367 | mTodoListView->setColumnAlignment(5,AlignLeft); | 368 | mTodoListView->setColumnAlignment(5,AlignLeft); |
368 | mTodoListView->addColumn(i18n("Start Time")); | 369 | mTodoListView->addColumn(i18n("Start Time")); |
369 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 370 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
370 | 371 | ||
371 | mTodoListView->addColumn(i18n("Cancelled")); | 372 | mTodoListView->addColumn(i18n("Cancelled")); |
372 | mTodoListView->addColumn(i18n("Categories")); | 373 | mTodoListView->addColumn(i18n("Categories")); |
373 | #if 0 | 374 | #if 0 |
374 | mTodoListView->addColumn(i18n("Sort Id")); | 375 | mTodoListView->addColumn(i18n("Sort Id")); |
375 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 376 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
376 | #endif | 377 | #endif |
377 | 378 | ||
378 | mTodoListView->setMinimumHeight( 60 ); | 379 | mTodoListView->setMinimumHeight( 60 ); |
379 | mTodoListView->setItemsRenameable( true ); | 380 | mTodoListView->setItemsRenameable( true ); |
380 | mTodoListView->setRenameable( 0 ); | 381 | mTodoListView->setRenameable( 0 ); |
381 | mTodoListView->setColumnWidth( 0, 120 ); | 382 | mTodoListView->setColumnWidth( 0, 120 ); |
382 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 383 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
383 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 384 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
384 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 385 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
385 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 386 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
386 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 387 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
387 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 388 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
388 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 389 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
389 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 390 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
390 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 391 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
391 | 392 | ||
392 | 393 | ||
393 | mPriorityPopupMenu = new QPopupMenu(this); | 394 | mPriorityPopupMenu = new QPopupMenu(this); |
394 | for (int i = 1; i <= 5; i++) { | 395 | for (int i = 1; i <= 5; i++) { |
395 | QString label = QString ("%1").arg (i); | 396 | QString label = QString ("%1").arg (i); |
396 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 397 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
397 | } | 398 | } |
398 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 399 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
399 | 400 | ||
400 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 401 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
401 | for (int i = 0; i <= 100; i+=20) { | 402 | for (int i = 0; i <= 100; i+=20) { |
402 | QString label = QString ("%1 %").arg (i); | 403 | QString label = QString ("%1 %").arg (i); |
403 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 404 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
404 | } | 405 | } |
405 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 406 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
406 | 407 | ||
407 | 408 | ||
408 | 409 | ||
409 | mItemPopupMenu = new QPopupMenu(this); | 410 | mItemPopupMenu = new QPopupMenu(this); |
410 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 411 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
411 | SLOT (showTodo())); | 412 | SLOT (showTodo())); |
412 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 413 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
413 | SLOT (editTodo())); | 414 | SLOT (editTodo())); |
414 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 415 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
415 | SLOT (deleteTodo())); | 416 | SLOT (deleteTodo())); |
416 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 417 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
417 | SLOT (cloneTodo())); | 418 | SLOT (cloneTodo())); |
418 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 419 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
419 | SLOT (moveTodo())); | 420 | SLOT (moveTodo())); |
420 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 421 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
421 | SLOT (beamTodo())); | 422 | SLOT (beamTodo())); |
422 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 423 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
423 | SLOT (cancelTodo())); | 424 | SLOT (cancelTodo())); |
424 | mItemPopupMenu->insertSeparator(); | 425 | mItemPopupMenu->insertSeparator(); |
425 | 426 | ||
426 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 427 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
427 | SLOT (newTodo())); | 428 | SLOT (newTodo())); |
428 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 429 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
429 | SLOT (newSubTodo())); | 430 | SLOT (newSubTodo())); |
430 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 431 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
431 | SLOT (unparentTodo()),0,21); | 432 | SLOT (unparentTodo()),0,21); |
432 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 433 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
433 | SLOT (reparentTodo()),0,22); | 434 | SLOT (reparentTodo()),0,22); |
434 | mItemPopupMenu->insertSeparator(); | 435 | mItemPopupMenu->insertSeparator(); |
435 | #if 0 | 436 | #if 0 |
436 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 437 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
437 | this, SLOT( purgeCompleted() ) ); | 438 | this, SLOT( purgeCompleted() ) ); |
438 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 439 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
439 | this, SLOT( toggleCompleted() ),0, 33 ); | 440 | this, SLOT( toggleCompleted() ),0, 33 ); |
440 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 441 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
441 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 442 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
442 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 443 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
443 | this, SLOT( toggleRunning() ),0, 35 ); | 444 | this, SLOT( toggleRunning() ),0, 35 ); |
444 | 445 | ||
445 | #endif | 446 | #endif |
446 | mPopupMenu = new QPopupMenu(this); | 447 | mPopupMenu = new QPopupMenu(this); |
447 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 448 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
448 | SLOT (newTodo()),0,1); | 449 | SLOT (newTodo()),0,1); |
449 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 450 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
450 | this, SLOT(purgeCompleted()),0,2); | 451 | this, SLOT(purgeCompleted()),0,2); |
451 | mPopupMenu->insertItem(i18n("Show Completed"), | 452 | mPopupMenu->insertItem(i18n("Show Completed"), |
452 | this, SLOT( toggleCompleted() ),0,3 ); | 453 | this, SLOT( toggleCompleted() ),0,3 ); |
453 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 454 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
454 | this, SLOT( toggleQuickTodo() ),0,4 ); | 455 | this, SLOT( toggleQuickTodo() ),0,4 ); |
455 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 456 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
456 | this, SLOT( toggleRunning() ),0,5 ); | 457 | this, SLOT( toggleRunning() ),0,5 ); |
457 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 458 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
458 | this, SLOT( setAllOpen() ),0,6 ); | 459 | this, SLOT( setAllOpen() ),0,6 ); |
459 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 460 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
460 | this, SLOT( setAllClose() ),0,7 ); | 461 | this, SLOT( setAllClose() ),0,7 ); |
461 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 462 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
462 | this, SLOT( setAllFlat() ),0,8 ); | 463 | this, SLOT( setAllFlat() ),0,8 ); |
463 | mDocPrefs = new DocPrefs( name ); | 464 | mDocPrefs = new DocPrefs( name ); |
464 | 465 | ||
465 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 466 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
466 | mPopupMenu->setCheckable( true ); | 467 | mPopupMenu->setCheckable( true ); |
467 | mItemPopupMenu->setCheckable( true ); | 468 | mItemPopupMenu->setCheckable( true ); |
468 | 469 | ||
469 | 470 | ||
470 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 471 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
471 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 472 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
472 | 473 | ||
473 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 474 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
474 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 475 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
475 | 476 | ||
476 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 477 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
477 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 478 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
478 | 479 | ||
479 | 480 | ||
480 | // Double clicking conflicts with opening/closing the subtree | 481 | // Double clicking conflicts with opening/closing the subtree |
481 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 482 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
482 | SLOT( editItem( QListViewItem *) ) ); | 483 | SLOT( editItem( QListViewItem *) ) ); |
483 | /* | 484 | /* |
484 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 485 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
485 | const QPoint &,int ) ), | 486 | const QPoint &,int ) ), |
486 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 487 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
487 | */ | 488 | */ |
488 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 489 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
489 | const QPoint &,int ) ), | 490 | const QPoint &,int ) ), |
490 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 491 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
491 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 492 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
492 | SLOT( itemClicked( QListViewItem * ) ) ); | 493 | SLOT( itemClicked( QListViewItem * ) ) ); |
493 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 494 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
494 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 495 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
495 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 496 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
496 | SLOT( updateView() ) ); | 497 | SLOT( updateView() ) ); |
497 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 498 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
498 | SLOT( todoModified(Todo *, int) ) ); | 499 | SLOT( todoModified(Todo *, int) ) ); |
499 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 500 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
500 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 501 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
501 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 502 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
502 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 503 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
503 | 504 | ||
504 | #if 0 | 505 | #if 0 |
505 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 506 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
506 | SLOT(selectionChanged(QListViewItem *))); | 507 | SLOT(selectionChanged(QListViewItem *))); |
507 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 508 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
508 | SLOT(selectionChanged(QListViewItem *))); | 509 | SLOT(selectionChanged(QListViewItem *))); |
509 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 510 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
510 | SLOT(selectionChanged(QListViewItem *))); | 511 | SLOT(selectionChanged(QListViewItem *))); |
511 | #endif | 512 | #endif |
512 | 513 | ||
513 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 514 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
514 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 515 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
515 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 516 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
516 | 517 | ||
517 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 518 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
518 | SLOT( processSelectionChange() ) ); | 519 | SLOT( processSelectionChange() ) ); |
519 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 520 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
520 | SLOT( addQuickTodo() ) ); | 521 | SLOT( addQuickTodo() ) ); |
521 | 522 | ||
522 | } | 523 | } |
523 | 524 | ||
524 | KOTodoView::~KOTodoView() | 525 | KOTodoView::~KOTodoView() |
525 | { | 526 | { |
526 | delete mDocPrefs; | 527 | delete mDocPrefs; |
527 | } | 528 | } |
528 | 529 | ||
529 | void KOTodoView::jumpToDate () | 530 | void KOTodoView::jumpToDate () |
530 | { | 531 | { |
531 | // if (mActiveItem) { | 532 | // if (mActiveItem) { |
532 | // mActiveItem->todo()); | 533 | // mActiveItem->todo()); |
533 | // if ( mActiveItem->todo()->hasDueDate() ) | 534 | // if ( mActiveItem->todo()->hasDueDate() ) |
534 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 535 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
535 | } | 536 | } |
536 | 537 | void KOTodoView::paintEvent(QPaintEvent * pevent) | |
538 | { | ||
539 | if ( mPendingUpdateBeforeRepaint ) { | ||
540 | updateView(); | ||
541 | mPendingUpdateBeforeRepaint = false; | ||
542 | } | ||
543 | KOrg::BaseView::paintEvent( pevent); | ||
544 | } | ||
545 | bool mPendingUpdateBeforeRepaint; | ||
537 | void KOTodoView::updateView() | 546 | void KOTodoView::updateView() |
538 | { | 547 | { |
539 | pendingSubtodo = 0; | 548 | pendingSubtodo = 0; |
540 | if ( mBlockUpdate ) { | 549 | if ( mBlockUpdate ) { |
541 | //qDebug("blocked "); | ||
542 | return; | 550 | return; |
543 | } | 551 | } |
552 | if ( !isVisible() ) { | ||
553 | mPendingUpdateBeforeRepaint = true; | ||
554 | return; | ||
555 | } | ||
556 | //qDebug("KOTodoView::updateView() %x", this); | ||
544 | if ( isFlatDisplay ) { | 557 | if ( isFlatDisplay ) { |
545 | setAllFlat(); | 558 | setAllFlat(); |
546 | return; | 559 | return; |
547 | } | 560 | } |
548 | //qDebug("update "); | 561 | //qDebug("update "); |
549 | // kdDebug() << "KOTodoView::updateView()" << endl; | 562 | // kdDebug() << "KOTodoView::updateView()" << endl; |
550 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 563 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
551 | mTodoListView->clear(); | 564 | mTodoListView->clear(); |
552 | if ( mName == "todolistsmall" ) { | 565 | if ( mName == "todolistsmall" ) { |
553 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 566 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
554 | int ps = fo.pointSize() -2; | 567 | int ps = fo.pointSize() -2; |
555 | if ( ps > 12 ) | 568 | if ( ps > 12 ) |
556 | ps -= 2; | 569 | ps -= 2; |
557 | fo.setPointSize( ps ); | 570 | fo.setPointSize( ps ); |
558 | } | 571 | } |
559 | } | 572 | } |
560 | 573 | ||
561 | mTodoListView->setFont( fo ); | 574 | mTodoListView->setFont( fo ); |
562 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 575 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
563 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 576 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
564 | QPtrList<Todo> todoList = calendar()->todos(); | 577 | QPtrList<Todo> todoList = calendar()->todos(); |
565 | 578 | ||
566 | /* | 579 | /* |
567 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 580 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
568 | Event *t; | 581 | Event *t; |
569 | for(t = todoList.first(); t; t = todoList.next()) { | 582 | for(t = todoList.first(); t; t = todoList.next()) { |
570 | kdDebug() << " " << t->getSummary() << endl; | 583 | kdDebug() << " " << t->getSummary() << endl; |
571 | 584 | ||
572 | if (t->getRelatedTo()) { | 585 | if (t->getRelatedTo()) { |
573 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 586 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
574 | } | 587 | } |
575 | 588 | ||
576 | QPtrList<Event> l = t->getRelations(); | 589 | QPtrList<Event> l = t->getRelations(); |
577 | Event *c; | 590 | Event *c; |
578 | for(c=l.first();c;c=l.next()) { | 591 | for(c=l.first();c;c=l.next()) { |
579 | kdDebug() << " - relation: " << c->getSummary() << endl; | 592 | kdDebug() << " - relation: " << c->getSummary() << endl; |
580 | } | 593 | } |
581 | } | 594 | } |
582 | */ | 595 | */ |
583 | 596 | ||
584 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 597 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
585 | // specific order of events. That means that we have to generate parent items | 598 | // specific order of events. That means that we have to generate parent items |
586 | // recursively for proper hierarchical display of Todos. | 599 | // recursively for proper hierarchical display of Todos. |
587 | mTodoMap.clear(); | 600 | mTodoMap.clear(); |
588 | Todo *todo; | 601 | Todo *todo; |
589 | todo = todoList.first();// todo; todo = todoList.next()) { | 602 | todo = todoList.first();// todo; todo = todoList.next()) { |
590 | while ( todo ) { | 603 | while ( todo ) { |
591 | bool next = true; | 604 | bool next = true; |
592 | // qDebug("todo %s ", todo->summary().latin1()); | 605 | // qDebug("todo %s ", todo->summary().latin1()); |
593 | Incidence *incidence = todo->relatedTo(); | 606 | Incidence *incidence = todo->relatedTo(); |
594 | while ( incidence ) { | 607 | while ( incidence ) { |
595 | if ( incidence->type() == "Todo") { | 608 | if ( incidence->type() == "Todo") { |
596 | //qDebug("related %s ",incidence->summary().latin1() ); | 609 | //qDebug("related %s ",incidence->summary().latin1() ); |
597 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 610 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
598 | //qDebug("related not found "); | 611 | //qDebug("related not found "); |
599 | todoList.remove( ); | 612 | todoList.remove( ); |
600 | todo = todoList.current(); | 613 | todo = todoList.current(); |
601 | next = false; | 614 | next = false; |
602 | incidence = 0; | 615 | incidence = 0; |
603 | 616 | ||
604 | } else { | 617 | } else { |
605 | //qDebug("related found "); | 618 | //qDebug("related found "); |
606 | incidence = incidence->relatedTo(); | 619 | incidence = incidence->relatedTo(); |
607 | } | 620 | } |
608 | } else | 621 | } else |
609 | incidence = 0; | 622 | incidence = 0; |
610 | } | 623 | } |
611 | if ( next ) | 624 | if ( next ) |
612 | todo = todoList.next(); | 625 | todo = todoList.next(); |
613 | } | 626 | } |
614 | // qDebug("again .... "); | 627 | // qDebug("again .... "); |
615 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 628 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
616 | 629 | ||
617 | // qDebug("yytodo %s ", todo->summary().latin1()); | 630 | // qDebug("yytodo %s ", todo->summary().latin1()); |
618 | // } | 631 | // } |
619 | //qDebug("for "); | 632 | //qDebug("for "); |
620 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 633 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
621 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 634 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
622 | { | 635 | { |
623 | insertTodoItem(todo); | 636 | insertTodoItem(todo); |
624 | } | 637 | } |
625 | } | 638 | } |
626 | //qDebug("for end "); | 639 | //qDebug("for end "); |
627 | // Restore opened/closed state | 640 | // Restore opened/closed state |
628 | mTodoListView->blockSignals( true ); | 641 | mTodoListView->blockSignals( true ); |
629 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 642 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
630 | mTodoListView->blockSignals( false ); | 643 | mTodoListView->blockSignals( false ); |
631 | mTodoListView->setFocus(); | 644 | mTodoListView->setFocus(); |
632 | processSelectionChange(); | 645 | processSelectionChange(); |
633 | } | 646 | } |
634 | 647 | ||
635 | bool KOTodoView::checkTodo( Todo * todo ) | 648 | bool KOTodoView::checkTodo( Todo * todo ) |
636 | { | 649 | { |
637 | 650 | ||
638 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 651 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
639 | return false; | 652 | return false; |
640 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 653 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
641 | if ( todo->hasStartDate() ) | 654 | if ( todo->hasStartDate() ) |
642 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 655 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
643 | return false; | 656 | return false; |
644 | if ( todo->hasDueDate() ) | 657 | if ( todo->hasDueDate() ) |
645 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 658 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
646 | return false; | 659 | return false; |
647 | } | 660 | } |
648 | return true; | 661 | return true; |
649 | } | 662 | } |
650 | 663 | ||
651 | void KOTodoView::restoreItemState( QListViewItem *item ) | 664 | void KOTodoView::restoreItemState( QListViewItem *item ) |
652 | { | 665 | { |
653 | pendingSubtodo = 0; | 666 | pendingSubtodo = 0; |
654 | while( item ) { | 667 | while( item ) { |
655 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 668 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
656 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 669 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
657 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 670 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
658 | item = item->nextSibling(); | 671 | item = item->nextSibling(); |
659 | } | 672 | } |
660 | } | 673 | } |
661 | 674 | ||
662 | 675 | ||
663 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
664 | KOTodoView::insertTodoItem(Todo *todo) | 677 | KOTodoView::insertTodoItem(Todo *todo) |
665 | { | 678 | { |
666 | 679 | ||
667 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 680 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
668 | // TODO: Check, if dynmaic cast is necessary | 681 | // TODO: Check, if dynmaic cast is necessary |
669 | 682 | ||
670 | pendingSubtodo = 0; | 683 | pendingSubtodo = 0; |
671 | Incidence *incidence = todo->relatedTo(); | 684 | Incidence *incidence = todo->relatedTo(); |
672 | if (incidence && incidence->type() == "Todo") { | 685 | if (incidence && incidence->type() == "Todo") { |
673 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 686 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
674 | 687 | ||
675 | // kdDebug() << " has Related" << endl; | 688 | // kdDebug() << " has Related" << endl; |
676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 689 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
677 | itemIterator = mTodoMap.find(relatedTodo); | 690 | itemIterator = mTodoMap.find(relatedTodo); |
678 | if (itemIterator == mTodoMap.end()) { | 691 | if (itemIterator == mTodoMap.end()) { |
679 | // kdDebug() << " related not yet in list" << endl; | 692 | // kdDebug() << " related not yet in list" << endl; |
680 | itemIterator = insertTodoItem (relatedTodo); | 693 | itemIterator = insertTodoItem (relatedTodo); |
681 | } | 694 | } |
682 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 695 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
683 | // and one into the map. Sure finding is more easy but why? -zecke | 696 | // and one into the map. Sure finding is more easy but why? -zecke |
684 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 697 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
685 | return mTodoMap.insert(todo,todoItem); | 698 | return mTodoMap.insert(todo,todoItem); |
686 | } else { | 699 | } else { |
687 | // kdDebug() << " no Related" << endl; | 700 | // kdDebug() << " no Related" << endl; |
688 | // see above -zecke | 701 | // see above -zecke |
689 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 702 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
690 | return mTodoMap.insert(todo,todoItem); | 703 | return mTodoMap.insert(todo,todoItem); |
691 | } | 704 | } |
692 | } | 705 | } |
693 | 706 | ||
694 | 707 | ||
695 | void KOTodoView::updateConfig() | 708 | void KOTodoView::updateConfig() |
696 | { | 709 | { |
697 | updateView(); | 710 | updateView(); |
698 | mTodoListView->repaintContents(); | 711 | mTodoListView->repaintContents(); |
699 | } | 712 | } |
700 | 713 | ||
701 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 714 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
702 | { | 715 | { |
703 | QPtrList<Incidence> selected; | 716 | QPtrList<Incidence> selected; |
704 | 717 | ||
705 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 718 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
706 | // if (!item) item = mActiveItem; | 719 | // if (!item) item = mActiveItem; |
707 | if (item) selected.append(item->todo()); | 720 | if (item) selected.append(item->todo()); |
708 | 721 | ||
709 | return selected; | 722 | return selected; |
710 | } | 723 | } |
711 | 724 | ||
712 | QPtrList<Todo> KOTodoView::selectedTodos() | 725 | QPtrList<Todo> KOTodoView::selectedTodos() |
713 | { | 726 | { |
714 | QPtrList<Todo> selected; | 727 | QPtrList<Todo> selected; |
715 | 728 | ||
716 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 729 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
717 | // if (!item) item = mActiveItem; | 730 | // if (!item) item = mActiveItem; |
718 | if (item) selected.append(item->todo()); | 731 | if (item) selected.append(item->todo()); |
719 | 732 | ||
720 | return selected; | 733 | return selected; |
721 | } | 734 | } |
722 | 735 | ||
723 | void KOTodoView::changeEventDisplay(Event *, int) | 736 | void KOTodoView::changeEventDisplay(Event *, int) |
724 | { | 737 | { |
725 | updateView(); | 738 | updateView(); |
726 | } | 739 | } |
727 | 740 | ||
728 | void KOTodoView::showDates(const QDate &, const QDate &) | 741 | void KOTodoView::showDates(const QDate &, const QDate &) |
729 | { | 742 | { |
730 | } | 743 | } |
731 | 744 | ||
732 | void KOTodoView::showEvents(QPtrList<Event>) | 745 | void KOTodoView::showEvents(QPtrList<Event>) |
733 | { | 746 | { |
734 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 747 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
735 | } | 748 | } |
736 | 749 | ||
737 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 750 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
738 | const QDate &td) | 751 | const QDate &td) |
739 | { | 752 | { |
740 | #ifndef KORG_NOPRINTER | 753 | #ifndef KORG_NOPRINTER |
741 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 754 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
742 | #endif | 755 | #endif |
743 | } | 756 | } |
744 | 757 | ||
745 | void KOTodoView::editItem(QListViewItem *item ) | 758 | void KOTodoView::editItem(QListViewItem *item ) |
746 | { | 759 | { |
747 | // qDebug("editItem(QListViewItem *item ) "); | 760 | // qDebug("editItem(QListViewItem *item ) "); |
748 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 761 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
749 | } | 762 | } |
750 | 763 | ||
751 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 764 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
752 | { | 765 | { |
753 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 766 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
754 | } | 767 | } |
755 | 768 | ||
756 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 769 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
757 | { | 770 | { |
758 | pendingSubtodo = 0; | 771 | pendingSubtodo = 0; |
759 | mActiveItem = (KOTodoViewItem *)item; | 772 | mActiveItem = (KOTodoViewItem *)item; |
760 | if (item) { | 773 | if (item) { |
761 | switch (column){ | 774 | switch (column){ |
762 | case 1: | 775 | case 1: |
763 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 776 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
764 | case 2: | 777 | case 2: |
765 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 778 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
766 | case 3: | 779 | case 3: |
767 | moveTodo(); | 780 | moveTodo(); |
768 | break; | 781 | break; |
769 | case 8: | 782 | case 8: |
770 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 783 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
771 | default: | 784 | default: |
772 | mItemPopupMenu->popup(QCursor::pos()); | 785 | mItemPopupMenu->popup(QCursor::pos()); |
773 | } | 786 | } |
774 | } else mPopupMenu->popup(QCursor::pos()); | 787 | } else mPopupMenu->popup(QCursor::pos()); |
775 | } | 788 | } |
776 | void KOTodoView::newTodo() | 789 | void KOTodoView::newTodo() |
777 | { | 790 | { |
778 | emit newTodoSignal(); | 791 | emit newTodoSignal(); |
779 | } | 792 | } |
780 | 793 | ||
781 | void KOTodoView::newSubTodo() | 794 | void KOTodoView::newSubTodo() |
782 | { | 795 | { |
783 | if (mActiveItem) { | 796 | if (mActiveItem) { |
784 | emit newSubTodoSignal(mActiveItem->todo()); | 797 | emit newSubTodoSignal(mActiveItem->todo()); |
785 | } | 798 | } |
786 | } | 799 | } |
787 | void KOTodoView::unparentTodo() | 800 | void KOTodoView::unparentTodo() |
788 | { | 801 | { |
789 | if (mActiveItem) { | 802 | if (mActiveItem) { |
790 | emit unparentTodoSignal(mActiveItem->todo()); | 803 | emit unparentTodoSignal(mActiveItem->todo()); |
791 | } | 804 | } |
792 | } | 805 | } |
793 | 806 | ||
794 | void KOTodoView::reparentTodo() | 807 | void KOTodoView::reparentTodo() |
795 | { | 808 | { |
796 | if (mActiveItem) { | 809 | if (mActiveItem) { |
797 | qDebug("KOTodoView::reparentTodo() "); | 810 | qDebug("KOTodoView::reparentTodo() "); |
798 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 811 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
799 | pendingSubtodo = mActiveItem; | 812 | pendingSubtodo = mActiveItem; |
800 | } | 813 | } |
801 | } | 814 | } |
802 | void KOTodoView::editTodo() | 815 | void KOTodoView::editTodo() |
803 | { | 816 | { |
804 | if (mActiveItem) { | 817 | if (mActiveItem) { |
805 | emit editTodoSignal(mActiveItem->todo()); | 818 | emit editTodoSignal(mActiveItem->todo()); |
806 | } | 819 | } |
807 | } | 820 | } |
808 | void KOTodoView::cloneTodo() | 821 | void KOTodoView::cloneTodo() |
809 | { | 822 | { |
810 | if (mActiveItem) { | 823 | if (mActiveItem) { |
811 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 824 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
812 | } | 825 | } |
813 | } | 826 | } |
814 | void KOTodoView::cancelTodo() | 827 | void KOTodoView::cancelTodo() |
815 | { | 828 | { |
816 | if (mActiveItem) { | 829 | if (mActiveItem) { |
817 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 830 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
818 | } | 831 | } |
819 | } | 832 | } |
820 | void KOTodoView::moveTodo() | 833 | void KOTodoView::moveTodo() |
821 | { | 834 | { |
822 | if (mActiveItem) { | 835 | if (mActiveItem) { |
823 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 836 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
824 | } | 837 | } |
825 | } | 838 | } |
826 | void KOTodoView::beamTodo() | 839 | void KOTodoView::beamTodo() |
827 | { | 840 | { |
828 | if (mActiveItem) { | 841 | if (mActiveItem) { |
829 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 842 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
830 | } | 843 | } |
831 | } | 844 | } |
832 | 845 | ||
833 | 846 | ||
834 | void KOTodoView::showTodo() | 847 | void KOTodoView::showTodo() |
835 | { | 848 | { |
836 | if (mActiveItem) { | 849 | if (mActiveItem) { |
837 | emit showTodoSignal(mActiveItem->todo()); | 850 | emit showTodoSignal(mActiveItem->todo()); |
838 | } | 851 | } |
839 | } | 852 | } |
840 | 853 | ||
841 | void KOTodoView::deleteTodo() | 854 | void KOTodoView::deleteTodo() |
842 | { | 855 | { |
843 | if (mActiveItem) { | 856 | if (mActiveItem) { |
844 | emit deleteTodoSignal(mActiveItem->todo()); | 857 | emit deleteTodoSignal(mActiveItem->todo()); |
845 | } | 858 | } |
846 | } | 859 | } |
847 | 860 | ||
848 | void KOTodoView::setNewPriority(int index) | 861 | void KOTodoView::setNewPriority(int index) |
849 | { | 862 | { |
850 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 863 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
851 | mActiveItem->todo()->setPriority(mPriority[index]); | 864 | mActiveItem->todo()->setPriority(mPriority[index]); |
852 | mActiveItem->construct(); | 865 | mActiveItem->construct(); |
853 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 866 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
854 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 867 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
855 | } | 868 | } |
856 | } | 869 | } |
857 | 870 | ||
858 | void KOTodoView::setNewPercentage(int index) | 871 | void KOTodoView::setNewPercentage(int index) |
859 | { | 872 | { |
860 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 873 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
861 | 874 | ||
862 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 875 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
863 | mActiveItem->setOn( true ); | 876 | mActiveItem->setOn( true ); |
864 | return; | 877 | return; |
865 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 878 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
866 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 879 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
867 | if ( par && par->isOn() ) | 880 | if ( par && par->isOn() ) |
868 | par->setOn( false ); | 881 | par->setOn( false ); |
869 | } | 882 | } |
870 | if (mPercentage[index] == 100) { | 883 | if (mPercentage[index] == 100) { |
871 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 884 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
872 | } else { | 885 | } else { |
873 | mActiveItem->todo()->setCompleted(false); | 886 | mActiveItem->todo()->setCompleted(false); |
874 | } | 887 | } |
875 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 888 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
876 | mActiveItem->construct(); | 889 | mActiveItem->construct(); |
877 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 890 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
878 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 891 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
879 | } | 892 | } |
880 | } | 893 | } |
881 | 894 | ||
882 | 895 | ||
883 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 896 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
884 | { | 897 | { |
885 | QPopupMenu* tempMenu = new QPopupMenu (this); | 898 | QPopupMenu* tempMenu = new QPopupMenu (this); |
886 | QStringList checkedCategories = todoItem->todo()->categories (); | 899 | QStringList checkedCategories = todoItem->todo()->categories (); |
887 | 900 | ||
888 | tempMenu->setCheckable (true); | 901 | tempMenu->setCheckable (true); |
889 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 902 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
890 | it != KOPrefs::instance()->mCustomCategories.end (); | 903 | it != KOPrefs::instance()->mCustomCategories.end (); |
891 | ++it) { | 904 | ++it) { |
892 | int index = tempMenu->insertItem (*it); | 905 | int index = tempMenu->insertItem (*it); |
893 | mCategory[index] = *it; | 906 | mCategory[index] = *it; |
894 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 907 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
895 | } | 908 | } |
896 | 909 | ||
897 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 910 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
898 | return tempMenu; | 911 | return tempMenu; |
899 | 912 | ||
900 | 913 | ||
901 | } | 914 | } |
902 | void KOTodoView::changedCategories(int index) | 915 | void KOTodoView::changedCategories(int index) |
903 | { | 916 | { |
904 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 917 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
905 | QStringList categories = mActiveItem->todo()->categories (); | 918 | QStringList categories = mActiveItem->todo()->categories (); |
906 | if (categories.find (mCategory[index]) != categories.end ()) | 919 | if (categories.find (mCategory[index]) != categories.end ()) |
907 | categories.remove (mCategory[index]); | 920 | categories.remove (mCategory[index]); |
908 | else | 921 | else |
909 | categories.insert (categories.end(), mCategory[index]); | 922 | categories.insert (categories.end(), mCategory[index]); |
910 | categories.sort (); | 923 | categories.sort (); |
911 | mActiveItem->todo()->setCategories (categories); | 924 | mActiveItem->todo()->setCategories (categories); |
912 | mActiveItem->construct(); | 925 | mActiveItem->construct(); |
913 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 926 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
914 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 927 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
915 | } | 928 | } |
916 | } | 929 | } |
917 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 930 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
918 | { | 931 | { |
919 | if ( pendingSubtodo != 0 ) { | 932 | if ( pendingSubtodo != 0 ) { |
920 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 933 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
921 | } | 934 | } |
922 | pendingSubtodo = 0; | 935 | pendingSubtodo = 0; |
923 | if (!item) { | 936 | if (!item) { |
924 | newTodo(); | 937 | newTodo(); |
925 | return; | 938 | return; |
926 | } | 939 | } |
927 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 940 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
928 | editItem( item ); | 941 | editItem( item ); |
929 | else | 942 | else |
930 | showItem( item , QPoint(), 0 ); | 943 | showItem( item , QPoint(), 0 ); |
931 | } | 944 | } |
932 | void KOTodoView::itemClicked(QListViewItem *item) | 945 | void KOTodoView::itemClicked(QListViewItem *item) |
933 | { | 946 | { |
934 | 947 | ||
935 | if (!item) { | 948 | if (!item) { |
936 | if ( pendingSubtodo != 0 ) { | 949 | if ( pendingSubtodo != 0 ) { |
937 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 950 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
938 | } | 951 | } |
939 | pendingSubtodo = 0; | 952 | pendingSubtodo = 0; |
940 | return; | 953 | return; |
941 | } | 954 | } |
942 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 955 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
943 | if ( pendingSubtodo != 0 ) { | 956 | if ( pendingSubtodo != 0 ) { |
944 | bool allowReparent = true; | 957 | bool allowReparent = true; |
945 | QListViewItem *par = item; | 958 | QListViewItem *par = item; |
946 | while ( par ) { | 959 | while ( par ) { |
947 | if ( par == pendingSubtodo ) { | 960 | if ( par == pendingSubtodo ) { |
948 | allowReparent = false; | 961 | allowReparent = false; |
949 | break; | 962 | break; |
950 | } | 963 | } |
951 | par = par->parent(); | 964 | par = par->parent(); |
952 | } | 965 | } |
953 | if ( !allowReparent ) { | 966 | if ( !allowReparent ) { |
954 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 967 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
955 | qDebug("Recursive reparenting not possible "); | 968 | qDebug("Recursive reparenting not possible "); |
956 | pendingSubtodo = 0; | 969 | pendingSubtodo = 0; |
957 | } else { | 970 | } else { |
958 | Todo* newParent = todoItem->todo(); | 971 | Todo* newParent = todoItem->todo(); |
959 | Todo* newSub = pendingSubtodo->todo(); | 972 | Todo* newSub = pendingSubtodo->todo(); |
960 | pendingSubtodo = 0; | 973 | pendingSubtodo = 0; |
961 | emit reparentTodoSignal( newParent,newSub ); | 974 | emit reparentTodoSignal( newParent,newSub ); |
962 | return; | 975 | return; |
963 | } | 976 | } |
964 | } | 977 | } |
965 | #if 0 | 978 | #if 0 |
966 | // handled by the item itself | 979 | // handled by the item itself |
967 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? | 980 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? |
968 | qDebug("com %d ",completed ); | 981 | qDebug("com %d ",completed ); |
969 | qDebug("itemclicked "); | 982 | qDebug("itemclicked "); |
970 | if (todoItem->isOn()) { | 983 | if (todoItem->isOn()) { |
971 | qDebug("on "); | 984 | qDebug("on "); |
972 | if (!completed) { | 985 | if (!completed) { |
973 | qDebug("set true "); | 986 | qDebug("set true "); |
974 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 987 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
975 | } | 988 | } |
976 | } else { | 989 | } else { |
977 | qDebug("not on "); | 990 | qDebug("not on "); |
978 | if (completed) { | 991 | if (completed) { |
979 | qDebug("set false "); | 992 | qDebug("set false "); |
980 | todoItem->todo()->setCompleted(false); | 993 | todoItem->todo()->setCompleted(false); |
981 | } | 994 | } |
982 | } | 995 | } |
983 | #endif | 996 | #endif |
984 | } | 997 | } |
985 | 998 | ||
986 | void KOTodoView::setDocumentId( const QString &id ) | 999 | void KOTodoView::setDocumentId( const QString &id ) |
987 | { | 1000 | { |
988 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 1001 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
989 | 1002 | ||
990 | mDocPrefs->setDoc( id ); | 1003 | mDocPrefs->setDoc( id ); |
991 | } | 1004 | } |
992 | 1005 | ||
993 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1006 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
994 | { | 1007 | { |
995 | if (!item) return; | 1008 | if (!item) return; |
996 | 1009 | ||
997 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1010 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
998 | 1011 | ||
999 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1012 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1000 | 1013 | ||
1001 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1014 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1002 | } | 1015 | } |
1003 | 1016 | ||
1004 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1017 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1005 | { | 1018 | { |
1006 | mTodoListView->saveLayout(config,group); | 1019 | mTodoListView->saveLayout(config,group); |
1007 | } | 1020 | } |
1008 | 1021 | ||
1009 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1022 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1010 | { | 1023 | { |
1011 | mTodoListView->restoreLayout(config,group); | 1024 | mTodoListView->restoreLayout(config,group); |
1012 | } | 1025 | } |
1013 | 1026 | ||
1014 | void KOTodoView::processSelectionChange() | 1027 | void KOTodoView::processSelectionChange() |
1015 | { | 1028 | { |
1016 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1029 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1017 | 1030 | ||
1018 | KOTodoViewItem *item = | 1031 | KOTodoViewItem *item = |
1019 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1032 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1020 | 1033 | ||
1021 | if ( !item ) { | 1034 | if ( !item ) { |
1022 | emit incidenceSelected( 0 ); | 1035 | emit incidenceSelected( 0 ); |
1023 | } else { | 1036 | } else { |
1024 | emit incidenceSelected( item->todo() ); | 1037 | emit incidenceSelected( item->todo() ); |
1025 | } | 1038 | } |
1026 | } | 1039 | } |
1027 | 1040 | ||
1028 | void KOTodoView::modified(bool b) | 1041 | void KOTodoView::modified(bool b) |
1029 | { | 1042 | { |
1030 | emit isModified(b); | 1043 | emit isModified(b); |
1031 | } | 1044 | } |
1032 | void KOTodoView::setTodoModified( Todo* todo ) | 1045 | void KOTodoView::setTodoModified( Todo* todo ) |
1033 | { | 1046 | { |
1034 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1047 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1035 | } | 1048 | } |
1036 | void KOTodoView::clearSelection() | 1049 | void KOTodoView::clearSelection() |
1037 | { | 1050 | { |
1038 | mTodoListView->selectAll( false ); | 1051 | mTodoListView->selectAll( false ); |
1039 | } | 1052 | } |
1040 | void KOTodoView::setAllOpen() | 1053 | void KOTodoView::setAllOpen() |
1041 | { | 1054 | { |
1042 | if ( isFlatDisplay ) { | 1055 | if ( isFlatDisplay ) { |
1043 | isFlatDisplay = false; | 1056 | isFlatDisplay = false; |
1044 | mPopupMenu->setItemChecked( 8,false ); | 1057 | mPopupMenu->setItemChecked( 8,false ); |
1045 | updateView(); | 1058 | updateView(); |
1046 | } | 1059 | } |
1047 | setOpen(mTodoListView->firstChild(), true); | 1060 | setOpen(mTodoListView->firstChild(), true); |
1048 | } | 1061 | } |
1049 | void KOTodoView::setAllClose() | 1062 | void KOTodoView::setAllClose() |
1050 | { | 1063 | { |
1051 | if ( isFlatDisplay ) { | 1064 | if ( isFlatDisplay ) { |
1052 | isFlatDisplay = false; | 1065 | isFlatDisplay = false; |
1053 | mPopupMenu->setItemChecked( 8,false ); | 1066 | mPopupMenu->setItemChecked( 8,false ); |
1054 | updateView(); | 1067 | updateView(); |
1055 | } | 1068 | } |
1056 | setOpen(mTodoListView->firstChild(), false); | 1069 | setOpen(mTodoListView->firstChild(), false); |
1057 | } | 1070 | } |
1058 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1071 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1059 | { | 1072 | { |
1060 | 1073 | ||
1061 | while ( item ) { | 1074 | while ( item ) { |
1062 | setOpen( item->firstChild(), setOpenI ); | 1075 | setOpen( item->firstChild(), setOpenI ); |
1063 | item->setOpen( setOpenI ); | 1076 | item->setOpen( setOpenI ); |
1064 | item = item->nextSibling(); | 1077 | item = item->nextSibling(); |
1065 | } | 1078 | } |
1066 | } | 1079 | } |
1067 | 1080 | ||
1068 | void KOTodoView::setAllFlat() | 1081 | void KOTodoView::setAllFlat() |
1069 | { | 1082 | { |
1070 | if ( isFlatDisplay ) { | 1083 | if ( isFlatDisplay ) { |
1071 | isFlatDisplay = false; | 1084 | isFlatDisplay = false; |
1072 | mPopupMenu->setItemChecked( 8,false ); | 1085 | mPopupMenu->setItemChecked( 8,false ); |
1073 | updateView(); | 1086 | updateView(); |
1074 | return; | 1087 | return; |
1075 | } | 1088 | } |
1076 | pendingSubtodo = 0; | 1089 | pendingSubtodo = 0; |
1077 | if ( mBlockUpdate ) { | 1090 | if ( mBlockUpdate ) { |
1078 | return; | 1091 | return; |
1079 | } | 1092 | } |
1080 | mPopupMenu->setItemChecked( 8,true ); | 1093 | mPopupMenu->setItemChecked( 8,true ); |
1081 | isFlatDisplay = true; | 1094 | isFlatDisplay = true; |
1082 | QPtrList<Todo> todoList = calendar()->todos(); | 1095 | QPtrList<Todo> todoList = calendar()->todos(); |
1083 | mTodoMap.clear(); | 1096 | mTodoMap.clear(); |
1084 | mTodoListView->clear(); | 1097 | mTodoListView->clear(); |
1085 | Todo *todo; | 1098 | Todo *todo; |
1086 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1099 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1087 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1100 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1088 | mTodoMap.insert(todo,todoItem); | 1101 | mTodoMap.insert(todo,todoItem); |
1089 | } | 1102 | } |
1090 | mTodoListView->setFocus(); | 1103 | mTodoListView->setFocus(); |
1091 | processSelectionChange(); | 1104 | processSelectionChange(); |
1092 | } | 1105 | } |
1093 | 1106 | ||
1094 | void KOTodoView::purgeCompleted() | 1107 | void KOTodoView::purgeCompleted() |
1095 | { | 1108 | { |
1096 | emit purgeCompletedSignal(); | 1109 | emit purgeCompletedSignal(); |
1097 | } | 1110 | } |
1098 | void KOTodoView::toggleQuickTodo() | 1111 | void KOTodoView::toggleQuickTodo() |
1099 | { | 1112 | { |
1100 | if ( mQuickAdd->isVisible() ) { | 1113 | if ( mQuickAdd->isVisible() ) { |
1101 | mQuickAdd->hide(); | 1114 | mQuickAdd->hide(); |
1102 | KOPrefs::instance()->mEnableQuickTodo = false; | 1115 | KOPrefs::instance()->mEnableQuickTodo = false; |
1103 | } | 1116 | } |
1104 | else { | 1117 | else { |
1105 | mQuickAdd->show(); | 1118 | mQuickAdd->show(); |
1106 | KOPrefs::instance()->mEnableQuickTodo = true; | 1119 | KOPrefs::instance()->mEnableQuickTodo = true; |
1107 | } | 1120 | } |
1108 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1121 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1109 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1122 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1110 | } | 1123 | } |
1111 | 1124 | ||
1112 | void KOTodoView::toggleRunning() | 1125 | void KOTodoView::toggleRunning() |
1113 | { | 1126 | { |
1114 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1127 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1115 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1128 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1116 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1129 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1117 | updateView(); | 1130 | updateView(); |
1118 | } | 1131 | } |
1119 | 1132 | ||
1120 | void KOTodoView::toggleCompleted() | 1133 | void KOTodoView::toggleCompleted() |
1121 | { | 1134 | { |
1122 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1135 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1123 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1136 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1124 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1137 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1125 | updateView(); | 1138 | updateView(); |
1126 | } | 1139 | } |
1127 | 1140 | ||
1128 | void KOTodoView::addQuickTodo() | 1141 | void KOTodoView::addQuickTodo() |
1129 | { | 1142 | { |
1130 | Todo *todo = new Todo(); | 1143 | Todo *todo = new Todo(); |
1131 | todo->setSummary(mQuickAdd->text()); | 1144 | todo->setSummary(mQuickAdd->text()); |
1132 | todo->setOrganizer(KOPrefs::instance()->email()); | 1145 | todo->setOrganizer(KOPrefs::instance()->email()); |
1133 | CalFilter * cf = mCalendar->filter(); | 1146 | CalFilter * cf = mCalendar->filter(); |
1134 | if ( cf ) { | 1147 | if ( cf ) { |
1135 | if ( cf->isEnabled()&& cf->showCategories()) { | 1148 | if ( cf->isEnabled()&& cf->showCategories()) { |
1136 | todo->setCategories(cf->categoryList()); | 1149 | todo->setCategories(cf->categoryList()); |
1137 | } | 1150 | } |
1138 | if ( cf->isEnabled() ) | 1151 | if ( cf->isEnabled() ) |
1139 | todo->setSecrecy( cf->getSecrecy()); | 1152 | todo->setSecrecy( cf->getSecrecy()); |
1140 | } | 1153 | } |
1141 | mCalendar->addTodo(todo); | 1154 | mCalendar->addTodo(todo); |
1142 | mQuickAdd->setText(""); | 1155 | mQuickAdd->setText(""); |
1143 | todoModified (todo, KOGlobals::EVENTADDED ); | 1156 | todoModified (todo, KOGlobals::EVENTADDED ); |
1144 | updateView(); | 1157 | updateView(); |
1145 | } | 1158 | } |
1146 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1159 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1147 | { | 1160 | { |
1148 | // e->ignore(); | 1161 | // e->ignore(); |
1149 | //return; | 1162 | //return; |
1150 | //qDebug("KOTodoView::keyPressEvent "); | 1163 | //qDebug("KOTodoView::keyPressEvent "); |
1151 | switch ( e->key() ) { | 1164 | switch ( e->key() ) { |
1152 | case Qt::Key_Down: | 1165 | case Qt::Key_Down: |
1153 | case Qt::Key_Up: | 1166 | case Qt::Key_Up: |
1154 | QWidget::keyPressEvent ( e ); | 1167 | QWidget::keyPressEvent ( e ); |
1155 | break; | 1168 | break; |
1156 | 1169 | ||
1157 | case Qt::Key_Q: | 1170 | case Qt::Key_Q: |
1158 | toggleQuickTodo(); | 1171 | toggleQuickTodo(); |
1159 | break; | 1172 | break; |
1160 | case Qt::Key_U: | 1173 | case Qt::Key_U: |
1161 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1174 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1162 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1175 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1163 | unparentTodo(); | 1176 | unparentTodo(); |
1164 | e->accept(); | 1177 | e->accept(); |
1165 | } else | 1178 | } else |
1166 | e->ignore(); | 1179 | e->ignore(); |
1167 | break; | 1180 | break; |
1168 | case Qt::Key_S: | 1181 | case Qt::Key_S: |
1169 | if ( e->state() == Qt::ControlButton ) { | 1182 | if ( e->state() == Qt::ControlButton ) { |
1170 | e->ignore(); | 1183 | e->ignore(); |
1171 | break; | 1184 | break; |
1172 | } | 1185 | } |
1173 | if ( e->state() == Qt::ShiftButton ) { | 1186 | if ( e->state() == Qt::ShiftButton ) { |
1174 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1187 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1175 | reparentTodo(); | 1188 | reparentTodo(); |
1176 | e->accept(); | 1189 | e->accept(); |
1177 | } else | 1190 | } else |
1178 | e->ignore(); | 1191 | e->ignore(); |
1179 | break; | 1192 | break; |
1180 | case Qt::Key_P: | 1193 | case Qt::Key_P: |
1181 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1194 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1182 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1195 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1183 | if ( pendingSubtodo ) | 1196 | if ( pendingSubtodo ) |
1184 | itemClicked(mActiveItem); | 1197 | itemClicked(mActiveItem); |
1185 | e->accept(); | 1198 | e->accept(); |
1186 | } else | 1199 | } else |
1187 | e->ignore(); | 1200 | e->ignore(); |
1188 | break; | 1201 | break; |
1189 | case Qt::Key_Escape: | 1202 | case Qt::Key_Escape: |
1190 | if ( pendingSubtodo ) { | 1203 | if ( pendingSubtodo ) { |
1191 | itemClicked(0); | 1204 | itemClicked(0); |
1192 | e->accept(); | 1205 | e->accept(); |
1193 | } else | 1206 | } else |
1194 | e->ignore(); | 1207 | e->ignore(); |
1195 | break; | 1208 | break; |
1196 | default: | 1209 | default: |
1197 | e->ignore(); | 1210 | e->ignore(); |
1198 | } | 1211 | } |
1199 | 1212 | ||
1200 | if ( true ) { | 1213 | if ( true ) { |
1201 | if ( e->key() == Qt::Key_I ) { | 1214 | if ( e->key() == Qt::Key_I ) { |
1202 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1215 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1203 | if ( cn ) { | 1216 | if ( cn ) { |
1204 | mActiveItem = cn; | 1217 | mActiveItem = cn; |
1205 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1218 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1206 | if ( ci ){ | 1219 | if ( ci ){ |
1207 | showTodo(); | 1220 | showTodo(); |
1208 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1221 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1209 | if ( cn ) { | 1222 | if ( cn ) { |
1210 | mTodoListView->setCurrentItem ( cn ); | 1223 | mTodoListView->setCurrentItem ( cn ); |
1211 | mTodoListView->ensureItemVisible ( cn ); | 1224 | mTodoListView->ensureItemVisible ( cn ); |
1212 | } | 1225 | } |
1213 | 1226 | ||
1214 | } | 1227 | } |
1215 | } | 1228 | } |
1216 | e->accept(); | 1229 | e->accept(); |
1217 | 1230 | ||
1218 | } | 1231 | } |
1219 | 1232 | ||
1220 | } | 1233 | } |
1221 | 1234 | ||
1222 | } | 1235 | } |
1223 | void KOTodoView::updateTodo( Todo * t, int type ) | 1236 | void KOTodoView::updateTodo( Todo * t, int type ) |
1224 | { | 1237 | { |
1225 | if ( mBlockUpdate) | 1238 | if ( mBlockUpdate) |
1226 | return; | 1239 | return; |
1227 | 1240 | ||
1228 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1241 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1229 | itemIterator = mTodoMap.find(t); | 1242 | itemIterator = mTodoMap.find(t); |
1230 | if (itemIterator != mTodoMap.end()) { | 1243 | if (itemIterator != mTodoMap.end()) { |
1231 | (*itemIterator)->construct(); | 1244 | (*itemIterator)->construct(); |
1232 | } else { | 1245 | } else { |
1233 | if ( type == KOGlobals::EVENTADDED ) { | 1246 | if ( type == KOGlobals::EVENTADDED ) { |
1234 | insertTodoItem( t ); | 1247 | insertTodoItem( t ); |
1235 | } | 1248 | } |
1236 | } | 1249 | } |
1237 | 1250 | ||
1238 | } | 1251 | } |
1239 | 1252 | ||
1240 | void KOTodoView::todoModified(Todo * t , int p ) | 1253 | void KOTodoView::todoModified(Todo * t , int p ) |
1241 | { | 1254 | { |
1242 | mBlockUpdate = true; | 1255 | mBlockUpdate = true; |
1243 | emit todoModifiedSignal ( t, p ); | 1256 | emit todoModifiedSignal ( t, p ); |
1244 | mBlockUpdate = false; | 1257 | mBlockUpdate = false; |
1245 | } | 1258 | } |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 68e29bb..16bc133 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -1,247 +1,249 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOTODOVIEW_H | 23 | #ifndef KOTODOVIEW_H |
24 | #define KOTODOVIEW_H | 24 | #define KOTODOVIEW_H |
25 | 25 | ||
26 | #include <qfont.h> | 26 | #include <qfont.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qptrlist.h> | 29 | #include <qptrlist.h> |
30 | #include <qstrlist.h> | 30 | #include <qstrlist.h> |
31 | #include <qlistbox.h> | 31 | #include <qlistbox.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qmap.h> | 34 | #include <qmap.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <klistview.h> | 36 | #include <klistview.h> |
37 | 37 | ||
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | 40 | ||
41 | #include <korganizer/baseview.h> | 41 | #include <korganizer/baseview.h> |
42 | 42 | ||
43 | #include "kotodoviewitem.h" | 43 | #include "kotodoviewitem.h" |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #include "koglobals.h" | 45 | #include "koglobals.h" |
46 | #include "datenavigator.h" | 46 | #include "datenavigator.h" |
47 | 47 | ||
48 | class QDragEnterEvent; | 48 | class QDragEnterEvent; |
49 | class QDragMoveEvent; | 49 | class QDragMoveEvent; |
50 | class QDragLeaveEvent; | 50 | class QDragLeaveEvent; |
51 | class QDropEvent; | 51 | class QDropEvent; |
52 | 52 | ||
53 | class DocPrefs; | 53 | class DocPrefs; |
54 | 54 | ||
55 | class KOTodoListView : public KListView | 55 | class KOTodoListView : public KListView |
56 | { | 56 | { |
57 | Q_OBJECT | 57 | Q_OBJECT |
58 | public: | 58 | public: |
59 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); | 59 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); |
60 | virtual ~KOTodoListView() {} | 60 | virtual ~KOTodoListView() {} |
61 | 61 | ||
62 | signals: | 62 | signals: |
63 | void todoDropped(Todo *, int); | 63 | void todoDropped(Todo *, int); |
64 | void double_Clicked(QListViewItem *item); | 64 | void double_Clicked(QListViewItem *item); |
65 | void reparentTodoSignal( Todo *,Todo * ); | 65 | void reparentTodoSignal( Todo *,Todo * ); |
66 | void unparentTodoSignal(Todo *); | 66 | void unparentTodoSignal(Todo *); |
67 | void deleteTodo( Todo * ); | 67 | void deleteTodo( Todo * ); |
68 | protected: | 68 | protected: |
69 | void contentsDragEnterEvent(QDragEnterEvent *); | 69 | void contentsDragEnterEvent(QDragEnterEvent *); |
70 | void contentsDragMoveEvent(QDragMoveEvent *); | 70 | void contentsDragMoveEvent(QDragMoveEvent *); |
71 | void contentsDragLeaveEvent(QDragLeaveEvent *); | 71 | void contentsDragLeaveEvent(QDragLeaveEvent *); |
72 | void contentsDropEvent(QDropEvent *); | 72 | void contentsDropEvent(QDropEvent *); |
73 | 73 | ||
74 | void contentsMousePressEvent(QMouseEvent *); | 74 | void contentsMousePressEvent(QMouseEvent *); |
75 | void contentsMouseMoveEvent(QMouseEvent *); | 75 | void contentsMouseMoveEvent(QMouseEvent *); |
76 | void contentsMouseReleaseEvent(QMouseEvent *); | 76 | void contentsMouseReleaseEvent(QMouseEvent *); |
77 | void contentsMouseDoubleClickEvent(QMouseEvent *); | 77 | void contentsMouseDoubleClickEvent(QMouseEvent *); |
78 | 78 | ||
79 | private: | 79 | private: |
80 | bool internalDrop; | 80 | bool internalDrop; |
81 | QString mName; | 81 | QString mName; |
82 | Calendar *mCalendar; | 82 | Calendar *mCalendar; |
83 | QPoint mPressPos; | 83 | QPoint mPressPos; |
84 | bool mMousePressed; | 84 | bool mMousePressed; |
85 | QListViewItem *mOldCurrent; | 85 | QListViewItem *mOldCurrent; |
86 | void keyPressEvent ( QKeyEvent * ) ; | 86 | void keyPressEvent ( QKeyEvent * ) ; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | 89 | ||
90 | /** | 90 | /** |
91 | This is the line-edit on top of the todoview for fast addition of new todos | 91 | This is the line-edit on top of the todoview for fast addition of new todos |
92 | */ | 92 | */ |
93 | class KOQuickTodo : public QLineEdit | 93 | class KOQuickTodo : public QLineEdit |
94 | { | 94 | { |
95 | public: | 95 | public: |
96 | KOQuickTodo(QWidget *parent=0); | 96 | KOQuickTodo(QWidget *parent=0); |
97 | protected: | 97 | protected: |
98 | void focusInEvent(QFocusEvent *ev); | 98 | void focusInEvent(QFocusEvent *ev); |
99 | void focusOutEvent(QFocusEvent *ev); | 99 | void focusOutEvent(QFocusEvent *ev); |
100 | }; | 100 | }; |
101 | 101 | ||
102 | 102 | ||
103 | /** | 103 | /** |
104 | This class provides a multi-column list view of todo events. | 104 | This class provides a multi-column list view of todo events. |
105 | 105 | ||
106 | @short multi-column list view of todo events. | 106 | @short multi-column list view of todo events. |
107 | @author Cornelius Schumacher <schumacher@kde.org> | 107 | @author Cornelius Schumacher <schumacher@kde.org> |
108 | */ | 108 | */ |
109 | class KOTodoView : public KOrg::BaseView | 109 | class KOTodoView : public KOrg::BaseView |
110 | { | 110 | { |
111 | Q_OBJECT | 111 | Q_OBJECT |
112 | public: | 112 | public: |
113 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); | 113 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); |
114 | ~KOTodoView(); | 114 | ~KOTodoView(); |
115 | 115 | ||
116 | QPtrList<Incidence> selectedIncidences(); | 116 | QPtrList<Incidence> selectedIncidences(); |
117 | QPtrList<Todo> selectedTodos(); | 117 | QPtrList<Todo> selectedTodos(); |
118 | 118 | ||
119 | DateList selectedDates() | 119 | DateList selectedDates() |
120 | {DateList q; | 120 | {DateList q; |
121 | return q;} | 121 | return q;} |
122 | 122 | ||
123 | /** Return number of shown dates. TodoView does not show dates, */ | 123 | /** Return number of shown dates. TodoView does not show dates, */ |
124 | int currentDateCount() { return 0; } | 124 | int currentDateCount() { return 0; } |
125 | 125 | ||
126 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); | 126 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); |
127 | 127 | ||
128 | void setDocumentId( const QString & ); | 128 | void setDocumentId( const QString & ); |
129 | 129 | ||
130 | void saveLayout(KConfig *config, const QString &group) const; | 130 | void saveLayout(KConfig *config, const QString &group) const; |
131 | void restoreLayout(KConfig *config, const QString &group); | 131 | void restoreLayout(KConfig *config, const QString &group); |
132 | /** Create a popup menu to set categories */ | 132 | /** Create a popup menu to set categories */ |
133 | QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); | 133 | QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); |
134 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} | 134 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} |
135 | 135 | ||
136 | public slots: | 136 | public slots: |
137 | void updateView(); | 137 | void updateView(); |
138 | void updateConfig(); | 138 | void updateConfig(); |
139 | 139 | ||
140 | void changeEventDisplay(Event *, int); | 140 | void changeEventDisplay(Event *, int); |
141 | 141 | ||
142 | void showDates(const QDate &start, const QDate &end); | 142 | void showDates(const QDate &start, const QDate &end); |
143 | void showEvents(QPtrList<Event> eventList); | 143 | void showEvents(QPtrList<Event> eventList); |
144 | 144 | ||
145 | void clearSelection(); | 145 | void clearSelection(); |
146 | void jumpToDate (); | 146 | void jumpToDate (); |
147 | 147 | ||
148 | void editItem(QListViewItem *item); | 148 | void editItem(QListViewItem *item); |
149 | void showItem(QListViewItem *item,const QPoint &,int); | 149 | void showItem(QListViewItem *item,const QPoint &,int); |
150 | void popupMenu(QListViewItem *item,const QPoint &,int); | 150 | void popupMenu(QListViewItem *item,const QPoint &,int); |
151 | void newTodo(); | 151 | void newTodo(); |
152 | void newSubTodo(); | 152 | void newSubTodo(); |
153 | void unparentTodo(); | 153 | void unparentTodo(); |
154 | void reparentTodo(); | 154 | void reparentTodo(); |
155 | void showTodo(); | 155 | void showTodo(); |
156 | void editTodo(); | 156 | void editTodo(); |
157 | void cloneTodo(); | 157 | void cloneTodo(); |
158 | void cancelTodo(); | 158 | void cancelTodo(); |
159 | void moveTodo(); | 159 | void moveTodo(); |
160 | void beamTodo(); | 160 | void beamTodo(); |
161 | void deleteTodo(); | 161 | void deleteTodo(); |
162 | 162 | ||
163 | void setNewPriority(int); | 163 | void setNewPriority(int); |
164 | void setNewPercentage(int); | 164 | void setNewPercentage(int); |
165 | void changedCategories(int); | 165 | void changedCategories(int); |
166 | 166 | ||
167 | void setAllOpen(); | 167 | void setAllOpen(); |
168 | void setAllClose(); | 168 | void setAllClose(); |
169 | void setAllFlat(); | 169 | void setAllFlat(); |
170 | 170 | ||
171 | void purgeCompleted(); | 171 | void purgeCompleted(); |
172 | void toggleCompleted(); | 172 | void toggleCompleted(); |
173 | void toggleRunning(); | 173 | void toggleRunning(); |
174 | void toggleQuickTodo(); | 174 | void toggleQuickTodo(); |
175 | void updateTodo( Todo *, int ); | 175 | void updateTodo( Todo *, int ); |
176 | 176 | ||
177 | void itemClicked(QListViewItem *); | 177 | void itemClicked(QListViewItem *); |
178 | void itemStateChanged(QListViewItem *); | 178 | void itemStateChanged(QListViewItem *); |
179 | void modified(bool); | 179 | void modified(bool); |
180 | void itemDoubleClicked(QListViewItem *item); | 180 | void itemDoubleClicked(QListViewItem *item); |
181 | 181 | ||
182 | signals: | 182 | signals: |
183 | void newTodoSignal(); | 183 | void newTodoSignal(); |
184 | void newSubTodoSignal(Todo *); | 184 | void newSubTodoSignal(Todo *); |
185 | void unparentTodoSignal(Todo *); | 185 | void unparentTodoSignal(Todo *); |
186 | void reparentTodoSignal( Todo *,Todo * ); | 186 | void reparentTodoSignal( Todo *,Todo * ); |
187 | void showTodoSignal(Todo *); | 187 | void showTodoSignal(Todo *); |
188 | 188 | ||
189 | void editTodoSignal(Todo *); | 189 | void editTodoSignal(Todo *); |
190 | void deleteTodoSignal(Todo *); | 190 | void deleteTodoSignal(Todo *); |
191 | void todoModifiedSignal (Todo *, int); | 191 | void todoModifiedSignal (Todo *, int); |
192 | 192 | ||
193 | void isModified(bool); | 193 | void isModified(bool); |
194 | void cloneTodoSignal( Incidence * ); | 194 | void cloneTodoSignal( Incidence * ); |
195 | void cancelTodoSignal( Incidence * ); | 195 | void cancelTodoSignal( Incidence * ); |
196 | void moveTodoSignal( Incidence * ); | 196 | void moveTodoSignal( Incidence * ); |
197 | void beamTodoSignal( Incidence * ); | 197 | void beamTodoSignal( Incidence * ); |
198 | void purgeCompletedSignal(); | 198 | void purgeCompletedSignal(); |
199 | 199 | ||
200 | protected slots: | 200 | protected slots: |
201 | void processSelectionChange(); | 201 | void processSelectionChange(); |
202 | void addQuickTodo(); | 202 | void addQuickTodo(); |
203 | void setTodoModified( Todo* ); | 203 | void setTodoModified( Todo* ); |
204 | void todoModified(Todo *, int ); | 204 | void todoModified(Todo *, int ); |
205 | 205 | ||
206 | private: | 206 | private: |
207 | /* | 207 | /* |
208 | * the TodoEditor approach is rather unscaling in the long | 208 | * the TodoEditor approach is rather unscaling in the long |
209 | * run. | 209 | * run. |
210 | * Korganizer keeps it in memory and we need to update | 210 | * Korganizer keeps it in memory and we need to update |
211 | * 1. make KOTodoViewItem a QObject again? | 211 | * 1. make KOTodoViewItem a QObject again? |
212 | * 2. add a public method for setting one todo modified? | 212 | * 2. add a public method for setting one todo modified? |
213 | * 3. add a private method for setting a todo modified + friend here? | 213 | * 3. add a private method for setting a todo modified + friend here? |
214 | * -- zecke 2002-07-08 | 214 | * -- zecke 2002-07-08 |
215 | */ | 215 | */ |
216 | void paintEvent(QPaintEvent * pevent); | ||
217 | bool mPendingUpdateBeforeRepaint; | ||
216 | friend class KOTodoViewItem; | 218 | friend class KOTodoViewItem; |
217 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); | 219 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); |
218 | void restoreItemState( QListViewItem * ); | 220 | void restoreItemState( QListViewItem * ); |
219 | 221 | ||
220 | bool checkTodo( Todo * ); | 222 | bool checkTodo( Todo * ); |
221 | bool isFlatDisplay; | 223 | bool isFlatDisplay; |
222 | void setOpen( QListViewItem*, bool setOpen); | 224 | void setOpen( QListViewItem*, bool setOpen); |
223 | KOTodoListView *mTodoListView; | 225 | KOTodoListView *mTodoListView; |
224 | QPopupMenu *mItemPopupMenu; | 226 | QPopupMenu *mItemPopupMenu; |
225 | QPopupMenu *mPopupMenu; | 227 | QPopupMenu *mPopupMenu; |
226 | QPopupMenu *mPriorityPopupMenu; | 228 | QPopupMenu *mPriorityPopupMenu; |
227 | QPopupMenu *mPercentageCompletedPopupMenu; | 229 | QPopupMenu *mPercentageCompletedPopupMenu; |
228 | QPopupMenu *mCategoryPopupMenu; | 230 | QPopupMenu *mCategoryPopupMenu; |
229 | 231 | ||
230 | QMap<int, int> mPercentage; | 232 | QMap<int, int> mPercentage; |
231 | QMap<int, int> mPriority; | 233 | QMap<int, int> mPriority; |
232 | QMap<int, QString> mCategory; | 234 | QMap<int, QString> mCategory; |
233 | KOTodoViewItem *mActiveItem; | 235 | KOTodoViewItem *mActiveItem; |
234 | 236 | ||
235 | QMap<Todo *,KOTodoViewItem *> mTodoMap; | 237 | QMap<Todo *,KOTodoViewItem *> mTodoMap; |
236 | QString mName; | 238 | QString mName; |
237 | 239 | ||
238 | DocPrefs *mDocPrefs; | 240 | DocPrefs *mDocPrefs; |
239 | QString mCurrentDoc; | 241 | QString mCurrentDoc; |
240 | KOQuickTodo *mQuickAdd; | 242 | KOQuickTodo *mQuickAdd; |
241 | bool mBlockUpdate; | 243 | bool mBlockUpdate; |
242 | void keyPressEvent ( QKeyEvent * ) ; | 244 | void keyPressEvent ( QKeyEvent * ) ; |
243 | KOTodoViewItem * pendingSubtodo; | 245 | KOTodoViewItem * pendingSubtodo; |
244 | DateNavigator* mNavigator; | 246 | DateNavigator* mNavigator; |
245 | }; | 247 | }; |
246 | 248 | ||
247 | #endif | 249 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 35774d6..2cd8792 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,647 +1,652 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void KOViewManager::showDateView( int view, QDate date) | 102 | void KOViewManager::showDateView( int view, QDate date) |
103 | { | 103 | { |
104 | 104 | ||
105 | //qDebug("date %d %s", view, date.toString().latin1()); | 105 | //qDebug("date %d %s", view, date.toString().latin1()); |
106 | #if 0 | 106 | #if 0 |
107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); | 108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); |
109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); | 109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); |
110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); | 110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); |
111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
112 | #endif | 112 | #endif |
113 | if ( view == 3 ) { | 113 | if ( view == 3 ) { |
114 | mMainView->showDay( date ); | 114 | mMainView->showDay( date ); |
115 | } else if (view == 4 ) { | 115 | } else if (view == 4 ) { |
116 | mMainView->dateNavigator()->selectDates( date, 7 ); | 116 | mMainView->dateNavigator()->selectDates( date, 7 ); |
117 | } else if (view == 5 ) { | 117 | } else if (view == 5 ) { |
118 | mMainView->dateNavigator()->selectDates( date, 14); | 118 | mMainView->dateNavigator()->selectDates( date, 14); |
119 | } else if (view == 6 ) { | 119 | } else if (view == 6 ) { |
120 | mMainView->dateNavigator()->blockSignals( true ); | 120 | mMainView->dateNavigator()->blockSignals( true ); |
121 | mMainView->dateNavigator()->selectMonthByDate( date ); | 121 | mMainView->dateNavigator()->selectMonthByDate( date ); |
122 | mMainView->dateNavigator()->selectDate( date ); | 122 | mMainView->dateNavigator()->selectDate( date ); |
123 | mMainView->dateNavigator()->blockSignals( false ); | 123 | mMainView->dateNavigator()->blockSignals( false ); |
124 | showMonthView(); | 124 | showMonthView(); |
125 | } else if (view == 7 ) { | 125 | } else if (view == 7 ) { |
126 | mMainView->dateNavigator()->selectDate( date ); | 126 | mMainView->dateNavigator()->selectDate( date ); |
127 | showJournalView(); | 127 | showJournalView(); |
128 | } else if (view == 8 ) { | 128 | } else if (view == 8 ) { |
129 | globalFlagBlockAgenda = 1; | 129 | globalFlagBlockAgenda = 1; |
130 | if ( mCurrentAgendaView != 3 ) | 130 | if ( mCurrentAgendaView != 3 ) |
131 | mCurrentAgendaView = -1; | 131 | mCurrentAgendaView = -1; |
132 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 132 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
133 | globalFlagBlockAgenda = 2; | 133 | globalFlagBlockAgenda = 2; |
134 | mMainView->dateNavigator()->selectDates( date , | 134 | mMainView->dateNavigator()->selectDates( date , |
135 | KOPrefs::instance()->mNextXDays ); | 135 | KOPrefs::instance()->mNextXDays ); |
136 | mFlagShowNextxDays = true; | 136 | mFlagShowNextxDays = true; |
137 | mCurrentAgendaView = 3 ; | 137 | mCurrentAgendaView = 3 ; |
138 | } | 138 | } |
139 | 139 | ||
140 | #if 0 | 140 | #if 0 |
141 | dateNavigator()->blockSignals( true ); | 141 | dateNavigator()->blockSignals( true ); |
142 | dateNavigator()->selectDate( d ); | 142 | dateNavigator()->selectDate( d ); |
143 | dateNavigator()->blockSignals( false ); | 143 | dateNavigator()->blockSignals( false ); |
144 | mViewManager->showDayView(); | 144 | mViewManager->showDayView(); |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | 150 | ||
151 | void KOViewManager::writeSettings(KConfig *config) | 151 | void KOViewManager::writeSettings(KConfig *config) |
152 | { | 152 | { |
153 | config->setGroup("General"); | 153 | config->setGroup("General"); |
154 | 154 | ||
155 | QString view; | 155 | QString view; |
156 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 156 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
157 | else if (mCurrentView == mMonthView) view = "Month"; | 157 | else if (mCurrentView == mMonthView) view = "Month"; |
158 | else if (mCurrentView == mListView) view = "List"; | 158 | else if (mCurrentView == mListView) view = "List"; |
159 | else if (mCurrentView == mJournalView) view = "Journal"; | 159 | else if (mCurrentView == mJournalView) view = "Journal"; |
160 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 160 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
161 | else if (mCurrentView == mTodoView) view = "Todo"; | 161 | else if (mCurrentView == mTodoView) view = "Todo"; |
162 | else view = "Agenda"; | 162 | else view = "Agenda"; |
163 | 163 | ||
164 | config->writeEntry("Current View",view); | 164 | config->writeEntry("Current View",view); |
165 | 165 | ||
166 | if (mAgendaView) { | 166 | if (mAgendaView) { |
167 | mAgendaView->writeSettings(config); | 167 | mAgendaView->writeSettings(config); |
168 | } | 168 | } |
169 | if (mTimeSpanView) { | 169 | if (mTimeSpanView) { |
170 | mTimeSpanView->writeSettings(config); | 170 | mTimeSpanView->writeSettings(config); |
171 | } | 171 | } |
172 | if (mListView) { | 172 | if (mListView) { |
173 | mListView->writeSettings(config); | 173 | mListView->writeSettings(config); |
174 | } | 174 | } |
175 | if (mTodoView) { | 175 | if (mTodoView) { |
176 | mTodoView->saveLayout(config,"Todo View"); | 176 | mTodoView->saveLayout(config,"Todo View"); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 180 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
181 | { | 181 | { |
182 | 182 | ||
183 | //mFlagShowNextxDays = false; | 183 | //mFlagShowNextxDays = false; |
184 | //if(view == mCurrentView) return; | 184 | //if(view == mCurrentView) return; |
185 | if ( view == 0 ) { | 185 | if ( view == 0 ) { |
186 | view = mCurrentView; | 186 | view = mCurrentView; |
187 | if ( view == 0 ) | 187 | if ( view == 0 ) |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | bool full = fullScreen; | 190 | bool full = fullScreen; |
191 | if(view == mCurrentView && view != mWhatsNextView ) { | 191 | if(view == mCurrentView && view != mWhatsNextView ) { |
192 | if ( mCurrentAgendaView < 0 ) | 192 | if ( mCurrentAgendaView < 0 ) |
193 | return; | 193 | return; |
194 | full = mMainView->leftFrame()->isVisible(); | 194 | full = mMainView->leftFrame()->isVisible(); |
195 | } else { | 195 | } else { |
196 | mCurrentView = view; | 196 | mCurrentView = view; |
197 | // bool full = fullScreen; | 197 | // bool full = fullScreen; |
198 | bool isFull = !mMainView->leftFrame()->isVisible(); | 198 | bool isFull = !mMainView->leftFrame()->isVisible(); |
199 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 199 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
200 | full = true; | 200 | full = true; |
201 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 201 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
202 | full = false; | 202 | full = false; |
203 | } | 203 | } |
204 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 204 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
205 | //raiseCurrentView( full ); | 205 | //raiseCurrentView( full ); |
206 | mMainView->processIncidenceSelection( 0 ); | 206 | mMainView->processIncidenceSelection( 0 ); |
207 | mMainView->updateView(); | 207 | //mMainView->updateView(); |
208 | raiseCurrentView( full ); | 208 | raiseCurrentView( full, true ); |
209 | mMainView->adaptNavigationUnits(); | 209 | mMainView->adaptNavigationUnits(); |
210 | } | 210 | } |
211 | 211 | ||
212 | void KOViewManager::raiseCurrentView( bool fullScreen ) | 212 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) |
213 | { | 213 | { |
214 | mCurrentAgendaView = 0; | 214 | mCurrentAgendaView = 0; |
215 | int wid = mMainView->width() ; | 215 | int wid = mMainView->width() ; |
216 | int hei = mMainView->height(); | 216 | int hei = mMainView->height(); |
217 | if ( mCurrentView == mMonthView ) { | 217 | if ( mCurrentView == mMonthView ) { |
218 | mMainView->navigatorBar()->show(); | 218 | mMainView->navigatorBar()->show(); |
219 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 219 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
220 | //mMainView->navigatorBar()->hide(); | 220 | //mMainView->navigatorBar()->hide(); |
221 | } else { | 221 | } else { |
222 | mMainView->navigatorBar()->hide(); | 222 | mMainView->navigatorBar()->hide(); |
223 | } | 223 | } |
224 | if ( fullScreen ) { | 224 | if ( fullScreen ) { |
225 | mMainView->leftFrame()->hide(); | 225 | mMainView->leftFrame()->hide(); |
226 | } else { | 226 | } else { |
227 | mMainView->leftFrame()->show(); | 227 | mMainView->leftFrame()->show(); |
228 | if ( KOPrefs::instance()->mVerticalScreen ) | 228 | if ( KOPrefs::instance()->mVerticalScreen ) |
229 | hei -= mMainView->leftFrame()->height(); | 229 | hei -= mMainView->leftFrame()->height(); |
230 | else | 230 | else |
231 | wid -= mMainView->leftFrame()->width(); | 231 | wid -= mMainView->leftFrame()->width(); |
232 | } | 232 | } |
233 | emit signalFullScreen( !fullScreen ); | 233 | emit signalFullScreen( !fullScreen ); |
234 | if ( callUpdateView ) | ||
235 | mMainView->updateView(); | ||
236 | |||
234 | if ( globalFlagBlockAgenda == 5 ) { | 237 | if ( globalFlagBlockAgenda == 5 ) { |
235 | globalFlagBlockAgenda = 4; | 238 | globalFlagBlockAgenda = 4; |
236 | globalFlagBlockAgendaItemPaint = 1; | 239 | globalFlagBlockAgendaItemPaint = 1; |
237 | } | 240 | } |
238 | mMainView->viewStack()->raiseWidget(mCurrentView); | 241 | mMainView->viewStack()->raiseWidget(mCurrentView); |
239 | if ( globalFlagBlockAgenda == 4 ) { | 242 | if ( globalFlagBlockAgenda == 4 ) { |
240 | if ( mCurrentView == mAgendaView ) { | 243 | if ( mCurrentView == mAgendaView ) { |
241 | //globalFlagBlockAgenda =1 ; | 244 | //globalFlagBlockAgenda =1 ; |
242 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 245 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
243 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 246 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
244 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 247 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
245 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 248 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
246 | qApp->processEvents(); | 249 | qApp->processEvents(); |
247 | //qDebug("qApp->processEvents() "); | 250 | //qDebug("qApp->processEvents() "); |
248 | globalFlagBlockAgenda = 0; | 251 | globalFlagBlockAgenda = 0; |
249 | mAgendaView->repaintAgenda(); | 252 | mAgendaView->repaintAgenda(); |
250 | 253 | ||
251 | } | 254 | } |
252 | globalFlagBlockAgenda = 0; | 255 | globalFlagBlockAgenda = 0; |
253 | } | 256 | } |
254 | emit signalAgendaView( mCurrentView == mAgendaView ); | 257 | emit signalAgendaView( mCurrentView == mAgendaView ); |
255 | //qDebug("raiseCurrentView ende "); | 258 | //qDebug("raiseCurrentView ende "); |
256 | 259 | ||
257 | } | 260 | } |
258 | 261 | ||
259 | void KOViewManager::updateView() | 262 | void KOViewManager::updateView() |
260 | { | 263 | { |
261 | // qDebug("KOViewManager::updateView() "); | 264 | // qDebug("KOViewManager::updateView() "); |
262 | // if we are updating mTodoView, we get endless recursion | 265 | // if we are updating mTodoView, we get endless recursion |
263 | if ( mTodoView == mCurrentView ) | 266 | if ( mTodoView == mCurrentView ) |
264 | return; | 267 | return; |
265 | if ( mCurrentView ) mCurrentView->updateView(); | 268 | if ( mCurrentView ) mCurrentView->updateView(); |
266 | 269 | ||
267 | } | 270 | } |
268 | 271 | ||
269 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 272 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
270 | { | 273 | { |
271 | // kdDebug() << "KOViewManager::updateView()" << endl; | 274 | // kdDebug() << "KOViewManager::updateView()" << endl; |
272 | 275 | ||
273 | if (mCurrentView) mCurrentView->showDates(start, end); | 276 | if (mCurrentView) mCurrentView->showDates(start, end); |
274 | 277 | ||
275 | if (mTodoView) mTodoView->updateView(); | 278 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); |
276 | } | 279 | } |
277 | 280 | ||
278 | 281 | ||
279 | void KOViewManager::updateWNview() | 282 | void KOViewManager::updateWNview() |
280 | { | 283 | { |
281 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 284 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
282 | mWhatsNextView->updateView(); | 285 | mWhatsNextView->updateView(); |
283 | 286 | ||
284 | } | 287 | } |
285 | void KOViewManager::showWhatsNextView() | 288 | void KOViewManager::showWhatsNextView() |
286 | { | 289 | { |
287 | if (!mWhatsNextView) { | 290 | if (!mWhatsNextView) { |
288 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 291 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
289 | "KOViewManager::WhatsNextView"); | 292 | "KOViewManager::WhatsNextView"); |
290 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 293 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
291 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 294 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
292 | addView(mWhatsNextView); | 295 | addView(mWhatsNextView); |
293 | connect(this, SIGNAL( printWNV() ), | 296 | connect(this, SIGNAL( printWNV() ), |
294 | mWhatsNextView, SLOT( printMe() ) ); | 297 | mWhatsNextView, SLOT( printMe() ) ); |
295 | } | 298 | } |
296 | globalFlagBlockAgenda = 1; | 299 | globalFlagBlockAgenda = 1; |
297 | showView(mWhatsNextView, true ); | 300 | showView(mWhatsNextView, true ); |
298 | //mWhatsNextView->updateView(); | 301 | //mWhatsNextView->updateView(); |
299 | 302 | ||
300 | } | 303 | } |
301 | 304 | ||
302 | void KOViewManager::showListView() | 305 | void KOViewManager::showListView() |
303 | { | 306 | { |
304 | if (!mListView) { | 307 | if (!mListView) { |
305 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 308 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
306 | addView(mListView); | 309 | addView(mListView); |
307 | 310 | ||
308 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 311 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
309 | mMainView, SLOT(showIncidence(Incidence *))); | 312 | mMainView, SLOT(showIncidence(Incidence *))); |
310 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 313 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
311 | mMainView, SLOT(editIncidence(Incidence *))); | 314 | mMainView, SLOT(editIncidence(Incidence *))); |
312 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 315 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
313 | mMainView, SLOT(deleteIncidence(Incidence *))); | 316 | mMainView, SLOT(deleteIncidence(Incidence *))); |
314 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 317 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
315 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 318 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
316 | connect( mListView, SIGNAL( signalNewEvent() ), | 319 | connect( mListView, SIGNAL( signalNewEvent() ), |
317 | mMainView, SLOT( newEvent() ) ); | 320 | mMainView, SLOT( newEvent() ) ); |
318 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 321 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
319 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 322 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
320 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 323 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
321 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 324 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
322 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 325 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
323 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 326 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
324 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 327 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
325 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 328 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
326 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 329 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
327 | } | 330 | } |
328 | // bool temp = mFlagShowNextxDays; | 331 | // bool temp = mFlagShowNextxDays; |
329 | //globalFlagBlockPainting = true; | 332 | //globalFlagBlockPainting = true; |
330 | globalFlagBlockAgenda = 1; | 333 | globalFlagBlockAgenda = 1; |
331 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 334 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
332 | mMainView->setBlockShowDates( true ); | 335 | mMainView->setBlockShowDates( true ); |
333 | mMainView->dateNavigator()->selectMonth(); | 336 | mMainView->dateNavigator()->selectMonth(); |
334 | mMainView->setBlockShowDates( false ); | 337 | mMainView->setBlockShowDates( false ); |
335 | } | 338 | } |
336 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 339 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
337 | //mFlagShowNextxDays = temp; | 340 | //mFlagShowNextxDays = temp; |
338 | } | 341 | } |
339 | 342 | ||
340 | void KOViewManager::showAgendaView( bool fullScreen ) | 343 | void KOViewManager::showAgendaView( bool fullScreen ) |
341 | { | 344 | { |
342 | 345 | ||
343 | mMainView->dialogManager()->hideSearchDialog(); | 346 | mMainView->dialogManager()->hideSearchDialog(); |
344 | // qDebug("KOViewManager::showAgendaView "); | 347 | // qDebug("KOViewManager::showAgendaView "); |
345 | bool full; | 348 | bool full; |
346 | full = fullScreen; | 349 | full = fullScreen; |
347 | if (!mAgendaView) { | 350 | if (!mAgendaView) { |
348 | full = false; | 351 | full = false; |
349 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 352 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
350 | addView(mAgendaView); | 353 | addView(mAgendaView); |
351 | #ifndef DESKTOP_VERSION | 354 | #ifndef DESKTOP_VERSION |
352 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 355 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
353 | #endif | 356 | #endif |
354 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 357 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
355 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 358 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
356 | 359 | ||
357 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 360 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
358 | 361 | ||
359 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 362 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
360 | 363 | ||
361 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 364 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
362 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 365 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
363 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 366 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
364 | mMainView, SLOT(newEvent(QDateTime))); | 367 | mMainView, SLOT(newEvent(QDateTime))); |
365 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 368 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
366 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 369 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
367 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 370 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
368 | mMainView, SLOT(newEvent(QDate))); | 371 | mMainView, SLOT(newEvent(QDate))); |
369 | 372 | ||
370 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 373 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
371 | mMainView, SLOT(editIncidence(Incidence *))); | 374 | mMainView, SLOT(editIncidence(Incidence *))); |
372 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 375 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
373 | mMainView, SLOT(showIncidence(Incidence *))); | 376 | mMainView, SLOT(showIncidence(Incidence *))); |
374 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 377 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
375 | mMainView, SLOT(deleteIncidence(Incidence *))); | 378 | mMainView, SLOT(deleteIncidence(Incidence *))); |
376 | 379 | ||
377 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 380 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
378 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 381 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
379 | 382 | ||
380 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 383 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
381 | mMainView, SLOT( toggleExpand() ) ); | 384 | mMainView, SLOT( toggleExpand() ) ); |
382 | 385 | ||
383 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 386 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
384 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 387 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
385 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 388 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
386 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 389 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
387 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 390 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
388 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 391 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
389 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 392 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
390 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 393 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
391 | SLOT( updateTodo( Todo *, int ) ) ); | 394 | SLOT( updateTodo( Todo *, int ) ) ); |
392 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 395 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
393 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 396 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
394 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 397 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
395 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 398 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
396 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 399 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
397 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 400 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
398 | mAgendaView->readSettings(); | 401 | mAgendaView->readSettings(); |
399 | mAgendaView->updateConfig(); | 402 | mAgendaView->updateConfig(); |
400 | } | 403 | } |
401 | 404 | ||
402 | showView( mAgendaView, full); | 405 | showView( mAgendaView, full); |
403 | 406 | ||
404 | } | 407 | } |
405 | 408 | ||
406 | void KOViewManager::showDayView() | 409 | void KOViewManager::showDayView() |
407 | { | 410 | { |
408 | mFlagShowNextxDays = false; | 411 | mFlagShowNextxDays = false; |
409 | globalFlagBlockLabel = 1; | 412 | globalFlagBlockLabel = 1; |
410 | globalFlagBlockAgenda = 1; | 413 | globalFlagBlockAgenda = 1; |
411 | if ( mCurrentAgendaView != 1 ) | 414 | if ( mCurrentAgendaView != 1 ) |
412 | mCurrentAgendaView = -1; | 415 | mCurrentAgendaView = -1; |
413 | showAgendaView(); | 416 | showAgendaView(); |
414 | qApp->processEvents(); | 417 | qApp->processEvents(); |
415 | globalFlagBlockAgenda = 2; | 418 | globalFlagBlockAgenda = 2; |
416 | globalFlagBlockLabel = 0; | 419 | globalFlagBlockLabel = 0; |
417 | mMainView->dateNavigator()->selectDates( 1 ); | 420 | mMainView->dateNavigator()->selectDates( 1 ); |
418 | mCurrentAgendaView = 1 ; | 421 | mCurrentAgendaView = 1 ; |
419 | 422 | ||
420 | } | 423 | } |
421 | 424 | ||
422 | void KOViewManager::showWorkWeekView() | 425 | void KOViewManager::showWorkWeekView() |
423 | { | 426 | { |
424 | mFlagShowNextxDays = false; | 427 | mFlagShowNextxDays = false; |
425 | globalFlagBlockAgenda = 1; | 428 | globalFlagBlockAgenda = 1; |
426 | globalFlagBlockLabel = 1; | 429 | globalFlagBlockLabel = 1; |
427 | if ( mCurrentAgendaView != 5 ) | 430 | if ( mCurrentAgendaView != 5 ) |
428 | mCurrentAgendaView = -1; | 431 | mCurrentAgendaView = -1; |
429 | showAgendaView(); | 432 | showAgendaView(); |
430 | qApp->processEvents(); | 433 | qApp->processEvents(); |
431 | globalFlagBlockAgenda = 2; | 434 | globalFlagBlockAgenda = 2; |
432 | globalFlagBlockLabel = 0; | 435 | globalFlagBlockLabel = 0; |
433 | mMainView->dateNavigator()->selectWorkWeek(); | 436 | mMainView->dateNavigator()->selectWorkWeek(); |
434 | mCurrentAgendaView = 5 ; | 437 | mCurrentAgendaView = 5 ; |
435 | 438 | ||
436 | } | 439 | } |
437 | 440 | ||
438 | void KOViewManager::showWeekView() | 441 | void KOViewManager::showWeekView() |
439 | { | 442 | { |
440 | /* | 443 | /* |
441 | globalFlagBlockAgenda = 2; | 444 | globalFlagBlockAgenda = 2; |
442 | qDebug("4globalFlagBlockAgenda = 2; "); | 445 | qDebug("4globalFlagBlockAgenda = 2; "); |
443 | //globalFlagBlockPainting = true; | 446 | //globalFlagBlockPainting = true; |
444 | mMainView->dateNavigator()->selectWeek(); | 447 | mMainView->dateNavigator()->selectWeek(); |
445 | showAgendaView(); | 448 | showAgendaView(); |
446 | */ | 449 | */ |
447 | 450 | ||
448 | 451 | ||
449 | mFlagShowNextxDays = false; | 452 | mFlagShowNextxDays = false; |
450 | globalFlagBlockAgenda = 1; | 453 | globalFlagBlockAgenda = 1; |
451 | globalFlagBlockLabel = 1; | 454 | globalFlagBlockLabel = 1; |
452 | if ( mCurrentAgendaView != 7 ) | 455 | if ( mCurrentAgendaView != 7 ) |
453 | mCurrentAgendaView = -1; | 456 | mCurrentAgendaView = -1; |
454 | showAgendaView(); | 457 | showAgendaView(); |
455 | qApp->processEvents(); | 458 | qApp->processEvents(); |
456 | globalFlagBlockAgenda = 2; | 459 | globalFlagBlockAgenda = 2; |
457 | globalFlagBlockLabel = 0; | 460 | globalFlagBlockLabel = 0; |
458 | mMainView->dateNavigator()->selectWeek(); | 461 | mMainView->dateNavigator()->selectWeek(); |
459 | mCurrentAgendaView = 7 ; | 462 | mCurrentAgendaView = 7 ; |
460 | } | 463 | } |
461 | 464 | ||
462 | void KOViewManager::showNextXView() | 465 | void KOViewManager::showNextXView() |
463 | { | 466 | { |
464 | 467 | ||
465 | globalFlagBlockAgenda = 1; | 468 | globalFlagBlockAgenda = 1; |
466 | if ( mCurrentAgendaView != 3 ) | 469 | if ( mCurrentAgendaView != 3 ) |
467 | mCurrentAgendaView = -1; | 470 | mCurrentAgendaView = -1; |
468 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 471 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
469 | globalFlagBlockAgenda = 2; | 472 | globalFlagBlockAgenda = 2; |
470 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 473 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
471 | KOPrefs::instance()->mNextXDays ); | 474 | KOPrefs::instance()->mNextXDays ); |
472 | mFlagShowNextxDays = true; | 475 | mFlagShowNextxDays = true; |
473 | mCurrentAgendaView = 3 ; | 476 | mCurrentAgendaView = 3 ; |
474 | } | 477 | } |
475 | bool KOViewManager::showsNextDays() | 478 | bool KOViewManager::showsNextDays() |
476 | { | 479 | { |
477 | return mFlagShowNextxDays; | 480 | return mFlagShowNextxDays; |
478 | } | 481 | } |
479 | void KOViewManager::showMonthView() | 482 | void KOViewManager::showMonthView() |
480 | { | 483 | { |
481 | if (!mMonthView) { | 484 | if (!mMonthView) { |
482 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 485 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
483 | 486 | ||
484 | addView(mMonthView); | 487 | addView(mMonthView); |
485 | // mMonthView->show(); | 488 | // mMonthView->show(); |
486 | // SIGNALS/SLOTS FOR MONTH VIEW | 489 | // SIGNALS/SLOTS FOR MONTH VIEW |
487 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 490 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
488 | mMainView, SLOT(newEvent(QDateTime))); | 491 | mMainView, SLOT(newEvent(QDateTime))); |
489 | 492 | ||
490 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 493 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
491 | mMainView, SLOT(showIncidence(Incidence *))); | 494 | mMainView, SLOT(showIncidence(Incidence *))); |
492 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 495 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
493 | mMainView, SLOT(editIncidence(Incidence *))); | 496 | mMainView, SLOT(editIncidence(Incidence *))); |
494 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 497 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
495 | mMainView, SLOT(deleteIncidence(Incidence *))); | 498 | mMainView, SLOT(deleteIncidence(Incidence *))); |
496 | 499 | ||
497 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 500 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
498 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 501 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
499 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 502 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
500 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 503 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
501 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 504 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
502 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 505 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
503 | 506 | ||
504 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 507 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
505 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 508 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
506 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 509 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
507 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 510 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
508 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 511 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
509 | mMainView, SLOT ( selectWeekNum( int ) ) ); | 512 | mMainView, SLOT ( selectWeekNum( int ) ) ); |
510 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 513 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
511 | mMainView, SLOT ( showDay( QDate ) ) ); | 514 | mMainView, SLOT ( showDay( QDate ) ) ); |
512 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 515 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
513 | connect( mMonthView, SIGNAL(nextMonth() ), | 516 | connect( mMonthView, SIGNAL(nextMonth() ), |
514 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); | 517 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); |
515 | connect( mMonthView, SIGNAL(prevMonth() ), | 518 | connect( mMonthView, SIGNAL(prevMonth() ), |
516 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 519 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
517 | mMonthView->updateConfig(); | 520 | mMonthView->updateConfig(); |
518 | } | 521 | } |
519 | 522 | ||
520 | globalFlagBlockAgenda = 1; | 523 | globalFlagBlockAgenda = 1; |
521 | //mFlagShowNextxDays = false; | 524 | //mFlagShowNextxDays = false; |
522 | // if(mMonthView == mCurrentView) return; | 525 | // if(mMonthView == mCurrentView) return; |
526 | mMainView->dateNavigator()->blockSignals( true ); | ||
523 | mMainView->dateNavigator()->selectMonth(); | 527 | mMainView->dateNavigator()->selectMonth(); |
528 | mMainView->dateNavigator()->blockSignals( false); | ||
524 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); | 529 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); |
525 | //mMonthView->showDates(tmpList.first(), tmpList.last()); | 530 | //mMonthView->showDates(tmpList.first(), tmpList.last()); |
526 | 531 | ||
527 | showView(mMonthView, true ); | 532 | showView(mMonthView, true ); |
528 | 533 | ||
529 | } | 534 | } |
530 | 535 | ||
531 | void KOViewManager::showTodoView() | 536 | void KOViewManager::showTodoView() |
532 | { | 537 | { |
533 | //mFlagShowNextxDays = false; | 538 | //mFlagShowNextxDays = false; |
534 | if ( !mTodoView ) { | 539 | if ( !mTodoView ) { |
535 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 540 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
536 | "KOViewManager::TodoView" ); | 541 | "KOViewManager::TodoView" ); |
537 | 542 | ||
538 | addView( mTodoView ); | 543 | addView( mTodoView ); |
539 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 544 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
540 | 545 | ||
541 | // SIGNALS/SLOTS FOR TODO VIEW | 546 | // SIGNALS/SLOTS FOR TODO VIEW |
542 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 547 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
543 | mMainView, SLOT( newTodo() ) ); | 548 | mMainView, SLOT( newTodo() ) ); |
544 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 549 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
545 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 550 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
546 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 551 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
547 | mMainView, SLOT( showTodo( Todo * ) ) ); | 552 | mMainView, SLOT( showTodo( Todo * ) ) ); |
548 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 553 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
549 | mMainView, SLOT( editTodo( Todo * ) ) ); | 554 | mMainView, SLOT( editTodo( Todo * ) ) ); |
550 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 555 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
551 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 556 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
552 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 557 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
553 | mMainView, SLOT( purgeCompleted() ) ); | 558 | mMainView, SLOT( purgeCompleted() ) ); |
554 | 559 | ||
555 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 560 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
556 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 561 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
557 | 562 | ||
558 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 563 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
559 | SLOT( updateConfig() ) ); | 564 | SLOT( updateConfig() ) ); |
560 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 565 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
561 | SLOT( updateTodo( Todo *, int ) ) ); | 566 | SLOT( updateTodo( Todo *, int ) ) ); |
562 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 567 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
563 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 568 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
564 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 569 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
565 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 570 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
566 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 571 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
567 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 572 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
568 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 573 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
569 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 574 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
570 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 575 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
571 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | 576 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); |
572 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 577 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
573 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 578 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
574 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 579 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
575 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 580 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
576 | KConfig *config = KOGlobals::config(); | 581 | KConfig *config = KOGlobals::config(); |
577 | mTodoView->restoreLayout(config,"Todo View"); | 582 | mTodoView->restoreLayout(config,"Todo View"); |
578 | mTodoView->setNavigator( mMainView->dateNavigator() ); | 583 | mTodoView->setNavigator( mMainView->dateNavigator() ); |
579 | } | 584 | } |
580 | 585 | ||
581 | globalFlagBlockAgenda = 1; | 586 | globalFlagBlockAgenda = 1; |
582 | showView( mTodoView, true ); | 587 | showView( mTodoView, true ); |
583 | 588 | ||
584 | } | 589 | } |
585 | 590 | ||
586 | void KOViewManager::showJournalView() | 591 | void KOViewManager::showJournalView() |
587 | { | 592 | { |
588 | //mFlagShowNextxDays = false; | 593 | //mFlagShowNextxDays = false; |
589 | if (!mJournalView) { | 594 | if (!mJournalView) { |
590 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 595 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
591 | "KOViewManager::JournalView"); | 596 | "KOViewManager::JournalView"); |
592 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 597 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
593 | SLOT( updateConfig() ) ); | 598 | SLOT( updateConfig() ) ); |
594 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 599 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
595 | addView(mJournalView); | 600 | addView(mJournalView); |
596 | } | 601 | } |
597 | 602 | ||
598 | showView(mJournalView); | 603 | showView(mJournalView); |
599 | } | 604 | } |
600 | 605 | ||
601 | void KOViewManager::showTimeSpanView() | 606 | void KOViewManager::showTimeSpanView() |
602 | { | 607 | { |
603 | //mFlagShowNextxDays = false; | 608 | //mFlagShowNextxDays = false; |
604 | if (!mTimeSpanView) { | 609 | if (!mTimeSpanView) { |
605 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 610 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
606 | "KOViewManager::TimeSpanView"); | 611 | "KOViewManager::TimeSpanView"); |
607 | addView(mTimeSpanView); | 612 | addView(mTimeSpanView); |
608 | 613 | ||
609 | mTimeSpanView->readSettings(); | 614 | mTimeSpanView->readSettings(); |
610 | } | 615 | } |
611 | 616 | ||
612 | showView(mTimeSpanView); | 617 | showView(mTimeSpanView); |
613 | } | 618 | } |
614 | 619 | ||
615 | Incidence *KOViewManager::currentSelection() | 620 | Incidence *KOViewManager::currentSelection() |
616 | { | 621 | { |
617 | if (!mCurrentView) return 0; | 622 | if (!mCurrentView) return 0; |
618 | if ( mCurrentView == mListView ) { | 623 | if ( mCurrentView == mListView ) { |
619 | if ( mListView->currentItem() ) | 624 | if ( mListView->currentItem() ) |
620 | return mListView->currentItem(); | 625 | return mListView->currentItem(); |
621 | } | 626 | } |
622 | return mCurrentView->selectedIncidences().first(); | 627 | return mCurrentView->selectedIncidences().first(); |
623 | } | 628 | } |
624 | 629 | ||
625 | QDate KOViewManager::currentSelectionDate() | 630 | QDate KOViewManager::currentSelectionDate() |
626 | { | 631 | { |
627 | QDate qd; | 632 | QDate qd; |
628 | if (mCurrentView) { | 633 | if (mCurrentView) { |
629 | DateList qvl = mCurrentView->selectedDates(); | 634 | DateList qvl = mCurrentView->selectedDates(); |
630 | if (!qvl.isEmpty()) qd = qvl.first(); | 635 | if (!qvl.isEmpty()) qd = qvl.first(); |
631 | } | 636 | } |
632 | return qd; | 637 | return qd; |
633 | } | 638 | } |
634 | 639 | ||
635 | void KOViewManager::addView(KOrg::BaseView *view) | 640 | void KOViewManager::addView(KOrg::BaseView *view) |
636 | { | 641 | { |
637 | #if QT_VERSION >= 0x030000 | 642 | #if QT_VERSION >= 0x030000 |
638 | mMainView->viewStack()->addWidget( view ); | 643 | mMainView->viewStack()->addWidget( view ); |
639 | #else | 644 | #else |
640 | mMainView->viewStack()->addWidget( view, 1 ); | 645 | mMainView->viewStack()->addWidget( view, 1 ); |
641 | #endif | 646 | #endif |
642 | } | 647 | } |
643 | 648 | ||
644 | void KOViewManager::setDocumentId( const QString &id ) | 649 | void KOViewManager::setDocumentId( const QString &id ) |
645 | { | 650 | { |
646 | if (mTodoView) mTodoView->setDocumentId( id ); | 651 | if (mTodoView) mTodoView->setDocumentId( id ); |
647 | } | 652 | } |
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index 137eb2d..66ab138 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h | |||
@@ -1,118 +1,118 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 | 3 | Copyright (c) 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef KOVIEWMANAGER_H | 24 | #ifndef KOVIEWMANAGER_H |
25 | #define KOVIEWMANAGER_H | 25 | #define KOVIEWMANAGER_H |
26 | 26 | ||
27 | #include <qobject.h> | 27 | #include <qobject.h> |
28 | 28 | ||
29 | #include <korganizer/baseview.h> | 29 | #include <korganizer/baseview.h> |
30 | 30 | ||
31 | class CalendarView; | 31 | class CalendarView; |
32 | 32 | ||
33 | class KOListView; | 33 | class KOListView; |
34 | class KOAgendaView; | 34 | class KOAgendaView; |
35 | class KOMonthView; | 35 | class KOMonthView; |
36 | class KOTimeSpanView; | 36 | class KOTimeSpanView; |
37 | class KOTodoView; | 37 | class KOTodoView; |
38 | class KOWhatsNextView; | 38 | class KOWhatsNextView; |
39 | class KOJournalView; | 39 | class KOJournalView; |
40 | 40 | ||
41 | using namespace KCal; | 41 | using namespace KCal; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | This class manages the views of the calendar. It owns the objects and handles | 44 | This class manages the views of the calendar. It owns the objects and handles |
45 | creation and selection. | 45 | creation and selection. |
46 | */ | 46 | */ |
47 | class KOViewManager : public QObject | 47 | class KOViewManager : public QObject |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | KOViewManager( CalendarView * ); | 51 | KOViewManager( CalendarView * ); |
52 | virtual ~KOViewManager(); | 52 | virtual ~KOViewManager(); |
53 | 53 | ||
54 | /** changes the view to be the currently selected view */ | 54 | /** changes the view to be the currently selected view */ |
55 | void showView(KOrg::BaseView *, bool fullScreen = false ); | 55 | void showView(KOrg::BaseView *, bool fullScreen = false ); |
56 | void updateWNview(); | 56 | void updateWNview(); |
57 | void readSettings(KConfig *config); | 57 | void readSettings(KConfig *config); |
58 | void writeSettings(KConfig *config); | 58 | void writeSettings(KConfig *config); |
59 | bool showsNextDays(); | 59 | bool showsNextDays(); |
60 | /** Read which view was shown last from config file */ | 60 | /** Read which view was shown last from config file */ |
61 | void readCurrentView(KConfig *); | 61 | void readCurrentView(KConfig *); |
62 | /** Write which view is currently shown to config file */ | 62 | /** Write which view is currently shown to config file */ |
63 | void writeCurrentView(KConfig *); | 63 | void writeCurrentView(KConfig *); |
64 | 64 | ||
65 | KOrg::BaseView *currentView(); | 65 | KOrg::BaseView *currentView(); |
66 | 66 | ||
67 | void setDocumentId( const QString & ); | 67 | void setDocumentId( const QString & ); |
68 | 68 | ||
69 | void updateView( const QDate &start, const QDate &end ); | 69 | void updateView( const QDate &start, const QDate &end ); |
70 | 70 | ||
71 | void raiseCurrentView( bool fullScreen = false ); | 71 | void raiseCurrentView( bool fullScreen = false , bool updateView = false); |
72 | 72 | ||
73 | void addView(KOrg::BaseView *); | 73 | void addView(KOrg::BaseView *); |
74 | 74 | ||
75 | Incidence *currentSelection(); | 75 | Incidence *currentSelection(); |
76 | QDate currentSelectionDate(); | 76 | QDate currentSelectionDate(); |
77 | 77 | ||
78 | KOAgendaView *agendaView() const { return mAgendaView; } | 78 | KOAgendaView *agendaView() const { return mAgendaView; } |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void printWNV(); | 81 | void printWNV(); |
82 | void signalFullScreen( bool ); | 82 | void signalFullScreen( bool ); |
83 | void signalAgendaView( bool ); | 83 | void signalAgendaView( bool ); |
84 | public slots: | 84 | public slots: |
85 | void showDateView( int, QDate ); | 85 | void showDateView( int, QDate ); |
86 | void updateView(); | 86 | void updateView(); |
87 | void showWhatsNextView(); | 87 | void showWhatsNextView(); |
88 | void showListView(); | 88 | void showListView(); |
89 | void showAgendaView( bool fullScreen = false ); | 89 | void showAgendaView( bool fullScreen = false ); |
90 | void showDayView(); | 90 | void showDayView(); |
91 | void showWorkWeekView(); | 91 | void showWorkWeekView(); |
92 | void showWeekView(); | 92 | void showWeekView(); |
93 | void showNextXView(); | 93 | void showNextXView(); |
94 | void showMonthView(); | 94 | void showMonthView(); |
95 | void showTodoView(); | 95 | void showTodoView(); |
96 | void showJournalView(); | 96 | void showJournalView(); |
97 | void showTimeSpanView(); | 97 | void showTimeSpanView(); |
98 | 98 | ||
99 | private: | 99 | private: |
100 | CalendarView *mMainView; | 100 | CalendarView *mMainView; |
101 | 101 | ||
102 | int mCurrentAgendaView; | 102 | int mCurrentAgendaView; |
103 | KOAgendaView *mAgendaView; | 103 | KOAgendaView *mAgendaView; |
104 | KOListView *mListView; | 104 | KOListView *mListView; |
105 | KOMonthView *mMonthView; | 105 | KOMonthView *mMonthView; |
106 | KOTodoView *mTodoView; | 106 | KOTodoView *mTodoView; |
107 | KOWhatsNextView *mWhatsNextView; | 107 | KOWhatsNextView *mWhatsNextView; |
108 | KOJournalView *mJournalView; | 108 | KOJournalView *mJournalView; |
109 | KOTimeSpanView *mTimeSpanView; | 109 | KOTimeSpanView *mTimeSpanView; |
110 | 110 | ||
111 | KOrg::BaseView *mCurrentView; // currently active event view | 111 | KOrg::BaseView *mCurrentView; // currently active event view |
112 | 112 | ||
113 | int mAgendaViewMode; | 113 | int mAgendaViewMode; |
114 | bool mFlagShowNextxDays; | 114 | bool mFlagShowNextxDays; |
115 | 115 | ||
116 | }; | 116 | }; |
117 | 117 | ||
118 | #endif | 118 | #endif |