-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrecordinfo.cpp
More file actions
145 lines (113 loc) · 2.48 KB
/
recordinfo.cpp
File metadata and controls
145 lines (113 loc) · 2.48 KB
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
#include <QtCore>
#include "recordinfo.h"
RecordInfo::RecordInfo(QObject *parent) : QObject(parent), _downloadPercent(0), _status(Ready)
{
}
bool RecordInfo::operator ==(const RecordInfo& other)
{
return _title.compare(other._title) == 0 && _url.matches(other._url, QUrl::None) && _date == other._date;
}
QString RecordInfo::title() const
{
return _title;
}
QUrl RecordInfo::url() const
{
return _url;
}
QString RecordInfo::guid() const
{
return _guid;
}
QDateTime RecordInfo::date() const
{
return _date;
}
void RecordInfo::setTitle(QString arg)
{
if (_title == arg)
return;
_title = arg;
emit titleChanged(arg);
}
void RecordInfo::setUrl(QUrl arg)
{
if (_url == arg)
return;
_url = arg;
emit urlChanged(arg);
}
void RecordInfo::setGuid(QString arg)
{
if (_guid == arg)
return;
_guid = arg;
emit guidChanged(arg);
}
void RecordInfo::setDate(QString date)
{
// QString date = "Sat, 19 Apr 2014 22:30:00 +0000";
const QString format = "ddd, dd MMM yyyy hh:mm:ss";
// QLocale loc( QLocale::C );
// QDateTime result = loc.toDateTime(date, format);
_date = QDateTime::fromString(date.remove(QRegExp("(\\s[+]\\d\\d\\d\\d)")), format);
if(!_date.isValid())
qWarning() << date;
}
int RecordInfo::downloadPercent() const
{
return _downloadPercent;
}
RecordInfo::Status RecordInfo::status() const
{
return _status;
}
int RecordInfo::length() const
{
return _length;
}
QString RecordInfo::description() const
{
return _description;
}
void RecordInfo::setDate(QDateTime arg)
{
if (_date == arg)
return;
_date = arg;
emit dateChanged(arg);
}
void RecordInfo::setLength(int arg)
{
if (_length == arg)
return;
_length = arg;
emit lengthChanged(arg);
}
void RecordInfo::setDescription(QString arg)
{
if (_description == arg)
return;
_description = arg;
emit descriptionChanged(arg);
}
void RecordInfo::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
if(bytesTotal > 0)
setDownloadPercent(bytesReceived * 100/bytesTotal);
}
void RecordInfo::setDownloadPercent(int arg)
{
if (_downloadPercent == arg)
return;
_downloadPercent = arg;
emit downloadPercentChanged(arg);
setStatus(_downloadPercent == 100 ? Downloaded : Downloading);
}
void RecordInfo::setStatus(Status arg)
{
if (_status == arg)
return;
_status = arg;
emit statusChanged(arg);
}