-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathknotsitem.cpp
More file actions
executable file
·181 lines (156 loc) · 4.26 KB
/
knotsitem.cpp
File metadata and controls
executable file
·181 lines (156 loc) · 4.26 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
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
#include "knots.h"
#include "knotsplayer.h"
#include "knotsitem.h"
#include <QDebug>
KnotsItem::KnotsItem(QObject *parent)
: QObject(parent)
, _id("")
, _mid("")
{
}
/**
* @author andy
* @desc Object to hold details of a knots item
*
* <item>
<id>12</id>
<name><![CDATA[101 - Death Has A Shadow]]></name>
<path><![CDATA[C:/Users/andy/Videos/Family Guy/Season 1/101 - Death Has A Shadow.avi]]></path>
<size>161716224</size>
<duration><![CDATA[00:22:32]]></duration>
<added><![CDATA[2010-08-21]]></added>
<modified><![CDATA[2008-06-01]]></modified>
<views>3</views>
<position><![CDATA[00:00:00]]></position>
<rating>0</rating>
<info/>
<last_viewed/>
<directory_changed>2009-11-05T18:14:32+00:00</directory_changed>
<video_format><![CDATA[mpeg4]]></video_format>
<audio_format><![CDATA[tbr]]></audio_format>
<audio_bitrate><![CDATA[2 channels]]></audio_bitrate>
<aspect><![CDATA[4:3]]></aspect>
<width>640</width>
<height>480</height>
<category>1</category>
<active>1</active>
<mediatype>0</mediatype>
<params/><dreambox_url/>
<tracks/>
<mid>22</mid>
</item>
*
*/
KnotsItem::~KnotsItem(){
}
QString KnotsItem::getMediaType() {
return _mediaType;
}
void KnotsItem::setMediaType(QString &mediaType) {
_mediaType = mediaType;
}
QString KnotsItem::getMid() {
return _mid;
}
void KnotsItem::setMid(QString& mid) {
_mid = mid;
}
QString KnotsItem::getId() {
return _id;
}
void KnotsItem::setId(QString & id) {
_id = id;
}
QString KnotsItem::getDirectoryId() {
return _directoryId;
}
void KnotsItem::setDirectoryId(QString & directoryId) {
_directoryId = directoryId;
}
QString KnotsItem::getText() {
return _text;
}
int KnotsItem::getType() {
QStringList types;
types << "category" << "tag" << "value" << "name" << "dirname" << "virtual" << "server" << "button";
for (int i = 0; i < types.length(); i++)
{
if (_fields.contains(types[types.length() - 1 - i]))
{
_text = _fields.value(types[types.length() - 1 - i]);
_type = types.length() - 1 - i;
break;
}
}
return _type;
}
QUrl KnotsItem::getItemImage() {
return _itemImage;
}
void KnotsItem::setItemImage() {
if( _itemImage == QUrl() )
{
if( !( _mid == "" ) ) {
_itemImage = Knots::instance().serverAddress();
_itemImage.setPassword(Knots::instance().password());
_itemImage.setUserName(Knots::instance().userName());
_itemImage.addQueryItem("type","screenshot");
_itemImage.addQueryItem("mid",_mid);
_itemImage.addQueryItem("mediatype","0");
_itemImage.setPath("/root/resource_file");
} else {
if( _type == DIR ) {
_itemImage = "/qml/images/knots_dir.png";
} else if ( _type == SERVER ) {
_itemImage = "/qml/images/knots_item_server.png";
} else if (_type == ITEM) {
if( _mediaType == "" || _mediaType == "1" ) {
_itemImage = "/qml/images/knots_item_video.png";
} else {
_itemImage = "/qml/images/knots_item_music.png";
}
} else if( _type == CATEGORY || _type == VIRTUAL || _type == TAG ) {
_itemImage = "/qml/images/knots_dir.png";
}
}
}
}
QHash<QString, QString>& KnotsItem::getFields() {
return _fields;
}
void KnotsItem::retrieveData() {
(void)getType();
setItemImage();
}
QString KnotsItem::itemSelected()
{
QString newState = "Browsing";
switch( _type ) {
case SERVER:
/*
* knots.get_connection().select_server(get_item_id());
* knots.connect_server();
* */
break;
case DIR:
Knots::instance().browseByPath(_fields["dir"]);
break;
case VIRTUAL:
Knots::instance().browseVirtual(_fields["search"]);
break;
case CATEGORY:
Knots::instance().browseCategory(_id);
break;
case TAG:
Knots::instance().browseTags(_id);
break;
case ITEM:
newState = "Details";
break;
}
return newState;
}
bool KnotsItem::operator ==(const KnotsItem& rhs )
{
return _id==rhs._id;
}