Ejemplo n.º 1
0
void TrackInfoObject::parse() {
    // Log parsing of header information in developer mode. This is useful for
    // tracking down corrupt files.
    const QString& canonicalLocation = m_fileInfo.canonicalFilePath();
    if (CmdlineArgs::Instance().getDeveloper()) {
        qDebug() << "TrackInfoObject::parse()" << canonicalLocation;
    }

    // Parse the information stored in the sound file.
    SoundSourceProxy proxy(canonicalLocation, m_pSecurityToken);
    Mixxx::SoundSource* pProxiedSoundSource = proxy.getProxiedSoundSource();
    if (pProxiedSoundSource != NULL && proxy.parseHeader() == OK) {

        // Dump the metadata extracted from the file into the track.

        // TODO(XXX): This involves locking the mutex for every setXXX
        // method. We should figure out an optimization where there are private
        // setters that don't lock the mutex.

        // If Artist, Title and Type fields are not blank, modify them.
        // Otherwise, keep their current values.
        // TODO(rryan): Should we re-visit this decision?
        if (!(pProxiedSoundSource->getArtist().isEmpty())) {
            setArtist(pProxiedSoundSource->getArtist());
        }

        if (!(pProxiedSoundSource->getTitle().isEmpty())) {
            setTitle(pProxiedSoundSource->getTitle());
        }

        if (!(pProxiedSoundSource->getType().isEmpty())) {
            setType(pProxiedSoundSource->getType());
        }

        setAlbum(pProxiedSoundSource->getAlbum());
        setAlbumArtist(pProxiedSoundSource->getAlbumArtist());
        setYear(pProxiedSoundSource->getYear());
        setGenre(pProxiedSoundSource->getGenre());
        setComposer(pProxiedSoundSource->getComposer());
        setGrouping(pProxiedSoundSource->getGrouping());
        setComment(pProxiedSoundSource->getComment());
        setTrackNumber(pProxiedSoundSource->getTrackNumber());
        setReplayGain(pProxiedSoundSource->getReplayGain());
        setBpm(pProxiedSoundSource->getBPM());
        setDuration(pProxiedSoundSource->getDuration());
        setBitrate(pProxiedSoundSource->getBitrate());
        setSampleRate(pProxiedSoundSource->getSampleRate());
        setChannels(pProxiedSoundSource->getChannels());
        setKeyText(pProxiedSoundSource->getKey(),
                   mixxx::track::io::key::FILE_METADATA);
        setHeaderParsed(true);
    } else {
        qDebug() << "TrackInfoObject::parse() error at file"
                 << canonicalLocation;
        setHeaderParsed(false);

        // Add basic information derived from the filename:
        parseFilename();
    }
}
Ejemplo n.º 2
0
 AlbumPart::AlbumPart(const AlbumPart& albumPart) :
 id(albumPart.getId()),
 pos(albumPart.getPos()),
 name(albumPart.getName()),
 albumId(albumPart.getAlbumId()),
 album(NULL) {
     if (albumPart.album) setAlbum(*albumPart.album);
 }
