コード例 #1
0
ファイル: metadata.cpp プロジェクト: stunami/mythtv
void Metadata::toMap(MetadataMap &metadataMap, const QString &prefix)
{
    metadataMap[prefix + "artist"] = m_artist;
    metadataMap[prefix + "formatartist"] = FormatArtist();
    metadataMap[prefix + "compilationartist"] = m_compilation_artist;
    metadataMap[prefix + "album"] = m_album;
    metadataMap[prefix + "title"] = m_title;
    metadataMap[prefix + "formattitle"] = FormatTitle();
    metadataMap[prefix + "tracknum"] = (m_tracknum > 0 ? QString("%1").arg(m_tracknum) : "");
    metadataMap[prefix + "trackcount"] = (m_trackCount > 0 ? QString("%1").arg(m_trackCount) : "");
    metadataMap[prefix + "genre"] = m_genre;
    metadataMap[prefix + "year"] = (m_year > 0 ? QString("%1").arg(m_year) : "");

    int len = m_length / 1000;
    int eh = len / 3600;
    int em = (len / 60) % 60;
    int es = len % 60;
    if (eh > 0)
        metadataMap[prefix + "length"] = QString().sprintf("%d:%02d:%02d", eh, em, es);
    else
        metadataMap[prefix + "length"] = QString().sprintf("%02d:%02d", em, es);

    if (m_lastplay.isValid())
        metadataMap[prefix + "lastplayed"] = MythDateTimeToString(m_lastplay,
                                                kDateFull | kSimplify | kAddYear);
    else
        metadataMap[prefix + "lastplayed"] = QObject::tr("Never Played");

    metadataMap[prefix + "dateadded"] = MythDateTimeToString(m_dateadded,
                                              kDateFull | kSimplify | kAddYear);

    metadataMap[prefix + "playcount"] = QString::number(m_playcount);
    // FIXME we should use Filename() here but that will slow things down because of the hunt for the file
    metadataMap[prefix + "filename"] = gMusicData->musicDir + m_filename;
}
コード例 #2
0
ファイル: metadatacommon.cpp プロジェクト: drescherjm/mythtv
void MetadataLookup::toMap(MetadataMap &metadataMap)
{
    metadataMap["filename"] = m_filename;
    metadataMap["title"] = m_title;
    metadataMap["network"] = m_network;
    metadataMap["status"] = m_status;
    metadataMap["category"] = m_categories.join(", ");
    metadataMap["userrating"] = QString::number(m_userrating);
    metadataMap["ratingcount"] = QString::number(m_ratingcount);
    metadataMap["language"] = m_language;
    metadataMap["subtitle"] = m_subtitle;
    metadataMap["tagline"] = m_tagline;
    metadataMap["description"] = m_description;
    metadataMap["season"] = QString::number(m_season);
    metadataMap["episode"] = QString::number(m_episode);
    metadataMap["chanid"] = QString::number(m_chanid);
    metadataMap["channum"] = m_channum;
    metadataMap["callsign"] = m_chansign;
    metadataMap["channame"] = m_channame;
    metadataMap["playbackfilters"] = m_chanplaybackfilters;
    metadataMap["recgroup"] = m_recgroup;
    metadataMap["playgroup"] = m_playgroup;
    metadataMap["seriesid"] = m_seriesid;
    metadataMap["programid"] = m_programid;
    metadataMap["storagegroup"] = m_storagegroup;
    metadataMap["startts"] = MythDateTimeToString(m_startts, kDateFull);
    metadataMap["endts"] = MythDateTimeToString(m_endts, kDateFull);
    metadataMap["recstartts"] = MythDateTimeToString(m_recstartts, kDateFull);
    metadataMap["recendts"] = MythDateTimeToString(m_recendts, kDateFull);
    metadataMap["certification"] = m_certification;
    metadataMap["countries"] = m_countries.join(", ");
    metadataMap["popularity"] = QString::number(m_popularity);
    metadataMap["budget"] = QString::number(m_budget);
    metadataMap["revenue"] = QString::number(m_revenue);
    metadataMap["album"] = m_album;
    metadataMap["tracknum"] = QString::number(m_tracknum);
    metadataMap["system"] = m_system;
    metadataMap["year"] = QString::number(m_year);

    metadataMap["releasedate"] = MythDateToString(m_releasedate, kDateFull);
    metadataMap["lastupdated"] = MythDateTimeToString(m_lastupdated, kDateFull);

    metadataMap["runtime"] = QObject::tr("%n minute(s)", "", m_runtime);
    metadataMap["runtimesecs"] = QObject::tr("%n second(s)", "", m_runtimesecs);
    metadataMap["inetref"] = m_inetref;
    metadataMap["collectionref"] = m_collectionref;
    metadataMap["tmsref"] = m_tmsref;
    metadataMap["imdb"] = m_imdb;
    metadataMap["studios"] = m_studios.join(", ");
    metadataMap["homepage"] = m_homepage;
    metadataMap["trailer"] = m_trailerURL;
}
コード例 #3
0
void ProgFinder::updateTimesList()
{
    InfoMap infoMap;

    m_timesList->Reset();

    if (m_showData.size() > 0)
    {
        QString itemText;
        QDateTime starttime;
        for (uint i = 0; i < m_showData.size(); ++i)
        {
            starttime = m_showData[i]->GetScheduledStartTime();
            itemText = MythDateTimeToString(starttime,
                                            kDateTimeFull | kSimplify);

            MythUIButtonListItem *item =
                new MythUIButtonListItem(m_timesList, "");

            m_showData[i]->ToMap(infoMap);
            item->SetTextFromMap(infoMap);

            QString state = toUIState(m_showData[i]->GetRecordingStatus());
            item->SetText(itemText, "buttontext", state);
            item->DisplayState(state, "status");
        }
    }
}
コード例 #4
0
bool ManualSchedule::Create(void)
{
    if (!LoadWindowFromXML("schedule-ui.xml", "manualschedule", this))
        return false;

    m_channelList = dynamic_cast<MythUIButtonList *>(GetChild("channel"));
    m_startdateList = dynamic_cast<MythUIButtonList *>(GetChild("startdate"));

    m_starthourSpin = dynamic_cast<MythUISpinBox *>(GetChild("starthour"));
    m_startminuteSpin = dynamic_cast<MythUISpinBox *>(GetChild("startminute"));
    m_durationSpin = dynamic_cast<MythUISpinBox *>(GetChild("duration"));

    m_titleEdit = dynamic_cast<MythUITextEdit *>(GetChild("title"));

    m_recordButton = dynamic_cast<MythUIButton *>(GetChild("next"));
    m_cancelButton = dynamic_cast<MythUIButton *>(GetChild("cancel"));

    if (!m_channelList || !m_startdateList || !m_starthourSpin ||
        !m_startminuteSpin || !m_durationSpin || !m_titleEdit ||
        !m_recordButton || !m_cancelButton)
    {
        LOG(VB_GENERAL, LOG_ERR,
            "ManualSchedule, theme is missing required elements");
        return false;
    }

    QString chanorder = gCoreContext->GetSetting("ChannelOrdering", "channum");
    DBChanList channels = ChannelUtil::GetChannels(0, false, "channum,callsign");
    ChannelUtil::SortChannels(channels, chanorder);

    for (uint i = 0; i < channels.size(); i++)
    {
        QString chantext = channels[i].GetFormatted(DBChannel::kChannelLong);

        MythUIButtonListItem *item =
                            new MythUIButtonListItem(m_channelList, chantext);
        InfoMap infomap;
        channels[i].ToMap(infomap);
        item->SetTextFromMap(infomap);
        m_chanids.push_back(channels[i].chanid);
    }

    for (uint index = 0; index <= 60; index++)
    {
        QString dinfo = MythDateTimeToString(m_nowDateTime.addDays(index), kDateFull | kSimplify);
        if (m_nowDateTime.addDays(index).date().dayOfWeek() < 6)
            dinfo += QString(" (%1)").arg(tr("5 weekdays if daily"));
        else
            dinfo += QString(" (%1)").arg(tr("7 days per week if daily"));
        new MythUIButtonListItem(m_startdateList, dinfo);
        if (m_nowDateTime.addDays(index).toString("MMdd") ==
            m_startDateTime.toString("MMdd"))
            m_startdateList->SetItemCurrent(m_startdateList->GetCount() - 1);
    }

    QTime thisTime = m_nowDateTime.time();
    thisTime = thisTime.addSecs((30 - (thisTime.minute() % 30)) * 60);

    if (thisTime < QTime(0,30))
        m_startdateList->SetItemCurrent(m_startdateList->GetCurrentPos() + 1);

    m_starthourSpin->SetRange(0,23,1);
    m_starthourSpin->SetValue(thisTime.hour());
    int minute_increment =
        gCoreContext->GetNumSetting("ManualScheduleMinuteIncrement", 5);
    m_startminuteSpin->SetRange(0, 60-minute_increment, minute_increment);
    m_startminuteSpin->SetValue((thisTime.minute()/5)*5);
    m_durationSpin->SetRange(5,360,5);
    m_durationSpin->SetValue(60);

    connectSignals();
    connect(m_recordButton, SIGNAL(Clicked()), SLOT(recordClicked()));
    connect(m_cancelButton, SIGNAL(Clicked()), SLOT(Close()));

    m_titleEdit->SetMaxLength(128);

    BuildFocusList();

    return true;
}
コード例 #5
0
ファイル: recordingrule.cpp プロジェクト: drescherjm/mythtv
void RecordingRule::ToMap(InfoMap &infoMap) const
{
    infoMap["title"] = m_title;
    infoMap["subtitle"] = m_subtitle;
    infoMap["description"] = m_description;
    infoMap["season"] = QString::number(m_season);
    infoMap["episode"] = QString::number(m_episode);

    infoMap["category"] = m_category;
    infoMap["callsign"] = m_station;

    infoMap["starttime"] = MythTimeToString(m_starttime, kTime);
    infoMap["startdate"] = MythDateToString(m_startdate, kDateFull | kSimplify);
    infoMap["endtime"] = MythTimeToString(m_endtime, kTime);
    infoMap["enddate"] = MythDateToString(m_enddate, kDateFull | kSimplify);

    infoMap["inetref"] = m_inetref;
    infoMap["chanid"] = m_channelid;
    infoMap["channel"] = m_station;

    QDateTime startts(m_startdate, m_starttime);
    QDateTime endts(m_enddate, m_endtime);

    QString length;
    int hours, minutes, seconds;
    seconds = startts.secsTo(endts);

    minutes = seconds / 60;
    infoMap["lenmins"] = QObject::tr("%n minute(s)","",minutes);
    hours   = minutes / 60;
    minutes = minutes % 60;

    QString minstring = QObject::tr("%n minute(s)","",minutes);

    if (hours > 0)
    {
        infoMap["lentime"] = QString("%1 %2")
                                    .arg(QObject::tr("%n hour(s)","", hours))
                                    .arg(minstring);
    }
    else
        infoMap["lentime"] = minstring;


    infoMap["timedate"] = MythDateTimeToString(startts,
                                            kDateTimeFull | kSimplify) + " - " +
                          MythDateTimeToString(endts, kTime);

    infoMap["shorttimedate"] = MythDateTimeToString(startts,
                                            kDateTimeShort | kSimplify) + " - " +
                               MythDateTimeToString(endts, kTime);

    if (m_type == kFindDailyRecord || m_type == kFindWeeklyRecord)
    {
        QString findfrom = MythTimeToString(m_findtime, kTime);
        if (m_type == kFindWeeklyRecord)
        {
            int daynum = (m_findday + 5) % 7 + 1;
            findfrom = QString("%1, %2").arg(QDate::shortDayName(daynum))
                                        .arg(findfrom);
        }
        infoMap["subtitle"] = QObject::tr("(%1 or later) %3",
                                          "e.g. (Sunday or later) program "
                                          "subtitle").arg(findfrom)
                                          .arg(m_subtitle);
    }

    infoMap["searchtype"] = SearchTypeToString(m_searchType);
    if (m_searchType != kNoSearch)
        infoMap["searchforwhat"] = m_description;


    if (m_nextRecording.isValid())
        infoMap["nextrecording"] = MythDateTimeToString(m_nextRecording,
                                                        kDateFull | kAddYear);
    if (m_lastRecorded.isValid())
        infoMap["lastrecorded"] = MythDateTimeToString(m_lastRecorded,
                                                       kDateFull | kAddYear);
    if (m_lastDeleted.isValid())
        infoMap["lastdeleted"] = MythDateTimeToString(m_lastDeleted,
                                                      kDateFull | kAddYear);

    infoMap["ruletype"] = toString(m_type);
    infoMap["rectype"] = toString(m_type);
}
コード例 #6
0
    virtual bool ProcessRequest(HTTPRequest *pRequest)
    {
        if (!pRequest)
            return false;

        if (pRequest->m_sBaseUrl != "/")
            return false;

        if (pRequest->m_sMethod == "getDeviceDesc")
            return false;

        pRequest->m_eResponseType = ResponseTypeHTML;
        pRequest->m_mapRespHeaders["Cache-Control"] =
            "no-cache=\"Ext\", max-age = 5000";

        SSDPCacheEntries* cache = NULL;
        QString ipaddress = QString();
/*      QStringList::const_iterator sit = UPnp::g_IPAddrList.begin();
        for (; sit != UPnp::g_IPAddrList.end(); ++sit)
        {
            if (QHostAddress(*sit).protocol() == QAbstractSocket::IPv4Protocol)
            {
                ipaddress = *sit;
                break;
            }
        }*/
        if (!UPnp::g_IPAddrList.isEmpty())
            ipaddress = UPnp::g_IPAddrList.at(0);

        QString hostname   = gCoreContext->GetHostName();
        QDateTime qdtNow   = QDateTime::currentDateTime();
        QString masterhost = gCoreContext->GetMasterHostName();
        QString masterip   = gCoreContext->GetSetting("MasterServerIP");
        QString masterport = gCoreContext->GetSettingOnHost("BackendStatusPort",
                                                            masterhost, "6544");

        QTextStream stream ( &pRequest->m_response );
        stream.setCodec("UTF-8");

        stream
           << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
           << "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n"
           << "<html xmlns=\"http://www.w3.org/1999/xhtml\""
           << " xml:lang=\"en\" lang=\"en\">\r\n"
           << "<head>\r\n"
           << "  <meta http-equiv=\"Content-Type\""
           << "content=\"text/html; charset=UTF-8\" />\r\n"
           << "  <title>MythFrontend Status - "
           << MythDateTimeToString(qdtNow, kDateTimeShort) << " - "
           << MYTH_BINARY_VERSION << "</title>\r\n"
           << "  <link rel=\"stylesheet\" href=\"/css/site.css\"   type=\"text/css\">\r\n"
           << "  <link rel=\"stylesheet\" href=\"/css/Status.css\" type=\"text/css\">\r\n"
           << "</head>\r\n"
           << "<body>\r\n\r\n"
           << "  <h1 class=\"status\">MythFrontend Status</h1>\r\n";

        // This frontend
        stream
           << "  <div class=\"content\">\r\n"
           << "    <h2 class=\"status\">This Frontend</h2>\r\n"
           << "Name : " << hostname << "<br />\r\n"
           << "Version : " << MYTH_BINARY_VERSION << "\r\n"
           << "  </div>\r\n";

        // Other frontends

        // This will not work with multiple frontends on the same machine (upnp
        // setup will fail on a second frontend anyway) and the ip address
        // filtering of the current frontend may not work in all situations

        cache = SSDP::Find("urn:schemas-mythtv-org:service:MythFrontend:1");
        if (cache)
        {
            stream
               << "  <div class=\"content\">\r\n"
               << "    <h2 class=\"status\">Other Frontends</h2>\r\n";

            EntryMap map;
            cache->GetEntryMap(map);
            cache->Release();
            cache = NULL;

            QMapIterator< QString, DeviceLocation * > i(map);
            while (i.hasNext())
            {
                i.next();
                QUrl url(i.value()->m_sLocation);
                if (url.host() != ipaddress)
                {
                    stream << "<br />" << url.host() << "&nbsp(<a href=\""
                           << url.toString(QUrl::RemovePath)
                           << "\">Status page</a>)\r\n";
                }
                i.value()->Release();
            }
            stream << "  </div>\r\n";
        }

        // Master backend
        stream
           << "  <div class=\"content\">\r\n"
           << "    <h2 class=\"status\">MythTV Backends</h2>\r\n"
           << "Master: " << masterhost << "&nbsp(<a href=\"http://"
           << masterip << ":" << masterport
           << "\">Status page</a>)\r\n";

        // Slave backends
        cache = SSDP::Find("urn:schemas-mythtv-org:device:SlaveMediaServer:1");
        if (cache)
        {
            EntryMap map;
            cache->GetEntryMap(map);
            cache->Release();
            cache = NULL;

            QMapIterator< QString, DeviceLocation * > i(map);
            while (i.hasNext())
            {
                i.next();
                QUrl url(i.value()->m_sLocation);
                stream << "<br />" << "Slave: " << url.host()
                       << "&nbsp(<a href=\""
                       << url.toString(QUrl::RemovePath)
                       << "\">Status page</a>)\r\n";
                i.value()->Release();
            }
        }

        stream
           << "  </div>\r\n";

        stream
           << "  <div class=\"content\">\r\n"
           << "    <h2 class=\"status\">Services</h2>\r\n"
           << "    <a href=\"MythFE/GetRemote\">Remote Control</a>\r\n"
           << "  </div>\r\n";

        double load[3];
        if (getloadavg(load, 3) != -1)
        {
            stream
               << "  <div class=\"content\">\r\n"
               << "    <h2 class=\"status\">Machine Information</h2>\r\n"
               << "    <div class=\"loadstatus\">\r\n"
               << "      This machine's load average:"
               << "\r\n      <ul>\r\n        <li>"
               << "1 Minute: " << QString::number(load[0]) << "</li>\r\n"
               << "        <li>5 Minutes: " << QString::number(load[1]) << "</li>\r\n"
               << "        <li>15 Minutes: " << QString::number(load[2])
               << "</li>\r\n      </ul>\r\n"
               << "    </div>\r\n"
               << "  </div>\r\n";
        }

        stream << "</body>\r\n</html>\r\n";
        stream.flush();

        return true;
    }
