Merge remote-tracking branch 'origin/pr/359'
This commit is contained in:
commit
a351279395
4 changed files with 53 additions and 2 deletions
13
src/idnode.c
13
src/idnode.c
|
@ -768,6 +768,17 @@ idclass_get_class (const idclass_t *idc)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
idclass_get_order (const idclass_t *idc)
|
||||
{
|
||||
while (idc) {
|
||||
if (idc->ic_class)
|
||||
return idc->ic_order;
|
||||
idc = idc->ic_super;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
ic_cmp ( const idclass_link_t *a, const idclass_link_t *b )
|
||||
{
|
||||
|
@ -816,6 +827,8 @@ idclass_serialize0(const idclass_t *idc, int optmask)
|
|||
htsmsg_add_str(m, "caption", s);
|
||||
if ((s = idclass_get_class(idc)))
|
||||
htsmsg_add_str(m, "class", s);
|
||||
if ((s = idclass_get_order(idc)))
|
||||
htsmsg_add_str(m, "order", s);
|
||||
|
||||
/* Props */
|
||||
if ((p = idnode_params(idc, NULL, optmask)))
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef struct idclass {
|
|||
const struct idclass *ic_super; /// Parent class
|
||||
const char *ic_class; /// Class name
|
||||
const char *ic_caption; /// Class description
|
||||
const char *ic_order; /// Property order (comma separated)
|
||||
const property_t *ic_properties; /// Property list
|
||||
const char *ic_event; /// Events to fire on add/delete/title
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ const idclass_t mpegts_service_class =
|
|||
.ic_super = &service_class,
|
||||
.ic_class = "mpegts_service",
|
||||
.ic_caption = "MPEGTS Service",
|
||||
.ic_order = "enabled,channel,svcname",
|
||||
.ic_properties = (const property_t[]){
|
||||
{
|
||||
.type = PT_STR,
|
||||
|
|
|
@ -121,6 +121,7 @@ tvheadend.IdNodeField = function (conf)
|
|||
this.store = null;
|
||||
if (this.enum)
|
||||
this.store = tvheadend.idnode_enum_store(this);
|
||||
this.ordered = false;
|
||||
|
||||
/*
|
||||
* Methods
|
||||
|
@ -245,10 +246,41 @@ tvheadend.IdNode = function (conf)
|
|||
this.clazz = conf.class;
|
||||
this.text = conf.caption || this.clazz;
|
||||
this.props = conf.props;
|
||||
this.fields = []
|
||||
this.order = [];
|
||||
this.fields = [];
|
||||
for (var i = 0; i < this.props.length; i++) {
|
||||
this.fields.push(new tvheadend.IdNodeField(this.props[i]));
|
||||
}
|
||||
var o = [];
|
||||
if (conf.order)
|
||||
o = conf.order.split(',');
|
||||
if (o) {
|
||||
while (o.length < this.fields.length)
|
||||
o.push(null);
|
||||
for (var i = 0; i < o.length; i++) {
|
||||
this.order[i] = null;
|
||||
if (o[i]) {
|
||||
for (var j = 0; j < this.fields.length; j++) {
|
||||
if (this.fields[j].id == o[i]) {
|
||||
this.order[i] = this.fields[j];
|
||||
this.fields[j].ordered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < o.length; i++) {
|
||||
if (this.order[i] == null) {
|
||||
for (var j = 0; j < this.fields.length; j++) {
|
||||
if (!this.fields[j].ordered) {
|
||||
this.fields[j].ordered = true;
|
||||
this.order[i] = this.fields[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Methods
|
||||
|
@ -257,6 +289,10 @@ tvheadend.IdNode = function (conf)
|
|||
this.length = function () {
|
||||
return this.fields.length;
|
||||
}
|
||||
|
||||
this.field = function ( index ) {
|
||||
if (this.order) return this.order[index]; else return this.fields[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -616,7 +652,7 @@ tvheadend.idnode_grid = function(panel, conf)
|
|||
/* Model */
|
||||
var idnode = new tvheadend.IdNode(d);
|
||||
for (var i = 0; i < idnode.length(); i++) {
|
||||
var f = idnode.fields[i];
|
||||
var f = idnode.field(i);
|
||||
var c = f.column();
|
||||
fields.push(f.id);
|
||||
columns.push(c);
|
||||
|
|
Loading…
Add table
Reference in a new issue