Ejemplo n.º 3
0
void Media::setAlbumAndUpdateRelations(const QSharedPointer<Media>& media, const QSharedPointer<Album>& album)
{
    QSharedPointer<Album> originalAlbum = media->album();
    if (setAlbum(album)) {
        if (originalAlbum) {
            originalAlbum->removeMedia(media);
        }
        album->addMedia(media);
    }
}
Ejemplo n.º 4
0
void EditMetadataDialog::searchAlbum()
{
    QString msg = tr("Select an Album");
    QStringList searchList = Metadata::fillFieldList("album");
    QString s = m_metadata->Album();

    MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
    MythUISearchDialog *searchDlg = new MythUISearchDialog(popupStack, msg, searchList, false, s);

    if (!searchDlg->Create())
    {
        delete searchDlg;
        return;
    }

    connect(searchDlg, SIGNAL(haveResult(QString)), SLOT(setAlbum(QString)));

    popupStack->AddScreen(searchDlg);
}
Ejemplo n.º 5
0
	void GraffitiTab::save ()
	{
		const auto& modified = FilesModel_->GetModified ();
		if (modified.isEmpty ())
			return;

		if (QMessageBox::question (this,
				"LMP Graffiti",
				tr ("Do you really want to accept changes to %n file(s)?", 0, modified.size ()),
				QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
			return;

		ITagResolver *resolver = LMPProxy_->GetTagResolver ();

		auto toTLStr = [] (const QString& str)
		{
			return TagLib::String (str.toUtf8 ().constData (), TagLib::String::UTF8);
		};

		for (const auto& pair : modified)
		{
			const auto& newInfo = pair.first;

			QMutexLocker locker (&resolver->GetMutex ());
			auto file = resolver->GetFileRef (newInfo.LocalPath_);
			auto tag = file.tag ();

			tag->setArtist (toTLStr (newInfo.Artist_));
			tag->setAlbum (toTLStr (newInfo.Album_));
			tag->setTitle (toTLStr (newInfo.Title_));
			tag->setYear (newInfo.Year_);
			tag->setGenre (toTLStr (newInfo.Genres_.join (" / ")));
			tag->setTrack (newInfo.TrackNumber_);

			if (!file.save ())
				qWarning () << Q_FUNC_INFO
						<< "unable to save file"
						<< newInfo.LocalPath_;
		}

		handleRereadFiles ();
	}
Ejemplo n.º 6
0
void
MetadataEditor::loadResult( const Tomahawk::result_ptr& result )
{
    if ( result.isNull() )
        return;

    m_result = result;
    setEditable( result->collection() && result->collection()->source()->isLocal() );

    setTitle( result->track()->track() );
    setArtist( result->track()->artist() );
    setAlbum( result->track()->album() );
    setAlbumPos( result->track()->albumpos() );
    setDuration( result->track()->duration() );
    setYear( result->track()->year() );
    setBitrate( result->bitrate() );

    if ( result->collection() && result->collection()->source()->isLocal() )
    {
        QString furl = m_result->url();
        if ( furl.startsWith( "file://" ) )
            furl = furl.right( furl.length() - 7 );

        QFileInfo fi( furl );
        setFileName( fi.absoluteFilePath() );
        setFileSize( TomahawkUtils::filesizeToString( fi.size() ) );
    }

    setWindowTitle( result->track()->track() );

    if ( m_interface )
    {
        m_index = m_interface->indexOfResult( result );

        if ( m_index >= 0 )
            enablePushButtons();
    }
}
Ejemplo n.º 7
0
void
MetadataEditor::loadQuery( const Tomahawk::query_ptr& query )
{
    if ( query.isNull() )
        return;

    if ( query->numResults() )
    {
        loadResult( query->results().first() );
        return;
    }

    m_result = Tomahawk::result_ptr();
    m_query = query;
    setEditable( false );

    setTitle( query->track()->track() );
    setArtist( query->track()->artist() );
    setAlbum( query->track()->album() );
    setAlbumPos( query->track()->albumpos() );
    setDuration( query->track()->duration() );
    setYear( 0 );
    setBitrate( 0 );

    setFileName( QString() );
    setFileSize( 0 );

    setWindowTitle( query->track()->track() );

    if ( m_interface )
    {
        m_index = m_interface->indexOfQuery( query );

        if ( m_index >= 0 )
            enablePushButtons();
    }
}
Ejemplo n.º 8
0
void ImportMusicDialog::showMenu()
{
    if (m_popupMenu)
        return;

    if (m_tracks->size() == 0)
        return;

    MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

    MythDialogBox *menu = new MythDialogBox("", popupStack, "importmusicmenu");

    if (menu->Create())
        popupStack->AddScreen(menu);
    else
    {
        delete menu;
        return;
    }

    menu->SetReturnEvent(this, "menu");
    menu->AddButton(tr("Save Defaults"), SLOT(saveDefaults()));

    if (m_haveDefaults)
    {
        menu->AddButton(tr("Change Compilation Flag"), SLOT(setCompilation()));
        menu->AddButton(tr("Change Compilation Artist"),
                                SLOT(setCompilationArtist()));
        menu->AddButton(tr("Change Artist"), SLOT(setArtist()));
        menu->AddButton(tr("Change Album"), SLOT(setAlbum()));
        menu->AddButton(tr("Change Genre"), SLOT(setGenre()));
        menu->AddButton(tr("Change Year"), SLOT(setYear()));
        menu->AddButton(tr("Change Rating"), SLOT(setRating()));
    }

    menu->AddButton(tr("Cancel"));
}
Ejemplo n.º 9
0
bool SoundSource::processTaglibFile(TagLib::File& f) {
    if (s_bDebugMetadata)
        qDebug() << "Parsing" << getFilename();

    if (f.isValid()) {
        TagLib::Tag *tag = f.tag();
        if (tag) {
            QString title = TStringToQString(tag->title());
            setTitle(title);

            QString artist = TStringToQString(tag->artist());
            setArtist(artist);

            QString album = TStringToQString(tag->album());
            setAlbum(album);

            QString comment = TStringToQString(tag->comment());
            setComment(comment);

            QString genre = TStringToQString(tag->genre());
            setGenre(genre);

            int iYear = tag->year();
            QString year = "";
            if (iYear > 0) {
                year = QString("%1").arg(iYear);
                setYear(year);
            }

            int iTrack = tag->track();
            QString trackNumber = "";
            if (iTrack > 0) {
                trackNumber = QString("%1").arg(iTrack);
                setTrackNumber(trackNumber);
            }

            if (s_bDebugMetadata)
                qDebug() << "TagLib" << "title" << title << "artist" << artist << "album" << album << "comment" << comment << "genre" << genre << "year" << year << "trackNumber" << trackNumber;
        }

        TagLib::AudioProperties *properties = f.audioProperties();
        if (properties) {
            int lengthSeconds = properties->length();
            int bitrate = properties->bitrate();
            int sampleRate = properties->sampleRate();
            int channels = properties->channels();

            if (s_bDebugMetadata)
                qDebug() << "TagLib" << "length" << lengthSeconds << "bitrate" << bitrate << "sampleRate" << sampleRate << "channels" << channels;

            setDuration(lengthSeconds);
            setBitrate(bitrate);
            setSampleRate(sampleRate);
            setChannels(channels);
        }

        // If we didn't get any audio properties, this was a failure.
        return (properties!=NULL);
    }
    return false;
}
Ejemplo n.º 10
0
bool ImportMusicDialog::keyPressEvent(QKeyEvent *event)
{
    if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
        return true;

    bool handled = false;
    QStringList actions;
    handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        if (action == "LEFT")
        {
            m_prevButton->Push();
        }
        else if (action == "RIGHT")
        {
            m_nextButton->Push();
        }
        else if (action == "EDIT")
        {
            showEditMetadataDialog();
        }
        else if (action == "MENU")
        {
            showMenu();
        }
        else if (action == "1")
        {
            setCompilation();
        }
        else if (action == "2")
        {
            setCompilationArtist();
        }
        else if (action == "3")
        {
            setArtist();
        }
        else if (action == "4")
        {
            setAlbum();
        }
        else if (action == "5")
        {
            setGenre();
        }
        else if (action == "6")
        {
            setYear();
        }
        else if (action == "7")
        {
            setRating();
        }
        else if (action == "8")
        {
            setTitleWordCaps();
        }
        else if (action == "9")
        {
            setTitleInitialCap();
        }
        else if (action == "0")
        {
            setTrack();
        }
        else
            handled = false;
    }

    if (!handled && MythScreenType::keyPressEvent(event))
        handled = true;

    return handled;
}
Ejemplo n.º 11
0
QSpotifyAlbumBrowse *QSpotifyAlbum::browse()
{
    auto browse = new QSpotifyAlbumBrowse();
    browse->setAlbum(shared_from_this());
    return browse;
}
Ejemplo n.º 12
0
        m_batchMode = true;
        foreach( TrackEditorPtr ec, m_editors ) ec->beginUpdate();
    }
    void endUpdate()
    {
        foreach( TrackEditorPtr ec, m_editors ) ec->endUpdate();
        m_batchMode = false;
        QTimer::singleShot( 0, m_collection, SLOT(slotUpdated()) );
    }
    void setComment( const QString &newComment ) { FORWARD( setComment( newComment ) ) }
    void setTrackNumber( int newTrackNumber ) { FORWARD( setTrackNumber( newTrackNumber ) ) }
    void setDiscNumber( int newDiscNumber ) { FORWARD( setDiscNumber( newDiscNumber ) ) }
    void setBpm( const qreal newBpm ) { FORWARD( setBpm( newBpm ) ) }
    void setTitle( const QString &newTitle ) { FORWARD( setTitle( newTitle ) ) }
    void setArtist( const QString &newArtist ) { FORWARD( setArtist( newArtist ) ) }
    void setAlbum( const QString &newAlbum ) { FORWARD( setAlbum( newAlbum ) ) }
    void setAlbumArtist( const QString &newAlbumArtist ) { FORWARD( setAlbumArtist ( newAlbumArtist ) ) }
    void setGenre( const QString &newGenre ) { FORWARD( setGenre( newGenre ) ) }
    void setComposer( const QString &newComposer ) { FORWARD( setComposer( newComposer ) ) }
    void setYear( int newYear ) { FORWARD( setYear( newYear ) ) }
private:
    bool m_batchMode;
    Collections::AggregateCollection *m_collection;
    QList<TrackEditorPtr> m_editors;
};

#undef FORWARD

AggregateTrack::AggregateTrack( Collections::AggregateCollection *coll, const TrackPtr &track )
        : Track()
        , Observer()