void PlaylistItem::guessTagInfo(TagGuesser::Type type) { switch(type) { case TagGuesser::FileName: { TagGuesser guesser(d->fileHandle.absFilePath()); Tag *tag = TagTransactionManager::duplicateTag(d->fileHandle.tag()); if(!guesser.title().isNull()) tag->setTitle(guesser.title()); if(!guesser.artist().isNull()) tag->setArtist(guesser.artist()); if(!guesser.album().isNull()) tag->setAlbum(guesser.album()); if(!guesser.track().isNull()) tag->setTrack(guesser.track().toInt()); if(!guesser.comment().isNull()) tag->setComment(guesser.comment()); TagTransactionManager::instance()->changeTagOnItem(this, tag); break; } case TagGuesser::MusicBrainz: startMusicBrainzQuery(d->fileHandle); break; } }
void TagDialog::guessFromFilename() //SLOT { TagGuesser guesser( m_bundle.url().path() ); if( !guesser.title().isNull() ) kLineEdit_title->setText( guesser.title() ); if( !guesser.artist().isNull() ) kComboBox_artist->setCurrentText( guesser.artist() ); if( !guesser.album().isNull() ) kComboBox_album->setCurrentText( guesser.album() ); if( !guesser.track().isNull() ) kIntSpinBox_track->setValue( guesser.track().toInt() ); if( !guesser.comment().isNull() ) kTextEdit_comment->setText( guesser.comment() ); }
// ============================================================================ int CFormatGuessApp::Run(void) // ============================================================================ { const CArgs& args = GetArgs(); CNcbiIstream & input_stream = args["i"].AsInputFile(CArgValue::fBinary); string name_of_input_stream = args["i"].AsString(); if( name_of_input_stream.empty() || name_of_input_stream == "-" ) { name_of_input_stream = "stdin"; } CFormatGuess guesser( input_stream ); CFormatGuess::EFormat uFormat = guesser.GuessFormat(); string format_name; if( args["canonical-name"] ) { // caller wants to always use the format-guesser's name format_name = CFormatGuess::GetFormatName(uFormat); } else { // caller wants special names for some types FormatMap FormatStrings; FormatStrings[ CFormatGuess::eUnknown ] = "Format not recognized"; FormatStrings[ CFormatGuess::eBinaryASN ] = "Binary ASN.1"; FormatStrings[ CFormatGuess::eTextASN ] = "Text ASN.1"; FormatStrings[ CFormatGuess::eFasta ] = "FASTA sequence record"; FormatStrings[ CFormatGuess::eXml ] = "XML"; FormatStrings[ CFormatGuess::eRmo ] = "RepeatMasker Out"; FormatStrings[ CFormatGuess::eGlimmer3 ] = "Glimmer3 prediction"; FormatStrings[ CFormatGuess::ePhrapAce ] = "Phrap ACE assembly file"; FormatStrings[ CFormatGuess::eGtf ] = "GFF/GTF style annotation"; FormatStrings[ CFormatGuess::eAgp ] = "AGP format assembly"; FormatStrings[ CFormatGuess::eNewick ] = "Newick tree"; FormatStrings[ CFormatGuess::eDistanceMatrix ] = "Distance matrix"; FormatStrings[ CFormatGuess::eFiveColFeatureTable ] = "Five column feature table"; FormatStrings[ CFormatGuess::eTaxplot ] = "Tax plot"; FormatStrings[ CFormatGuess::eTable ] = "Generic table"; FormatStrings[ CFormatGuess::eAlignment ] = "Text alignment"; FormatStrings[ CFormatGuess::eFlatFileSequence ] = "Flat file sequence portion"; FormatStrings[ CFormatGuess::eSnpMarkers ] = "SNP marker flat file"; FormatStrings[ CFormatGuess::eWiggle ] = "UCSC Wiggle file"; FormatStrings[ CFormatGuess::eBed ] = "UCSC BED file"; FormatStrings[ CFormatGuess::eBed15 ] = "UCSC microarray file"; FormatStrings[ CFormatGuess::eHgvs ] = "HGVS Variation file"; FormatStrings[ CFormatGuess::eGff2 ] = "GFF2 feature table"; FormatStrings[ CFormatGuess::eGff3 ] = "GFF3 feature table"; FormatStrings[ CFormatGuess::eGvf ] = "GVF gene variation data"; FormatStrings[ CFormatGuess::eVcf ] = "VCF Variant Call Format"; FormatIter it = FormatStrings.find( uFormat ); if ( it == FormatStrings.end() ) { // cout << "Unmapped format [" << uFormat << "]"; format_name = CFormatGuess::GetFormatName(uFormat); } else { format_name = it->second; } } string object_type_to_show; if( args["show-object-type"] ) { AutoPtr<CObjectIStream> obj_istrm; switch( uFormat ) { case CFormatGuess::eBinaryASN: obj_istrm.reset( new CObjectIStreamAsnBinary(input_stream, eNoOwnership)); break; case CFormatGuess::eTextASN: obj_istrm.reset( new CObjectIStreamAsn(input_stream, eNoOwnership)); break; case CFormatGuess::eXml: obj_istrm.reset( new CObjectIStreamXml(input_stream, eNoOwnership)); break; case CFormatGuess::eJSON: obj_istrm.reset( new CObjectIStreamJson(input_stream, eNoOwnership)); break; default: // obj_istrm will be unset break; } if( obj_istrm.get() ) { object_type_to_show = guess_object_type(*obj_istrm); } else { object_type_to_show = "unknown"; } // If caller requested the object type then it should be set // even if it's unknown _ASSERT( ! object_type_to_show.empty() ); } const string output_format = args["output-format"].AsString(); if( output_format == "text" ) { cout << name_of_input_stream << " : "; _ASSERT( ! format_name.empty() ); // should be non-empty even if unknown cout << format_name; // second line is object type line, if applicable. if( ! object_type_to_show.empty() ) { cout << ", object type: " << object_type_to_show; } cout << endl; } else if( output_format == "XML" ) { xml::node output_node("formatguess"); // input_stream_node for each input specified. // However, there's currently only one so no loop here yet. xml::node input_stream_node("input_stream"); xml::attributes & stream_attribs = input_stream_node.get_attributes(); stream_attribs.insert("name", name_of_input_stream.c_str()); stream_attribs.insert("format_name", format_name.c_str()); if( ! object_type_to_show.empty() ) { stream_attribs.insert("object_type", object_type_to_show.c_str()); } output_node.push_back(input_stream_node); xml::document output_doc(output_node); output_doc.save_to_stream(cout); } else { _TROUBLE; } return 0; }