Example #1
0
void EditMetadataDialog::saveAll()
{
    cancelPopup();

    if (GetMythDB()->GetNumSetting("AllowTagWriting", 0))
    {
        Decoder *decoder = Decoder::create(m_metadata->Filename(), NULL, NULL, true);
        if (decoder)
        {
            decoder->commitMetadata(m_metadata);
            delete decoder;
        }
    }

    saveToDatabase();
}
Example #2
0
void ImportMusicDialog::addPressed()
{
    if (m_tracks->size() == 0)
        return;

    Metadata *meta = m_tracks->at(m_currentTrack)->metadata;

    // is the current track a new file?
    if (m_tracks->at(m_currentTrack)->isNewTune)
    {
        // get the save filename - this also creates the correct directory stucture
        QString saveFilename = Ripper::filenameFromMetadata(meta);

        // we need to manually copy the file extension
        QFileInfo fi(meta->Filename());
        saveFilename += "." + fi.suffix();

        // copy the file to the new location
        if (!copyFile(meta->Filename(), saveFilename))
        {
            ShowOkPopup(tr("Copy Failed\nCould not copy file to: %1")
                                                        .arg(saveFilename));
            return;
        }

        meta->setFilename(saveFilename);

        // do we need to update the tags?
        if (m_tracks->at(m_currentTrack)->metadataHasChanged)
        {
            Decoder *decoder = Decoder::create(saveFilename, NULL, NULL, true);
            if (decoder)
            {
                decoder->commitMetadata(meta);
                delete decoder;
            }
        }

        // update the database
        meta->dumpToDatabase();

        // read any embedded images from the tag
        MetaIO *tagger = meta->getTagger();
        if (tagger && tagger->supportsEmbeddedImages())
        {
            AlbumArtList artList = tagger->getAlbumArtList(meta->Filename());
            meta->setEmbeddedAlbumArt(artList);
            meta->getAlbumArtImages()->dumpToDatabase();
        }

        m_somethingWasImported = true;

        m_tracks->at(m_currentTrack)->isNewTune = Ripper::isNewTune(
                meta->Artist(), meta->Album(), meta->Title());

        // update the UI
        fillWidgets();
    }
    else
        ShowOkPopup(tr("This track is already in the database"));
}