Commit a85c25c3 authored by Carsten Fuhrmann's avatar Carsten Fuhrmann

everything in correct order now

parent 49efc53a
......@@ -11,7 +11,7 @@
//#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
//#endif
struct channelInfo {
struct ChannelInfo {
uint64 id;
QString name;
uint64 parent;
......@@ -230,11 +230,11 @@ void OverlayController::displayChannelList()
return;
// get a list of all channels containing name, id, parent,..
QVector<channelInfo> channelList;
QVector<ChannelInfo> channelList;
int i(0);
while (channelIDList[i] != NULL)
{
channelInfo tmp;
ChannelInfo tmp;
tmp.id = channelIDList[i];
tmp.name = channelID2Name(m_SCHID, channelIDList[i]);
ts3.getChannelVariableAsInt(m_SCHID, tmp.id, CHANNEL_ORDER, &tmp.order);
......@@ -255,13 +255,36 @@ void OverlayController::displayChannelList()
i++;
}
// for every channel
for (auto &parent : channelList)
{
// collect all childs
QVector<ChannelInfo> childs;
for (auto &child : channelList)
if (child.parent == parent.id)
childs.push_back(child);
// add childs in correct order
int prevID(0);
while (!childs.isEmpty())
{
int i;
for (i = 0; i < childs.size(); i++)
if (childs[i].order == prevID)
break;
prevID = childs[i].id;
parent.entry->addChild(childs.takeAt(i).entry);
}
}
// get all toplvl channels
QVector<channelInfo> topLvlList;
QVector<ChannelInfo> topLvlList;
for (auto &it : channelList)
if (it.parent == 0)
topLvlList.push_back(it);
// sort the toplvl channels
// add toplvl to tree in correct order
int prevID = 0;
while(!topLvlList.isEmpty())
{
......@@ -274,31 +297,6 @@ void OverlayController::displayChannelList()
m_tree->getTree()->addTopLevelItem(topLvlList.takeAt(i).entry);
}
// build tree structure
for (auto& it : channelList)
{
if (it.parent == 0)
continue;
else
{
bool found(false);
for (auto& it2 : channelList)
{
if (it.parent == it2.id)
{
it2.entry->addChild(it.entry);
found = true;
break;
}
}
if (!found)
{
debugPrint(QString("%1: parent %2 not found").arg(it.name).arg(it.parent));
delete it.entry;
}
}
}
// insert clients
for (auto& it : channelList)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment