static void readTags(const char* fileName, tagVector& v) { if (fileName != 0) { ifstream f(fileName); if (f == 0) { cerr << "Could not open attribute file: " << fileName << endl; ::exit(1); } readTags(f, v); } else { readTags(cin, v); } }
inline void TagDialog::nextTrack() { if( m_playlistItem ) { if( !m_playlistItem->itemBelow() ) return; storeTags(); m_playlistItem = static_cast<PlaylistItem *>( m_playlistItem->itemBelow() ); loadTags( m_playlistItem->url() ); } else { storeTags( *m_currentURL ); KURL::List::iterator next = m_currentURL; ++next; if( next != m_urlList.end() ) ++m_currentURL; loadTags( *m_currentURL ); enableItems(); } readTags(); }
vector<KeyFrame> ModelLoaderMD3::loadKeyFrames(const FileName &fileName, const FileName &skinName, TextureFactory &textureFactory) const { FILE * stream = fopen(fileName.c_str(), "rb"); VERIFY(stream && !ferror(stream), "MD3 failed to open: "+fileName.str()); Header header = readHeader(stream); Frame *frames = readFrames(stream, header); Tag *tags = readTags(stream, header); Surface *surfaces = readSurfaces(stream, header); fclose(stream); vector<KeyFrame> keyFrames = buildKeyFrame(surfaces, fileName, skinName, header, textureFactory); delete [] frames; delete [] tags; delete [] surfaces; return keyFrames; }
AMD3Decoder::AMD3Decoder(const char *fname) : AMeshDecoder(fname) { init(); openFile(fname); readHeader(); /*if(!errorFlag)*/ readBFrames(); /*if(!errorFlag)*/ readTags(); /*if(!errorFlag)*/ readMeshes(); }
void CollectionScanner::scanFiles( const QStringList& entries ) { DEBUG_BLOCK typedef QPair<QString, QString> CoverBundle; QStringList validImages; validImages << "jpg" << "png" << "gif" << "jpeg"; QStringList validPlaylists; validPlaylists << "m3u" << "pls"; QValueList<CoverBundle> covers; QStringList images; foreachType( QStringList, entries ) { const QString path = *it; const QString ext = extension( path ); const QString dir = directory( path ); // Write path to logfile if( !m_logfile.isEmpty() ) { QFile log( m_logfile ); if( log.open( IO_WriteOnly ) ) log.writeBlock( path.local8Bit(), path.length() ); } if( validImages.contains( ext ) ) images += path; else if( m_importPlaylists && validPlaylists.contains( ext ) ) { AttributeMap attributes; attributes["path"] = path; writeElement( "playlist", attributes ); } else { MetaBundle::EmbeddedImageList images; MetaBundle mb( KURL::fromPathOrURL( path ), true, TagLib::AudioProperties::Fast, &images ); const AttributeMap attributes = readTags( mb ); if( !attributes.empty() ) { writeElement( "tags", attributes ); CoverBundle cover( attributes["artist"], attributes["album"] ); if( !covers.contains( cover ) ) covers += cover; foreachType( MetaBundle::EmbeddedImageList, images ) { AttributeMap attributes; attributes["path"] = path; attributes["hash"] = (*it).hash(); attributes["description"] = (*it).description(); writeElement( "embed", attributes ); } } }
MetaBundle::MetaBundle( const KURL &url, TagLib::AudioProperties::ReadStyle readStyle ) : m_url( url ) , m_exists( url.protocol() == "file" && QFile::exists( url.path() ) ) , m_isValidMedia( false ) //will be updated { if ( m_exists ) { m_isValidMedia = CollectionDB::instance()->bundleForUrl( this ); if ( !m_isValidMedia || length() <= 0 ) readTags( readStyle ); } else m_bitrate = m_length = m_sampleRate = Unavailable; }
inline void TagDialog::perTrack() { m_perTrack = !m_perTrack; if( m_perTrack ) { // just switched to per track mode applyToAllTracks(); setSingleTrackMode(); loadTags( *m_currentURL ); readTags(); } else { storeTags( *m_currentURL ); setMultipleTracksMode(); readMultipleTracks(); } enableItems(); }
int main(int argc, char **argv) { char* attributeFile = 0; char* outputFile = 0; while (--argc > 0 && (*++argv)[0] == '-') { switch (*(argv[0] + 1)) { case 'a': argc--; argv++; if (argc <= 0) usage(); attributeFile = *argv; break; case 'f': argc--; argv++; if (argc <= 0) usage(); outputFile = *argv; break; default: break; } } if (argc < 1) usage(); tagVector v; readTags(attributeFile, v); MDICOMWrapper w(*argv); dumpAttributes(w, v, outputFile); return 0; }
///PlaylistItem ctor /// NOT THREAD-SAFE!! MetaBundle::MetaBundle( const PlaylistItem *item ) : m_url ( item->url() ) , m_title ( item->title() ) //because you override text() , m_artist ( item->exactText( 2 ) ) //because you override text() , m_album ( item->exactText( 3 ) ) //etc. , m_year ( item->exactText( 4 ) ) //.. , m_comment( item->exactText( 5 ) ) //. , m_genre ( item->exactText( 6 ) ) , m_track ( item->exactText( 7 ) ) , m_exists ( true ) //FIXME , m_isValidMedia( true ) { if( m_url.protocol() == "file" ) readTags( TagLib::AudioProperties::Accurate ); else { // is a stream //FIXME not correct handling, say is ftp://file m_bitrate = item->exactText( 10 ).left( 3 ).toInt(); m_sampleRate = Undetermined; m_length = Irrelevant; } }
inline void TagDialog::previousTrack() { if( m_playlistItem ) { if( !m_playlistItem->itemAbove() ) return; storeTags(); m_playlistItem = static_cast<PlaylistItem *>( m_playlistItem->itemAbove() ); loadTags( m_playlistItem->url() ); } else { storeTags( *m_currentURL ); if( m_currentURL != m_urlList.begin() ) --m_currentURL; loadTags( *m_currentURL ); enableItems(); } readTags(); }
void TagDialog::init() { //NOTE We allocate on the stack in Playlist if( parent() != Playlist::instance()->qscrollview() ) setWFlags( getWFlags() | Qt::WDestructiveClose ); KConfig *config = amaroK::config( "TagDialog" ); kTabWidget->addTab( summaryTab, i18n( "Summary" ) ); kTabWidget->addTab( tagsTab, i18n( "Tags" ) ); kTabWidget->addTab( lyricsTab, i18n( "Lyrics" ) ); kTabWidget->addTab( statisticsTab, i18n( "Statistics" ) ); kTabWidget->setCurrentPage( config->readNumEntry( "CurrentTab", 0 ) ); const QStringList artists = CollectionDB::instance()->artistList(); kComboBox_artist->insertStringList( artists ); kComboBox_artist->completionObject()->insertItems( artists ); kComboBox_artist->completionObject()->setIgnoreCase( true ); kComboBox_artist->setCompletionMode( KGlobalSettings::CompletionPopup ); const QStringList albums = CollectionDB::instance()->albumList(); kComboBox_album->insertStringList( albums ); kComboBox_album->completionObject()->insertItems( albums ); kComboBox_album->completionObject()->setIgnoreCase( true ); kComboBox_album->setCompletionMode( KGlobalSettings::CompletionPopup ); const QStringList composers = CollectionDB::instance()->composerList(); kComboBox_composer->insertStringList( composers ); kComboBox_composer->completionObject()->insertItems( composers ); kComboBox_composer->completionObject()->setIgnoreCase( true ); kComboBox_composer->setCompletionMode( KGlobalSettings::CompletionPopup ); kComboBox_rating->insertStringList( MetaBundle::ratingList() ); // const QStringList genres = MetaBundle::genreList(); const QStringList genres = CollectionDB::instance()->genreList(); kComboBox_genre->insertStringList( genres ); kComboBox_genre->completionObject()->insertItems( genres ); kComboBox_genre->completionObject()->setIgnoreCase( true ); // looks better to have a blank label than 0, we can't do this in // the UI file due to bug in Designer kIntSpinBox_track->setSpecialValueText( " " ); kIntSpinBox_year->setSpecialValueText( " " ); kIntSpinBox_score->setSpecialValueText( " " ); kIntSpinBox_discNumber->setSpecialValueText( " " ); if( !AmarokConfig::useRatings() ) { kComboBox_rating->hide(); ratingLabel->hide(); } if( !AmarokConfig::useScores() ) { kIntSpinBox_score->hide(); scoreLabel->hide(); } //HACK due to deficiency in Qt that will be addressed in version 4 // QSpinBox doesn't emit valueChanged if you edit the value with // the lineEdit until you change the keyboard focus connect( kIntSpinBox_year->child( "qt_spinbox_edit" ), SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kIntSpinBox_track->child( "qt_spinbox_edit" ), SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kIntSpinBox_score->child( "qt_spinbox_edit" ), SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kIntSpinBox_discNumber->child( "qt_spinbox_edit" ), SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); // Connects for modification check connect( kLineEdit_title, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kComboBox_composer, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_artist, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_artist, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kComboBox_album, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_album, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kComboBox_genre, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_genre, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kComboBox_rating, SIGNAL(activated( int )), SLOT(checkModified()) ); connect( kComboBox_rating, SIGNAL(textChanged( const QString& )), SLOT(checkModified()) ); connect( kIntSpinBox_track,SIGNAL(valueChanged( int )), SLOT(checkModified()) ); connect( kIntSpinBox_year, SIGNAL(valueChanged( int )), SLOT(checkModified()) ); connect( kIntSpinBox_score,SIGNAL(valueChanged( int )), SLOT(checkModified()) ); connect( kTextEdit_comment,SIGNAL(textChanged()), SLOT(checkModified()) ); connect( kTextEdit_lyrics, SIGNAL(textChanged()), SLOT(checkModified()) ); // Remember original button text m_buttonMbText = pushButton_musicbrainz->text(); connect( pushButton_cancel, SIGNAL(clicked()), SLOT(cancelPressed()) ); connect( pushButton_ok, SIGNAL(clicked()), SLOT(accept()) ); connect( pushButton_open, SIGNAL(clicked()), SLOT(openPressed()) ); connect( pushButton_previous, SIGNAL(clicked()), SLOT(previousTrack()) ); connect( pushButton_next, SIGNAL(clicked()), SLOT(nextTrack()) ); connect( checkBox_perTrack, SIGNAL(clicked()), SLOT(perTrack()) ); // draw an icon onto the open-in-konqui button pushButton_open->setIconSet( kapp->iconLoader()->loadIconSet( "fileopen", KIcon::Small ) ); //Update lyrics on Context Browser connect( this, SIGNAL(lyricsChanged( const QString& )), ContextBrowser::instance(), SLOT( lyricsChanged( const QString& ) ) ); //Update cover connect( CollectionDB::instance(), SIGNAL( coverFetched( const QString&, const QString& ) ), this, SLOT( loadCover( const QString&, const QString& ) ) ); connect( CollectionDB::instance(), SIGNAL( coverChanged( const QString&, const QString& ) ), this, SLOT( loadCover( const QString&, const QString& ) ) ); #if HAVE_TUNEPIMP connect( pushButton_musicbrainz, SIGNAL(clicked()), SLOT(musicbrainzQuery()) ); #else QToolTip::add( pushButton_musicbrainz, i18n("Please install MusicBrainz to enable this functionality") ); #endif connect( pushButton_guessTags, SIGNAL(clicked()), SLOT( guessFromFilename() ) ); connect( pushButton_setFilenameSchemes, SIGNAL(clicked()), SLOT( setFileNameSchemes() ) ); if( m_urlList.count() ) { //editing multiple tracks m_perTrack = false; setMultipleTracksMode(); readMultipleTracks(); checkBox_perTrack->setChecked( m_perTrack ); if( m_urlList.count() == 1 ) { checkBox_perTrack->setEnabled( false ); pushButton_previous->setEnabled( false ); pushButton_next->setEnabled( false ); } else { checkBox_perTrack->setEnabled( true ); pushButton_previous->setEnabled( m_perTrack ); pushButton_next->setEnabled( m_perTrack ); } } else { m_perTrack = true; checkBox_perTrack->hide(); if( !m_playlistItem ) { pushButton_previous->hide(); pushButton_next->hide(); } loadLyrics( m_bundle.url() ); readTags(); } // make it as small as possible resize( sizeHint().width(), minimumSize().height() ); }
void CollectionScanner::scanFiles( const QStringList& entries ) { typedef QPair<QString, QString> CoverBundle; QStringList validImages; validImages << "jpg" << "png" << "gif" << "jpeg" << "bmp"; QStringList validPlaylists; validPlaylists << "m3u" << "pls"; QList<CoverBundle> covers; QStringList images; int itemCount = 0; for( QStringList::ConstIterator it = entries.constBegin(), end = entries.constEnd(); it != end; ++it ) { const QString path = *it; const QString ext = extension( path ); const QString dir = directory( path ); itemCount++; // Write path to logfile if( !m_logfile.isEmpty() ) { QFile log( m_logfile ); if( log.open( QIODevice::WriteOnly ) ) { QByteArray cPath = path.toUtf8(); log.write( cPath, cPath.length() ); log.close(); } } if( validImages.contains( ext ) ) images += path; else if( m_importPlaylists && validPlaylists.contains( ext ) ) { AttributeHash attributes; if( m_batch && !m_rpath.isEmpty() ) { QString rpath = path; rpath.remove( QDir::cleanPath( QDir::currentPath() ) ); rpath.prepend( QDir::cleanPath( m_rpath + '/' ) ); attributes["path"] = rpath; } else attributes["path"] = path; writeElement( "playlist", attributes ); } else { //FIXME: PORT 2.0 // QList<EmbeddedImage> images; const AttributeHash attributes = readTags( path ); if( !attributes.empty() ) { writeElement( "tags", attributes ); CoverBundle cover( attributes["artist"], attributes["album"] ); if( !covers.contains( cover ) ) covers += cover; //FIXME: PORT 2.0 // foreach( EmbeddedImage image, images ) // { // AttributeHash attributes; // if( m_batch && !m_rpath.isEmpty() ) // { // QString rpath = path; // rpath.remove( QDir::cleanPath( QDir::currentPath() ) ); // rpath.prepend( QDir::cleanPath( m_rpath + '/' ) ); // attributes["path"] = rpath; // } // else // attributes["path"] = path; // attributes["hash"] = image.hash(); // attributes["description"] = image.description(); // writeElement( "embed", attributes ); // } } } // Update Compilation-flag, when this is the last loop-run // or we're going to switch to another dir in the next run QStringList::const_iterator itTemp( it ); ++itTemp; if( path == entries.last() || dir != directory( *itTemp ) ) { // we entered the next directory foreach( const QString &imagePath, images ) { // Serialize CoverBundle list with AMAROK_MAGIC as separator QString string; for( QList<CoverBundle>::ConstIterator it2 = covers.begin(); it2 != covers.end(); ++it2 ) { string += ( string.isEmpty() ? "" : "AMAROK_MAGIC" ) + (*it2).first + "AMAROK_MAGIC" + (*it2).second; } AttributeHash attributes; if( m_batch && !m_rpath.isEmpty() ) { QString rpath = imagePath; rpath.remove( QDir::cleanPath( QDir::currentPath() ) ); rpath.prepend( QDir::cleanPath( m_rpath + '/' ) ); attributes["path"] = rpath; } else attributes["path"] = imagePath; attributes["list"] = string; writeElement( "image", attributes ); } AttributeHash attributes; if( m_batch && !m_rpath.isEmpty() ) { QString rdir = dir; rdir.remove( QDir::cleanPath( QDir::currentPath() ) ); rdir.prepend( QDir::cleanPath( m_rpath + '/' ) ); attributes["path"] = rdir; } else attributes["path"] = dir; writeElement( "compilation", attributes ); // clear now because we've processed them covers.clear(); images.clear(); }
Track::Track( const QUrl &u ) :p(new TrackPrivate) { p->url=u; readTags(); }