author | zautrix <zautrix> | 2004-10-29 23:13:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 23:13:22 (UTC) |
commit | da80b510e4643fa3f78cf3f97af108e87097583d (patch) (unidiff) | |
tree | 01c328362a6bf1898853ba26fd5d48eb5cff1e27 /kabc/addressee.cpp | |
parent | aafa695508796e86e9f267633ea5e6965d876031 (diff) | |
download | kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.zip kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.gz kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.bz2 |
added better category handling to kapi
-rw-r--r-- | kabc/addressee.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index eec0f1f..3ce733d 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1903,192 +1903,196 @@ QString Addressee::custom( const QString &app, const QString &name ) const | |||
1903 | 1903 | ||
1904 | QStringList::ConstIterator it; | 1904 | QStringList::ConstIterator it; |
1905 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1905 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1906 | if ( (*it).startsWith( qualifiedName ) ) { | 1906 | if ( (*it).startsWith( qualifiedName ) ) { |
1907 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1907 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1908 | break; | 1908 | break; |
1909 | } | 1909 | } |
1910 | } | 1910 | } |
1911 | 1911 | ||
1912 | return value; | 1912 | return value; |
1913 | } | 1913 | } |
1914 | 1914 | ||
1915 | void Addressee::setCustoms( const QStringList &l ) | 1915 | void Addressee::setCustoms( const QStringList &l ) |
1916 | { | 1916 | { |
1917 | detach(); | 1917 | detach(); |
1918 | mData->empty = false; | 1918 | mData->empty = false; |
1919 | 1919 | ||
1920 | mData->custom = l; | 1920 | mData->custom = l; |
1921 | } | 1921 | } |
1922 | 1922 | ||
1923 | QStringList Addressee::customs() const | 1923 | QStringList Addressee::customs() const |
1924 | { | 1924 | { |
1925 | return mData->custom; | 1925 | return mData->custom; |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1928 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1929 | QString &email) | 1929 | QString &email) |
1930 | { | 1930 | { |
1931 | int startPos, endPos, len; | 1931 | int startPos, endPos, len; |
1932 | QString partA, partB, result; | 1932 | QString partA, partB, result; |
1933 | char endCh = '>'; | 1933 | char endCh = '>'; |
1934 | 1934 | ||
1935 | startPos = rawEmail.find('<'); | 1935 | startPos = rawEmail.find('<'); |
1936 | if (startPos < 0) | 1936 | if (startPos < 0) |
1937 | { | 1937 | { |
1938 | startPos = rawEmail.find('('); | 1938 | startPos = rawEmail.find('('); |
1939 | endCh = ')'; | 1939 | endCh = ')'; |
1940 | } | 1940 | } |
1941 | if (startPos < 0) | 1941 | if (startPos < 0) |
1942 | { | 1942 | { |
1943 | // We couldn't find any separators, so we assume the whole string | 1943 | // We couldn't find any separators, so we assume the whole string |
1944 | // is the email address | 1944 | // is the email address |
1945 | email = rawEmail; | 1945 | email = rawEmail; |
1946 | fullName = ""; | 1946 | fullName = ""; |
1947 | } | 1947 | } |
1948 | else | 1948 | else |
1949 | { | 1949 | { |
1950 | // We have a start position, try to find an end | 1950 | // We have a start position, try to find an end |
1951 | endPos = rawEmail.find(endCh, startPos+1); | 1951 | endPos = rawEmail.find(endCh, startPos+1); |
1952 | 1952 | ||
1953 | if (endPos < 0) | 1953 | if (endPos < 0) |
1954 | { | 1954 | { |
1955 | // We couldn't find the end of the email address. We can only | 1955 | // We couldn't find the end of the email address. We can only |
1956 | // assume the entire string is the email address. | 1956 | // assume the entire string is the email address. |
1957 | email = rawEmail; | 1957 | email = rawEmail; |
1958 | fullName = ""; | 1958 | fullName = ""; |
1959 | } | 1959 | } |
1960 | else | 1960 | else |
1961 | { | 1961 | { |
1962 | // We have a start and end to the email address | 1962 | // We have a start and end to the email address |
1963 | 1963 | ||
1964 | // Grab the name part | 1964 | // Grab the name part |
1965 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1965 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1966 | 1966 | ||
1967 | // grab the email part | 1967 | // grab the email part |
1968 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1968 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1969 | 1969 | ||
1970 | // Check that we do not have any extra characters on the end of the | 1970 | // Check that we do not have any extra characters on the end of the |
1971 | // strings | 1971 | // strings |
1972 | len = fullName.length(); | 1972 | len = fullName.length(); |
1973 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1973 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1974 | fullName = fullName.mid(1, len-2); | 1974 | fullName = fullName.mid(1, len-2); |
1975 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1975 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1976 | fullName = fullName.mid(1, len-2); | 1976 | fullName = fullName.mid(1, len-2); |
1977 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1977 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1978 | fullName = fullName.mid(1, len-2); | 1978 | fullName = fullName.mid(1, len-2); |
1979 | } | 1979 | } |
1980 | } | 1980 | } |
1981 | } | 1981 | } |
1982 | 1982 | ||
1983 | void Addressee::setResource( Resource *resource ) | 1983 | void Addressee::setResource( Resource *resource ) |
1984 | { | 1984 | { |
1985 | detach(); | 1985 | detach(); |
1986 | mData->resource = resource; | 1986 | mData->resource = resource; |
1987 | } | 1987 | } |
1988 | 1988 | ||
1989 | Resource *Addressee::resource() const | 1989 | Resource *Addressee::resource() const |
1990 | { | 1990 | { |
1991 | return mData->resource; | 1991 | return mData->resource; |
1992 | } | 1992 | } |
1993 | 1993 | ||
1994 | //US | 1994 | //US |
1995 | QString Addressee::resourceLabel() | 1995 | QString Addressee::resourceLabel() |
1996 | { | 1996 | { |
1997 | return i18n("Resource"); | 1997 | return i18n("Resource"); |
1998 | } | 1998 | } |
1999 | QString Addressee::categoryLabel() | ||
2000 | { | ||
2001 | return i18n("Category"); | ||
2002 | } | ||
1999 | 2003 | ||
2000 | void Addressee::setChanged( bool value ) | 2004 | void Addressee::setChanged( bool value ) |
2001 | { | 2005 | { |
2002 | detach(); | 2006 | detach(); |
2003 | mData->changed = value; | 2007 | mData->changed = value; |
2004 | } | 2008 | } |
2005 | 2009 | ||
2006 | bool Addressee::changed() const | 2010 | bool Addressee::changed() const |
2007 | { | 2011 | { |
2008 | return mData->changed; | 2012 | return mData->changed; |
2009 | } | 2013 | } |
2010 | 2014 | ||
2011 | void Addressee::setTagged( bool value ) | 2015 | void Addressee::setTagged( bool value ) |
2012 | { | 2016 | { |
2013 | detach(); | 2017 | detach(); |
2014 | mData->tagged = value; | 2018 | mData->tagged = value; |
2015 | } | 2019 | } |
2016 | 2020 | ||
2017 | bool Addressee::tagged() const | 2021 | bool Addressee::tagged() const |
2018 | { | 2022 | { |
2019 | return mData->tagged; | 2023 | return mData->tagged; |
2020 | } | 2024 | } |
2021 | 2025 | ||
2022 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 2026 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
2023 | { | 2027 | { |
2024 | if (!a.mData) return s; | 2028 | if (!a.mData) return s; |
2025 | 2029 | ||
2026 | s << a.uid(); | 2030 | s << a.uid(); |
2027 | 2031 | ||
2028 | s << a.mData->name; | 2032 | s << a.mData->name; |
2029 | s << a.mData->formattedName; | 2033 | s << a.mData->formattedName; |
2030 | s << a.mData->familyName; | 2034 | s << a.mData->familyName; |
2031 | s << a.mData->givenName; | 2035 | s << a.mData->givenName; |
2032 | s << a.mData->additionalName; | 2036 | s << a.mData->additionalName; |
2033 | s << a.mData->prefix; | 2037 | s << a.mData->prefix; |
2034 | s << a.mData->suffix; | 2038 | s << a.mData->suffix; |
2035 | s << a.mData->nickName; | 2039 | s << a.mData->nickName; |
2036 | s << a.mData->birthday; | 2040 | s << a.mData->birthday; |
2037 | s << a.mData->mailer; | 2041 | s << a.mData->mailer; |
2038 | s << a.mData->timeZone; | 2042 | s << a.mData->timeZone; |
2039 | s << a.mData->geo; | 2043 | s << a.mData->geo; |
2040 | s << a.mData->title; | 2044 | s << a.mData->title; |
2041 | s << a.mData->role; | 2045 | s << a.mData->role; |
2042 | s << a.mData->organization; | 2046 | s << a.mData->organization; |
2043 | s << a.mData->note; | 2047 | s << a.mData->note; |
2044 | s << a.mData->productId; | 2048 | s << a.mData->productId; |
2045 | s << a.mData->revision; | 2049 | s << a.mData->revision; |
2046 | s << a.mData->sortString; | 2050 | s << a.mData->sortString; |
2047 | s << a.mData->url; | 2051 | s << a.mData->url; |
2048 | s << a.mData->secrecy; | 2052 | s << a.mData->secrecy; |
2049 | s << a.mData->logo; | 2053 | s << a.mData->logo; |
2050 | s << a.mData->photo; | 2054 | s << a.mData->photo; |
2051 | s << a.mData->sound; | 2055 | s << a.mData->sound; |
2052 | s << a.mData->agent; | 2056 | s << a.mData->agent; |
2053 | s << a.mData->phoneNumbers; | 2057 | s << a.mData->phoneNumbers; |
2054 | s << a.mData->addresses; | 2058 | s << a.mData->addresses; |
2055 | s << a.mData->emails; | 2059 | s << a.mData->emails; |
2056 | s << a.mData->categories; | 2060 | s << a.mData->categories; |
2057 | s << a.mData->custom; | 2061 | s << a.mData->custom; |
2058 | s << a.mData->keys; | 2062 | s << a.mData->keys; |
2059 | return s; | 2063 | return s; |
2060 | } | 2064 | } |
2061 | 2065 | ||
2062 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 2066 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
2063 | { | 2067 | { |
2064 | if (!a.mData) return s; | 2068 | if (!a.mData) return s; |
2065 | 2069 | ||
2066 | s >> a.mData->uid; | 2070 | s >> a.mData->uid; |
2067 | 2071 | ||
2068 | s >> a.mData->name; | 2072 | s >> a.mData->name; |
2069 | s >> a.mData->formattedName; | 2073 | s >> a.mData->formattedName; |
2070 | s >> a.mData->familyName; | 2074 | s >> a.mData->familyName; |
2071 | s >> a.mData->givenName; | 2075 | s >> a.mData->givenName; |
2072 | s >> a.mData->additionalName; | 2076 | s >> a.mData->additionalName; |
2073 | s >> a.mData->prefix; | 2077 | s >> a.mData->prefix; |
2074 | s >> a.mData->suffix; | 2078 | s >> a.mData->suffix; |
2075 | s >> a.mData->nickName; | 2079 | s >> a.mData->nickName; |
2076 | s >> a.mData->birthday; | 2080 | s >> a.mData->birthday; |
2077 | s >> a.mData->mailer; | 2081 | s >> a.mData->mailer; |
2078 | s >> a.mData->timeZone; | 2082 | s >> a.mData->timeZone; |
2079 | s >> a.mData->geo; | 2083 | s >> a.mData->geo; |
2080 | s >> a.mData->title; | 2084 | s >> a.mData->title; |
2081 | s >> a.mData->role; | 2085 | s >> a.mData->role; |
2082 | s >> a.mData->organization; | 2086 | s >> a.mData->organization; |
2083 | s >> a.mData->note; | 2087 | s >> a.mData->note; |
2084 | s >> a.mData->productId; | 2088 | s >> a.mData->productId; |
2085 | s >> a.mData->revision; | 2089 | s >> a.mData->revision; |
2086 | s >> a.mData->sortString; | 2090 | s >> a.mData->sortString; |
2087 | s >> a.mData->url; | 2091 | s >> a.mData->url; |
2088 | s >> a.mData->secrecy; | 2092 | s >> a.mData->secrecy; |
2089 | s >> a.mData->logo; | 2093 | s >> a.mData->logo; |
2090 | s >> a.mData->photo; | 2094 | s >> a.mData->photo; |
2091 | s >> a.mData->sound; | 2095 | s >> a.mData->sound; |
2092 | s >> a.mData->agent; | 2096 | s >> a.mData->agent; |
2093 | s >> a.mData->phoneNumbers; | 2097 | s >> a.mData->phoneNumbers; |
2094 | s >> a.mData->addresses; | 2098 | s >> a.mData->addresses; |