Beispiel #1
0
void
CollectionSetup::writeConfig()
{
    AmarokConfig::setCollectionFolders( m_dirs );
    AmarokConfig::setScanRecursively( recursive() );
    AmarokConfig::setMonitorChanges( monitor() );
    AmarokConfig::setImportPlaylists( importPlaylists() );
}
Beispiel #2
0
TreeItem* RhythmboxFeature::importMusicCollection() {
    qDebug() << "importMusicCollection Thread Id: " << QThread::currentThread();
     // Try and open the Rhythmbox DB. An API call which tells us where
     // the file is would be nice.
    QFile db(QDir::homePath() + "/.gnome2/rhythmbox/rhythmdb.xml");
    if (!db.exists()) {
        db.setFileName(QDir::homePath() + "/.local/share/rhythmbox/rhythmdb.xml");
        if (!db.exists()) {
            return NULL;
        }
    }

    if (!db.open(QIODevice::ReadOnly | QIODevice::Text))
        return NULL;

    //Delete all table entries of Traktor feature
    ScopedTransaction transaction(m_database);
    clearTable("rhythmbox_playlist_tracks");
    clearTable("rhythmbox_library");
    clearTable("rhythmbox_playlists");
    transaction.commit();

    transaction.transaction();
    QSqlQuery query(m_database);
    query.prepare("INSERT INTO rhythmbox_library (artist, title, album, year, "
                  "genre, comment, tracknumber, bpm, bitrate,"
                  "duration, location, rating ) "
                  "VALUES (:artist, :title, :album, :year, :genre, :comment, "
                  ":tracknumber, :bpm, :bitrate, :duration, :location, :rating )");


    QXmlStreamReader xml(&db);
    while (!xml.atEnd() && !m_cancelImport) {
        xml.readNext();
        if (xml.isStartElement() && xml.name() == "entry") {
            QXmlStreamAttributes attr = xml.attributes();
            //Check if we really parse a track and not album art information
            if (attr.value("type").toString() == "song") {
                importTrack(xml, query);
            }
        }
    }
    transaction.commit();

    if (xml.hasError()) {
        // do error handling
        qDebug() << "Cannot process Rhythmbox music collection";
        qDebug() << "XML ERROR: " << xml.errorString();
        return NULL;
    }

    db.close();
    if (m_cancelImport) {
        return NULL;
    }
    return importPlaylists();
}
Beispiel #3
0
void KNMusicPlaylist::onActionImportPlaylist()
{
    //Generate a file dialog.
    QFileDialog importPlaylists(this);
    //Set the file mode and the name filters.
    importPlaylists.setFileMode(QFileDialog::ExistingFiles);
    importPlaylists.setNameFilters(m_playlistManager->playlistFilter());
    //Launch the selector.
    if(importPlaylists.exec() &&
            !importPlaylists.selectedFiles().isEmpty())
    {
        //Import all the selected files to the playlist manager.
        QModelIndex firstPlaylistIndex=
            m_playlistManager->importPlaylists(importPlaylists.selectedFiles());
        //Check whether the index is valid.
        if(firstPlaylistIndex.isValid())
        {
            //Show that playlist.
            m_playlistList->showPlaylist(firstPlaylistIndex);
            //Make the container switch to the content widget.
            m_container->showContentWidget();
        }
    }
}