Changed the code naming style according to agreed guideline
[situare] / src / ui / infotab.cpp
1 #include "infotab.h"
2
3 InfoTab::InfoTab(QWidget *parent)
4     : QWidget(parent, Qt::FramelessWindowHint)
5 {
6     m_layout = new QGridLayout(this);
7     m_userPicture = new QLabel;
8     m_userNameLabel = new QLabel;
9     m_messageLabel = new QLabel;
10     m_addressLabel = new QLabel;
11     m_timeLabel = new QLabel;
12     QLabel *m_clockLabel = new QLabel;
13     QLabel *m_envelopeLabel = new QLabel;
14     QLabel *m_compassLabel = new QLabel;
15     QToolButton *sendLocationButton = new QToolButton;
16     QToolButton *updateStatusMessageButton = new QToolButton;
17
18     sendLocationButton->setIcon(QIcon(QPixmap(":/resources/reload_icon.png")));
19     updateStatusMessageButton->setIcon(QIcon(QPixmap(":/resources/sendPosition_icon.png")));
20
21     m_clockLabel->setPixmap(QPixmap(":/resources/clock_small.png"));
22     m_envelopeLabel->setPixmap(QPixmap(":/resources/list_small.png"));
23     m_compassLabel->setPixmap(QPixmap(":/resources/compas_small.png"));
24     m_layout->addWidget(m_userPicture,0,0,4,1);
25     m_layout->addWidget(m_userNameLabel,0,2,1,2);
26     m_layout->addWidget(m_clockLabel,1,1,1,1);
27     m_layout->addWidget(m_envelopeLabel,2,1,1,1);
28     m_layout->addWidget(m_compassLabel,3,1,1,1);
29     m_layout->addWidget(m_timeLabel,1,2,1,1);
30     m_layout->addWidget(m_messageLabel,2,2,1,1);
31     m_layout->addWidget(m_addressLabel,3,2,1,1);
32     m_layout->addWidget(sendLocationButton,0,3,2,1);
33     m_layout->addWidget(updateStatusMessageButton,1,3,2,1);
34
35 }
36
37 InfoTab::~InfoTab()
38 {
39     if (m_userPicture)
40         delete m_userPicture;
41     if (m_userNameLabel)
42         delete m_userNameLabel;
43     if (m_messageLabel)
44         delete m_messageLabel;
45     if (m_addressLabel)
46         delete m_addressLabel;
47     if (m_timeLabel)
48         delete m_timeLabel;
49     if (m_layout)
50         delete m_layout;
51     m_userPicture=NULL;
52     m_userNameLabel=NULL;
53     m_messageLabel=NULL;
54     m_addressLabel=NULL;
55     m_timeLabel=NULL;
56     m_layout=NULL;
57 }
58
59 void InfoTab::paintEvent(QPaintEvent *aPaintEvent)
60 {
61     //Look and feel settings
62     QPalette qpalette;
63     QColor myColor(Qt::black);
64     myColor.setAlpha(50);
65     qpalette.setColor(QPalette::Background,myColor);
66     setPalette(qpalette);
67     int roundness(6);
68
69     QRect widgetRect = this->rect();
70     QPainter painter(this);
71     painter.save();
72
73     painter.setRenderHint(QPainter::Antialiasing);
74     QPainterPath roundedRect;
75     roundedRect.addRoundedRect(1,1,widgetRect.width() - 2, widgetRect.height()-2,roundness,roundness);
76
77     painter.setClipPath(roundedRect);
78     QRegion maskRegion = painter.clipRegion();
79
80     setMask(maskRegion);
81
82     painter.fillPath(roundedRect,QBrush(myColor));
83     painter.restore();
84 }
85
86 void InfoTab::setAvatar(const QPixmap &avat)
87 {
88     m_avatar = avat;
89     m_userPicture->setPixmap(m_avatar);
90 }
91
92 void InfoTab::setUserName(const QString &usernam)
93 {
94     if(m_userName == usernam)
95       return;
96     m_userName = usernam;
97     m_userNameLabel->setText(m_userName);
98 }
99
100 void InfoTab::setMessageText(const QString &text)
101 {
102     if(m_messageText == text)
103       return;
104     m_messageText = text;
105     m_messageLabel->setText(m_messageText);
106 }
107
108 void InfoTab::setAddress(const QString &addr)
109 {
110     if(m_address == addr)
111       return;
112     m_address = addr;
113     m_addressLabel->setText(m_address);
114 }
115
116 void InfoTab::setTime(const QString &tim)
117 {
118     if(m_time == tim)
119       return;
120     m_time = tim;
121     m_timeLabel->setText(m_time);
122 }