ChannelGroupList ChannelGroup::GetChannelGroups(bool includeEmpty) { ChannelGroupList list; MSqlQuery query(MSqlQuery::InitCon()); QString qstr; if (includeEmpty) qstr = "SELECT grpid, name FROM channelgroupnames ORDER BY name"; else qstr = "SELECT DISTINCT t1.grpid, name FROM channelgroupnames t1,channelgroup t2 " "WHERE t1.grpid = t2.grpid ORDER BY name"; query.prepare(qstr); if (!query.exec()) MythDB::DBError("ChannelGroup::GetChannelGroups", query); else { while (query.next()) { ChannelGroupItem group(query.value(0).toUInt(), query.value(1).toString()); list.push_back(group); } } return list; }
DTC::ChannelGroupList* Guide::GetChannelGroupList( bool bIncludeEmpty ) { ChannelGroupList list = ChannelGroup::GetChannelGroups(bIncludeEmpty); DTC::ChannelGroupList *pGroupList = new DTC::ChannelGroupList(); ChannelGroupList::iterator it; for (it = list.begin(); it < list.end(); ++it) { DTC::ChannelGroup *pGroup = pGroupList->AddNewChannelGroup(); FillChannelGroup(pGroup, (*it)); } return pGroupList; }
void ChannelGroupEditor::Load(void) { listbox->clearSelections(); ChannelGroupList changrplist; changrplist = ChannelGroup::GetChannelGroups(); ChannelGroupList::iterator it; for (it = changrplist.begin(); it < changrplist.end(); ++it) listbox->addSelection(it->name); listbox->addSelection(tr("(Create new group)"), "__CREATE_NEW_GROUP__"); listbox->setValue(lastValue); }
// Cycle through the available groups, then all channels // Will cycle through to end then return -1 // To signify all channels. int ChannelGroup::GetNextChannelGroup(const ChannelGroupList &sorted, int grpid) { // If no groups return -1 for all channels if (sorted.empty()) return -1; // If grpid is all channels (-1), then return the first grpid if (grpid == -1) return sorted[0].grpid; ChannelGroupList::const_iterator it = find(sorted.begin(), sorted.end(), grpid); // If grpid is not in the list, return -1 for all channels if (it == sorted.end()) return -1; ++it; // If we reached the end, the next option is all channels (-1) if (it == sorted.end()) return -1; return it->grpid; }
void ChannelsResponder::replyGroups(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply) { QueryHandler q("/channels/groups", request); ChannelGroupList* channelGroupList; if ( q.isFormat(".json") ) { reply.addHeader("Content-Type", "application/json; charset=utf-8"); channelGroupList = (ChannelGroupList*)new JsonChannelGroupList(&out); } else if ( q.isFormat(".html") ) { reply.addHeader("Content-Type", "text/html; charset=utf-8"); channelGroupList = (ChannelGroupList*)new HtmlChannelGroupList(&out); } else if ( q.isFormat(".xml") ) { reply.addHeader("Content-Type", "text/xml; charset=utf-8"); channelGroupList = (ChannelGroupList*)new XmlChannelGroupList(&out); } else { reply.httpReturn(403, "Resources are not available for the selected format. (Use: .json, .html or .xml)"); return; } int start_filter = q.getOptionAsInt("start"); int limit_filter = q.getOptionAsInt("limit"); if ( start_filter >= 0 && limit_filter >= 1 ) { channelGroupList->activateLimit(start_filter, limit_filter); } channelGroupList->init(); int total = 0; for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) { if (channel->GroupSep()) { channelGroupList->addGroup((std::string)channel->Name()); total++; } } channelGroupList->setTotal(total); channelGroupList->finish(); delete channelGroupList; }