Beispiel #1
0
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;
}
Beispiel #2
0
void Metadata::toMap(MetadataMap &metadataMap)
{
    metadataMap["artist"] = m_artist;
    metadataMap["formatartist"] = FormatArtist();
    metadataMap["compilationartist"] = m_compilation_artist;
    metadataMap["album"] = m_album;
    metadataMap["title"] = m_title;
    metadataMap["tracknum"] = (m_tracknum > 0 ? QString("%1").arg(m_tracknum) : "");
    metadataMap["genre"] = m_genre;
    metadataMap["year"] = (m_year > 0 ? QString("%1").arg(m_year) : "");
    metadataMap["artisttitle"] = QObject::tr("%1  by  %2",
                                 "Music track 'title by artist'")
                                 .arg(FormatTitle())
                                 .arg(FormatArtist());
    int len = m_length / 1000;
    int eh = len / 3600;
    int em = (len / 60) % 60;
    int es = len % 60;
    if (eh > 0)
        metadataMap["length"] = QString().sprintf("%d:%02d:%02d", eh, em, es);
    else
        metadataMap["length"] = QString().sprintf("%02d:%02d", em, es);

    QString dateFormat = gCoreContext->GetSetting("DateFormat", "ddd MMMM d");
    QString fullDateFormat = dateFormat;
    if (!fullDateFormat.contains("yyyy"))
        fullDateFormat += " yyyy";
    metadataMap["lastplayed"] = m_lastplay.toString(fullDateFormat);

    metadataMap["playcount"] = QString("%1").arg(m_playcount);
    metadataMap["filename"] = m_filename;
}
Beispiel #3
0
void ScriptEditorPane::UpdateStateInUI()
{
  wxString dbname;
  if (db) dbname = db->DbName();
  PQWXDatabaseEvent event(server, dbname, PQWX_ScriptStateUpdated);
  event.SetString(FormatTitle());
  event.SetEventObject(this);
  if (db) event.SetConnectionState(state);
  ProcessEvent(event);
}
Beispiel #4
0
void Metadata::getField(const QString &field, QString *data)
{
    if (field == "artist")
        *data = FormatArtist();
    else if (field == "album")
        *data = m_album;
    else if (field == "title")
        *data = FormatTitle();
    else if (field == "genre")
        *data = m_genre;
    else
    {
        LOG(VB_GENERAL, LOG_ERR, QString("Something asked me to return data "
                                         "about a field called %1").arg(field));
        *data = "I Dunno";
    }
}
Beispiel #5
0
  void FormatLabel(TCHAR *buffer, size_t buffer_size,
                   const Waypoint &way_point,
                   WaypointRenderer::Reachability reachable,
                   const ReachResult &reach) const {
    FormatTitle(buffer, buffer_size - 20, way_point);

    if (!way_point.IsLandable() && !way_point.flags.watched)
      return;

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::REQUIRED_GR) {
      if (!basic.location_available || !basic.NavAltitudeAvailable())
        return;

      const auto safety_height = task_behaviour.safety_height_arrival;
      const auto target_altitude = way_point.elevation + safety_height;
      const auto delta_h = basic.nav_altitude - target_altitude;
      if (delta_h <= 0)
        /* no L/D if below waypoint */
        return;

      const auto distance = basic.location.DistanceS(way_point.location);
      const auto gr = distance / delta_h;
      if (!GradientValid(gr))
        return;

      size_t length = _tcslen(buffer);
      if (length > 0)
        buffer[length++] = _T(':');
      StringFormatUnsafe(buffer + length, _T("%.1f"), (double) gr);
      return;
    }

    if (reachable == WaypointRenderer::Invalid)
      return;

    if (!reach.IsReachableDirect() && !way_point.flags.watched)
      return;

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::NONE)
      return;

    size_t length = _tcslen(buffer);
    int uah_glide = (int)Units::ToUserAltitude(reach.direct);
    int uah_terrain = (int)Units::ToUserAltitude(reach.terrain);

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::TERRAIN) {
      if (reach.IsReachableTerrain()) {
        if (length > 0)
          buffer[length++] = _T(':');
        StringFormatUnsafe(buffer + length, _T("%d%s"),
                           uah_terrain, altitude_unit);
      }
      return;
    }

    if (length > 0)
      buffer[length++] = _T(':');

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::GLIDE_AND_TERRAIN &&
        reach.IsReachableDirect() && reach.IsReachableTerrain() &&
        reach.IsDeltaConsiderable()) {
      StringFormatUnsafe(buffer + length, _T("%d/%d%s"), uah_glide,
                         uah_terrain, altitude_unit);
      return;
    }

    StringFormatUnsafe(buffer + length, _T("%d%s"), uah_glide, altitude_unit);
  }
Beispiel #6
0
  void
  FormatLabel(TCHAR *buffer, const Waypoint &way_point,
              const ReachResult &reach)
  {
    FormatTitle(buffer, way_point);

    if (!way_point.IsLandable() && !way_point.flags.watched)
      return;

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::REQUIRED_GR) {
      if (!basic.location_available || !basic.NavAltitudeAvailable())
        return;

      const fixed safety_height = task_behaviour.safety_height_arrival;
      const fixed target_altitude = way_point.elevation + safety_height;
      const fixed delta_h = basic.nav_altitude - target_altitude;
      if (!positive(delta_h))
        /* no L/D if below waypoint */
        return;

      const fixed distance = basic.location.Distance(way_point.location);
      const fixed gr = distance / delta_h;
      if (!GradientValid(gr))
        return;

      size_t length = _tcslen(buffer);
      if (length > 0)
        buffer[length++] = _T(':');
      _stprintf(buffer + length, _T("%.1f"), (double) gr);
      return;
    }

    if (!reach.IsReachableDirect() && !way_point.flags.watched)
      return;

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::NONE)
      return;

    size_t length = _tcslen(buffer);
    int uah_glide = (int)Units::ToUserAltitude(fixed(reach.direct));
    int uah_terrain = (int)Units::ToUserAltitude(fixed(reach.terrain));

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::TERRAIN) {
      if (reach.IsReachableTerrain()) {
        if (length > 0)
          buffer[length++] = _T(':');
        _stprintf(buffer + length, _T("%d%s"), uah_terrain, sAltUnit);
      }
      return;
    }

    if (length > 0)
      buffer[length++] = _T(':');

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::GLIDE_AND_TERRAIN &&
        reach.IsReachableDirect() && reach.IsReachableTerrain() &&
        reach.IsDeltaConsiderable()) {
      _stprintf(buffer + length, _T("%d/%d%s"), uah_glide,
                uah_terrain, sAltUnit);
      return;
    }

    _stprintf(buffer + length, _T("%d%s"), uah_glide, sAltUnit);
  }