Ejemplo n.º 1
0
void StreamView::removeStream(void)
{
    MythUIButtonListItem *item = m_streamList->GetItemCurrent();
    if (item)
    {
        Metadata *mdata = qVariantValue<Metadata*> (item->GetData());

        ShowOkPopup(QString("Are you sure you want to delete this Stream?\n"
                            "Station:%1 - Channel: %2")
                            .arg(mdata->Station()).arg(mdata->Channel()),
                    this, SLOT(doRemoveStream(bool)), true);
    }
}
Ejemplo n.º 2
0
void SearchStream::updateStreams(void)
{
    m_streamList->Reset();

    QString station = m_stationList->GetValue();
    QString genre = m_genreList->GetValue();
    QString channel = m_channelEdit->GetText();

    bool searchStation = (station != tr("<All Stations>"));
    bool searchGenre = (genre != tr("<All Genres>"));
    bool searchChannel = !channel.isEmpty();

    QMap<QString, Metadata>::iterator it;

    for (it = m_streams.begin(); it != m_streams.end(); ++it)
    {
        Metadata *mdata = &(*it);

        if (searchStation && station != mdata->Station())
            continue;

        if (searchGenre && !mdata->Genre().contains(genre, Qt::CaseInsensitive))
            continue;

        if (searchChannel && !mdata->Channel().contains(channel, Qt::CaseInsensitive))
            continue;

        // if we got here we must have a match so add it to the list
        MythUIButtonListItem *item = new MythUIButtonListItem(m_streamList, 
                "", qVariantFromValue(mdata));

        MetadataMap metadataMap;
        mdata->toMap(metadataMap);
        item->SetTextFromMap(metadataMap);

        item->SetText(" ", "dummy");
    }

    m_matchesText->SetText(QString("%1").arg(m_streamList->GetCount()));
}
Ejemplo n.º 3
0
void SearchStream::loadStreams(void)
{
    m_streams.clear();
    m_stations.clear();
    m_genres.clear();

    m_stations.append(tr("<All Stations>"));
    m_genres.append(tr("<All Genres>"));

    QString filename = QString("%1%2").arg(GetShareDir()).arg("mythmusic/streams.xml");

    QFile xmlFile(filename);

    if (!xmlFile.exists() || !xmlFile.open(QIODevice::ReadOnly))
    {
        LOG(VB_GENERAL, LOG_ERR, "SearchStream: Cannot open streams.xml");
        return;
    }

    QString errorMsg;
    int errorLine = 0;
    int errorColumn = 0;

    QDomDocument domDoc;

    if (!domDoc.setContent(&xmlFile, false, &errorMsg,
                           &errorLine, &errorColumn))
    {
        LOG(VB_GENERAL, LOG_ERR,
            "SearchStream: Could not read content of streams.xml" +
                QString("\n\t\t\tError parsing %1").arg(filename) +
                QString("\n\t\t\tat line: %1  column: %2 msg: %3")
                .arg(errorLine).arg(errorColumn).arg(errorMsg));
        return;
    }

    QDomNodeList itemList = domDoc.elementsByTagName("item");

    QDomNode itemNode;
    for (int i = 0; i < itemList.count(); i++)
    {
        itemNode = itemList.item(i);

        Metadata mdata;
        mdata.setStation(itemNode.namedItem(QString("station")).toElement().text());
        mdata.setChannel(itemNode.namedItem(QString("channel")).toElement().text());
        mdata.setUrl(itemNode.namedItem(QString("url")).toElement().text());
        mdata.setLogoUrl(itemNode.namedItem(QString("logourl")).toElement().text());
        mdata.setGenre(itemNode.namedItem(QString("genre")).toElement().text());
        mdata.setMetadataFormat(itemNode.namedItem(QString("metadataformat")).toElement().text());

        m_streams.insert(mdata.Station() + '-' + mdata.Channel(), mdata);

        if (!m_stations.contains(mdata.Station()))
            m_stations.append(mdata.Station());

        QStringList genreList = mdata.Genre().split(',');

        for (int x = 0; x < genreList.count(); x++)
        {
            if (!m_genres.contains(genreList[x].trimmed()))
                m_genres.append(genreList[x].trimmed());
        }
    }

    xmlFile.close();

    m_stations.sort();
    m_genres.sort();
}