summaryrefslogtreecommitdiffstats
path: root/moviepropertiesdialog.cpp
blob: 26bec8f4e144a7385a6176cd9cd816a4864f55f2 (plain)
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
/*
  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 <QHBoxLayout>
#include <QVBoxLayout>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QPushButton>
#include <QTextEdit>
#include <QLabel>
#include <QSqlQuery>
#include <QFileInfo>

#include "moviepropertiesdialog.h"
#include "helper.h"

MoviePropertiesDialog::MoviePropertiesDialog(int movid, QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), mId(movid), mIndex(-1){
	//gather data
	covers();
	QSqlQuery q1;
	q1.prepare("SELECT ttitle, tfilename, cmd5sum, bisize, genre.tgenrename, iquality, idvd FROM movies, genre WHERE movies.igenreid = genre.igenreid AND movies.imovid = :id");
	q1.bindValue(":id", mId);
	q1.exec();
	QString title, filename, md5, genre;
	quint64 size(0);
	qint32 quality, dvd;
	quality = dvd = 0;
	q1.exec();
	while(q1.next()){
		title = q1.value(0).toString();
		filename = q1.value(1).toString();
		md5 = q1.value(2).toString();
		genre = q1.value(4).toString();
		size = q1.value(3).toLongLong();
		quality = q1.value(5).toInt();
		dvd = q1.value(6).toInt();
	}
	QStringList actors;
	QSqlQuery q2;
	q2.prepare("SELECT tactorname FROM actor, movieactormap WHERE movieactormap.iactorid = actor.iactorid AND movieactormap.imovid = :id");
	q2.bindValue(":id", mId);
	while(q2.next()){
		actors << q2.value(0).toString();
	}
	//layout
	
}

void MoviePropertiesDialog::covers(){
	QSqlQuery q;
	q.prepare("SELECT tfilename, cmd5sum FROM covers WHERE imovid = :id");
	q.bindValue(":id", mId);
	q.exec();
	while(q.next()){
		QString path = Helper::createArchivePath(q.value(0).toString(), q.value(1).toString());
		QFileInfo fi(path);
		if(fi.exists()){
			mCovers << path;
		}
	}
}