-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiplecheckdialog.cpp
139 lines (118 loc) · 4.68 KB
/
multiplecheckdialog.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
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
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 "multiplecheckdialog.h"
#include "ui_multiplecheckdialog.h"
#include "contactwidgetfastbook.h"
#include <QMultiMap>
multipleCheckDialog::multipleCheckDialog(const libJackSMS::dataTypes::phoneBookType &_rubrica, const libJackSMS::dataTypes::configuredServicesType &_elencoServiziConfigurati, const libJackSMS::dataTypes::servicesType &_elencoServizi, MainJackSMS *_padre, QWidget *parent) :
QDialog(parent),
padre(_padre),
ui(new Ui::multipleCheckDialog),
rubrica(_rubrica),
elencoServiziConfigurati(_elencoServiziConfigurati),
elencoServizi(_elencoServizi)
{
ui->setupUi(this);
writeToGui();
}
multipleCheckDialog::~multipleCheckDialog()
{
delete ui;
}
void multipleCheckDialog::writeToGui()
{
QMultiMap<QString,contactWidgetFastBook*> fastList;
QString filter = ui->lineEdit->text();
for (libJackSMS::dataTypes::phoneBookType::const_iterator i = rubrica.begin(); i != rubrica.end(); ++i) {
//Controllo che non sia già presente nella lista destinatari
if (!padre->isInRecipients(i.value().getPhone()))
{
if (i->getName().contains(filter, Qt::CaseInsensitive))
{
QIcon ico;
libJackSMS::dataTypes::configuredServicesType::const_iterator x = elencoServiziConfigurati.find(i->getAccount());
if (x == elencoServiziConfigurati.end())
{
ico = QIcon(":/resource/ico_contact.png");
}
else
{
QString serv = x.value().getService();
libJackSMS::dataTypes::servicesType::const_iterator tmp = elencoServizi.find(serv);
ico = tmp->getIcon();
}
contactWidgetFastBook *ww = new contactWidgetFastBook(i.value(), ico.pixmap(16,16), true);
fastList.insert(i->getName().toUpper(), ww);
}
}
}
if (fastList.size() > 0)
{
for (QMultiMap<QString,contactWidgetFastBook*>::ConstIterator xx = fastList.begin(); xx != fastList.end(); ++xx)
{
QListWidgetItem *item = new QListWidgetItem;
item->setSizeHint(xx.value()->size());
ui->listWidget->addItem(item);
ui->listWidget->setItemWidget(item, xx.value());
}
}
}
void multipleCheckDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void multipleCheckDialog::on_pushButton_clicked()
{
close();
}
void multipleCheckDialog::on_lineEdit_textEdited(QString text)
{
int c=ui->listWidget->count();
for(int x=0;x<c;++x){
QListWidgetItem *item=ui->listWidget->item(x);
contactWidgetFastBook *w=static_cast<contactWidgetFastBook*>(ui->listWidget->itemWidget(item));
if (w->getName().contains(text,Qt::CaseInsensitive))
ui->listWidget->setItemHidden(item,false);
else
ui->listWidget->setItemHidden(item,true);
}
}
void multipleCheckDialog::on_pushButton_2_clicked()
{
QList<QRecipientWidget*> l;
for(int x = 0; x < ui->listWidget->count(); ++x) {
contactWidgetFastBook *w = static_cast<contactWidgetFastBook*>(ui->listWidget->itemWidget(ui->listWidget->item(x)));
if (w->isChecked()) {
QRecipientWidget *wi = new QRecipientWidget(w->getContact().getName(), w->getContact().getAccount(), w->getContact().getPhone(), w->getIcon());
l.push_back(wi);
}
}
emit addRecipients(l);
close();
}
void multipleCheckDialog::on_button_all_clicked()
{
for(int x = 0; x < ui->listWidget->count(); ++x) {
dynamic_cast<contactWidgetFastBook*>(ui->listWidget->itemWidget(ui->listWidget->item(x)))->setChecked(true);
}
}