1 | /* |
---|
2 | * BCContact.cpp |
---|
3 | * |
---|
4 | * Created on: May 17, 2009 |
---|
5 | * Author: saemy |
---|
6 | */ |
---|
7 | |
---|
8 | #include "BCContact.h" |
---|
9 | |
---|
10 | BCContact::BCContact() |
---|
11 | : id_(-1) |
---|
12 | , name_("") |
---|
13 | , number_(SNumber()) |
---|
14 | , image_(QImage()) |
---|
15 | { |
---|
16 | eventMapper_ = new ContactEventMapper(this); |
---|
17 | } |
---|
18 | |
---|
19 | ContactEventMapper* BCContact::eventMapper() const { |
---|
20 | return eventMapper_; |
---|
21 | } |
---|
22 | IContactEvents* BCContact::contactEvents() const { |
---|
23 | return static_cast<IContactEvents*>(eventMapper()); |
---|
24 | } |
---|
25 | |
---|
26 | |
---|
27 | int BCContact::id() const{ |
---|
28 | return id_; |
---|
29 | } |
---|
30 | QString BCContact::name() const{ |
---|
31 | return name_; |
---|
32 | } |
---|
33 | SNumber BCContact::number() const{ |
---|
34 | return number_; |
---|
35 | } |
---|
36 | QStringList BCContact::aliases() const{ |
---|
37 | return aliases_; |
---|
38 | } |
---|
39 | QImage BCContact::image() const{ |
---|
40 | return image_; |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | void BCContact::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 | } |
---|
53 | void BCContact::setName(const QString& name){ |
---|
54 | SET_IF_DIFFERENT(name_, name.trimmed()); |
---|
55 | emit contactEvents()->dataChanged(); |
---|
56 | } |
---|
57 | void BCContact::setNumber(const SNumber& number){ |
---|
58 | SET_IF_DIFFERENT(number_, number); |
---|
59 | emit contactEvents()->dataChanged(); |
---|
60 | } |
---|
61 | void BCContact::setAliases(const QStringList& aliases){ |
---|
62 | SET_IF_DIFFERENT(aliases_, aliases); |
---|
63 | aliases_.sort(); |
---|
64 | emit contactEvents()->dataChanged(); |
---|
65 | } |
---|
66 | void BCContact::setImage(const QImage& image){ |
---|
67 | SET_IF_DIFFERENT(image_, image); |
---|
68 | image_ = image_.scaledToWidth(50, Qt::SmoothTransformation); |
---|
69 | emit contactEvents()->dataChanged(); |
---|
70 | } |
---|