コード例 #7
0
void RecordingSelector::updateRecordingList(void)
{
    if (!m_recordingList || m_recordingList->empty())
        return;

    m_recordingButtonList->Reset();

    if (m_categorySelector)
    {
        ProgramInfo *p;
        vector<ProgramInfo *>::iterator i = m_recordingList->begin();
        for ( ; i != m_recordingList->end(); ++i)
        {
            p = *i;

            if (p->GetTitle() == m_categorySelector->GetValue() ||
                m_categorySelector->GetValue() == tr("All Recordings"))
            {
                MythUIButtonListItem* item = new MythUIButtonListItem(
                    m_recordingButtonList,
                    p->GetTitle() + " ~ " +
                    p->GetScheduledStartTime().toString("dd MMM yy (hh:mm)"));
                item->setCheckable(true);
                if (m_selectedList.indexOf((ProgramInfo *) p) != -1)
                {
                    item->setChecked(MythUIButtonListItem::FullChecked);
                }
                else
                {
                    item->setChecked(MythUIButtonListItem::NotChecked);
                }

                QString title = p->GetTitle();
                QString subtitle = p->GetSubtitle();

                QDateTime recstartts = p->GetScheduledStartTime();
                QDateTime recendts   = p->GetScheduledEndTime();

                QString timedate = QString("%1 - %2")
                                   .arg(MythDateTimeToString
                                        (recstartts, kDateTimeFull))
                                   .arg(MythDateTimeToString(recendts, kTime));

                uint season = p->GetSeason();
                uint episode = p->GetEpisode();
                QString seasone, seasonx;

                if (season && episode)
                {
                    seasone = QString("s%1e%2")
                                .arg(GetDisplaySeasonEpisode(season, 2))
                                .arg(GetDisplaySeasonEpisode(episode, 2));
                    seasonx = QString("%1x%2")
                              .arg(GetDisplaySeasonEpisode(season, 1))
                              .arg(GetDisplaySeasonEpisode(episode, 2));
                }

                item->SetText(title, "title");
                item->SetText(subtitle, "subtitle");
                if (subtitle.isEmpty())
                    item->SetText(title, "titlesubtitle");
                else
                    item->SetText(title + " - \"" + subtitle + '"',
                                  "titlesubtitle");

                item->SetText(timedate, "timedate");
                item->SetText(p->GetDescription(), "description");
                item->SetText(formatSize(p->GetFilesize() / 1024),
                              "filesize_str");

                item->SetText(QString::number(season), "season");
                item->SetText(QString::number(episode), "episode");
                item->SetText(seasonx, "00x00");
                item->SetText(seasone, "s00e00");

                item->DisplayState(p->HasCutlist() ? "yes" : "no", "cutlist");

                item->SetData(qVariantFromValue(p));
            }
            qApp->processEvents();
        }
    }

    m_recordingButtonList->SetItemCurrent(m_recordingButtonList->GetItemFirst());
    titleChanged(m_recordingButtonList->GetItemCurrent());
}