summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actorcountmodel.cpp76
-rw-r--r--actorcountmodel.h31
-rw-r--r--graphbarwidget.cpp125
-rw-r--r--graphbarwidget.h45
-rw-r--r--shemov.pro5
-rw-r--r--shemov.qrc3
-rw-r--r--statistics.html67
-rw-r--r--statisticsdialog.cpp239
-rw-r--r--statisticsdialog.h14
9 files changed, 245 insertions, 360 deletions
diff --git a/actorcountmodel.cpp b/actorcountmodel.cpp
deleted file mode 100644
index ac82f97..0000000
--- a/actorcountmodel.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- 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
- 2 of the License, or (at your option) any later version.
-*/
-
-#include <QSqlQuery>
-#include <QIcon>
-
-#include "actorcountmodel.h"
-
-ActorCountModel::ActorCountModel(QObject *parent) : QAbstractItemModel(parent) {
- QSqlQuery query("SELECT iactorid, tactorname FROM actor ORDER BY tactorname ASC");
- QSqlQuery countQuery;
- countQuery.prepare("SELECT COUNT(*) FROM movieactormap WHERE iactorid = :id");
- while(query.next()){
- QVariant *name = new QVariant(query.value(1));
- countQuery.bindValue(":id", query.value(0));
- countQuery.exec();
- QVariant *count;
- while(countQuery.next()){
- count = new QVariant(countQuery.value(0));
- }
- QList<QVariant*> l;
- l << name << count;
- mItems.append(l);
- }
- mHeaderData << tr("Model name") << tr("Movies");
-}
-
-ActorCountModel::~ActorCountModel() {
- foreach(QList<QVariant*> l, mItems){
- qDeleteAll(l);
- }
-}
-
-QModelIndex ActorCountModel::index(int row, int column, const QModelIndex &parent) const {
- if((column > 1) || (row >= mItems.size()) || (row < 0) || (parent != QModelIndex())){
- return QModelIndex();
- }
- return createIndex(row, column, 0);
-}
-
-int ActorCountModel::rowCount(const QModelIndex &) const {
- return mItems.size();
-}
-
-int ActorCountModel::columnCount(const QModelIndex &) const {
- return 2;
-}
-
-QVariant ActorCountModel::data(const QModelIndex &idx, int role) const {
- if(!idx.isValid() || (idx.column() > 1) || (idx.row() > mItems.size())){
- return QVariant();
- }
- switch (role) {
- case Qt::DisplayRole:
- return *(mItems.at(idx.row()).at(idx.column()));
- break;
- case Qt::DecorationRole:
- if(idx.column() == 0){
- return QIcon(":/dildo.png");
- }
- break;
- }
- return QVariant();
-}
-
-QVariant ActorCountModel::headerData(int section, Qt::Orientation o, int role) const {
- if((role != Qt::DisplayRole) || (o != Qt::Horizontal) || (section > 1)){
- return QVariant();
- }
- return mHeaderData.at(section);
-}
-
diff --git a/actorcountmodel.h b/actorcountmodel.h
deleted file mode 100644
index aa605aa..0000000
--- a/actorcountmodel.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- 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
- 2 of the License, or (at your option) any later version.
-*/
-
-#ifndef ACTORCOUNTMODEL_H
-#define ACTORCOUNTMODEL_H
-
-#include <QAbstractItemModel>
-
-class ActorCountModel : public QAbstractItemModel {
- Q_OBJECT
- public:
- ActorCountModel(QObject *parent = 0);
- virtual ~ActorCountModel();
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- int rowCount(const QModelIndex &idx) const;
- int columnCount(const QModelIndex &idx) const;
- QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation o, int role = Qt::DisplayRole) const;
- QModelIndex parent(const QModelIndex &) const { return QModelIndex(); };
-
- private:
- QList<QList<QVariant*> >mItems;
- QList<QVariant> mHeaderData;
-};
-
-#endif
-
diff --git a/graphbarwidget.cpp b/graphbarwidget.cpp
deleted file mode 100644
index c6f9b0e..0000000
--- a/graphbarwidget.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- 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
- 2 of the License, or (at your option) any later version.
-*/
-
-#include <QFontMetrics>
-#include <QPainter>
-
-#include "graphbarwidget.h"
-
-GraphBarWidget::GraphBarWidget(const QList<QList<QVariant> > data, QWidget *parent) : QWidget(parent), mMargin(10), mData(data) {
- mBarHeight = fontMetrics().height();
-}
-
-int GraphBarWidget::maxValue() const {
- int retval = -1;
- foreach(QList<QVariant> l, mData){
- if(l.at(1).toInt() > retval){
- retval = l.at(1).toInt();
- }
- }
- return retval;
-}
-
-QSize GraphBarWidget::maxDescr() const {
- QFont f = font();
- f.setBold(true);
- QFontMetrics fm(f);
- QSize retval(0,0);
- foreach(QList<QVariant> l, mData){
- QString descr = l.at(0).toString();
- QSize curSize = fm.size(Qt::TextSingleLine, descr);
- if(curSize.width() > retval.width()){
- retval = curSize;
- }
- }
- return retval;
-}
-
-QSize GraphBarWidget::maxCount() const {
- QFontMetrics fm = fontMetrics();
- QSize retval(0,0);
- foreach(QList<QVariant> l, mData){
- QString curCount = QString("(%1)").arg(l.at(2).toString());
- QSize curSize = fm.size(Qt::TextSingleLine, curCount);
- if(curSize.width() > retval.width()){
- retval = curSize;
- }
- }
- return retval;
-}
-
-QSize GraphBarWidget::sizeHint() const {
- int height = mData.count() * mBarHeight;
- height += mData.count() * mMargin;
- height += mBarHeight + mMargin;
- return QSize(400, height);
-}
-
-void GraphBarWidget::paintEvent(QPaintEvent *){
- QPainter p(this);
- QHash<QString, qreal> length; //int
- QList<QList<QVariant> >::const_iterator it;
-
- //draw background
- QPen pen(Qt::red, 2);
- p.setPen(pen);
- QLinearGradient bgGradient(QPointF(0.0, height() / 2), QPointF(width(), height() / 2));
- bgGradient.setColorAt(0, QColor(221, 107, 80));
- bgGradient.setColorAt(1, QColor(251, 179, 150));
- QBrush brush(bgGradient);
- p.setBrush(brush);
- p.drawRect(contentsRect());
-
- //draw caption
- QFont f = font();
- f.setUnderline(true);
- f.setBold(true);
- p.setFont(f);
- QString cap(caption());
- QFontMetrics fm(f);
- int captionStartx = (width() - fm.width(cap)) / 2;
- int captionStarty = fm.height();
- p.drawText(captionStartx, captionStarty, cap);
-
- //prepare drawing data
- int barsStarty = fm.height() + 2 * mMargin + 10;
- f.setUnderline(false);
- f.setBold(true);
- p.setFont(f);
- int maxdescr = maxDescr().width();
- int maxcount = maxCount().width();
-
- int barsStartx = maxdescr + 2 * mMargin;
- int marginRight = maxcount + 2 * mMargin;
- int maxWidth = width() - barsStartx - marginRight;
- p.setRenderHints(QPainter::Antialiasing);
- p.setPen(QPen(Qt::red, 1));
-
- //calculate real lengths based on widget width
- for(it = mData.constBegin(); it != mData.constEnd(); ++it){
- qreal value = it->at(1).toDouble();
- value = value / maxValue() * maxWidth;
- length[it->at(0).toString()] = value;
- }
-
- //draw the bars and numbers
- int ctr(0);
- for(QList<QList<QVariant> >::const_iterator itr = mData.constBegin(); itr != mData.constEnd() ; ++itr, ++ctr){
- int starty = barsStarty + ctr * p.fontMetrics().height() + ctr * mMargin;
- p.drawText(mMargin, starty, itr->at(0).toString());
- QLinearGradient barGradient(QPointF(barsStartx, starty), QPointF(width(), starty));
- barGradient.setColorAt(0, QColor(0, 128, 170));
- barGradient.setColorAt(1, QColor(131, 205, 214));
- QBrush b(barGradient);
- p.setBrush(b);
- qreal len = length.value(itr->at(0).toString());
- QRect bar(barsStartx, starty - p.fontMetrics().height() + p.fontMetrics().descent(), len, p.fontMetrics().height());
- p.drawRect(bar);
- int nStartx = barsStartx + len + mMargin;
- p.drawText(nStartx, starty, QString(tr("(%1)")).arg(itr->at(2).toString()));
- }
-}
diff --git a/graphbarwidget.h b/graphbarwidget.h
deleted file mode 100644
index af7c8ba..0000000
--- a/graphbarwidget.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- 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
- 2 of the License, or (at your option) any later version.
-*/
-
-#ifndef GRAPHBARWIDGET_H
-#define GRAPHBARWIDGET_H
-
-#include <QWidget>
-#include <QVariant>
-#include <QSize>
-
-class QPaintEvent;
-
-class GraphBarWidget : public QWidget {
- Q_OBJECT
- Q_PROPERTY(int maxValue READ maxValue);
- Q_PROPERTY(QSize maxDescr READ maxDescr);
- Q_PROPERTY(QSize maxCount READ maxCount);
- Q_PROPERTY(QString caption READ caption WRITE setCaption);
- public:
- GraphBarWidget(const QList<QList<QVariant> > data, QWidget *parent = 0);
- ~GraphBarWidget() {}
- QString caption() const { return mCaption; }
- void setCaption(const QString &caption) { mCaption = caption; }
- int maxValue() const;
- QSize maxDescr() const;
- QSize maxCount() const;
- virtual QSize sizeHint() const;
-
- protected:
- void paintEvent(QPaintEvent *);
-
- private:
- int mBarHeight;
- int mMargin;
- QString mCaption;
- QList<QList<QVariant> > mData;
- QList<QSize> mSizes;
-
-};
-
-#endif
diff --git a/shemov.pro b/shemov.pro
index 865e1d3..5173801 100644
--- a/shemov.pro
+++ b/shemov.pro
@@ -5,6 +5,7 @@ CONFIG += warn_on \
debug
CONFIG -= release
QT += sql
+QT += webkit
SOURCES = main.cpp \
filesystemdirproxy.cpp \
filesystemwidget.cpp \
@@ -20,8 +21,6 @@ SOURCES = main.cpp \
statisticsdialog.cpp \
actorwidget.cpp \
actormodel.cpp \
- actorcountmodel.cpp \
- graphbarwidget.cpp \
programconfigurator.cpp \
pictureviewer.cpp \
pictureviewerinfoitem.cpp \
@@ -51,8 +50,6 @@ HEADERS = listitem.h \
statisticsdialog.h \
actorwidget.h \
actormodel.h \
- actorcountmodel.h \
- graphbarwidget.h \
programconfigurator.h \
pictureviewer.h \
pictureviewerinfoitem.h \
diff --git a/shemov.qrc b/shemov.qrc
index 17ee5df..e11f49b 100644
--- a/shemov.qrc
+++ b/shemov.qrc
@@ -1,10 +1,11 @@
<RCC>
- <qresource prefix="/" >
+ <qresource prefix="/">
<file>movie.svg</file>
<file>dildo.png</file>
<file>picture.svg</file>
<file>shemov.png</file>
<file>archive.svg</file>
<file>shemov_splash.png</file>
+ <file>statistics.html</file>
</qresource>
</RCC>
diff --git a/statistics.html b/statistics.html
new file mode 100644
index 0000000..d4432c2
--- /dev/null
+++ b/statistics.html
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>{title}</title>
+<style type="text/css">
+body, html {
+ margin: 10px;
+ padding: 10px;
+ background: #0015F2;
+ color: #d9ed1b;
+}
+body {
+ min-width: 100%;
+}
+h1 {
+ text-align:center;
+ margin-top: 0;
+ padding-top: 0;
+}
+.overview {
+ border: 1px solid;
+ margin-left: auto;
+ margin-right: auto;
+}
+td.desc {
+ width: 15%;
+}
+td.total {
+ width: 15%;
+ text-align: right;
+}
+.bar {
+ width: 60%;
+ background-color: #0FE6FD;
+ text-align: right;
+ border-left: solid 1px;
+ padding-right: 0.5em;
+}
+.bar div {
+ border-top: 2px solid #066FF7;
+ border-bottom: 2px solid #066FF7;
+ background-color: #d9ed1b;
+ text-align: right;
+ float: left;
+ padding-top: 0;
+ height: 1em;
+}
+</style>
+</head>
+<body>
+<h1>{title}</h1>
+<table class="overview">
+<thead>
+<tr>
+<th>{desc}</th>
+<th>Graph</th>
+<th>Number</th>
+</tr>
+</thead>
+<tbody>
+{table}
+</tbody>
+</table>
+</body>
+</html>
diff --git a/statisticsdialog.cpp b/statisticsdialog.cpp
index ba93726..30141c2 100644
--- a/statisticsdialog.cpp
+++ b/statisticsdialog.cpp
@@ -6,89 +6,188 @@
*/
#include <QTabWidget>
-#include <QPainter>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSqlQuery>
#include <QVariant>
-#include <QFontMetrics>
-#include <QApplication>
-#include <QPainter>
-#include <QPen>
-#include <QBrush>
-#include <QLinearGradient>
#include <QPushButton>
-#include <QSqlError>
-#include <QTreeView>
-#include <QSortFilterProxyModel>
+#include <QLocale>
+#include <QFile>
+#include <QWebView>
#include "statisticsdialog.h"
-#include "actorcountmodel.h"
-#include "graphbarwidget.h"
StatisticsDialog::StatisticsDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){
+ //html skeleton
+ QFile htmlFile(":/statistics.html");
+ htmlFile.open(QIODevice::ReadOnly);
+ QString html = htmlFile.readAll();
+
+ //genre distribution
+ QWebView *genreView = new QWebView;
+ QString genreHtml = html;
+ genreHtml.replace("{title}", tr("Genre distribution"));
+ genreHtml.replace("{desc}", tr("Genres"));
+ QList<QList<QVariant> > data = queryData("SELECT genres.tgenrename, COUNT(seriesparts_genremap.iseriesparts_id) FROM genres, seriesparts_genremap WHERE genres.igenres_id = seriesparts_genremap.igenres_id GROUP BY genres.tgenrename ORDER BY count DESC;");
+ QString tableData = table(data, max(data));
+ genreHtml.replace("{table}", tableData);
+ genreView->setHtml(genreHtml);
+
+ //quality distribution
+ QWebView *qualityView = new QWebView;
+ QString qualityHtml = html;
+ qualityHtml.replace("{title}", tr("Quality distribution"));
+ qualityHtml.replace("{desc}", tr("Quality"));
+ data = queryData("SELECT files.siquality, COUNT(seriesparts.iseriesparts_id) FROM files, seriesparts WHERE files.iseriespart_id = seriesparts.iseriesparts_id AND files.siquality IS NOT NULL GROUP BY files.siquality ORDER by siquality desc;");
+ tableData = table(data, max(data));
+ qualityHtml.replace("{table}", tableData);
+ qualityView->setHtml(qualityHtml);
+
+ //top 20 actors
+ QWebView *topActorView = new QWebView;
+ QString topActorHtml = html;
+ topActorHtml.replace("{title}", tr("Top 20 actors"));
+ topActorHtml.replace("{desc}", tr("Actor"));
+ data = queryData("SELECT actors.tactorname, COUNT(seriesparts_actormap.iseriesparts_id) FROM actors, seriesparts_actormap WHERE actors.iactors_id = seriesparts_actormap.iactors_id GROUP BY actors.tactorname ORDER BY count desc LIMIT 20");
+ tableData = table(data, max(data));
+ topActorHtml.replace("{table}", tableData);
+ topActorView->setHtml(topActorHtml);
+
+ //general statistics
+ QWebView *generalView = new QWebView;
+ QString generalHtml = html;
+ generalHtml.remove(QRegExp("<thead>.*</thead>"));
+ tableData = generalStatistics();
+ generalHtml.replace("{title}", tr("General statistics"));
+ generalHtml.replace("{table}", tableData);
+ generalView->setHtml(generalHtml);
+
+ //tab
+ QTabWidget *tab = new QTabWidget;
+ tab->addTab(genreView, tr("Genres"));
+ tab->addTab(qualityView, tr("Quality"));
+ tab->addTab(topActorView, tr("Top 20 actors"));
+ tab->addTab(generalView, tr("General statistics"));
+
+ //close button
+ QPushButton *close = new QPushButton(tr("Close"));
+ connect(close, SIGNAL(clicked()), this, SLOT(accept()));
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ buttonLayout->setAlignment(Qt::AlignCenter);
+ buttonLayout->addWidget(close);
+
+ //the dialog
QVBoxLayout *mainLayout = new QVBoxLayout;
- mTab = new QTabWidget;
+ mainLayout->addWidget(tab);
+ mainLayout->addLayout(buttonLayout);
+ setLayout(mainLayout);
+ setWindowTitle(tr("SheMov - Statistics"));
+}
- // quality distribution
- QList<QList<QVariant> > qualityData;
- QSqlQuery q("SELECT DISTINCT(iquality), COUNT(iquality) FROM movies GROUP BY iquality ORDER BY iquality");
- while(q.next()){
- QList<QVariant> d;
- d << q.value(0) << q.value(1) << q.value(1);
- qualityData << d;
+QString StatisticsDialog::table(const QList<QList<QVariant> > &data, int max) const {
+ QString table;
+ QLocale loc;
+ foreach(QList<QVariant> l, data){
+ table.append("<tr>");
+ int percent = l.at(1).toInt() * 100 / max - 1;
+ percent = percent < 1 ? 1 : percent;
+ table.append(QString("<td class=\"descr\">%1</td>").arg(l.at(0).toString()));
+ table.append(QString("<td class=\"bar\"><div style=\"width: %1%\" class=\"bar\"></div></td>").arg(percent));
+ table.append(QString("<td class=\"total\">%1</td>").arg(loc.toString(l.at(1).toInt())));
+ table.append("</tr>");
}
- GraphBarWidget *qs = new GraphBarWidget(qualityData);
- qs->setCaption(tr("Movie qualities"));
- mTab->addTab(qs, tr("Quality Distribution"));
- mainLayout->addWidget(mTab);
-
- // genre distribution
- QList<QList<QVariant> > genreData;
- QSqlQuery q2("SELECT DISTINCT(genre.igenreid), genre.tgenrename, COUNT(movies.imovid) FROM movies, genre WHERE movies.igenreid = genre.igenreid GROUP by genre.igenreid, genre.tgenrename ORDER by genre.tgenrename");
- while(q2.next()){
- QList<QVariant> d;
- d << q2.value(1) << q2.value(2) << q2.value(2);
- genreData << d;
+ return table;
+}
+
+QList<QList<QVariant> > StatisticsDialog::queryData(const QString &query) const {
+ QSqlDatabase db = QSqlDatabase::database("treedb");
+ QSqlQuery q(query, db);
+ QList<QList<QVariant> > retval;
+ while(q.next()){
+ QList<QVariant> data;
+ data << q.value(0) << q.value(1);
+ retval << data;
}
- GraphBarWidget *gs = new GraphBarWidget(genreData);
- gs->setCaption(tr("Genre Distribution"));
- mTab->addTab(gs, tr("Genre Distribution"));
-
- // top ten actors
- QList<QList<QVariant> > actorData;
- QSqlQuery q3("SELECT DISTINCT(actor.iactorid), actor.tactorname, COUNT(DISTINCT(movies.ttitle)) AS num FROM movies, actor, movieactormap WHERE actor.iactorid = movieactormap.iactorid AND movieactormap.imovid = movies.imovid GROUP BY actor.iactorid, actor.tactorname ORDER BY num DESC LIMIT 10");
- while(q3.next()){
- QList<QVariant> d;
- d << q3.value(1) << q3.value(2) << q3.value(2);
- actorData << d;
+ return retval;
+}
+
+int StatisticsDialog::max(const QList<QList<QVariant> > &data) const{
+ int retval = 0;
+ foreach(QList<QVariant> l, data){
+ int value = l.at(1).toInt();
+ if(value > retval){
+ retval = value;
+ }
}
- GraphBarWidget *as = new GraphBarWidget(actorData);
- as->setCaption(tr("Top 10 actors"));
- mTab->addTab(as, tr("Top 10 actors"));
-
- // actor count
- QWidget *actorWidget = new QWidget;
- QHBoxLayout *actorLayout = new QHBoxLayout;
- QTreeView *actorView = new QTreeView;
- actorView->setRootIsDecorated(false);
- ActorCountModel *aModel = new ActorCountModel;
- QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
- proxy->setSourceModel(aModel);
- actorView->setModel(proxy);
- actorView->resizeColumnToContents(0);
- actorLayout->addWidget(actorView);
- actorWidget->setLayout(actorLayout);
- actorView->setSortingEnabled(true);
- mTab->addTab(actorWidget, tr("Actor overview"));
+ return retval;
+}
- QHBoxLayout *buttonLayout = new QHBoxLayout;
- buttonLayout->setAlignment(Qt::AlignHCenter);
- mOk = new QPushButton(tr("Ok"));
- connect(mOk, SIGNAL(clicked()), this, SLOT(accept()));
- buttonLayout->addWidget(mOk);
- mainLayout->addLayout(buttonLayout);
- QString title = QString(tr("%1 - Statistics")).arg(qApp->applicationName());
- setLayout(mainLayout);
- setWindowTitle(title);
+QString StatisticsDialog::generalStatistics() const{
+ //get database
+ QSqlDatabase db = QSqlDatabase::database("treedb");
+
+ //series count
+ QSqlQuery q1("SELECT COUNT(*) FROM series", db);
+ q1.first();
+ int numSeries = q1.value(0).toInt();
+
+ //movies count
+ QSqlQuery q2("SELECT COUNT(*) FROM seriesparts", db);
+ q2.first();
+ int numMovies = q2.value(0).toInt();
+
+ //files count
+ QSqlQuery q3("SELECT COUNT(*) FROM files", db);
+ q3.first();
+ int numFiles = q3.value(0).toInt();
+
+ //movie files
+ QSqlQuery q4("SELECT COUNT(*) FROM files WHERE sifiletype = 1", db);
+ q4.first();
+ int numMovieFiles = q4.value(0).toInt();
+
+ //cover files
+ QSqlQuery q5("SELECT COUNT(*) FROM files WHERE sifiletype != 1", db);
+ q5.first();
+ int numCoverFiles = q5.value(0).toInt();
+
+ //total archive size
+ QSqlQuery q6("SELECT ROUND(SUM(bisize) / 1024 / 1024 / 1024, 2) FROM files", db);
+ q6.first();
+ float totalArchiveSize = q6.value(0).toFloat();
+
+ //local file size
+ QSqlQuery q7("SELECT ROUND(SUM(bisize) / 1024 / 1024 / 1024, 2) FROM files WHERE idvd = -1", db);
+ q7.first();
+ float localFileSize = q7.value(0).toFloat();
+
+ //archived file size
+ QSqlQuery q8("SELECT ROUND(SUM(bisize) / 1024 / 1024 / 1024, 2) FROM files WHERE idvd != -1", db);
+ q8.first();
+ float archivedFileSize = q8.value(0).toFloat();
+
+ //actor count
+ QSqlQuery q9("SELECT COUNT(*) FROM actors", db);
+ q9.first();
+ int actorCount = q9.value(0).toInt();
+
+ //genre count
+ QSqlQuery q10("SELECT COUNT(*) FROM genres", db);
+ q10.first();
+ int genreCount = q10.value(0).toInt();
+
+ //build the tabel
+ QString retval;
+ QLocale loc;
+ retval.append(QString("<tr><td>Number of series</td><td style=\"padding-left: 30px\">%1</td></tr>").arg(numSeries));
+ retval.append(QString("<tr><td>Number of movies</td><td style=\"padding-left: 30px\">%1</td></tr>").arg(numMovies));
+ retval.append(QString("<tr><td>Number of files</td><td style=\"padding-left: 30px\">%1</td></tr>").arg(numFiles));
+ retval.append(QString("<tr><td>Number of movie files</td><td style=\"padding-left: 30px\">%1</td></tr>").arg(numMovieFiles));
+ retval.append(QString("<tr><td>Number of cover files</td><td style=\"padding-left: 30px\">%1</td></tr>").arg(numCoverFiles));
+ retval.append(QString("<tr><td>Total archive size</td><td style=\"padding-left: 30px\">%1 GB</td></tr>").arg(loc.toString(totalArchiveSize)));
+ retval.append(QString("<tr><td>Local files size</td><td style=\"padding-left: 30px\">%1 GB</td></tr>").arg(loc.toString(localFileSize)));
+ retval.append(QString("<tr><td>Archived files size</td><td style=\"padding-left: 30px\">%1 GB</td></tr>").arg(loc.toString(archivedFileSize)));
+ retval.append(QString("<tr><td>Number of actors</td><td style=\"padding-left: 30px\">%1</td></tr>").arg(actorCount));
+ retval.append(QString("<tr><td>Number of genres</td><td style=\"padding-left: 30px\">%1</td></tr>").arg(genreCount));
+ return retval;
}
diff --git a/statisticsdialog.h b/statisticsdialog.h
index b431a07..70f2e55 100644
--- a/statisticsdialog.h
+++ b/statisticsdialog.h
@@ -9,12 +9,8 @@
#define STATISTICSDIALOG_H
#include <QDialog>
-#include <QMap>
-
-class QTabWidget;
-class QPaintEvent;
-class QSize;
-class QPushButton;
+#include <QList>
+#include <QVariant>
class StatisticsDialog : public QDialog {
Q_OBJECT
@@ -23,8 +19,10 @@ class StatisticsDialog : public QDialog {
~StatisticsDialog() {}
private:
- QTabWidget *mTab;
- QPushButton *mOk;
+ QString table(const QList<QList<QVariant> > &data, int max) const;
+ QList<QList<QVariant> > queryData(const QString &query) const;
+ int max(const QList<QList<QVariant> > &data) const;
+ QString generalStatistics() const;
};
#endif