]> git.tdb.fi Git - xinema.git/blob - remote/source/streamcontrolitem.cpp
a225d52494f2366c63494c7015de75706a48846b
[xinema.git] / remote / source / streamcontrolitem.cpp
1 #include "streamcontrolitem.h"
2 #include "xinemacontrolitem.h"
3
4 StreamControlItem::StreamControlItem():
5         control(0)
6 {
7 }
8
9 void StreamControlItem::set_control(XinemaControlItem *c)
10 {
11         if(control)
12                 disconnect(control, 0, this, 0);
13
14         control = c;
15         if(control)
16         {
17                 XinemaControl &xc = control->get_control();
18                 connect(&xc, &XinemaControl::title_changed, this, &StreamControlItem::title_changed);
19                 connect(&xc, &XinemaControl::duration_changed, this, &StreamControlItem::duration_changed);
20                 connect(&xc, &XinemaControl::position_changed, this, &StreamControlItem::position_changed);
21         }
22
23         emit control_changed();
24
25         if(control)
26         {
27                 emit title_changed();
28                 emit duration_changed();
29                 emit position_changed();
30         }
31 }
32
33 QString StreamControlItem::get_title() const
34 {
35         if(!control)
36                 return QString();
37
38         return control->get_control().get_title();
39 }
40
41 float StreamControlItem::get_duration() const
42 {
43         if(!control)
44                 return 0;
45
46         return control->get_control().get_duration();
47 }
48
49 float StreamControlItem::get_position() const
50 {
51         if(!control)
52                 return 0;
53
54         return control->get_control().get_position();
55 }