// Get a pixmap containing the current picture QPixmap PlayGround::getPicture() const { QPixmap result(editableArea.size()); QPainter artist(&result); QRect transEditableArea(editableArea); transEditableArea.moveBy(-XMARGIN, -YMARGIN); artist.translate(XMARGIN - editableArea.left(), YMARGIN - editableArea.top()); drawGameboard(artist, transEditableArea); return result; }
void EchonestPlugin::getArtistTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData ) { if( !isValidArtistData( requestData ) ) return; Echonest::Artist artist( requestData.input.toString() ); QNetworkReply* reply = artist.fetchTerms( Echonest::Artist::Weight ); reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); connect( reply, SIGNAL( finished() ), SLOT( getArtistTermsSlot() ) ); }
AudioFile parseAudioFile(QJsonObject const &obj) { QString artist(obj[QString("artist")].toString()); QString title(obj[QString("title")].toString()); unsigned duration = obj[(QString("duration"))].toInt(); QUrl url(obj[QString("url")].toString()); qDebug() << url; AudioFile audio = { artist, title, duration, url }; return audio; }
void SoundItem::slotMediaStateChanged(Phonon::State newstate, Phonon::State /*oldstate*/) { if ( newstate == Phonon::ErrorState ) { KMessageBox::detailedError( (QWidget*)(this), i18n("%1 is damaged and may not be playable.", m_url.fileName()), m_mediaObject->errorString(), i18n("Phonon error") ); m_artist = m_url.fileName(); m_title = i18n("This file is damaged and may not be playable."); setText(artist().append(" - ").append(title())); setBackground(QBrush(Qt::red)); setForeground(QBrush(Qt::white)); QFont errorFont = font(); errorFont.setBold(true); errorFont.setItalic(true); setFont(errorFont); return; } if ( newstate != Phonon::StoppedState ) return; long int total = m_mediaObject->totalTime(); int hours = (int)(total / (long int)( 60 * 60 * 1000 )); int mins = (int)((total / (long int)( 60 * 1000 )) - (long int)(hours * 60)); int secs = (int)((total / (long int)1000) - (long int)(hours * 60 * 60) - (long int)(mins * 60)); m_totalTime = QTime(hours, mins, secs); m_artist = (m_mediaObject->metaData(Phonon::ArtistMetaData)).join(","); m_title = (m_mediaObject->metaData(Phonon::TitleMetaData)).join(","); if ( m_artist.isEmpty() && m_title.isEmpty() ) setText(m_url.fileName()); else setText(artist().append(" - ").append(title())); emit signalTotalTimeReady(m_url, m_totalTime); }
void EchonestPlugin::getArtistFamiliarity( const Tomahawk::InfoSystem::InfoRequestData &requestData ) { if( !isValidArtistData( requestData ) ) return; qDebug() << "Fetching artist familiarity!" << requestData.input; Echonest::Artist artist( requestData.input.toString() ); QNetworkReply* reply = artist.fetchFamiliarity(); reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); connect( reply, SIGNAL( finished() ), SLOT( getArtistFamiliaritySlot() ) ); }
void CLastFmPaneView::TrackChanged(LPCPlayListItem *item) { char *cArtist = Unicode2UTF8((LPWSTR)(*item)->GetArtist().c_str()); string artist(cArtist); LFArtist lfArtist; if (artist_getInfo(artist, lfArtist)) { cout << lfArtist.name << endl; } infoDisplay = UTF82Unicode( (LPSTR)lfArtist.bio.summary.c_str() ); }
MediaInfo LocalFileResolver::ResolveInfo (const QString& file) { const auto& modified = QFileInfo (file).lastModified (); { QReadLocker locker (&CacheLock_); if (Cache_.contains (file)) { const auto& pair = Cache_ [file]; if (pair.first == modified) return pair.second; } } QMutexLocker tlLocker (&TaglibMutex_); auto r = GetFileRef (file); auto tag = r.tag (); if (!tag) throw ResolveError (file, "failed to get file tags"); auto audio = r.audioProperties (); auto ftl = [] (const TagLib::String& str) { return QString::fromUtf8 (str.toCString (true)); }; auto genres = ftl (tag->genre ()).split ('/', QString::SkipEmptyParts); std::for_each (genres.begin (), genres.end (), [] (QString& genre) { genre = genre.trimmed (); }); MediaInfo info { file, ftl (tag->artist ()), ftl (tag->album ()), ftl (tag->title ()), genres, audio ? audio->length () : 0, static_cast<qint32> (tag->year ()), static_cast<qint32> (tag->track ()) }; { QWriteLocker locker (&CacheLock_); if (Cache_.size () > 200) Cache_.clear (); Cache_ [file] = qMakePair (modified, info); } return info; }
// Painting event void PlayGround::paintEvent( QPaintEvent *event ) { QPoint destination(event->rect().topLeft()), position(destination.x() - XMARGIN, destination.y() - YMARGIN); QRect area(position, QSize(event->rect().size())); QPixmap cache(gameboard.size()); QPainter artist(&cache); if (destination.x() < XMARGIN) destination.setX(XMARGIN); if (destination.y() < YMARGIN) destination.setY(YMARGIN); area = QRect(0, 0, gameboard.width(), gameboard.height()).intersect(area); if (area.isEmpty()) return; drawGameboard(artist, area); bitBlt(this, destination, &cache, area, Qt::CopyROP); }
QString RDLogLine::resolveWildcards(QString pattern) { pattern.replace("%n",QString().sprintf("%06u",cartNumber())); pattern.replace("%h",QString().sprintf("%d",effectiveLength())); pattern.replace("%g",groupName()); pattern.replace("%t",title()); pattern.replace("%a",artist()); pattern.replace("%l",album()); pattern.replace("%y",year().toString("yyyy")); pattern.replace("%b",label()); pattern.replace("%c",client()); pattern.replace("%e",agency()); pattern.replace("%m",composer()); pattern.replace("%p",publisher()); pattern.replace("%u",userDefined()); return pattern; }
void PlaylistModel::onQueryFinished() { QSparqlResult *result = static_cast<QSparqlResult*>(sender()); if (result->size() > 0) { result->next(); QSparqlResultRow row(result->current()); PlaylistTrack *track = m_tracks.at(result->property("trackIndex").toInt()); track->title = row.value("title").toString(); track->duration = row.value("duration").toLongLong(); QVariant artist(row.value("artist")); if (artist.isValid()) { track->artist = artist.toString(); } else { track->artist = tr("Unknown artist"); track->unknownArtist = true; } QVariant album(row.value("album")); if (album.isValid()) { track->album = album.toString(); } else { track->album = tr("Unknown album"); track->unknownAlbum = true; } } m_loadedTracks++; if (m_loadedTracks == m_tracks.size()) { m_loaded = true; emit loadedChanged(); beginResetModel(); m_rowCount = m_tracks.size(); endResetModel(); qDeleteAll(m_queries); m_queries.clear(); } }
QVariant ScrobblesModel::Scrobble::attribute( int index ) const { switch( index ) { case Artist: return artist(); case Title: return title(); case Album: return album(); case TimeStamp: return timestamp(); case Loved: return isLoved(); default: return QVariant(); } }
/* ** Called during each update of the main measure. ** */ void PlayerSpotify::UpdateData() { if (m_Initialized || CheckWindow()) { // Parse title and artist from window title WCHAR buffer[256]; if (GetWindowText(m_Window, buffer, 256) > 10) { std::wstring title = &buffer[10]; // Skip "Spotify - " std::wstring::size_type pos = title.find(L" \u2013 "); if (pos != std::wstring::npos) { std::wstring artist(title, 0, pos); pos += 3; // Skip " - " std::wstring track(title, pos); if (track != m_Title || artist != m_Artist) { m_State = STATE_PLAYING; m_Title = track; m_Artist = artist; ++m_TrackCount; if (m_Measures & MEASURE_LYRICS) { FindLyrics(); } } return; } } else if (IsWindow(m_Window)) { m_State = STATE_PAUSED; } else { ClearData(); m_Initialized = false; } } }
void DatabaseCommand_ShareTrack::postCommitHook() { if ( source()->isLocal() ) Servent::instance()->triggerDBSync(); if ( !m_query.isNull() ) return; QString myDbid = SourceList::instance()->getLocal()->nodeId(); QString sourceDbid = source()->nodeId(); if ( myDbid != m_recipient || sourceDbid == m_recipient ) return; //From here on, everything happens only on the recipient, and only if recipient!=source m_query = Tomahawk::Query::get( artist(), track(), QString() ); if ( m_query.isNull() ) return; Tomahawk::SocialAction action; action.action = "Inbox"; action.source = source(); action.value = true; //unlistened action.timestamp = timestamp(); QList< Tomahawk::SocialAction > actions; actions << action; m_query->setAllSocialActions( actions ); QMetaObject::invokeMethod( ViewManager::instance()->inboxModel(), "insertQuery", Qt::QueuedConnection, Q_ARG( const Tomahawk::query_ptr&, m_query ), Q_ARG( int, 0 ) /*row*/ ); //TODO: replace with a proper JobStatusItem if( ViewManager::instance()->currentPage() != ViewManager::instance()->inboxWidget() ) JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "%1 recommended %2 by %3" ) .arg( source()->friendlyName() ) .arg( m_query->track() ) .arg( m_query->artist() ) ) ); }
void EchonestPlugin::getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData &requestData ) { if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) { return; } InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >(); if ( !hash.contains( "artist" ) ) { return; } Echonest::Artist artist( hash["artist"] ); QNetworkReply *reply = artist.fetchBiographies(); reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); connect( reply, SIGNAL( finished() ), SLOT( getArtistBiographySlot() ) ); }
QString MetaBundle::infoByColumn( int column, bool pretty ) const { switch( column ) { case PlaylistItem::Filename: return filename(); case PlaylistItem::Title: return title(); case PlaylistItem::Artist: return artist(); case PlaylistItem::Album: return album(); case PlaylistItem::Year: return year(); case PlaylistItem::Comment: return comment(); case PlaylistItem::Genre: return genre(); case PlaylistItem::Track: return track(); case PlaylistItem::Directory: return directory(); case PlaylistItem::Length: return pretty ? prettyLength() : QString::number( length() ); case PlaylistItem::Bitrate: return pretty ? prettyBitrate() : QString::number( bitrate() ); case PlaylistItem::Type: return type( pretty ); } return QString::null; }
Beatmap BeatmapParser::parse_beatmap() { std::ifstream file(mFilename); if (file) { std::string title(read_value(file, "Title")); std::string artist(read_value(file, "Artist")); std::string version(read_value(file, "Version")); double overallDifficulty(std::stod(read_value(file, "OverallDifficulty"))); double sliderMultiplier(std::stod(read_value(file, "SliderMultiplier")) * 100); double sliderTickRate(std::stod(read_value(file, "SliderTickRate"))); std::vector<TimingSection> timingSections(read_timing_sections(file)); Beatmap beatmap(title, artist, version, overallDifficulty, sliderMultiplier, sliderTickRate, timingSections); add_hitobjects(file, beatmap); file.close(); return beatmap; } throw std::exception(("Could not open file: " + mFilename + ".").c_str()); }
//! ---- slot_send_fanart_info_request ----------------------------------------- void CHTBackdrops::requestInfo(int id) { //REMOVE ACENTOS E CARACTERES ESPECIAIS QString artistName = artist(); artistName = artistName.normalized(QString::NormalizationForm_D); artistName = artistName.replace(QRegExp("[^a-zA-Z0-9\\s]"), ""); //FIM REMOVE ACENTOS E CARACTERES ESPECIAIS CLog::log(LOG_INFO, "PROVIDER", "Requesting info for: '"+artistName+"'", "HTBackDrops"); QUrlQuery url("http://htbackdrops.org/api/"+apiKey()+"/searchXML/?"); url.addQueryItem("default_operator", "and"); url.addQueryItem("keywords", artistName); QObject *reply = CNetworkAccess::instance()->get(url.query()); _listRequests[reply] = id; CLog::log(LOG_DEBUG, "PROVIDER", "Connecting Signals", "HTBackDrops"); connect(reply, SIGNAL(data(QByteArray)), this, SLOT(parseInfo(QByteArray))); connect(reply, SIGNAL(error(QNetworkReply*)), this, SLOT(stopSearch())); }
//! ---- slot_send_fanart_info_request ----------------------------------------- void CPlexusArtist::requestInfo(int id) { //REMOVE ACENTOS E CARACTERES ESPECIAIS QString artistName = artist(); artistName = artistName.normalized(QString::NormalizationForm_D); artistName = artistName.replace(QRegExp("[^a-zA-Z0-9\\s]"), ""); //FIM REMOVE ACENTOS E CARACTERES ESPECIAIS CLog::log(LOG_INFO, "PROVIDER", "Requesting info for: '"+artistName+"'", "PlexusArtist"); QUrlQuery url("http://plexusdynamics.com/admin/api/getartist.php?"); url.addQueryItem("key", apiKey()); url.addQueryItem("artist", artistName); QObject *reply = CNetworkAccess::instance()->get(url.query()); _listRequests[reply] = id; CLog::log(LOG_DEBUG, "PROVIDER", "Connecting Signals", "PlexusArtist"); connect(reply, SIGNAL(data(QByteArray)), this, SLOT(parseInfo(QByteArray))); connect(reply, SIGNAL(error(QNetworkReply*)), this, SLOT(stopSearch())); }
void PresentationAudioListItem::showErrorDialog() { QMessageBox msgBox(QApplication::activeWindow()); msgBox.setWindowTitle(i18n("Error")); msgBox.setText(i18n("%1 may not be playable.", d->url.fileName())); msgBox.setDetailedText(d->mediaObject->errorString()); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); d->artist = d->url.fileName(); d->title = i18n("This file may not be playable."); setText(i18nc("artist - title", "%1 - %2", artist(), title())); setBackground(QBrush(Qt::red)); setForeground(QBrush(Qt::white)); QFont errorFont = font(); errorFont.setBold(true); errorFont.setItalic(true); setFont(errorFont); }
void TestMetaManager::read() { QString album("Album: " + _meta->album()); QString artist("Artist: " + _meta->artist()); QString artwork("Artwork: " + _meta->artwork()); QString copyright("Copyright: " + _meta->copyright()); QString description("Description: " + _meta->description()); QString encoder("Encoder: " + _meta->encoder()); QString genre("Genre: " + _meta->genre()); QString id("ID: " + _meta->id()); QString language("Language: " + _meta->language()); QString number("Number: " + QString().number(_meta->number())); QString publisher("Publisher: " + _meta->publisher()); QString rating("Rating: " + _meta->rating()); QString setting("Setting: " + _meta->setting()); QString title("Title: " + _meta->title()); QString url("Url: " + _meta->url()); QString year("Year: " + QString().number(_meta->year())); ui->labelMeta->setText(album + "\n" + artist + "\n" + artwork + "\n" + copyright + "\n" + description + "\n" + encoder + "\n" + genre + "\n" + id + "\n" + language + "\n" + number + "\n" + publisher + "\n" + rating + "\n" + setting + "\n" + title + "\n" + url + "\n" + year + "\n"); }
void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise) { std::string value; float fValue; if (XMLUtils::GetString(movie, "title", value)) SetTitle(value); if (XMLUtils::GetString(movie, "originaltitle", value)) SetOriginalTitle(value); if (XMLUtils::GetString(movie, "showtitle", value)) SetShowTitle(value); if (XMLUtils::GetString(movie, "sorttitle", value)) SetSortTitle(value); const TiXmlElement* node = movie->FirstChildElement("ratings"); if (node) { for (const TiXmlElement* child = node->FirstChildElement("rating"); child != nullptr; child = child->NextSiblingElement("rating")) { CRating r; std::string name; if (child->QueryStringAttribute("name", &name) != TIXML_SUCCESS) name = "default"; XMLUtils::GetFloat(child, "value", r.rating); XMLUtils::GetInt(child, "votes", r.votes); int max_value = 10; if ((child->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1) r.rating = r.rating / max_value * 10; // Normalise the Movie Rating to between 1 and 10 SetRating(r, name); bool isDefault = false; if ((child->QueryBoolAttribute("default", &isDefault) == TIXML_SUCCESS) && isDefault) m_strDefaultRating = name; } } else if (XMLUtils::GetFloat(movie, "rating", fValue)) { CRating r(fValue, 0); if (XMLUtils::GetString(movie, "votes", value)) r.votes = StringUtils::ReturnDigits(value); int max_value = 10; const TiXmlElement* rElement = movie->FirstChildElement("rating"); if (rElement && (rElement->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1) r.rating = r.rating / max_value * 10; // Normalise the Movie Rating to between 1 and 10 SetRating(r, "default"); m_strDefaultRating = "default"; } XMLUtils::GetInt(movie, "userrating", m_iUserRating); const TiXmlElement *epbookmark = movie->FirstChildElement("episodebookmark"); if (epbookmark) { XMLUtils::GetDouble(epbookmark, "position", m_EpBookmark.timeInSeconds); const TiXmlElement *playerstate = epbookmark->FirstChildElement("playerstate"); if (playerstate) { const TiXmlElement *value = playerstate->FirstChildElement(); if (value) m_EpBookmark.playerState << *value; } } else XMLUtils::GetDouble(movie, "epbookmark", m_EpBookmark.timeInSeconds); int max_value = 10; const TiXmlElement* urElement = movie->FirstChildElement("userrating"); if (urElement && (urElement->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1) m_iUserRating = m_iUserRating / max_value * 10; // Normalise the user Movie Rating to between 1 and 10 XMLUtils::GetInt(movie, "top250", m_iTop250); XMLUtils::GetInt(movie, "season", m_iSeason); XMLUtils::GetInt(movie, "episode", m_iEpisode); XMLUtils::GetInt(movie, "track", m_iTrack); XMLUtils::GetInt(movie, "displayseason", m_iSpecialSortSeason); XMLUtils::GetInt(movie, "displayepisode", m_iSpecialSortEpisode); int after=0; XMLUtils::GetInt(movie, "displayafterseason",after); if (after > 0) { m_iSpecialSortSeason = after; m_iSpecialSortEpisode = 0x1000; // should be more than any realistic episode number } if (XMLUtils::GetString(movie, "outline", value)) SetPlotOutline(value); if (XMLUtils::GetString(movie, "plot", value)) SetPlot(value); if (XMLUtils::GetString(movie, "tagline", value)) SetTagLine(value); if (XMLUtils::GetString(movie, "runtime", value) && !value.empty()) m_duration = GetDurationFromMinuteString(StringUtils::Trim(value)); if (XMLUtils::GetString(movie, "mpaa", value)) SetMPAARating(value); XMLUtils::GetInt(movie, "playcount", m_playCount); XMLUtils::GetDate(movie, "lastplayed", m_lastPlayed); if (XMLUtils::GetString(movie, "file", value)) SetFile(value); if (XMLUtils::GetString(movie, "path", value)) SetPath(value); const TiXmlElement* uniqueid = movie->FirstChildElement("uniqueid"); if (uniqueid == nullptr) { if (XMLUtils::GetString(movie, "id", value)) SetUniqueID(value); } else { for (; uniqueid != nullptr; uniqueid = uniqueid->NextSiblingElement("uniqueid")) { if (uniqueid->FirstChild()) { if (uniqueid->QueryStringAttribute("type", &value) == TIXML_SUCCESS) SetUniqueID(uniqueid->FirstChild()->ValueStr(), value); else SetUniqueID(uniqueid->FirstChild()->ValueStr()); bool isDefault; if ((uniqueid->QueryBoolAttribute("default", &isDefault) == TIXML_SUCCESS) && isDefault) m_strDefaultUniqueID = value; } } } if (XMLUtils::GetString(movie, "filenameandpath", value)) SetFileNameAndPath(value); if (XMLUtils::GetDate(movie, "premiered", m_premiered)) { m_bHasPremiered = true; } else { int year; if (XMLUtils::GetInt(movie, "year", year)) SetYear(year); } if (XMLUtils::GetString(movie, "status", value)) SetStatus(value); if (XMLUtils::GetString(movie, "code", value)) SetProductionCode(value); XMLUtils::GetDate(movie, "aired", m_firstAired); if (XMLUtils::GetString(movie, "album", value)) SetAlbum(value); if (XMLUtils::GetString(movie, "trailer", value)) SetTrailer(value); if (XMLUtils::GetString(movie, "basepath", value)) SetBasePath(value); size_t iThumbCount = m_strPictureURL.m_url.size(); std::string xmlAdd = m_strPictureURL.m_xml; const TiXmlElement* thumb = movie->FirstChildElement("thumb"); while (thumb) { m_strPictureURL.ParseElement(thumb); if (prioritise) { std::string temp; temp << *thumb; xmlAdd = temp+xmlAdd; } thumb = thumb->NextSiblingElement("thumb"); } // prioritise thumbs from nfos if (prioritise && iThumbCount && iThumbCount != m_strPictureURL.m_url.size()) { rotate(m_strPictureURL.m_url.begin(), m_strPictureURL.m_url.begin()+iThumbCount, m_strPictureURL.m_url.end()); m_strPictureURL.m_xml = xmlAdd; } std::vector<std::string> genres(m_genre); if (XMLUtils::GetStringArray(movie, "genre", genres, prioritise, g_advancedSettings.m_videoItemSeparator)) SetGenre(genres); std::vector<std::string> country(m_country); if (XMLUtils::GetStringArray(movie, "country", country, prioritise, g_advancedSettings.m_videoItemSeparator)) SetCountry(country); std::vector<std::string> credits(m_writingCredits); if (XMLUtils::GetStringArray(movie, "credits", credits, prioritise, g_advancedSettings.m_videoItemSeparator)) SetWritingCredits(credits); std::vector<std::string> director(m_director); if (XMLUtils::GetStringArray(movie, "director", director, prioritise, g_advancedSettings.m_videoItemSeparator)) SetDirector(director); std::vector<std::string> showLink(m_showLink); if (XMLUtils::GetStringArray(movie, "showlink", showLink, prioritise, g_advancedSettings.m_videoItemSeparator)) SetShowLink(showLink); const TiXmlElement* namedSeason = movie->FirstChildElement("namedseason"); while (namedSeason != nullptr) { if (namedSeason->FirstChild() != nullptr) { int seasonNumber; std::string seasonName = namedSeason->FirstChild()->ValueStr(); if (!seasonName.empty() && namedSeason->Attribute("number", &seasonNumber) != nullptr) m_namedSeasons.insert(std::make_pair(seasonNumber, seasonName)); } namedSeason = namedSeason->NextSiblingElement("namedseason"); } // cast node = movie->FirstChildElement("actor"); if (node && node->FirstChild() && prioritise) m_cast.clear(); while (node) { const TiXmlNode *actor = node->FirstChild("name"); if (actor && actor->FirstChild()) { SActorInfo info; info.strName = actor->FirstChild()->Value(); if (XMLUtils::GetString(node, "role", value)) info.strRole = StringUtils::Trim(value); XMLUtils::GetInt(node, "order", info.order); const TiXmlElement* thumb = node->FirstChildElement("thumb"); while (thumb) { info.thumbUrl.ParseElement(thumb); thumb = thumb->NextSiblingElement("thumb"); } const char* clear=node->Attribute("clear"); if (clear && stricmp(clear,"true")) m_cast.clear(); m_cast.push_back(info); } node = node->NextSiblingElement("actor"); } // Pre-Jarvis NFO file: // <set>A set</set> if (XMLUtils::GetString(movie, "set", value)) SetSet(value); // Jarvis+: // <set><name>A set</name><overview>A set with a number of movies...</overview></set> node = movie->FirstChildElement("set"); if (node) { // No name, no set if (XMLUtils::GetString(node, "name", value)) { SetSet(value); if (XMLUtils::GetString(node, "overview", value)) SetSetOverview(value); } } std::vector<std::string> tags(m_tags); if (XMLUtils::GetStringArray(movie, "tag", tags, prioritise, g_advancedSettings.m_videoItemSeparator)) SetTags(tags); std::vector<std::string> studio(m_studio); if (XMLUtils::GetStringArray(movie, "studio", studio, prioritise, g_advancedSettings.m_videoItemSeparator)) SetStudio(studio); // artists std::vector<std::string> artist(m_artist); node = movie->FirstChildElement("artist"); if (node && node->FirstChild() && prioritise) artist.clear(); while (node) { const TiXmlNode* pNode = node->FirstChild("name"); const char* pValue=NULL; if (pNode && pNode->FirstChild()) pValue = pNode->FirstChild()->Value(); else if (node->FirstChild()) pValue = node->FirstChild()->Value(); if (pValue) { const char* clear=node->Attribute("clear"); if (clear && stricmp(clear,"true")==0) artist.clear(); std::vector<std::string> newArtists = StringUtils::Split(pValue, g_advancedSettings.m_videoItemSeparator); artist.insert(artist.end(), newArtists.begin(), newArtists.end()); } node = node->NextSiblingElement("artist"); } SetArtist(artist); node = movie->FirstChildElement("fileinfo"); if (node) { // Try to pull from fileinfo/streamdetails/[video|audio|subtitle] const TiXmlNode *nodeStreamDetails = node->FirstChild("streamdetails"); if (nodeStreamDetails) { const TiXmlNode *nodeDetail = NULL; while ((nodeDetail = nodeStreamDetails->IterateChildren("audio", nodeDetail))) { CStreamDetailAudio *p = new CStreamDetailAudio(); if (XMLUtils::GetString(nodeDetail, "codec", value)) p->m_strCodec = StringUtils::Trim(value); if (XMLUtils::GetString(nodeDetail, "language", value)) p->m_strLanguage = StringUtils::Trim(value); XMLUtils::GetInt(nodeDetail, "channels", p->m_iChannels); StringUtils::ToLower(p->m_strCodec); StringUtils::ToLower(p->m_strLanguage); m_streamDetails.AddStream(p); } nodeDetail = NULL; while ((nodeDetail = nodeStreamDetails->IterateChildren("video", nodeDetail))) { CStreamDetailVideo *p = new CStreamDetailVideo(); if (XMLUtils::GetString(nodeDetail, "codec", value)) p->m_strCodec = StringUtils::Trim(value); XMLUtils::GetFloat(nodeDetail, "aspect", p->m_fAspect); XMLUtils::GetInt(nodeDetail, "width", p->m_iWidth); XMLUtils::GetInt(nodeDetail, "height", p->m_iHeight); XMLUtils::GetInt(nodeDetail, "durationinseconds", p->m_iDuration); if (XMLUtils::GetString(nodeDetail, "stereomode", value)) p->m_strStereoMode = StringUtils::Trim(value); if (XMLUtils::GetString(nodeDetail, "language", value)) p->m_strLanguage = StringUtils::Trim(value); StringUtils::ToLower(p->m_strCodec); StringUtils::ToLower(p->m_strStereoMode); StringUtils::ToLower(p->m_strLanguage); m_streamDetails.AddStream(p); } nodeDetail = NULL; while ((nodeDetail = nodeStreamDetails->IterateChildren("subtitle", nodeDetail))) { CStreamDetailSubtitle *p = new CStreamDetailSubtitle(); if (XMLUtils::GetString(nodeDetail, "language", value)) p->m_strLanguage = StringUtils::Trim(value); StringUtils::ToLower(p->m_strLanguage); m_streamDetails.AddStream(p); } } m_streamDetails.DetermineBestStreams(); } /* if fileinfo */ const TiXmlElement *epguide = movie->FirstChildElement("episodeguide"); if (epguide) { // DEPRECIATE ME - support for old XML-encoded <episodeguide> blocks. if (epguide->FirstChild() && strnicmp("<episodeguide", epguide->FirstChild()->Value(), 13) == 0) m_strEpisodeGuide = epguide->FirstChild()->Value(); else { std::stringstream stream; stream << *epguide; m_strEpisodeGuide = stream.str(); } } // fanart const TiXmlElement *fanart = movie->FirstChildElement("fanart"); if (fanart) { // we prioritise mixed-mode nfo's with fanart set if (prioritise) { std::string temp; temp << *fanart; m_fanart.m_xml = temp+m_fanart.m_xml; } else m_fanart.m_xml << *fanart; m_fanart.Unpack(); } // resumePoint const TiXmlNode *resume = movie->FirstChild("resume"); if (resume) { XMLUtils::GetDouble(resume, "position", m_resumePoint.timeInSeconds); XMLUtils::GetDouble(resume, "total", m_resumePoint.totalTimeInSeconds); } XMLUtils::GetDateTime(movie, "dateadded", m_dateAdded); }
bool ID3v1Tag::read ( XMP_IO* file, SXMPMeta* meta ) { // Returns true if ID3v1 (or v1.1) exists, otherwise false, sets XMP properties en route. if ( file->Length() <= 128 ) return false; // ensure sufficient room file->Seek ( -128, kXMP_SeekFromEnd ); XMP_Uns32 tagID = XIO::ReadInt32_BE ( file ); tagID = tagID & 0xFFFFFF00; // wipe 4th byte if ( tagID != 0x54414700 ) return false; // must be "TAG" file->Seek ( -1, kXMP_SeekFromCurrent ); //rewind 1 XMP_Uns8 buffer[31]; // nothing is bigger here, than 30 bytes (offsets [0]-[29]) buffer[30] = 0; // wipe last byte std::string utf8string; file->ReadAll ( buffer, 30 ); std::string title ( (char*) buffer ); //security: guaranteed to 0-terminate after 30 bytes if ( ! title.empty() ) { ReconcileUtils::Latin1ToUTF8 ( title.c_str(), title.size(), &utf8string ); meta->SetLocalizedText ( kXMP_NS_DC, "title", "", "x-default", utf8string.c_str() ); } file->ReadAll ( buffer, 30 ); std::string artist( (char*) buffer ); if ( ! artist.empty() ) { ReconcileUtils::Latin1ToUTF8 ( artist.c_str(), artist.size(), &utf8string ); meta->SetProperty ( kXMP_NS_DM, "artist", utf8string.c_str() ); } file->ReadAll ( buffer, 30 ); std::string album( (char*) buffer ); if ( ! album.empty() ) { ReconcileUtils::Latin1ToUTF8 ( album.c_str(), album.size(), &utf8string ); meta->SetProperty ( kXMP_NS_DM, "album", utf8string.c_str() ); } file->ReadAll ( buffer, 4 ); buffer[4]=0; // ensure 0-term std::string year( (char*) buffer ); if ( ! year.empty() ) { // should be moot for a year, but let's be safe: ReconcileUtils::Latin1ToUTF8 ( year.c_str(), year.size(), &utf8string ); meta->SetProperty ( kXMP_NS_XMP, "CreateDate", utf8string.c_str() ); } file->ReadAll ( buffer, 30 ); std::string comment( (char*) buffer ); if ( ! comment.empty() ) { ReconcileUtils::Latin1ToUTF8 ( comment.c_str(), comment.size(), &utf8string ); meta->SetProperty ( kXMP_NS_DM, "logComment", utf8string.c_str() ); } if ( buffer[28] == 0 ) { XMP_Uns8 trackNo = buffer[29]; if ( trackNo > 0 ) { std::string trackStr; meta->SetProperty_Int ( kXMP_NS_DM, "trackNumber", trackNo ); } } XMP_Uns8 genreNo = XIO::ReadUns8 ( file ); if ( genreNo < numberedGenreCount ) { meta->SetProperty ( kXMP_NS_DM, "genre", kNumberedGenres[genreNo].name ); } else { char buffer[4]; // AUDIT: Big enough for UInt8. snprintf ( buffer, 4, "%d", genreNo ); XMP_Assert ( strlen(buffer) == 3 ); // Should be in the range 126..255. meta->SetProperty ( kXMP_NS_DM, "genre", buffer ); } return true; // ID3Tag found } // ID3v1Tag::read
void MetadataEditor::writeMetadata( bool closeDlg ) { if ( m_result ) { QFileInfo fi( QUrl( m_result->url() ).toLocalFile() ); bool changed = false; QByteArray fileName = QFile::encodeName( fi.canonicalFilePath() ); #ifdef Q_OS_WIN const wchar_t* encodedName = fi.canonicalFilePath().toStdWString().c_str(); #else const char* encodedName = fileName.constData(); #endif TagLib::FileRef f( encodedName ); QSharedPointer<Tomahawk::Tag> tag( Tomahawk::Tag::fromFile( f ) ); if ( title() != m_result->track()->track() ) { tDebug() << Q_FUNC_INFO << "Track changed" << title() << m_result->track(); tag->setTitle( title() ); m_result->track()->setTrack( title() ); changed = true; } Tomahawk::artist_ptr newArtist = Tomahawk::Artist::get( artist(), true ); if ( newArtist != m_result->track()->artistPtr() ) { tDebug() << Q_FUNC_INFO << "Artist changed" << artist() << m_result->track()->artist(); tag->setArtist( artist() ); m_result->track()->setArtist( artist() ); changed = true; } Tomahawk::album_ptr newAlbum = Tomahawk::Album::get( newArtist, album(), true ); if ( newAlbum != m_result->track()->albumPtr() ) { tDebug() << Q_FUNC_INFO << "Album changed" << album() << newAlbum->id() << m_result->track()->album() << m_result->track()->albumPtr()->id() << newAlbum.data() << m_result->track()->albumPtr().data(); if ( newAlbum->id() != m_result->track()->albumPtr()->id() ) { tag->setAlbum( album() ); m_result->track()->setAlbum( album() ); changed = true; } } // FIXME: Ugly workaround for the min value of 0 if ( albumPos() != 0 && albumPos() != (int)m_result->track()->albumpos() ) { tag->setTrack( albumPos() ); m_result->track()->setAlbumPos( albumPos() ); tDebug() << Q_FUNC_INFO << "Albumpos changed"; changed = true; } // FIXME: Ugly workaround for the min value of 1900 if ( year() != 1900 && year() != m_result->track()->year() ) { tag->setYear( year() ); { QVariantMap attr = m_result->track()->attributes(); attr[ "releaseyear" ] = year(); m_result->track()->setAttributes( attr ); } tDebug() << Q_FUNC_INFO << "Year changed"; changed = true; } if ( changed ) { f.save(); m_editFiles.append( fileName ); m_result->doneEditing(); tDebug() << Q_FUNC_INFO << m_result->toString() << m_result->track()->toString(); } } if ( closeDlg ) { if ( m_editFiles.count() ) ScanManager::instance()->runFileScan( m_editFiles, false ); close(); } }
QString RDLogLine::xml(int line) const { QString ret; #ifndef WIN32 ret+=" <logLine>\n"; ret+=" "+RDXmlField("line",line); ret+=" "+RDXmlField("id",id()); ret+=" "+RDXmlField("type",RDLogLine::typeText(type())); ret+=" "+RDXmlField("cartType",RDCart::typeText(cartType())); ret+=" "+RDXmlField("cartNumber",cartNumber()); ret+=" "+RDXmlField("cutNumber",cutNumber()); ret+=" "+RDXmlField("groupName",groupName()); ret+=" "+RDXmlField("groupColor",groupColor().name()); ret+=" "+RDXmlField("title",title()); ret+=" "+RDXmlField("artist",artist()); ret+=" "+RDXmlField("publisher",publisher()); ret+=" "+RDXmlField("composer",composer()); ret+=" "+RDXmlField("album",album()); ret+=" "+RDXmlField("label",label()); if(year().isValid()) { ret+=" "+RDXmlField("year",year().year()); } else { ret+=" "+RDXmlField("year"); } ret+=" "+RDXmlField("client",client()); ret+=" "+RDXmlField("agency",agency()); ret+=" "+RDXmlField("userDefined",userDefined()); ret+=" "+RDXmlField("usageCode",usageCode()); ret+=" "+RDXmlField("enforceLength",enforceLength()); ret+=" "+RDXmlField("forcedLength",RDGetTimeLength(forcedLength(),true)); ret+=" "+RDXmlField("evergreen",evergreen()); ret+=" "+RDXmlField("source",RDLogLine::sourceText(source())); ret+=" "+RDXmlField("timeType",RDLogLine::timeTypeText(timeType())); if(startTime(RDLogLine::Logged).isValid()&& (!startTime(RDLogLine::Logged).isNull())) { ret+=" "+RDXmlField("startTime",startTime(RDLogLine::Logged). toString("hh:mm:ss.zzz")); } else { ret+=" "+RDXmlField("startTime"); } ret+=" "+RDXmlField("transitionType",RDLogLine::transText(transType())); ret+=" "+RDXmlField("cutQuantity",cutQuantity()); ret+=" "+RDXmlField("lastCutPlayed",lastCutPlayed()); ret+=" "+RDXmlField("markerComment",markerComment()); ret+=" "+RDXmlField("markerLabel",markerLabel()); ret+=" "+RDXmlField("originUser",originUser()); ret+=" "+RDXmlField("originDateTime",originDateTime()); ret+=" "+RDXmlField("startPoint",startPoint(RDLogLine::CartPointer), "src=\"cart\""); ret+=" "+RDXmlField("startPoint",startPoint(RDLogLine::LogPointer), "src=\"log\""); ret+=" "+RDXmlField("endPoint",endPoint(RDLogLine::CartPointer), "src=\"cart\""); ret+=" "+RDXmlField("endPoint",endPoint(RDLogLine::LogPointer), "src=\"log\""); ret+=" "+RDXmlField("segueStartPoint", segueStartPoint(RDLogLine::CartPointer), "src=\"cart\""); ret+=" "+RDXmlField("segueStartPoint", segueStartPoint(RDLogLine::LogPointer),"src=\"log\""); ret+=" "+RDXmlField("segueEndPoint", segueEndPoint(RDLogLine::CartPointer), "src=\"cart\""); ret+=" "+RDXmlField("segueEndPoint", segueEndPoint(RDLogLine::LogPointer),"src=\"log\""); ret+=" "+RDXmlField("segueGain",segueGain()); ret+=" "+RDXmlField("fadeupPoint", fadeupPoint(RDLogLine::CartPointer),"src=\"cart\""); ret+=" "+RDXmlField("fadeupPoint", fadeupPoint(RDLogLine::LogPointer),"src=\"log\""); ret+=" "+RDXmlField("fadeupGain",fadeupGain()); ret+=" "+RDXmlField("fadedownPoint", fadedownPoint(RDLogLine::CartPointer),"src=\"cart\""); ret+=" "+RDXmlField("fadedownPoint", fadedownPoint(RDLogLine::LogPointer),"src=\"log\""); ret+=" "+RDXmlField("duckUpGain",duckUpGain()); ret+=" "+RDXmlField("duckDownGain",duckDownGain()); ret+=" "+RDXmlField("talkStartPoint",talkStartPoint()); ret+=" "+RDXmlField("talkEndPoint",talkEndPoint()); ret+=" "+RDXmlField("hookMode",hookMode()); ret+=" "+RDXmlField("hookStartPoint",hookStartPoint()); ret+=" "+RDXmlField("hookEndPoint",hookEndPoint()); ret+=" </logLine>\n"; #endif // WIN32 return ret; }
void QueryLabel::mouseMoveEvent( QMouseEvent* event ) { QFrame::mouseMoveEvent( event ); int x = event->x(); if ( event->buttons() & Qt::LeftButton && ( m_dragPos - event->pos() ).manhattanLength() >= QApplication::startDragDistance() ) { startDrag(); leaveEvent( 0 ); return; } if ( m_query.isNull() && m_result.isNull() ) { m_hoverArea = QRect(); m_hoverType = None; return; } const QFontMetrics& fm = fontMetrics(); int dashX = fm.width( DASH ); int artistX = m_type & Artist ? fm.width( artist() ) : 0; int albumX = m_type & Album ? fm.width( album() ) : 0; int trackX = m_type & Track ? fm.width( track() ) : 0; if ( m_type & Track ) { trackX += contentsMargins().left(); } if ( m_type & Album ) { trackX += albumX + dashX; albumX += contentsMargins().left(); } if ( m_type & Artist ) { albumX += artistX + dashX; trackX += artistX + dashX; artistX += contentsMargins().left(); } QRect hoverArea; m_hoverType = None; if ( m_type & Artist && x < artistX ) { m_hoverType = Artist; hoverArea.setLeft( 0 ); hoverArea.setRight( artistX + contentsMargins().left() - 1 ); } else if ( m_type & Album && x < albumX && x > artistX ) { m_hoverType = Album; int spacing = ( m_type & Artist ) ? dashX : 0; hoverArea.setLeft( artistX + spacing ); hoverArea.setRight( albumX + spacing + contentsMargins().left() - 1 ); } else if ( m_type & Track && x < trackX && x > albumX ) { m_hoverType = Track; int spacing = ( m_type & Album ) ? dashX : 0; hoverArea.setLeft( albumX + spacing ); hoverArea.setRight( trackX + contentsMargins().left() - 1 ); } if ( hoverArea.width() ) { hoverArea.setY( 1 ); hoverArea.setHeight( height() - 2 ); } if ( hoverArea != m_hoverArea ) { m_hoverArea = hoverArea; repaint(); } }
void QueryLabel::paintEvent( QPaintEvent* event ) { QFrame::paintEvent( event ); QPainter p( this ); QRect r = contentsRect(); QString s = text(); const QString elidedText = fontMetrics().elidedText( s, mode, r.width() ); p.save(); p.setRenderHint( QPainter::Antialiasing ); if ( m_hoverArea.width() ) { if ( elidedText != s ) { m_hoverArea.setLeft( 0 ); m_hoverArea.setRight( fontMetrics().width( elidedText ) + contentsMargins().left() * 2 ); m_hoverType = Track; } p.setPen( palette().mid().color() ); p.setBrush( palette().highlight() ); p.drawRoundedRect( m_hoverArea, 4.0, 4.0 ); } if ( elidedText != s || ( m_result.isNull() && m_query.isNull() ) ) { if ( m_hoverArea.width() ) { p.setPen( palette().highlightedText().color() ); p.setBrush( palette().highlight() ); } else { p.setBrush( palette().window() ); p.setPen( palette().color( foregroundRole() ) ); } p.drawText( r, align, elidedText ); } else { const QFontMetrics& fm = fontMetrics(); int dashX = fm.width( DASH ); int artistX = m_type & Artist ? fm.width( artist() ) : 0; int albumX = m_type & Album ? fm.width( album() ) : 0; int trackX = m_type & Track ? fm.width( track() ) : 0; if ( m_type & Artist ) { p.setBrush( palette().window() ); p.setPen( palette().color( foregroundRole() ) ); if ( m_hoverType == Artist ) { p.setPen( palette().highlightedText().color() ); p.setBrush( palette().highlight() ); } p.drawText( r, align, artist() ); r.adjust( artistX, 0, 0, 0 ); } if ( m_type & Album ) { p.setBrush( palette().window() ); p.setPen( palette().color( foregroundRole() ) ); if ( m_type & Artist ) { p.drawText( r, align, DASH ); r.adjust( dashX, 0, 0, 0 ); } if ( m_hoverType == Album ) { p.setPen( palette().highlightedText().color() ); p.setBrush( palette().highlight() ); } p.drawText( r, align, album() ); r.adjust( albumX, 0, 0, 0 ); } if ( m_type & Track ) { p.setBrush( palette().window() ); p.setPen( palette().color( foregroundRole() ) ); if ( m_type & Artist || m_type & Album ) { p.drawText( r, align, DASH ); r.adjust( dashX, 0, 0, 0 ); } if ( m_hoverType == Track ) { p.setPen( palette().highlightedText().color() ); p.setBrush( palette().highlight() ); } p.drawText( r, align, track() ); r.adjust( trackX, 0, 0, 0 ); } } p.restore(); }
// --- void DragonWindGame::walkNinja (int r) { ((DragonNinjaArtist*) artist (_DRAGONNINJAARTIST)) -> walk (r); }
// --- void DragonWindGame::climbNinja (int u) { ((DragonNinjaArtist*) artist (_DRAGONNINJAARTIST)) -> climb (u); }
// --- void DragonWindGame::jumpNinja () { ((DragonNinjaArtist*) artist (_DRAGONNINJAARTIST)) -> jump (); }
// --- void DragonWindGame::fightNinja (bool f) { ((DragonNinjaArtist*) artist (_DRAGONNINJAARTIST)) -> fight (f); }