Changeset View
Changeset View
Standalone View
Standalone View
src/addressee.cpp
Show All 14 Lines | 1 | /* | |||
---|---|---|---|---|---|
15 | Library General Public License for more details. | 15 | Library General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License | ||
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to | ||
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
20 | Boston, MA 02110-1301, USA. | 20 | Boston, MA 02110-1301, USA. | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #include <QDate> | ||||
23 | #include <QList> | 24 | #include <QList> | ||
24 | #include <QRegExp> | 25 | #include <QRegExp> | ||
25 | #include <QSharedData> | 26 | #include <QSharedData> | ||
26 | #include <QUuid> | 27 | #include <QUuid> | ||
27 | 28 | | |||
28 | #include "kcontacts_debug.h" | 29 | #include "kcontacts_debug.h" | ||
29 | #include <klocalizedstring.h> | 30 | #include <klocalizedstring.h> | ||
30 | 31 | | |||
▲ Show 20 Lines • Show All 2111 Lines • ▼ Show 20 Line(s) | 2141 | { | |||
2142 | d->mRelationShips = c; | 2143 | d->mRelationShips = c; | ||
2143 | } | 2144 | } | ||
2144 | 2145 | | |||
2145 | Related::List Addressee::relationShips() const | 2146 | Related::List Addressee::relationShips() const | ||
2146 | { | 2147 | { | ||
2147 | return d->mRelationShips; | 2148 | return d->mRelationShips; | ||
2148 | } | 2149 | } | ||
2149 | 2150 | | |||
2151 | static const auto VENDOR_ID = QStringLiteral("KADDRESSBOOK"); | ||||
2152 | static const auto X_ANNIVERSARY = QStringLiteral("X-Anniversary"); | ||||
2153 | static const auto X_ASSISTANTSNAME = QStringLiteral("X-AssistantsName"); | ||||
2154 | static const auto BLOGFEED = QStringLiteral("BlogFeed"); | ||||
2155 | static const auto X_MANAGERSNAME = QStringLiteral("X-ManagersName"); | ||||
2156 | static const auto X_OFFICE = QStringLiteral("X-Office"); | ||||
2157 | static const auto X_PROFESSION = QStringLiteral("X-Profession"); | ||||
2158 | static const auto X_SPOUSESNAME = QStringLiteral("X-SpousesName"); | ||||
2159 | | ||||
2160 | QDate Addressee::anniversary() const | ||||
2161 | { | ||||
2162 | return QDate::fromString(custom(VENDOR_ID, X_ANNIVERSARY), Qt::ISODate); | ||||
2163 | } | ||||
2164 | | ||||
2165 | void Addressee::setAnniversary(const QDate &anniversary) | ||||
2166 | { | ||||
2167 | if (anniversary.isValid()) { | ||||
2168 | insertCustom(VENDOR_ID, X_ANNIVERSARY, anniversary.toString(Qt::ISODate)); | ||||
2169 | } else { | ||||
2170 | removeCustom(VENDOR_ID, X_ANNIVERSARY); | ||||
2171 | } | ||||
2172 | } | ||||
2173 | | ||||
2174 | QString Addressee::assistantsName() const | ||||
2175 | { | ||||
2176 | return custom(VENDOR_ID, X_ASSISTANTSNAME); | ||||
2177 | } | ||||
2178 | | ||||
2179 | void Addressee::setAssistantsName(const QString &assistantsName) | ||||
2180 | { | ||||
2181 | if (!assistantsName.isEmpty()) { | ||||
2182 | insertCustom(VENDOR_ID, X_ASSISTANTSNAME, assistantsName); | ||||
2183 | } else { | ||||
2184 | removeCustom(VENDOR_ID, X_ASSISTANTSNAME); | ||||
2185 | } | ||||
2186 | } | ||||
2187 | | ||||
2188 | QString Addressee::blogFeed() const | ||||
2189 | { | ||||
2190 | return custom(VENDOR_ID, BLOGFEED); | ||||
2191 | } | ||||
2192 | | ||||
2193 | void Addressee::setBlogFeed(const QString &blogFeed) | ||||
2194 | { | ||||
2195 | if (!blogFeed.isEmpty()) { | ||||
2196 | insertCustom(VENDOR_ID, BLOGFEED, blogFeed); | ||||
2197 | } else { | ||||
2198 | removeCustom(VENDOR_ID, BLOGFEED); | ||||
2199 | } | ||||
2200 | } | ||||
2201 | | ||||
2202 | QString Addressee::managersName() const | ||||
2203 | { | ||||
2204 | return custom(VENDOR_ID, X_MANAGERSNAME); | ||||
2205 | } | ||||
2206 | | ||||
2207 | void Addressee::setManagersName(const QString &managersName) | ||||
2208 | { | ||||
2209 | if (!managersName.isEmpty()) { | ||||
2210 | insertCustom(VENDOR_ID, X_MANAGERSNAME, managersName); | ||||
2211 | } else { | ||||
2212 | removeCustom(VENDOR_ID, X_MANAGERSNAME); | ||||
2213 | } | ||||
2214 | } | ||||
2215 | | ||||
2216 | QString Addressee::office() const | ||||
2217 | { | ||||
2218 | return custom(VENDOR_ID, X_OFFICE); | ||||
2219 | } | ||||
2220 | | ||||
2221 | void Addressee::setOffice(const QString &office) | ||||
2222 | { | ||||
2223 | if (!office.isEmpty()) { | ||||
2224 | insertCustom(VENDOR_ID, X_OFFICE, office); | ||||
2225 | } else { | ||||
2226 | removeCustom(VENDOR_ID, X_OFFICE); | ||||
2227 | } | ||||
2228 | } | ||||
2229 | | ||||
2230 | QString Addressee::profession() const | ||||
2231 | { | ||||
2232 | return custom(VENDOR_ID, X_PROFESSION); | ||||
2233 | } | ||||
2234 | | ||||
2235 | void Addressee::setProfession(const QString &profession) | ||||
2236 | { | ||||
2237 | if (!profession.isEmpty()) { | ||||
2238 | insertCustom(VENDOR_ID, X_PROFESSION, profession); | ||||
2239 | } else { | ||||
2240 | removeCustom(VENDOR_ID, X_PROFESSION); | ||||
2241 | } | ||||
2242 | } | ||||
2243 | | ||||
2244 | QString Addressee::spousesName() const | ||||
2245 | { | ||||
2246 | return custom(VENDOR_ID, X_SPOUSESNAME); | ||||
2247 | } | ||||
2248 | | ||||
2249 | void Addressee::setSpousesName(const QString &spousesName) | ||||
2250 | { | ||||
2251 | if (!spousesName.isEmpty()) { | ||||
2252 | insertCustom(VENDOR_ID, X_SPOUSESNAME, spousesName); | ||||
2253 | } else { | ||||
2254 | removeCustom(VENDOR_ID, X_SPOUSESNAME); | ||||
2255 | } | ||||
2256 | } | ||||
2257 | | ||||
2150 | void Addressee::insertCustom(const QString &app, const QString &name, const QString &value) | 2258 | void Addressee::insertCustom(const QString &app, const QString &name, const QString &value) | ||
2151 | { | 2259 | { | ||
2152 | if (value.isEmpty() || name.isEmpty() || app.isEmpty()) { | 2260 | if (value.isEmpty() || name.isEmpty() || app.isEmpty()) { | ||
2153 | return; | 2261 | return; | ||
2154 | } | 2262 | } | ||
2155 | 2263 | | |||
2156 | d->mEmpty = false; | 2264 | d->mEmpty = false; | ||
2157 | 2265 | | |||
▲ Show 20 Lines • Show All 398 Lines • Show Last 20 Lines |