-rw-r--r-- | core/pim/datebook/datebook.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 7dcf156..db2058b 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -683,257 +683,262 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) | |||
683 | if ( cur ) { | 683 | if ( cur ) { |
684 | if ( cur == dayView ) | 684 | if ( cur == dayView ) |
685 | viewWeek(); | 685 | viewWeek(); |
686 | else if ( cur == weekView ) | 686 | else if ( cur == weekView ) |
687 | viewWeekLst(); | 687 | viewWeekLst(); |
688 | else if ( cur == weekLstView ) | 688 | else if ( cur == weekLstView ) |
689 | viewMonth(); | 689 | viewMonth(); |
690 | else if ( cur == monthView ) | 690 | else if ( cur == monthView ) |
691 | viewDay(); | 691 | viewDay(); |
692 | needShow = TRUE; | 692 | needShow = TRUE; |
693 | } | 693 | } |
694 | } | 694 | } |
695 | } | 695 | } |
696 | if ( needShow ) { | 696 | if ( needShow ) { |
697 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 697 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
698 | showMaximized(); | 698 | showMaximized(); |
699 | #else | 699 | #else |
700 | show(); | 700 | show(); |
701 | #endif | 701 | #endif |
702 | raise(); | 702 | raise(); |
703 | QPEApplication::setKeepRunning(); | 703 | QPEApplication::setKeepRunning(); |
704 | setActiveWindow(); | 704 | setActiveWindow(); |
705 | } | 705 | } |
706 | } | 706 | } |
707 | 707 | ||
708 | void DateBook::reload() | 708 | void DateBook::reload() |
709 | { | 709 | { |
710 | db->reload(); | 710 | db->reload(); |
711 | if ( dayAction->isOn() ) | 711 | if ( dayAction->isOn() ) |
712 | viewDay(); | 712 | viewDay(); |
713 | else if ( weekAction->isOn() ) | 713 | else if ( weekAction->isOn() ) |
714 | viewWeek(); | 714 | viewWeek(); |
715 | else if ( monthAction->isOn() ) | 715 | else if ( monthAction->isOn() ) |
716 | viewMonth(); | 716 | viewMonth(); |
717 | syncing = FALSE; | 717 | syncing = FALSE; |
718 | } | 718 | } |
719 | 719 | ||
720 | void DateBook::flush() | 720 | void DateBook::flush() |
721 | { | 721 | { |
722 | syncing = TRUE; | 722 | syncing = TRUE; |
723 | db->save(); | 723 | db->save(); |
724 | } | 724 | } |
725 | 725 | ||
726 | void DateBook::timerEvent( QTimerEvent *e ) | 726 | void DateBook::timerEvent( QTimerEvent *e ) |
727 | { | 727 | { |
728 | if ( alarmCounter < 10 ) { | 728 | if ( alarmCounter < 10 ) { |
729 | alarmCounter++; | 729 | alarmCounter++; |
730 | Sound::soundAlarm(); | 730 | Sound::soundAlarm(); |
731 | } | 731 | } |
732 | else | 732 | else |
733 | killTimer( e->timerId() ); | 733 | killTimer( e->timerId() ); |
734 | } | 734 | } |
735 | 735 | ||
736 | void DateBook::changeClock( bool newClock ) | 736 | void DateBook::changeClock( bool newClock ) |
737 | { | 737 | { |
738 | ampm = newClock; | 738 | ampm = newClock; |
739 | // repaint the affected objects... | 739 | // repaint the affected objects... |
740 | if (dayView) dayView->redraw(); | 740 | if (dayView) dayView->redraw(); |
741 | if (weekView) weekView->redraw(); | 741 | if (weekView) weekView->redraw(); |
742 | if (weekLstView) weekLstView->redraw(); | 742 | if (weekLstView) weekLstView->redraw(); |
743 | } | 743 | } |
744 | 744 | ||
745 | void DateBook::changeWeek( bool m ) | 745 | void DateBook::changeWeek( bool m ) |
746 | { | 746 | { |
747 | /* no need to redraw, each widget catches. Do need to | 747 | /* no need to redraw, each widget catches. Do need to |
748 | store though for widgets we haven't made yet */ | 748 | store though for widgets we haven't made yet */ |
749 | onMonday = m; | 749 | onMonday = m; |
750 | } | 750 | } |
751 | 751 | ||
752 | void DateBook::slotToday() | 752 | void DateBook::slotToday() |
753 | { | 753 | { |
754 | // we need to view today using default view | 754 | // we need to view today using default view |
755 | viewDefault(QDate::currentDate()); | 755 | viewDefault(QDate::currentDate()); |
756 | } | 756 | } |
757 | 757 | ||
758 | void DateBook::closeEvent( QCloseEvent *e ) | 758 | void DateBook::closeEvent( QCloseEvent *e ) |
759 | { | 759 | { |
760 | if(syncing) { | 760 | if(syncing) { |
761 | /* no need to save, did that at flush */ | 761 | /* no need to save, did that at flush */ |
762 | e->accept(); | 762 | e->accept(); |
763 | return; | 763 | return; |
764 | } | 764 | } |
765 | 765 | ||
766 | // save settings will generate it's own error messages, no | 766 | // save settings will generate it's own error messages, no |
767 | // need to do checking ourselves. | 767 | // need to do checking ourselves. |
768 | saveSettings(); | 768 | saveSettings(); |
769 | if ( db->save() ) | 769 | if ( db->save() ) |
770 | e->accept(); | 770 | e->accept(); |
771 | else { | 771 | else { |
772 | if ( QMessageBox::critical( this, tr( "Out of space" ), | 772 | if ( QMessageBox::critical( this, tr( "Out of space" ), |
773 | tr("Calendar was unable to save\n" | 773 | tr("Calendar was unable to save\n" |
774 | "your changes.\n" | 774 | "your changes.\n" |
775 | "Free up some space and try again.\n" | 775 | "Free up some space and try again.\n" |
776 | "\nQuit anyway?"), | 776 | "\nQuit anyway?"), |
777 | QMessageBox::Yes|QMessageBox::Escape, | 777 | QMessageBox::Yes|QMessageBox::Escape, |
778 | QMessageBox::No|QMessageBox::Default ) | 778 | QMessageBox::No|QMessageBox::Default ) |
779 | != QMessageBox::No ) | 779 | != QMessageBox::No ) |
780 | e->accept(); | 780 | e->accept(); |
781 | else | 781 | else |
782 | e->ignore(); | 782 | e->ignore(); |
783 | } | 783 | } |
784 | } | 784 | } |
785 | 785 | ||
786 | // Entering directly from the "keyboard" | 786 | // Entering directly from the "keyboard" |
787 | void DateBook::slotNewEventFromKey( const QString &str ) | 787 | void DateBook::slotNewEventFromKey( const QString &str ) |
788 | { | 788 | { |
789 | if (syncing) { | 789 | if (syncing) { |
790 | QMessageBox::warning( this, tr("Calendar"), | 790 | QMessageBox::warning( this, tr("Calendar"), |
791 | tr( "Can not edit data, currently syncing") ); | 791 | tr( "Can not edit data, currently syncing") ); |
792 | return; | 792 | return; |
793 | } | 793 | } |
794 | 794 | ||
795 | // We get to here from a key pressed in the Day View | 795 | // We get to here from a key pressed in the Day View |
796 | // So we can assume some things. We want the string | 796 | // So we can assume some things. We want the string |
797 | // passed in to be part of the description. | 797 | // passed in to be part of the description. |
798 | QDateTime start, end; | 798 | QDateTime start, end; |
799 | if ( views->visibleWidget() == dayView ) { | 799 | if ( views->visibleWidget() == dayView ) { |
800 | dayView->selectedDates( start, end ); | 800 | dayView->selectedDates( start, end ); |
801 | } else if ( views->visibleWidget() == monthView ) { | 801 | } else if ( views->visibleWidget() == monthView ) { |
802 | QDate d = monthView->selectedDate(); | 802 | QDate d = monthView->selectedDate(); |
803 | start = end = d; | 803 | start = end = d; |
804 | start.setTime( QTime( 10, 0 ) ); | 804 | start.setTime( QTime( 10, 0 ) ); |
805 | end.setTime( QTime( 12, 0 ) ); | 805 | end.setTime( QTime( 12, 0 ) ); |
806 | } else if ( views->visibleWidget() == weekView ) { | 806 | } else if ( views->visibleWidget() == weekView ) { |
807 | QDate d = weekView->date(); | 807 | QDate d = weekView->date(); |
808 | start = end = d; | 808 | start = end = d; |
809 | start.setTime( QTime( 10, 0 ) ); | 809 | start.setTime( QTime( 10, 0 ) ); |
810 | end.setTime( QTime( 12, 0 ) ); | 810 | end.setTime( QTime( 12, 0 ) ); |
811 | } | 811 | } else if ( views->visibleWidget() == weekLstView ) { |
812 | QDate d = weekLstView->date(); | ||
813 | start = end = d; | ||
814 | start.setTime( QTime( 10, 0 ) ); | ||
815 | end.setTime( QTime( 12, 0 ) ); | ||
816 | } | ||
812 | slotNewEntry(start, end, str); | 817 | slotNewEntry(start, end, str); |
813 | } | 818 | } |
814 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { | 819 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { |
815 | // argh! This really needs to be encapsulated in a class | 820 | // argh! This really needs to be encapsulated in a class |
816 | // or function. | 821 | // or function. |
817 | QDialog newDlg( this, 0, TRUE ); | 822 | QDialog newDlg( this, 0, TRUE ); |
818 | newDlg.setCaption( DateEntryBase::tr("New Event") ); | 823 | newDlg.setCaption( DateEntryBase::tr("New Event") ); |
819 | DateEntry *e; | 824 | DateEntry *e; |
820 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); | 825 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); |
821 | QScrollView *sv = new QScrollView( &newDlg ); | 826 | QScrollView *sv = new QScrollView( &newDlg ); |
822 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 827 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
823 | sv->setFrameStyle( QFrame::NoFrame ); | 828 | sv->setFrameStyle( QFrame::NoFrame ); |
824 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 829 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
825 | vb->addWidget( sv ); | 830 | vb->addWidget( sv ); |
826 | 831 | ||
827 | Event ev; | 832 | Event ev; |
828 | ev.setDescription( str ); | 833 | ev.setDescription( str ); |
829 | // When the new gui comes in, change this... | 834 | // When the new gui comes in, change this... |
830 | ev.setLocation( tr("(Unknown)") ); | 835 | ev.setLocation( tr("(Unknown)") ); |
831 | ev.setStart( start ); | 836 | ev.setStart( start ); |
832 | ev.setEnd( end ); | 837 | ev.setEnd( end ); |
833 | 838 | ||
834 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); | 839 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); |
835 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); | 840 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); |
836 | sv->addChild( e ); | 841 | sv->addChild( e ); |
837 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 842 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
838 | newDlg.showMaximized(); | 843 | newDlg.showMaximized(); |
839 | #endif | 844 | #endif |
840 | while (newDlg.exec()) { | 845 | while (newDlg.exec()) { |
841 | ev = e->event(); | 846 | ev = e->event(); |
842 | ev.assignUid(); | 847 | ev.assignUid(); |
843 | QString error = checkEvent( ev ); | 848 | QString error = checkEvent( ev ); |
844 | if ( !error.isNull() ) { | 849 | if ( !error.isNull() ) { |
845 | if ( QMessageBox::warning( this, tr("Error!"), | 850 | if ( QMessageBox::warning( this, tr("Error!"), |
846 | error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) | 851 | error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) |
847 | continue; | 852 | continue; |
848 | } | 853 | } |
849 | db->addEvent( ev ); | 854 | db->addEvent( ev ); |
850 | emit newEvent(); | 855 | emit newEvent(); |
851 | break; | 856 | break; |
852 | } | 857 | } |
853 | } | 858 | } |
854 | 859 | ||
855 | void DateBook::setDocument( const QString &filename ) | 860 | void DateBook::setDocument( const QString &filename ) |
856 | { | 861 | { |
857 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 862 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
858 | 863 | ||
859 | QValueList<Event> tl = Event::readVCalendar( filename ); | 864 | QValueList<Event> tl = Event::readVCalendar( filename ); |
860 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 865 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
861 | db->addEvent( *it ); | 866 | db->addEvent( *it ); |
862 | } | 867 | } |
863 | } | 868 | } |
864 | 869 | ||
865 | static const char * beamfile = "/tmp/obex/event.vcs"; | 870 | static const char * beamfile = "/tmp/obex/event.vcs"; |
866 | 871 | ||
867 | void DateBook::beamEvent( const Event &e ) | 872 | void DateBook::beamEvent( const Event &e ) |
868 | { | 873 | { |
869 | qDebug("trying to beamn"); | 874 | qDebug("trying to beamn"); |
870 | unlink( beamfile ); // delete if exists | 875 | unlink( beamfile ); // delete if exists |
871 | mkdir("/tmp/obex/", 0755); | 876 | mkdir("/tmp/obex/", 0755); |
872 | Event::writeVCalendar( beamfile, e ); | 877 | Event::writeVCalendar( beamfile, e ); |
873 | Ir *ir = new Ir( this ); | 878 | Ir *ir = new Ir( this ); |
874 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 879 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
875 | QString description = e.description(); | 880 | QString description = e.description(); |
876 | ir->send( beamfile, description, "text/x-vCalendar" ); | 881 | ir->send( beamfile, description, "text/x-vCalendar" ); |
877 | } | 882 | } |
878 | 883 | ||
879 | void DateBook::beamDone( Ir *ir ) | 884 | void DateBook::beamDone( Ir *ir ) |
880 | { | 885 | { |
881 | delete ir; | 886 | delete ir; |
882 | unlink( beamfile ); | 887 | unlink( beamfile ); |
883 | } | 888 | } |
884 | 889 | ||
885 | void DateBook::slotFind() | 890 | void DateBook::slotFind() |
886 | { | 891 | { |
887 | // move it to the day view... | 892 | // move it to the day view... |
888 | viewDay(); | 893 | viewDay(); |
889 | FindDialog frmFind( "Calendar", this ); | 894 | FindDialog frmFind( "Calendar", this ); |
890 | frmFind.setUseDate( true ); | 895 | frmFind.setUseDate( true ); |
891 | frmFind.setDate( currentDate() ); | 896 | frmFind.setDate( currentDate() ); |
892 | QObject::connect( &frmFind, | 897 | QObject::connect( &frmFind, |
893 | SIGNAL(signalFindClicked(const QString&, const QDate&, | 898 | SIGNAL(signalFindClicked(const QString&, const QDate&, |
894 | bool, bool, int)), | 899 | bool, bool, int)), |
895 | this, | 900 | this, |
896 | SLOT(slotDoFind(const QString&, const QDate&, | 901 | SLOT(slotDoFind(const QString&, const QDate&, |
897 | bool, bool, int)) ); | 902 | bool, bool, int)) ); |
898 | QObject::connect( this, | 903 | QObject::connect( this, |
899 | SIGNAL(signalNotFound()), | 904 | SIGNAL(signalNotFound()), |
900 | &frmFind, | 905 | &frmFind, |
901 | SLOT(slotNotFound()) ); | 906 | SLOT(slotNotFound()) ); |
902 | QObject::connect( this, | 907 | QObject::connect( this, |
903 | SIGNAL(signalWrapAround()), | 908 | SIGNAL(signalWrapAround()), |
904 | &frmFind, | 909 | &frmFind, |
905 | SLOT(slotWrapAround()) ); | 910 | SLOT(slotWrapAround()) ); |
906 | frmFind.exec(); | 911 | frmFind.exec(); |
907 | inSearch = false; | 912 | inSearch = false; |
908 | } | 913 | } |
909 | 914 | ||
910 | bool catComp( QArray<int> cats, int category ) | 915 | bool catComp( QArray<int> cats, int category ) |
911 | { | 916 | { |
912 | bool returnMe; | 917 | bool returnMe; |
913 | int i, | 918 | int i, |
914 | count; | 919 | count; |
915 | 920 | ||
916 | count = int(cats.count()); | 921 | count = int(cats.count()); |
917 | returnMe = false; | 922 | returnMe = false; |
918 | if ( (category == -1 && count == 0) || category == -2 ) | 923 | if ( (category == -1 && count == 0) || category == -2 ) |
919 | returnMe = true; | 924 | returnMe = true; |
920 | else { | 925 | else { |
921 | for ( i = 0; i < count; i++ ) { | 926 | for ( i = 0; i < count; i++ ) { |
922 | if ( category == cats[i] ) { | 927 | if ( category == cats[i] ) { |
923 | returnMe = true; | 928 | returnMe = true; |
924 | break; | 929 | break; |
925 | } | 930 | } |
926 | } | 931 | } |
927 | } | 932 | } |
928 | return returnMe; | 933 | return returnMe; |
929 | } | 934 | } |
930 | 935 | ||
931 | 936 | ||
932 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, | 937 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, |
933 | bool caseSensitive, bool /*backwards*/, | 938 | bool caseSensitive, bool /*backwards*/, |
934 | int category ) | 939 | int category ) |
935 | { | 940 | { |
936 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), | 941 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), |
937 | next; | 942 | next; |
938 | 943 | ||
939 | QRegExp r( txt ); | 944 | QRegExp r( txt ); |