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 )
{
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)))
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
.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,
this.store = null;
if (this.enum)
this.store = tvheadend.idnode_enum_store(this);
+ this.ordered = false;
/*
* Methods
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
this.length = function () {
return this.fields.length;
}
+
+ this.field = function ( index ) {
+ if (this.order) return this.order[index]; else return this.fields[index];
+ }
}
/* 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);