Q_PROPERTY(QList<QVariantMap> mediaSourceList READ getMediaSourceList WRITE setMediaSourceList NOTIFY sigMediaSourceListChanged)
void TESTCPP::setMediaSourceList(QList<QVariantMap> mediaSourceList)
{
m_mediaSourceList.clear();
#if 1
//SRCInitMediaList represents the original media list
//SRCMediaList represents the list of transmitted media
struct SRCMediaList
{
std::string id;
std::string name;
std::string state;
};
struct SRCInitMediaList
{
std::string id;
std::string name;
std::string state;
};
std::vector<SRCMediaList> MediaList;
std::vector<SRCInitMediaList> InitMediaList;
SRCInitMediaList InitList;
InitList.id = "8";
InitList.name = " 8";
InitList.state =" ";
InitMediaList.push_back(InitList);
InitList.id = "6";
InitList.name = "6";
InitList.state =" ";
InitMediaList.push_back(InitList);
InitList.id = "13";
InitList.name = "13";
InitList.state =" ";
InitMediaList.push_back(InitList);
InitList.id = "1";
InitList.name = "1";
InitList.state =" ";
InitMediaList.push_back(InitList);
InitList.id = "2";
InitList.name = "2";
InitList.state =" ";
InitMediaList.push_back(InitList);
SRCMediaList src;
src.id = "8";
src.name = "8";
MediaList.push_back(src);
src.id = "6";
src.name = "6";
MediaList.push_back(src);
src.id = "13";
src.name = "13";
MediaList.push_back(src);
#endif
#if 0
//Assume unconnected data sources
src.id = "1";
src.name = "1";
MediaList.push_back(src);
src.id = "2";
src.name = "2";
MediaList.push_back(src);
#endif
for(int i=0; i< MediaList.size();i++)
{
if(MediaList.size()< InitMediaList.size())
{
InitMediaList[i].state ="0";
}
if(InitMediaList[i].name ==InitMediaList[i].name && InitMediaList[i].id == MediaList[i].id)
{
InitMediaList[i].state ="1";
}
}
for (unsigned int i= 0; i< InitMediaList.size(); i++)
{
QVariantMap srcInfo;
srcInfo["id"] = QString::fromStdString(InitMediaList[i].id);
srcInfo["name"] = QString::fromStdString(InitMediaList[i].name);
srcInfo["state"] = QString::fromStdString(InitMediaList[i].state);
m_mediaSourceList.push_back(srcInfo);
}
emit sigMediaSourceListChanged(m_mediaSourceList);
}
MenuList
{
id: mediaMainMenuList
anchors{
left: parent.left
top: parent.top
}
listViewScrollBarActive: false
ListModel: mediaSourceList
ListDelegate: TListItemTextWithIcon {
id: menuItemText
textValue: modelData.name
textColor: ""
height: 65
enabled: true
iconSource: {
var path = " "
switch(modelData.name)
{
case :
default:
break
}
return path
}
}
}