This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
ThumbnailItem.cpp
198 lines (174 loc) · 4.55 KB
/
ThumbnailItem.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/***************************************************************************//**
* @brief Thumbnail me 3.0
* Thumbnail me is a user interface for Movie thumbnailer.
* Generate thumbnails from any movie is now easier !
*
* @file ThumbnailItem.h
* @class ThumbnailItem
* Représente un item de type Thumbnail.
*
* @author Quentin Rousseau\n
* @note Copyright (C) 2011-2012 Quentin Rousseau\n
* License: GNU General Public License version 2 (GPLv2) - http://www.gnu.org/licenses/gpl-2.0.html\n
* Site web: www.thumbnailme.com\n
* Email: [email protected]
*
* @since 3.0
* @version 3.0
* @date 2011-2012
*******************************************************************************/
#include "ThumbnailItem.h"
/**
*@brief Constructeur.
*/
ThumbnailItem::ThumbnailItem(QUrl filePath) : QObject() , QListWidgetItem ()
{
this->setText(filePath.toString());
this->filePath = filePath;
this->filePathOutput = QString();
this->mediaPlayer = new QMediaPlayer(this);
this->readable = true;
connect(mediaPlayer, SIGNAL(durationChanged (qint64)), this, SLOT(manageDuration(qint64)));
connect(mediaPlayer, SIGNAL(error (QMediaPlayer::Error)), this, SLOT(manageError(QMediaPlayer::Error)));
mediaPlayer->setMedia(QMediaContent(QUrl::fromLocalFile(filePath.toString())));
mediaPlayer->pause();
}
/**
*@brief Constructeur de copie.
*/
ThumbnailItem::ThumbnailItem(ThumbnailItem &other) : QObject() , QListWidgetItem (other)
{
this->setText(other.text());
this->filePath = other.getFilePath();
this->filePathOutput = other.getFilePathOutput();
this->readable = other.isReadable();
this->lowerQTime = other.getLowerTime();
this->upperQTime = other.getUpperTime();
this->mediaPlayer = new QMediaPlayer(this);
connect(mediaPlayer, SIGNAL(durationChanged (qint64)), this, SLOT(manageDuration(qint64)));
connect(mediaPlayer, SIGNAL(error (QMediaPlayer::Error)), this, SLOT(manageError(QMediaPlayer::Error)));
mediaPlayer->setMedia(QMediaContent(QUrl::fromLocalFile(filePath.toString())));
mediaPlayer->pause();
}
/**
*@brief Destructeur.
*/
ThumbnailItem::~ThumbnailItem()
{
}
/**
*@brief Setter du QTime de début.
*@param t Qtime
*/
void ThumbnailItem::setLowerTime(QTime t)
{
this->lowerQTime = t;
}
/**
*@brief Setter du QTime de fin.
*@param t Qtime
*/
void ThumbnailItem::setUpperTime(QTime t)
{
this->upperQTime = t;
}
/**
*@brief Setter du QTime de la durée totale.
*@param t Qtime
*/
void ThumbnailItem::setTotalDuration(QTime t)
{
this->totalDurationQTime = t;
}
/**
*@brief Setter du Fichier du chemin.
*@param path QUrl.
*/
void ThumbnailItem::setFilePath(QUrl path)
{
this->filePath = path;
this->setText(path.toString());
}
/**
*@brief Setter du Fichier du chemin de destination.
*@param path QUrl.
*/
void ThumbnailItem::setFilePathOutput(QUrl path)
{
this->filePathOutput = path;
}
/**
*@brief Retourne le QTime de début.
*@return QTime - QTime
*/
QTime ThumbnailItem::getLowerTime()
{
return this->lowerQTime;
}
/**
*@brief Retourne le QTime de fin.
*@return QTime - QTime
*/
QTime ThumbnailItem::getUpperTime()
{
return this->upperQTime;
}
/**
*@brief Retourne le QTime de la durée totale.
*@return QTime - QTime
*/
QTime ThumbnailItem::getTotalDuration()
{
return this->totalDurationQTime;
}
/**
*@brief Retourne le chemin de l'item.
*@return QUrl - Url du fichier
*/
QUrl ThumbnailItem::getFilePath()
{
return filePath;
}
/**
*@brief Retourne le chemin de destination de l'item.
*@return QUrl - Url du fichier
*/
QUrl ThumbnailItem::getFilePathOutput()
{
return filePathOutput;
}
/**
*@brief Retourne le nombre de secondes omis au début du média.
*@return QString - Format X.X en secondes.
*/
double ThumbnailItem::getBeginOmmitSecs()
{
return (double) -this->getLowerTime().secsTo(QTime());
}
/**
*@brief Retourne le nombre de secondes omis à la fin du média.
*@return QString - Format X.X en secondes.
*/
double ThumbnailItem::getEndOmmitSecs()
{
return (double) this->getUpperTime().secsTo(this->getTotalDuration());
}
/**
*@brief Récupère la durée d'un Item.
*@param duration Durée du média en ms.
*/
void ThumbnailItem::manageDuration(qint64 duration)
{
QTime t(0,0);
this->totalDurationQTime = t.addMSecs(duration);
if(!this->totalDurationQTime.isValid())
readable = false;
}
/**
*@brief Récupération de l'erreur si une a lieu.
*@param error Type d'erreur.
*/
void ThumbnailItem::manageError(QMediaPlayer::Error error)
{
readable = false;
}