-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqrecipientwidget.cpp
126 lines (107 loc) · 3.5 KB
/
qrecipientwidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
Copyright (C) <2011>
<enrico bacis> <[email protected]>
<ivan vaccari> <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qrecipientwidget.h"
#include <QStyle>
#include "faderwidget.h"
#include "qlabelresult.h"
QRecipientWidget::QRecipientWidget(const QString &_contactName, const QString &accId, const libJackSMS::dataTypes::phoneNumber &_number, QPixmap Icon, QWidget *parent) :
QWidget(parent),
contactName(_contactName),
accountId(accId),
number(_number),
nameStr(contactName)
{
original = Icon;
hLayout = new QHBoxLayout;
//hLayout->setMargin(3);
iconLabel = new QLabel;
iconLabel->setPixmap(Icon);
iconLabel->setFixedSize(16, 16);
iconStatus = new QLabel;
iconStatus->setFixedSize(16, 16);
name = new QLabel(contactName);
name->setCursor(Qt::WhatsThisCursor);
name->setToolTip(number.toString());
name->setFixedHeight(16);
name->adjustSize();
//name->setFixedWidth(name->width());
name->setContentsMargins(0, 0, 5, 0);
removeLabel = new QLabelResult(this);
removeLabel->setFixedSize(16, 16);
removeLabel->setPixmap(QIcon(":/resource/rimuovi.png").pixmap(10, 10));
removeLabel->setCursor(Qt::PointingHandCursor);
connect(removeLabel, SIGNAL(clicked()), this, SLOT(remove()));
hLayout->addWidget(removeLabel);
hLayout->addWidget(iconLabel);
hLayout->addWidget(name);
hLayout->addWidget(iconStatus);
hLayout->setContentsMargins(3, 0, 3, 0);
setLayout(hLayout);
setFixedHeight(22);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
adjustSize();
FaderWidget *faderWidget = new FaderWidget(this, Qt::white);
faderWidget->start();
}
void QRecipientWidget::setParentItem(QListWidgetItem * it)
{
pIt = it;
}
void QRecipientWidget::remove()
{
emit removed(pIt);
}
void QRecipientWidget::setStatusFailed(QString message)
{
iconStatus->setPixmap(QIcon(":/resource/jms-not-active.png").pixmap(16, 16));
iconStatus->setToolTip(message);
iconStatus->setCursor(Qt::WhatsThisCursor);
}
void QRecipientWidget::restoreOriginalIcon()
{
iconLabel->setPixmap(original);
}
void QRecipientWidget::setStatusWorking()
{
iconStatus->setPixmap(QIcon(":/resource/jms-activating.png").pixmap(16, 16));
iconStatus->setCursor(Qt::WhatsThisCursor);
}
void QRecipientWidget::clearStatus()
{
iconStatus->clear();
}
void QRecipientWidget::setStatusSuccess(QString message)
{
iconStatus->setPixmap(QIcon(":/resource/jms-active.png").pixmap(16, 16));
iconStatus->setToolTip(message);
iconStatus->setCursor(Qt::WhatsThisCursor);
}
libJackSMS::dataTypes::phoneNumber QRecipientWidget::getPhone() const
{
return number;
}
void QRecipientWidget::setIcon(QPixmap Icon)
{
iconLabel->setPixmap(Icon);
}
QString QRecipientWidget::getAccountId() const
{
return accountId;
}
QString QRecipientWidget::getName() const
{
return nameStr;
}