1
/* This file is part of Clementine.
2
Copyright 2010, David Sansome <me@davidsansome.com>
4
Clementine is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
9
Clementine is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
18
#include "coversearchstatisticsdialog.h"
19
#include "ui_coversearchstatisticsdialog.h"
20
#include "core/utilities.h"
22
CoverSearchStatisticsDialog::CoverSearchStatisticsDialog(QWidget *parent)
24
ui_(new Ui_CoverSearchStatisticsDialog)
27
details_layout_ = new QVBoxLayout(ui_->details);
28
details_layout_->setSpacing(0);
32
" background-color: palette(base);"
34
"#details QLabel[type=\"label\"] {"
35
" border: 2px solid transparent;"
36
" border-right: 2px solid palette(midlight);"
37
" margin-right: 10px;"
39
"#details QLabel[type=\"value\"] {"
46
CoverSearchStatisticsDialog::~CoverSearchStatisticsDialog() {
50
void CoverSearchStatisticsDialog::Show(const CoverSearchStatistics& statistics) {
51
QStringList providers(statistics.total_images_by_provider_.keys());
54
ui_->summary->setText(tr("Got %1 covers out of %2 (%3 failed)")
55
.arg(statistics.chosen_images_)
56
.arg(statistics.chosen_images_ + statistics.missing_images_)
57
.arg(statistics.missing_images_));
59
foreach (const QString& provider, providers) {
60
AddLine(tr("Covers from %1").arg(provider),
61
QString::number(statistics.chosen_images_by_provider_[provider]));
64
if (!providers.isEmpty()) {
68
AddLine(tr("Total network requests made"),
69
QString::number(statistics.network_requests_made_));
70
AddLine(tr("Average image size"), statistics.AverageDimensions());
71
AddLine(tr("Total bytes transferred"),
72
statistics.bytes_transferred_
73
? Utilities::PrettySize(statistics.bytes_transferred_)
76
details_layout_->addStretch();
81
void CoverSearchStatisticsDialog::AddLine(const QString& label, const QString& value) {
82
QLabel* label1 = new QLabel(label);
83
QLabel* label2 = new QLabel(value);
85
label1->setProperty("type", "label");
86
label2->setProperty("type", "value");
88
QHBoxLayout* layout = new QHBoxLayout;
89
layout->addWidget(label1);
90
layout->addWidget(label2);
91
details_layout_->addLayout(layout);
94
void CoverSearchStatisticsDialog::AddSpacer() {
95
details_layout_->addSpacing(20);