summaryrefslogtreecommitdiff
authortille <tille>2003-05-08 13:55:09 (UTC)
committer tille <tille>2003-05-08 13:55:09 (UTC)
commit0cb4111d34d9fe96731f48983e1ff2e67262db02 (patch) (unidiff)
treece6ec869ae7753ab0261e7ad075a10ad8b0a404b
parent78c60031b506b85dc20bd555d83486aeb831bf38 (diff)
downloadopie-0cb4111d34d9fe96731f48983e1ff2e67262db02.zip
opie-0cb4111d34d9fe96731f48983e1ff2e67262db02.tar.gz
opie-0cb4111d34d9fe96731f48983e1ff2e67262db02.tar.bz2
search stuff
and match, toRichText & toShortText in oevent
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp9
-rw-r--r--libopie/pim/ocontact.h3
-rw-r--r--libopie/pim/ocontactaccess.cpp13
-rw-r--r--libopie/pim/ocontactaccess.h6
-rw-r--r--libopie/pim/odatebookaccessbackend_xml.cpp18
-rw-r--r--libopie/pim/odatebookaccessbackend_xml.h1
-rw-r--r--libopie/pim/oevent.cpp41
-rw-r--r--libopie/pim/oevent.h2
-rw-r--r--libopie/pim/opimaccessbackend.h6
-rw-r--r--libopie/pim/opimaccesstemplate.h12
-rw-r--r--libopie/pim/opimrecord.h6
-rw-r--r--libopie/pim/otodo.h2
-rw-r--r--libopie/pim/otodoaccessvcal.cpp4
-rw-r--r--libopie/pim/otodoaccessvcal.h1
-rw-r--r--libopie/pim/otodoaccessxml.cpp16
-rw-r--r--libopie/pim/otodoaccessxml.h1
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp18
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h1
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h6
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp4
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.h1
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp16
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h1
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp13
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h6
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h12
-rw-r--r--libopie2/opiepim/core/opimrecord.h6
-rw-r--r--libopie2/opiepim/ocontact.cpp9
-rw-r--r--libopie2/opiepim/ocontact.h3
-rw-r--r--libopie2/opiepim/oevent.cpp41
-rw-r--r--libopie2/opiepim/oevent.h2
-rw-r--r--libopie2/opiepim/otodo.h2
32 files changed, 228 insertions, 54 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 96a5f65..a38b62b 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -758,389 +758,380 @@ QString OContact::fullName() const
758 758
759/*! 759/*!
760 Returns a list of the names of the children of the contact. 760 Returns a list of the names of the children of the contact.
761*/ 761*/
762QStringList OContact::childrenList() const 762QStringList OContact::childrenList() const
763{ 763{
764 return QStringList::split( " ", find( Qtopia::Children ) ); 764 return QStringList::split( " ", find( Qtopia::Children ) );
765} 765}
766 766
767/*! \fn void OContact::insertEmail( const QString &email ) 767/*! \fn void OContact::insertEmail( const QString &email )
768 768
769 Insert \a email into the email list. Ensures \a email can only be added 769 Insert \a email into the email list. Ensures \a email can only be added
770 once. If there is no default email address set, it sets it to the \a email. 770 once. If there is no default email address set, it sets it to the \a email.
771*/ 771*/
772 772
773/*! \fn void OContact::removeEmail( const QString &email ) 773/*! \fn void OContact::removeEmail( const QString &email )
774 774
775 Removes the \a email from the email list. If the default email was \a email, 775 Removes the \a email from the email list. If the default email was \a email,
776 then the default email address is assigned to the first email in the 776 then the default email address is assigned to the first email in the
777 email list 777 email list
778*/ 778*/
779 779
780/*! \fn void OContact::clearEmails() 780/*! \fn void OContact::clearEmails()
781 781
782 Clears the email list. 782 Clears the email list.
783 */ 783 */
784 784
785/*! \fn void OContact::insertEmails( const QStringList &emailList ) 785/*! \fn void OContact::insertEmails( const QStringList &emailList )
786 786
787 Appends the \a emailList to the exiting email list 787 Appends the \a emailList to the exiting email list
788 */ 788 */
789 789
790/*! 790/*!
791 Returns a list of email addresses belonging to the contact, including 791 Returns a list of email addresses belonging to the contact, including
792 the default email address. 792 the default email address.
793*/ 793*/
794QStringList OContact::emailList() const 794QStringList OContact::emailList() const
795{ 795{
796 QString emailStr = emails(); 796 QString emailStr = emails();
797 797
798 QStringList r; 798 QStringList r;
799 if ( !emailStr.isEmpty() ) { 799 if ( !emailStr.isEmpty() ) {
800 qDebug(" emailstr "); 800 qDebug(" emailstr ");
801 QStringList l = QStringList::split( emailSeparator(), emailStr ); 801 QStringList l = QStringList::split( emailSeparator(), emailStr );
802 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 802 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
803 r += (*it).simplifyWhiteSpace(); 803 r += (*it).simplifyWhiteSpace();
804 } 804 }
805 805
806 return r; 806 return r;
807} 807}
808 808
809/*! 809/*!
810 \overload 810 \overload
811 811
812 Generates the string for the contact to be filed as from the first, 812 Generates the string for the contact to be filed as from the first,
813 middle and last name of the contact. 813 middle and last name of the contact.
814*/ 814*/
815void OContact::setFileAs() 815void OContact::setFileAs()
816{ 816{
817 QString lastName, firstName, middleName, fileas; 817 QString lastName, firstName, middleName, fileas;
818 818
819 lastName = find( Qtopia::LastName ); 819 lastName = find( Qtopia::LastName );
820 firstName = find( Qtopia::FirstName ); 820 firstName = find( Qtopia::FirstName );
821 middleName = find( Qtopia::MiddleName ); 821 middleName = find( Qtopia::MiddleName );
822 if ( !lastName.isEmpty() && !firstName.isEmpty() 822 if ( !lastName.isEmpty() && !firstName.isEmpty()
823 && !middleName.isEmpty() ) 823 && !middleName.isEmpty() )
824 fileas = lastName + ", " + firstName + " " + middleName; 824 fileas = lastName + ", " + firstName + " " + middleName;
825 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 825 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
826 fileas = lastName + ", " + firstName; 826 fileas = lastName + ", " + firstName;
827 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 827 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
828 !middleName.isEmpty() ) 828 !middleName.isEmpty() )
829 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 829 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
830 + middleName + ( middleName.isEmpty() ? "" : " " ) 830 + middleName + ( middleName.isEmpty() ? "" : " " )
831 + lastName; 831 + lastName;
832 832
833 replace( Qtopia::FileAs, fileas ); 833 replace( Qtopia::FileAs, fileas );
834} 834}
835 835
836/*! 836/*!
837 \internal 837 \internal
838 Appends the contact information to \a buf. 838 Appends the contact information to \a buf.
839*/ 839*/
840void OContact::save( QString &buf ) const 840void OContact::save( QString &buf ) const
841{ 841{
842 static const QStringList SLFIELDS = fields(); 842 static const QStringList SLFIELDS = fields();
843 // I'm expecting "<Contact " in front of this... 843 // I'm expecting "<Contact " in front of this...
844 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 844 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
845 it != mMap.end(); ++it ) { 845 it != mMap.end(); ++it ) {
846 const QString &value = it.data(); 846 const QString &value = it.data();
847 int key = it.key(); 847 int key = it.key();
848 if ( !value.isEmpty() ) { 848 if ( !value.isEmpty() ) {
849 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 849 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
850 continue; 850 continue;
851 851
852 key -= Qtopia::AddressCategory+1; 852 key -= Qtopia::AddressCategory+1;
853 buf += SLFIELDS[key]; 853 buf += SLFIELDS[key];
854 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 854 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
855 } 855 }
856 } 856 }
857 buf += customToXml(); 857 buf += customToXml();
858 if ( categories().count() > 0 ) 858 if ( categories().count() > 0 )
859 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 859 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
860 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 860 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
861 // You need to close this yourself 861 // You need to close this yourself
862} 862}
863 863
864 864
865/*! 865/*!
866 \internal 866 \internal
867 Returns the list of fields belonging to a contact 867 Returns the list of fields belonging to a contact
868 Never change order of this list ! It has to be regarding 868 Never change order of this list ! It has to be regarding
869 enum AddressBookFields !! 869 enum AddressBookFields !!
870*/ 870*/
871QStringList OContact::fields() 871QStringList OContact::fields()
872{ 872{
873 QStringList list; 873 QStringList list;
874 874
875 list.append( "Title" ); // Not Used! 875 list.append( "Title" ); // Not Used!
876 list.append( "FirstName" ); 876 list.append( "FirstName" );
877 list.append( "MiddleName" ); 877 list.append( "MiddleName" );
878 list.append( "LastName" ); 878 list.append( "LastName" );
879 list.append( "Suffix" ); 879 list.append( "Suffix" );
880 list.append( "FileAs" ); 880 list.append( "FileAs" );
881 881
882 list.append( "JobTitle" ); 882 list.append( "JobTitle" );
883 list.append( "Department" ); 883 list.append( "Department" );
884 list.append( "Company" ); 884 list.append( "Company" );
885 list.append( "BusinessPhone" ); 885 list.append( "BusinessPhone" );
886 list.append( "BusinessFax" ); 886 list.append( "BusinessFax" );
887 list.append( "BusinessMobile" ); 887 list.append( "BusinessMobile" );
888 888
889 list.append( "DefaultEmail" ); 889 list.append( "DefaultEmail" );
890 list.append( "Emails" ); 890 list.append( "Emails" );
891 891
892 list.append( "HomePhone" ); 892 list.append( "HomePhone" );
893 list.append( "HomeFax" ); 893 list.append( "HomeFax" );
894 list.append( "HomeMobile" ); 894 list.append( "HomeMobile" );
895 895
896 list.append( "BusinessStreet" ); 896 list.append( "BusinessStreet" );
897 list.append( "BusinessCity" ); 897 list.append( "BusinessCity" );
898 list.append( "BusinessState" ); 898 list.append( "BusinessState" );
899 list.append( "BusinessZip" ); 899 list.append( "BusinessZip" );
900 list.append( "BusinessCountry" ); 900 list.append( "BusinessCountry" );
901 list.append( "BusinessPager" ); 901 list.append( "BusinessPager" );
902 list.append( "BusinessWebPage" ); 902 list.append( "BusinessWebPage" );
903 903
904 list.append( "Office" ); 904 list.append( "Office" );
905 list.append( "Profession" ); 905 list.append( "Profession" );
906 list.append( "Assistant" ); 906 list.append( "Assistant" );
907 list.append( "Manager" ); 907 list.append( "Manager" );
908 908
909 list.append( "HomeStreet" ); 909 list.append( "HomeStreet" );
910 list.append( "HomeCity" ); 910 list.append( "HomeCity" );
911 list.append( "HomeState" ); 911 list.append( "HomeState" );
912 list.append( "HomeZip" ); 912 list.append( "HomeZip" );
913 list.append( "HomeCountry" ); 913 list.append( "HomeCountry" );
914 list.append( "HomeWebPage" ); 914 list.append( "HomeWebPage" );
915 915
916 list.append( "Spouse" ); 916 list.append( "Spouse" );
917 list.append( "Gender" ); 917 list.append( "Gender" );
918 list.append( "Birthday" ); 918 list.append( "Birthday" );
919 list.append( "Anniversary" ); 919 list.append( "Anniversary" );
920 list.append( "Nickname" ); 920 list.append( "Nickname" );
921 list.append( "Children" ); 921 list.append( "Children" );
922 922
923 list.append( "Notes" ); 923 list.append( "Notes" );
924 list.append( "Groups" ); 924 list.append( "Groups" );
925 925
926 return list; 926 return list;
927} 927}
928 928
929 929
930/*! 930/*!
931 Sets the list of email address for contact to those contained in \a str. 931 Sets the list of email address for contact to those contained in \a str.
932 Email address should be separated by ';'s. 932 Email address should be separated by ';'s.
933*/ 933*/
934void OContact::setEmails( const QString &str ) 934void OContact::setEmails( const QString &str )
935{ 935{
936 replace( Qtopia::Emails, str ); 936 replace( Qtopia::Emails, str );
937 if ( str.isEmpty() ) 937 if ( str.isEmpty() )
938 setDefaultEmail( QString::null ); 938 setDefaultEmail( QString::null );
939} 939}
940 940
941/*! 941/*!
942 Sets the list of children for the contact to those contained in \a str. 942 Sets the list of children for the contact to those contained in \a str.
943*/ 943*/
944void OContact::setChildren( const QString &str ) 944void OContact::setChildren( const QString &str )
945{ 945{
946 replace( Qtopia::Children, str ); 946 replace( Qtopia::Children, str );
947} 947}
948 948
949/*! 949/*!
950 Returns TRUE if the contact matches the regular expression \a regexp.
951 Otherwise returns FALSE.
952*/
953bool OContact::match( const QString &regexp ) const
954{
955 return match(QRegExp(regexp));
956}
957
958/*!
959 \overload 950 \overload
960 Returns TRUE if the contact matches the regular expression \a regexp. 951 Returns TRUE if the contact matches the regular expression \a regexp.
961 Otherwise returns FALSE. 952 Otherwise returns FALSE.
962*/ 953*/
963bool OContact::match( const QRegExp &r ) const 954bool OContact::match( const QRegExp &r ) const
964{ 955{
965 bool match; 956 bool match;
966 match = false; 957 match = false;
967 QMap<int, QString>::ConstIterator it; 958 QMap<int, QString>::ConstIterator it;
968 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 959 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
969 if ( (*it).find( r ) > -1 ) { 960 if ( (*it).find( r ) > -1 ) {
970 match = true; 961 match = true;
971 break; 962 break;
972 } 963 }
973 } 964 }
974 return match; 965 return match;
975} 966}
976 967
977 968
978QString OContact::toShortText() const 969QString OContact::toShortText() const
979{ 970{
980 return ( fullName() ); 971 return ( fullName() );
981} 972}
982QString OContact::type() const 973QString OContact::type() const
983{ 974{
984 return QString::fromLatin1( "OContact" ); 975 return QString::fromLatin1( "OContact" );
985} 976}
986 977
987// Definition is missing ! (se) 978// Definition is missing ! (se)
988QMap<QString,QString> OContact::toExtraMap() const 979QMap<QString,QString> OContact::toExtraMap() const
989{ 980{
990 qWarning ("Function not implemented: OContact::toExtraMap()"); 981 qWarning ("Function not implemented: OContact::toExtraMap()");
991 QMap <QString,QString> useless; 982 QMap <QString,QString> useless;
992 return useless; 983 return useless;
993} 984}
994 985
995class QString OContact::recordField( int pos ) const 986class QString OContact::recordField( int pos ) const
996{ 987{
997 QStringList SLFIELDS = fields(); // ?? why this ? (se) 988 QStringList SLFIELDS = fields(); // ?? why this ? (se)
998 return SLFIELDS[pos]; 989 return SLFIELDS[pos];
999} 990}
1000 991
1001// In future releases, we should store birthday and anniversary 992// In future releases, we should store birthday and anniversary
1002// internally as QDate instead of QString ! 993// internally as QDate instead of QString !
1003// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 994// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1004 995
1005/*! \fn void OContact::setBirthday( const QDate& date ) 996/*! \fn void OContact::setBirthday( const QDate& date )
1006 Sets the birthday for the contact to \a date. If date is null 997 Sets the birthday for the contact to \a date. If date is null
1007 the current stored date will be removed. 998 the current stored date will be removed.
1008*/ 999*/
1009void OContact::setBirthday( const QDate &v ) 1000void OContact::setBirthday( const QDate &v )
1010{ 1001{
1011 if ( v.isNull() ){ 1002 if ( v.isNull() ){
1012 qWarning( "Remove Birthday"); 1003 qWarning( "Remove Birthday");
1013 replace( Qtopia::Birthday, QString::null ); 1004 replace( Qtopia::Birthday, QString::null );
1014 return; 1005 return;
1015 } 1006 }
1016 1007
1017 if ( v.isValid() ) 1008 if ( v.isValid() )
1018 replace( Qtopia::Birthday, OConversion::dateToString( v ) ); 1009 replace( Qtopia::Birthday, OConversion::dateToString( v ) );
1019 1010
1020} 1011}
1021 1012
1022 1013
1023/*! \fn void OContact::setAnniversary( const QDate &date ) 1014/*! \fn void OContact::setAnniversary( const QDate &date )
1024 Sets the anniversary of the contact to \a date. If date is 1015 Sets the anniversary of the contact to \a date. If date is
1025 null, the current stored date will be removed. 1016 null, the current stored date will be removed.
1026*/ 1017*/
1027void OContact::setAnniversary( const QDate &v ) 1018void OContact::setAnniversary( const QDate &v )
1028{ 1019{
1029 if ( v.isNull() ){ 1020 if ( v.isNull() ){
1030 qWarning( "Remove Anniversary"); 1021 qWarning( "Remove Anniversary");
1031 replace( Qtopia::Anniversary, QString::null ); 1022 replace( Qtopia::Anniversary, QString::null );
1032 return; 1023 return;
1033 } 1024 }
1034 1025
1035 if ( v.isValid() ) 1026 if ( v.isValid() )
1036 replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); 1027 replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
1037} 1028}
1038 1029
1039/*! \fn QDate OContact::birthday() const 1030/*! \fn QDate OContact::birthday() const
1040 Returns the birthday of the contact. 1031 Returns the birthday of the contact.
1041*/ 1032*/
1042QDate OContact::birthday() const 1033QDate OContact::birthday() const
1043{ 1034{
1044 QString str = find( Qtopia::Birthday ); 1035 QString str = find( Qtopia::Birthday );
1045 qWarning ("Birthday %s", str.latin1() ); 1036 qWarning ("Birthday %s", str.latin1() );
1046 if ( !str.isEmpty() ) 1037 if ( !str.isEmpty() )
1047 return OConversion::dateFromString ( str ); 1038 return OConversion::dateFromString ( str );
1048 else 1039 else
1049 return QDate(); 1040 return QDate();
1050} 1041}
1051 1042
1052 1043
1053/*! \fn QDate OContact::anniversary() const 1044/*! \fn QDate OContact::anniversary() const
1054 Returns the anniversary of the contact. 1045 Returns the anniversary of the contact.
1055*/ 1046*/
1056QDate OContact::anniversary() const 1047QDate OContact::anniversary() const
1057{ 1048{
1058 QDate empty; 1049 QDate empty;
1059 QString str = find( Qtopia::Anniversary ); 1050 QString str = find( Qtopia::Anniversary );
1060 qWarning ("Anniversary %s", str.latin1() ); 1051 qWarning ("Anniversary %s", str.latin1() );
1061 if ( !str.isEmpty() ) 1052 if ( !str.isEmpty() )
1062 return OConversion::dateFromString ( str ); 1053 return OConversion::dateFromString ( str );
1063 else 1054 else
1064 return empty; 1055 return empty;
1065} 1056}
1066 1057
1067 1058
1068void OContact::insertEmail( const QString &v ) 1059void OContact::insertEmail( const QString &v )
1069{ 1060{
1070 //qDebug("insertEmail %s", v.latin1()); 1061 //qDebug("insertEmail %s", v.latin1());
1071 QString e = v.simplifyWhiteSpace(); 1062 QString e = v.simplifyWhiteSpace();
1072 QString def = defaultEmail(); 1063 QString def = defaultEmail();
1073 1064
1074 // if no default, set it as the default email and don't insert 1065 // if no default, set it as the default email and don't insert
1075 if ( def.isEmpty() ) { 1066 if ( def.isEmpty() ) {
1076 setDefaultEmail( e ); // will insert into the list for us 1067 setDefaultEmail( e ); // will insert into the list for us
1077 return; 1068 return;
1078 } 1069 }
1079 1070
1080 // otherwise, insert assuming doesn't already exist 1071 // otherwise, insert assuming doesn't already exist
1081 QString emailsStr = find( Qtopia::Emails ); 1072 QString emailsStr = find( Qtopia::Emails );
1082 if ( emailsStr.contains( e )) 1073 if ( emailsStr.contains( e ))
1083 return; 1074 return;
1084 if ( !emailsStr.isEmpty() ) 1075 if ( !emailsStr.isEmpty() )
1085 emailsStr += emailSeparator(); 1076 emailsStr += emailSeparator();
1086 emailsStr += e; 1077 emailsStr += e;
1087 replace( Qtopia::Emails, emailsStr ); 1078 replace( Qtopia::Emails, emailsStr );
1088} 1079}
1089 1080
1090void OContact::removeEmail( const QString &v ) 1081void OContact::removeEmail( const QString &v )
1091{ 1082{
1092 QString e = v.simplifyWhiteSpace(); 1083 QString e = v.simplifyWhiteSpace();
1093 QString def = defaultEmail(); 1084 QString def = defaultEmail();
1094 QString emailsStr = find( Qtopia::Emails ); 1085 QString emailsStr = find( Qtopia::Emails );
1095 QStringList emails = emailList(); 1086 QStringList emails = emailList();
1096 1087
1097 // otherwise, must first contain it 1088 // otherwise, must first contain it
1098 if ( !emailsStr.contains( e ) ) 1089 if ( !emailsStr.contains( e ) )
1099 return; 1090 return;
1100 1091
1101 // remove it 1092 // remove it
1102 //qDebug(" removing email from list %s", e.latin1()); 1093 //qDebug(" removing email from list %s", e.latin1());
1103 emails.remove( e ); 1094 emails.remove( e );
1104 // reset the string 1095 // reset the string
1105 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 1096 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
1106 replace( Qtopia::Emails, emailsStr ); 1097 replace( Qtopia::Emails, emailsStr );
1107 1098
1108 // if default, then replace the default email with the first one 1099 // if default, then replace the default email with the first one
1109 if ( def == e ) { 1100 if ( def == e ) {
1110 //qDebug("removeEmail is default; setting new default"); 1101 //qDebug("removeEmail is default; setting new default");
1111 if ( !emails.count() ) 1102 if ( !emails.count() )
1112 clearEmails(); 1103 clearEmails();
1113 else // setDefaultEmail will remove e from the list 1104 else // setDefaultEmail will remove e from the list
1114 setDefaultEmail( emails.first() ); 1105 setDefaultEmail( emails.first() );
1115 } 1106 }
1116} 1107}
1117void OContact::clearEmails() 1108void OContact::clearEmails()
1118{ 1109{
1119 mMap.remove( Qtopia::DefaultEmail ); 1110 mMap.remove( Qtopia::DefaultEmail );
1120 mMap.remove( Qtopia::Emails ); 1111 mMap.remove( Qtopia::Emails );
1121} 1112}
1122void OContact::setDefaultEmail( const QString &v ) 1113void OContact::setDefaultEmail( const QString &v )
1123{ 1114{
1124 QString e = v.simplifyWhiteSpace(); 1115 QString e = v.simplifyWhiteSpace();
1125 1116
1126 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1117 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1127 replace( Qtopia::DefaultEmail, e ); 1118 replace( Qtopia::DefaultEmail, e );
1128 1119
1129 if ( !e.isEmpty() ) 1120 if ( !e.isEmpty() )
1130 insertEmail( e ); 1121 insertEmail( e );
1131 1122
1132} 1123}
1133 1124
1134void OContact::insertEmails( const QStringList &v ) 1125void OContact::insertEmails( const QStringList &v )
1135{ 1126{
1136 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1127 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1137 insertEmail( *it ); 1128 insertEmail( *it );
1138} 1129}
1139int OContact::rtti() { 1130int OContact::rtti() {
1140 return OPimResolver::AddressBook; 1131 return OPimResolver::AddressBook;
1141} 1132}
1142void OContact::setUid( int i ) 1133void OContact::setUid( int i )
1143{ 1134{
1144 OPimRecord::setUid(i); 1135 OPimRecord::setUid(i);
1145 replace( Qtopia::AddressUid , QString::number(i)); 1136 replace( Qtopia::AddressUid , QString::number(i));
1146} 1137}
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index 50f6176..0e6cbd2 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -1,242 +1,241 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13** See http://www.trolltech.com/gpl/ for GPL licensing information. 13** See http://www.trolltech.com/gpl/ for GPL licensing information.
14** 14**
15** Contact info@trolltech.com if any conditions of this licensing are 15** Contact info@trolltech.com if any conditions of this licensing are
16** not clear to you. 16** not clear to you.
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#ifndef __OCONTACT_H__ 20#ifndef __OCONTACT_H__
21#define __OCONTACT_H__ 21#define __OCONTACT_H__
22 22
23#include <opie/opimrecord.h> 23#include <opie/opimrecord.h>
24#include <qpe/recordfields.h> 24#include <qpe/recordfields.h>
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#if defined(QPC_TEMPLATEDLL) 29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
33#endif 33#endif
34 34
35class ContactPrivate; 35class ContactPrivate;
36 36
37/** 37/**
38 * OContact class represents a specialised PIM Record for contacts. 38 * OContact class represents a specialised PIM Record for contacts.
39 * It does store all kind of persopn related information. 39 * It does store all kind of persopn related information.
40 * 40 *
41 * @short Contact Container 41 * @short Contact Container
42 * @author TT, Stefan Eiler, Holger Freyther 42 * @author TT, Stefan Eiler, Holger Freyther
43 */ 43 */
44class QPC_EXPORT OContact : public OPimRecord 44class QPC_EXPORT OContact : public OPimRecord
45{ 45{
46 friend class DataSet; 46 friend class DataSet;
47public: 47public:
48 OContact(); 48 OContact();
49 OContact( const QMap<int, QString> &fromMap ); 49 OContact( const QMap<int, QString> &fromMap );
50 virtual ~OContact(); 50 virtual ~OContact();
51 51
52 /* 52 /*
53 * do we need to inline them 53 * do we need to inline them
54 * if yes do we need to inline them this way? 54 * if yes do we need to inline them this way?
55 * -zecke 55 * -zecke
56 */ 56 */
57 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 57 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
58 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 58 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
59 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 59 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
60 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 60 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
61 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 61 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
62 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 62 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
63 void setFileAs(); 63 void setFileAs();
64 64
65 // default email address 65 // default email address
66 void setDefaultEmail( const QString &v ); 66 void setDefaultEmail( const QString &v );
67 // inserts email to list and ensure's doesn't already exist 67 // inserts email to list and ensure's doesn't already exist
68 void insertEmail( const QString &v ); 68 void insertEmail( const QString &v );
69 void removeEmail( const QString &v ); 69 void removeEmail( const QString &v );
70 void clearEmails(); 70 void clearEmails();
71 void insertEmails( const QStringList &v ); 71 void insertEmails( const QStringList &v );
72 72
73 // home 73 // home
74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
83 83
84 // business 84 // business
85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
100 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 100 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
101 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 101 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
102 102
103 // personal 103 // personal
104 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 104 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
105 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 105 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
106 void setBirthday( const QDate &v ); 106 void setBirthday( const QDate &v );
107 void setAnniversary( const QDate &v ); 107 void setAnniversary( const QDate &v );
108 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 108 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
109 void setChildren( const QString &v ); 109 void setChildren( const QString &v );
110 110
111 // other 111 // other
112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
113 113
114 bool match( const QString &regexp ) const; 114 virtual bool match( const QRegExp &regexp ) const;
115 bool match( const QRegExp &regexp ) const;
116 115
117// // custom 116// // custom
118// void setCustomField( const QString &key, const QString &v ) 117// void setCustomField( const QString &key, const QString &v )
119// { replace(Custom- + key, v ); } 118// { replace(Custom- + key, v ); }
120 119
121 // name 120 // name
122 QString fullName() const; 121 QString fullName() const;
123 QString title() const { return find( Qtopia::Title ); } 122 QString title() const { return find( Qtopia::Title ); }
124 QString firstName() const { return find( Qtopia::FirstName ); } 123 QString firstName() const { return find( Qtopia::FirstName ); }
125 QString middleName() const { return find( Qtopia::MiddleName ); } 124 QString middleName() const { return find( Qtopia::MiddleName ); }
126 QString lastName() const { return find( Qtopia::LastName ); } 125 QString lastName() const { return find( Qtopia::LastName ); }
127 QString suffix() const { return find( Qtopia::Suffix ); } 126 QString suffix() const { return find( Qtopia::Suffix ); }
128 QString fileAs() const { return find( Qtopia::FileAs ); } 127 QString fileAs() const { return find( Qtopia::FileAs ); }
129 128
130 // email 129 // email
131 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 130 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
132 QStringList emailList() const; 131 QStringList emailList() const;
133 132
134 // home 133 // home
135 /* 134 /*
136 * OPimAddress address(enum Location)const; 135 * OPimAddress address(enum Location)const;
137 * would be some how nicer... 136 * would be some how nicer...
138 * -zecke 137 * -zecke
139 */ 138 */
140 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 139 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
141 QString homeCity() const { return find( Qtopia::HomeCity ); } 140 QString homeCity() const { return find( Qtopia::HomeCity ); }
142 QString homeState() const { return find( Qtopia::HomeState ); } 141 QString homeState() const { return find( Qtopia::HomeState ); }
143 QString homeZip() const { return find( Qtopia::HomeZip ); } 142 QString homeZip() const { return find( Qtopia::HomeZip ); }
144 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 143 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
145 QString homePhone() const { return find( Qtopia::HomePhone ); } 144 QString homePhone() const { return find( Qtopia::HomePhone ); }
146 QString homeFax() const { return find( Qtopia::HomeFax ); } 145 QString homeFax() const { return find( Qtopia::HomeFax ); }
147 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 146 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
148 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 147 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
149 /** Multi line string containing all non-empty address info in the form 148 /** Multi line string containing all non-empty address info in the form
150 * Street 149 * Street
151 * City, State Zip 150 * City, State Zip
152 * Country 151 * Country
153 */ 152 */
154 QString displayHomeAddress() const; 153 QString displayHomeAddress() const;
155 154
156 // business 155 // business
157 QString company() const { return find( Qtopia::Company ); } 156 QString company() const { return find( Qtopia::Company ); }
158 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 157 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
159 QString businessCity() const { return find( Qtopia::BusinessCity ); } 158 QString businessCity() const { return find( Qtopia::BusinessCity ); }
160 QString businessState() const { return find( Qtopia::BusinessState ); } 159 QString businessState() const { return find( Qtopia::BusinessState ); }
161 QString businessZip() const { return find( Qtopia::BusinessZip ); } 160 QString businessZip() const { return find( Qtopia::BusinessZip ); }
162 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 161 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
163 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 162 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
164 QString jobTitle() const { return find( Qtopia::JobTitle ); } 163 QString jobTitle() const { return find( Qtopia::JobTitle ); }
165 QString department() const { return find( Qtopia::Department ); } 164 QString department() const { return find( Qtopia::Department ); }
166 QString office() const { return find( Qtopia::Office ); } 165 QString office() const { return find( Qtopia::Office ); }
167 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 166 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
168 QString businessFax() const { return find( Qtopia::BusinessFax ); } 167 QString businessFax() const { return find( Qtopia::BusinessFax ); }
169 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 168 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
170 QString businessPager() const { return find( Qtopia::BusinessPager ); } 169 QString businessPager() const { return find( Qtopia::BusinessPager ); }
171 QString profession() const { return find( Qtopia::Profession ); } 170 QString profession() const { return find( Qtopia::Profession ); }
172 QString assistant() const { return find( Qtopia::Assistant ); } 171 QString assistant() const { return find( Qtopia::Assistant ); }
173 QString manager() const { return find( Qtopia::Manager ); } 172 QString manager() const { return find( Qtopia::Manager ); }
174 /** Multi line string containing all non-empty address info in the form 173 /** Multi line string containing all non-empty address info in the form
175 * Street 174 * Street
176 * City, State Zip 175 * City, State Zip
177 * Country 176 * Country
178 */ 177 */
179 QString displayBusinessAddress() const; 178 QString displayBusinessAddress() const;
180 179
181 //personal 180 //personal
182 QString spouse() const { return find( Qtopia::Spouse ); } 181 QString spouse() const { return find( Qtopia::Spouse ); }
183 QString gender() const { return find( Qtopia::Gender ); } 182 QString gender() const { return find( Qtopia::Gender ); }
184 QDate birthday() const; 183 QDate birthday() const;
185 QDate anniversary() const; 184 QDate anniversary() const;
186 QString nickname() const { return find( Qtopia::Nickname ); } 185 QString nickname() const { return find( Qtopia::Nickname ); }
187 QString children() const { return find( Qtopia::Children ); } 186 QString children() const { return find( Qtopia::Children ); }
188 QStringList childrenList() const; 187 QStringList childrenList() const;
189 188
190 // other 189 // other
191 QString notes() const { return find( Qtopia::Notes ); } 190 QString notes() const { return find( Qtopia::Notes ); }
192 QString groups() const { return find( Qtopia::Groups ); } 191 QString groups() const { return find( Qtopia::Groups ); }
193 QStringList groupList() const; 192 QStringList groupList() const;
194 193
195// // custom 194// // custom
196// const QString &customField( const QString &key ) 195// const QString &customField( const QString &key )
197// { return find( Custom- + key ); } 196// { return find( Custom- + key ); }
198 197
199 198
200 QString toRichText() const; 199 QString toRichText() const;
201 QMap<int, QString> toMap() const; 200 QMap<int, QString> toMap() const;
202 QString field( int key ) const { return find( key ); } 201 QString field( int key ) const { return find( key ); }
203 202
204 203
205 void setUid( int i ); 204 void setUid( int i );
206 205
207 QString toShortText()const; 206 QString toShortText()const;
208 QString OContact::type()const; 207 QString OContact::type()const;
209 QMap<QString,QString> OContact::toExtraMap() const; 208 QMap<QString,QString> OContact::toExtraMap() const;
210 class QString OContact::recordField(int) const; 209 class QString OContact::recordField(int) const;
211 210
212 // Why private ? (eilers,se) 211 // Why private ? (eilers,se)
213 QString emailSeparator() const { return " "; } 212 QString emailSeparator() const { return " "; }
214 // the emails should be seperated by a comma 213 // the emails should be seperated by a comma
215 void setEmails( const QString &v ); 214 void setEmails( const QString &v );
216 QString emails() const { return find( Qtopia::Emails ); } 215 QString emails() const { return find( Qtopia::Emails ); }
217 static int rtti(); 216 static int rtti();
218 217
219 218
220private: 219private:
221 // The XML-Backend needs some access to the private functions 220 // The XML-Backend needs some access to the private functions
222 friend class OContactAccessBackend_XML; 221 friend class OContactAccessBackend_XML;
223 222
224 void insert( int key, const QString &value ); 223 void insert( int key, const QString &value );
225 void replace( int key, const QString &value ); 224 void replace( int key, const QString &value );
226 QString find( int key ) const; 225 QString find( int key ) const;
227 static QStringList fields(); 226 static QStringList fields();
228 227
229 void save( QString &buf ) const; 228 void save( QString &buf ) const;
230 229
231 QString displayAddress( const QString &street, 230 QString displayAddress( const QString &street,
232 const QString &city, 231 const QString &city,
233 const QString &state, 232 const QString &state,
234 const QString &zip, 233 const QString &zip,
235 const QString &country ) const; 234 const QString &country ) const;
236 235
237 QMap<int, QString> mMap; 236 QMap<int, QString> mMap;
238 ContactPrivate *d; 237 ContactPrivate *d;
239}; 238};
240 239
241 240
242#endif 241#endif
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
index 9c9338e..2e3ec1f 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/libopie/pim/ocontactaccess.cpp
@@ -1,169 +1,168 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.8 2003/05/08 13:55:09 tille
25 * search stuff
26 * and match, toRichText & toShortText in oevent
27 *
24 * Revision 1.7 2002/11/13 14:14:51 eilers 28 * Revision 1.7 2002/11/13 14:14:51 eilers
25 * Added sorted for Contacts.. 29 * Added sorted for Contacts..
26 * 30 *
27 * Revision 1.6 2002/11/01 15:10:42 eilers 31 * Revision 1.6 2002/11/01 15:10:42 eilers
28 * Added regExp-search in database for all fields in a contact. 32 * Added regExp-search in database for all fields in a contact.
29 * 33 *
30 * Revision 1.5 2002/10/16 10:52:40 eilers 34 * Revision 1.5 2002/10/16 10:52:40 eilers
31 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 35 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
32 * 36 *
33 * Revision 1.4 2002/10/14 16:21:54 eilers 37 * Revision 1.4 2002/10/14 16:21:54 eilers
34 * Some minor interface updates 38 * Some minor interface updates
35 * 39 *
36 * Revision 1.3 2002/10/07 17:34:24 eilers 40 * Revision 1.3 2002/10/07 17:34:24 eilers
37 * added OBackendFactory for advanced backend access 41 * added OBackendFactory for advanced backend access
38 * 42 *
39 * Revision 1.2 2002/10/02 16:18:11 eilers 43 * Revision 1.2 2002/10/02 16:18:11 eilers
40 * debugged and seems to work almost perfectly .. 44 * debugged and seems to work almost perfectly ..
41 * 45 *
42 * Revision 1.1 2002/09/27 17:11:44 eilers 46 * Revision 1.1 2002/09/27 17:11:44 eilers
43 * Added API for accessing the Contact-Database ! It is compiling, but 47 * Added API for accessing the Contact-Database ! It is compiling, but
44 * please do not expect that anything is working ! 48 * please do not expect that anything is working !
45 * I will debug that stuff in the next time .. 49 * I will debug that stuff in the next time ..
46 * Please read README_COMPILE for compiling ! 50 * Please read README_COMPILE for compiling !
47 * 51 *
48 * 52 *
49 */ 53 */
50 54
51#include "ocontactaccess.h" 55#include "ocontactaccess.h"
52#include "obackendfactory.h" 56#include "obackendfactory.h"
53 57
54#include <qasciidict.h> 58#include <qasciidict.h>
55#include <qdatetime.h> 59#include <qdatetime.h>
56#include <qfile.h> 60#include <qfile.h>
57#include <qregexp.h> 61#include <qregexp.h>
58#include <qlist.h> 62#include <qlist.h>
59#include <qcopchannel_qws.h> 63#include <qcopchannel_qws.h>
60 64
61//#include <qpe/qcopenvelope_qws.h> 65//#include <qpe/qcopenvelope_qws.h>
62#include <qpe/global.h> 66#include <qpe/global.h>
63 67
64#include <errno.h> 68#include <errno.h>
65#include <fcntl.h> 69#include <fcntl.h>
66#include <unistd.h> 70#include <unistd.h>
67#include <stdlib.h> 71#include <stdlib.h>
68 72
69#include "ocontactaccessbackend_xml.h" 73#include "ocontactaccessbackend_xml.h"
70 74
71 75
72OContactAccess::OContactAccess ( const QString appname, const QString , 76OContactAccess::OContactAccess ( const QString appname, const QString ,
73 OContactAccessBackend* end, bool autosync ): 77 OContactAccessBackend* end, bool autosync ):
74 OPimAccessTemplate<OContact>( end ) 78 OPimAccessTemplate<OContact>( end )
75{ 79{
76 /* take care of the backend. If there is no one defined, we 80 /* take care of the backend. If there is no one defined, we
77 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 81 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
78 */ 82 */
79 if( end == 0 ) { 83 if( end == 0 ) {
80 qWarning ("Using BackendFactory !"); 84 qWarning ("Using BackendFactory !");
81 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 85 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
82 } 86 }
83 // Set backend locally and in template 87 // Set backend locally and in template
84 m_backEnd = end; 88 m_backEnd = end;
85 OPimAccessTemplate<OContact>::setBackEnd (end); 89 OPimAccessTemplate<OContact>::setBackEnd (end);
86 90
87 91
88 /* Connect signal of external db change to function */ 92 /* Connect signal of external db change to function */
89 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 93 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
90 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 94 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
91 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 95 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
92 if ( autosync ){ 96 if ( autosync ){
93 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 97 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
94 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 98 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)),
95 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 99 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
96 } 100 }
97 101
98 102
99} 103}
100OContactAccess::~OContactAccess () 104OContactAccess::~OContactAccess ()
101{ 105{
102 /* The user may forget to save the changed database, therefore try to 106 /* The user may forget to save the changed database, therefore try to
103 * do it for him.. 107 * do it for him..
104 */ 108 */
105 save(); 109 save();
106 // delete m_backEnd; is done by template.. 110 // delete m_backEnd; is done by template..
107} 111}
108 112
109 113
110bool OContactAccess::save () 114bool OContactAccess::save ()
111{ 115{
112 /* If the database was changed externally, we could not save the 116 /* If the database was changed externally, we could not save the
113 * Data. This will remove added items which is unacceptable ! 117 * Data. This will remove added items which is unacceptable !
114 * Therefore: Reload database and merge the data... 118 * Therefore: Reload database and merge the data...
115 */ 119 */
116 if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) 120 if ( OPimAccessTemplate<OContact>::wasChangedExternally() )
117 reload(); 121 reload();
118 122
119 bool status = OPimAccessTemplate<OContact>::save(); 123 bool status = OPimAccessTemplate<OContact>::save();
120 if ( !status ) return false; 124 if ( !status ) return false;
121 125
122 /* Now tell everyone that new data is available. 126 /* Now tell everyone that new data is available.
123 */ 127 */
124 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 128 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
125 129
126 return true; 130 return true;
127} 131}
128 132
129ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{
130 QArray<int> matchingContacts = m_backEnd -> matchRegexp( r );
131 return ( ORecordList<OContact>(matchingContacts, this) );
132}
133
134const uint OContactAccess::querySettings() 133const uint OContactAccess::querySettings()
135{ 134{
136 return ( m_backEnd->querySettings() ); 135 return ( m_backEnd->querySettings() );
137} 136}
138 137
139bool OContactAccess::hasQuerySettings ( int querySettings ) const 138bool OContactAccess::hasQuerySettings ( int querySettings ) const
140{ 139{
141 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 140 return ( m_backEnd->hasQuerySettings ( querySettings ) );
142} 141}
143ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 142ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
144{ 143{
145 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 144 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
146 return ( ORecordList<OContact>(matchingContacts, this) ); 145 return ( ORecordList<OContact>(matchingContacts, this) );
147} 146}
148 147
149 148
150bool OContactAccess::wasChangedExternally()const 149bool OContactAccess::wasChangedExternally()const
151{ 150{
152 return ( m_backEnd->wasChangedExternally() ); 151 return ( m_backEnd->wasChangedExternally() );
153} 152}
154 153
155 154
156void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) 155void OContactAccess::copMessage( const QCString &msg, const QByteArray & )
157{ 156{
158 if ( msg == "addressbookUpdated()" ){ 157 if ( msg == "addressbookUpdated()" ){
159 qWarning ("OContactAccess: Received addressbokUpdated()"); 158 qWarning ("OContactAccess: Received addressbokUpdated()");
160 emit signalChanged ( this ); 159 emit signalChanged ( this );
161 } else if ( msg == "flush()" ) { 160 } else if ( msg == "flush()" ) {
162 qWarning ("OContactAccess: Received flush()"); 161 qWarning ("OContactAccess: Received flush()");
163 save (); 162 save ();
164 } else if ( msg == "reload()" ) { 163 } else if ( msg == "reload()" ) {
165 qWarning ("OContactAccess: Received reload()"); 164 qWarning ("OContactAccess: Received reload()");
166 reload (); 165 reload ();
167 emit signalChanged ( this ); 166 emit signalChanged ( this );
168 } 167 }
169} 168}
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h
index d7ceaf2..e90db32 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/libopie/pim/ocontactaccess.h
@@ -1,168 +1,170 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; 10 * License as published by the Free Software Foundation;
11 * either version 2 of the License, or (at your option) any later 11 * either version 2 of the License, or (at your option) any later
12 * version. 12 * version.
13 * ===================================================================== 13 * =====================================================================
14 * ToDo: Define enum for query settings 14 * ToDo: Define enum for query settings
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.8 2003/05/08 13:55:09 tille
21 * search stuff
22 * and match, toRichText & toShortText in oevent
23 *
20 * Revision 1.7 2003/04/13 18:07:10 zecke 24 * Revision 1.7 2003/04/13 18:07:10 zecke
21 * More API doc 25 * More API doc
22 * QString -> const QString& 26 * QString -> const QString&
23 * QString = 0l -> QString::null 27 * QString = 0l -> QString::null
24 * 28 *
25 * Revision 1.6 2003/01/02 14:27:12 eilers 29 * Revision 1.6 2003/01/02 14:27:12 eilers
26 * Improved query by example: Search by date is possible.. First step 30 * Improved query by example: Search by date is possible.. First step
27 * for a today plugin for birthdays.. 31 * for a today plugin for birthdays..
28 * 32 *
29 * Revision 1.5 2002/11/13 14:14:51 eilers 33 * Revision 1.5 2002/11/13 14:14:51 eilers
30 * Added sorted for Contacts.. 34 * Added sorted for Contacts..
31 * 35 *
32 * Revision 1.4 2002/11/01 15:10:42 eilers 36 * Revision 1.4 2002/11/01 15:10:42 eilers
33 * Added regExp-search in database for all fields in a contact. 37 * Added regExp-search in database for all fields in a contact.
34 * 38 *
35 * Revision 1.3 2002/10/16 10:52:40 eilers 39 * Revision 1.3 2002/10/16 10:52:40 eilers
36 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 40 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
37 * 41 *
38 * Revision 1.2 2002/10/14 16:21:54 eilers 42 * Revision 1.2 2002/10/14 16:21:54 eilers
39 * Some minor interface updates 43 * Some minor interface updates
40 * 44 *
41 * Revision 1.1 2002/09/27 17:11:44 eilers 45 * Revision 1.1 2002/09/27 17:11:44 eilers
42 * Added API for accessing the Contact-Database ! It is compiling, but 46 * Added API for accessing the Contact-Database ! It is compiling, but
43 * please do not expect that anything is working ! 47 * please do not expect that anything is working !
44 * I will debug that stuff in the next time .. 48 * I will debug that stuff in the next time ..
45 * Please read README_COMPILE for compiling ! 49 * Please read README_COMPILE for compiling !
46 * 50 *
47 * ===================================================================== 51 * =====================================================================
48 */ 52 */
49#ifndef _OCONTACTACCESS_H 53#ifndef _OCONTACTACCESS_H
50#define _OCONTACTACCESS_H 54#define _OCONTACTACCESS_H
51 55
52#include <qobject.h> 56#include <qobject.h>
53 57
54#include <qpe/qcopenvelope_qws.h> 58#include <qpe/qcopenvelope_qws.h>
55 59
56#include <qvaluelist.h> 60#include <qvaluelist.h>
57#include <qfileinfo.h> 61#include <qfileinfo.h>
58 62
59#include "ocontact.h" 63#include "ocontact.h"
60#include "ocontactaccessbackend.h" 64#include "ocontactaccessbackend.h"
61#include "opimaccesstemplate.h" 65#include "opimaccesstemplate.h"
62 66
63/** 67/**
64 * Class to access the contacts database. 68 * Class to access the contacts database.
65 * This is just a frontend for the real database handling which is 69 * This is just a frontend for the real database handling which is
66 * done by the backend. 70 * done by the backend.
67 * This class is used to access the Contacts on a system. This class as any OPIE PIM 71 * This class is used to access the Contacts on a system. This class as any OPIE PIM
68 * class is backend independent. 72 * class is backend independent.
69 73
70 * @see OPimAccessTemplate 74 * @see OPimAccessTemplate
71 */ 75 */
72class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 76class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
73{ 77{
74 Q_OBJECT 78 Q_OBJECT
75 79
76 public: 80 public:
77 /** 81 /**
78 * Create Database with contacts (addressbook). 82 * Create Database with contacts (addressbook).
79 * @param appname Name of application which wants access to the database 83 * @param appname Name of application which wants access to the database
80 * (i.e. "todolist") 84 * (i.e. "todolist")
81 * @param filename The name of the database file. If not set, the default one 85 * @param filename The name of the database file. If not set, the default one
82 * is used. 86 * is used.
83 * @param backend Pointer to an alternative Backend. If not set, we will use 87 * @param backend Pointer to an alternative Backend. If not set, we will use
84 * the default backend. 88 * the default backend.
85 * @param handlesync If <b>true</b> the database stores the current state 89 * @param handlesync If <b>true</b> the database stores the current state
86 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> 90 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
87 * which are used before and after synchronisation. If the application wants 91 * which are used before and after synchronisation. If the application wants
88 * to react itself, it should be disabled by setting it to <b>false</b> 92 * to react itself, it should be disabled by setting it to <b>false</b>
89 * @see OContactAccessBackend 93 * @see OContactAccessBackend
90 */ 94 */
91 OContactAccess (const QString appname, const QString filename = 0l, 95 OContactAccess (const QString appname, const QString filename = 0l,
92 OContactAccessBackend* backend = 0l, bool handlesync = true); 96 OContactAccessBackend* backend = 0l, bool handlesync = true);
93 ~OContactAccess (); 97 ~OContactAccess ();
94 98
95 /** Constants for query. 99 /** Constants for query.
96 * Use this constants to set the query parameters. 100 * Use this constants to set the query parameters.
97 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! 101 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
98 * @see queryByExample() 102 * @see queryByExample()
99 */ 103 */
100 enum QuerySettings { 104 enum QuerySettings {
101 WildCards = 0x0001, 105 WildCards = 0x0001,
102 IgnoreCase = 0x0002, 106 IgnoreCase = 0x0002,
103 RegExp = 0x0004, 107 RegExp = 0x0004,
104 ExactMatch = 0x0008, 108 ExactMatch = 0x0008,
105 MatchOne = 0x0010, // Only one Entry must match 109 MatchOne = 0x0010, // Only one Entry must match
106 DateDiff = 0x0020, // Find all entries from today until given date 110 DateDiff = 0x0020, // Find all entries from today until given date
107 DateYear = 0x0040, // The year matches 111 DateYear = 0x0040, // The year matches
108 DateMonth = 0x0080, // The month matches 112 DateMonth = 0x0080, // The month matches
109 DateDay = 0x0100, // The day matches 113 DateDay = 0x0100, // The day matches
110 }; 114 };
111 115
112 116
113 ORecordList<OContact> matchRegexp( const QRegExp &r )const;
114
115 /** Return all Contacts in a sorted manner. 117 /** Return all Contacts in a sorted manner.
116 * @param ascending true: Sorted in acending order. 118 * @param ascending true: Sorted in acending order.
117 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess 119 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
118 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess 120 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
119 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess 121 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
120 */ 122 */
121 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; 123 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
122 124
123 /** Return all possible settings. 125 /** Return all possible settings.
124 * @return All settings provided by the current backend 126 * @return All settings provided by the current backend
125 * (i.e.: query_WildCards & query_IgnoreCase) 127 * (i.e.: query_WildCards & query_IgnoreCase)
126 */ 128 */
127 const uint querySettings(); 129 const uint querySettings();
128 130
129 /** Check whether settings are correct. 131 /** Check whether settings are correct.
130 * @return <i>true</i> if the given settings are correct and possible. 132 * @return <i>true</i> if the given settings are correct and possible.
131 */ 133 */
132 bool hasQuerySettings ( int querySettings ) const; 134 bool hasQuerySettings ( int querySettings ) const;
133 135
134 /** 136 /**
135 * if the resource was changed externally. 137 * if the resource was changed externally.
136 * You should use the signal instead of polling possible changes ! 138 * You should use the signal instead of polling possible changes !
137 */ 139 */
138 bool wasChangedExternally()const; 140 bool wasChangedExternally()const;
139 141
140 142
141 /** Save contacts database. 143 /** Save contacts database.
142 * Save is more a "commit". After calling this function, all changes are public available. 144 * Save is more a "commit". After calling this function, all changes are public available.
143 * @return true if successful 145 * @return true if successful
144 */ 146 */
145 bool save(); 147 bool save();
146 148
147 signals: 149 signals:
148 /* Signal is emitted if the database was changed. Therefore 150 /* Signal is emitted if the database was changed. Therefore
149 * we may need to reload to stay consistent. 151 * we may need to reload to stay consistent.
150 * @param which Pointer to the database who created this event. This pointer 152 * @param which Pointer to the database who created this event. This pointer
151 * is useful if an application has to handle multiple databases at the same time. 153 * is useful if an application has to handle multiple databases at the same time.
152 * @see reload() 154 * @see reload()
153 */ 155 */
154 void signalChanged ( const OContactAccess *which ); 156 void signalChanged ( const OContactAccess *which );
155 157
156 158
157 private: 159 private:
158 // class OContactAccessPrivate; 160 // class OContactAccessPrivate;
159 // OContactAccessPrivate* d; 161 // OContactAccessPrivate* d;
160 OContactAccessBackend *m_backEnd; 162 OContactAccessBackend *m_backEnd;
161 bool m_loading:1; 163 bool m_loading:1;
162 164
163 private slots: 165 private slots:
164 void copMessage( const QCString &msg, const QByteArray &data ); 166 void copMessage( const QCString &msg, const QByteArray &data );
165 167
166 168
167}; 169};
168#endif 170#endif
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp
index a0ae7b7..ab2eea4 100644
--- a/libopie/pim/odatebookaccessbackend_xml.cpp
+++ b/libopie/pim/odatebookaccessbackend_xml.cpp
@@ -397,192 +397,210 @@ bool ODateBookAccessBackend_XML::loadFile() {
397 397
398 i = ++j; // skip = 398 i = ++j; // skip =
399 399
400 // find the start of quotes 400 // find the start of quotes
401 while ( i < len && dt[i] != '"' ) 401 while ( i < len && dt[i] != '"' )
402 ++i; 402 ++i;
403 j = ++i; 403 j = ++i;
404 404
405 bool haveUtf = FALSE; 405 bool haveUtf = FALSE;
406 bool haveEnt = FALSE; 406 bool haveEnt = FALSE;
407 while ( j < len && dt[j] != '"' ) { 407 while ( j < len && dt[j] != '"' ) {
408 if ( ((unsigned char)dt[j]) > 0x7f ) 408 if ( ((unsigned char)dt[j]) > 0x7f )
409 haveUtf = TRUE; 409 haveUtf = TRUE;
410 if ( dt[j] == '&' ) 410 if ( dt[j] == '&' )
411 haveEnt = TRUE; 411 haveEnt = TRUE;
412 ++j; 412 ++j;
413 } 413 }
414 if ( i == j ) { 414 if ( i == j ) {
415 // empty value 415 // empty value
416 i = j + 1; 416 i = j + 1;
417 continue; 417 continue;
418 } 418 }
419 419
420 QCString value( dt+i, j-i+1 ); 420 QCString value( dt+i, j-i+1 );
421 i = j + 1; 421 i = j + 1;
422 422
423 QString str = (haveUtf ? QString::fromUtf8( value ) 423 QString str = (haveUtf ? QString::fromUtf8( value )
424 : QString::fromLatin1( value ) ); 424 : QString::fromLatin1( value ) );
425 if ( haveEnt ) 425 if ( haveEnt )
426 str = Qtopia::plainString( str ); 426 str = Qtopia::plainString( str );
427 427
428 /* 428 /*
429 * add key + value 429 * add key + value
430 */ 430 */
431 find = dict[attr.data()]; 431 find = dict[attr.data()];
432 if (!find) 432 if (!find)
433 ev.setCustomField( attr, value ); 433 ev.setCustomField( attr, value );
434 else { 434 else {
435 setField( ev, *find, value ); 435 setField( ev, *find, value );
436 } 436 }
437 } 437 }
438 /* time to finalize */ 438 /* time to finalize */
439 finalizeRecord( ev ); 439 finalizeRecord( ev );
440 delete rec; 440 delete rec;
441 } 441 }
442 ::munmap(map_addr, attribute.st_size ); 442 ::munmap(map_addr, attribute.st_size );
443 m_changed = false; // changed during add 443 m_changed = false; // changed during add
444 444
445 return true; 445 return true;
446} 446}
447void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { 447void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) {
448 /* AllDay is alway in UTC */ 448 /* AllDay is alway in UTC */
449 if ( ev.isAllDay() ) { 449 if ( ev.isAllDay() ) {
450 OTimeZone utc = OTimeZone::utc(); 450 OTimeZone utc = OTimeZone::utc();
451 ev.setStartDateTime( utc.fromUTCDateTime( start ) ); 451 ev.setStartDateTime( utc.fromUTCDateTime( start ) );
452 ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); 452 ev.setEndDateTime ( utc.fromUTCDateTime( end ) );
453 ev.setTimeZone( "UTC"); // make sure it is really utc 453 ev.setTimeZone( "UTC"); // make sure it is really utc
454 }else { 454 }else {
455 /* to current date time */ 455 /* to current date time */
456 qWarning(" Start is %d", start ); 456 qWarning(" Start is %d", start );
457 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); 457 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() );
458 QDateTime date = zone.toDateTime( start ); 458 QDateTime date = zone.toDateTime( start );
459 qWarning(" Start is %s", date.toString().latin1() ); 459 qWarning(" Start is %s", date.toString().latin1() );
460 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); 460 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) );
461 461
462 date = zone.toDateTime( end ); 462 date = zone.toDateTime( end );
463 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); 463 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) );
464 } 464 }
465 if ( rec && rec->doesRecur() ) { 465 if ( rec && rec->doesRecur() ) {
466 OTimeZone utc = OTimeZone::utc(); 466 OTimeZone utc = OTimeZone::utc();
467 ORecur recu( *rec ); // call copy c'tor; 467 ORecur recu( *rec ); // call copy c'tor;
468 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); 468 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() );
469 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); 469 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) );
470 recu.setStart( ev.startDateTime().date() ); 470 recu.setStart( ev.startDateTime().date() );
471 ev.setRecurrence( recu ); 471 ev.setRecurrence( recu );
472 } 472 }
473 473
474 if (alarmTime != -1 ) { 474 if (alarmTime != -1 ) {
475 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); 475 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 );
476 OPimAlarm al( snd , dt ); 476 OPimAlarm al( snd , dt );
477 ev.notifiers().add( al ); 477 ev.notifiers().add( al );
478 } 478 }
479 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 479 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
480 qWarning("already contains assign uid"); 480 qWarning("already contains assign uid");
481 ev.setUid( 1 ); 481 ev.setUid( 1 );
482 } 482 }
483 qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); 483 qWarning("addind %d %s", ev.uid(), ev.description().latin1() );
484 if ( ev.hasRecurrence() ) 484 if ( ev.hasRecurrence() )
485 m_rep.insert( ev.uid(), ev ); 485 m_rep.insert( ev.uid(), ev );
486 else 486 else
487 m_raw.insert( ev.uid(), ev ); 487 m_raw.insert( ev.uid(), ev );
488 488
489} 489}
490void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { 490void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) {
491// qWarning(" setting %s", value.latin1() ); 491// qWarning(" setting %s", value.latin1() );
492 switch( id ) { 492 switch( id ) {
493 case FDescription: 493 case FDescription:
494 e.setDescription( value ); 494 e.setDescription( value );
495 break; 495 break;
496 case FLocation: 496 case FLocation:
497 e.setLocation( value ); 497 e.setLocation( value );
498 break; 498 break;
499 case FCategories: 499 case FCategories:
500 e.setCategories( e.idsFromString( value ) ); 500 e.setCategories( e.idsFromString( value ) );
501 break; 501 break;
502 case FUid: 502 case FUid:
503 e.setUid( value.toInt() ); 503 e.setUid( value.toInt() );
504 break; 504 break;
505 case FType: 505 case FType:
506 if ( value == "AllDay" ) { 506 if ( value == "AllDay" ) {
507 e.setAllDay( true ); 507 e.setAllDay( true );
508 e.setTimeZone( "UTC" ); 508 e.setTimeZone( "UTC" );
509 } 509 }
510 break; 510 break;
511 case FAlarm: 511 case FAlarm:
512 alarmTime = value.toInt(); 512 alarmTime = value.toInt();
513 break; 513 break;
514 case FSound: 514 case FSound:
515 snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; 515 snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent;
516 break; 516 break;
517 // recurrence stuff 517 // recurrence stuff
518 case FRType: 518 case FRType:
519 if ( value == "Daily" ) 519 if ( value == "Daily" )
520 recur()->setType( ORecur::Daily ); 520 recur()->setType( ORecur::Daily );
521 else if ( value == "Weekly" ) 521 else if ( value == "Weekly" )
522 recur()->setType( ORecur::Weekly); 522 recur()->setType( ORecur::Weekly);
523 else if ( value == "MonthlyDay" ) 523 else if ( value == "MonthlyDay" )
524 recur()->setType( ORecur::MonthlyDay ); 524 recur()->setType( ORecur::MonthlyDay );
525 else if ( value == "MonthlyDate" ) 525 else if ( value == "MonthlyDate" )
526 recur()->setType( ORecur::MonthlyDate ); 526 recur()->setType( ORecur::MonthlyDate );
527 else if ( value == "Yearly" ) 527 else if ( value == "Yearly" )
528 recur()->setType( ORecur::Yearly ); 528 recur()->setType( ORecur::Yearly );
529 else 529 else
530 recur()->setType( ORecur::NoRepeat ); 530 recur()->setType( ORecur::NoRepeat );
531 break; 531 break;
532 case FRWeekdays: 532 case FRWeekdays:
533 recur()->setDays( value.toInt() ); 533 recur()->setDays( value.toInt() );
534 break; 534 break;
535 case FRPosition: 535 case FRPosition:
536 recur()->setPosition( value.toInt() ); 536 recur()->setPosition( value.toInt() );
537 break; 537 break;
538 case FRFreq: 538 case FRFreq:
539 recur()->setFrequency( value.toInt() ); 539 recur()->setFrequency( value.toInt() );
540 break; 540 break;
541 case FRHasEndDate: 541 case FRHasEndDate:
542 recur()->setHasEndDate( value.toInt() ); 542 recur()->setHasEndDate( value.toInt() );
543 break; 543 break;
544 case FREndDate: { 544 case FREndDate: {
545 rp_end = (time_t) value.toLong(); 545 rp_end = (time_t) value.toLong();
546 break; 546 break;
547 } 547 }
548 case FRStart: { 548 case FRStart: {
549 start = (time_t) value.toLong(); 549 start = (time_t) value.toLong();
550 break; 550 break;
551 } 551 }
552 case FREnd: { 552 case FREnd: {
553 end = ( (time_t) value.toLong() ); 553 end = ( (time_t) value.toLong() );
554 break; 554 break;
555 } 555 }
556 case FNote: 556 case FNote:
557 e.setNote( value ); 557 e.setNote( value );
558 break; 558 break;
559 case FCreated: 559 case FCreated:
560 created = value.toInt(); 560 created = value.toInt();
561 break; 561 break;
562 case FRecParent: 562 case FRecParent:
563 e.setParent( value.toInt() ); 563 e.setParent( value.toInt() );
564 break; 564 break;
565 case FRecChildren:{ 565 case FRecChildren:{
566 QStringList list = QStringList::split(' ', value ); 566 QStringList list = QStringList::split(' ', value );
567 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 567 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
568 e.addChild( (*it).toInt() ); 568 e.addChild( (*it).toInt() );
569 } 569 }
570 } 570 }
571 break; 571 break;
572 case FExceptions:{ 572 case FExceptions:{
573 QStringList list = QStringList::split(' ', value ); 573 QStringList list = QStringList::split(' ', value );
574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
575 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); 575 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
576 qWarning("adding exception %s", date.toString().latin1() ); 576 qWarning("adding exception %s", date.toString().latin1() );
577 recur()->exceptions().append( date ); 577 recur()->exceptions().append( date );
578 } 578 }
579 } 579 }
580 break; 580 break;
581 case FTimeZone: 581 case FTimeZone:
582 if ( value != "None" ) 582 if ( value != "None" )
583 e.setTimeZone( value ); 583 e.setTimeZone( value );
584 break; 584 break;
585 default: 585 default:
586 break; 586 break;
587 } 587 }
588} 588}
589QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
590{
591 QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
592 uint arraycounter = 0;
593 QMap<int, OEvent>::ConstIterator it;
594
595 for ( it = m_raw.begin(); it != m_raw.end(); ++it )
596 if ( it.data().match( r ) )
597 m_currentQuery[arraycounter++] = it.data().uid();
598 for ( it = m_rep.begin(); it != m_rep.end(); ++it )
599 if ( it.data().match( r ) )
600 m_currentQuery[arraycounter++] = it.data().uid();
601
602 // Shrink to fit..
603 m_currentQuery.resize(arraycounter);
604
605 return m_currentQuery;
606}
diff --git a/libopie/pim/odatebookaccessbackend_xml.h b/libopie/pim/odatebookaccessbackend_xml.h
index 7848f7c..a5cc0fc 100644
--- a/libopie/pim/odatebookaccessbackend_xml.h
+++ b/libopie/pim/odatebookaccessbackend_xml.h
@@ -1,54 +1,55 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
3 3
4#include <qmap.h> 4#include <qmap.h>
5 5
6#include "odatebookaccessbackend.h" 6#include "odatebookaccessbackend.h"
7 7
8/** 8/**
9 * This is the default XML implementation for DateBoook XML storage 9 * This is the default XML implementation for DateBoook XML storage
10 * It fully implements the interface 10 * It fully implements the interface
11 * @see ODateBookAccessBackend 11 * @see ODateBookAccessBackend
12 * @see OPimAccessBackend 12 * @see OPimAccessBackend
13 */ 13 */
14class ODateBookAccessBackend_XML : public ODateBookAccessBackend { 14class ODateBookAccessBackend_XML : public ODateBookAccessBackend {
15public: 15public:
16 ODateBookAccessBackend_XML( const QString& appName, 16 ODateBookAccessBackend_XML( const QString& appName,
17 const QString& fileName = QString::null); 17 const QString& fileName = QString::null);
18 ~ODateBookAccessBackend_XML(); 18 ~ODateBookAccessBackend_XML();
19 19
20 bool load(); 20 bool load();
21 bool reload(); 21 bool reload();
22 bool save(); 22 bool save();
23 23
24 QArray<int> allRecords()const; 24 QArray<int> allRecords()const;
25 QArray<int> matchRegexp(const QRegExp &r) const;
25 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); 26 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
26 OEvent find( int uid )const; 27 OEvent find( int uid )const;
27 void clear(); 28 void clear();
28 bool add( const OEvent& ev ); 29 bool add( const OEvent& ev );
29 bool remove( int uid ); 30 bool remove( int uid );
30 bool replace( const OEvent& ev ); 31 bool replace( const OEvent& ev );
31 32
32 QArray<UID> rawEvents()const; 33 QArray<UID> rawEvents()const;
33 QArray<UID> rawRepeats()const; 34 QArray<UID> rawRepeats()const;
34 QArray<UID> nonRepeats()const; 35 QArray<UID> nonRepeats()const;
35 36
36 OEvent::ValueList directNonRepeats(); 37 OEvent::ValueList directNonRepeats();
37 OEvent::ValueList directRawRepeats(); 38 OEvent::ValueList directRawRepeats();
38 39
39private: 40private:
40 bool m_changed :1 ; 41 bool m_changed :1 ;
41 bool loadFile(); 42 bool loadFile();
42 inline void finalizeRecord( OEvent& ev ); 43 inline void finalizeRecord( OEvent& ev );
43 inline void setField( OEvent&, int field, const QString& val ); 44 inline void setField( OEvent&, int field, const QString& val );
44 QString m_name; 45 QString m_name;
45 QMap<int, OEvent> m_raw; 46 QMap<int, OEvent> m_raw;
46 QMap<int, OEvent> m_rep; 47 QMap<int, OEvent> m_rep;
47 48
48 struct Data; 49 struct Data;
49 Data* data; 50 Data* data;
50 class Private; 51 class Private;
51 Private *d; 52 Private *d;
52}; 53};
53 54
54#endif 55#endif
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp
index 3ba8a52..28cf873 100644
--- a/libopie/pim/oevent.cpp
+++ b/libopie/pim/oevent.cpp
@@ -1,414 +1,445 @@
1#include <qshared.h> 1#include <qshared.h>
2 2
3#include <qpe/palmtopuidgen.h> 3#include <qpe/palmtopuidgen.h>
4#include <qpe/categories.h> 4#include <qpe/categories.h>
5#include <qpe/stringutil.h>
5 6
6#include "orecur.h" 7#include "orecur.h"
7#include "opimresolver.h" 8#include "opimresolver.h"
8#include "opimnotifymanager.h" 9#include "opimnotifymanager.h"
9 10
10#include "oevent.h" 11#include "oevent.h"
11 12
12int OCalendarHelper::week( const QDate& date) { 13int OCalendarHelper::week( const QDate& date) {
13 // Calculates the week this date is in within that 14 // Calculates the week this date is in within that
14 // month. Equals the "row" is is in in the month view 15 // month. Equals the "row" is is in in the month view
15 int week = 1; 16 int week = 1;
16 QDate tmp( date.year(), date.month(), 1 ); 17 QDate tmp( date.year(), date.month(), 1 );
17 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 18 if ( date.dayOfWeek() < tmp.dayOfWeek() )
18 ++week; 19 ++week;
19 20
20 week += ( date.day() - 1 ) / 7; 21 week += ( date.day() - 1 ) / 7;
21 22
22 return week; 23 return week;
23} 24}
24int OCalendarHelper::ocurrence( const QDate& date) { 25int OCalendarHelper::ocurrence( const QDate& date) {
25 // calculates the number of occurrances of this day of the 26 // calculates the number of occurrances of this day of the
26 // week till the given date (e.g 3rd Wednesday of the month) 27 // week till the given date (e.g 3rd Wednesday of the month)
27 return ( date.day() - 1 ) / 7 + 1; 28 return ( date.day() - 1 ) / 7 + 1;
28} 29}
29int OCalendarHelper::dayOfWeek( char day ) { 30int OCalendarHelper::dayOfWeek( char day ) {
30 int dayOfWeek = 1; 31 int dayOfWeek = 1;
31 char i = ORecur::MON; 32 char i = ORecur::MON;
32 while ( !( i & day ) && i <= ORecur::SUN ) { 33 while ( !( i & day ) && i <= ORecur::SUN ) {
33 i <<= 1; 34 i <<= 1;
34 ++dayOfWeek; 35 ++dayOfWeek;
35 } 36 }
36 return dayOfWeek; 37 return dayOfWeek;
37} 38}
38int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { 39int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
39 return ( second.year() - first.year() ) * 12 + 40 return ( second.year() - first.year() ) * 12 +
40 second.month() - first.month(); 41 second.month() - first.month();
41} 42}
42 43
43struct OEvent::Data : public QShared { 44struct OEvent::Data : public QShared {
44 Data() : QShared() { 45 Data() : QShared() {
45 child = 0; 46 child = 0;
46 recur = 0; 47 recur = 0;
47 manager = 0; 48 manager = 0;
48 isAllDay = false; 49 isAllDay = false;
49 parent = 0; 50 parent = 0;
50 } 51 }
51 ~Data() { 52 ~Data() {
52 delete manager; 53 delete manager;
53 delete recur; 54 delete recur;
54 } 55 }
55 QString description; 56 QString description;
56 QString location; 57 QString location;
57 OPimNotifyManager* manager; 58 OPimNotifyManager* manager;
58 ORecur* recur; 59 ORecur* recur;
59 QString note; 60 QString note;
60 QDateTime created; 61 QDateTime created;
61 QDateTime start; 62 QDateTime start;
62 QDateTime end; 63 QDateTime end;
63 bool isAllDay : 1; 64 bool isAllDay : 1;
64 QString timezone; 65 QString timezone;
65 QArray<int>* child; 66 QArray<int>* child;
66 int parent; 67 int parent;
67}; 68};
68 69
69OEvent::OEvent( int uid ) 70OEvent::OEvent( int uid )
70 : OPimRecord( uid ) { 71 : OPimRecord( uid ) {
71 data = new Data; 72 data = new Data;
72} 73}
73OEvent::OEvent( const OEvent& ev) 74OEvent::OEvent( const OEvent& ev)
74 : OPimRecord( ev ), data( ev.data ) 75 : OPimRecord( ev ), data( ev.data )
75{ 76{
76 data->ref(); 77 data->ref();
77} 78}
78OEvent::~OEvent() { 79OEvent::~OEvent() {
79 if ( data->deref() ) { 80 if ( data->deref() ) {
80 delete data; 81 delete data;
81 data = 0; 82 data = 0;
82 } 83 }
83} 84}
84OEvent& OEvent::operator=( const OEvent& ev) { 85OEvent& OEvent::operator=( const OEvent& ev) {
85 if ( this == &ev ) return *this; 86 if ( this == &ev ) return *this;
86 87
87 OPimRecord::operator=( ev ); 88 OPimRecord::operator=( ev );
88 ev.data->ref(); 89 ev.data->ref();
89 deref(); 90 deref();
90 data = ev.data; 91 data = ev.data;
91 92
92 93
93 return *this; 94 return *this;
94} 95}
95QString OEvent::description()const { 96QString OEvent::description()const {
96 return data->description; 97 return data->description;
97} 98}
98void OEvent::setDescription( const QString& description ) { 99void OEvent::setDescription( const QString& description ) {
99 changeOrModify(); 100 changeOrModify();
100 data->description = description; 101 data->description = description;
101} 102}
102void OEvent::setLocation( const QString& loc ) { 103void OEvent::setLocation( const QString& loc ) {
103 changeOrModify(); 104 changeOrModify();
104 data->location = loc; 105 data->location = loc;
105} 106}
106QString OEvent::location()const { 107QString OEvent::location()const {
107 return data->location; 108 return data->location;
108} 109}
109OPimNotifyManager &OEvent::notifiers()const { 110OPimNotifyManager &OEvent::notifiers()const {
110 // I hope we can skip the changeOrModify here 111 // I hope we can skip the changeOrModify here
111 // the notifier should take care of it 112 // the notifier should take care of it
112 // and OPimNotify is shared too 113 // and OPimNotify is shared too
113 if (!data->manager ) 114 if (!data->manager )
114 data->manager = new OPimNotifyManager; 115 data->manager = new OPimNotifyManager;
115 116
116 return *data->manager; 117 return *data->manager;
117} 118}
118bool OEvent::hasNotifiers()const { 119bool OEvent::hasNotifiers()const {
119 if (!data->manager ) 120 if (!data->manager )
120 return false; 121 return false;
121 if (data->manager->reminders().isEmpty() && 122 if (data->manager->reminders().isEmpty() &&
122 data->manager->alarms().isEmpty() ) 123 data->manager->alarms().isEmpty() )
123 return false; 124 return false;
124 125
125 return true; 126 return true;
126} 127}
127ORecur OEvent::recurrence()const { 128ORecur OEvent::recurrence()const {
128 if (!data->recur) 129 if (!data->recur)
129 data->recur = new ORecur; 130 data->recur = new ORecur;
130 131
131 return *data->recur; 132 return *data->recur;
132} 133}
133void OEvent::setRecurrence( const ORecur& rec) { 134void OEvent::setRecurrence( const ORecur& rec) {
134 changeOrModify(); 135 changeOrModify();
135 if (data->recur ) 136 if (data->recur )
136 (*data->recur) = rec; 137 (*data->recur) = rec;
137 else 138 else
138 data->recur = new ORecur( rec ); 139 data->recur = new ORecur( rec );
139} 140}
140bool OEvent::hasRecurrence()const { 141bool OEvent::hasRecurrence()const {
141 if (!data->recur ) return false; 142 if (!data->recur ) return false;
142 return data->recur->doesRecur(); 143 return data->recur->doesRecur();
143} 144}
144QString OEvent::note()const { 145QString OEvent::note()const {
145 return data->note; 146 return data->note;
146} 147}
147void OEvent::setNote( const QString& note ) { 148void OEvent::setNote( const QString& note ) {
148 changeOrModify(); 149 changeOrModify();
149 data->note = note; 150 data->note = note;
150} 151}
151QDateTime OEvent::createdDateTime()const { 152QDateTime OEvent::createdDateTime()const {
152 return data->created; 153 return data->created;
153} 154}
154void OEvent::setCreatedDateTime( const QDateTime& time ) { 155void OEvent::setCreatedDateTime( const QDateTime& time ) {
155 changeOrModify(); 156 changeOrModify();
156 data->created = time; 157 data->created = time;
157} 158}
158QDateTime OEvent::startDateTime()const { 159QDateTime OEvent::startDateTime()const {
159 if ( data->isAllDay ) 160 if ( data->isAllDay )
160 return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); 161 return QDateTime( data->start.date(), QTime(0, 0, 0 ) );
161 return data->start; 162 return data->start;
162} 163}
163QDateTime OEvent::startDateTimeInZone()const { 164QDateTime OEvent::startDateTimeInZone()const {
164 /* if no timezone, or all day event or if the current and this timeZone match... */ 165 /* if no timezone, or all day event or if the current and this timeZone match... */
165 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); 166 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime();
166 167
167 OTimeZone zone(data->timezone ); 168 OTimeZone zone(data->timezone );
168 return zone.toDateTime( data->start, OTimeZone::current() ); 169 return zone.toDateTime( data->start, OTimeZone::current() );
169} 170}
170void OEvent::setStartDateTime( const QDateTime& dt ) { 171void OEvent::setStartDateTime( const QDateTime& dt ) {
171 changeOrModify(); 172 changeOrModify();
172 data->start = dt; 173 data->start = dt;
173} 174}
174QDateTime OEvent::endDateTime()const { 175QDateTime OEvent::endDateTime()const {
175 /* 176 /*
176 * if all Day event the end time needs 177 * if all Day event the end time needs
177 * to be on the same day as the start 178 * to be on the same day as the start
178 */ 179 */
179 if ( data->isAllDay ) 180 if ( data->isAllDay )
180 return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); 181 return QDateTime( data->start.date(), QTime(23, 59, 59 ) );
181 return data->end; 182 return data->end;
182} 183}
183QDateTime OEvent::endDateTimeInZone()const { 184QDateTime OEvent::endDateTimeInZone()const {
184 /* if no timezone, or all day event or if the current and this timeZone match... */ 185 /* if no timezone, or all day event or if the current and this timeZone match... */
185 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); 186 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime();
186 187
187 OTimeZone zone(data->timezone ); 188 OTimeZone zone(data->timezone );
188 return zone.toDateTime( data->end, OTimeZone::current() ); 189 return zone.toDateTime( data->end, OTimeZone::current() );
189} 190}
190void OEvent::setEndDateTime( const QDateTime& dt ) { 191void OEvent::setEndDateTime( const QDateTime& dt ) {
191 changeOrModify(); 192 changeOrModify();
192 data->end = dt; 193 data->end = dt;
193} 194}
194bool OEvent::isMultipleDay()const { 195bool OEvent::isMultipleDay()const {
195 return data->end.date().day() - data->start.date().day(); 196 return data->end.date().day() - data->start.date().day();
196} 197}
197bool OEvent::isAllDay()const { 198bool OEvent::isAllDay()const {
198 return data->isAllDay; 199 return data->isAllDay;
199} 200}
200void OEvent::setAllDay( bool allDay ) { 201void OEvent::setAllDay( bool allDay ) {
201 changeOrModify(); 202 changeOrModify();
202 data->isAllDay = allDay; 203 data->isAllDay = allDay;
203 if (allDay ) data->timezone = "UTC"; 204 if (allDay ) data->timezone = "UTC";
204} 205}
205void OEvent::setTimeZone( const QString& tz ) { 206void OEvent::setTimeZone( const QString& tz ) {
206 changeOrModify(); 207 changeOrModify();
207 data->timezone = tz; 208 data->timezone = tz;
208} 209}
209QString OEvent::timeZone()const { 210QString OEvent::timeZone()const {
210 if (data->isAllDay ) return QString::fromLatin1("UTC"); 211 if (data->isAllDay ) return QString::fromLatin1("UTC");
211 return data->timezone; 212 return data->timezone;
212} 213}
213bool OEvent::match( const QRegExp& )const { 214bool OEvent::match( const QRegExp& re )const {
214 // FIXME 215 if (data->description.contains( re ) )
216 return true;
217 if ( data->note.contains( re ) )
218 return true;
219 if ( data->location.contains( re ) )
220 return true;
221 if ( data->start.toString().contains( re ) )
222 return true;
223 if ( data->end.toString().contains( re ) )
224 return true;
215 return false; 225 return false;
216} 226}
217QString OEvent::toRichText()const { 227QString OEvent::toRichText()const {
218 // FIXME 228 QString text;
219 return "OEvent test"; 229 if ( !description().isEmpty() ) {
230 text += "<b>" + QObject::tr( "Description:") + "</b><br>";
231 text += Qtopia::escapeString(description() ).
232 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
233 }
234 if ( startDateTime().isValid() ) {
235 text += "<b>" + QObject::tr( "Start:") + "</b> ";
236 text += Qtopia::escapeString(startDateTime().toString() ).
237 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
238 }
239 if ( endDateTime().isValid() ) {
240 text += "<b>" + QObject::tr( "End:") + "</b> ";
241 text += Qtopia::escapeString(endDateTime().toString() ).
242 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
243 }
244 if ( !note().isEmpty() ) {
245 text += "<b>" + QObject::tr( "Note:") + "</b><br>";
246 text += note();
247// text += Qtopia::escapeString(note() ).
248// replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
249 }
250 return text;
220} 251}
221QString OEvent::toShortText()const { 252QString OEvent::toShortText()const {
222 return "OEvent shotText"; 253 return description();
223} 254}
224QString OEvent::type()const { 255QString OEvent::type()const {
225 return QString::fromLatin1("OEvent"); 256 return QString::fromLatin1("OEvent");
226} 257}
227QString OEvent::recordField( int /*id */ )const { 258QString OEvent::recordField( int /*id */ )const {
228 return QString::null; 259 return QString::null;
229} 260}
230int OEvent::rtti() { 261int OEvent::rtti() {
231 return OPimResolver::DateBook; 262 return OPimResolver::DateBook;
232} 263}
233bool OEvent::loadFromStream( QDataStream& ) { 264bool OEvent::loadFromStream( QDataStream& ) {
234 return true; 265 return true;
235} 266}
236bool OEvent::saveToStream( QDataStream& )const { 267bool OEvent::saveToStream( QDataStream& )const {
237 return true; 268 return true;
238} 269}
239void OEvent::changeOrModify() { 270void OEvent::changeOrModify() {
240 if ( data->count != 1 ) { 271 if ( data->count != 1 ) {
241 data->deref(); 272 data->deref();
242 Data* d2 = new Data; 273 Data* d2 = new Data;
243 d2->description = data->description; 274 d2->description = data->description;
244 d2->location = data->location; 275 d2->location = data->location;
245 276
246 if (data->manager ) 277 if (data->manager )
247 d2->manager = new OPimNotifyManager( *data->manager ); 278 d2->manager = new OPimNotifyManager( *data->manager );
248 279
249 if ( data->recur ) 280 if ( data->recur )
250 d2->recur = new ORecur( *data->recur ); 281 d2->recur = new ORecur( *data->recur );
251 282
252 d2->note = data->note; 283 d2->note = data->note;
253 d2->created = data->created; 284 d2->created = data->created;
254 d2->start = data->start; 285 d2->start = data->start;
255 d2->end = data->end; 286 d2->end = data->end;
256 d2->isAllDay = data->isAllDay; 287 d2->isAllDay = data->isAllDay;
257 d2->timezone = data->timezone; 288 d2->timezone = data->timezone;
258 d2->parent = data->parent; 289 d2->parent = data->parent;
259 290
260 if ( data->child ) { 291 if ( data->child ) {
261 d2->child = new QArray<int>( *data->child ); 292 d2->child = new QArray<int>( *data->child );
262 d2->child->detach(); 293 d2->child->detach();
263 } 294 }
264 295
265 data = d2; 296 data = d2;
266 } 297 }
267} 298}
268void OEvent::deref() { 299void OEvent::deref() {
269 if ( data->deref() ) { 300 if ( data->deref() ) {
270 delete data; 301 delete data;
271 data = 0; 302 data = 0;
272 } 303 }
273} 304}
274// FIXME 305// FIXME
275QMap<int, QString> OEvent::toMap()const { 306QMap<int, QString> OEvent::toMap()const {
276 return QMap<int, QString>(); 307 return QMap<int, QString>();
277} 308}
278QMap<QString, QString> OEvent::toExtraMap()const { 309QMap<QString, QString> OEvent::toExtraMap()const {
279 return QMap<QString, QString>(); 310 return QMap<QString, QString>();
280} 311}
281int OEvent::parent()const { 312int OEvent::parent()const {
282 return data->parent; 313 return data->parent;
283} 314}
284void OEvent::setParent( int uid ) { 315void OEvent::setParent( int uid ) {
285 changeOrModify(); 316 changeOrModify();
286 data->parent = uid; 317 data->parent = uid;
287} 318}
288QArray<int> OEvent::children() const{ 319QArray<int> OEvent::children() const{
289 if (!data->child) return QArray<int>(); 320 if (!data->child) return QArray<int>();
290 else 321 else
291 return data->child->copy(); 322 return data->child->copy();
292} 323}
293void OEvent::setChildren( const QArray<int>& arr ) { 324void OEvent::setChildren( const QArray<int>& arr ) {
294 changeOrModify(); 325 changeOrModify();
295 if (data->child) delete data->child; 326 if (data->child) delete data->child;
296 327
297 data->child = new QArray<int>( arr ); 328 data->child = new QArray<int>( arr );
298 data->child->detach(); 329 data->child->detach();
299} 330}
300void OEvent::addChild( int uid ) { 331void OEvent::addChild( int uid ) {
301 changeOrModify(); 332 changeOrModify();
302 if (!data->child ) { 333 if (!data->child ) {
303 data->child = new QArray<int>(1); 334 data->child = new QArray<int>(1);
304 (*data->child)[0] = uid; 335 (*data->child)[0] = uid;
305 }else{ 336 }else{
306 int count = data->child->count(); 337 int count = data->child->count();
307 data->child->resize( count + 1 ); 338 data->child->resize( count + 1 );
308 (*data->child)[count] = uid; 339 (*data->child)[count] = uid;
309 } 340 }
310} 341}
311void OEvent::removeChild( int uid ) { 342void OEvent::removeChild( int uid ) {
312 if (!data->child || !data->child->contains( uid ) ) return; 343 if (!data->child || !data->child->contains( uid ) ) return;
313 changeOrModify(); 344 changeOrModify();
314 QArray<int> newAr( data->child->count() - 1 ); 345 QArray<int> newAr( data->child->count() - 1 );
315 int j = 0; 346 int j = 0;
316 uint count = data->child->count(); 347 uint count = data->child->count();
317 for ( uint i = 0; i < count; i++ ) { 348 for ( uint i = 0; i < count; i++ ) {
318 if ( (*data->child)[i] != uid ) { 349 if ( (*data->child)[i] != uid ) {
319 newAr[j] = (*data->child)[i]; 350 newAr[j] = (*data->child)[i];
320 j++; 351 j++;
321 } 352 }
322 } 353 }
323 (*data->child) = newAr; 354 (*data->child) = newAr;
324} 355}
325struct OEffectiveEvent::Data : public QShared { 356struct OEffectiveEvent::Data : public QShared {
326 Data() : QShared() { 357 Data() : QShared() {
327 } 358 }
328 OEvent event; 359 OEvent event;
329 QDate date; 360 QDate date;
330 QTime start, end; 361 QTime start, end;
331 QDate startDate, endDate; 362 QDate startDate, endDate;
332 bool dates : 1; 363 bool dates : 1;
333}; 364};
334 365
335OEffectiveEvent::OEffectiveEvent() { 366OEffectiveEvent::OEffectiveEvent() {
336 data = new Data; 367 data = new Data;
337 data->date = QDate::currentDate(); 368 data->date = QDate::currentDate();
338 data->start = data->end = QTime::currentTime(); 369 data->start = data->end = QTime::currentTime();
339 data->dates = false; 370 data->dates = false;
340} 371}
341OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, 372OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
342 Position pos ) { 373 Position pos ) {
343 data = new Data; 374 data = new Data;
344 data->event = ev; 375 data->event = ev;
345 data->date = startDate; 376 data->date = startDate;
346 if ( pos & Start ) 377 if ( pos & Start )
347 data->start = ev.startDateTime().time(); 378 data->start = ev.startDateTime().time();
348 else 379 else
349 data->start = QTime( 0, 0, 0 ); 380 data->start = QTime( 0, 0, 0 );
350 381
351 if ( pos & End ) 382 if ( pos & End )
352 data->end = ev.endDateTime().time(); 383 data->end = ev.endDateTime().time();
353 else 384 else
354 data->end = QTime( 23, 59, 59 ); 385 data->end = QTime( 23, 59, 59 );
355 386
356 data->dates = false; 387 data->dates = false;
357} 388}
358OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { 389OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) {
359 data = ev.data; 390 data = ev.data;
360 data->ref(); 391 data->ref();
361} 392}
362OEffectiveEvent::~OEffectiveEvent() { 393OEffectiveEvent::~OEffectiveEvent() {
363 if ( data->deref() ) { 394 if ( data->deref() ) {
364 delete data; 395 delete data;
365 data = 0; 396 data = 0;
366 } 397 }
367} 398}
368OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { 399OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) {
369 if ( *this == ev ) return *this; 400 if ( *this == ev ) return *this;
370 401
371 ev.data->ref(); 402 ev.data->ref();
372 deref(); 403 deref();
373 data = ev.data; 404 data = ev.data;
374 405
375 return *this; 406 return *this;
376} 407}
377 408
378void OEffectiveEvent::setStartTime( const QTime& ti) { 409void OEffectiveEvent::setStartTime( const QTime& ti) {
379 changeOrModify(); 410 changeOrModify();
380 data->start = ti; 411 data->start = ti;
381} 412}
382void OEffectiveEvent::setEndTime( const QTime& en) { 413void OEffectiveEvent::setEndTime( const QTime& en) {
383 changeOrModify(); 414 changeOrModify();
384 data->end = en; 415 data->end = en;
385} 416}
386void OEffectiveEvent::setEvent( const OEvent& ev) { 417void OEffectiveEvent::setEvent( const OEvent& ev) {
387 changeOrModify(); 418 changeOrModify();
388 data->event = ev; 419 data->event = ev;
389} 420}
390void OEffectiveEvent::setDate( const QDate& da) { 421void OEffectiveEvent::setDate( const QDate& da) {
391 changeOrModify(); 422 changeOrModify();
392 data->date = da; 423 data->date = da;
393} 424}
394void OEffectiveEvent::setEffectiveDates( const QDate& from, 425void OEffectiveEvent::setEffectiveDates( const QDate& from,
395 const QDate& to ) { 426 const QDate& to ) {
396 if (!from.isValid() ) { 427 if (!from.isValid() ) {
397 data->dates = false; 428 data->dates = false;
398 return; 429 return;
399 } 430 }
400 431
401 data->startDate = from; 432 data->startDate = from;
402 data->endDate = to; 433 data->endDate = to;
403} 434}
404QString OEffectiveEvent::description()const { 435QString OEffectiveEvent::description()const {
405 return data->event.description(); 436 return data->event.description();
406} 437}
407QString OEffectiveEvent::location()const { 438QString OEffectiveEvent::location()const {
408 return data->event.location(); 439 return data->event.location();
409} 440}
410QString OEffectiveEvent::note()const { 441QString OEffectiveEvent::note()const {
411 return data->event.note(); 442 return data->event.note();
412} 443}
413OEvent OEffectiveEvent::event()const { 444OEvent OEffectiveEvent::event()const {
414 return data->event; 445 return data->event;
diff --git a/libopie/pim/oevent.h b/libopie/pim/oevent.h
index 57d32d0..b696d81 100644
--- a/libopie/pim/oevent.h
+++ b/libopie/pim/oevent.h
@@ -1,221 +1,221 @@
1// CONTAINS GPLed code of TT 1// CONTAINS GPLed code of TT
2 2
3#ifndef OPIE_PIM_EVENT_H 3#ifndef OPIE_PIM_EVENT_H
4#define OPIE_PIM_EVENT_H 4#define OPIE_PIM_EVENT_H
5 5
6#include <qstring.h> 6#include <qstring.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8#include <qvaluelist.h> 8#include <qvaluelist.h>
9 9
10#include <qpe/recordfields.h> 10#include <qpe/recordfields.h>
11#include <qpe/palmtopuidgen.h> 11#include <qpe/palmtopuidgen.h>
12 12
13#include "otimezone.h" 13#include "otimezone.h"
14#include "opimrecord.h" 14#include "opimrecord.h"
15 15
16struct OCalendarHelper { 16struct OCalendarHelper {
17 /** calculate the week number of the date */ 17 /** calculate the week number of the date */
18 static int week( const QDate& ); 18 static int week( const QDate& );
19 /** calculate the occurence of week days since the start of the month */ 19 /** calculate the occurence of week days since the start of the month */
20 static int ocurrence( const QDate& ); 20 static int ocurrence( const QDate& );
21 21
22 // returns the dayOfWeek for the *first* day it finds (ignores 22 // returns the dayOfWeek for the *first* day it finds (ignores
23 // any further days!). Returns 1 (Monday) if there isn't any day found 23 // any further days!). Returns 1 (Monday) if there isn't any day found
24 static int dayOfWeek( char day ); 24 static int dayOfWeek( char day );
25 25
26 /** returns the diff of month */ 26 /** returns the diff of month */
27 static int monthDiff( const QDate& first, const QDate& second ); 27 static int monthDiff( const QDate& first, const QDate& second );
28 28
29}; 29};
30 30
31class OPimNotifyManager; 31class OPimNotifyManager;
32class ORecur; 32class ORecur;
33 33
34/** 34/**
35 * This is the container for all Events. It encapsules all 35 * This is the container for all Events. It encapsules all
36 * available information for a single Event 36 * available information for a single Event
37 * @short container for events. 37 * @short container for events.
38 */ 38 */
39class OEvent : public OPimRecord { 39class OEvent : public OPimRecord {
40public: 40public:
41 typedef QValueList<OEvent> ValueList; 41 typedef QValueList<OEvent> ValueList;
42 /** 42 /**
43 * RecordFields contain possible attributes 43 * RecordFields contain possible attributes
44 */ 44 */
45 enum RecordFields { 45 enum RecordFields {
46 Uid = Qtopia::UID_ID, 46 Uid = Qtopia::UID_ID,
47 Category = Qtopia::CATEGORY_ID, 47 Category = Qtopia::CATEGORY_ID,
48 Description, 48 Description,
49 Location, 49 Location,
50 Alarm, 50 Alarm,
51 Reminder, 51 Reminder,
52 Recurrence, 52 Recurrence,
53 Note, 53 Note,
54 Created, 54 Created,
55 StartDate, 55 StartDate,
56 EndDate, 56 EndDate,
57 AllDay, 57 AllDay,
58 TimeZone 58 TimeZone
59 }; 59 };
60 60
61 /** 61 /**
62 * Start with an Empty OEvent. UID == 0 means that it is empty 62 * Start with an Empty OEvent. UID == 0 means that it is empty
63 */ 63 */
64 OEvent(int uid = 0); 64 OEvent(int uid = 0);
65 65
66 /** 66 /**
67 * copy c'tor 67 * copy c'tor
68 */ 68 */
69 OEvent( const OEvent& ); 69 OEvent( const OEvent& );
70 ~OEvent(); 70 ~OEvent();
71 OEvent &operator=( const OEvent& ); 71 OEvent &operator=( const OEvent& );
72 72
73 QString description()const; 73 QString description()const;
74 void setDescription( const QString& description ); 74 void setDescription( const QString& description );
75 75
76 QString location()const; 76 QString location()const;
77 void setLocation( const QString& loc ); 77 void setLocation( const QString& loc );
78 78
79 bool hasNotifiers()const; 79 bool hasNotifiers()const;
80 OPimNotifyManager &notifiers()const; 80 OPimNotifyManager &notifiers()const;
81 81
82 ORecur recurrence()const; 82 ORecur recurrence()const;
83 void setRecurrence( const ORecur& ); 83 void setRecurrence( const ORecur& );
84 bool hasRecurrence()const; 84 bool hasRecurrence()const;
85 85
86 QString note()const; 86 QString note()const;
87 void setNote( const QString& note ); 87 void setNote( const QString& note );
88 88
89 89
90 QDateTime createdDateTime()const; 90 QDateTime createdDateTime()const;
91 void setCreatedDateTime( const QDateTime& dt); 91 void setCreatedDateTime( const QDateTime& dt);
92 92
93 /** set the date to dt. dt is the QDateTime in localtime */ 93 /** set the date to dt. dt is the QDateTime in localtime */
94 void setStartDateTime( const QDateTime& ); 94 void setStartDateTime( const QDateTime& );
95 /** returns the datetime in the local timeZone */ 95 /** returns the datetime in the local timeZone */
96 QDateTime startDateTime()const; 96 QDateTime startDateTime()const;
97 97
98 /** returns the start datetime in the current zone */ 98 /** returns the start datetime in the current zone */
99 QDateTime startDateTimeInZone()const; 99 QDateTime startDateTimeInZone()const;
100 100
101 /** in current timezone */ 101 /** in current timezone */
102 void setEndDateTime( const QDateTime& ); 102 void setEndDateTime( const QDateTime& );
103 /** in current timezone */ 103 /** in current timezone */
104 QDateTime endDateTime()const; 104 QDateTime endDateTime()const;
105 QDateTime endDateTimeInZone()const; 105 QDateTime endDateTimeInZone()const;
106 106
107 bool isMultipleDay()const; 107 bool isMultipleDay()const;
108 bool isAllDay()const; 108 bool isAllDay()const;
109 void setAllDay( bool isAllDay ); 109 void setAllDay( bool isAllDay );
110 110
111 /* pin this event to a timezone! FIXME */ 111 /* pin this event to a timezone! FIXME */
112 void setTimeZone( const QString& timeZone ); 112 void setTimeZone( const QString& timeZone );
113 QString timeZone()const; 113 QString timeZone()const;
114 114
115 115
116 bool match( const QRegExp& )const; 116 virtual bool match( const QRegExp& )const;
117 117
118 /** For exception to recurrence here is a list of children... */ 118 /** For exception to recurrence here is a list of children... */
119 QArray<int> children()const; 119 QArray<int> children()const;
120 void setChildren( const QArray<int>& ); 120 void setChildren( const QArray<int>& );
121 void addChild( int uid ); 121 void addChild( int uid );
122 void removeChild( int uid ); 122 void removeChild( int uid );
123 123
124 /** return the parent OEvent */ 124 /** return the parent OEvent */
125 int parent()const; 125 int parent()const;
126 void setParent( int uid ); 126 void setParent( int uid );
127 127
128 128
129 /* needed reimp */ 129 /* needed reimp */
130 QString toRichText()const; 130 QString toRichText()const;
131 QString toShortText()const; 131 QString toShortText()const;
132 QString type()const; 132 QString type()const;
133 133
134 QMap<int, QString> toMap()const; 134 QMap<int, QString> toMap()const;
135 QMap<QString, QString> toExtraMap()const; 135 QMap<QString, QString> toExtraMap()const;
136 QString recordField(int )const; 136 QString recordField(int )const;
137 137
138 static int rtti(); 138 static int rtti();
139 139
140 bool loadFromStream( QDataStream& ); 140 bool loadFromStream( QDataStream& );
141 bool saveToStream( QDataStream& )const; 141 bool saveToStream( QDataStream& )const;
142 142
143/* bool operator==( const OEvent& ); 143/* bool operator==( const OEvent& );
144 bool operator!=( const OEvent& ); 144 bool operator!=( const OEvent& );
145 bool operator<( const OEvent& ); 145 bool operator<( const OEvent& );
146 bool operator<=( const OEvent& ); 146 bool operator<=( const OEvent& );
147 bool operator>( const OEvent& ); 147 bool operator>( const OEvent& );
148 bool operator>=(const OEvent& ); 148 bool operator>=(const OEvent& );
149*/ 149*/
150private: 150private:
151 inline void changeOrModify(); 151 inline void changeOrModify();
152 void deref(); 152 void deref();
153 struct Data; 153 struct Data;
154 Data* data; 154 Data* data;
155 class Private; 155 class Private;
156 Private* priv; 156 Private* priv;
157 157
158}; 158};
159 159
160/** 160/**
161 * AN Event can span through multiple days. We split up a multiday eve 161 * AN Event can span through multiple days. We split up a multiday eve
162 */ 162 */
163class OEffectiveEvent { 163class OEffectiveEvent {
164public: 164public:
165 typedef QValueList<OEffectiveEvent> ValueList; 165 typedef QValueList<OEffectiveEvent> ValueList;
166 enum Position { MidWay, Start, End, StartEnd }; 166 enum Position { MidWay, Start, End, StartEnd };
167 // If we calculate the effective event of a multi-day event 167 // If we calculate the effective event of a multi-day event
168 // we have to figure out whether we are at the first day, 168 // we have to figure out whether we are at the first day,
169 // at the end, or anywhere else ("middle"). This is important 169 // at the end, or anywhere else ("middle"). This is important
170 // for the start/end times (00:00/23:59) 170 // for the start/end times (00:00/23:59)
171 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- 171 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi-
172 // day event 172 // day event
173 // Start: start time -> 23:59 173 // Start: start time -> 23:59
174 // End: 00:00 -> end time 174 // End: 00:00 -> end time
175 // Start | End == StartEnd: for single-day events (default) 175 // Start | End == StartEnd: for single-day events (default)
176 // here we draw start time -> end time 176 // here we draw start time -> end time
177 OEffectiveEvent(); 177 OEffectiveEvent();
178 OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); 178 OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd );
179 OEffectiveEvent( const OEffectiveEvent& ); 179 OEffectiveEvent( const OEffectiveEvent& );
180 OEffectiveEvent &operator=(const OEffectiveEvent& ); 180 OEffectiveEvent &operator=(const OEffectiveEvent& );
181 ~OEffectiveEvent(); 181 ~OEffectiveEvent();
182 182
183 void setStartTime( const QTime& ); 183 void setStartTime( const QTime& );
184 void setEndTime( const QTime& ); 184 void setEndTime( const QTime& );
185 void setEvent( const OEvent& ); 185 void setEvent( const OEvent& );
186 void setDate( const QDate& ); 186 void setDate( const QDate& );
187 187
188 void setEffectiveDates( const QDate& from, const QDate& to ); 188 void setEffectiveDates( const QDate& from, const QDate& to );
189 189
190 QString description()const; 190 QString description()const;
191 QString location()const; 191 QString location()const;
192 QString note()const; 192 QString note()const;
193 OEvent event()const; 193 OEvent event()const;
194 QTime startTime()const; 194 QTime startTime()const;
195 QTime endTime()const; 195 QTime endTime()const;
196 QDate date()const; 196 QDate date()const;
197 197
198 /* return the length in hours */ 198 /* return the length in hours */
199 int length()const; 199 int length()const;
200 int size()const; 200 int size()const;
201 201
202 QDate startDate()const; 202 QDate startDate()const;
203 QDate endDate()const; 203 QDate endDate()const;
204 204
205 bool operator<( const OEffectiveEvent &e ) const; 205 bool operator<( const OEffectiveEvent &e ) const;
206 bool operator<=( const OEffectiveEvent &e ) const; 206 bool operator<=( const OEffectiveEvent &e ) const;
207 bool operator==( const OEffectiveEvent &e ) const; 207 bool operator==( const OEffectiveEvent &e ) const;
208 bool operator!=( const OEffectiveEvent &e ) const; 208 bool operator!=( const OEffectiveEvent &e ) const;
209 bool operator>( const OEffectiveEvent &e ) const; 209 bool operator>( const OEffectiveEvent &e ) const;
210 bool operator>= ( const OEffectiveEvent &e ) const; 210 bool operator>= ( const OEffectiveEvent &e ) const;
211 211
212private: 212private:
213 void deref(); 213 void deref();
214 inline void changeOrModify(); 214 inline void changeOrModify();
215 class Private; 215 class Private;
216 Private* priv; 216 Private* priv;
217 struct Data; 217 struct Data;
218 Data* data; 218 Data* data;
219 219
220}; 220};
221#endif 221#endif
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h
index 01a0c86..f4bbe35 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/libopie/pim/opimaccessbackend.h
@@ -1,153 +1,159 @@
1#ifndef OPIE_PIM_ACCESS_BACKEND 1#ifndef OPIE_PIM_ACCESS_BACKEND
2#define OPIE_PIM_ACCESS_BACKEND 2#define OPIE_PIM_ACCESS_BACKEND
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/otemplatebase.h> 6#include <opie/otemplatebase.h>
7#include <opie/opimrecord.h> 7#include <opie/opimrecord.h>
8 8
9 9
10/** 10/**
11 * OPimAccessBackend is the base class 11 * OPimAccessBackend is the base class
12 * for all private backends 12 * for all private backends
13 * it operates on OPimRecord as the base class 13 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 14 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 15 * the resource the implementation takes care
16 * of 16 * of
17 */ 17 */
18template <class T = OPimRecord> 18template <class T = OPimRecord>
19class OPimAccessBackend { 19class OPimAccessBackend {
20public: 20public:
21 typedef OTemplateBase<T> Frontend; 21 typedef OTemplateBase<T> Frontend;
22 22
23 /** The access hint from the frontend */ 23 /** The access hint from the frontend */
24 OPimAccessBackend(int access = 0); 24 OPimAccessBackend(int access = 0);
25 virtual ~OPimAccessBackend(); 25 virtual ~OPimAccessBackend();
26 26
27 /** 27 /**
28 * load the resource 28 * load the resource
29 */ 29 */
30 virtual bool load() = 0; 30 virtual bool load() = 0;
31 31
32 /** 32 /**
33 * reload the resource 33 * reload the resource
34 */ 34 */
35 virtual bool reload() = 0; 35 virtual bool reload() = 0;
36 36
37 /** 37 /**
38 * save the resource and 38 * save the resource and
39 * all it's changes 39 * all it's changes
40 */ 40 */
41 virtual bool save() = 0; 41 virtual bool save() = 0;
42 42
43 /** 43 /**
44 * return an array of 44 * return an array of
45 * all available uids 45 * all available uids
46 */ 46 */
47 virtual QArray<int> allRecords()const = 0; 47 virtual QArray<int> allRecords()const = 0;
48 48
49 /**
50 * return a List of records
51 * that match the regex
52 */
53 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
54
49 /** 55 /**
50 * queryByExample for T with the given Settings 56 * queryByExample for T with the given Settings
51 * 57 *
52 */ 58 */
53 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; 59 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0;
54 60
55 /** 61 /**
56 * find the OPimRecord with uid @param uid 62 * find the OPimRecord with uid @param uid
57 * returns T and T.isEmpty() if nothing was found 63 * returns T and T.isEmpty() if nothing was found
58 */ 64 */
59 virtual T find(int uid )const = 0; 65 virtual T find(int uid )const = 0;
60 66
61 virtual T find(int uid, const QArray<int>& items, 67 virtual T find(int uid, const QArray<int>& items,
62 uint current, typename Frontend::CacheDirection )const ; 68 uint current, typename Frontend::CacheDirection )const ;
63 /** 69 /**
64 * clear the back end 70 * clear the back end
65 */ 71 */
66 virtual void clear() = 0; 72 virtual void clear() = 0;
67 73
68 /** 74 /**
69 * add T 75 * add T
70 */ 76 */
71 virtual bool add( const T& t ) = 0; 77 virtual bool add( const T& t ) = 0;
72 78
73 /** 79 /**
74 * remove 80 * remove
75 */ 81 */
76 virtual bool remove( int uid ) = 0; 82 virtual bool remove( int uid ) = 0;
77 83
78 /** 84 /**
79 * replace a record with T.uid() 85 * replace a record with T.uid()
80 */ 86 */
81 virtual bool replace( const T& t ) = 0; 87 virtual bool replace( const T& t ) = 0;
82 88
83 /* 89 /*
84 * setTheFrontEnd!!! 90 * setTheFrontEnd!!!
85 */ 91 */
86 void setFrontend( Frontend* front ); 92 void setFrontend( Frontend* front );
87 93
88 /** 94 /**
89 * set the read ahead count 95 * set the read ahead count
90 */ 96 */
91 void setReadAhead( uint count ); 97 void setReadAhead( uint count );
92protected: 98protected:
93 int access()const; 99 int access()const;
94 void cache( const T& t )const; 100 void cache( const T& t )const;
95 101
96 /** 102 /**
97 * use a prime number here! 103 * use a prime number here!
98 */ 104 */
99 void setSaneCacheSize( int ); 105 void setSaneCacheSize( int );
100 106
101 uint readAhead()const; 107 uint readAhead()const;
102 108
103private: 109private:
104 class Private; 110 class Private;
105 Private* d; 111 Private* d;
106 Frontend* m_front; 112 Frontend* m_front;
107 uint m_read; 113 uint m_read;
108 int m_acc; 114 int m_acc;
109 115
110}; 116};
111 117
112template <class T> 118template <class T>
113OPimAccessBackend<T>::OPimAccessBackend(int acc) 119OPimAccessBackend<T>::OPimAccessBackend(int acc)
114 : m_acc( acc ) 120 : m_acc( acc )
115{ 121{
116 m_front = 0l; 122 m_front = 0l;
117} 123}
118template <class T> 124template <class T>
119OPimAccessBackend<T>::~OPimAccessBackend() { 125OPimAccessBackend<T>::~OPimAccessBackend() {
120 126
121} 127}
122template <class T> 128template <class T>
123void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 129void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
124 m_front = fr; 130 m_front = fr;
125} 131}
126template <class T> 132template <class T>
127void OPimAccessBackend<T>::cache( const T& t )const { 133void OPimAccessBackend<T>::cache( const T& t )const {
128 if (m_front ) 134 if (m_front )
129 m_front->cache( t ); 135 m_front->cache( t );
130} 136}
131template <class T> 137template <class T>
132void OPimAccessBackend<T>::setSaneCacheSize( int size) { 138void OPimAccessBackend<T>::setSaneCacheSize( int size) {
133 if (m_front ) 139 if (m_front )
134 m_front->setSaneCacheSize( size ); 140 m_front->setSaneCacheSize( size );
135} 141}
136template <class T> 142template <class T>
137T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 143T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
138 uint, typename Frontend::CacheDirection )const { 144 uint, typename Frontend::CacheDirection )const {
139 return find( uid ); 145 return find( uid );
140} 146}
141template <class T> 147template <class T>
142void OPimAccessBackend<T>::setReadAhead( uint count ) { 148void OPimAccessBackend<T>::setReadAhead( uint count ) {
143 m_read = count; 149 m_read = count;
144} 150}
145template <class T> 151template <class T>
146uint OPimAccessBackend<T>::readAhead()const { 152uint OPimAccessBackend<T>::readAhead()const {
147 return m_read; 153 return m_read;
148} 154}
149template <class T> 155template <class T>
150int OPimAccessBackend<T>::access()const { 156int OPimAccessBackend<T>::access()const {
151 return m_acc; 157 return m_acc;
152} 158}
153#endif 159#endif
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index 6a3a0db..8ff205c 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -1,286 +1,298 @@
1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H 1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H
2#define OPIE_PIM_ACCESS_TEMPLATE_H 2#define OPIE_PIM_ACCESS_TEMPLATE_H
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7#include <opie/opimaccessbackend.h> 7#include <opie/opimaccessbackend.h>
8#include <opie/orecordlist.h> 8#include <opie/orecordlist.h>
9 9
10#include "opimcache.h" 10#include "opimcache.h"
11#include "otemplatebase.h" 11#include "otemplatebase.h"
12 12
13/** 13/**
14 * Thats the frontend to our OPIE PIM 14 * Thats the frontend to our OPIE PIM
15 * Library. Either you want to use it's 15 * Library. Either you want to use it's
16 * interface or you want to implement 16 * interface or you want to implement
17 * your own Access lib 17 * your own Access lib
18 * Just create a OPimRecord and inherit from 18 * Just create a OPimRecord and inherit from
19 * the plugins 19 * the plugins
20 */ 20 */
21 21
22template <class T = OPimRecord > 22template <class T = OPimRecord >
23class OPimAccessTemplate : public OTemplateBase<T> { 23class OPimAccessTemplate : public OTemplateBase<T> {
24public: 24public:
25 enum Access { 25 enum Access {
26 Random = 0, 26 Random = 0,
27 SortedAccess 27 SortedAccess
28 }; 28 };
29 typedef ORecordList<T> List; 29 typedef ORecordList<T> List;
30 typedef OPimAccessBackend<T> BackEnd; 30 typedef OPimAccessBackend<T> BackEnd;
31 typedef OPimCache<T> Cache; 31 typedef OPimCache<T> Cache;
32 32
33 /** 33 /**
34 * c'tor BackEnd 34 * c'tor BackEnd
35 * enum Access a small hint on how to handle the backend 35 * enum Access a small hint on how to handle the backend
36 */ 36 */
37 OPimAccessTemplate( BackEnd* end); 37 OPimAccessTemplate( BackEnd* end);
38 38
39 virtual ~OPimAccessTemplate(); 39 virtual ~OPimAccessTemplate();
40 40
41 /** 41 /**
42 * load from the backend 42 * load from the backend
43 */ 43 */
44 bool load(); 44 bool load();
45 45
46 /** Reload database. 46 /** Reload database.
47 * You should execute this function if the external database 47 * You should execute this function if the external database
48 * was changed. 48 * was changed.
49 * This function will load the external database and afterwards 49 * This function will load the external database and afterwards
50 * rejoin the local changes. Therefore the local database will be set consistent. 50 * rejoin the local changes. Therefore the local database will be set consistent.
51 */ 51 */
52 virtual bool reload(); 52 virtual bool reload();
53 53
54 /** Save contacts database. 54 /** Save contacts database.
55 * Save is more a "commit". After calling this function, all changes are public available. 55 * Save is more a "commit". After calling this function, all changes are public available.
56 * @return true if successful 56 * @return true if successful
57 */ 57 */
58 bool save(); 58 bool save();
59 59
60 /** 60 /**
61 * if the resource was changed externally 61 * if the resource was changed externally
62 * You should use the signal handling instead of polling possible changes ! 62 * You should use the signal handling instead of polling possible changes !
63 * zecke: Do you implement a signal for otodoaccess ? 63 * zecke: Do you implement a signal for otodoaccess ?
64 */ 64 */
65 bool wasChangedExternally()const; 65 bool wasChangedExternally()const;
66 66
67 /** 67 /**
68 * return a List of records 68 * return a List of records
69 * you can iterate over them 69 * you can iterate over them
70 */ 70 */
71 virtual List allRecords()const; 71 virtual List allRecords()const;
72
73 /**
74 * return a List of records
75 * that match the regex
76 */
77 virtual List matchRegexp( const QRegExp &r ) const;
72 78
73 /** 79 /**
74 * queryByExample. 80 * queryByExample.
75 * @see otodoaccess, ocontactaccess 81 * @see otodoaccess, ocontactaccess
76 */ 82 */
77 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); 83 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
78 84
79 /** 85 /**
80 * find the OPimRecord uid 86 * find the OPimRecord uid
81 */ 87 */
82 virtual T find( int uid )const; 88 virtual T find( int uid )const;
83 89
84 /** 90 /**
85 * read ahead cache find method ;) 91 * read ahead cache find method ;)
86 */ 92 */
87 virtual T find( int uid, const QArray<int>&, 93 virtual T find( int uid, const QArray<int>&,
88 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 94 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
89 95
90 /* invalidate cache here */ 96 /* invalidate cache here */
91 /** 97 /**
92 * clears the backend and invalidates the backend 98 * clears the backend and invalidates the backend
93 */ 99 */
94 void clear() ; 100 void clear() ;
95 101
96 /** 102 /**
97 * add T to the backend 103 * add T to the backend
98 * @param t The item to add. 104 * @param t The item to add.
99 * @return <i>true</i> if added successfully. 105 * @return <i>true</i> if added successfully.
100 */ 106 */
101 virtual bool add( const T& t ) ; 107 virtual bool add( const T& t ) ;
102 bool add( const OPimRecord& ); 108 bool add( const OPimRecord& );
103 109
104 /* only the uid matters */ 110 /* only the uid matters */
105 /** 111 /**
106 * remove T from the backend 112 * remove T from the backend
107 * @param t The item to remove 113 * @param t The item to remove
108 * @return <i>true</i> if successful. 114 * @return <i>true</i> if successful.
109 */ 115 */
110 virtual bool remove( const T& t ); 116 virtual bool remove( const T& t );
111 117
112 /** 118 /**
113 * remove the OPimRecord with uid 119 * remove the OPimRecord with uid
114 * @param uid The ID of the item to remove 120 * @param uid The ID of the item to remove
115 * @return <i>true</i> if successful. 121 * @return <i>true</i> if successful.
116 */ 122 */
117 bool remove( int uid ); 123 bool remove( int uid );
118 bool remove( const OPimRecord& ); 124 bool remove( const OPimRecord& );
119 125
120 /** 126 /**
121 * replace T from backend 127 * replace T from backend
122 * @param t The item to replace 128 * @param t The item to replace
123 * @return <i>true</i> if successful. 129 * @return <i>true</i> if successful.
124 */ 130 */
125 virtual bool replace( const T& t) ; 131 virtual bool replace( const T& t) ;
126 132
127 void setReadAhead( uint count ); 133 void setReadAhead( uint count );
128 /** 134 /**
129 * @internal 135 * @internal
130 */ 136 */
131 void cache( const T& )const; 137 void cache( const T& )const;
132 void setSaneCacheSize( int ); 138 void setSaneCacheSize( int );
133 139
134 QArray<int> records()const; 140 QArray<int> records()const;
135protected: 141protected:
136 /** 142 /**
137 * invalidate the cache 143 * invalidate the cache
138 */ 144 */
139 void invalidateCache(); 145 void invalidateCache();
140 146
141 void setBackEnd( BackEnd* end ); 147 void setBackEnd( BackEnd* end );
142 /** 148 /**
143 * returns the backend 149 * returns the backend
144 */ 150 */
145 BackEnd* backEnd(); 151 BackEnd* backEnd();
146 BackEnd* m_backEnd; 152 BackEnd* m_backEnd;
147 Cache m_cache; 153 Cache m_cache;
148 154
149}; 155};
150 156
151template <class T> 157template <class T>
152OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 158OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
153 : OTemplateBase<T>(), m_backEnd( end ) 159 : OTemplateBase<T>(), m_backEnd( end )
154{ 160{
155 if (end ) 161 if (end )
156 end->setFrontend( this ); 162 end->setFrontend( this );
157} 163}
158template <class T> 164template <class T>
159OPimAccessTemplate<T>::~OPimAccessTemplate() { 165OPimAccessTemplate<T>::~OPimAccessTemplate() {
160 qWarning("~OPimAccessTemplate<T>"); 166 qWarning("~OPimAccessTemplate<T>");
161 delete m_backEnd; 167 delete m_backEnd;
162} 168}
163template <class T> 169template <class T>
164bool OPimAccessTemplate<T>::load() { 170bool OPimAccessTemplate<T>::load() {
165 invalidateCache(); 171 invalidateCache();
166 return m_backEnd->load(); 172 return m_backEnd->load();
167} 173}
168template <class T> 174template <class T>
169bool OPimAccessTemplate<T>::reload() { 175bool OPimAccessTemplate<T>::reload() {
170 invalidateCache(); // zecke: I think this should be added (se) 176 invalidateCache(); // zecke: I think this should be added (se)
171 return m_backEnd->reload(); 177 return m_backEnd->reload();
172} 178}
173template <class T> 179template <class T>
174bool OPimAccessTemplate<T>::save() { 180bool OPimAccessTemplate<T>::save() {
175 return m_backEnd->save(); 181 return m_backEnd->save();
176} 182}
177template <class T> 183template <class T>
178typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 184typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
179 QArray<int> ints = m_backEnd->allRecords(); 185 QArray<int> ints = m_backEnd->allRecords();
180 List lis(ints, this ); 186 List lis(ints, this );
181 return lis; 187 return lis;
182} 188}
183template <class T> 189template <class T>
190typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
191 QArray<int> ints = m_backEnd->matchRegexp( r );
192 List lis(ints, this );
193 return lis;
194}
195template <class T>
184QArray<int> OPimAccessTemplate<T>::records()const { 196QArray<int> OPimAccessTemplate<T>::records()const {
185 return m_backEnd->allRecords(); 197 return m_backEnd->allRecords();
186} 198}
187template <class T> 199template <class T>
188typename OPimAccessTemplate<T>::List 200typename OPimAccessTemplate<T>::List
189OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { 201OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) {
190 QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); 202 QArray<int> ints = m_backEnd->queryByExample( t, settings, d );
191 203
192 List lis(ints, this ); 204 List lis(ints, this );
193 return lis; 205 return lis;
194} 206}
195template <class T> 207template <class T>
196T OPimAccessTemplate<T>::find( int uid ) const{ 208T OPimAccessTemplate<T>::find( int uid ) const{
197 T t = m_backEnd->find( uid ); 209 T t = m_backEnd->find( uid );
198 cache( t ); 210 cache( t );
199 return t; 211 return t;
200} 212}
201template <class T> 213template <class T>
202T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 214T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
203 uint current, typename OTemplateBase<T>::CacheDirection dir )const { 215 uint current, typename OTemplateBase<T>::CacheDirection dir )const {
204 /* 216 /*
205 * better do T.isEmpty() 217 * better do T.isEmpty()
206 * after a find this way we would 218 * after a find this way we would
207 * avoid two finds in QCache... 219 * avoid two finds in QCache...
208 */ 220 */
209 // qWarning("find it now %d", uid ); 221 // qWarning("find it now %d", uid );
210 if (m_cache.contains( uid ) ) { 222 if (m_cache.contains( uid ) ) {
211 return m_cache.find( uid ); 223 return m_cache.find( uid );
212 } 224 }
213 225
214 T t = m_backEnd->find( uid, ar, current, dir ); 226 T t = m_backEnd->find( uid, ar, current, dir );
215 cache( t ); 227 cache( t );
216 return t; 228 return t;
217} 229}
218template <class T> 230template <class T>
219void OPimAccessTemplate<T>::clear() { 231void OPimAccessTemplate<T>::clear() {
220 invalidateCache(); 232 invalidateCache();
221 m_backEnd->clear(); 233 m_backEnd->clear();
222} 234}
223template <class T> 235template <class T>
224bool OPimAccessTemplate<T>::add( const T& t ) { 236bool OPimAccessTemplate<T>::add( const T& t ) {
225 cache( t ); 237 cache( t );
226 return m_backEnd->add( t ); 238 return m_backEnd->add( t );
227} 239}
228template <class T> 240template <class T>
229bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { 241bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
230 /* same type */ 242 /* same type */
231 if ( rec.rtti() == T::rtti() ) { 243 if ( rec.rtti() == T::rtti() ) {
232 const T &t = static_cast<const T&>(rec); 244 const T &t = static_cast<const T&>(rec);
233 return add(t); 245 return add(t);
234 } 246 }
235 return false; 247 return false;
236} 248}
237template <class T> 249template <class T>
238bool OPimAccessTemplate<T>::remove( const T& t ) { 250bool OPimAccessTemplate<T>::remove( const T& t ) {
239 return remove( t.uid() ); 251 return remove( t.uid() );
240} 252}
241template <class T> 253template <class T>
242bool OPimAccessTemplate<T>::remove( int uid ) { 254bool OPimAccessTemplate<T>::remove( int uid ) {
243 m_cache.remove( uid ); 255 m_cache.remove( uid );
244 return m_backEnd->remove( uid ); 256 return m_backEnd->remove( uid );
245} 257}
246template <class T> 258template <class T>
247bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { 259bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) {
248 return remove( rec.uid() ); 260 return remove( rec.uid() );
249} 261}
250template <class T> 262template <class T>
251bool OPimAccessTemplate<T>::replace( const T& t ) { 263bool OPimAccessTemplate<T>::replace( const T& t ) {
252 m_cache.replace( t ); 264 m_cache.replace( t );
253 return m_backEnd->replace( t ); 265 return m_backEnd->replace( t );
254} 266}
255template <class T> 267template <class T>
256void OPimAccessTemplate<T>::invalidateCache() { 268void OPimAccessTemplate<T>::invalidateCache() {
257 m_cache.invalidate(); 269 m_cache.invalidate();
258} 270}
259template <class T> 271template <class T>
260typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { 272typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() {
261 return m_backEnd; 273 return m_backEnd;
262} 274}
263template <class T> 275template <class T>
264bool OPimAccessTemplate<T>::wasChangedExternally()const { 276bool OPimAccessTemplate<T>::wasChangedExternally()const {
265 return false; 277 return false;
266} 278}
267template <class T> 279template <class T>
268void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { 280void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) {
269 m_backEnd = end; 281 m_backEnd = end;
270 if (m_backEnd ) 282 if (m_backEnd )
271 m_backEnd->setFrontend( this ); 283 m_backEnd->setFrontend( this );
272} 284}
273template <class T> 285template <class T>
274void OPimAccessTemplate<T>::cache( const T& t ) const{ 286void OPimAccessTemplate<T>::cache( const T& t ) const{
275 /* hacky we need to work around the const*/ 287 /* hacky we need to work around the const*/
276 ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); 288 ((OPimAccessTemplate<T>*)this)->m_cache.add( t );
277} 289}
278template <class T> 290template <class T>
279void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { 291void OPimAccessTemplate<T>::setSaneCacheSize( int size ) {
280 m_cache.setSize( size ); 292 m_cache.setSize( size );
281} 293}
282template <class T> 294template <class T>
283void OPimAccessTemplate<T>::setReadAhead( uint count ) { 295void OPimAccessTemplate<T>::setReadAhead( uint count ) {
284 m_backEnd->setReadAhead( count ); 296 m_backEnd->setReadAhead( count );
285} 297}
286#endif 298#endif
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index c7f9460..de2d9f4 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -1,134 +1,140 @@
1#ifndef OPIE_PIM_RECORD_H 1#ifndef OPIE_PIM_RECORD_H
2#define OPIE_PIM_RECORD_H 2#define OPIE_PIM_RECORD_H
3 3
4#include <qdatastream.h> 4#include <qdatastream.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10 10
11#include <opie/opimxrefmanager.h> 11#include <opie/opimxrefmanager.h>
12 12
13/** 13/**
14 * This is the base class for 14 * This is the base class for
15 * all PIM Records 15 * all PIM Records
16 * 16 *
17 */ 17 */
18class OPimRecord : public Qtopia::Record { 18class OPimRecord : public Qtopia::Record {
19public: 19public:
20 /** 20 /**
21 * c'tor 21 * c'tor
22 * uid of 0 isEmpty 22 * uid of 0 isEmpty
23 * uid of 1 will be assigned a new one 23 * uid of 1 will be assigned a new one
24 */ 24 */
25 OPimRecord(int uid = 0); 25 OPimRecord(int uid = 0);
26 ~OPimRecord(); 26 ~OPimRecord();
27 27
28 /** 28 /**
29 * copy c'tor 29 * copy c'tor
30 */ 30 */
31 OPimRecord( const OPimRecord& rec ); 31 OPimRecord( const OPimRecord& rec );
32 32
33 /** 33 /**
34 * copy operator 34 * copy operator
35 */ 35 */
36 OPimRecord &operator=( const OPimRecord& ); 36 OPimRecord &operator=( const OPimRecord& );
37 37
38 /** 38 /**
39 * category names resolved 39 * category names resolved
40 */ 40 */
41 QStringList categoryNames( const QString& appname )const; 41 QStringList categoryNames( const QString& appname )const;
42 42
43 /** 43 /**
44 * set category names they will be resolved 44 * set category names they will be resolved
45 */ 45 */
46 void setCategoryNames( const QStringList& ); 46 void setCategoryNames( const QStringList& );
47 47
48 /** 48 /**
49 * addCategoryName adds a name 49 * addCategoryName adds a name
50 * to the internal category list 50 * to the internal category list
51 */ 51 */
52 void addCategoryName( const QString& ); 52 void addCategoryName( const QString& );
53 53
54 /** 54 /**
55 * if a Record isEmpty 55 * if a Record isEmpty
56 * it's empty if it's 0 56 * it's empty if it's 0
57 */ 57 */
58 virtual bool isEmpty()const; 58 virtual bool isEmpty()const;
59 59
60 /** 60 /**
61 * toRichText summary 61 * toRichText summary
62 */ 62 */
63 virtual QString toRichText()const = 0; 63 virtual QString toRichText()const = 0;
64 64
65 /** 65 /**
66 * a small one line summary 66 * a small one line summary
67 */ 67 */
68 virtual QString toShortText()const = 0; 68 virtual QString toShortText()const = 0;
69 69
70 /** 70 /**
71 * the name of the Record 71 * the name of the Record
72 */ 72 */
73 virtual QString type()const = 0; 73 virtual QString type()const = 0;
74 74
75 /** 75 /**
76 * matches the Records the regular expression?
77 */
78 virtual bool match( const QString &regexp ) const {return match(QRegExp(regexp));};
79 virtual bool match( const QRegExp &regexp ) const = 0;
80
81 /**
76 * converts the internal structure to a map 82 * converts the internal structure to a map
77 */ 83 */
78 virtual QMap<int, QString> toMap()const = 0; 84 virtual QMap<int, QString> toMap()const = 0;
79 85
80 /** 86 /**
81 * key value representation of extra items 87 * key value representation of extra items
82 */ 88 */
83 virtual QMap<QString, QString> toExtraMap()const = 0; 89 virtual QMap<QString, QString> toExtraMap()const = 0;
84 90
85 /** 91 /**
86 * the name for a recordField 92 * the name for a recordField
87 */ 93 */
88 virtual QString recordField(int)const = 0; 94 virtual QString recordField(int)const = 0;
89 95
90 /** 96 /**
91 * returns a reference of the 97 * returns a reference of the
92 * Cross Reference Manager 98 * Cross Reference Manager
93 * Partner 'One' is THIS PIM RECORD! 99 * Partner 'One' is THIS PIM RECORD!
94 * 'Two' is the Partner where we link to 100 * 'Two' is the Partner where we link to
95 */ 101 */
96 OPimXRefManager& xrefmanager(); 102 OPimXRefManager& xrefmanager();
97 103
98 /** 104 /**
99 * set the uid 105 * set the uid
100 */ 106 */
101 virtual void setUid( int uid ); 107 virtual void setUid( int uid );
102 108
103 /* 109 /*
104 * used inside the Templates for casting 110 * used inside the Templates for casting
105 * REIMPLEMENT in your .... 111 * REIMPLEMENT in your ....
106 */ 112 */
107 static int rtti(); 113 static int rtti();
108 114
109 /** 115 /**
110 * some marshalling and de marshalling code 116 * some marshalling and de marshalling code
111 * saves the OPimRecord 117 * saves the OPimRecord
112 * to and from a DataStream 118 * to and from a DataStream
113 */ 119 */
114 virtual bool loadFromStream(QDataStream& ); 120 virtual bool loadFromStream(QDataStream& );
115 virtual bool saveToStream( QDataStream& stream )const; 121 virtual bool saveToStream( QDataStream& stream )const;
116 122
117protected: 123protected:
118 Qtopia::UidGen &uidGen(); 124 Qtopia::UidGen &uidGen();
119// QString crossToString()const; 125// QString crossToString()const;
120 126
121private: 127private:
122 class OPimRecordPrivate; 128 class OPimRecordPrivate;
123 OPimRecordPrivate *d; 129 OPimRecordPrivate *d;
124 OPimXRefManager m_xrefman; 130 OPimXRefManager m_xrefman;
125 static Qtopia::UidGen m_uidGen; 131 static Qtopia::UidGen m_uidGen;
126 132
127private: 133private:
128 void flush( const OPimXRefPartner&, QDataStream& stream )const; 134 void flush( const OPimXRefPartner&, QDataStream& stream )const;
129 OPimXRefPartner partner( QDataStream& ); 135 OPimXRefPartner partner( QDataStream& );
130}; 136};
131 137
132 138
133 139
134#endif 140#endif
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index a58d9aa..0e7c73f 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -69,221 +69,221 @@ public:
69 69
70 OTodo( bool completed, int priority, 70 OTodo( bool completed, int priority,
71 const QArray<int>& category, 71 const QArray<int>& category,
72 const QString& summary = QString::null, 72 const QString& summary = QString::null,
73 const QString& description = QString::null, 73 const QString& description = QString::null,
74 ushort progress = 0, 74 ushort progress = 0,
75 bool hasDate = false, QDate date = QDate::currentDate(), 75 bool hasDate = false, QDate date = QDate::currentDate(),
76 int uid = 0 /* empty */ ); 76 int uid = 0 /* empty */ );
77 77
78 /** Copy c'tor 78 /** Copy c'tor
79 * 79 *
80 */ 80 */
81 OTodo(const OTodo & ); 81 OTodo(const OTodo & );
82 82
83 /** 83 /**
84 *destructor 84 *destructor
85 */ 85 */
86 ~OTodo(); 86 ~OTodo();
87 87
88 /** 88 /**
89 * Is this event completed? 89 * Is this event completed?
90 */ 90 */
91 bool isCompleted() const; 91 bool isCompleted() const;
92 92
93 /** 93 /**
94 * Does this Event have a deadline 94 * Does this Event have a deadline
95 */ 95 */
96 bool hasDueDate() const; 96 bool hasDueDate() const;
97 bool hasStartDate()const; 97 bool hasStartDate()const;
98 bool hasCompletedDate()const; 98 bool hasCompletedDate()const;
99 99
100 /** 100 /**
101 * Does this Event has an alarm time ? 101 * Does this Event has an alarm time ?
102 */ 102 */
103 bool hasAlarmDateTime() const; 103 bool hasAlarmDateTime() const;
104 104
105 /** 105 /**
106 * What is the priority? 106 * What is the priority?
107 */ 107 */
108 int priority()const ; 108 int priority()const ;
109 109
110 /** 110 /**
111 * progress as ushort 0, 20, 40, 60, 80 or 100% 111 * progress as ushort 0, 20, 40, 60, 80 or 100%
112 */ 112 */
113 ushort progress() const; 113 ushort progress() const;
114 114
115 /** 115 /**
116 * The due Date 116 * The due Date
117 */ 117 */
118 QDate dueDate()const; 118 QDate dueDate()const;
119 119
120 /** 120 /**
121 * When did it start? 121 * When did it start?
122 */ 122 */
123 QDate startDate()const; 123 QDate startDate()const;
124 124
125 /** 125 /**
126 * When was it completed? 126 * When was it completed?
127 */ 127 */
128 QDate completedDate()const; 128 QDate completedDate()const;
129 129
130 /** 130 /**
131 * does it have a state? 131 * does it have a state?
132 */ 132 */
133 bool hasState()const; 133 bool hasState()const;
134 134
135 /** 135 /**
136 * What is the state of this OTodo? 136 * What is the state of this OTodo?
137 */ 137 */
138 OPimState state()const; 138 OPimState state()const;
139 139
140 /** 140 /**
141 * has recurrence? 141 * has recurrence?
142 */ 142 */
143 bool hasRecurrence()const; 143 bool hasRecurrence()const;
144 144
145 /** 145 /**
146 * the recurrance of this 146 * the recurrance of this
147 */ 147 */
148 ORecur recurrence()const; 148 ORecur recurrence()const;
149 149
150 /** 150 /**
151 * does this OTodo have a maintainer? 151 * does this OTodo have a maintainer?
152 */ 152 */
153 bool hasMaintainer()const; 153 bool hasMaintainer()const;
154 154
155 /** 155 /**
156 * the Maintainer of this OTodo 156 * the Maintainer of this OTodo
157 */ 157 */
158 OPimMaintainer maintainer()const; 158 OPimMaintainer maintainer()const;
159 159
160 /** 160 /**
161 * The description of the todo 161 * The description of the todo
162 */ 162 */
163 QString description()const; 163 QString description()const;
164 164
165 /** 165 /**
166 * A small summary of the todo 166 * A small summary of the todo
167 */ 167 */
168 QString summary() const; 168 QString summary() const;
169 169
170 /** 170 /**
171 * @reimplemented 171 * @reimplemented
172 * Return this todoevent in a RichText formatted QString 172 * Return this todoevent in a RichText formatted QString
173 */ 173 */
174 QString toRichText() const; 174 QString toRichText() const;
175 175
176 bool hasNotifiers()const; 176 bool hasNotifiers()const;
177 /* 177 /*
178 * check if the sharing is still fine!! -zecke 178 * check if the sharing is still fine!! -zecke
179 */ 179 */
180 /** 180 /**
181 * return a reference to our notifiers... 181 * return a reference to our notifiers...
182 */ 182 */
183 OPimNotifyManager &notifiers(); 183 OPimNotifyManager &notifiers();
184 184
185 /** 185 /**
186 * reimplementations 186 * reimplementations
187 */ 187 */
188 QString type()const; 188 QString type()const;
189 QString toShortText()const; 189 QString toShortText()const;
190 QMap<QString, QString> toExtraMap()const; 190 QMap<QString, QString> toExtraMap()const;
191 QString recordField(int id )const; 191 QString recordField(int id )const;
192 192
193 /** 193 /**
194 * toMap puts all data into the map. int relates 194 * toMap puts all data into the map. int relates
195 * to ToDoEvent RecordFields enum 195 * to ToDoEvent RecordFields enum
196 */ 196 */
197 QMap<int, QString> toMap()const; 197 QMap<int, QString> toMap()const;
198 198
199 /** 199 /**
200 * Set if this Todo is completed 200 * Set if this Todo is completed
201 */ 201 */
202 void setCompleted(bool completed ); 202 void setCompleted(bool completed );
203 203
204 /** 204 /**
205 * set if this todo got an end data 205 * set if this todo got an end data
206 */ 206 */
207 void setHasDueDate( bool hasDate ); 207 void setHasDueDate( bool hasDate );
208 // FIXME we do not have these for start, completed 208 // FIXME we do not have these for start, completed
209 // cause we'll use the isNull() of QDate for figuring 209 // cause we'll use the isNull() of QDate for figuring
210 // out if it's has a date... 210 // out if it's has a date...
211 // decide what to do here? -zecke 211 // decide what to do here? -zecke
212 212
213 /** 213 /**
214 * Set the priority of the Todo 214 * Set the priority of the Todo
215 */ 215 */
216 void setPriority(int priority ); 216 void setPriority(int priority );
217 217
218 /** 218 /**
219 * Set the progress. 219 * Set the progress.
220 */ 220 */
221 void setProgress( ushort progress ); 221 void setProgress( ushort progress );
222 222
223 /** 223 /**
224 * set the end date 224 * set the end date
225 */ 225 */
226 void setDueDate( const QDate& date ); 226 void setDueDate( const QDate& date );
227 227
228 /** 228 /**
229 * set the start date 229 * set the start date
230 */ 230 */
231 void setStartDate( const QDate& date ); 231 void setStartDate( const QDate& date );
232 232
233 /** 233 /**
234 * set the completed date 234 * set the completed date
235 */ 235 */
236 void setCompletedDate( const QDate& date ); 236 void setCompletedDate( const QDate& date );
237 237
238 void setRecurrence( const ORecur& ); 238 void setRecurrence( const ORecur& );
239 /** 239 /**
240 * set the alarm time 240 * set the alarm time
241 */ 241 */
242 void setAlarmDateTime ( const QDateTime& alarm ); 242 void setAlarmDateTime ( const QDateTime& alarm );
243 243
244 void setDescription(const QString& ); 244 void setDescription(const QString& );
245 void setSummary(const QString& ); 245 void setSummary(const QString& );
246 246
247 /** 247 /**
248 * set the state of a Todo 248 * set the state of a Todo
249 * @param state State what the todo should take 249 * @param state State what the todo should take
250 */ 250 */
251 void setState( const OPimState& state); 251 void setState( const OPimState& state);
252 252
253 /** 253 /**
254 * set the Maintainer Mode 254 * set the Maintainer Mode
255 */ 255 */
256 void setMaintainer( const OPimMaintainer& ); 256 void setMaintainer( const OPimMaintainer& );
257 257
258 bool isOverdue(); 258 bool isOverdue();
259 259
260 260
261 bool match( const QRegExp &r )const; 261 virtual bool match( const QRegExp &r )const;
262 262
263 bool operator<(const OTodo &toDoEvent )const; 263 bool operator<(const OTodo &toDoEvent )const;
264 bool operator<=(const OTodo &toDoEvent )const; 264 bool operator<=(const OTodo &toDoEvent )const;
265 bool operator!=(const OTodo &toDoEvent )const; 265 bool operator!=(const OTodo &toDoEvent )const;
266 bool operator>(const OTodo &toDoEvent )const; 266 bool operator>(const OTodo &toDoEvent )const;
267 bool operator>=(const OTodo &toDoEvent)const; 267 bool operator>=(const OTodo &toDoEvent)const;
268 bool operator==(const OTodo &toDoEvent )const; 268 bool operator==(const OTodo &toDoEvent )const;
269 OTodo &operator=(const OTodo &toDoEvent ); 269 OTodo &operator=(const OTodo &toDoEvent );
270 270
271 static int rtti(); 271 static int rtti();
272 272
273 private: 273 private:
274 class OTodoPrivate; 274 class OTodoPrivate;
275 struct OTodoData; 275 struct OTodoData;
276 276
277 void deref(); 277 void deref();
278 inline void changeOrModify(); 278 inline void changeOrModify();
279 void copy( OTodoData* src, OTodoData* dest ); 279 void copy( OTodoData* src, OTodoData* dest );
280 OTodoPrivate *d; 280 OTodoPrivate *d;
281 OTodoData *data; 281 OTodoData *data;
282 282
283}; 283};
284inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 284inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
285 return !(*this == toDoEvent); 285 return !(*this == toDoEvent);
286} 286}
287 287
288 288
289#endif 289#endif
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp
index 9bc16c6..3577e14 100644
--- a/libopie/pim/otodoaccessvcal.cpp
+++ b/libopie/pim/otodoaccessvcal.cpp
@@ -1,221 +1,225 @@
1#include <qfile.h> 1#include <qfile.h>
2 2
3#include <qtopia/private/vobject_p.h> 3#include <qtopia/private/vobject_p.h>
4#include <qtopia/timeconversion.h> 4#include <qtopia/timeconversion.h>
5#include <qtopia/private/qfiledirect_p.h> 5#include <qtopia/private/qfiledirect_p.h>
6 6
7#include "otodoaccessvcal.h" 7#include "otodoaccessvcal.h"
8 8
9namespace { 9namespace {
10 static OTodo eventByVObj( VObject *obj ){ 10 static OTodo eventByVObj( VObject *obj ){
11 OTodo event; 11 OTodo event;
12 VObject *ob; 12 VObject *ob;
13 QCString name; 13 QCString name;
14 // no uid, attendees, ... and no fun 14 // no uid, attendees, ... and no fun
15 // description 15 // description
16 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ 16 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
17 name = vObjectStringZValue( ob ); 17 name = vObjectStringZValue( ob );
18 event.setDescription( name ); 18 event.setDescription( name );
19 } 19 }
20 // summary 20 // summary
21 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { 21 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
22 name = vObjectStringZValue( ob ); 22 name = vObjectStringZValue( ob );
23 event.setSummary( name ); 23 event.setSummary( name );
24 } 24 }
25 // completed 25 // completed
26 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 26 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
27 name = vObjectStringZValue( ob ); 27 name = vObjectStringZValue( ob );
28 if( name == "COMPLETED" ){ 28 if( name == "COMPLETED" ){
29 event.setCompleted( true ); 29 event.setCompleted( true );
30 }else{ 30 }else{
31 event.setCompleted( false ); 31 event.setCompleted( false );
32 } 32 }
33 }else 33 }else
34 event.setCompleted( false ); 34 event.setCompleted( false );
35 // priority 35 // priority
36 if ((ob = isAPropertyOf(obj, VCPriorityProp))) { 36 if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
37 name = vObjectStringZValue( ob ); 37 name = vObjectStringZValue( ob );
38 bool ok; 38 bool ok;
39 event.setPriority(name.toInt(&ok) ); 39 event.setPriority(name.toInt(&ok) );
40 } 40 }
41 //due date 41 //due date
42 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 42 if((ob = isAPropertyOf(obj, VCDueProp)) ){
43 event.setHasDueDate( true ); 43 event.setHasDueDate( true );
44 name = vObjectStringZValue( ob ); 44 name = vObjectStringZValue( ob );
45 event.setDueDate( TimeConversion::fromISO8601( name).date() ); 45 event.setDueDate( TimeConversion::fromISO8601( name).date() );
46 } 46 }
47 // categories 47 // categories
48 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 48 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
49 name = vObjectStringZValue( ob ); 49 name = vObjectStringZValue( ob );
50 qWarning("Categories:%s", name.data() ); 50 qWarning("Categories:%s", name.data() );
51 } 51 }
52 52
53 event.setUid( 1 ); 53 event.setUid( 1 );
54 return event; 54 return event;
55 }; 55 };
56 static VObject *vobjByEvent( const OTodo &event ) { 56 static VObject *vobjByEvent( const OTodo &event ) {
57 VObject *task = newVObject( VCTodoProp ); 57 VObject *task = newVObject( VCTodoProp );
58 if( task == 0 ) 58 if( task == 0 )
59 return 0l; 59 return 0l;
60 60
61 if( event.hasDueDate() ) { 61 if( event.hasDueDate() ) {
62 QTime time(0, 0, 0); 62 QTime time(0, 0, 0);
63 QDateTime date(event.dueDate(), time ); 63 QDateTime date(event.dueDate(), time );
64 addPropValue( task, VCDueProp, 64 addPropValue( task, VCDueProp,
65 TimeConversion::toISO8601( date ) ); 65 TimeConversion::toISO8601( date ) );
66 } 66 }
67 67
68 if( event.isCompleted() ) 68 if( event.isCompleted() )
69 addPropValue( task, VCStatusProp, "COMPLETED"); 69 addPropValue( task, VCStatusProp, "COMPLETED");
70 70
71 QString string = QString::number(event.priority() ); 71 QString string = QString::number(event.priority() );
72 addPropValue( task, VCPriorityProp, string.local8Bit() ); 72 addPropValue( task, VCPriorityProp, string.local8Bit() );
73 73
74 addPropValue( task, VCCategoriesProp, 74 addPropValue( task, VCCategoriesProp,
75 event.idsToString( event.categories() ).local8Bit() ); 75 event.idsToString( event.categories() ).local8Bit() );
76 76
77 addPropValue( task, VCDescriptionProp, 77 addPropValue( task, VCDescriptionProp,
78 event.description().local8Bit() ); 78 event.description().local8Bit() );
79 79
80 addPropValue( task, VCSummaryProp, 80 addPropValue( task, VCSummaryProp,
81 event.summary().local8Bit() ); 81 event.summary().local8Bit() );
82 return task; 82 return task;
83}; 83};
84} 84}
85 85
86OTodoAccessVCal::OTodoAccessVCal( const QString& path ) 86OTodoAccessVCal::OTodoAccessVCal( const QString& path )
87 : m_dirty(false), m_file( path ) 87 : m_dirty(false), m_file( path )
88{ 88{
89} 89}
90OTodoAccessVCal::~OTodoAccessVCal() { 90OTodoAccessVCal::~OTodoAccessVCal() {
91} 91}
92bool OTodoAccessVCal::load() { 92bool OTodoAccessVCal::load() {
93 m_map.clear(); 93 m_map.clear();
94 m_dirty = false; 94 m_dirty = false;
95 95
96 VObject* vcal = 0l; 96 VObject* vcal = 0l;
97 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 97 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
98 if (!vcal ) 98 if (!vcal )
99 return false; 99 return false;
100 100
101 // Iterate over the list 101 // Iterate over the list
102 VObjectIterator it; 102 VObjectIterator it;
103 VObject* vobj; 103 VObject* vobj;
104 104
105 initPropIterator(&it, vcal); 105 initPropIterator(&it, vcal);
106 106
107 while( moreIteration( &it ) ) { 107 while( moreIteration( &it ) ) {
108 vobj = ::nextVObject( &it ); 108 vobj = ::nextVObject( &it );
109 QCString name = ::vObjectName( vobj ); 109 QCString name = ::vObjectName( vobj );
110 if( name == VCTodoProp ){ 110 if( name == VCTodoProp ){
111 OTodo to = eventByVObj( vobj ); 111 OTodo to = eventByVObj( vobj );
112 m_map.insert( to.uid(), to ); 112 m_map.insert( to.uid(), to );
113 } 113 }
114 } 114 }
115 115
116 // Should I do a delete vcal? 116 // Should I do a delete vcal?
117 117
118 return true; 118 return true;
119} 119}
120bool OTodoAccessVCal::reload() { 120bool OTodoAccessVCal::reload() {
121 return load(); 121 return load();
122} 122}
123bool OTodoAccessVCal::save() { 123bool OTodoAccessVCal::save() {
124 if (!m_dirty ) 124 if (!m_dirty )
125 return true; 125 return true;
126 126
127 QFileDirect file( m_file ); 127 QFileDirect file( m_file );
128 if (!file.open(IO_WriteOnly ) ) 128 if (!file.open(IO_WriteOnly ) )
129 return false; 129 return false;
130 130
131 VObject *obj; 131 VObject *obj;
132 obj = newVObject( VCCalProp ); 132 obj = newVObject( VCCalProp );
133 addPropValue( obj, VCVersionProp, "1.0" ); 133 addPropValue( obj, VCVersionProp, "1.0" );
134 VObject *vo; 134 VObject *vo;
135 for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 135 for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
136 vo = vobjByEvent( it.data() ); 136 vo = vobjByEvent( it.data() );
137 addVObjectProp(obj, vo ); 137 addVObjectProp(obj, vo );
138 } 138 }
139 writeVObject( file.directHandle(), obj ); 139 writeVObject( file.directHandle(), obj );
140 cleanVObject( obj ); 140 cleanVObject( obj );
141 cleanStrTbl(); 141 cleanStrTbl();
142 142
143 m_dirty = false; 143 m_dirty = false;
144 return true; 144 return true;
145} 145}
146void OTodoAccessVCal::clear() { 146void OTodoAccessVCal::clear() {
147 m_map.clear(); 147 m_map.clear();
148 m_dirty = true; 148 m_dirty = true;
149} 149}
150bool OTodoAccessVCal::add( const OTodo& to ) { 150bool OTodoAccessVCal::add( const OTodo& to ) {
151 m_map.insert( to.uid(), to ); 151 m_map.insert( to.uid(), to );
152 m_dirty = true; 152 m_dirty = true;
153 return true; 153 return true;
154} 154}
155bool OTodoAccessVCal::remove( int uid ) { 155bool OTodoAccessVCal::remove( int uid ) {
156 m_map.remove( uid ); 156 m_map.remove( uid );
157 m_dirty = true; 157 m_dirty = true;
158 return true; 158 return true;
159} 159}
160void OTodoAccessVCal::removeAllCompleted() { 160void OTodoAccessVCal::removeAllCompleted() {
161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { 161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
162 if ( (*it).isCompleted() ) 162 if ( (*it).isCompleted() )
163 m_map.remove( it ); 163 m_map.remove( it );
164 } 164 }
165} 165}
166bool OTodoAccessVCal::replace( const OTodo& to ) { 166bool OTodoAccessVCal::replace( const OTodo& to ) {
167 m_map.replace( to.uid(), to ); 167 m_map.replace( to.uid(), to );
168 m_dirty = true; 168 m_dirty = true;
169 return true; 169 return true;
170} 170}
171OTodo OTodoAccessVCal::find(int uid )const { 171OTodo OTodoAccessVCal::find(int uid )const {
172 return m_map[uid]; 172 return m_map[uid];
173} 173}
174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { 174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
175 QArray<int> ar(0); 175 QArray<int> ar(0);
176 return ar; 176 return ar;
177} 177}
178QArray<int> OTodoAccessVCal::allRecords()const { 178QArray<int> OTodoAccessVCal::allRecords()const {
179 QArray<int> ar( m_map.count() ); 179 QArray<int> ar( m_map.count() );
180 QMap<int, OTodo>::ConstIterator it; 180 QMap<int, OTodo>::ConstIterator it;
181 int i = 0; 181 int i = 0;
182 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 182 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
183 ar[i] = it.key(); 183 ar[i] = it.key();
184 i++; 184 i++;
185 } 185 }
186 return ar; 186 return ar;
187} 187}
188QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const {
189 QArray<int> ar(0);
190 return ar;
191}
188QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { 192QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
189 QArray<int> ar(0); 193 QArray<int> ar(0);
190 return ar; 194 return ar;
191} 195}
192QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , 196QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& ,
193 const QDate& , 197 const QDate& ,
194 bool ) { 198 bool ) {
195 QArray<int> ar(0); 199 QArray<int> ar(0);
196 return ar; 200 return ar;
197} 201}
198QArray<int> OTodoAccessVCal::overDue() { 202QArray<int> OTodoAccessVCal::overDue() {
199 QArray<int> ar(0); 203 QArray<int> ar(0);
200 return ar; 204 return ar;
201} 205}
202QBitArray OTodoAccessVCal::supports()const { 206QBitArray OTodoAccessVCal::supports()const {
203 static QBitArray ar = sup(); 207 static QBitArray ar = sup();
204 208
205 return ar; 209 return ar;
206} 210}
207QBitArray OTodoAccessVCal::sup() { 211QBitArray OTodoAccessVCal::sup() {
208 QBitArray ar ( OTodo::CompletedDate +1 ); 212 QBitArray ar ( OTodo::CompletedDate +1 );
209 ar.fill( true ); 213 ar.fill( true );
210 214
211 ar[OTodo::CrossReference] = false; 215 ar[OTodo::CrossReference] = false;
212 ar[OTodo::State ] = false; 216 ar[OTodo::State ] = false;
213 ar[OTodo::Reminders] = false; 217 ar[OTodo::Reminders] = false;
214 ar[OTodo::Notifiers] = false; 218 ar[OTodo::Notifiers] = false;
215 ar[OTodo::Maintainer] = false; 219 ar[OTodo::Maintainer] = false;
216 ar[OTodo::Progress] = false; 220 ar[OTodo::Progress] = false;
217 ar[OTodo::Alarms ] = false; 221 ar[OTodo::Alarms ] = false;
218 ar[OTodo::Recurrence] = false; 222 ar[OTodo::Recurrence] = false;
219 223
220 return ar; 224 return ar;
221} 225}
diff --git a/libopie/pim/otodoaccessvcal.h b/libopie/pim/otodoaccessvcal.h
index 489416b..2b17147 100644
--- a/libopie/pim/otodoaccessvcal.h
+++ b/libopie/pim/otodoaccessvcal.h
@@ -1,39 +1,40 @@
1#ifndef OPIE_OTODO_ACCESS_VCAL_H 1#ifndef OPIE_OTODO_ACCESS_VCAL_H
2#define OPIE_OTODO_ACCESS_VCAL_H 2#define OPIE_OTODO_ACCESS_VCAL_H
3 3
4#include "otodoaccessbackend.h" 4#include "otodoaccessbackend.h"
5 5
6class OTodoAccessVCal : public OTodoAccessBackend { 6class OTodoAccessVCal : public OTodoAccessBackend {
7public: 7public:
8 OTodoAccessVCal(const QString& ); 8 OTodoAccessVCal(const QString& );
9 ~OTodoAccessVCal(); 9 ~OTodoAccessVCal();
10 10
11 bool load(); 11 bool load();
12 bool reload(); 12 bool reload();
13 bool save(); 13 bool save();
14 14
15 QArray<int> allRecords()const; 15 QArray<int> allRecords()const;
16 QArray<int> matchRegexp(const QRegExp &r) const;
16 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); 17 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
17 QArray<int> effectiveToDos( const QDate& start, 18 QArray<int> effectiveToDos( const QDate& start,
18 const QDate& end, 19 const QDate& end,
19 bool includeNoDates ); 20 bool includeNoDates );
20 QArray<int> overDue(); 21 QArray<int> overDue();
21 QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 22 QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
22 int cat ); 23 int cat );
23 OTodo find(int uid)const; 24 OTodo find(int uid)const;
24 void clear(); 25 void clear();
25 bool add( const OTodo& ); 26 bool add( const OTodo& );
26 bool remove( int uid ); 27 bool remove( int uid );
27 bool replace( const OTodo& ); 28 bool replace( const OTodo& );
28 29
29 void removeAllCompleted(); 30 void removeAllCompleted();
30 virtual QBitArray supports()const; 31 virtual QBitArray supports()const;
31 32
32private: 33private:
33 static QBitArray sup(); 34 static QBitArray sup();
34 bool m_dirty : 1; 35 bool m_dirty : 1;
35 QString m_file; 36 QString m_file;
36 QMap<int, OTodo> m_map; 37 QMap<int, OTodo> m_map;
37}; 38};
38 39
39#endif 40#endif
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index 285d2b8..69b7ab4 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -585,192 +585,208 @@ namespace {
585 * 0 if item1 == item2 585 * 0 if item1 == item2
586 * 586 *
587 * > 0 (positive integer) if item1 > item2 587 * > 0 (positive integer) if item1 > item2
588 * 588 *
589 * < 0 (negative integer) if item1 < item2 589 * < 0 (negative integer) if item1 < item2
590 * 590 *
591 */ 591 */
592class OTodoXMLVector : public QVector<OTodoXMLContainer> { 592class OTodoXMLVector : public QVector<OTodoXMLContainer> {
593public: 593public:
594 OTodoXMLVector(int size, bool asc, int sort) 594 OTodoXMLVector(int size, bool asc, int sort)
595 : QVector<OTodoXMLContainer>( size ) 595 : QVector<OTodoXMLContainer>( size )
596 { 596 {
597 setAutoDelete( true ); 597 setAutoDelete( true );
598 m_asc = asc; 598 m_asc = asc;
599 m_sort = sort; 599 m_sort = sort;
600 } 600 }
601 /* return the summary/description */ 601 /* return the summary/description */
602 QString string( const OTodo& todo) { 602 QString string( const OTodo& todo) {
603 return todo.summary().isEmpty() ? 603 return todo.summary().isEmpty() ?
604 todo.description().left(20 ) : 604 todo.description().left(20 ) :
605 todo.summary(); 605 todo.summary();
606 } 606 }
607 /** 607 /**
608 * we take the sortorder( switch on it ) 608 * we take the sortorder( switch on it )
609 * 609 *
610 */ 610 */
611 int compareItems( Item d1, Item d2 ) { 611 int compareItems( Item d1, Item d2 ) {
612 bool seComp, sePrio, seDesc, seDeadline; 612 bool seComp, sePrio, seDesc, seDeadline;
613 seComp = sePrio = seDeadline = seDesc = false; 613 seComp = sePrio = seDeadline = seDesc = false;
614 int ret =0; 614 int ret =0;
615 OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1; 615 OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1;
616 OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2; 616 OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2;
617 617
618 /* same item */ 618 /* same item */
619 if ( con1->todo.uid() == con2->todo.uid() ) 619 if ( con1->todo.uid() == con2->todo.uid() )
620 return 0; 620 return 0;
621 621
622 switch ( m_sort ) { 622 switch ( m_sort ) {
623 /* completed */ 623 /* completed */
624 case 0: { 624 case 0: {
625 ret = completed( con1->todo, con2->todo ); 625 ret = completed( con1->todo, con2->todo );
626 seComp = TRUE; 626 seComp = TRUE;
627 break; 627 break;
628 } 628 }
629 /* priority */ 629 /* priority */
630 case 1: { 630 case 1: {
631 ret = priority( con1->todo, con2->todo ); 631 ret = priority( con1->todo, con2->todo );
632 sePrio = TRUE; 632 sePrio = TRUE;
633 break; 633 break;
634 } 634 }
635 /* description */ 635 /* description */
636 case 2: { 636 case 2: {
637 ret = description( con1->todo, con2->todo ); 637 ret = description( con1->todo, con2->todo );
638 seDesc = TRUE; 638 seDesc = TRUE;
639 break; 639 break;
640 } 640 }
641 /* deadline */ 641 /* deadline */
642 case 3: { 642 case 3: {
643 ret = deadline( con1->todo, con2->todo ); 643 ret = deadline( con1->todo, con2->todo );
644 seDeadline = TRUE; 644 seDeadline = TRUE;
645 break; 645 break;
646 } 646 }
647 default: 647 default:
648 ret = 0; 648 ret = 0;
649 break; 649 break;
650 }; 650 };
651 /* 651 /*
652 * FIXME do better sorting if the first sort criteria 652 * FIXME do better sorting if the first sort criteria
653 * ret equals 0 start with complete and so on... 653 * ret equals 0 start with complete and so on...
654 */ 654 */
655 655
656 /* twist it we're not ascending*/ 656 /* twist it we're not ascending*/
657 if (!m_asc) 657 if (!m_asc)
658 ret = ret * -1; 658 ret = ret * -1;
659 659
660 if ( ret ) 660 if ( ret )
661 return ret; 661 return ret;
662 662
663 // default did not gave difference let's try it other way around 663 // default did not gave difference let's try it other way around
664 /* 664 /*
665 * General try if already checked if not test 665 * General try if already checked if not test
666 * and return 666 * and return
667 * 1.Completed 667 * 1.Completed
668 * 2.Priority 668 * 2.Priority
669 * 3.Description 669 * 3.Description
670 * 4.DueDate 670 * 4.DueDate
671 */ 671 */
672 if (!seComp ) { 672 if (!seComp ) {
673 if ( (ret = completed( con1->todo, con2->todo ) ) ) { 673 if ( (ret = completed( con1->todo, con2->todo ) ) ) {
674 if (!m_asc ) ret *= -1; 674 if (!m_asc ) ret *= -1;
675 return ret; 675 return ret;
676 } 676 }
677 } 677 }
678 if (!sePrio ) { 678 if (!sePrio ) {
679 if ( (ret = priority( con1->todo, con2->todo ) ) ) { 679 if ( (ret = priority( con1->todo, con2->todo ) ) ) {
680 if (!m_asc ) ret *= -1; 680 if (!m_asc ) ret *= -1;
681 return ret; 681 return ret;
682 } 682 }
683 } 683 }
684 if (!seDesc ) { 684 if (!seDesc ) {
685 if ( (ret = description(con1->todo, con2->todo ) ) ) { 685 if ( (ret = description(con1->todo, con2->todo ) ) ) {
686 if (!m_asc) ret *= -1; 686 if (!m_asc) ret *= -1;
687 return ret; 687 return ret;
688 } 688 }
689 } 689 }
690 if (!seDeadline) { 690 if (!seDeadline) {
691 if ( (ret = deadline( con1->todo, con2->todo ) ) ) { 691 if ( (ret = deadline( con1->todo, con2->todo ) ) ) {
692 if (!m_asc) ret *= -1; 692 if (!m_asc) ret *= -1;
693 return ret; 693 return ret;
694 } 694 }
695 } 695 }
696 696
697 return 0; 697 return 0;
698 } 698 }
699 private: 699 private:
700 bool m_asc; 700 bool m_asc;
701 int m_sort; 701 int m_sort;
702 702
703}; 703};
704 704
705QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, 705QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
706 int sortFilter, int cat ) { 706 int sortFilter, int cat ) {
707 qWarning("sorted! %d cat", cat); 707 qWarning("sorted! %d cat", cat);
708 OTodoXMLVector vector(m_events.count(), asc,sortOrder ); 708 OTodoXMLVector vector(m_events.count(), asc,sortOrder );
709 QMap<int, OTodo>::Iterator it; 709 QMap<int, OTodo>::Iterator it;
710 int item = 0; 710 int item = 0;
711 711
712 bool bCat = sortFilter & 1 ? true : false; 712 bool bCat = sortFilter & 1 ? true : false;
713 bool bOnly = sortFilter & 2 ? true : false; 713 bool bOnly = sortFilter & 2 ? true : false;
714 bool comp = sortFilter & 4 ? true : false; 714 bool comp = sortFilter & 4 ? true : false;
715 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 715 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
716 716
717 /* show category */ 717 /* show category */
718 if ( bCat && cat != 0) 718 if ( bCat && cat != 0)
719 if (!(*it).categories().contains( cat ) ) { 719 if (!(*it).categories().contains( cat ) ) {
720 qWarning("category mis match"); 720 qWarning("category mis match");
721 continue; 721 continue;
722 } 722 }
723 /* isOverdue but we should not show overdue - why?*/ 723 /* isOverdue but we should not show overdue - why?*/
724/* if ( (*it).isOverdue() && !bOnly ) { 724/* if ( (*it).isOverdue() && !bOnly ) {
725 qWarning("item is overdue but !bOnly"); 725 qWarning("item is overdue but !bOnly");
726 continue; 726 continue;
727 } 727 }
728*/ 728*/
729 if ( !(*it).isOverdue() && bOnly ) { 729 if ( !(*it).isOverdue() && bOnly ) {
730 qWarning("item is not overdue but bOnly checked"); 730 qWarning("item is not overdue but bOnly checked");
731 continue; 731 continue;
732 } 732 }
733 733
734 if ((*it).isCompleted() && comp ) { 734 if ((*it).isCompleted() && comp ) {
735 qWarning("completed continue!"); 735 qWarning("completed continue!");
736 continue; 736 continue;
737 } 737 }
738 738
739 739
740 OTodoXMLContainer* con = new OTodoXMLContainer(); 740 OTodoXMLContainer* con = new OTodoXMLContainer();
741 con->todo = (*it); 741 con->todo = (*it);
742 vector.insert(item, con ); 742 vector.insert(item, con );
743 item++; 743 item++;
744 } 744 }
745 qWarning("XXX %d Items added", item); 745 qWarning("XXX %d Items added", item);
746 vector.resize( item ); 746 vector.resize( item );
747 /* sort it now */ 747 /* sort it now */
748 vector.sort(); 748 vector.sort();
749 /* now get the uids */ 749 /* now get the uids */
750 QArray<int> array( vector.count() ); 750 QArray<int> array( vector.count() );
751 for (uint i= 0; i < vector.count(); i++ ) { 751 for (uint i= 0; i < vector.count(); i++ ) {
752 array[i] = ( vector.at(i) )->todo.uid(); 752 array[i] = ( vector.at(i) )->todo.uid();
753 } 753 }
754 return array; 754 return array;
755}; 755};
756void OTodoAccessXML::removeAllCompleted() { 756void OTodoAccessXML::removeAllCompleted() {
757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
758 if ( (*it).isCompleted() ) 758 if ( (*it).isCompleted() )
759 m_events.remove( it ); 759 m_events.remove( it );
760 } 760 }
761} 761}
762QBitArray OTodoAccessXML::supports()const { 762QBitArray OTodoAccessXML::supports()const {
763 static QBitArray ar = sup(); 763 static QBitArray ar = sup();
764 return ar; 764 return ar;
765} 765}
766QBitArray OTodoAccessXML::sup() { 766QBitArray OTodoAccessXML::sup() {
767 QBitArray ar( OTodo::CompletedDate +1 ); 767 QBitArray ar( OTodo::CompletedDate +1 );
768 ar.fill( true ); 768 ar.fill( true );
769 ar[OTodo::CrossReference] = false; 769 ar[OTodo::CrossReference] = false;
770 ar[OTodo::State ] = false; 770 ar[OTodo::State ] = false;
771 ar[OTodo::Reminders] = false; 771 ar[OTodo::Reminders] = false;
772 ar[OTodo::Notifiers] = false; 772 ar[OTodo::Notifiers] = false;
773 ar[OTodo::Maintainer] = false; 773 ar[OTodo::Maintainer] = false;
774 774
775 return ar; 775 return ar;
776} 776}
777QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
778{
779 QArray<int> m_currentQuery( m_events.count() );
780 uint arraycounter = 0;
781
782 QMap<int, OTodo>::ConstIterator it;
783 for (it = m_events.begin(); it != m_events.end(); ++it ) {
784 if ( it.data().match( r ) )
785 m_currentQuery[arraycounter++] = it.data().uid();
786
787 }
788 // Shrink to fit..
789 m_currentQuery.resize(arraycounter);
790
791 return m_currentQuery;
792}
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h
index cc4a16f..e4850a1 100644
--- a/libopie/pim/otodoaccessxml.h
+++ b/libopie/pim/otodoaccessxml.h
@@ -1,59 +1,60 @@
1#ifndef OPIE_TODO_ACCESS_XML_H 1#ifndef OPIE_TODO_ACCESS_XML_H
2#define OPIE_TODO_ACCESS_XML_H 2#define OPIE_TODO_ACCESS_XML_H
3 3
4#include <qasciidict.h> 4#include <qasciidict.h>
5#include <qmap.h> 5#include <qmap.h>
6 6
7#include "otodoaccessbackend.h" 7#include "otodoaccessbackend.h"
8 8
9namespace Opie { 9namespace Opie {
10 class XMLElement; 10 class XMLElement;
11}; 11};
12 12
13class OTodoAccessXML : public OTodoAccessBackend { 13class OTodoAccessXML : public OTodoAccessBackend {
14public: 14public:
15 /** 15 /**
16 * fileName if Empty we will use the default path 16 * fileName if Empty we will use the default path
17 */ 17 */
18 OTodoAccessXML( const QString& appName, 18 OTodoAccessXML( const QString& appName,
19 const QString& fileName = QString::null ); 19 const QString& fileName = QString::null );
20 ~OTodoAccessXML(); 20 ~OTodoAccessXML();
21 21
22 bool load(); 22 bool load();
23 bool reload(); 23 bool reload();
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> matchRegexp(const QRegExp &r) const;
27 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); 28 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
28 OTodo find( int uid )const; 29 OTodo find( int uid )const;
29 void clear(); 30 void clear();
30 bool add( const OTodo& ); 31 bool add( const OTodo& );
31 bool remove( int uid ); 32 bool remove( int uid );
32 void removeAllCompleted(); 33 void removeAllCompleted();
33 bool replace( const OTodo& ); 34 bool replace( const OTodo& );
34 35
35 /* our functions */ 36 /* our functions */
36 QArray<int> effectiveToDos( const QDate& start, 37 QArray<int> effectiveToDos( const QDate& start,
37 const QDate& end, 38 const QDate& end,
38 bool includeNoDates ); 39 bool includeNoDates );
39 QArray<int> overDue(); 40 QArray<int> overDue();
40 QArray<int> sorted( bool asc, int sortOrder, 41 QArray<int> sorted( bool asc, int sortOrder,
41 int sortFilter, int cat ); 42 int sortFilter, int cat );
42 QBitArray supports()const; 43 QBitArray supports()const;
43private: 44private:
44 static QBitArray sup(); 45 static QBitArray sup();
45 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); 46 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& );
46 QString toString( const OTodo& )const; 47 QString toString( const OTodo& )const;
47 QString toString( const QArray<int>& ints ) const; 48 QString toString( const QArray<int>& ints ) const;
48 QMap<int, OTodo> m_events; 49 QMap<int, OTodo> m_events;
49 QString m_file; 50 QString m_file;
50 QString m_app; 51 QString m_app;
51 bool m_opened : 1; 52 bool m_opened : 1;
52 bool m_changed : 1; 53 bool m_changed : 1;
53 class OTodoAccessXMLPrivate; 54 class OTodoAccessXMLPrivate;
54 OTodoAccessXMLPrivate* d; 55 OTodoAccessXMLPrivate* d;
55 int m_year, m_month, m_day; 56 int m_year, m_month, m_day;
56 57
57}; 58};
58 59
59#endif 60#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index a0ae7b7..ab2eea4 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -397,192 +397,210 @@ bool ODateBookAccessBackend_XML::loadFile() {
397 397
398 i = ++j; // skip = 398 i = ++j; // skip =
399 399
400 // find the start of quotes 400 // find the start of quotes
401 while ( i < len && dt[i] != '"' ) 401 while ( i < len && dt[i] != '"' )
402 ++i; 402 ++i;
403 j = ++i; 403 j = ++i;
404 404
405 bool haveUtf = FALSE; 405 bool haveUtf = FALSE;
406 bool haveEnt = FALSE; 406 bool haveEnt = FALSE;
407 while ( j < len && dt[j] != '"' ) { 407 while ( j < len && dt[j] != '"' ) {
408 if ( ((unsigned char)dt[j]) > 0x7f ) 408 if ( ((unsigned char)dt[j]) > 0x7f )
409 haveUtf = TRUE; 409 haveUtf = TRUE;
410 if ( dt[j] == '&' ) 410 if ( dt[j] == '&' )
411 haveEnt = TRUE; 411 haveEnt = TRUE;
412 ++j; 412 ++j;
413 } 413 }
414 if ( i == j ) { 414 if ( i == j ) {
415 // empty value 415 // empty value
416 i = j + 1; 416 i = j + 1;
417 continue; 417 continue;
418 } 418 }
419 419
420 QCString value( dt+i, j-i+1 ); 420 QCString value( dt+i, j-i+1 );
421 i = j + 1; 421 i = j + 1;
422 422
423 QString str = (haveUtf ? QString::fromUtf8( value ) 423 QString str = (haveUtf ? QString::fromUtf8( value )
424 : QString::fromLatin1( value ) ); 424 : QString::fromLatin1( value ) );
425 if ( haveEnt ) 425 if ( haveEnt )
426 str = Qtopia::plainString( str ); 426 str = Qtopia::plainString( str );
427 427
428 /* 428 /*
429 * add key + value 429 * add key + value
430 */ 430 */
431 find = dict[attr.data()]; 431 find = dict[attr.data()];
432 if (!find) 432 if (!find)
433 ev.setCustomField( attr, value ); 433 ev.setCustomField( attr, value );
434 else { 434 else {
435 setField( ev, *find, value ); 435 setField( ev, *find, value );
436 } 436 }
437 } 437 }
438 /* time to finalize */ 438 /* time to finalize */
439 finalizeRecord( ev ); 439 finalizeRecord( ev );
440 delete rec; 440 delete rec;
441 } 441 }
442 ::munmap(map_addr, attribute.st_size ); 442 ::munmap(map_addr, attribute.st_size );
443 m_changed = false; // changed during add 443 m_changed = false; // changed during add
444 444
445 return true; 445 return true;
446} 446}
447void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { 447void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) {
448 /* AllDay is alway in UTC */ 448 /* AllDay is alway in UTC */
449 if ( ev.isAllDay() ) { 449 if ( ev.isAllDay() ) {
450 OTimeZone utc = OTimeZone::utc(); 450 OTimeZone utc = OTimeZone::utc();
451 ev.setStartDateTime( utc.fromUTCDateTime( start ) ); 451 ev.setStartDateTime( utc.fromUTCDateTime( start ) );
452 ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); 452 ev.setEndDateTime ( utc.fromUTCDateTime( end ) );
453 ev.setTimeZone( "UTC"); // make sure it is really utc 453 ev.setTimeZone( "UTC"); // make sure it is really utc
454 }else { 454 }else {
455 /* to current date time */ 455 /* to current date time */
456 qWarning(" Start is %d", start ); 456 qWarning(" Start is %d", start );
457 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); 457 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() );
458 QDateTime date = zone.toDateTime( start ); 458 QDateTime date = zone.toDateTime( start );
459 qWarning(" Start is %s", date.toString().latin1() ); 459 qWarning(" Start is %s", date.toString().latin1() );
460 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); 460 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) );
461 461
462 date = zone.toDateTime( end ); 462 date = zone.toDateTime( end );
463 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); 463 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) );
464 } 464 }
465 if ( rec && rec->doesRecur() ) { 465 if ( rec && rec->doesRecur() ) {
466 OTimeZone utc = OTimeZone::utc(); 466 OTimeZone utc = OTimeZone::utc();
467 ORecur recu( *rec ); // call copy c'tor; 467 ORecur recu( *rec ); // call copy c'tor;
468 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); 468 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() );
469 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); 469 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) );
470 recu.setStart( ev.startDateTime().date() ); 470 recu.setStart( ev.startDateTime().date() );
471 ev.setRecurrence( recu ); 471 ev.setRecurrence( recu );
472 } 472 }
473 473
474 if (alarmTime != -1 ) { 474 if (alarmTime != -1 ) {
475 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); 475 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 );
476 OPimAlarm al( snd , dt ); 476 OPimAlarm al( snd , dt );
477 ev.notifiers().add( al ); 477 ev.notifiers().add( al );
478 } 478 }
479 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 479 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
480 qWarning("already contains assign uid"); 480 qWarning("already contains assign uid");
481 ev.setUid( 1 ); 481 ev.setUid( 1 );
482 } 482 }
483 qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); 483 qWarning("addind %d %s", ev.uid(), ev.description().latin1() );
484 if ( ev.hasRecurrence() ) 484 if ( ev.hasRecurrence() )
485 m_rep.insert( ev.uid(), ev ); 485 m_rep.insert( ev.uid(), ev );
486 else 486 else
487 m_raw.insert( ev.uid(), ev ); 487 m_raw.insert( ev.uid(), ev );
488 488
489} 489}
490void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { 490void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) {
491// qWarning(" setting %s", value.latin1() ); 491// qWarning(" setting %s", value.latin1() );
492 switch( id ) { 492 switch( id ) {
493 case FDescription: 493 case FDescription:
494 e.setDescription( value ); 494 e.setDescription( value );
495 break; 495 break;
496 case FLocation: 496 case FLocation:
497 e.setLocation( value ); 497 e.setLocation( value );
498 break; 498 break;
499 case FCategories: 499 case FCategories:
500 e.setCategories( e.idsFromString( value ) ); 500 e.setCategories( e.idsFromString( value ) );
501 break; 501 break;
502 case FUid: 502 case FUid:
503 e.setUid( value.toInt() ); 503 e.setUid( value.toInt() );
504 break; 504 break;
505 case FType: 505 case FType:
506 if ( value == "AllDay" ) { 506 if ( value == "AllDay" ) {
507 e.setAllDay( true ); 507 e.setAllDay( true );
508 e.setTimeZone( "UTC" ); 508 e.setTimeZone( "UTC" );
509 } 509 }
510 break; 510 break;
511 case FAlarm: 511 case FAlarm:
512 alarmTime = value.toInt(); 512 alarmTime = value.toInt();
513 break; 513 break;
514 case FSound: 514 case FSound:
515 snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; 515 snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent;
516 break; 516 break;
517 // recurrence stuff 517 // recurrence stuff
518 case FRType: 518 case FRType:
519 if ( value == "Daily" ) 519 if ( value == "Daily" )
520 recur()->setType( ORecur::Daily ); 520 recur()->setType( ORecur::Daily );
521 else if ( value == "Weekly" ) 521 else if ( value == "Weekly" )
522 recur()->setType( ORecur::Weekly); 522 recur()->setType( ORecur::Weekly);
523 else if ( value == "MonthlyDay" ) 523 else if ( value == "MonthlyDay" )
524 recur()->setType( ORecur::MonthlyDay ); 524 recur()->setType( ORecur::MonthlyDay );
525 else if ( value == "MonthlyDate" ) 525 else if ( value == "MonthlyDate" )
526 recur()->setType( ORecur::MonthlyDate ); 526 recur()->setType( ORecur::MonthlyDate );
527 else if ( value == "Yearly" ) 527 else if ( value == "Yearly" )
528 recur()->setType( ORecur::Yearly ); 528 recur()->setType( ORecur::Yearly );
529 else 529 else
530 recur()->setType( ORecur::NoRepeat ); 530 recur()->setType( ORecur::NoRepeat );
531 break; 531 break;
532 case FRWeekdays: 532 case FRWeekdays:
533 recur()->setDays( value.toInt() ); 533 recur()->setDays( value.toInt() );
534 break; 534 break;
535 case FRPosition: 535 case FRPosition:
536 recur()->setPosition( value.toInt() ); 536 recur()->setPosition( value.toInt() );
537 break; 537 break;
538 case FRFreq: 538 case FRFreq:
539 recur()->setFrequency( value.toInt() ); 539 recur()->setFrequency( value.toInt() );
540 break; 540 break;
541 case FRHasEndDate: 541 case FRHasEndDate:
542 recur()->setHasEndDate( value.toInt() ); 542 recur()->setHasEndDate( value.toInt() );
543 break; 543 break;
544 case FREndDate: { 544 case FREndDate: {
545 rp_end = (time_t) value.toLong(); 545 rp_end = (time_t) value.toLong();
546 break; 546 break;
547 } 547 }
548 case FRStart: { 548 case FRStart: {
549 start = (time_t) value.toLong(); 549 start = (time_t) value.toLong();
550 break; 550 break;
551 } 551 }
552 case FREnd: { 552 case FREnd: {
553 end = ( (time_t) value.toLong() ); 553 end = ( (time_t) value.toLong() );
554 break; 554 break;
555 } 555 }
556 case FNote: 556 case FNote:
557 e.setNote( value ); 557 e.setNote( value );
558 break; 558 break;
559 case FCreated: 559 case FCreated:
560 created = value.toInt(); 560 created = value.toInt();
561 break; 561 break;
562 case FRecParent: 562 case FRecParent:
563 e.setParent( value.toInt() ); 563 e.setParent( value.toInt() );
564 break; 564 break;
565 case FRecChildren:{ 565 case FRecChildren:{
566 QStringList list = QStringList::split(' ', value ); 566 QStringList list = QStringList::split(' ', value );
567 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 567 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
568 e.addChild( (*it).toInt() ); 568 e.addChild( (*it).toInt() );
569 } 569 }
570 } 570 }
571 break; 571 break;
572 case FExceptions:{ 572 case FExceptions:{
573 QStringList list = QStringList::split(' ', value ); 573 QStringList list = QStringList::split(' ', value );
574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
575 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); 575 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
576 qWarning("adding exception %s", date.toString().latin1() ); 576 qWarning("adding exception %s", date.toString().latin1() );
577 recur()->exceptions().append( date ); 577 recur()->exceptions().append( date );
578 } 578 }
579 } 579 }
580 break; 580 break;
581 case FTimeZone: 581 case FTimeZone:
582 if ( value != "None" ) 582 if ( value != "None" )
583 e.setTimeZone( value ); 583 e.setTimeZone( value );
584 break; 584 break;
585 default: 585 default:
586 break; 586 break;
587 } 587 }
588} 588}
589QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
590{
591 QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
592 uint arraycounter = 0;
593 QMap<int, OEvent>::ConstIterator it;
594
595 for ( it = m_raw.begin(); it != m_raw.end(); ++it )
596 if ( it.data().match( r ) )
597 m_currentQuery[arraycounter++] = it.data().uid();
598 for ( it = m_rep.begin(); it != m_rep.end(); ++it )
599 if ( it.data().match( r ) )
600 m_currentQuery[arraycounter++] = it.data().uid();
601
602 // Shrink to fit..
603 m_currentQuery.resize(arraycounter);
604
605 return m_currentQuery;
606}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index 7848f7c..a5cc0fc 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -1,54 +1,55 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
3 3
4#include <qmap.h> 4#include <qmap.h>
5 5
6#include "odatebookaccessbackend.h" 6#include "odatebookaccessbackend.h"
7 7
8/** 8/**
9 * This is the default XML implementation for DateBoook XML storage 9 * This is the default XML implementation for DateBoook XML storage
10 * It fully implements the interface 10 * It fully implements the interface
11 * @see ODateBookAccessBackend 11 * @see ODateBookAccessBackend
12 * @see OPimAccessBackend 12 * @see OPimAccessBackend
13 */ 13 */
14class ODateBookAccessBackend_XML : public ODateBookAccessBackend { 14class ODateBookAccessBackend_XML : public ODateBookAccessBackend {
15public: 15public:
16 ODateBookAccessBackend_XML( const QString& appName, 16 ODateBookAccessBackend_XML( const QString& appName,
17 const QString& fileName = QString::null); 17 const QString& fileName = QString::null);
18 ~ODateBookAccessBackend_XML(); 18 ~ODateBookAccessBackend_XML();
19 19
20 bool load(); 20 bool load();
21 bool reload(); 21 bool reload();
22 bool save(); 22 bool save();
23 23
24 QArray<int> allRecords()const; 24 QArray<int> allRecords()const;
25 QArray<int> matchRegexp(const QRegExp &r) const;
25 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); 26 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
26 OEvent find( int uid )const; 27 OEvent find( int uid )const;
27 void clear(); 28 void clear();
28 bool add( const OEvent& ev ); 29 bool add( const OEvent& ev );
29 bool remove( int uid ); 30 bool remove( int uid );
30 bool replace( const OEvent& ev ); 31 bool replace( const OEvent& ev );
31 32
32 QArray<UID> rawEvents()const; 33 QArray<UID> rawEvents()const;
33 QArray<UID> rawRepeats()const; 34 QArray<UID> rawRepeats()const;
34 QArray<UID> nonRepeats()const; 35 QArray<UID> nonRepeats()const;
35 36
36 OEvent::ValueList directNonRepeats(); 37 OEvent::ValueList directNonRepeats();
37 OEvent::ValueList directRawRepeats(); 38 OEvent::ValueList directRawRepeats();
38 39
39private: 40private:
40 bool m_changed :1 ; 41 bool m_changed :1 ;
41 bool loadFile(); 42 bool loadFile();
42 inline void finalizeRecord( OEvent& ev ); 43 inline void finalizeRecord( OEvent& ev );
43 inline void setField( OEvent&, int field, const QString& val ); 44 inline void setField( OEvent&, int field, const QString& val );
44 QString m_name; 45 QString m_name;
45 QMap<int, OEvent> m_raw; 46 QMap<int, OEvent> m_raw;
46 QMap<int, OEvent> m_rep; 47 QMap<int, OEvent> m_rep;
47 48
48 struct Data; 49 struct Data;
49 Data* data; 50 Data* data;
50 class Private; 51 class Private;
51 Private *d; 52 Private *d;
52}; 53};
53 54
54#endif 55#endif
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 01a0c86..f4bbe35 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,153 +1,159 @@
1#ifndef OPIE_PIM_ACCESS_BACKEND 1#ifndef OPIE_PIM_ACCESS_BACKEND
2#define OPIE_PIM_ACCESS_BACKEND 2#define OPIE_PIM_ACCESS_BACKEND
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/otemplatebase.h> 6#include <opie/otemplatebase.h>
7#include <opie/opimrecord.h> 7#include <opie/opimrecord.h>
8 8
9 9
10/** 10/**
11 * OPimAccessBackend is the base class 11 * OPimAccessBackend is the base class
12 * for all private backends 12 * for all private backends
13 * it operates on OPimRecord as the base class 13 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 14 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 15 * the resource the implementation takes care
16 * of 16 * of
17 */ 17 */
18template <class T = OPimRecord> 18template <class T = OPimRecord>
19class OPimAccessBackend { 19class OPimAccessBackend {
20public: 20public:
21 typedef OTemplateBase<T> Frontend; 21 typedef OTemplateBase<T> Frontend;
22 22
23 /** The access hint from the frontend */ 23 /** The access hint from the frontend */
24 OPimAccessBackend(int access = 0); 24 OPimAccessBackend(int access = 0);
25 virtual ~OPimAccessBackend(); 25 virtual ~OPimAccessBackend();
26 26
27 /** 27 /**
28 * load the resource 28 * load the resource
29 */ 29 */
30 virtual bool load() = 0; 30 virtual bool load() = 0;
31 31
32 /** 32 /**
33 * reload the resource 33 * reload the resource
34 */ 34 */
35 virtual bool reload() = 0; 35 virtual bool reload() = 0;
36 36
37 /** 37 /**
38 * save the resource and 38 * save the resource and
39 * all it's changes 39 * all it's changes
40 */ 40 */
41 virtual bool save() = 0; 41 virtual bool save() = 0;
42 42
43 /** 43 /**
44 * return an array of 44 * return an array of
45 * all available uids 45 * all available uids
46 */ 46 */
47 virtual QArray<int> allRecords()const = 0; 47 virtual QArray<int> allRecords()const = 0;
48 48
49 /**
50 * return a List of records
51 * that match the regex
52 */
53 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
54
49 /** 55 /**
50 * queryByExample for T with the given Settings 56 * queryByExample for T with the given Settings
51 * 57 *
52 */ 58 */
53 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; 59 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0;
54 60
55 /** 61 /**
56 * find the OPimRecord with uid @param uid 62 * find the OPimRecord with uid @param uid
57 * returns T and T.isEmpty() if nothing was found 63 * returns T and T.isEmpty() if nothing was found
58 */ 64 */
59 virtual T find(int uid )const = 0; 65 virtual T find(int uid )const = 0;
60 66
61 virtual T find(int uid, const QArray<int>& items, 67 virtual T find(int uid, const QArray<int>& items,
62 uint current, typename Frontend::CacheDirection )const ; 68 uint current, typename Frontend::CacheDirection )const ;
63 /** 69 /**
64 * clear the back end 70 * clear the back end
65 */ 71 */
66 virtual void clear() = 0; 72 virtual void clear() = 0;
67 73
68 /** 74 /**
69 * add T 75 * add T
70 */ 76 */
71 virtual bool add( const T& t ) = 0; 77 virtual bool add( const T& t ) = 0;
72 78
73 /** 79 /**
74 * remove 80 * remove
75 */ 81 */
76 virtual bool remove( int uid ) = 0; 82 virtual bool remove( int uid ) = 0;
77 83
78 /** 84 /**
79 * replace a record with T.uid() 85 * replace a record with T.uid()
80 */ 86 */
81 virtual bool replace( const T& t ) = 0; 87 virtual bool replace( const T& t ) = 0;
82 88
83 /* 89 /*
84 * setTheFrontEnd!!! 90 * setTheFrontEnd!!!
85 */ 91 */
86 void setFrontend( Frontend* front ); 92 void setFrontend( Frontend* front );
87 93
88 /** 94 /**
89 * set the read ahead count 95 * set the read ahead count
90 */ 96 */
91 void setReadAhead( uint count ); 97 void setReadAhead( uint count );
92protected: 98protected:
93 int access()const; 99 int access()const;
94 void cache( const T& t )const; 100 void cache( const T& t )const;
95 101
96 /** 102 /**
97 * use a prime number here! 103 * use a prime number here!
98 */ 104 */
99 void setSaneCacheSize( int ); 105 void setSaneCacheSize( int );
100 106
101 uint readAhead()const; 107 uint readAhead()const;
102 108
103private: 109private:
104 class Private; 110 class Private;
105 Private* d; 111 Private* d;
106 Frontend* m_front; 112 Frontend* m_front;
107 uint m_read; 113 uint m_read;
108 int m_acc; 114 int m_acc;
109 115
110}; 116};
111 117
112template <class T> 118template <class T>
113OPimAccessBackend<T>::OPimAccessBackend(int acc) 119OPimAccessBackend<T>::OPimAccessBackend(int acc)
114 : m_acc( acc ) 120 : m_acc( acc )
115{ 121{
116 m_front = 0l; 122 m_front = 0l;
117} 123}
118template <class T> 124template <class T>
119OPimAccessBackend<T>::~OPimAccessBackend() { 125OPimAccessBackend<T>::~OPimAccessBackend() {
120 126
121} 127}
122template <class T> 128template <class T>
123void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 129void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
124 m_front = fr; 130 m_front = fr;
125} 131}
126template <class T> 132template <class T>
127void OPimAccessBackend<T>::cache( const T& t )const { 133void OPimAccessBackend<T>::cache( const T& t )const {
128 if (m_front ) 134 if (m_front )
129 m_front->cache( t ); 135 m_front->cache( t );
130} 136}
131template <class T> 137template <class T>
132void OPimAccessBackend<T>::setSaneCacheSize( int size) { 138void OPimAccessBackend<T>::setSaneCacheSize( int size) {
133 if (m_front ) 139 if (m_front )
134 m_front->setSaneCacheSize( size ); 140 m_front->setSaneCacheSize( size );
135} 141}
136template <class T> 142template <class T>
137T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 143T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
138 uint, typename Frontend::CacheDirection )const { 144 uint, typename Frontend::CacheDirection )const {
139 return find( uid ); 145 return find( uid );
140} 146}
141template <class T> 147template <class T>
142void OPimAccessBackend<T>::setReadAhead( uint count ) { 148void OPimAccessBackend<T>::setReadAhead( uint count ) {
143 m_read = count; 149 m_read = count;
144} 150}
145template <class T> 151template <class T>
146uint OPimAccessBackend<T>::readAhead()const { 152uint OPimAccessBackend<T>::readAhead()const {
147 return m_read; 153 return m_read;
148} 154}
149template <class T> 155template <class T>
150int OPimAccessBackend<T>::access()const { 156int OPimAccessBackend<T>::access()const {
151 return m_acc; 157 return m_acc;
152} 158}
153#endif 159#endif
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 9bc16c6..3577e14 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -1,221 +1,225 @@
1#include <qfile.h> 1#include <qfile.h>
2 2
3#include <qtopia/private/vobject_p.h> 3#include <qtopia/private/vobject_p.h>
4#include <qtopia/timeconversion.h> 4#include <qtopia/timeconversion.h>
5#include <qtopia/private/qfiledirect_p.h> 5#include <qtopia/private/qfiledirect_p.h>
6 6
7#include "otodoaccessvcal.h" 7#include "otodoaccessvcal.h"
8 8
9namespace { 9namespace {
10 static OTodo eventByVObj( VObject *obj ){ 10 static OTodo eventByVObj( VObject *obj ){
11 OTodo event; 11 OTodo event;
12 VObject *ob; 12 VObject *ob;
13 QCString name; 13 QCString name;
14 // no uid, attendees, ... and no fun 14 // no uid, attendees, ... and no fun
15 // description 15 // description
16 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ 16 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
17 name = vObjectStringZValue( ob ); 17 name = vObjectStringZValue( ob );
18 event.setDescription( name ); 18 event.setDescription( name );
19 } 19 }
20 // summary 20 // summary
21 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { 21 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
22 name = vObjectStringZValue( ob ); 22 name = vObjectStringZValue( ob );
23 event.setSummary( name ); 23 event.setSummary( name );
24 } 24 }
25 // completed 25 // completed
26 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 26 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
27 name = vObjectStringZValue( ob ); 27 name = vObjectStringZValue( ob );
28 if( name == "COMPLETED" ){ 28 if( name == "COMPLETED" ){
29 event.setCompleted( true ); 29 event.setCompleted( true );
30 }else{ 30 }else{
31 event.setCompleted( false ); 31 event.setCompleted( false );
32 } 32 }
33 }else 33 }else
34 event.setCompleted( false ); 34 event.setCompleted( false );
35 // priority 35 // priority
36 if ((ob = isAPropertyOf(obj, VCPriorityProp))) { 36 if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
37 name = vObjectStringZValue( ob ); 37 name = vObjectStringZValue( ob );
38 bool ok; 38 bool ok;
39 event.setPriority(name.toInt(&ok) ); 39 event.setPriority(name.toInt(&ok) );
40 } 40 }
41 //due date 41 //due date
42 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 42 if((ob = isAPropertyOf(obj, VCDueProp)) ){
43 event.setHasDueDate( true ); 43 event.setHasDueDate( true );
44 name = vObjectStringZValue( ob ); 44 name = vObjectStringZValue( ob );
45 event.setDueDate( TimeConversion::fromISO8601( name).date() ); 45 event.setDueDate( TimeConversion::fromISO8601( name).date() );
46 } 46 }
47 // categories 47 // categories
48 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 48 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
49 name = vObjectStringZValue( ob ); 49 name = vObjectStringZValue( ob );
50 qWarning("Categories:%s", name.data() ); 50 qWarning("Categories:%s", name.data() );
51 } 51 }
52 52
53 event.setUid( 1 ); 53 event.setUid( 1 );
54 return event; 54 return event;
55 }; 55 };
56 static VObject *vobjByEvent( const OTodo &event ) { 56 static VObject *vobjByEvent( const OTodo &event ) {
57 VObject *task = newVObject( VCTodoProp ); 57 VObject *task = newVObject( VCTodoProp );
58 if( task == 0 ) 58 if( task == 0 )
59 return 0l; 59 return 0l;
60 60
61 if( event.hasDueDate() ) { 61 if( event.hasDueDate() ) {
62 QTime time(0, 0, 0); 62 QTime time(0, 0, 0);
63 QDateTime date(event.dueDate(), time ); 63 QDateTime date(event.dueDate(), time );
64 addPropValue( task, VCDueProp, 64 addPropValue( task, VCDueProp,
65 TimeConversion::toISO8601( date ) ); 65 TimeConversion::toISO8601( date ) );
66 } 66 }
67 67
68 if( event.isCompleted() ) 68 if( event.isCompleted() )
69 addPropValue( task, VCStatusProp, "COMPLETED"); 69 addPropValue( task, VCStatusProp, "COMPLETED");
70 70
71 QString string = QString::number(event.priority() ); 71 QString string = QString::number(event.priority() );
72 addPropValue( task, VCPriorityProp, string.local8Bit() ); 72 addPropValue( task, VCPriorityProp, string.local8Bit() );
73 73
74 addPropValue( task, VCCategoriesProp, 74 addPropValue( task, VCCategoriesProp,
75 event.idsToString( event.categories() ).local8Bit() ); 75 event.idsToString( event.categories() ).local8Bit() );
76 76
77 addPropValue( task, VCDescriptionProp, 77 addPropValue( task, VCDescriptionProp,
78 event.description().local8Bit() ); 78 event.description().local8Bit() );
79 79
80 addPropValue( task, VCSummaryProp, 80 addPropValue( task, VCSummaryProp,
81 event.summary().local8Bit() ); 81 event.summary().local8Bit() );
82 return task; 82 return task;
83}; 83};
84} 84}
85 85
86OTodoAccessVCal::OTodoAccessVCal( const QString& path ) 86OTodoAccessVCal::OTodoAccessVCal( const QString& path )
87 : m_dirty(false), m_file( path ) 87 : m_dirty(false), m_file( path )
88{ 88{
89} 89}
90OTodoAccessVCal::~OTodoAccessVCal() { 90OTodoAccessVCal::~OTodoAccessVCal() {
91} 91}
92bool OTodoAccessVCal::load() { 92bool OTodoAccessVCal::load() {
93 m_map.clear(); 93 m_map.clear();
94 m_dirty = false; 94 m_dirty = false;
95 95
96 VObject* vcal = 0l; 96 VObject* vcal = 0l;
97 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 97 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
98 if (!vcal ) 98 if (!vcal )
99 return false; 99 return false;
100 100
101 // Iterate over the list 101 // Iterate over the list
102 VObjectIterator it; 102 VObjectIterator it;
103 VObject* vobj; 103 VObject* vobj;
104 104
105 initPropIterator(&it, vcal); 105 initPropIterator(&it, vcal);
106 106
107 while( moreIteration( &it ) ) { 107 while( moreIteration( &it ) ) {
108 vobj = ::nextVObject( &it ); 108 vobj = ::nextVObject( &it );
109 QCString name = ::vObjectName( vobj ); 109 QCString name = ::vObjectName( vobj );
110 if( name == VCTodoProp ){ 110 if( name == VCTodoProp ){
111 OTodo to = eventByVObj( vobj ); 111 OTodo to = eventByVObj( vobj );
112 m_map.insert( to.uid(), to ); 112 m_map.insert( to.uid(), to );
113 } 113 }
114 } 114 }
115 115
116 // Should I do a delete vcal? 116 // Should I do a delete vcal?
117 117
118 return true; 118 return true;
119} 119}
120bool OTodoAccessVCal::reload() { 120bool OTodoAccessVCal::reload() {
121 return load(); 121 return load();
122} 122}
123bool OTodoAccessVCal::save() { 123bool OTodoAccessVCal::save() {
124 if (!m_dirty ) 124 if (!m_dirty )
125 return true; 125 return true;
126 126
127 QFileDirect file( m_file ); 127 QFileDirect file( m_file );
128 if (!file.open(IO_WriteOnly ) ) 128 if (!file.open(IO_WriteOnly ) )
129 return false; 129 return false;
130 130
131 VObject *obj; 131 VObject *obj;
132 obj = newVObject( VCCalProp ); 132 obj = newVObject( VCCalProp );
133 addPropValue( obj, VCVersionProp, "1.0" ); 133 addPropValue( obj, VCVersionProp, "1.0" );
134 VObject *vo; 134 VObject *vo;
135 for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 135 for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
136 vo = vobjByEvent( it.data() ); 136 vo = vobjByEvent( it.data() );
137 addVObjectProp(obj, vo ); 137 addVObjectProp(obj, vo );
138 } 138 }
139 writeVObject( file.directHandle(), obj ); 139 writeVObject( file.directHandle(), obj );
140 cleanVObject( obj ); 140 cleanVObject( obj );
141 cleanStrTbl(); 141 cleanStrTbl();
142 142
143 m_dirty = false; 143 m_dirty = false;
144 return true; 144 return true;
145} 145}
146void OTodoAccessVCal::clear() { 146void OTodoAccessVCal::clear() {
147 m_map.clear(); 147 m_map.clear();
148 m_dirty = true; 148 m_dirty = true;
149} 149}
150bool OTodoAccessVCal::add( const OTodo& to ) { 150bool OTodoAccessVCal::add( const OTodo& to ) {
151 m_map.insert( to.uid(), to ); 151 m_map.insert( to.uid(), to );
152 m_dirty = true; 152 m_dirty = true;
153 return true; 153 return true;
154} 154}
155bool OTodoAccessVCal::remove( int uid ) { 155bool OTodoAccessVCal::remove( int uid ) {
156 m_map.remove( uid ); 156 m_map.remove( uid );
157 m_dirty = true; 157 m_dirty = true;
158 return true; 158 return true;
159} 159}
160void OTodoAccessVCal::removeAllCompleted() { 160void OTodoAccessVCal::removeAllCompleted() {
161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { 161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
162 if ( (*it).isCompleted() ) 162 if ( (*it).isCompleted() )
163 m_map.remove( it ); 163 m_map.remove( it );
164 } 164 }
165} 165}
166bool OTodoAccessVCal::replace( const OTodo& to ) { 166bool OTodoAccessVCal::replace( const OTodo& to ) {
167 m_map.replace( to.uid(), to ); 167 m_map.replace( to.uid(), to );
168 m_dirty = true; 168 m_dirty = true;
169 return true; 169 return true;
170} 170}
171OTodo OTodoAccessVCal::find(int uid )const { 171OTodo OTodoAccessVCal::find(int uid )const {
172 return m_map[uid]; 172 return m_map[uid];
173} 173}
174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { 174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
175 QArray<int> ar(0); 175 QArray<int> ar(0);
176 return ar; 176 return ar;
177} 177}
178QArray<int> OTodoAccessVCal::allRecords()const { 178QArray<int> OTodoAccessVCal::allRecords()const {
179 QArray<int> ar( m_map.count() ); 179 QArray<int> ar( m_map.count() );
180 QMap<int, OTodo>::ConstIterator it; 180 QMap<int, OTodo>::ConstIterator it;
181 int i = 0; 181 int i = 0;
182 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 182 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
183 ar[i] = it.key(); 183 ar[i] = it.key();
184 i++; 184 i++;
185 } 185 }
186 return ar; 186 return ar;
187} 187}
188QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const {
189 QArray<int> ar(0);
190 return ar;
191}
188QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { 192QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
189 QArray<int> ar(0); 193 QArray<int> ar(0);
190 return ar; 194 return ar;
191} 195}
192QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , 196QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& ,
193 const QDate& , 197 const QDate& ,
194 bool ) { 198 bool ) {
195 QArray<int> ar(0); 199 QArray<int> ar(0);
196 return ar; 200 return ar;
197} 201}
198QArray<int> OTodoAccessVCal::overDue() { 202QArray<int> OTodoAccessVCal::overDue() {
199 QArray<int> ar(0); 203 QArray<int> ar(0);
200 return ar; 204 return ar;
201} 205}
202QBitArray OTodoAccessVCal::supports()const { 206QBitArray OTodoAccessVCal::supports()const {
203 static QBitArray ar = sup(); 207 static QBitArray ar = sup();
204 208
205 return ar; 209 return ar;
206} 210}
207QBitArray OTodoAccessVCal::sup() { 211QBitArray OTodoAccessVCal::sup() {
208 QBitArray ar ( OTodo::CompletedDate +1 ); 212 QBitArray ar ( OTodo::CompletedDate +1 );
209 ar.fill( true ); 213 ar.fill( true );
210 214
211 ar[OTodo::CrossReference] = false; 215 ar[OTodo::CrossReference] = false;
212 ar[OTodo::State ] = false; 216 ar[OTodo::State ] = false;
213 ar[OTodo::Reminders] = false; 217 ar[OTodo::Reminders] = false;
214 ar[OTodo::Notifiers] = false; 218 ar[OTodo::Notifiers] = false;
215 ar[OTodo::Maintainer] = false; 219 ar[OTodo::Maintainer] = false;
216 ar[OTodo::Progress] = false; 220 ar[OTodo::Progress] = false;
217 ar[OTodo::Alarms ] = false; 221 ar[OTodo::Alarms ] = false;
218 ar[OTodo::Recurrence] = false; 222 ar[OTodo::Recurrence] = false;
219 223
220 return ar; 224 return ar;
221} 225}
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h
index 489416b..2b17147 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.h
+++ b/libopie2/opiepim/backend/otodoaccessvcal.h
@@ -1,39 +1,40 @@
1#ifndef OPIE_OTODO_ACCESS_VCAL_H 1#ifndef OPIE_OTODO_ACCESS_VCAL_H
2#define OPIE_OTODO_ACCESS_VCAL_H 2#define OPIE_OTODO_ACCESS_VCAL_H
3 3
4#include "otodoaccessbackend.h" 4#include "otodoaccessbackend.h"
5 5
6class OTodoAccessVCal : public OTodoAccessBackend { 6class OTodoAccessVCal : public OTodoAccessBackend {
7public: 7public:
8 OTodoAccessVCal(const QString& ); 8 OTodoAccessVCal(const QString& );
9 ~OTodoAccessVCal(); 9 ~OTodoAccessVCal();
10 10
11 bool load(); 11 bool load();
12 bool reload(); 12 bool reload();
13 bool save(); 13 bool save();
14 14
15 QArray<int> allRecords()const; 15 QArray<int> allRecords()const;
16 QArray<int> matchRegexp(const QRegExp &r) const;
16 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); 17 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
17 QArray<int> effectiveToDos( const QDate& start, 18 QArray<int> effectiveToDos( const QDate& start,
18 const QDate& end, 19 const QDate& end,
19 bool includeNoDates ); 20 bool includeNoDates );
20 QArray<int> overDue(); 21 QArray<int> overDue();
21 QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 22 QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
22 int cat ); 23 int cat );
23 OTodo find(int uid)const; 24 OTodo find(int uid)const;
24 void clear(); 25 void clear();
25 bool add( const OTodo& ); 26 bool add( const OTodo& );
26 bool remove( int uid ); 27 bool remove( int uid );
27 bool replace( const OTodo& ); 28 bool replace( const OTodo& );
28 29
29 void removeAllCompleted(); 30 void removeAllCompleted();
30 virtual QBitArray supports()const; 31 virtual QBitArray supports()const;
31 32
32private: 33private:
33 static QBitArray sup(); 34 static QBitArray sup();
34 bool m_dirty : 1; 35 bool m_dirty : 1;
35 QString m_file; 36 QString m_file;
36 QMap<int, OTodo> m_map; 37 QMap<int, OTodo> m_map;
37}; 38};
38 39
39#endif 40#endif
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 285d2b8..69b7ab4 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -585,192 +585,208 @@ namespace {
585 * 0 if item1 == item2 585 * 0 if item1 == item2
586 * 586 *
587 * > 0 (positive integer) if item1 > item2 587 * > 0 (positive integer) if item1 > item2
588 * 588 *
589 * < 0 (negative integer) if item1 < item2 589 * < 0 (negative integer) if item1 < item2
590 * 590 *
591 */ 591 */
592class OTodoXMLVector : public QVector<OTodoXMLContainer> { 592class OTodoXMLVector : public QVector<OTodoXMLContainer> {
593public: 593public:
594 OTodoXMLVector(int size, bool asc, int sort) 594 OTodoXMLVector(int size, bool asc, int sort)
595 : QVector<OTodoXMLContainer>( size ) 595 : QVector<OTodoXMLContainer>( size )
596 { 596 {
597 setAutoDelete( true ); 597 setAutoDelete( true );
598 m_asc = asc; 598 m_asc = asc;
599 m_sort = sort; 599 m_sort = sort;
600 } 600 }
601 /* return the summary/description */ 601 /* return the summary/description */
602 QString string( const OTodo& todo) { 602 QString string( const OTodo& todo) {
603 return todo.summary().isEmpty() ? 603 return todo.summary().isEmpty() ?
604 todo.description().left(20 ) : 604 todo.description().left(20 ) :
605 todo.summary(); 605 todo.summary();
606 } 606 }
607 /** 607 /**
608 * we take the sortorder( switch on it ) 608 * we take the sortorder( switch on it )
609 * 609 *
610 */ 610 */
611 int compareItems( Item d1, Item d2 ) { 611 int compareItems( Item d1, Item d2 ) {
612 bool seComp, sePrio, seDesc, seDeadline; 612 bool seComp, sePrio, seDesc, seDeadline;
613 seComp = sePrio = seDeadline = seDesc = false; 613 seComp = sePrio = seDeadline = seDesc = false;
614 int ret =0; 614 int ret =0;
615 OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1; 615 OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1;
616 OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2; 616 OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2;
617 617
618 /* same item */ 618 /* same item */
619 if ( con1->todo.uid() == con2->todo.uid() ) 619 if ( con1->todo.uid() == con2->todo.uid() )
620 return 0; 620 return 0;
621 621
622 switch ( m_sort ) { 622 switch ( m_sort ) {
623 /* completed */ 623 /* completed */
624 case 0: { 624 case 0: {
625 ret = completed( con1->todo, con2->todo ); 625 ret = completed( con1->todo, con2->todo );
626 seComp = TRUE; 626 seComp = TRUE;
627 break; 627 break;
628 } 628 }
629 /* priority */ 629 /* priority */
630 case 1: { 630 case 1: {
631 ret = priority( con1->todo, con2->todo ); 631 ret = priority( con1->todo, con2->todo );
632 sePrio = TRUE; 632 sePrio = TRUE;
633 break; 633 break;
634 } 634 }
635 /* description */ 635 /* description */
636 case 2: { 636 case 2: {
637 ret = description( con1->todo, con2->todo ); 637 ret = description( con1->todo, con2->todo );
638 seDesc = TRUE; 638 seDesc = TRUE;
639 break; 639 break;
640 } 640 }
641 /* deadline */ 641 /* deadline */
642 case 3: { 642 case 3: {
643 ret = deadline( con1->todo, con2->todo ); 643 ret = deadline( con1->todo, con2->todo );
644 seDeadline = TRUE; 644 seDeadline = TRUE;
645 break; 645 break;
646 } 646 }
647 default: 647 default:
648 ret = 0; 648 ret = 0;
649 break; 649 break;
650 }; 650 };
651 /* 651 /*
652 * FIXME do better sorting if the first sort criteria 652 * FIXME do better sorting if the first sort criteria
653 * ret equals 0 start with complete and so on... 653 * ret equals 0 start with complete and so on...
654 */ 654 */
655 655
656 /* twist it we're not ascending*/ 656 /* twist it we're not ascending*/
657 if (!m_asc) 657 if (!m_asc)
658 ret = ret * -1; 658 ret = ret * -1;
659 659
660 if ( ret ) 660 if ( ret )
661 return ret; 661 return ret;
662 662
663 // default did not gave difference let's try it other way around 663 // default did not gave difference let's try it other way around
664 /* 664 /*
665 * General try if already checked if not test 665 * General try if already checked if not test
666 * and return 666 * and return
667 * 1.Completed 667 * 1.Completed
668 * 2.Priority 668 * 2.Priority
669 * 3.Description 669 * 3.Description
670 * 4.DueDate 670 * 4.DueDate
671 */ 671 */
672 if (!seComp ) { 672 if (!seComp ) {
673 if ( (ret = completed( con1->todo, con2->todo ) ) ) { 673 if ( (ret = completed( con1->todo, con2->todo ) ) ) {
674 if (!m_asc ) ret *= -1; 674 if (!m_asc ) ret *= -1;
675 return ret; 675 return ret;
676 } 676 }
677 } 677 }
678 if (!sePrio ) { 678 if (!sePrio ) {
679 if ( (ret = priority( con1->todo, con2->todo ) ) ) { 679 if ( (ret = priority( con1->todo, con2->todo ) ) ) {
680 if (!m_asc ) ret *= -1; 680 if (!m_asc ) ret *= -1;
681 return ret; 681 return ret;
682 } 682 }
683 } 683 }
684 if (!seDesc ) { 684 if (!seDesc ) {
685 if ( (ret = description(con1->todo, con2->todo ) ) ) { 685 if ( (ret = description(con1->todo, con2->todo ) ) ) {
686 if (!m_asc) ret *= -1; 686 if (!m_asc) ret *= -1;
687 return ret; 687 return ret;
688 } 688 }
689 } 689 }
690 if (!seDeadline) { 690 if (!seDeadline) {
691 if ( (ret = deadline( con1->todo, con2->todo ) ) ) { 691 if ( (ret = deadline( con1->todo, con2->todo ) ) ) {
692 if (!m_asc) ret *= -1; 692 if (!m_asc) ret *= -1;
693 return ret; 693 return ret;
694 } 694 }
695 } 695 }
696 696
697 return 0; 697 return 0;
698 } 698 }
699 private: 699 private:
700 bool m_asc; 700 bool m_asc;
701 int m_sort; 701 int m_sort;
702 702
703}; 703};
704 704
705QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, 705QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
706 int sortFilter, int cat ) { 706 int sortFilter, int cat ) {
707 qWarning("sorted! %d cat", cat); 707 qWarning("sorted! %d cat", cat);
708 OTodoXMLVector vector(m_events.count(), asc,sortOrder ); 708 OTodoXMLVector vector(m_events.count(), asc,sortOrder );
709 QMap<int, OTodo>::Iterator it; 709 QMap<int, OTodo>::Iterator it;
710 int item = 0; 710 int item = 0;
711 711
712 bool bCat = sortFilter & 1 ? true : false; 712 bool bCat = sortFilter & 1 ? true : false;
713 bool bOnly = sortFilter & 2 ? true : false; 713 bool bOnly = sortFilter & 2 ? true : false;
714 bool comp = sortFilter & 4 ? true : false; 714 bool comp = sortFilter & 4 ? true : false;
715 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 715 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
716 716
717 /* show category */ 717 /* show category */
718 if ( bCat && cat != 0) 718 if ( bCat && cat != 0)
719 if (!(*it).categories().contains( cat ) ) { 719 if (!(*it).categories().contains( cat ) ) {
720 qWarning("category mis match"); 720 qWarning("category mis match");
721 continue; 721 continue;
722 } 722 }
723 /* isOverdue but we should not show overdue - why?*/ 723 /* isOverdue but we should not show overdue - why?*/
724/* if ( (*it).isOverdue() && !bOnly ) { 724/* if ( (*it).isOverdue() && !bOnly ) {
725 qWarning("item is overdue but !bOnly"); 725 qWarning("item is overdue but !bOnly");
726 continue; 726 continue;
727 } 727 }
728*/ 728*/
729 if ( !(*it).isOverdue() && bOnly ) { 729 if ( !(*it).isOverdue() && bOnly ) {
730 qWarning("item is not overdue but bOnly checked"); 730 qWarning("item is not overdue but bOnly checked");
731 continue; 731 continue;
732 } 732 }
733 733
734 if ((*it).isCompleted() && comp ) { 734 if ((*it).isCompleted() && comp ) {
735 qWarning("completed continue!"); 735 qWarning("completed continue!");
736 continue; 736 continue;
737 } 737 }
738 738
739 739
740 OTodoXMLContainer* con = new OTodoXMLContainer(); 740 OTodoXMLContainer* con = new OTodoXMLContainer();
741 con->todo = (*it); 741 con->todo = (*it);
742 vector.insert(item, con ); 742 vector.insert(item, con );
743 item++; 743 item++;
744 } 744 }
745 qWarning("XXX %d Items added", item); 745 qWarning("XXX %d Items added", item);
746 vector.resize( item ); 746 vector.resize( item );
747 /* sort it now */ 747 /* sort it now */
748 vector.sort(); 748 vector.sort();
749 /* now get the uids */ 749 /* now get the uids */
750 QArray<int> array( vector.count() ); 750 QArray<int> array( vector.count() );
751 for (uint i= 0; i < vector.count(); i++ ) { 751 for (uint i= 0; i < vector.count(); i++ ) {
752 array[i] = ( vector.at(i) )->todo.uid(); 752 array[i] = ( vector.at(i) )->todo.uid();
753 } 753 }
754 return array; 754 return array;
755}; 755};
756void OTodoAccessXML::removeAllCompleted() { 756void OTodoAccessXML::removeAllCompleted() {
757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
758 if ( (*it).isCompleted() ) 758 if ( (*it).isCompleted() )
759 m_events.remove( it ); 759 m_events.remove( it );
760 } 760 }
761} 761}
762QBitArray OTodoAccessXML::supports()const { 762QBitArray OTodoAccessXML::supports()const {
763 static QBitArray ar = sup(); 763 static QBitArray ar = sup();
764 return ar; 764 return ar;
765} 765}
766QBitArray OTodoAccessXML::sup() { 766QBitArray OTodoAccessXML::sup() {
767 QBitArray ar( OTodo::CompletedDate +1 ); 767 QBitArray ar( OTodo::CompletedDate +1 );
768 ar.fill( true ); 768 ar.fill( true );
769 ar[OTodo::CrossReference] = false; 769 ar[OTodo::CrossReference] = false;
770 ar[OTodo::State ] = false; 770 ar[OTodo::State ] = false;
771 ar[OTodo::Reminders] = false; 771 ar[OTodo::Reminders] = false;
772 ar[OTodo::Notifiers] = false; 772 ar[OTodo::Notifiers] = false;
773 ar[OTodo::Maintainer] = false; 773 ar[OTodo::Maintainer] = false;
774 774
775 return ar; 775 return ar;
776} 776}
777QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
778{
779 QArray<int> m_currentQuery( m_events.count() );
780 uint arraycounter = 0;
781
782 QMap<int, OTodo>::ConstIterator it;
783 for (it = m_events.begin(); it != m_events.end(); ++it ) {
784 if ( it.data().match( r ) )
785 m_currentQuery[arraycounter++] = it.data().uid();
786
787 }
788 // Shrink to fit..
789 m_currentQuery.resize(arraycounter);
790
791 return m_currentQuery;
792}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index cc4a16f..e4850a1 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -1,59 +1,60 @@
1#ifndef OPIE_TODO_ACCESS_XML_H 1#ifndef OPIE_TODO_ACCESS_XML_H
2#define OPIE_TODO_ACCESS_XML_H 2#define OPIE_TODO_ACCESS_XML_H
3 3
4#include <qasciidict.h> 4#include <qasciidict.h>
5#include <qmap.h> 5#include <qmap.h>
6 6
7#include "otodoaccessbackend.h" 7#include "otodoaccessbackend.h"
8 8
9namespace Opie { 9namespace Opie {
10 class XMLElement; 10 class XMLElement;
11}; 11};
12 12
13class OTodoAccessXML : public OTodoAccessBackend { 13class OTodoAccessXML : public OTodoAccessBackend {
14public: 14public:
15 /** 15 /**
16 * fileName if Empty we will use the default path 16 * fileName if Empty we will use the default path
17 */ 17 */
18 OTodoAccessXML( const QString& appName, 18 OTodoAccessXML( const QString& appName,
19 const QString& fileName = QString::null ); 19 const QString& fileName = QString::null );
20 ~OTodoAccessXML(); 20 ~OTodoAccessXML();
21 21
22 bool load(); 22 bool load();
23 bool reload(); 23 bool reload();
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> matchRegexp(const QRegExp &r) const;
27 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); 28 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
28 OTodo find( int uid )const; 29 OTodo find( int uid )const;
29 void clear(); 30 void clear();
30 bool add( const OTodo& ); 31 bool add( const OTodo& );
31 bool remove( int uid ); 32 bool remove( int uid );
32 void removeAllCompleted(); 33 void removeAllCompleted();
33 bool replace( const OTodo& ); 34 bool replace( const OTodo& );
34 35
35 /* our functions */ 36 /* our functions */
36 QArray<int> effectiveToDos( const QDate& start, 37 QArray<int> effectiveToDos( const QDate& start,
37 const QDate& end, 38 const QDate& end,
38 bool includeNoDates ); 39 bool includeNoDates );
39 QArray<int> overDue(); 40 QArray<int> overDue();
40 QArray<int> sorted( bool asc, int sortOrder, 41 QArray<int> sorted( bool asc, int sortOrder,
41 int sortFilter, int cat ); 42 int sortFilter, int cat );
42 QBitArray supports()const; 43 QBitArray supports()const;
43private: 44private:
44 static QBitArray sup(); 45 static QBitArray sup();
45 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); 46 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& );
46 QString toString( const OTodo& )const; 47 QString toString( const OTodo& )const;
47 QString toString( const QArray<int>& ints ) const; 48 QString toString( const QArray<int>& ints ) const;
48 QMap<int, OTodo> m_events; 49 QMap<int, OTodo> m_events;
49 QString m_file; 50 QString m_file;
50 QString m_app; 51 QString m_app;
51 bool m_opened : 1; 52 bool m_opened : 1;
52 bool m_changed : 1; 53 bool m_changed : 1;
53 class OTodoAccessXMLPrivate; 54 class OTodoAccessXMLPrivate;
54 OTodoAccessXMLPrivate* d; 55 OTodoAccessXMLPrivate* d;
55 int m_year, m_month, m_day; 56 int m_year, m_month, m_day;
56 57
57}; 58};
58 59
59#endif 60#endif
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index 9c9338e..2e3ec1f 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -1,169 +1,168 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.8 2003/05/08 13:55:09 tille
25 * search stuff
26 * and match, toRichText & toShortText in oevent
27 *
24 * Revision 1.7 2002/11/13 14:14:51 eilers 28 * Revision 1.7 2002/11/13 14:14:51 eilers
25 * Added sorted for Contacts.. 29 * Added sorted for Contacts..
26 * 30 *
27 * Revision 1.6 2002/11/01 15:10:42 eilers 31 * Revision 1.6 2002/11/01 15:10:42 eilers
28 * Added regExp-search in database for all fields in a contact. 32 * Added regExp-search in database for all fields in a contact.
29 * 33 *
30 * Revision 1.5 2002/10/16 10:52:40 eilers 34 * Revision 1.5 2002/10/16 10:52:40 eilers
31 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 35 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
32 * 36 *
33 * Revision 1.4 2002/10/14 16:21:54 eilers 37 * Revision 1.4 2002/10/14 16:21:54 eilers
34 * Some minor interface updates 38 * Some minor interface updates
35 * 39 *
36 * Revision 1.3 2002/10/07 17:34:24 eilers 40 * Revision 1.3 2002/10/07 17:34:24 eilers
37 * added OBackendFactory for advanced backend access 41 * added OBackendFactory for advanced backend access
38 * 42 *
39 * Revision 1.2 2002/10/02 16:18:11 eilers 43 * Revision 1.2 2002/10/02 16:18:11 eilers
40 * debugged and seems to work almost perfectly .. 44 * debugged and seems to work almost perfectly ..
41 * 45 *
42 * Revision 1.1 2002/09/27 17:11:44 eilers 46 * Revision 1.1 2002/09/27 17:11:44 eilers
43 * Added API for accessing the Contact-Database ! It is compiling, but 47 * Added API for accessing the Contact-Database ! It is compiling, but
44 * please do not expect that anything is working ! 48 * please do not expect that anything is working !
45 * I will debug that stuff in the next time .. 49 * I will debug that stuff in the next time ..
46 * Please read README_COMPILE for compiling ! 50 * Please read README_COMPILE for compiling !
47 * 51 *
48 * 52 *
49 */ 53 */
50 54
51#include "ocontactaccess.h" 55#include "ocontactaccess.h"
52#include "obackendfactory.h" 56#include "obackendfactory.h"
53 57
54#include <qasciidict.h> 58#include <qasciidict.h>
55#include <qdatetime.h> 59#include <qdatetime.h>
56#include <qfile.h> 60#include <qfile.h>
57#include <qregexp.h> 61#include <qregexp.h>
58#include <qlist.h> 62#include <qlist.h>
59#include <qcopchannel_qws.h> 63#include <qcopchannel_qws.h>
60 64
61//#include <qpe/qcopenvelope_qws.h> 65//#include <qpe/qcopenvelope_qws.h>
62#include <qpe/global.h> 66#include <qpe/global.h>
63 67
64#include <errno.h> 68#include <errno.h>
65#include <fcntl.h> 69#include <fcntl.h>
66#include <unistd.h> 70#include <unistd.h>
67#include <stdlib.h> 71#include <stdlib.h>
68 72
69#include "ocontactaccessbackend_xml.h" 73#include "ocontactaccessbackend_xml.h"
70 74
71 75
72OContactAccess::OContactAccess ( const QString appname, const QString , 76OContactAccess::OContactAccess ( const QString appname, const QString ,
73 OContactAccessBackend* end, bool autosync ): 77 OContactAccessBackend* end, bool autosync ):
74 OPimAccessTemplate<OContact>( end ) 78 OPimAccessTemplate<OContact>( end )
75{ 79{
76 /* take care of the backend. If there is no one defined, we 80 /* take care of the backend. If there is no one defined, we
77 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 81 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
78 */ 82 */
79 if( end == 0 ) { 83 if( end == 0 ) {
80 qWarning ("Using BackendFactory !"); 84 qWarning ("Using BackendFactory !");
81 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 85 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
82 } 86 }
83 // Set backend locally and in template 87 // Set backend locally and in template
84 m_backEnd = end; 88 m_backEnd = end;
85 OPimAccessTemplate<OContact>::setBackEnd (end); 89 OPimAccessTemplate<OContact>::setBackEnd (end);
86 90
87 91
88 /* Connect signal of external db change to function */ 92 /* Connect signal of external db change to function */
89 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 93 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
90 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 94 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
91 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 95 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
92 if ( autosync ){ 96 if ( autosync ){
93 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 97 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
94 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 98 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)),
95 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 99 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
96 } 100 }
97 101
98 102
99} 103}
100OContactAccess::~OContactAccess () 104OContactAccess::~OContactAccess ()
101{ 105{
102 /* The user may forget to save the changed database, therefore try to 106 /* The user may forget to save the changed database, therefore try to
103 * do it for him.. 107 * do it for him..
104 */ 108 */
105 save(); 109 save();
106 // delete m_backEnd; is done by template.. 110 // delete m_backEnd; is done by template..
107} 111}
108 112
109 113
110bool OContactAccess::save () 114bool OContactAccess::save ()
111{ 115{
112 /* If the database was changed externally, we could not save the 116 /* If the database was changed externally, we could not save the
113 * Data. This will remove added items which is unacceptable ! 117 * Data. This will remove added items which is unacceptable !
114 * Therefore: Reload database and merge the data... 118 * Therefore: Reload database and merge the data...
115 */ 119 */
116 if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) 120 if ( OPimAccessTemplate<OContact>::wasChangedExternally() )
117 reload(); 121 reload();
118 122
119 bool status = OPimAccessTemplate<OContact>::save(); 123 bool status = OPimAccessTemplate<OContact>::save();
120 if ( !status ) return false; 124 if ( !status ) return false;
121 125
122 /* Now tell everyone that new data is available. 126 /* Now tell everyone that new data is available.
123 */ 127 */
124 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 128 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
125 129
126 return true; 130 return true;
127} 131}
128 132
129ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{
130 QArray<int> matchingContacts = m_backEnd -> matchRegexp( r );
131 return ( ORecordList<OContact>(matchingContacts, this) );
132}
133
134const uint OContactAccess::querySettings() 133const uint OContactAccess::querySettings()
135{ 134{
136 return ( m_backEnd->querySettings() ); 135 return ( m_backEnd->querySettings() );
137} 136}
138 137
139bool OContactAccess::hasQuerySettings ( int querySettings ) const 138bool OContactAccess::hasQuerySettings ( int querySettings ) const
140{ 139{
141 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 140 return ( m_backEnd->hasQuerySettings ( querySettings ) );
142} 141}
143ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 142ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
144{ 143{
145 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 144 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
146 return ( ORecordList<OContact>(matchingContacts, this) ); 145 return ( ORecordList<OContact>(matchingContacts, this) );
147} 146}
148 147
149 148
150bool OContactAccess::wasChangedExternally()const 149bool OContactAccess::wasChangedExternally()const
151{ 150{
152 return ( m_backEnd->wasChangedExternally() ); 151 return ( m_backEnd->wasChangedExternally() );
153} 152}
154 153
155 154
156void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) 155void OContactAccess::copMessage( const QCString &msg, const QByteArray & )
157{ 156{
158 if ( msg == "addressbookUpdated()" ){ 157 if ( msg == "addressbookUpdated()" ){
159 qWarning ("OContactAccess: Received addressbokUpdated()"); 158 qWarning ("OContactAccess: Received addressbokUpdated()");
160 emit signalChanged ( this ); 159 emit signalChanged ( this );
161 } else if ( msg == "flush()" ) { 160 } else if ( msg == "flush()" ) {
162 qWarning ("OContactAccess: Received flush()"); 161 qWarning ("OContactAccess: Received flush()");
163 save (); 162 save ();
164 } else if ( msg == "reload()" ) { 163 } else if ( msg == "reload()" ) {
165 qWarning ("OContactAccess: Received reload()"); 164 qWarning ("OContactAccess: Received reload()");
166 reload (); 165 reload ();
167 emit signalChanged ( this ); 166 emit signalChanged ( this );
168 } 167 }
169} 168}
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index d7ceaf2..e90db32 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -1,168 +1,170 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; 10 * License as published by the Free Software Foundation;
11 * either version 2 of the License, or (at your option) any later 11 * either version 2 of the License, or (at your option) any later
12 * version. 12 * version.
13 * ===================================================================== 13 * =====================================================================
14 * ToDo: Define enum for query settings 14 * ToDo: Define enum for query settings
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.8 2003/05/08 13:55:09 tille
21 * search stuff
22 * and match, toRichText & toShortText in oevent
23 *
20 * Revision 1.7 2003/04/13 18:07:10 zecke 24 * Revision 1.7 2003/04/13 18:07:10 zecke
21 * More API doc 25 * More API doc
22 * QString -> const QString& 26 * QString -> const QString&
23 * QString = 0l -> QString::null 27 * QString = 0l -> QString::null
24 * 28 *
25 * Revision 1.6 2003/01/02 14:27:12 eilers 29 * Revision 1.6 2003/01/02 14:27:12 eilers
26 * Improved query by example: Search by date is possible.. First step 30 * Improved query by example: Search by date is possible.. First step
27 * for a today plugin for birthdays.. 31 * for a today plugin for birthdays..
28 * 32 *
29 * Revision 1.5 2002/11/13 14:14:51 eilers 33 * Revision 1.5 2002/11/13 14:14:51 eilers
30 * Added sorted for Contacts.. 34 * Added sorted for Contacts..
31 * 35 *
32 * Revision 1.4 2002/11/01 15:10:42 eilers 36 * Revision 1.4 2002/11/01 15:10:42 eilers
33 * Added regExp-search in database for all fields in a contact. 37 * Added regExp-search in database for all fields in a contact.
34 * 38 *
35 * Revision 1.3 2002/10/16 10:52:40 eilers 39 * Revision 1.3 2002/10/16 10:52:40 eilers
36 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 40 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
37 * 41 *
38 * Revision 1.2 2002/10/14 16:21:54 eilers 42 * Revision 1.2 2002/10/14 16:21:54 eilers
39 * Some minor interface updates 43 * Some minor interface updates
40 * 44 *
41 * Revision 1.1 2002/09/27 17:11:44 eilers 45 * Revision 1.1 2002/09/27 17:11:44 eilers
42 * Added API for accessing the Contact-Database ! It is compiling, but 46 * Added API for accessing the Contact-Database ! It is compiling, but
43 * please do not expect that anything is working ! 47 * please do not expect that anything is working !
44 * I will debug that stuff in the next time .. 48 * I will debug that stuff in the next time ..
45 * Please read README_COMPILE for compiling ! 49 * Please read README_COMPILE for compiling !
46 * 50 *
47 * ===================================================================== 51 * =====================================================================
48 */ 52 */
49#ifndef _OCONTACTACCESS_H 53#ifndef _OCONTACTACCESS_H
50#define _OCONTACTACCESS_H 54#define _OCONTACTACCESS_H
51 55
52#include <qobject.h> 56#include <qobject.h>
53 57
54#include <qpe/qcopenvelope_qws.h> 58#include <qpe/qcopenvelope_qws.h>
55 59
56#include <qvaluelist.h> 60#include <qvaluelist.h>
57#include <qfileinfo.h> 61#include <qfileinfo.h>
58 62
59#include "ocontact.h" 63#include "ocontact.h"
60#include "ocontactaccessbackend.h" 64#include "ocontactaccessbackend.h"
61#include "opimaccesstemplate.h" 65#include "opimaccesstemplate.h"
62 66
63/** 67/**
64 * Class to access the contacts database. 68 * Class to access the contacts database.
65 * This is just a frontend for the real database handling which is 69 * This is just a frontend for the real database handling which is
66 * done by the backend. 70 * done by the backend.
67 * This class is used to access the Contacts on a system. This class as any OPIE PIM 71 * This class is used to access the Contacts on a system. This class as any OPIE PIM
68 * class is backend independent. 72 * class is backend independent.
69 73
70 * @see OPimAccessTemplate 74 * @see OPimAccessTemplate
71 */ 75 */
72class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 76class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
73{ 77{
74 Q_OBJECT 78 Q_OBJECT
75 79
76 public: 80 public:
77 /** 81 /**
78 * Create Database with contacts (addressbook). 82 * Create Database with contacts (addressbook).
79 * @param appname Name of application which wants access to the database 83 * @param appname Name of application which wants access to the database
80 * (i.e. "todolist") 84 * (i.e. "todolist")
81 * @param filename The name of the database file. If not set, the default one 85 * @param filename The name of the database file. If not set, the default one
82 * is used. 86 * is used.
83 * @param backend Pointer to an alternative Backend. If not set, we will use 87 * @param backend Pointer to an alternative Backend. If not set, we will use
84 * the default backend. 88 * the default backend.
85 * @param handlesync If <b>true</b> the database stores the current state 89 * @param handlesync If <b>true</b> the database stores the current state
86 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> 90 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
87 * which are used before and after synchronisation. If the application wants 91 * which are used before and after synchronisation. If the application wants
88 * to react itself, it should be disabled by setting it to <b>false</b> 92 * to react itself, it should be disabled by setting it to <b>false</b>
89 * @see OContactAccessBackend 93 * @see OContactAccessBackend
90 */ 94 */
91 OContactAccess (const QString appname, const QString filename = 0l, 95 OContactAccess (const QString appname, const QString filename = 0l,
92 OContactAccessBackend* backend = 0l, bool handlesync = true); 96 OContactAccessBackend* backend = 0l, bool handlesync = true);
93 ~OContactAccess (); 97 ~OContactAccess ();
94 98
95 /** Constants for query. 99 /** Constants for query.
96 * Use this constants to set the query parameters. 100 * Use this constants to set the query parameters.
97 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! 101 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
98 * @see queryByExample() 102 * @see queryByExample()
99 */ 103 */
100 enum QuerySettings { 104 enum QuerySettings {
101 WildCards = 0x0001, 105 WildCards = 0x0001,
102 IgnoreCase = 0x0002, 106 IgnoreCase = 0x0002,
103 RegExp = 0x0004, 107 RegExp = 0x0004,
104 ExactMatch = 0x0008, 108 ExactMatch = 0x0008,
105 MatchOne = 0x0010, // Only one Entry must match 109 MatchOne = 0x0010, // Only one Entry must match
106 DateDiff = 0x0020, // Find all entries from today until given date 110 DateDiff = 0x0020, // Find all entries from today until given date
107 DateYear = 0x0040, // The year matches 111 DateYear = 0x0040, // The year matches
108 DateMonth = 0x0080, // The month matches 112 DateMonth = 0x0080, // The month matches
109 DateDay = 0x0100, // The day matches 113 DateDay = 0x0100, // The day matches
110 }; 114 };
111 115
112 116
113 ORecordList<OContact> matchRegexp( const QRegExp &r )const;
114
115 /** Return all Contacts in a sorted manner. 117 /** Return all Contacts in a sorted manner.
116 * @param ascending true: Sorted in acending order. 118 * @param ascending true: Sorted in acending order.
117 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess 119 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
118 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess 120 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
119 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess 121 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
120 */ 122 */
121 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; 123 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
122 124
123 /** Return all possible settings. 125 /** Return all possible settings.
124 * @return All settings provided by the current backend 126 * @return All settings provided by the current backend
125 * (i.e.: query_WildCards & query_IgnoreCase) 127 * (i.e.: query_WildCards & query_IgnoreCase)
126 */ 128 */
127 const uint querySettings(); 129 const uint querySettings();
128 130
129 /** Check whether settings are correct. 131 /** Check whether settings are correct.
130 * @return <i>true</i> if the given settings are correct and possible. 132 * @return <i>true</i> if the given settings are correct and possible.
131 */ 133 */
132 bool hasQuerySettings ( int querySettings ) const; 134 bool hasQuerySettings ( int querySettings ) const;
133 135
134 /** 136 /**
135 * if the resource was changed externally. 137 * if the resource was changed externally.
136 * You should use the signal instead of polling possible changes ! 138 * You should use the signal instead of polling possible changes !
137 */ 139 */
138 bool wasChangedExternally()const; 140 bool wasChangedExternally()const;
139 141
140 142
141 /** Save contacts database. 143 /** Save contacts database.
142 * Save is more a "commit". After calling this function, all changes are public available. 144 * Save is more a "commit". After calling this function, all changes are public available.
143 * @return true if successful 145 * @return true if successful
144 */ 146 */
145 bool save(); 147 bool save();
146 148
147 signals: 149 signals:
148 /* Signal is emitted if the database was changed. Therefore 150 /* Signal is emitted if the database was changed. Therefore
149 * we may need to reload to stay consistent. 151 * we may need to reload to stay consistent.
150 * @param which Pointer to the database who created this event. This pointer 152 * @param which Pointer to the database who created this event. This pointer
151 * is useful if an application has to handle multiple databases at the same time. 153 * is useful if an application has to handle multiple databases at the same time.
152 * @see reload() 154 * @see reload()
153 */ 155 */
154 void signalChanged ( const OContactAccess *which ); 156 void signalChanged ( const OContactAccess *which );
155 157
156 158
157 private: 159 private:
158 // class OContactAccessPrivate; 160 // class OContactAccessPrivate;
159 // OContactAccessPrivate* d; 161 // OContactAccessPrivate* d;
160 OContactAccessBackend *m_backEnd; 162 OContactAccessBackend *m_backEnd;
161 bool m_loading:1; 163 bool m_loading:1;
162 164
163 private slots: 165 private slots:
164 void copMessage( const QCString &msg, const QByteArray &data ); 166 void copMessage( const QCString &msg, const QByteArray &data );
165 167
166 168
167}; 169};
168#endif 170#endif
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 6a3a0db..8ff205c 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -1,286 +1,298 @@
1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H 1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H
2#define OPIE_PIM_ACCESS_TEMPLATE_H 2#define OPIE_PIM_ACCESS_TEMPLATE_H
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7#include <opie/opimaccessbackend.h> 7#include <opie/opimaccessbackend.h>
8#include <opie/orecordlist.h> 8#include <opie/orecordlist.h>
9 9
10#include "opimcache.h" 10#include "opimcache.h"
11#include "otemplatebase.h" 11#include "otemplatebase.h"
12 12
13/** 13/**
14 * Thats the frontend to our OPIE PIM 14 * Thats the frontend to our OPIE PIM
15 * Library. Either you want to use it's 15 * Library. Either you want to use it's
16 * interface or you want to implement 16 * interface or you want to implement
17 * your own Access lib 17 * your own Access lib
18 * Just create a OPimRecord and inherit from 18 * Just create a OPimRecord and inherit from
19 * the plugins 19 * the plugins
20 */ 20 */
21 21
22template <class T = OPimRecord > 22template <class T = OPimRecord >
23class OPimAccessTemplate : public OTemplateBase<T> { 23class OPimAccessTemplate : public OTemplateBase<T> {
24public: 24public:
25 enum Access { 25 enum Access {
26 Random = 0, 26 Random = 0,
27 SortedAccess 27 SortedAccess
28 }; 28 };
29 typedef ORecordList<T> List; 29 typedef ORecordList<T> List;
30 typedef OPimAccessBackend<T> BackEnd; 30 typedef OPimAccessBackend<T> BackEnd;
31 typedef OPimCache<T> Cache; 31 typedef OPimCache<T> Cache;
32 32
33 /** 33 /**
34 * c'tor BackEnd 34 * c'tor BackEnd
35 * enum Access a small hint on how to handle the backend 35 * enum Access a small hint on how to handle the backend
36 */ 36 */
37 OPimAccessTemplate( BackEnd* end); 37 OPimAccessTemplate( BackEnd* end);
38 38
39 virtual ~OPimAccessTemplate(); 39 virtual ~OPimAccessTemplate();
40 40
41 /** 41 /**
42 * load from the backend 42 * load from the backend
43 */ 43 */
44 bool load(); 44 bool load();
45 45
46 /** Reload database. 46 /** Reload database.
47 * You should execute this function if the external database 47 * You should execute this function if the external database
48 * was changed. 48 * was changed.
49 * This function will load the external database and afterwards 49 * This function will load the external database and afterwards
50 * rejoin the local changes. Therefore the local database will be set consistent. 50 * rejoin the local changes. Therefore the local database will be set consistent.
51 */ 51 */
52 virtual bool reload(); 52 virtual bool reload();
53 53
54 /** Save contacts database. 54 /** Save contacts database.
55 * Save is more a "commit". After calling this function, all changes are public available. 55 * Save is more a "commit". After calling this function, all changes are public available.
56 * @return true if successful 56 * @return true if successful
57 */ 57 */
58 bool save(); 58 bool save();
59 59
60 /** 60 /**
61 * if the resource was changed externally 61 * if the resource was changed externally
62 * You should use the signal handling instead of polling possible changes ! 62 * You should use the signal handling instead of polling possible changes !
63 * zecke: Do you implement a signal for otodoaccess ? 63 * zecke: Do you implement a signal for otodoaccess ?
64 */ 64 */
65 bool wasChangedExternally()const; 65 bool wasChangedExternally()const;
66 66
67 /** 67 /**
68 * return a List of records 68 * return a List of records
69 * you can iterate over them 69 * you can iterate over them
70 */ 70 */
71 virtual List allRecords()const; 71 virtual List allRecords()const;
72
73 /**
74 * return a List of records
75 * that match the regex
76 */
77 virtual List matchRegexp( const QRegExp &r ) const;
72 78
73 /** 79 /**
74 * queryByExample. 80 * queryByExample.
75 * @see otodoaccess, ocontactaccess 81 * @see otodoaccess, ocontactaccess
76 */ 82 */
77 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); 83 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
78 84
79 /** 85 /**
80 * find the OPimRecord uid 86 * find the OPimRecord uid
81 */ 87 */
82 virtual T find( int uid )const; 88 virtual T find( int uid )const;
83 89
84 /** 90 /**
85 * read ahead cache find method ;) 91 * read ahead cache find method ;)
86 */ 92 */
87 virtual T find( int uid, const QArray<int>&, 93 virtual T find( int uid, const QArray<int>&,
88 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 94 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
89 95
90 /* invalidate cache here */ 96 /* invalidate cache here */
91 /** 97 /**
92 * clears the backend and invalidates the backend 98 * clears the backend and invalidates the backend
93 */ 99 */
94 void clear() ; 100 void clear() ;
95 101
96 /** 102 /**
97 * add T to the backend 103 * add T to the backend
98 * @param t The item to add. 104 * @param t The item to add.
99 * @return <i>true</i> if added successfully. 105 * @return <i>true</i> if added successfully.
100 */ 106 */
101 virtual bool add( const T& t ) ; 107 virtual bool add( const T& t ) ;
102 bool add( const OPimRecord& ); 108 bool add( const OPimRecord& );
103 109
104 /* only the uid matters */ 110 /* only the uid matters */
105 /** 111 /**
106 * remove T from the backend 112 * remove T from the backend
107 * @param t The item to remove 113 * @param t The item to remove
108 * @return <i>true</i> if successful. 114 * @return <i>true</i> if successful.
109 */ 115 */
110 virtual bool remove( const T& t ); 116 virtual bool remove( const T& t );
111 117
112 /** 118 /**
113 * remove the OPimRecord with uid 119 * remove the OPimRecord with uid
114 * @param uid The ID of the item to remove 120 * @param uid The ID of the item to remove
115 * @return <i>true</i> if successful. 121 * @return <i>true</i> if successful.
116 */ 122 */
117 bool remove( int uid ); 123 bool remove( int uid );
118 bool remove( const OPimRecord& ); 124 bool remove( const OPimRecord& );
119 125
120 /** 126 /**
121 * replace T from backend 127 * replace T from backend
122 * @param t The item to replace 128 * @param t The item to replace
123 * @return <i>true</i> if successful. 129 * @return <i>true</i> if successful.
124 */ 130 */
125 virtual bool replace( const T& t) ; 131 virtual bool replace( const T& t) ;
126 132
127 void setReadAhead( uint count ); 133 void setReadAhead( uint count );
128 /** 134 /**
129 * @internal 135 * @internal
130 */ 136 */
131 void cache( const T& )const; 137 void cache( const T& )const;
132 void setSaneCacheSize( int ); 138 void setSaneCacheSize( int );
133 139
134 QArray<int> records()const; 140 QArray<int> records()const;
135protected: 141protected:
136 /** 142 /**
137 * invalidate the cache 143 * invalidate the cache
138 */ 144 */
139 void invalidateCache(); 145 void invalidateCache();
140 146
141 void setBackEnd( BackEnd* end ); 147 void setBackEnd( BackEnd* end );
142 /** 148 /**
143 * returns the backend 149 * returns the backend
144 */ 150 */
145 BackEnd* backEnd(); 151 BackEnd* backEnd();
146 BackEnd* m_backEnd; 152 BackEnd* m_backEnd;
147 Cache m_cache; 153 Cache m_cache;
148 154
149}; 155};
150 156
151template <class T> 157template <class T>
152OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 158OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
153 : OTemplateBase<T>(), m_backEnd( end ) 159 : OTemplateBase<T>(), m_backEnd( end )
154{ 160{
155 if (end ) 161 if (end )
156 end->setFrontend( this ); 162 end->setFrontend( this );
157} 163}
158template <class T> 164template <class T>
159OPimAccessTemplate<T>::~OPimAccessTemplate() { 165OPimAccessTemplate<T>::~OPimAccessTemplate() {
160 qWarning("~OPimAccessTemplate<T>"); 166 qWarning("~OPimAccessTemplate<T>");
161 delete m_backEnd; 167 delete m_backEnd;
162} 168}
163template <class T> 169template <class T>
164bool OPimAccessTemplate<T>::load() { 170bool OPimAccessTemplate<T>::load() {
165 invalidateCache(); 171 invalidateCache();
166 return m_backEnd->load(); 172 return m_backEnd->load();
167} 173}
168template <class T> 174template <class T>
169bool OPimAccessTemplate<T>::reload() { 175bool OPimAccessTemplate<T>::reload() {
170 invalidateCache(); // zecke: I think this should be added (se) 176 invalidateCache(); // zecke: I think this should be added (se)
171 return m_backEnd->reload(); 177 return m_backEnd->reload();
172} 178}
173template <class T> 179template <class T>
174bool OPimAccessTemplate<T>::save() { 180bool OPimAccessTemplate<T>::save() {
175 return m_backEnd->save(); 181 return m_backEnd->save();
176} 182}
177template <class T> 183template <class T>
178typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 184typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
179 QArray<int> ints = m_backEnd->allRecords(); 185 QArray<int> ints = m_backEnd->allRecords();
180 List lis(ints, this ); 186 List lis(ints, this );
181 return lis; 187 return lis;
182} 188}
183template <class T> 189template <class T>
190typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
191 QArray<int> ints = m_backEnd->matchRegexp( r );
192 List lis(ints, this );
193 return lis;
194}
195template <class T>
184QArray<int> OPimAccessTemplate<T>::records()const { 196QArray<int> OPimAccessTemplate<T>::records()const {
185 return m_backEnd->allRecords(); 197 return m_backEnd->allRecords();
186} 198}
187template <class T> 199template <class T>
188typename OPimAccessTemplate<T>::List 200typename OPimAccessTemplate<T>::List
189OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { 201OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) {
190 QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); 202 QArray<int> ints = m_backEnd->queryByExample( t, settings, d );
191 203
192 List lis(ints, this ); 204 List lis(ints, this );
193 return lis; 205 return lis;
194} 206}
195template <class T> 207template <class T>
196T OPimAccessTemplate<T>::find( int uid ) const{ 208T OPimAccessTemplate<T>::find( int uid ) const{
197 T t = m_backEnd->find( uid ); 209 T t = m_backEnd->find( uid );
198 cache( t ); 210 cache( t );
199 return t; 211 return t;
200} 212}
201template <class T> 213template <class T>
202T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 214T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
203 uint current, typename OTemplateBase<T>::CacheDirection dir )const { 215 uint current, typename OTemplateBase<T>::CacheDirection dir )const {
204 /* 216 /*
205 * better do T.isEmpty() 217 * better do T.isEmpty()
206 * after a find this way we would 218 * after a find this way we would
207 * avoid two finds in QCache... 219 * avoid two finds in QCache...
208 */ 220 */
209 // qWarning("find it now %d", uid ); 221 // qWarning("find it now %d", uid );
210 if (m_cache.contains( uid ) ) { 222 if (m_cache.contains( uid ) ) {
211 return m_cache.find( uid ); 223 return m_cache.find( uid );
212 } 224 }
213 225
214 T t = m_backEnd->find( uid, ar, current, dir ); 226 T t = m_backEnd->find( uid, ar, current, dir );
215 cache( t ); 227 cache( t );
216 return t; 228 return t;
217} 229}
218template <class T> 230template <class T>
219void OPimAccessTemplate<T>::clear() { 231void OPimAccessTemplate<T>::clear() {
220 invalidateCache(); 232 invalidateCache();
221 m_backEnd->clear(); 233 m_backEnd->clear();
222} 234}
223template <class T> 235template <class T>
224bool OPimAccessTemplate<T>::add( const T& t ) { 236bool OPimAccessTemplate<T>::add( const T& t ) {
225 cache( t ); 237 cache( t );
226 return m_backEnd->add( t ); 238 return m_backEnd->add( t );
227} 239}
228template <class T> 240template <class T>
229bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { 241bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
230 /* same type */ 242 /* same type */
231 if ( rec.rtti() == T::rtti() ) { 243 if ( rec.rtti() == T::rtti() ) {
232 const T &t = static_cast<const T&>(rec); 244 const T &t = static_cast<const T&>(rec);
233 return add(t); 245 return add(t);
234 } 246 }
235 return false; 247 return false;
236} 248}
237template <class T> 249template <class T>
238bool OPimAccessTemplate<T>::remove( const T& t ) { 250bool OPimAccessTemplate<T>::remove( const T& t ) {
239 return remove( t.uid() ); 251 return remove( t.uid() );
240} 252}
241template <class T> 253template <class T>
242bool OPimAccessTemplate<T>::remove( int uid ) { 254bool OPimAccessTemplate<T>::remove( int uid ) {
243 m_cache.remove( uid ); 255 m_cache.remove( uid );
244 return m_backEnd->remove( uid ); 256 return m_backEnd->remove( uid );
245} 257}
246template <class T> 258template <class T>
247bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { 259bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) {
248 return remove( rec.uid() ); 260 return remove( rec.uid() );
249} 261}
250template <class T> 262template <class T>
251bool OPimAccessTemplate<T>::replace( const T& t ) { 263bool OPimAccessTemplate<T>::replace( const T& t ) {
252 m_cache.replace( t ); 264 m_cache.replace( t );
253 return m_backEnd->replace( t ); 265 return m_backEnd->replace( t );
254} 266}
255template <class T> 267template <class T>
256void OPimAccessTemplate<T>::invalidateCache() { 268void OPimAccessTemplate<T>::invalidateCache() {
257 m_cache.invalidate(); 269 m_cache.invalidate();
258} 270}
259template <class T> 271template <class T>
260typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { 272typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() {
261 return m_backEnd; 273 return m_backEnd;
262} 274}
263template <class T> 275template <class T>
264bool OPimAccessTemplate<T>::wasChangedExternally()const { 276bool OPimAccessTemplate<T>::wasChangedExternally()const {
265 return false; 277 return false;
266} 278}
267template <class T> 279template <class T>
268void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { 280void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) {
269 m_backEnd = end; 281 m_backEnd = end;
270 if (m_backEnd ) 282 if (m_backEnd )
271 m_backEnd->setFrontend( this ); 283 m_backEnd->setFrontend( this );
272} 284}
273template <class T> 285template <class T>
274void OPimAccessTemplate<T>::cache( const T& t ) const{ 286void OPimAccessTemplate<T>::cache( const T& t ) const{
275 /* hacky we need to work around the const*/ 287 /* hacky we need to work around the const*/
276 ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); 288 ((OPimAccessTemplate<T>*)this)->m_cache.add( t );
277} 289}
278template <class T> 290template <class T>
279void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { 291void OPimAccessTemplate<T>::setSaneCacheSize( int size ) {
280 m_cache.setSize( size ); 292 m_cache.setSize( size );
281} 293}
282template <class T> 294template <class T>
283void OPimAccessTemplate<T>::setReadAhead( uint count ) { 295void OPimAccessTemplate<T>::setReadAhead( uint count ) {
284 m_backEnd->setReadAhead( count ); 296 m_backEnd->setReadAhead( count );
285} 297}
286#endif 298#endif
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index c7f9460..de2d9f4 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -1,134 +1,140 @@
1#ifndef OPIE_PIM_RECORD_H 1#ifndef OPIE_PIM_RECORD_H
2#define OPIE_PIM_RECORD_H 2#define OPIE_PIM_RECORD_H
3 3
4#include <qdatastream.h> 4#include <qdatastream.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10 10
11#include <opie/opimxrefmanager.h> 11#include <opie/opimxrefmanager.h>
12 12
13/** 13/**
14 * This is the base class for 14 * This is the base class for
15 * all PIM Records 15 * all PIM Records
16 * 16 *
17 */ 17 */
18class OPimRecord : public Qtopia::Record { 18class OPimRecord : public Qtopia::Record {
19public: 19public:
20 /** 20 /**
21 * c'tor 21 * c'tor
22 * uid of 0 isEmpty 22 * uid of 0 isEmpty
23 * uid of 1 will be assigned a new one 23 * uid of 1 will be assigned a new one
24 */ 24 */
25 OPimRecord(int uid = 0); 25 OPimRecord(int uid = 0);
26 ~OPimRecord(); 26 ~OPimRecord();
27 27
28 /** 28 /**
29 * copy c'tor 29 * copy c'tor
30 */ 30 */
31 OPimRecord( const OPimRecord& rec ); 31 OPimRecord( const OPimRecord& rec );
32 32
33 /** 33 /**
34 * copy operator 34 * copy operator
35 */ 35 */
36 OPimRecord &operator=( const OPimRecord& ); 36 OPimRecord &operator=( const OPimRecord& );
37 37
38 /** 38 /**
39 * category names resolved 39 * category names resolved
40 */ 40 */
41 QStringList categoryNames( const QString& appname )const; 41 QStringList categoryNames( const QString& appname )const;
42 42
43 /** 43 /**
44 * set category names they will be resolved 44 * set category names they will be resolved
45 */ 45 */
46 void setCategoryNames( const QStringList& ); 46 void setCategoryNames( const QStringList& );
47 47
48 /** 48 /**
49 * addCategoryName adds a name 49 * addCategoryName adds a name
50 * to the internal category list 50 * to the internal category list
51 */ 51 */
52 void addCategoryName( const QString& ); 52 void addCategoryName( const QString& );
53 53
54 /** 54 /**
55 * if a Record isEmpty 55 * if a Record isEmpty
56 * it's empty if it's 0 56 * it's empty if it's 0
57 */ 57 */
58 virtual bool isEmpty()const; 58 virtual bool isEmpty()const;
59 59
60 /** 60 /**
61 * toRichText summary 61 * toRichText summary
62 */ 62 */
63 virtual QString toRichText()const = 0; 63 virtual QString toRichText()const = 0;
64 64
65 /** 65 /**
66 * a small one line summary 66 * a small one line summary
67 */ 67 */
68 virtual QString toShortText()const = 0; 68 virtual QString toShortText()const = 0;
69 69
70 /** 70 /**
71 * the name of the Record 71 * the name of the Record
72 */ 72 */
73 virtual QString type()const = 0; 73 virtual QString type()const = 0;
74 74
75 /** 75 /**
76 * matches the Records the regular expression?
77 */
78 virtual bool match( const QString &regexp ) const {return match(QRegExp(regexp));};
79 virtual bool match( const QRegExp &regexp ) const = 0;
80
81 /**
76 * converts the internal structure to a map 82 * converts the internal structure to a map
77 */ 83 */
78 virtual QMap<int, QString> toMap()const = 0; 84 virtual QMap<int, QString> toMap()const = 0;
79 85
80 /** 86 /**
81 * key value representation of extra items 87 * key value representation of extra items
82 */ 88 */
83 virtual QMap<QString, QString> toExtraMap()const = 0; 89 virtual QMap<QString, QString> toExtraMap()const = 0;
84 90
85 /** 91 /**
86 * the name for a recordField 92 * the name for a recordField
87 */ 93 */
88 virtual QString recordField(int)const = 0; 94 virtual QString recordField(int)const = 0;
89 95
90 /** 96 /**
91 * returns a reference of the 97 * returns a reference of the
92 * Cross Reference Manager 98 * Cross Reference Manager
93 * Partner 'One' is THIS PIM RECORD! 99 * Partner 'One' is THIS PIM RECORD!
94 * 'Two' is the Partner where we link to 100 * 'Two' is the Partner where we link to
95 */ 101 */
96 OPimXRefManager& xrefmanager(); 102 OPimXRefManager& xrefmanager();
97 103
98 /** 104 /**
99 * set the uid 105 * set the uid
100 */ 106 */
101 virtual void setUid( int uid ); 107 virtual void setUid( int uid );
102 108
103 /* 109 /*
104 * used inside the Templates for casting 110 * used inside the Templates for casting
105 * REIMPLEMENT in your .... 111 * REIMPLEMENT in your ....
106 */ 112 */
107 static int rtti(); 113 static int rtti();
108 114
109 /** 115 /**
110 * some marshalling and de marshalling code 116 * some marshalling and de marshalling code
111 * saves the OPimRecord 117 * saves the OPimRecord
112 * to and from a DataStream 118 * to and from a DataStream
113 */ 119 */
114 virtual bool loadFromStream(QDataStream& ); 120 virtual bool loadFromStream(QDataStream& );
115 virtual bool saveToStream( QDataStream& stream )const; 121 virtual bool saveToStream( QDataStream& stream )const;
116 122
117protected: 123protected:
118 Qtopia::UidGen &uidGen(); 124 Qtopia::UidGen &uidGen();
119// QString crossToString()const; 125// QString crossToString()const;
120 126
121private: 127private:
122 class OPimRecordPrivate; 128 class OPimRecordPrivate;
123 OPimRecordPrivate *d; 129 OPimRecordPrivate *d;
124 OPimXRefManager m_xrefman; 130 OPimXRefManager m_xrefman;
125 static Qtopia::UidGen m_uidGen; 131 static Qtopia::UidGen m_uidGen;
126 132
127private: 133private:
128 void flush( const OPimXRefPartner&, QDataStream& stream )const; 134 void flush( const OPimXRefPartner&, QDataStream& stream )const;
129 OPimXRefPartner partner( QDataStream& ); 135 OPimXRefPartner partner( QDataStream& );
130}; 136};
131 137
132 138
133 139
134#endif 140#endif
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 96a5f65..a38b62b 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -758,389 +758,380 @@ QString OContact::fullName() const
758 758
759/*! 759/*!
760 Returns a list of the names of the children of the contact. 760 Returns a list of the names of the children of the contact.
761*/ 761*/
762QStringList OContact::childrenList() const 762QStringList OContact::childrenList() const
763{ 763{
764 return QStringList::split( " ", find( Qtopia::Children ) ); 764 return QStringList::split( " ", find( Qtopia::Children ) );
765} 765}
766 766
767/*! \fn void OContact::insertEmail( const QString &email ) 767/*! \fn void OContact::insertEmail( const QString &email )
768 768
769 Insert \a email into the email list. Ensures \a email can only be added 769 Insert \a email into the email list. Ensures \a email can only be added
770 once. If there is no default email address set, it sets it to the \a email. 770 once. If there is no default email address set, it sets it to the \a email.
771*/ 771*/
772 772
773/*! \fn void OContact::removeEmail( const QString &email ) 773/*! \fn void OContact::removeEmail( const QString &email )
774 774
775 Removes the \a email from the email list. If the default email was \a email, 775 Removes the \a email from the email list. If the default email was \a email,
776 then the default email address is assigned to the first email in the 776 then the default email address is assigned to the first email in the
777 email list 777 email list
778*/ 778*/
779 779
780/*! \fn void OContact::clearEmails() 780/*! \fn void OContact::clearEmails()
781 781
782 Clears the email list. 782 Clears the email list.
783 */ 783 */
784 784
785/*! \fn void OContact::insertEmails( const QStringList &emailList ) 785/*! \fn void OContact::insertEmails( const QStringList &emailList )
786 786
787 Appends the \a emailList to the exiting email list 787 Appends the \a emailList to the exiting email list
788 */ 788 */
789 789
790/*! 790/*!
791 Returns a list of email addresses belonging to the contact, including 791 Returns a list of email addresses belonging to the contact, including
792 the default email address. 792 the default email address.
793*/ 793*/
794QStringList OContact::emailList() const 794QStringList OContact::emailList() const
795{ 795{
796 QString emailStr = emails(); 796 QString emailStr = emails();
797 797
798 QStringList r; 798 QStringList r;
799 if ( !emailStr.isEmpty() ) { 799 if ( !emailStr.isEmpty() ) {
800 qDebug(" emailstr "); 800 qDebug(" emailstr ");
801 QStringList l = QStringList::split( emailSeparator(), emailStr ); 801 QStringList l = QStringList::split( emailSeparator(), emailStr );
802 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 802 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
803 r += (*it).simplifyWhiteSpace(); 803 r += (*it).simplifyWhiteSpace();
804 } 804 }
805 805
806 return r; 806 return r;
807} 807}
808 808
809/*! 809/*!
810 \overload 810 \overload
811 811
812 Generates the string for the contact to be filed as from the first, 812 Generates the string for the contact to be filed as from the first,
813 middle and last name of the contact. 813 middle and last name of the contact.
814*/ 814*/
815void OContact::setFileAs() 815void OContact::setFileAs()
816{ 816{
817 QString lastName, firstName, middleName, fileas; 817 QString lastName, firstName, middleName, fileas;
818 818
819 lastName = find( Qtopia::LastName ); 819 lastName = find( Qtopia::LastName );
820 firstName = find( Qtopia::FirstName ); 820 firstName = find( Qtopia::FirstName );
821 middleName = find( Qtopia::MiddleName ); 821 middleName = find( Qtopia::MiddleName );
822 if ( !lastName.isEmpty() && !firstName.isEmpty() 822 if ( !lastName.isEmpty() && !firstName.isEmpty()
823 && !middleName.isEmpty() ) 823 && !middleName.isEmpty() )
824 fileas = lastName + ", " + firstName + " " + middleName; 824 fileas = lastName + ", " + firstName + " " + middleName;
825 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 825 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
826 fileas = lastName + ", " + firstName; 826 fileas = lastName + ", " + firstName;
827 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 827 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
828 !middleName.isEmpty() ) 828 !middleName.isEmpty() )
829 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 829 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
830 + middleName + ( middleName.isEmpty() ? "" : " " ) 830 + middleName + ( middleName.isEmpty() ? "" : " " )
831 + lastName; 831 + lastName;
832 832
833 replace( Qtopia::FileAs, fileas ); 833 replace( Qtopia::FileAs, fileas );
834} 834}
835 835
836/*! 836/*!
837 \internal 837 \internal
838 Appends the contact information to \a buf. 838 Appends the contact information to \a buf.
839*/ 839*/
840void OContact::save( QString &buf ) const 840void OContact::save( QString &buf ) const
841{ 841{
842 static const QStringList SLFIELDS = fields(); 842 static const QStringList SLFIELDS = fields();
843 // I'm expecting "<Contact " in front of this... 843 // I'm expecting "<Contact " in front of this...
844 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 844 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
845 it != mMap.end(); ++it ) { 845 it != mMap.end(); ++it ) {
846 const QString &value = it.data(); 846 const QString &value = it.data();
847 int key = it.key(); 847 int key = it.key();
848 if ( !value.isEmpty() ) { 848 if ( !value.isEmpty() ) {
849 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 849 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
850 continue; 850 continue;
851 851
852 key -= Qtopia::AddressCategory+1; 852 key -= Qtopia::AddressCategory+1;
853 buf += SLFIELDS[key]; 853 buf += SLFIELDS[key];
854 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 854 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
855 } 855 }
856 } 856 }
857 buf += customToXml(); 857 buf += customToXml();
858 if ( categories().count() > 0 ) 858 if ( categories().count() > 0 )
859 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 859 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
860 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 860 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
861 // You need to close this yourself 861 // You need to close this yourself
862} 862}
863 863
864 864
865/*! 865/*!
866 \internal 866 \internal
867 Returns the list of fields belonging to a contact 867 Returns the list of fields belonging to a contact
868 Never change order of this list ! It has to be regarding 868 Never change order of this list ! It has to be regarding
869 enum AddressBookFields !! 869 enum AddressBookFields !!
870*/ 870*/
871QStringList OContact::fields() 871QStringList OContact::fields()
872{ 872{
873 QStringList list; 873 QStringList list;
874 874
875 list.append( "Title" ); // Not Used! 875 list.append( "Title" ); // Not Used!
876 list.append( "FirstName" ); 876 list.append( "FirstName" );
877 list.append( "MiddleName" ); 877 list.append( "MiddleName" );
878 list.append( "LastName" ); 878 list.append( "LastName" );
879 list.append( "Suffix" ); 879 list.append( "Suffix" );
880 list.append( "FileAs" ); 880 list.append( "FileAs" );
881 881
882 list.append( "JobTitle" ); 882 list.append( "JobTitle" );
883 list.append( "Department" ); 883 list.append( "Department" );
884 list.append( "Company" ); 884 list.append( "Company" );
885 list.append( "BusinessPhone" ); 885 list.append( "BusinessPhone" );
886 list.append( "BusinessFax" ); 886 list.append( "BusinessFax" );
887 list.append( "BusinessMobile" ); 887 list.append( "BusinessMobile" );
888 888
889 list.append( "DefaultEmail" ); 889 list.append( "DefaultEmail" );
890 list.append( "Emails" ); 890 list.append( "Emails" );
891 891
892 list.append( "HomePhone" ); 892 list.append( "HomePhone" );
893 list.append( "HomeFax" ); 893 list.append( "HomeFax" );
894 list.append( "HomeMobile" ); 894 list.append( "HomeMobile" );
895 895
896 list.append( "BusinessStreet" ); 896 list.append( "BusinessStreet" );
897 list.append( "BusinessCity" ); 897 list.append( "BusinessCity" );
898 list.append( "BusinessState" ); 898 list.append( "BusinessState" );
899 list.append( "BusinessZip" ); 899 list.append( "BusinessZip" );
900 list.append( "BusinessCountry" ); 900 list.append( "BusinessCountry" );
901 list.append( "BusinessPager" ); 901 list.append( "BusinessPager" );
902 list.append( "BusinessWebPage" ); 902 list.append( "BusinessWebPage" );
903 903
904 list.append( "Office" ); 904 list.append( "Office" );
905 list.append( "Profession" ); 905 list.append( "Profession" );
906 list.append( "Assistant" ); 906 list.append( "Assistant" );
907 list.append( "Manager" ); 907 list.append( "Manager" );
908 908
909 list.append( "HomeStreet" ); 909 list.append( "HomeStreet" );
910 list.append( "HomeCity" ); 910 list.append( "HomeCity" );
911 list.append( "HomeState" ); 911 list.append( "HomeState" );
912 list.append( "HomeZip" ); 912 list.append( "HomeZip" );
913 list.append( "HomeCountry" ); 913 list.append( "HomeCountry" );
914 list.append( "HomeWebPage" ); 914 list.append( "HomeWebPage" );
915 915
916 list.append( "Spouse" ); 916 list.append( "Spouse" );
917 list.append( "Gender" ); 917 list.append( "Gender" );
918 list.append( "Birthday" ); 918 list.append( "Birthday" );
919 list.append( "Anniversary" ); 919 list.append( "Anniversary" );
920 list.append( "Nickname" ); 920 list.append( "Nickname" );
921 list.append( "Children" ); 921 list.append( "Children" );
922 922
923 list.append( "Notes" ); 923 list.append( "Notes" );
924 list.append( "Groups" ); 924 list.append( "Groups" );
925 925
926 return list; 926 return list;
927} 927}
928 928
929 929
930/*! 930/*!
931 Sets the list of email address for contact to those contained in \a str. 931 Sets the list of email address for contact to those contained in \a str.
932 Email address should be separated by ';'s. 932 Email address should be separated by ';'s.
933*/ 933*/
934void OContact::setEmails( const QString &str ) 934void OContact::setEmails( const QString &str )
935{ 935{
936 replace( Qtopia::Emails, str ); 936 replace( Qtopia::Emails, str );
937 if ( str.isEmpty() ) 937 if ( str.isEmpty() )
938 setDefaultEmail( QString::null ); 938 setDefaultEmail( QString::null );
939} 939}
940 940
941/*! 941/*!
942 Sets the list of children for the contact to those contained in \a str. 942 Sets the list of children for the contact to those contained in \a str.
943*/ 943*/
944void OContact::setChildren( const QString &str ) 944void OContact::setChildren( const QString &str )
945{ 945{
946 replace( Qtopia::Children, str ); 946 replace( Qtopia::Children, str );
947} 947}
948 948
949/*! 949/*!
950 Returns TRUE if the contact matches the regular expression \a regexp.
951 Otherwise returns FALSE.
952*/
953bool OContact::match( const QString &regexp ) const
954{
955 return match(QRegExp(regexp));
956}
957
958/*!
959 \overload 950 \overload
960 Returns TRUE if the contact matches the regular expression \a regexp. 951 Returns TRUE if the contact matches the regular expression \a regexp.
961 Otherwise returns FALSE. 952 Otherwise returns FALSE.
962*/ 953*/
963bool OContact::match( const QRegExp &r ) const 954bool OContact::match( const QRegExp &r ) const
964{ 955{
965 bool match; 956 bool match;
966 match = false; 957 match = false;
967 QMap<int, QString>::ConstIterator it; 958 QMap<int, QString>::ConstIterator it;
968 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 959 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
969 if ( (*it).find( r ) > -1 ) { 960 if ( (*it).find( r ) > -1 ) {
970 match = true; 961 match = true;
971 break; 962 break;
972 } 963 }
973 } 964 }
974 return match; 965 return match;
975} 966}
976 967
977 968
978QString OContact::toShortText() const 969QString OContact::toShortText() const
979{ 970{
980 return ( fullName() ); 971 return ( fullName() );
981} 972}
982QString OContact::type() const 973QString OContact::type() const
983{ 974{
984 return QString::fromLatin1( "OContact" ); 975 return QString::fromLatin1( "OContact" );
985} 976}
986 977
987// Definition is missing ! (se) 978// Definition is missing ! (se)
988QMap<QString,QString> OContact::toExtraMap() const 979QMap<QString,QString> OContact::toExtraMap() const
989{ 980{
990 qWarning ("Function not implemented: OContact::toExtraMap()"); 981 qWarning ("Function not implemented: OContact::toExtraMap()");
991 QMap <QString,QString> useless; 982 QMap <QString,QString> useless;
992 return useless; 983 return useless;
993} 984}
994 985
995class QString OContact::recordField( int pos ) const 986class QString OContact::recordField( int pos ) const
996{ 987{
997 QStringList SLFIELDS = fields(); // ?? why this ? (se) 988 QStringList SLFIELDS = fields(); // ?? why this ? (se)
998 return SLFIELDS[pos]; 989 return SLFIELDS[pos];
999} 990}
1000 991
1001// In future releases, we should store birthday and anniversary 992// In future releases, we should store birthday and anniversary
1002// internally as QDate instead of QString ! 993// internally as QDate instead of QString !
1003// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 994// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1004 995
1005/*! \fn void OContact::setBirthday( const QDate& date ) 996/*! \fn void OContact::setBirthday( const QDate& date )
1006 Sets the birthday for the contact to \a date. If date is null 997 Sets the birthday for the contact to \a date. If date is null
1007 the current stored date will be removed. 998 the current stored date will be removed.
1008*/ 999*/
1009void OContact::setBirthday( const QDate &v ) 1000void OContact::setBirthday( const QDate &v )
1010{ 1001{
1011 if ( v.isNull() ){ 1002 if ( v.isNull() ){
1012 qWarning( "Remove Birthday"); 1003 qWarning( "Remove Birthday");
1013 replace( Qtopia::Birthday, QString::null ); 1004 replace( Qtopia::Birthday, QString::null );
1014 return; 1005 return;
1015 } 1006 }
1016 1007
1017 if ( v.isValid() ) 1008 if ( v.isValid() )
1018 replace( Qtopia::Birthday, OConversion::dateToString( v ) ); 1009 replace( Qtopia::Birthday, OConversion::dateToString( v ) );
1019 1010
1020} 1011}
1021 1012
1022 1013
1023/*! \fn void OContact::setAnniversary( const QDate &date ) 1014/*! \fn void OContact::setAnniversary( const QDate &date )
1024 Sets the anniversary of the contact to \a date. If date is 1015 Sets the anniversary of the contact to \a date. If date is
1025 null, the current stored date will be removed. 1016 null, the current stored date will be removed.
1026*/ 1017*/
1027void OContact::setAnniversary( const QDate &v ) 1018void OContact::setAnniversary( const QDate &v )
1028{ 1019{
1029 if ( v.isNull() ){ 1020 if ( v.isNull() ){
1030 qWarning( "Remove Anniversary"); 1021 qWarning( "Remove Anniversary");
1031 replace( Qtopia::Anniversary, QString::null ); 1022 replace( Qtopia::Anniversary, QString::null );
1032 return; 1023 return;
1033 } 1024 }
1034 1025
1035 if ( v.isValid() ) 1026 if ( v.isValid() )
1036 replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); 1027 replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
1037} 1028}
1038 1029
1039/*! \fn QDate OContact::birthday() const 1030/*! \fn QDate OContact::birthday() const
1040 Returns the birthday of the contact. 1031 Returns the birthday of the contact.
1041*/ 1032*/
1042QDate OContact::birthday() const 1033QDate OContact::birthday() const
1043{ 1034{
1044 QString str = find( Qtopia::Birthday ); 1035 QString str = find( Qtopia::Birthday );
1045 qWarning ("Birthday %s", str.latin1() ); 1036 qWarning ("Birthday %s", str.latin1() );
1046 if ( !str.isEmpty() ) 1037 if ( !str.isEmpty() )
1047 return OConversion::dateFromString ( str ); 1038 return OConversion::dateFromString ( str );
1048 else 1039 else
1049 return QDate(); 1040 return QDate();
1050} 1041}
1051 1042
1052 1043
1053/*! \fn QDate OContact::anniversary() const 1044/*! \fn QDate OContact::anniversary() const
1054 Returns the anniversary of the contact. 1045 Returns the anniversary of the contact.
1055*/ 1046*/
1056QDate OContact::anniversary() const 1047QDate OContact::anniversary() const
1057{ 1048{
1058 QDate empty; 1049 QDate empty;
1059 QString str = find( Qtopia::Anniversary ); 1050 QString str = find( Qtopia::Anniversary );
1060 qWarning ("Anniversary %s", str.latin1() ); 1051 qWarning ("Anniversary %s", str.latin1() );
1061 if ( !str.isEmpty() ) 1052 if ( !str.isEmpty() )
1062 return OConversion::dateFromString ( str ); 1053 return OConversion::dateFromString ( str );
1063 else 1054 else
1064 return empty; 1055 return empty;
1065} 1056}
1066 1057
1067 1058
1068void OContact::insertEmail( const QString &v ) 1059void OContact::insertEmail( const QString &v )
1069{ 1060{
1070 //qDebug("insertEmail %s", v.latin1()); 1061 //qDebug("insertEmail %s", v.latin1());
1071 QString e = v.simplifyWhiteSpace(); 1062 QString e = v.simplifyWhiteSpace();
1072 QString def = defaultEmail(); 1063 QString def = defaultEmail();
1073 1064
1074 // if no default, set it as the default email and don't insert 1065 // if no default, set it as the default email and don't insert
1075 if ( def.isEmpty() ) { 1066 if ( def.isEmpty() ) {
1076 setDefaultEmail( e ); // will insert into the list for us 1067 setDefaultEmail( e ); // will insert into the list for us
1077 return; 1068 return;
1078 } 1069 }
1079 1070
1080 // otherwise, insert assuming doesn't already exist 1071 // otherwise, insert assuming doesn't already exist
1081 QString emailsStr = find( Qtopia::Emails ); 1072 QString emailsStr = find( Qtopia::Emails );
1082 if ( emailsStr.contains( e )) 1073 if ( emailsStr.contains( e ))
1083 return; 1074 return;
1084 if ( !emailsStr.isEmpty() ) 1075 if ( !emailsStr.isEmpty() )
1085 emailsStr += emailSeparator(); 1076 emailsStr += emailSeparator();
1086 emailsStr += e; 1077 emailsStr += e;
1087 replace( Qtopia::Emails, emailsStr ); 1078 replace( Qtopia::Emails, emailsStr );
1088} 1079}
1089 1080
1090void OContact::removeEmail( const QString &v ) 1081void OContact::removeEmail( const QString &v )
1091{ 1082{
1092 QString e = v.simplifyWhiteSpace(); 1083 QString e = v.simplifyWhiteSpace();
1093 QString def = defaultEmail(); 1084 QString def = defaultEmail();
1094 QString emailsStr = find( Qtopia::Emails ); 1085 QString emailsStr = find( Qtopia::Emails );
1095 QStringList emails = emailList(); 1086 QStringList emails = emailList();
1096 1087
1097 // otherwise, must first contain it 1088 // otherwise, must first contain it
1098 if ( !emailsStr.contains( e ) ) 1089 if ( !emailsStr.contains( e ) )
1099 return; 1090 return;
1100 1091
1101 // remove it 1092 // remove it
1102 //qDebug(" removing email from list %s", e.latin1()); 1093 //qDebug(" removing email from list %s", e.latin1());
1103 emails.remove( e ); 1094 emails.remove( e );
1104 // reset the string 1095 // reset the string
1105 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 1096 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
1106 replace( Qtopia::Emails, emailsStr ); 1097 replace( Qtopia::Emails, emailsStr );
1107 1098
1108 // if default, then replace the default email with the first one 1099 // if default, then replace the default email with the first one
1109 if ( def == e ) { 1100 if ( def == e ) {
1110 //qDebug("removeEmail is default; setting new default"); 1101 //qDebug("removeEmail is default; setting new default");
1111 if ( !emails.count() ) 1102 if ( !emails.count() )
1112 clearEmails(); 1103 clearEmails();
1113 else // setDefaultEmail will remove e from the list 1104 else // setDefaultEmail will remove e from the list
1114 setDefaultEmail( emails.first() ); 1105 setDefaultEmail( emails.first() );
1115 } 1106 }
1116} 1107}
1117void OContact::clearEmails() 1108void OContact::clearEmails()
1118{ 1109{
1119 mMap.remove( Qtopia::DefaultEmail ); 1110 mMap.remove( Qtopia::DefaultEmail );
1120 mMap.remove( Qtopia::Emails ); 1111 mMap.remove( Qtopia::Emails );
1121} 1112}
1122void OContact::setDefaultEmail( const QString &v ) 1113void OContact::setDefaultEmail( const QString &v )
1123{ 1114{
1124 QString e = v.simplifyWhiteSpace(); 1115 QString e = v.simplifyWhiteSpace();
1125 1116
1126 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1117 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1127 replace( Qtopia::DefaultEmail, e ); 1118 replace( Qtopia::DefaultEmail, e );
1128 1119
1129 if ( !e.isEmpty() ) 1120 if ( !e.isEmpty() )
1130 insertEmail( e ); 1121 insertEmail( e );
1131 1122
1132} 1123}
1133 1124
1134void OContact::insertEmails( const QStringList &v ) 1125void OContact::insertEmails( const QStringList &v )
1135{ 1126{
1136 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1127 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1137 insertEmail( *it ); 1128 insertEmail( *it );
1138} 1129}
1139int OContact::rtti() { 1130int OContact::rtti() {
1140 return OPimResolver::AddressBook; 1131 return OPimResolver::AddressBook;
1141} 1132}
1142void OContact::setUid( int i ) 1133void OContact::setUid( int i )
1143{ 1134{
1144 OPimRecord::setUid(i); 1135 OPimRecord::setUid(i);
1145 replace( Qtopia::AddressUid , QString::number(i)); 1136 replace( Qtopia::AddressUid , QString::number(i));
1146} 1137}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index 50f6176..0e6cbd2 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -1,242 +1,241 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13** See http://www.trolltech.com/gpl/ for GPL licensing information. 13** See http://www.trolltech.com/gpl/ for GPL licensing information.
14** 14**
15** Contact info@trolltech.com if any conditions of this licensing are 15** Contact info@trolltech.com if any conditions of this licensing are
16** not clear to you. 16** not clear to you.
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#ifndef __OCONTACT_H__ 20#ifndef __OCONTACT_H__
21#define __OCONTACT_H__ 21#define __OCONTACT_H__
22 22
23#include <opie/opimrecord.h> 23#include <opie/opimrecord.h>
24#include <qpe/recordfields.h> 24#include <qpe/recordfields.h>
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#if defined(QPC_TEMPLATEDLL) 29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
33#endif 33#endif
34 34
35class ContactPrivate; 35class ContactPrivate;
36 36
37/** 37/**
38 * OContact class represents a specialised PIM Record for contacts. 38 * OContact class represents a specialised PIM Record for contacts.
39 * It does store all kind of persopn related information. 39 * It does store all kind of persopn related information.
40 * 40 *
41 * @short Contact Container 41 * @short Contact Container
42 * @author TT, Stefan Eiler, Holger Freyther 42 * @author TT, Stefan Eiler, Holger Freyther
43 */ 43 */
44class QPC_EXPORT OContact : public OPimRecord 44class QPC_EXPORT OContact : public OPimRecord
45{ 45{
46 friend class DataSet; 46 friend class DataSet;
47public: 47public:
48 OContact(); 48 OContact();
49 OContact( const QMap<int, QString> &fromMap ); 49 OContact( const QMap<int, QString> &fromMap );
50 virtual ~OContact(); 50 virtual ~OContact();
51 51
52 /* 52 /*
53 * do we need to inline them 53 * do we need to inline them
54 * if yes do we need to inline them this way? 54 * if yes do we need to inline them this way?
55 * -zecke 55 * -zecke
56 */ 56 */
57 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 57 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
58 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 58 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
59 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 59 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
60 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 60 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
61 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 61 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
62 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 62 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
63 void setFileAs(); 63 void setFileAs();
64 64
65 // default email address 65 // default email address
66 void setDefaultEmail( const QString &v ); 66 void setDefaultEmail( const QString &v );
67 // inserts email to list and ensure's doesn't already exist 67 // inserts email to list and ensure's doesn't already exist
68 void insertEmail( const QString &v ); 68 void insertEmail( const QString &v );
69 void removeEmail( const QString &v ); 69 void removeEmail( const QString &v );
70 void clearEmails(); 70 void clearEmails();
71 void insertEmails( const QStringList &v ); 71 void insertEmails( const QStringList &v );
72 72
73 // home 73 // home
74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
83 83
84 // business 84 // business
85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
100 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 100 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
101 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 101 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
102 102
103 // personal 103 // personal
104 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 104 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
105 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 105 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
106 void setBirthday( const QDate &v ); 106 void setBirthday( const QDate &v );
107 void setAnniversary( const QDate &v ); 107 void setAnniversary( const QDate &v );
108 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 108 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
109 void setChildren( const QString &v ); 109 void setChildren( const QString &v );
110 110
111 // other 111 // other
112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
113 113
114 bool match( const QString &regexp ) const; 114 virtual bool match( const QRegExp &regexp ) const;
115 bool match( const QRegExp &regexp ) const;
116 115
117// // custom 116// // custom
118// void setCustomField( const QString &key, const QString &v ) 117// void setCustomField( const QString &key, const QString &v )
119// { replace(Custom- + key, v ); } 118// { replace(Custom- + key, v ); }
120 119
121 // name 120 // name
122 QString fullName() const; 121 QString fullName() const;
123 QString title() const { return find( Qtopia::Title ); } 122 QString title() const { return find( Qtopia::Title ); }
124 QString firstName() const { return find( Qtopia::FirstName ); } 123 QString firstName() const { return find( Qtopia::FirstName ); }
125 QString middleName() const { return find( Qtopia::MiddleName ); } 124 QString middleName() const { return find( Qtopia::MiddleName ); }
126 QString lastName() const { return find( Qtopia::LastName ); } 125 QString lastName() const { return find( Qtopia::LastName ); }
127 QString suffix() const { return find( Qtopia::Suffix ); } 126 QString suffix() const { return find( Qtopia::Suffix ); }
128 QString fileAs() const { return find( Qtopia::FileAs ); } 127 QString fileAs() const { return find( Qtopia::FileAs ); }
129 128
130 // email 129 // email
131 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 130 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
132 QStringList emailList() const; 131 QStringList emailList() const;
133 132
134 // home 133 // home
135 /* 134 /*
136 * OPimAddress address(enum Location)const; 135 * OPimAddress address(enum Location)const;
137 * would be some how nicer... 136 * would be some how nicer...
138 * -zecke 137 * -zecke
139 */ 138 */
140 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 139 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
141 QString homeCity() const { return find( Qtopia::HomeCity ); } 140 QString homeCity() const { return find( Qtopia::HomeCity ); }
142 QString homeState() const { return find( Qtopia::HomeState ); } 141 QString homeState() const { return find( Qtopia::HomeState ); }
143 QString homeZip() const { return find( Qtopia::HomeZip ); } 142 QString homeZip() const { return find( Qtopia::HomeZip ); }
144 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 143 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
145 QString homePhone() const { return find( Qtopia::HomePhone ); } 144 QString homePhone() const { return find( Qtopia::HomePhone ); }
146 QString homeFax() const { return find( Qtopia::HomeFax ); } 145 QString homeFax() const { return find( Qtopia::HomeFax ); }
147 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 146 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
148 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 147 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
149 /** Multi line string containing all non-empty address info in the form 148 /** Multi line string containing all non-empty address info in the form
150 * Street 149 * Street
151 * City, State Zip 150 * City, State Zip
152 * Country 151 * Country
153 */ 152 */
154 QString displayHomeAddress() const; 153 QString displayHomeAddress() const;
155 154
156 // business 155 // business
157 QString company() const { return find( Qtopia::Company ); } 156 QString company() const { return find( Qtopia::Company ); }
158 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 157 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
159 QString businessCity() const { return find( Qtopia::BusinessCity ); } 158 QString businessCity() const { return find( Qtopia::BusinessCity ); }
160 QString businessState() const { return find( Qtopia::BusinessState ); } 159 QString businessState() const { return find( Qtopia::BusinessState ); }
161 QString businessZip() const { return find( Qtopia::BusinessZip ); } 160 QString businessZip() const { return find( Qtopia::BusinessZip ); }
162 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 161 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
163 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 162 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
164 QString jobTitle() const { return find( Qtopia::JobTitle ); } 163 QString jobTitle() const { return find( Qtopia::JobTitle ); }
165 QString department() const { return find( Qtopia::Department ); } 164 QString department() const { return find( Qtopia::Department ); }
166 QString office() const { return find( Qtopia::Office ); } 165 QString office() const { return find( Qtopia::Office ); }
167 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 166 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
168 QString businessFax() const { return find( Qtopia::BusinessFax ); } 167 QString businessFax() const { return find( Qtopia::BusinessFax ); }
169 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 168 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
170 QString businessPager() const { return find( Qtopia::BusinessPager ); } 169 QString businessPager() const { return find( Qtopia::BusinessPager ); }
171 QString profession() const { return find( Qtopia::Profession ); } 170 QString profession() const { return find( Qtopia::Profession ); }
172 QString assistant() const { return find( Qtopia::Assistant ); } 171 QString assistant() const { return find( Qtopia::Assistant ); }
173 QString manager() const { return find( Qtopia::Manager ); } 172 QString manager() const { return find( Qtopia::Manager ); }
174 /** Multi line string containing all non-empty address info in the form 173 /** Multi line string containing all non-empty address info in the form
175 * Street 174 * Street
176 * City, State Zip 175 * City, State Zip
177 * Country 176 * Country
178 */ 177 */
179 QString displayBusinessAddress() const; 178 QString displayBusinessAddress() const;
180 179
181 //personal 180 //personal
182 QString spouse() const { return find( Qtopia::Spouse ); } 181 QString spouse() const { return find( Qtopia::Spouse ); }
183 QString gender() const { return find( Qtopia::Gender ); } 182 QString gender() const { return find( Qtopia::Gender ); }
184 QDate birthday() const; 183 QDate birthday() const;
185 QDate anniversary() const; 184 QDate anniversary() const;
186 QString nickname() const { return find( Qtopia::Nickname ); } 185 QString nickname() const { return find( Qtopia::Nickname ); }
187 QString children() const { return find( Qtopia::Children ); } 186 QString children() const { return find( Qtopia::Children ); }
188 QStringList childrenList() const; 187 QStringList childrenList() const;
189 188
190 // other 189 // other
191 QString notes() const { return find( Qtopia::Notes ); } 190 QString notes() const { return find( Qtopia::Notes ); }
192 QString groups() const { return find( Qtopia::Groups ); } 191 QString groups() const { return find( Qtopia::Groups ); }
193 QStringList groupList() const; 192 QStringList groupList() const;
194 193
195// // custom 194// // custom
196// const QString &customField( const QString &key ) 195// const QString &customField( const QString &key )
197// { return find( Custom- + key ); } 196// { return find( Custom- + key ); }
198 197
199 198
200 QString toRichText() const; 199 QString toRichText() const;
201 QMap<int, QString> toMap() const; 200 QMap<int, QString> toMap() const;
202 QString field( int key ) const { return find( key ); } 201 QString field( int key ) const { return find( key ); }
203 202
204 203
205 void setUid( int i ); 204 void setUid( int i );
206 205
207 QString toShortText()const; 206 QString toShortText()const;
208 QString OContact::type()const; 207 QString OContact::type()const;
209 QMap<QString,QString> OContact::toExtraMap() const; 208 QMap<QString,QString> OContact::toExtraMap() const;
210 class QString OContact::recordField(int) const; 209 class QString OContact::recordField(int) const;
211 210
212 // Why private ? (eilers,se) 211 // Why private ? (eilers,se)
213 QString emailSeparator() const { return " "; } 212 QString emailSeparator() const { return " "; }
214 // the emails should be seperated by a comma 213 // the emails should be seperated by a comma
215 void setEmails( const QString &v ); 214 void setEmails( const QString &v );
216 QString emails() const { return find( Qtopia::Emails ); } 215 QString emails() const { return find( Qtopia::Emails ); }
217 static int rtti(); 216 static int rtti();
218 217
219 218
220private: 219private:
221 // The XML-Backend needs some access to the private functions 220 // The XML-Backend needs some access to the private functions
222 friend class OContactAccessBackend_XML; 221 friend class OContactAccessBackend_XML;
223 222
224 void insert( int key, const QString &value ); 223 void insert( int key, const QString &value );
225 void replace( int key, const QString &value ); 224 void replace( int key, const QString &value );
226 QString find( int key ) const; 225 QString find( int key ) const;
227 static QStringList fields(); 226 static QStringList fields();
228 227
229 void save( QString &buf ) const; 228 void save( QString &buf ) const;
230 229
231 QString displayAddress( const QString &street, 230 QString displayAddress( const QString &street,
232 const QString &city, 231 const QString &city,
233 const QString &state, 232 const QString &state,
234 const QString &zip, 233 const QString &zip,
235 const QString &country ) const; 234 const QString &country ) const;
236 235
237 QMap<int, QString> mMap; 236 QMap<int, QString> mMap;
238 ContactPrivate *d; 237 ContactPrivate *d;
239}; 238};
240 239
241 240
242#endif 241#endif
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp
index 3ba8a52..28cf873 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/oevent.cpp
@@ -1,414 +1,445 @@
1#include <qshared.h> 1#include <qshared.h>
2 2
3#include <qpe/palmtopuidgen.h> 3#include <qpe/palmtopuidgen.h>
4#include <qpe/categories.h> 4#include <qpe/categories.h>
5#include <qpe/stringutil.h>
5 6
6#include "orecur.h" 7#include "orecur.h"
7#include "opimresolver.h" 8#include "opimresolver.h"
8#include "opimnotifymanager.h" 9#include "opimnotifymanager.h"
9 10
10#include "oevent.h" 11#include "oevent.h"
11 12
12int OCalendarHelper::week( const QDate& date) { 13int OCalendarHelper::week( const QDate& date) {
13 // Calculates the week this date is in within that 14 // Calculates the week this date is in within that
14 // month. Equals the "row" is is in in the month view 15 // month. Equals the "row" is is in in the month view
15 int week = 1; 16 int week = 1;
16 QDate tmp( date.year(), date.month(), 1 ); 17 QDate tmp( date.year(), date.month(), 1 );
17 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 18 if ( date.dayOfWeek() < tmp.dayOfWeek() )
18 ++week; 19 ++week;
19 20
20 week += ( date.day() - 1 ) / 7; 21 week += ( date.day() - 1 ) / 7;
21 22
22 return week; 23 return week;
23} 24}
24int OCalendarHelper::ocurrence( const QDate& date) { 25int OCalendarHelper::ocurrence( const QDate& date) {
25 // calculates the number of occurrances of this day of the 26 // calculates the number of occurrances of this day of the
26 // week till the given date (e.g 3rd Wednesday of the month) 27 // week till the given date (e.g 3rd Wednesday of the month)
27 return ( date.day() - 1 ) / 7 + 1; 28 return ( date.day() - 1 ) / 7 + 1;
28} 29}
29int OCalendarHelper::dayOfWeek( char day ) { 30int OCalendarHelper::dayOfWeek( char day ) {
30 int dayOfWeek = 1; 31 int dayOfWeek = 1;
31 char i = ORecur::MON; 32 char i = ORecur::MON;
32 while ( !( i & day ) && i <= ORecur::SUN ) { 33 while ( !( i & day ) && i <= ORecur::SUN ) {
33 i <<= 1; 34 i <<= 1;
34 ++dayOfWeek; 35 ++dayOfWeek;
35 } 36 }
36 return dayOfWeek; 37 return dayOfWeek;
37} 38}
38int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { 39int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
39 return ( second.year() - first.year() ) * 12 + 40 return ( second.year() - first.year() ) * 12 +
40 second.month() - first.month(); 41 second.month() - first.month();
41} 42}
42 43
43struct OEvent::Data : public QShared { 44struct OEvent::Data : public QShared {
44 Data() : QShared() { 45 Data() : QShared() {
45 child = 0; 46 child = 0;
46 recur = 0; 47 recur = 0;
47 manager = 0; 48 manager = 0;
48 isAllDay = false; 49 isAllDay = false;
49 parent = 0; 50 parent = 0;
50 } 51 }
51 ~Data() { 52 ~Data() {
52 delete manager; 53 delete manager;
53 delete recur; 54 delete recur;
54 } 55 }
55 QString description; 56 QString description;
56 QString location; 57 QString location;
57 OPimNotifyManager* manager; 58 OPimNotifyManager* manager;
58 ORecur* recur; 59 ORecur* recur;
59 QString note; 60 QString note;
60 QDateTime created; 61 QDateTime created;
61 QDateTime start; 62 QDateTime start;
62 QDateTime end; 63 QDateTime end;
63 bool isAllDay : 1; 64 bool isAllDay : 1;
64 QString timezone; 65 QString timezone;
65 QArray<int>* child; 66 QArray<int>* child;
66 int parent; 67 int parent;
67}; 68};
68 69
69OEvent::OEvent( int uid ) 70OEvent::OEvent( int uid )
70 : OPimRecord( uid ) { 71 : OPimRecord( uid ) {
71 data = new Data; 72 data = new Data;
72} 73}
73OEvent::OEvent( const OEvent& ev) 74OEvent::OEvent( const OEvent& ev)
74 : OPimRecord( ev ), data( ev.data ) 75 : OPimRecord( ev ), data( ev.data )
75{ 76{
76 data->ref(); 77 data->ref();
77} 78}
78OEvent::~OEvent() { 79OEvent::~OEvent() {
79 if ( data->deref() ) { 80 if ( data->deref() ) {
80 delete data; 81 delete data;
81 data = 0; 82 data = 0;
82 } 83 }
83} 84}
84OEvent& OEvent::operator=( const OEvent& ev) { 85OEvent& OEvent::operator=( const OEvent& ev) {
85 if ( this == &ev ) return *this; 86 if ( this == &ev ) return *this;
86 87
87 OPimRecord::operator=( ev ); 88 OPimRecord::operator=( ev );
88 ev.data->ref(); 89 ev.data->ref();
89 deref(); 90 deref();
90 data = ev.data; 91 data = ev.data;
91 92
92 93
93 return *this; 94 return *this;
94} 95}
95QString OEvent::description()const { 96QString OEvent::description()const {
96 return data->description; 97 return data->description;
97} 98}
98void OEvent::setDescription( const QString& description ) { 99void OEvent::setDescription( const QString& description ) {
99 changeOrModify(); 100 changeOrModify();
100 data->description = description; 101 data->description = description;
101} 102}
102void OEvent::setLocation( const QString& loc ) { 103void OEvent::setLocation( const QString& loc ) {
103 changeOrModify(); 104 changeOrModify();
104 data->location = loc; 105 data->location = loc;
105} 106}
106QString OEvent::location()const { 107QString OEvent::location()const {
107 return data->location; 108 return data->location;
108} 109}
109OPimNotifyManager &OEvent::notifiers()const { 110OPimNotifyManager &OEvent::notifiers()const {
110 // I hope we can skip the changeOrModify here 111 // I hope we can skip the changeOrModify here
111 // the notifier should take care of it 112 // the notifier should take care of it
112 // and OPimNotify is shared too 113 // and OPimNotify is shared too
113 if (!data->manager ) 114 if (!data->manager )
114 data->manager = new OPimNotifyManager; 115 data->manager = new OPimNotifyManager;
115 116
116 return *data->manager; 117 return *data->manager;
117} 118}
118bool OEvent::hasNotifiers()const { 119bool OEvent::hasNotifiers()const {
119 if (!data->manager ) 120 if (!data->manager )
120 return false; 121 return false;
121 if (data->manager->reminders().isEmpty() && 122 if (data->manager->reminders().isEmpty() &&
122 data->manager->alarms().isEmpty() ) 123 data->manager->alarms().isEmpty() )
123 return false; 124 return false;
124 125
125 return true; 126 return true;
126} 127}
127ORecur OEvent::recurrence()const { 128ORecur OEvent::recurrence()const {
128 if (!data->recur) 129 if (!data->recur)
129 data->recur = new ORecur; 130 data->recur = new ORecur;
130 131
131 return *data->recur; 132 return *data->recur;
132} 133}
133void OEvent::setRecurrence( const ORecur& rec) { 134void OEvent::setRecurrence( const ORecur& rec) {
134 changeOrModify(); 135 changeOrModify();
135 if (data->recur ) 136 if (data->recur )
136 (*data->recur) = rec; 137 (*data->recur) = rec;
137 else 138 else
138 data->recur = new ORecur( rec ); 139 data->recur = new ORecur( rec );
139} 140}
140bool OEvent::hasRecurrence()const { 141bool OEvent::hasRecurrence()const {
141 if (!data->recur ) return false; 142 if (!data->recur ) return false;
142 return data->recur->doesRecur(); 143 return data->recur->doesRecur();
143} 144}
144QString OEvent::note()const { 145QString OEvent::note()const {
145 return data->note; 146 return data->note;
146} 147}
147void OEvent::setNote( const QString& note ) { 148void OEvent::setNote( const QString& note ) {
148 changeOrModify(); 149 changeOrModify();
149 data->note = note; 150 data->note = note;
150} 151}
151QDateTime OEvent::createdDateTime()const { 152QDateTime OEvent::createdDateTime()const {
152 return data->created; 153 return data->created;
153} 154}
154void OEvent::setCreatedDateTime( const QDateTime& time ) { 155void OEvent::setCreatedDateTime( const QDateTime& time ) {
155 changeOrModify(); 156 changeOrModify();
156 data->created = time; 157 data->created = time;
157} 158}
158QDateTime OEvent::startDateTime()const { 159QDateTime OEvent::startDateTime()const {
159 if ( data->isAllDay ) 160 if ( data->isAllDay )
160 return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); 161 return QDateTime( data->start.date(), QTime(0, 0, 0 ) );
161 return data->start; 162 return data->start;
162} 163}
163QDateTime OEvent::startDateTimeInZone()const { 164QDateTime OEvent::startDateTimeInZone()const {
164 /* if no timezone, or all day event or if the current and this timeZone match... */ 165 /* if no timezone, or all day event or if the current and this timeZone match... */
165 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); 166 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime();
166 167
167 OTimeZone zone(data->timezone ); 168 OTimeZone zone(data->timezone );
168 return zone.toDateTime( data->start, OTimeZone::current() ); 169 return zone.toDateTime( data->start, OTimeZone::current() );
169} 170}
170void OEvent::setStartDateTime( const QDateTime& dt ) { 171void OEvent::setStartDateTime( const QDateTime& dt ) {
171 changeOrModify(); 172 changeOrModify();
172 data->start = dt; 173 data->start = dt;
173} 174}
174QDateTime OEvent::endDateTime()const { 175QDateTime OEvent::endDateTime()const {
175 /* 176 /*
176 * if all Day event the end time needs 177 * if all Day event the end time needs
177 * to be on the same day as the start 178 * to be on the same day as the start
178 */ 179 */
179 if ( data->isAllDay ) 180 if ( data->isAllDay )
180 return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); 181 return QDateTime( data->start.date(), QTime(23, 59, 59 ) );
181 return data->end; 182 return data->end;
182} 183}
183QDateTime OEvent::endDateTimeInZone()const { 184QDateTime OEvent::endDateTimeInZone()const {
184 /* if no timezone, or all day event or if the current and this timeZone match... */ 185 /* if no timezone, or all day event or if the current and this timeZone match... */
185 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); 186 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime();
186 187
187 OTimeZone zone(data->timezone ); 188 OTimeZone zone(data->timezone );
188 return zone.toDateTime( data->end, OTimeZone::current() ); 189 return zone.toDateTime( data->end, OTimeZone::current() );
189} 190}
190void OEvent::setEndDateTime( const QDateTime& dt ) { 191void OEvent::setEndDateTime( const QDateTime& dt ) {
191 changeOrModify(); 192 changeOrModify();
192 data->end = dt; 193 data->end = dt;
193} 194}
194bool OEvent::isMultipleDay()const { 195bool OEvent::isMultipleDay()const {
195 return data->end.date().day() - data->start.date().day(); 196 return data->end.date().day() - data->start.date().day();
196} 197}
197bool OEvent::isAllDay()const { 198bool OEvent::isAllDay()const {
198 return data->isAllDay; 199 return data->isAllDay;
199} 200}
200void OEvent::setAllDay( bool allDay ) { 201void OEvent::setAllDay( bool allDay ) {
201 changeOrModify(); 202 changeOrModify();
202 data->isAllDay = allDay; 203 data->isAllDay = allDay;
203 if (allDay ) data->timezone = "UTC"; 204 if (allDay ) data->timezone = "UTC";
204} 205}
205void OEvent::setTimeZone( const QString& tz ) { 206void OEvent::setTimeZone( const QString& tz ) {
206 changeOrModify(); 207 changeOrModify();
207 data->timezone = tz; 208 data->timezone = tz;
208} 209}
209QString OEvent::timeZone()const { 210QString OEvent::timeZone()const {
210 if (data->isAllDay ) return QString::fromLatin1("UTC"); 211 if (data->isAllDay ) return QString::fromLatin1("UTC");
211 return data->timezone; 212 return data->timezone;
212} 213}
213bool OEvent::match( const QRegExp& )const { 214bool OEvent::match( const QRegExp& re )const {
214 // FIXME 215 if (data->description.contains( re ) )
216 return true;
217 if ( data->note.contains( re ) )
218 return true;
219 if ( data->location.contains( re ) )
220 return true;
221 if ( data->start.toString().contains( re ) )
222 return true;
223 if ( data->end.toString().contains( re ) )
224 return true;
215 return false; 225 return false;
216} 226}
217QString OEvent::toRichText()const { 227QString OEvent::toRichText()const {
218 // FIXME 228 QString text;
219 return "OEvent test"; 229 if ( !description().isEmpty() ) {
230 text += "<b>" + QObject::tr( "Description:") + "</b><br>";
231 text += Qtopia::escapeString(description() ).
232 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
233 }
234 if ( startDateTime().isValid() ) {
235 text += "<b>" + QObject::tr( "Start:") + "</b> ";
236 text += Qtopia::escapeString(startDateTime().toString() ).
237 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
238 }
239 if ( endDateTime().isValid() ) {
240 text += "<b>" + QObject::tr( "End:") + "</b> ";
241 text += Qtopia::escapeString(endDateTime().toString() ).
242 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
243 }
244 if ( !note().isEmpty() ) {
245 text += "<b>" + QObject::tr( "Note:") + "</b><br>";
246 text += note();
247// text += Qtopia::escapeString(note() ).
248// replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
249 }
250 return text;
220} 251}
221QString OEvent::toShortText()const { 252QString OEvent::toShortText()const {
222 return "OEvent shotText"; 253 return description();
223} 254}
224QString OEvent::type()const { 255QString OEvent::type()const {
225 return QString::fromLatin1("OEvent"); 256 return QString::fromLatin1("OEvent");
226} 257}
227QString OEvent::recordField( int /*id */ )const { 258QString OEvent::recordField( int /*id */ )const {
228 return QString::null; 259 return QString::null;
229} 260}
230int OEvent::rtti() { 261int OEvent::rtti() {
231 return OPimResolver::DateBook; 262 return OPimResolver::DateBook;
232} 263}
233bool OEvent::loadFromStream( QDataStream& ) { 264bool OEvent::loadFromStream( QDataStream& ) {
234 return true; 265 return true;
235} 266}
236bool OEvent::saveToStream( QDataStream& )const { 267bool OEvent::saveToStream( QDataStream& )const {
237 return true; 268 return true;
238} 269}
239void OEvent::changeOrModify() { 270void OEvent::changeOrModify() {
240 if ( data->count != 1 ) { 271 if ( data->count != 1 ) {
241 data->deref(); 272 data->deref();
242 Data* d2 = new Data; 273 Data* d2 = new Data;
243 d2->description = data->description; 274 d2->description = data->description;
244 d2->location = data->location; 275 d2->location = data->location;
245 276
246 if (data->manager ) 277 if (data->manager )
247 d2->manager = new OPimNotifyManager( *data->manager ); 278 d2->manager = new OPimNotifyManager( *data->manager );
248 279
249 if ( data->recur ) 280 if ( data->recur )
250 d2->recur = new ORecur( *data->recur ); 281 d2->recur = new ORecur( *data->recur );
251 282
252 d2->note = data->note; 283 d2->note = data->note;
253 d2->created = data->created; 284 d2->created = data->created;
254 d2->start = data->start; 285 d2->start = data->start;
255 d2->end = data->end; 286 d2->end = data->end;
256 d2->isAllDay = data->isAllDay; 287 d2->isAllDay = data->isAllDay;
257 d2->timezone = data->timezone; 288 d2->timezone = data->timezone;
258 d2->parent = data->parent; 289 d2->parent = data->parent;
259 290
260 if ( data->child ) { 291 if ( data->child ) {
261 d2->child = new QArray<int>( *data->child ); 292 d2->child = new QArray<int>( *data->child );
262 d2->child->detach(); 293 d2->child->detach();
263 } 294 }
264 295
265 data = d2; 296 data = d2;
266 } 297 }
267} 298}
268void OEvent::deref() { 299void OEvent::deref() {
269 if ( data->deref() ) { 300 if ( data->deref() ) {
270 delete data; 301 delete data;
271 data = 0; 302 data = 0;
272 } 303 }
273} 304}
274// FIXME 305// FIXME
275QMap<int, QString> OEvent::toMap()const { 306QMap<int, QString> OEvent::toMap()const {
276 return QMap<int, QString>(); 307 return QMap<int, QString>();
277} 308}
278QMap<QString, QString> OEvent::toExtraMap()const { 309QMap<QString, QString> OEvent::toExtraMap()const {
279 return QMap<QString, QString>(); 310 return QMap<QString, QString>();
280} 311}
281int OEvent::parent()const { 312int OEvent::parent()const {
282 return data->parent; 313 return data->parent;
283} 314}
284void OEvent::setParent( int uid ) { 315void OEvent::setParent( int uid ) {
285 changeOrModify(); 316 changeOrModify();
286 data->parent = uid; 317 data->parent = uid;
287} 318}
288QArray<int> OEvent::children() const{ 319QArray<int> OEvent::children() const{
289 if (!data->child) return QArray<int>(); 320 if (!data->child) return QArray<int>();
290 else 321 else
291 return data->child->copy(); 322 return data->child->copy();
292} 323}
293void OEvent::setChildren( const QArray<int>& arr ) { 324void OEvent::setChildren( const QArray<int>& arr ) {
294 changeOrModify(); 325 changeOrModify();
295 if (data->child) delete data->child; 326 if (data->child) delete data->child;
296 327
297 data->child = new QArray<int>( arr ); 328 data->child = new QArray<int>( arr );
298 data->child->detach(); 329 data->child->detach();
299} 330}
300void OEvent::addChild( int uid ) { 331void OEvent::addChild( int uid ) {
301 changeOrModify(); 332 changeOrModify();
302 if (!data->child ) { 333 if (!data->child ) {
303 data->child = new QArray<int>(1); 334 data->child = new QArray<int>(1);
304 (*data->child)[0] = uid; 335 (*data->child)[0] = uid;
305 }else{ 336 }else{
306 int count = data->child->count(); 337 int count = data->child->count();
307 data->child->resize( count + 1 ); 338 data->child->resize( count + 1 );
308 (*data->child)[count] = uid; 339 (*data->child)[count] = uid;
309 } 340 }
310} 341}
311void OEvent::removeChild( int uid ) { 342void OEvent::removeChild( int uid ) {
312 if (!data->child || !data->child->contains( uid ) ) return; 343 if (!data->child || !data->child->contains( uid ) ) return;
313 changeOrModify(); 344 changeOrModify();
314 QArray<int> newAr( data->child->count() - 1 ); 345 QArray<int> newAr( data->child->count() - 1 );
315 int j = 0; 346 int j = 0;
316 uint count = data->child->count(); 347 uint count = data->child->count();
317 for ( uint i = 0; i < count; i++ ) { 348 for ( uint i = 0; i < count; i++ ) {
318 if ( (*data->child)[i] != uid ) { 349 if ( (*data->child)[i] != uid ) {
319 newAr[j] = (*data->child)[i]; 350 newAr[j] = (*data->child)[i];
320 j++; 351 j++;
321 } 352 }
322 } 353 }
323 (*data->child) = newAr; 354 (*data->child) = newAr;
324} 355}
325struct OEffectiveEvent::Data : public QShared { 356struct OEffectiveEvent::Data : public QShared {
326 Data() : QShared() { 357 Data() : QShared() {
327 } 358 }
328 OEvent event; 359 OEvent event;
329 QDate date; 360 QDate date;
330 QTime start, end; 361 QTime start, end;
331 QDate startDate, endDate; 362 QDate startDate, endDate;
332 bool dates : 1; 363 bool dates : 1;
333}; 364};
334 365
335OEffectiveEvent::OEffectiveEvent() { 366OEffectiveEvent::OEffectiveEvent() {
336 data = new Data; 367 data = new Data;
337 data->date = QDate::currentDate(); 368 data->date = QDate::currentDate();
338 data->start = data->end = QTime::currentTime(); 369 data->start = data->end = QTime::currentTime();
339 data->dates = false; 370 data->dates = false;
340} 371}
341OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, 372OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
342 Position pos ) { 373 Position pos ) {
343 data = new Data; 374 data = new Data;
344 data->event = ev; 375 data->event = ev;
345 data->date = startDate; 376 data->date = startDate;
346 if ( pos & Start ) 377 if ( pos & Start )
347 data->start = ev.startDateTime().time(); 378 data->start = ev.startDateTime().time();
348 else 379 else
349 data->start = QTime( 0, 0, 0 ); 380 data->start = QTime( 0, 0, 0 );
350 381
351 if ( pos & End ) 382 if ( pos & End )
352 data->end = ev.endDateTime().time(); 383 data->end = ev.endDateTime().time();
353 else 384 else
354 data->end = QTime( 23, 59, 59 ); 385 data->end = QTime( 23, 59, 59 );
355 386
356 data->dates = false; 387 data->dates = false;
357} 388}
358OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { 389OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) {
359 data = ev.data; 390 data = ev.data;
360 data->ref(); 391 data->ref();
361} 392}
362OEffectiveEvent::~OEffectiveEvent() { 393OEffectiveEvent::~OEffectiveEvent() {
363 if ( data->deref() ) { 394 if ( data->deref() ) {
364 delete data; 395 delete data;
365 data = 0; 396 data = 0;
366 } 397 }
367} 398}
368OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { 399OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) {
369 if ( *this == ev ) return *this; 400 if ( *this == ev ) return *this;
370 401
371 ev.data->ref(); 402 ev.data->ref();
372 deref(); 403 deref();
373 data = ev.data; 404 data = ev.data;
374 405
375 return *this; 406 return *this;
376} 407}
377 408
378void OEffectiveEvent::setStartTime( const QTime& ti) { 409void OEffectiveEvent::setStartTime( const QTime& ti) {
379 changeOrModify(); 410 changeOrModify();
380 data->start = ti; 411 data->start = ti;
381} 412}
382void OEffectiveEvent::setEndTime( const QTime& en) { 413void OEffectiveEvent::setEndTime( const QTime& en) {
383 changeOrModify(); 414 changeOrModify();
384 data->end = en; 415 data->end = en;
385} 416}
386void OEffectiveEvent::setEvent( const OEvent& ev) { 417void OEffectiveEvent::setEvent( const OEvent& ev) {
387 changeOrModify(); 418 changeOrModify();
388 data->event = ev; 419 data->event = ev;
389} 420}
390void OEffectiveEvent::setDate( const QDate& da) { 421void OEffectiveEvent::setDate( const QDate& da) {
391 changeOrModify(); 422 changeOrModify();
392 data->date = da; 423 data->date = da;
393} 424}
394void OEffectiveEvent::setEffectiveDates( const QDate& from, 425void OEffectiveEvent::setEffectiveDates( const QDate& from,
395 const QDate& to ) { 426 const QDate& to ) {
396 if (!from.isValid() ) { 427 if (!from.isValid() ) {
397 data->dates = false; 428 data->dates = false;
398 return; 429 return;
399 } 430 }
400 431
401 data->startDate = from; 432 data->startDate = from;
402 data->endDate = to; 433 data->endDate = to;
403} 434}
404QString OEffectiveEvent::description()const { 435QString OEffectiveEvent::description()const {
405 return data->event.description(); 436 return data->event.description();
406} 437}
407QString OEffectiveEvent::location()const { 438QString OEffectiveEvent::location()const {
408 return data->event.location(); 439 return data->event.location();
409} 440}
410QString OEffectiveEvent::note()const { 441QString OEffectiveEvent::note()const {
411 return data->event.note(); 442 return data->event.note();
412} 443}
413OEvent OEffectiveEvent::event()const { 444OEvent OEffectiveEvent::event()const {
414 return data->event; 445 return data->event;
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h
index 57d32d0..b696d81 100644
--- a/libopie2/opiepim/oevent.h
+++ b/libopie2/opiepim/oevent.h
@@ -1,221 +1,221 @@
1// CONTAINS GPLed code of TT 1// CONTAINS GPLed code of TT
2 2
3#ifndef OPIE_PIM_EVENT_H 3#ifndef OPIE_PIM_EVENT_H
4#define OPIE_PIM_EVENT_H 4#define OPIE_PIM_EVENT_H
5 5
6#include <qstring.h> 6#include <qstring.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8#include <qvaluelist.h> 8#include <qvaluelist.h>
9 9
10#include <qpe/recordfields.h> 10#include <qpe/recordfields.h>
11#include <qpe/palmtopuidgen.h> 11#include <qpe/palmtopuidgen.h>
12 12
13#include "otimezone.h" 13#include "otimezone.h"
14#include "opimrecord.h" 14#include "opimrecord.h"
15 15
16struct OCalendarHelper { 16struct OCalendarHelper {
17 /** calculate the week number of the date */ 17 /** calculate the week number of the date */
18 static int week( const QDate& ); 18 static int week( const QDate& );
19 /** calculate the occurence of week days since the start of the month */ 19 /** calculate the occurence of week days since the start of the month */
20 static int ocurrence( const QDate& ); 20 static int ocurrence( const QDate& );
21 21
22 // returns the dayOfWeek for the *first* day it finds (ignores 22 // returns the dayOfWeek for the *first* day it finds (ignores
23 // any further days!). Returns 1 (Monday) if there isn't any day found 23 // any further days!). Returns 1 (Monday) if there isn't any day found
24 static int dayOfWeek( char day ); 24 static int dayOfWeek( char day );
25 25
26 /** returns the diff of month */ 26 /** returns the diff of month */
27 static int monthDiff( const QDate& first, const QDate& second ); 27 static int monthDiff( const QDate& first, const QDate& second );
28 28
29}; 29};
30 30
31class OPimNotifyManager; 31class OPimNotifyManager;
32class ORecur; 32class ORecur;
33 33
34/** 34/**
35 * This is the container for all Events. It encapsules all 35 * This is the container for all Events. It encapsules all
36 * available information for a single Event 36 * available information for a single Event
37 * @short container for events. 37 * @short container for events.
38 */ 38 */
39class OEvent : public OPimRecord { 39class OEvent : public OPimRecord {
40public: 40public:
41 typedef QValueList<OEvent> ValueList; 41 typedef QValueList<OEvent> ValueList;
42 /** 42 /**
43 * RecordFields contain possible attributes 43 * RecordFields contain possible attributes
44 */ 44 */
45 enum RecordFields { 45 enum RecordFields {
46 Uid = Qtopia::UID_ID, 46 Uid = Qtopia::UID_ID,
47 Category = Qtopia::CATEGORY_ID, 47 Category = Qtopia::CATEGORY_ID,
48 Description, 48 Description,
49 Location, 49 Location,
50 Alarm, 50 Alarm,
51 Reminder, 51 Reminder,
52 Recurrence, 52 Recurrence,
53 Note, 53 Note,
54 Created, 54 Created,
55 StartDate, 55 StartDate,
56 EndDate, 56 EndDate,
57 AllDay, 57 AllDay,
58 TimeZone 58 TimeZone
59 }; 59 };
60 60
61 /** 61 /**
62 * Start with an Empty OEvent. UID == 0 means that it is empty 62 * Start with an Empty OEvent. UID == 0 means that it is empty
63 */ 63 */
64 OEvent(int uid = 0); 64 OEvent(int uid = 0);
65 65
66 /** 66 /**
67 * copy c'tor 67 * copy c'tor
68 */ 68 */
69 OEvent( const OEvent& ); 69 OEvent( const OEvent& );
70 ~OEvent(); 70 ~OEvent();
71 OEvent &operator=( const OEvent& ); 71 OEvent &operator=( const OEvent& );
72 72
73 QString description()const; 73 QString description()const;
74 void setDescription( const QString& description ); 74 void setDescription( const QString& description );
75 75
76 QString location()const; 76 QString location()const;
77 void setLocation( const QString& loc ); 77 void setLocation( const QString& loc );
78 78
79 bool hasNotifiers()const; 79 bool hasNotifiers()const;
80 OPimNotifyManager &notifiers()const; 80 OPimNotifyManager &notifiers()const;
81 81
82 ORecur recurrence()const; 82 ORecur recurrence()const;
83 void setRecurrence( const ORecur& ); 83 void setRecurrence( const ORecur& );
84 bool hasRecurrence()const; 84 bool hasRecurrence()const;
85 85
86 QString note()const; 86 QString note()const;
87 void setNote( const QString& note ); 87 void setNote( const QString& note );
88 88
89 89
90 QDateTime createdDateTime()const; 90 QDateTime createdDateTime()const;
91 void setCreatedDateTime( const QDateTime& dt); 91 void setCreatedDateTime( const QDateTime& dt);
92 92
93 /** set the date to dt. dt is the QDateTime in localtime */ 93 /** set the date to dt. dt is the QDateTime in localtime */
94 void setStartDateTime( const QDateTime& ); 94 void setStartDateTime( const QDateTime& );
95 /** returns the datetime in the local timeZone */ 95 /** returns the datetime in the local timeZone */
96 QDateTime startDateTime()const; 96 QDateTime startDateTime()const;
97 97
98 /** returns the start datetime in the current zone */ 98 /** returns the start datetime in the current zone */
99 QDateTime startDateTimeInZone()const; 99 QDateTime startDateTimeInZone()const;
100 100
101 /** in current timezone */ 101 /** in current timezone */
102 void setEndDateTime( const QDateTime& ); 102 void setEndDateTime( const QDateTime& );
103 /** in current timezone */ 103 /** in current timezone */
104 QDateTime endDateTime()const; 104 QDateTime endDateTime()const;
105 QDateTime endDateTimeInZone()const; 105 QDateTime endDateTimeInZone()const;
106 106
107 bool isMultipleDay()const; 107 bool isMultipleDay()const;
108 bool isAllDay()const; 108 bool isAllDay()const;
109 void setAllDay( bool isAllDay ); 109 void setAllDay( bool isAllDay );
110 110
111 /* pin this event to a timezone! FIXME */ 111 /* pin this event to a timezone! FIXME */
112 void setTimeZone( const QString& timeZone ); 112 void setTimeZone( const QString& timeZone );
113 QString timeZone()const; 113 QString timeZone()const;
114 114
115 115
116 bool match( const QRegExp& )const; 116 virtual bool match( const QRegExp& )const;
117 117
118 /** For exception to recurrence here is a list of children... */ 118 /** For exception to recurrence here is a list of children... */
119 QArray<int> children()const; 119 QArray<int> children()const;
120 void setChildren( const QArray<int>& ); 120 void setChildren( const QArray<int>& );
121 void addChild( int uid ); 121 void addChild( int uid );
122 void removeChild( int uid ); 122 void removeChild( int uid );
123 123
124 /** return the parent OEvent */ 124 /** return the parent OEvent */
125 int parent()const; 125 int parent()const;
126 void setParent( int uid ); 126 void setParent( int uid );
127 127
128 128
129 /* needed reimp */ 129 /* needed reimp */
130 QString toRichText()const; 130 QString toRichText()const;
131 QString toShortText()const; 131 QString toShortText()const;
132 QString type()const; 132 QString type()const;
133 133
134 QMap<int, QString> toMap()const; 134 QMap<int, QString> toMap()const;
135 QMap<QString, QString> toExtraMap()const; 135 QMap<QString, QString> toExtraMap()const;
136 QString recordField(int )const; 136 QString recordField(int )const;
137 137
138 static int rtti(); 138 static int rtti();
139 139
140 bool loadFromStream( QDataStream& ); 140 bool loadFromStream( QDataStream& );
141 bool saveToStream( QDataStream& )const; 141 bool saveToStream( QDataStream& )const;
142 142
143/* bool operator==( const OEvent& ); 143/* bool operator==( const OEvent& );
144 bool operator!=( const OEvent& ); 144 bool operator!=( const OEvent& );
145 bool operator<( const OEvent& ); 145 bool operator<( const OEvent& );
146 bool operator<=( const OEvent& ); 146 bool operator<=( const OEvent& );
147 bool operator>( const OEvent& ); 147 bool operator>( const OEvent& );
148 bool operator>=(const OEvent& ); 148 bool operator>=(const OEvent& );
149*/ 149*/
150private: 150private:
151 inline void changeOrModify(); 151 inline void changeOrModify();
152 void deref(); 152 void deref();
153 struct Data; 153 struct Data;
154 Data* data; 154 Data* data;
155 class Private; 155 class Private;
156 Private* priv; 156 Private* priv;
157 157
158}; 158};
159 159
160/** 160/**
161 * AN Event can span through multiple days. We split up a multiday eve 161 * AN Event can span through multiple days. We split up a multiday eve
162 */ 162 */
163class OEffectiveEvent { 163class OEffectiveEvent {
164public: 164public:
165 typedef QValueList<OEffectiveEvent> ValueList; 165 typedef QValueList<OEffectiveEvent> ValueList;
166 enum Position { MidWay, Start, End, StartEnd }; 166 enum Position { MidWay, Start, End, StartEnd };
167 // If we calculate the effective event of a multi-day event 167 // If we calculate the effective event of a multi-day event
168 // we have to figure out whether we are at the first day, 168 // we have to figure out whether we are at the first day,
169 // at the end, or anywhere else ("middle"). This is important 169 // at the end, or anywhere else ("middle"). This is important
170 // for the start/end times (00:00/23:59) 170 // for the start/end times (00:00/23:59)
171 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- 171 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi-
172 // day event 172 // day event
173 // Start: start time -> 23:59 173 // Start: start time -> 23:59
174 // End: 00:00 -> end time 174 // End: 00:00 -> end time
175 // Start | End == StartEnd: for single-day events (default) 175 // Start | End == StartEnd: for single-day events (default)
176 // here we draw start time -> end time 176 // here we draw start time -> end time
177 OEffectiveEvent(); 177 OEffectiveEvent();
178 OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); 178 OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd );
179 OEffectiveEvent( const OEffectiveEvent& ); 179 OEffectiveEvent( const OEffectiveEvent& );
180 OEffectiveEvent &operator=(const OEffectiveEvent& ); 180 OEffectiveEvent &operator=(const OEffectiveEvent& );
181 ~OEffectiveEvent(); 181 ~OEffectiveEvent();
182 182
183 void setStartTime( const QTime& ); 183 void setStartTime( const QTime& );
184 void setEndTime( const QTime& ); 184 void setEndTime( const QTime& );
185 void setEvent( const OEvent& ); 185 void setEvent( const OEvent& );
186 void setDate( const QDate& ); 186 void setDate( const QDate& );
187 187
188 void setEffectiveDates( const QDate& from, const QDate& to ); 188 void setEffectiveDates( const QDate& from, const QDate& to );
189 189
190 QString description()const; 190 QString description()const;
191 QString location()const; 191 QString location()const;
192 QString note()const; 192 QString note()const;
193 OEvent event()const; 193 OEvent event()const;
194 QTime startTime()const; 194 QTime startTime()const;
195 QTime endTime()const; 195 QTime endTime()const;
196 QDate date()const; 196 QDate date()const;
197 197
198 /* return the length in hours */ 198 /* return the length in hours */
199 int length()const; 199 int length()const;
200 int size()const; 200 int size()const;
201 201
202 QDate startDate()const; 202 QDate startDate()const;
203 QDate endDate()const; 203 QDate endDate()const;
204 204
205 bool operator<( const OEffectiveEvent &e ) const; 205 bool operator<( const OEffectiveEvent &e ) const;
206 bool operator<=( const OEffectiveEvent &e ) const; 206 bool operator<=( const OEffectiveEvent &e ) const;
207 bool operator==( const OEffectiveEvent &e ) const; 207 bool operator==( const OEffectiveEvent &e ) const;
208 bool operator!=( const OEffectiveEvent &e ) const; 208 bool operator!=( const OEffectiveEvent &e ) const;
209 bool operator>( const OEffectiveEvent &e ) const; 209 bool operator>( const OEffectiveEvent &e ) const;
210 bool operator>= ( const OEffectiveEvent &e ) const; 210 bool operator>= ( const OEffectiveEvent &e ) const;
211 211
212private: 212private:
213 void deref(); 213 void deref();
214 inline void changeOrModify(); 214 inline void changeOrModify();
215 class Private; 215 class Private;
216 Private* priv; 216 Private* priv;
217 struct Data; 217 struct Data;
218 Data* data; 218 Data* data;
219 219
220}; 220};
221#endif 221#endif
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index a58d9aa..0e7c73f 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -69,221 +69,221 @@ public:
69 69
70 OTodo( bool completed, int priority, 70 OTodo( bool completed, int priority,
71 const QArray<int>& category, 71 const QArray<int>& category,
72 const QString& summary = QString::null, 72 const QString& summary = QString::null,
73 const QString& description = QString::null, 73 const QString& description = QString::null,
74 ushort progress = 0, 74 ushort progress = 0,
75 bool hasDate = false, QDate date = QDate::currentDate(), 75 bool hasDate = false, QDate date = QDate::currentDate(),
76 int uid = 0 /* empty */ ); 76 int uid = 0 /* empty */ );
77 77
78 /** Copy c'tor 78 /** Copy c'tor
79 * 79 *
80 */ 80 */
81 OTodo(const OTodo & ); 81 OTodo(const OTodo & );
82 82
83 /** 83 /**
84 *destructor 84 *destructor
85 */ 85 */
86 ~OTodo(); 86 ~OTodo();
87 87
88 /** 88 /**
89 * Is this event completed? 89 * Is this event completed?
90 */ 90 */
91 bool isCompleted() const; 91 bool isCompleted() const;
92 92
93 /** 93 /**
94 * Does this Event have a deadline 94 * Does this Event have a deadline
95 */ 95 */
96 bool hasDueDate() const; 96 bool hasDueDate() const;
97 bool hasStartDate()const; 97 bool hasStartDate()const;
98 bool hasCompletedDate()const; 98 bool hasCompletedDate()const;
99 99
100 /** 100 /**
101 * Does this Event has an alarm time ? 101 * Does this Event has an alarm time ?
102 */ 102 */
103 bool hasAlarmDateTime() const; 103 bool hasAlarmDateTime() const;
104 104
105 /** 105 /**
106 * What is the priority? 106 * What is the priority?
107 */ 107 */
108 int priority()const ; 108 int priority()const ;
109 109
110 /** 110 /**
111 * progress as ushort 0, 20, 40, 60, 80 or 100% 111 * progress as ushort 0, 20, 40, 60, 80 or 100%
112 */ 112 */
113 ushort progress() const; 113 ushort progress() const;
114 114
115 /** 115 /**
116 * The due Date 116 * The due Date
117 */ 117 */
118 QDate dueDate()const; 118 QDate dueDate()const;
119 119
120 /** 120 /**
121 * When did it start? 121 * When did it start?
122 */ 122 */
123 QDate startDate()const; 123 QDate startDate()const;
124 124
125 /** 125 /**
126 * When was it completed? 126 * When was it completed?
127 */ 127 */
128 QDate completedDate()const; 128 QDate completedDate()const;
129 129
130 /** 130 /**
131 * does it have a state? 131 * does it have a state?
132 */ 132 */
133 bool hasState()const; 133 bool hasState()const;
134 134
135 /** 135 /**
136 * What is the state of this OTodo? 136 * What is the state of this OTodo?
137 */ 137 */
138 OPimState state()const; 138 OPimState state()const;
139 139
140 /** 140 /**
141 * has recurrence? 141 * has recurrence?
142 */ 142 */
143 bool hasRecurrence()const; 143 bool hasRecurrence()const;
144 144
145 /** 145 /**
146 * the recurrance of this 146 * the recurrance of this
147 */ 147 */
148 ORecur recurrence()const; 148 ORecur recurrence()const;
149 149
150 /** 150 /**
151 * does this OTodo have a maintainer? 151 * does this OTodo have a maintainer?
152 */ 152 */
153 bool hasMaintainer()const; 153 bool hasMaintainer()const;
154 154
155 /** 155 /**
156 * the Maintainer of this OTodo 156 * the Maintainer of this OTodo
157 */ 157 */
158 OPimMaintainer maintainer()const; 158 OPimMaintainer maintainer()const;
159 159
160 /** 160 /**
161 * The description of the todo 161 * The description of the todo
162 */ 162 */
163 QString description()const; 163 QString description()const;
164 164
165 /** 165 /**
166 * A small summary of the todo 166 * A small summary of the todo
167 */ 167 */
168 QString summary() const; 168 QString summary() const;
169 169
170 /** 170 /**
171 * @reimplemented 171 * @reimplemented
172 * Return this todoevent in a RichText formatted QString 172 * Return this todoevent in a RichText formatted QString
173 */ 173 */
174 QString toRichText() const; 174 QString toRichText() const;
175 175
176 bool hasNotifiers()const; 176 bool hasNotifiers()const;
177 /* 177 /*
178 * check if the sharing is still fine!! -zecke 178 * check if the sharing is still fine!! -zecke
179 */ 179 */
180 /** 180 /**
181 * return a reference to our notifiers... 181 * return a reference to our notifiers...
182 */ 182 */
183 OPimNotifyManager &notifiers(); 183 OPimNotifyManager &notifiers();
184 184
185 /** 185 /**
186 * reimplementations 186 * reimplementations
187 */ 187 */
188 QString type()const; 188 QString type()const;
189 QString toShortText()const; 189 QString toShortText()const;
190 QMap<QString, QString> toExtraMap()const; 190 QMap<QString, QString> toExtraMap()const;
191 QString recordField(int id )const; 191 QString recordField(int id )const;
192 192
193 /** 193 /**
194 * toMap puts all data into the map. int relates 194 * toMap puts all data into the map. int relates
195 * to ToDoEvent RecordFields enum 195 * to ToDoEvent RecordFields enum
196 */ 196 */
197 QMap<int, QString> toMap()const; 197 QMap<int, QString> toMap()const;
198 198
199 /** 199 /**
200 * Set if this Todo is completed 200 * Set if this Todo is completed
201 */ 201 */
202 void setCompleted(bool completed ); 202 void setCompleted(bool completed );
203 203
204 /** 204 /**
205 * set if this todo got an end data 205 * set if this todo got an end data
206 */ 206 */
207 void setHasDueDate( bool hasDate ); 207 void setHasDueDate( bool hasDate );
208 // FIXME we do not have these for start, completed 208 // FIXME we do not have these for start, completed
209 // cause we'll use the isNull() of QDate for figuring 209 // cause we'll use the isNull() of QDate for figuring
210 // out if it's has a date... 210 // out if it's has a date...
211 // decide what to do here? -zecke 211 // decide what to do here? -zecke
212 212
213 /** 213 /**
214 * Set the priority of the Todo 214 * Set the priority of the Todo
215 */ 215 */
216 void setPriority(int priority ); 216 void setPriority(int priority );
217 217
218 /** 218 /**
219 * Set the progress. 219 * Set the progress.
220 */ 220 */
221 void setProgress( ushort progress ); 221 void setProgress( ushort progress );
222 222
223 /** 223 /**
224 * set the end date 224 * set the end date
225 */ 225 */
226 void setDueDate( const QDate& date ); 226 void setDueDate( const QDate& date );
227 227
228 /** 228 /**
229 * set the start date 229 * set the start date
230 */ 230 */
231 void setStartDate( const QDate& date ); 231 void setStartDate( const QDate& date );
232 232
233 /** 233 /**
234 * set the completed date 234 * set the completed date
235 */ 235 */
236 void setCompletedDate( const QDate& date ); 236 void setCompletedDate( const QDate& date );
237 237
238 void setRecurrence( const ORecur& ); 238 void setRecurrence( const ORecur& );
239 /** 239 /**
240 * set the alarm time 240 * set the alarm time
241 */ 241 */
242 void setAlarmDateTime ( const QDateTime& alarm ); 242 void setAlarmDateTime ( const QDateTime& alarm );
243 243
244 void setDescription(const QString& ); 244 void setDescription(const QString& );
245 void setSummary(const QString& ); 245 void setSummary(const QString& );
246 246
247 /** 247 /**
248 * set the state of a Todo 248 * set the state of a Todo
249 * @param state State what the todo should take 249 * @param state State what the todo should take
250 */ 250 */
251 void setState( const OPimState& state); 251 void setState( const OPimState& state);
252 252
253 /** 253 /**
254 * set the Maintainer Mode 254 * set the Maintainer Mode
255 */ 255 */
256 void setMaintainer( const OPimMaintainer& ); 256 void setMaintainer( const OPimMaintainer& );
257 257
258 bool isOverdue(); 258 bool isOverdue();
259 259
260 260
261 bool match( const QRegExp &r )const; 261 virtual bool match( const QRegExp &r )const;
262 262
263 bool operator<(const OTodo &toDoEvent )const; 263 bool operator<(const OTodo &toDoEvent )const;
264 bool operator<=(const OTodo &toDoEvent )const; 264 bool operator<=(const OTodo &toDoEvent )const;
265 bool operator!=(const OTodo &toDoEvent )const; 265 bool operator!=(const OTodo &toDoEvent )const;
266 bool operator>(const OTodo &toDoEvent )const; 266 bool operator>(const OTodo &toDoEvent )const;
267 bool operator>=(const OTodo &toDoEvent)const; 267 bool operator>=(const OTodo &toDoEvent)const;
268 bool operator==(const OTodo &toDoEvent )const; 268 bool operator==(const OTodo &toDoEvent )const;
269 OTodo &operator=(const OTodo &toDoEvent ); 269 OTodo &operator=(const OTodo &toDoEvent );
270 270
271 static int rtti(); 271 static int rtti();
272 272
273 private: 273 private:
274 class OTodoPrivate; 274 class OTodoPrivate;
275 struct OTodoData; 275 struct OTodoData;
276 276
277 void deref(); 277 void deref();
278 inline void changeOrModify(); 278 inline void changeOrModify();
279 void copy( OTodoData* src, OTodoData* dest ); 279 void copy( OTodoData* src, OTodoData* dest );
280 OTodoPrivate *d; 280 OTodoPrivate *d;
281 OTodoData *data; 281 OTodoData *data;
282 282
283}; 283};
284inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 284inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
285 return !(*this == toDoEvent); 285 return !(*this == toDoEvent);
286} 286}
287 287
288 288
289#endif 289#endif