]> git.tdb.fi Git - xinema.git/blob - remote/source/browsedirectoryitem.cpp
Create an icon for the remote
[xinema.git] / remote / source / browsedirectoryitem.cpp
1 #include "browsedirectoryitem.h"
2 #include "xinemacontrol.h"
3 #include "xinemacontrolitem.h"
4
5 BrowseDirectoryItem::BrowseDirectoryItem():
6         control(0)
7 { }
8
9 void BrowseDirectoryItem::set_control(XinemaControlItem *c)
10 {
11         if(control)
12                 disconnect(&control->get_control(), 0, this, 0);
13
14         control = c;
15         if(control)
16         {
17                 XinemaControl &xc = control->get_control();
18                 connect(&xc, &XinemaControl::directory_started, this, &BrowseDirectoryItem::directory_started);
19                 connect(&xc, &XinemaControl::file_added, this, &BrowseDirectoryItem::file_added);
20                 connect(&xc, &XinemaControl::subdirectory_added, this, &BrowseDirectoryItem::subdirectory_added);
21         }
22
23         emit control_changed();
24 }
25
26 void BrowseDirectoryItem::set_directory(const QString &d)
27 {
28         if(d==directory)
29                 return;
30
31         directory = d;
32         if(control)
33                 control->get_control().list_directory(directory);
34         emit directory_changed();
35 }
36
37 void BrowseDirectoryItem::directory_started(const QString &dir)
38 {
39         if(dir!=directory)
40         {
41                 directory = dir;
42                 emit directory_changed();
43         }
44
45         model.clear();
46         if(directory!="/")
47                 model.add_entry("..", DirectoryModel::ParentDir);
48 }
49
50 void BrowseDirectoryItem::file_added(const QString &name)
51 {
52         model.add_entry(name, DirectoryModel::File);
53 }
54
55 void BrowseDirectoryItem::subdirectory_added(const QString &name)
56 {
57         model.add_entry(name, DirectoryModel::SubDir);
58 }