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