/
PlayListCollection.cpp
167 lines (132 loc) · 2.74 KB
/
PlayListCollection.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
#include "PlayListCollection.h"
/*!
\brief
\param name
*/
PlayListCollection::PlayListCollection(const QString& name) {
name_ = name;
if (name_.isEmpty()) {
name_ = defaultCollectionName();
}
}
/*!
\brief
\param name
*/
void PlayListCollection::setName(const QString& name) {
name_ = name;
}
/*!
\brief
\return QString
*/
QString PlayListCollection::name() const {
return name_;
}
/*!
\brief
\param playLists
*/
void PlayListCollection::setPlayLists(const QList<PlayList> &playLists) {
playLists_ = playLists;
}
/*!
\brief
\return QList<PlayList>
*/
QList<PlayList> PlayListCollection::playLists() const {
return playLists_;
}
/*!
\brief
\return QDir
*/
QDir PlayListCollection::outPutPath() const{
return outPutPath_;
}
/*!
\brief
\param outPutPath
*/
void PlayListCollection::setOutPutPath( const QDir &outPutPath ){
outPutPath_ = outPutPath;
}
/*!
\brief
\param other
\return bool PlayListCollection::operator
*/
bool PlayListCollection::operator ==(const PlayListCollection& other) const {
bool res = name_ == other.name();
res &= playLists_ == other.playLists();
res &= outPutPath_ == other.outPutPath();
res &= script_ == other.script();
return res;
}
/*!
\brief
\return PlayListCollection::operator
*/
PlayListCollection::operator QVariant() const {
return QVariant::fromValue(*this);
}
/*!
\brief
\param in
\param p
\return QDataStream & operator >>
*/
QDataStream& operator>>(QDataStream& in, PlayListCollection& p) {
bool ok;
QString log;
QString version = Global::versionCheck(&in, &ok, &log);
if (!ok) {
QMessageBox::critical(0, "", log);
}
if (version != "1.0") {
in.setStatus(QDataStream::ReadCorruptData);
return in;
}
QString name;
QList<PlayList> playLists;
QString outPutPath,script;
in >> name >> playLists >> outPutPath >> script;
p = PlayListCollection(name);
p.setPlayLists(playLists);
p.setOutPutPath(QDir(outPutPath));
p.setSCript(script);
return in;
}
/*!
\brief
\param out
\param p
\return QDataStream & operator
*/
QDataStream& operator<<(QDataStream& out, const PlayListCollection& p) {
out << out.version();
out << qApp->applicationVersion();
out << p.name() << p.playLists() << p.outPutPath().absolutePath() << p.script();
return out;
}
/*!
\brief
\return QString
*/
QString PlayListCollection::defaultCollectionName() {
return QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "/New collection" + Global::ext;
}
/*!
\brief
\param script
*/
void PlayListCollection::setSCript(const QString &script){
script_=script;
}
/*!
\brief
return QString
*/
QString PlayListCollection::script() const{
return script_;
}