summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-03-24 07:45:52 (UTC)
committer umopapisdn <umopapisdn>2003-03-24 07:45:52 (UTC)
commit4a0041efd5cc7e08063c09b02858fcd9c2b59880 (patch) (unidiff)
tree3948d60e0b94a2a821b4d87c0b1b985c5abdbff8
parent0e1275a67cae2435c0ac8cee2252f91737c2e10a (diff)
downloadopie-4a0041efd5cc7e08063c09b02858fcd9c2b59880.zip
opie-4a0041efd5cc7e08063c09b02858fcd9c2b59880.tar.gz
opie-4a0041efd5cc7e08063c09b02858fcd9c2b59880.tar.bz2
Bugfix: (bug #0000722) - Date-Popup in calendar-find dialog only appears shortly and then closes. This is due to the fact that the date-popup
appears on top of the button just pressed, and when the mouseup event fires, it is on the date-popup, so this fix just moves the find dialog to the topleft corner, which makes sure that the date-popup doesn't appear underneath the clicking position.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index db2058b..fa509d9 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -719,318 +719,319 @@ void DateBook::reload()
719 719
720void DateBook::flush() 720void DateBook::flush()
721{ 721{
722 syncing = TRUE; 722 syncing = TRUE;
723 db->save(); 723 db->save();
724} 724}
725 725
726void DateBook::timerEvent( QTimerEvent *e ) 726void 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
736void DateBook::changeClock( bool newClock ) 736void 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
745void DateBook::changeWeek( bool m ) 745void 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
752void DateBook::slotToday() 752void 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
758void DateBook::closeEvent( QCloseEvent *e ) 758void 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"
787void DateBook::slotNewEventFromKey( const QString &str ) 787void 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 } else if ( views->visibleWidget() == weekLstView ) { 811 } else if ( views->visibleWidget() == weekLstView ) {
812 QDate d = weekLstView->date(); 812 QDate d = weekLstView->date();
813 start = end = d; 813 start = end = d;
814 start.setTime( QTime( 10, 0 ) ); 814 start.setTime( QTime( 10, 0 ) );
815 end.setTime( QTime( 12, 0 ) ); 815 end.setTime( QTime( 12, 0 ) );
816 } 816 }
817 slotNewEntry(start, end, str); 817 slotNewEntry(start, end, str);
818} 818}
819void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { 819void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) {
820 // argh! This really needs to be encapsulated in a class 820 // argh! This really needs to be encapsulated in a class
821 // or function. 821 // or function.
822 QDialog newDlg( this, 0, TRUE ); 822 QDialog newDlg( this, 0, TRUE );
823 newDlg.setCaption( DateEntryBase::tr("New Event") ); 823 newDlg.setCaption( DateEntryBase::tr("New Event") );
824 DateEntry *e; 824 DateEntry *e;
825 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 825 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
826 QScrollView *sv = new QScrollView( &newDlg ); 826 QScrollView *sv = new QScrollView( &newDlg );
827 sv->setResizePolicy( QScrollView::AutoOneFit ); 827 sv->setResizePolicy( QScrollView::AutoOneFit );
828 sv->setFrameStyle( QFrame::NoFrame ); 828 sv->setFrameStyle( QFrame::NoFrame );
829 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 829 sv->setHScrollBarMode( QScrollView::AlwaysOff );
830 vb->addWidget( sv ); 830 vb->addWidget( sv );
831 831
832 Event ev; 832 Event ev;
833 ev.setDescription( str ); 833 ev.setDescription( str );
834 // When the new gui comes in, change this... 834 // When the new gui comes in, change this...
835 ev.setLocation( tr("(Unknown)") ); 835 ev.setLocation( tr("(Unknown)") );
836 ev.setStart( start ); 836 ev.setStart( start );
837 ev.setEnd( end ); 837 ev.setEnd( end );
838 838
839 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 839 e = new DateEntry( onMonday, ev, ampm, &newDlg );
840 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 840 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
841 sv->addChild( e ); 841 sv->addChild( e );
842#if defined(Q_WS_QWS) || defined(_WS_QWS_) 842#if defined(Q_WS_QWS) || defined(_WS_QWS_)
843 newDlg.showMaximized(); 843 newDlg.showMaximized();
844#endif 844#endif
845 while (newDlg.exec()) { 845 while (newDlg.exec()) {
846 ev = e->event(); 846 ev = e->event();
847 ev.assignUid(); 847 ev.assignUid();
848 QString error = checkEvent( ev ); 848 QString error = checkEvent( ev );
849 if ( !error.isNull() ) { 849 if ( !error.isNull() ) {
850 if ( QMessageBox::warning( this, tr("Error!"), 850 if ( QMessageBox::warning( this, tr("Error!"),
851 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 851 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
852 continue; 852 continue;
853 } 853 }
854 db->addEvent( ev ); 854 db->addEvent( ev );
855 emit newEvent(); 855 emit newEvent();
856 break; 856 break;
857 } 857 }
858} 858}
859 859
860void DateBook::setDocument( const QString &filename ) 860void DateBook::setDocument( const QString &filename )
861{ 861{
862 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 862 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
863 863
864 QValueList<Event> tl = Event::readVCalendar( filename ); 864 QValueList<Event> tl = Event::readVCalendar( filename );
865 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 865 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
866 db->addEvent( *it ); 866 db->addEvent( *it );
867 } 867 }
868} 868}
869 869
870static const char * beamfile = "/tmp/obex/event.vcs"; 870static const char * beamfile = "/tmp/obex/event.vcs";
871 871
872void DateBook::beamEvent( const Event &e ) 872void DateBook::beamEvent( const Event &e )
873{ 873{
874 qDebug("trying to beamn"); 874 qDebug("trying to beamn");
875 unlink( beamfile ); // delete if exists 875 unlink( beamfile ); // delete if exists
876 mkdir("/tmp/obex/", 0755); 876 mkdir("/tmp/obex/", 0755);
877 Event::writeVCalendar( beamfile, e ); 877 Event::writeVCalendar( beamfile, e );
878 Ir *ir = new Ir( this ); 878 Ir *ir = new Ir( this );
879 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 879 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
880 QString description = e.description(); 880 QString description = e.description();
881 ir->send( beamfile, description, "text/x-vCalendar" ); 881 ir->send( beamfile, description, "text/x-vCalendar" );
882} 882}
883 883
884void DateBook::beamDone( Ir *ir ) 884void DateBook::beamDone( Ir *ir )
885{ 885{
886 delete ir; 886 delete ir;
887 unlink( beamfile ); 887 unlink( beamfile );
888} 888}
889 889
890void DateBook::slotFind() 890void DateBook::slotFind()
891{ 891{
892 // move it to the day view... 892 // move it to the day view...
893 viewDay(); 893 viewDay();
894 FindDialog frmFind( "Calendar", this ); 894 FindDialog frmFind( "Calendar", this );
895 frmFind.setUseDate( true ); 895 frmFind.setUseDate( true );
896 frmFind.setDate( currentDate() ); 896 frmFind.setDate( currentDate() );
897 QObject::connect( &frmFind, 897 QObject::connect( &frmFind,
898 SIGNAL(signalFindClicked(const QString&, const QDate&, 898 SIGNAL(signalFindClicked(const QString&, const QDate&,
899 bool, bool, int)), 899 bool, bool, int)),
900 this, 900 this,
901 SLOT(slotDoFind(const QString&, const QDate&, 901 SLOT(slotDoFind(const QString&, const QDate&,
902 bool, bool, int)) ); 902 bool, bool, int)) );
903 QObject::connect( this, 903 QObject::connect( this,
904 SIGNAL(signalNotFound()), 904 SIGNAL(signalNotFound()),
905 &frmFind, 905 &frmFind,
906 SLOT(slotNotFound()) ); 906 SLOT(slotNotFound()) );
907 QObject::connect( this, 907 QObject::connect( this,
908 SIGNAL(signalWrapAround()), 908 SIGNAL(signalWrapAround()),
909 &frmFind, 909 &frmFind,
910 SLOT(slotWrapAround()) ); 910 SLOT(slotWrapAround()) );
911 frmFind.move(0,0);
911 frmFind.exec(); 912 frmFind.exec();
912 inSearch = false; 913 inSearch = false;
913} 914}
914 915
915bool catComp( QArray<int> cats, int category ) 916bool catComp( QArray<int> cats, int category )
916{ 917{
917 bool returnMe; 918 bool returnMe;
918 int i, 919 int i,
919 count; 920 count;
920 921
921 count = int(cats.count()); 922 count = int(cats.count());
922 returnMe = false; 923 returnMe = false;
923 if ( (category == -1 && count == 0) || category == -2 ) 924 if ( (category == -1 && count == 0) || category == -2 )
924 returnMe = true; 925 returnMe = true;
925 else { 926 else {
926 for ( i = 0; i < count; i++ ) { 927 for ( i = 0; i < count; i++ ) {
927 if ( category == cats[i] ) { 928 if ( category == cats[i] ) {
928 returnMe = true; 929 returnMe = true;
929 break; 930 break;
930 } 931 }
931 } 932 }
932 } 933 }
933 return returnMe; 934 return returnMe;
934} 935}
935 936
936 937
937void DateBook::slotDoFind( const QString& txt, const QDate &dt, 938void DateBook::slotDoFind( const QString& txt, const QDate &dt,
938 bool caseSensitive, bool /*backwards*/, 939 bool caseSensitive, bool /*backwards*/,
939 int category ) 940 int category )
940{ 941{
941 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 942 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
942 next; 943 next;
943 944
944 QRegExp r( txt ); 945 QRegExp r( txt );
945 r.setCaseSensitive( caseSensitive ); 946 r.setCaseSensitive( caseSensitive );
946 947
947 948
948 static Event rev, 949 static Event rev,
949 nonrev; 950 nonrev;
950 if ( !inSearch ) { 951 if ( !inSearch ) {
951 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 952 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
952 nonrev.setStart( rev.start() ); 953 nonrev.setStart( rev.start() );
953 inSearch = true; 954 inSearch = true;
954 } 955 }
955 static QDate searchDate = dt; 956 static QDate searchDate = dt;
956 static bool wrapAround = true; 957 static bool wrapAround = true;
957 bool candidtate; 958 bool candidtate;
958 candidtate = false; 959 candidtate = false;
959 960
960 QValueList<Event> repeats = db->getRawRepeats(); 961 QValueList<Event> repeats = db->getRawRepeats();
961 962
962 // find the candidate for the first repeat that matches... 963 // find the candidate for the first repeat that matches...
963 QValueListConstIterator<Event> it; 964 QValueListConstIterator<Event> it;
964 QDate start = dt; 965 QDate start = dt;
965 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 966 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
966 if ( catComp( (*it).categories(), category ) ) { 967 if ( catComp( (*it).categories(), category ) ) {
967 while ( nextOccurance( *it, start, next ) ) { 968 while ( nextOccurance( *it, start, next ) ) {
968 if ( next < dtEnd ) { 969 if ( next < dtEnd ) {
969 if ( (*it).match( r ) && !(next <= rev.start()) ) { 970 if ( (*it).match( r ) && !(next <= rev.start()) ) {
970 rev = *it; 971 rev = *it;
971 dtEnd = next; 972 dtEnd = next;
972 rev.setStart( next ); 973 rev.setStart( next );
973 candidtate = true; 974 candidtate = true;
974 wrapAround = true; 975 wrapAround = true;
975 start = dt; 976 start = dt;
976 break; 977 break;
977 } else 978 } else
978 start = next.date().addDays( 1 ); 979 start = next.date().addDays( 1 );
979 } 980 }
980 } 981 }
981 } 982 }
982 } 983 }
983 984
984 // now the for first non repeat... 985 // now the for first non repeat...
985 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 986 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
986 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 987 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
987 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 988 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
988 if ( catComp( (*it).categories(), category ) ) { 989 if ( catComp( (*it).categories(), category ) ) {
989 if ( (*it).start() < dtEnd ) { 990 if ( (*it).start() < dtEnd ) {
990 if ( (*it).match( r ) && !(*it <= nonrev) ) { 991 if ( (*it).match( r ) && !(*it <= nonrev) ) {
991 nonrev = *it; 992 nonrev = *it;
992 dtEnd = nonrev.start(); 993 dtEnd = nonrev.start();
993 candidtate = true; 994 candidtate = true;
994 wrapAround = true; 995 wrapAround = true;
995 break; 996 break;
996 } 997 }
997 } 998 }
998 } 999 }
999 } 1000 }
1000 if ( candidtate ) { 1001 if ( candidtate ) {
1001 dayView->setStartViewTime( dtEnd.time().hour() ); 1002 dayView->setStartViewTime( dtEnd.time().hour() );
1002 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1003 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1003 dtEnd.date().day() ); 1004 dtEnd.date().day() );
1004 } else { 1005 } else {
1005 if ( wrapAround ) { 1006 if ( wrapAround ) {
1006 emit signalWrapAround(); 1007 emit signalWrapAround();
1007 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1008 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1008 nonrev.setStart( rev.start() ); 1009 nonrev.setStart( rev.start() );
1009 } else 1010 } else
1010 emit signalNotFound(); 1011 emit signalNotFound();
1011 wrapAround = !wrapAround; 1012 wrapAround = !wrapAround;
1012 } 1013 }
1013} 1014}
1014 1015
1015Event DateBookDBHack::eventByUID(int uid) { 1016Event DateBookDBHack::eventByUID(int uid) {
1016 1017
1017 // FIXME: Dirty Hacks to get hold of the private event lists 1018 // FIXME: Dirty Hacks to get hold of the private event lists
1018 QDate start; 1019 QDate start;
1019 QDate end=start.addDays(-1); 1020 QDate end=start.addDays(-1);
1020 QValueList<Event> myEventList=getNonRepeatingEvents(start,end); 1021 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
1021 QValueList<Event> myRepeatEvents=getRawRepeats(); 1022 QValueList<Event> myRepeatEvents=getRawRepeats();
1022 1023
1023 QValueList<Event>::ConstIterator it; 1024 QValueList<Event>::ConstIterator it;
1024 1025
1025 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1026 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1026 if ((*it).uid() == uid) return *it; 1027 if ((*it).uid() == uid) return *it;
1027 } 1028 }
1028 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1029 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1029 if ((*it).uid() == uid) return *it; 1030 if ((*it).uid() == uid) return *it;
1030 } 1031 }
1031 1032
1032 qDebug("Event not found: uid=%d\n", uid); 1033 qDebug("Event not found: uid=%d\n", uid);
1033 Event ev; 1034 Event ev;
1034 return ev; // return at least 1035 return ev; // return at least
1035} 1036}
1036 1037