2011-06-26 17:07:48 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "coversearchstatisticsdialog.h"
|
|
|
|
#include "ui_coversearchstatisticsdialog.h"
|
|
|
|
#include "core/utilities.h"
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
CoverSearchStatisticsDialog::CoverSearchStatisticsDialog(QWidget* parent)
|
|
|
|
: QDialog(parent), ui_(new Ui_CoverSearchStatisticsDialog) {
|
2011-06-26 17:07:48 +02:00
|
|
|
ui_->setupUi(this);
|
|
|
|
details_layout_ = new QVBoxLayout(ui_->details);
|
|
|
|
details_layout_->setSpacing(0);
|
|
|
|
|
|
|
|
setStyleSheet(
|
2014-02-07 16:34:20 +01:00
|
|
|
"#details {"
|
|
|
|
" background-color: palette(base);"
|
|
|
|
"}"
|
|
|
|
"#details QLabel[type=\"label\"] {"
|
|
|
|
" border: 2px solid transparent;"
|
|
|
|
" border-right: 2px solid palette(midlight);"
|
|
|
|
" margin-right: 10px;"
|
|
|
|
"}"
|
|
|
|
"#details QLabel[type=\"value\"] {"
|
|
|
|
" font-weight: bold;"
|
|
|
|
" max-width: 100px;"
|
|
|
|
"}");
|
2011-06-26 17:07:48 +02:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
CoverSearchStatisticsDialog::~CoverSearchStatisticsDialog() { delete ui_; }
|
2011-06-26 17:07:48 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void CoverSearchStatisticsDialog::Show(
|
|
|
|
const CoverSearchStatistics& statistics) {
|
2011-06-26 17:07:48 +02:00
|
|
|
QStringList providers(statistics.total_images_by_provider_.keys());
|
|
|
|
qSort(providers);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
ui_->summary->setText(
|
|
|
|
tr("Got %1 covers out of %2 (%3 failed)")
|
|
|
|
.arg(statistics.chosen_images_)
|
|
|
|
.arg(statistics.chosen_images_ + statistics.missing_images_)
|
|
|
|
.arg(statistics.missing_images_));
|
2011-06-26 17:07:48 +02:00
|
|
|
|
2014-02-10 14:29:07 +01:00
|
|
|
for (const QString& provider : providers) {
|
2011-06-26 17:07:48 +02:00
|
|
|
AddLine(tr("Covers from %1").arg(provider),
|
|
|
|
QString::number(statistics.chosen_images_by_provider_[provider]));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!providers.isEmpty()) {
|
|
|
|
AddSpacer();
|
|
|
|
}
|
|
|
|
|
|
|
|
AddLine(tr("Total network requests made"),
|
|
|
|
QString::number(statistics.network_requests_made_));
|
|
|
|
AddLine(tr("Average image size"), statistics.AverageDimensions());
|
|
|
|
AddLine(tr("Total bytes transferred"),
|
|
|
|
statistics.bytes_transferred_
|
2014-02-07 16:34:20 +01:00
|
|
|
? Utilities::PrettySize(statistics.bytes_transferred_)
|
|
|
|
: "0 bytes");
|
2011-06-26 17:07:48 +02:00
|
|
|
|
|
|
|
details_layout_->addStretch();
|
|
|
|
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void CoverSearchStatisticsDialog::AddLine(const QString& label,
|
|
|
|
const QString& value) {
|
2011-06-26 17:07:48 +02:00
|
|
|
QLabel* label1 = new QLabel(label);
|
|
|
|
QLabel* label2 = new QLabel(value);
|
|
|
|
|
|
|
|
label1->setProperty("type", "label");
|
|
|
|
label2->setProperty("type", "value");
|
|
|
|
|
|
|
|
QHBoxLayout* layout = new QHBoxLayout;
|
|
|
|
layout->addWidget(label1);
|
|
|
|
layout->addWidget(label2);
|
|
|
|
details_layout_->addLayout(layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoverSearchStatisticsDialog::AddSpacer() {
|
|
|
|
details_layout_->addSpacing(20);
|
|
|
|
}
|