-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatsdialog.cpp
105 lines (86 loc) · 3.52 KB
/
statsdialog.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
/*
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 "statsdialog.h"
#include "ui_statsdialog.h"
#include <QLabel>
#include <QMap>
#include <QPixmap>
#include <QTextEdit>
#include "libjacksms/libJackSMS.h"
#include <QHBoxLayout>
#include "libjacksms/ConfiguredAccount.h"
StatsDialog::StatsDialog(const libJackSMS::dataTypes::optionsType &_opzioni, const libJackSMS::dataTypes::configuredServicesType &_servizi, const libJackSMS::dataTypes::servicesType &_ElencoServizi, QWidget *parent) :
QDialog(parent),
m_ui(new Ui::StatsDialog),
opzioni(_opzioni),
servizi(_servizi),
ElencoServizi(_ElencoServizi)
{
m_ui->setupUi(this);
int tot= 0;
QMap<QString, libJackSMS::dataTypes::configuredAccount> tempMap;
for (libJackSMS::dataTypes::configuredServicesType::const_iterator i = servizi.begin(); i != servizi.end(); ++i)
{
if ((i.value().getId() != "1") && (i.value().getId() != "2"))
tempMap.insert(i.value().getName(), i.value());
}
// Aggiungo Free+ separatamente in modo che sia in cima alla lista
tot += addServiceToList(servizi.find("1"));
// Aggiungo SMS+ separatamente in modo che sia in cima alla lista
tot += addServiceToList(servizi.find("2"));
for (libJackSMS::dataTypes::configuredServicesType::const_iterator i = tempMap.begin(); i != tempMap.end(); ++i)
tot += addServiceToList(i);
m_ui->labelTotal->setText("Messaggi inviati da questa postazione: <b>" + QString::number(tot) + "</b>");
}
StatsDialog::~StatsDialog()
{
delete m_ui;
}
int StatsDialog::addServiceToList(libJackSMS::dataTypes::configuredServicesType::const_iterator i)
{
QHBoxLayout *hLayout = new QHBoxLayout;
{
QLabel *l = new QLabel;
l->setPixmap(ElencoServizi[i.value().getService()].getIcon().pixmap(16, 16));
l->setFixedSize(16, 16);
l->adjustSize();
hLayout->addWidget(l);
}
{
QTextEdit *l = new QTextEdit;
QString result = "<b>" + i.value().getName() + "</b><br>Inviati oggi da tutti i client: " + QString::number(i.value().getSentAll()) + "<br>Totale inviati da questa postazione: " + i.value().getStat("sent");
l->setText(result);
l->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
l->setMaximumHeight(55);
l->setReadOnly(true);
l->adjustSize();
hLayout->addWidget(l);
}
hLayout->setSizeConstraint(QLayout::SetMinimumSize);
m_ui->layoutStatistiche->addLayout(hLayout);
return i.value().getStat("sent").toInt();
}
void StatsDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}