source: SMSSender/lib/libdatatypes/src/scontact.cpp @ 71:415b45c71663

3.0
Last change on this file since 71:415b45c71663 was 71:415b45c71663, checked in by Sämy Zehnder <saemy.zehnder@…>, 12 years ago
  • Reorganized all the libraries. libinterfaces and libgateways are removed now and libdatatypes contains now all these files.
File size: 1.5 KB
Line 
1/*
2 * BCContact.cpp
3 *
4 *  Created on: May 17, 2009
5 *      Author: saemy
6 */
7
8#include "scontact.h"
9
10SContact::SContact()
11  : id_(-1)
12  , name_("")
13  , number_(SNumber())
14  , image_(QImage())
15{
16    eventMapper_ = new SContactEventMapper(this);
17}
18
19SContactEventMapper* SContact::eventMapper() const {
20    return eventMapper_;
21}
22IContactEvents* SContact::contactEvents() const {
23    return static_cast<IContactEvents*>(eventMapper());
24}
25
26
27int SContact::id() const{
28    return id_;
29}
30QString SContact::name() const{
31    return name_;
32}
33SNumber SContact::number() const{
34    return number_;
35}
36QStringList SContact::aliases() const{
37    return aliases_;
38}
39QImage SContact::image() const{
40    return image_;
41}
42
43
44void SContact::setId(int id){
45    if (id_ == id) return;
46
47    int oldId = id_;
48    id_ = id;
49
50    emit contactEvents()->idChanged(oldId, id);
51    emit contactEvents()->dataChanged();
52}
53void SContact::setName(const QString& name){
54    SET_IF_DIFFERENT(name_, name.trimmed());
55    emit contactEvents()->dataChanged();
56}
57void SContact::setNumber(const SNumber& number){
58    SET_IF_DIFFERENT(number_, number);
59    emit contactEvents()->dataChanged();
60}
61void SContact::setAliases(const QStringList& aliases){
62    SET_IF_DIFFERENT(aliases_, aliases);
63    aliases_.sort();
64    emit contactEvents()->dataChanged();
65}
66void SContact::setImage(const QImage& image){
67    SET_IF_DIFFERENT(image_, image);
68    image_ = image_.scaledToWidth(50, Qt::SmoothTransformation);
69    emit contactEvents()->dataChanged();
70}
Note: See TracBrowser for help on using the repository browser.