void TagDialog::fillSelected( KTRMResult selected ) //SLOT { #if HAVE_TUNEPIMP kdDebug() << k_funcinfo << endl; if ( m_bundle.url().path() == m_mbTrack ) { if ( !selected.title().isEmpty() ) kLineEdit_title->setText( selected.title() ); if ( !selected.artist().isEmpty() ) kComboBox_artist->setCurrentText( selected.artist() ); if ( !selected.album().isEmpty() ) kComboBox_album->setCurrentText( selected.album() ); if ( selected.track() != 0 ) kIntSpinBox_track->setValue( selected.track() ); if ( selected.year() != 0 ) kIntSpinBox_year->setValue( selected.year() ); } else { MetaBundle mb; mb.setPath( m_mbTrack ); if ( !selected.title().isEmpty() ) mb.setTitle( selected.title() ); if ( !selected.artist().isEmpty() ) mb.setArtist( selected.artist() ); if ( !selected.album().isEmpty() ) mb.setAlbum( selected.album() ); if ( selected.track() != 0 ) mb.setTrack( selected.track() ); if ( selected.year() != 0 ) mb.setYear( selected.year() ); storedTags.replace( m_mbTrack, mb ); } #endif }
void Reader::songListFinished( int /*id*/, bool error ) { ContentFetcher* http = (ContentFetcher*) sender(); disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( songListFinished( int, bool ) ) ); if( error ) { http->deleteLater(); return; } Map songResults = parse( http->results(), 0, true ); SongList result; QValueList<QVariant> songList; songList = songResults["adbs"].asList()[0].asMap()["mlcl"].asList()[0].asMap()["mlit"].asList(); debug() << "songList.count() = " << songList.count() << endl; QValueList<QVariant>::iterator it; for( it = songList.begin(); it != songList.end(); ++it ) { MetaBundle* bundle = new MetaBundle(); bundle->setTitle( (*it).asMap()["minm"].asList()[0].toString() ); //input url: daap://host:port/databaseId/music.ext bundle->setUrl( Amarok::QStringx("daap://%1:%2/%3/%4.%5").args( QStringList() << m_host << QString::number( m_port ) << m_databaseId << QString::number( (*it).asMap()["miid"].asList()[0].asInt() ) << (*it).asMap()["asfm"].asList()[0].asString() ) ); bundle->setLength( (*it).asMap()["astm"].asList()[0].toInt()/1000 ); bundle->setTrack( (*it).asMap()["astn"].asList()[0].toInt() ); QString album = (*it).asMap()["asal"].asList()[0].toString(); bundle->setAlbum( album ); QString artist = (*it).asMap()["asar"].asList()[0].toString(); bundle->setArtist( artist ); result[ artist.lower() ][ album.lower() ].append(bundle); bundle->setYear( (*it).asMap()["asyr"].asList()[0].toInt() ); bundle->setGenre( (*it).asMap()["asgn"].asList()[0].toString() ); } emit daapBundles( m_host , result ); http->deleteLater(); }
void TagDialog::applyToAllTracks() { const KURL::List::ConstIterator end = m_urlList.end(); for ( KURL::List::ConstIterator it = m_urlList.begin(); it != end; ++it ) { /* we have to update the values if they changed, so: 1) !kLineEdit_field->text().isEmpty() && kLineEdit_field->text() != mb.field i.e.: The user wrote something on the field, and it's different from what we have in the tag. 2) !m_bundle.field().isEmpty() && kLineEdit_field->text().isEmpty() i.e.: The user was shown some value for the field (it was the same for all selected tracks), and he deliberately emptied it. TODO: All this mess is because the dialog uses "" to represent what the user doesn't want to change, maybe we can think of something better? */ MetaBundle mb = bundleForURL( *it ); int changed = 0; if( !kComboBox_artist->currentText().isEmpty() && kComboBox_artist->currentText() != mb.artist() || kComboBox_artist->currentText().isEmpty() && !m_bundle.artist().isEmpty() ) { mb.setArtist( kComboBox_artist->currentText() ); changed |= TagDialog::TAGSCHANGED; } if( !kComboBox_album->currentText().isEmpty() && kComboBox_album->currentText() != mb.album() || kComboBox_album->currentText().isEmpty() && !m_bundle.album().isEmpty() ) { mb.setAlbum( kComboBox_album->currentText() ); changed |= TagDialog::TAGSCHANGED; } if( !kComboBox_genre->currentText().isEmpty() && kComboBox_genre->currentText() != mb.genre() || kComboBox_genre->currentText().isEmpty() && !m_bundle.genre().isEmpty() ) { mb.setGenre( kComboBox_genre->currentText() ); changed |= TagDialog::TAGSCHANGED; } if( !kTextEdit_comment->text().isEmpty() && kTextEdit_comment->text() != mb.comment() || kTextEdit_comment->text().isEmpty() && !m_bundle.comment().isEmpty() ) { mb.setComment( kTextEdit_comment->text() ); changed |= TagDialog::TAGSCHANGED; } if( !kComboBox_composer->currentText().isEmpty() && kComboBox_composer->currentText() != mb.composer() || kComboBox_composer->currentText().isEmpty() && !m_bundle.composer().isEmpty() ) { mb.setComposer( kComboBox_composer->currentText() ); changed |= TagDialog::TAGSCHANGED; } if( kIntSpinBox_year->value() && kIntSpinBox_year->value() != mb.year() || !kIntSpinBox_year->value() && m_bundle.year() ) { mb.setYear( kIntSpinBox_year->value() ); changed |= TagDialog::TAGSCHANGED; } if( kIntSpinBox_discNumber->value() && kIntSpinBox_discNumber->value() != mb.discNumber() || !kIntSpinBox_discNumber->value() && m_bundle.discNumber() ) { mb.setDiscNumber( kIntSpinBox_discNumber->value() ); changed |= TagDialog::TAGSCHANGED; } if( kIntSpinBox_score->value() && kIntSpinBox_score->value() != m_score || !kIntSpinBox_score->value() && m_score ) { m_score = kIntSpinBox_score->value(); changed |= TagDialog::SCORECHANGED; } storeTags( *it, changed, mb, m_score ); } }