diff options
author | Slávek Banko <[email protected]> | 2013-06-29 12:56:53 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2013-07-04 03:11:35 +0200 |
commit | 5f5e7c5455d52826b0bd50f64fcffb7695ce970d (patch) | |
tree | c8ee8792d3fb139365abbf70c2255f1e69d2aa34 /src/webquerypubmed.cpp | |
parent | 251c9a439759c830d34c70683d0fc9454d703010 (diff) | |
download | kbibtex-5f5e7c5455d52826b0bd50f64fcffb7695ce970d.tar.gz kbibtex-5f5e7c5455d52826b0bd50f64fcffb7695ce970d.zip |
Initial TQt conversion
Diffstat (limited to 'src/webquerypubmed.cpp')
-rw-r--r-- | src/webquerypubmed.cpp | 176 |
1 files changed, 88 insertions, 88 deletions
diff --git a/src/webquerypubmed.cpp b/src/webquerypubmed.cpp index f3dcb82..7dfeb32 100644 --- a/src/webquerypubmed.cpp +++ b/src/webquerypubmed.cpp @@ -17,14 +17,14 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include <qwidget.h> -#include <qdom.h> -#include <qapplication.h> -#include <qstringlist.h> -#include <qbuffer.h> -#include <qcstring.h> -#include <qregexp.h> -#include <qspinbox.h> +#include <ntqwidget.h> +#include <ntqdom.h> +#include <ntqapplication.h> +#include <ntqstringlist.h> +#include <ntqbuffer.h> +#include <ntqcstring.h> +#include <ntqregexp.h> +#include <ntqspinbox.h> #include <klineedit.h> #include <kdialog.h> @@ -40,19 +40,19 @@ namespace KBibTeX { - WebQueryPubMedWidget::WebQueryPubMedWidget( QWidget *parent, const char *name ) + WebQueryPubMedWidget::WebQueryPubMedWidget( TQWidget *parent, const char *name ) : WebQueryWidget( parent, name ) { init(); Settings *settings = Settings::self(); - QString value = settings->getWebQueryDefault( "PubMed" ); - value = value == QString::null ? "" : value; + TQString value = settings->getWebQueryDefault( "PubMed" ); + value = value == TQString::null ? "" : value; lineEditQuery->setText( value ); slotTextChanged( value, true ); } - WebQueryPubMed::WebQueryPubMed( QWidget *parent ) : WebQuery( parent ) + WebQueryPubMed::WebQueryPubMed( TQWidget *parent ) : WebQuery( parent ) { m_widget = new WebQueryPubMedWidget( parent ); } @@ -62,17 +62,17 @@ namespace KBibTeX delete m_widget; } - QString WebQueryPubMed::title() + TQString WebQueryPubMed::title() { return i18n( "NCBI (PubMed)" ); } - QString WebQueryPubMed::disclaimer() + TQString WebQueryPubMed::disclaimer() { return i18n( "NCBI's Disclaimer and Copyright" ); } - QString WebQueryPubMed::disclaimerURL() + TQString WebQueryPubMed::disclaimerURL() { return "http://eutils.ncbi.nlm.nih.gov/About/disclaimer.html"; } @@ -91,7 +91,7 @@ namespace KBibTeX setNumStages( 2 ); int numberOfResults = m_widget->spinBoxMaxHits->value(); - QString searchTerm = m_widget->lineEditQuery->text().stripWhiteSpace().replace( '$', "" ); + TQString searchTerm = m_widget->lineEditQuery->text().stripWhiteSpace().replace( '$', "" ); if ( searchTerm.isEmpty() ) { setEndSearch( WebQuery::statusInvalidQuery ); @@ -99,54 +99,54 @@ namespace KBibTeX } searchTerm = searchTerm.replace( "%", "%25" ).replace( "+", "%2B" ).replace( " ", "%20" ).replace( "#", "%23" ).replace( "&", "%26" ).replace( "?", "%3F" ); - KURL url = KURL( QString( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=%2&retmax=%1&tool=KBibTeX&[email protected]" ).arg( numberOfResults ).arg( searchTerm ) ); + KURL url = KURL( TQString( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=%2&retmax=%1&tool=KBibTeX&[email protected]" ).arg( numberOfResults ).arg( searchTerm ) ); - QString data = downloadHTML( url ); - if ( data != QString::null && !m_aborted ) + TQString data = downloadHTML( url ); + if ( data != TQString::null && !m_aborted ) { - QBuffer buffer; + TQBuffer buffer; buffer.open( IO_WriteOnly ); - QTextStream ts( &buffer ); - ts.setEncoding( QTextStream::UnicodeUTF8 ); + TQTextStream ts( &buffer ); + ts.setEncoding( TQTextStream::UnicodeUTF8 ); ts << data << endl; buffer.close(); buffer.open( IO_ReadOnly ); - QValueList<int> intList; - QXmlInputSource inputSource( &buffer ); - QXmlSimpleReader reader; + TQValueList<int> intList; + TQXmlInputSource inputSource( &buffer ); + TQXmlSimpleReader reader; WebQueryPubMedStructureParserQuery handler( &intList ); reader.setContentHandler( &handler ); reader.parse( &inputSource ); buffer.close(); - QString ids; - QValueList<int>::iterator it = intList.begin(); + TQString ids; + TQValueList<int>::iterator it = intList.begin(); if ( it != intList.end() ) { - ids.append( QString::number( *it ) ); + ids.append( TQString::number( *it ) ); ++it; for ( ; it != intList.end(); ++it ) { ids.append( "," ); - ids.append( QString::number( *it ) ); + ids.append( TQString::number( *it ) ); } } - url = KURL( QString( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=%1&tool=KBibTeX&[email protected]" ).arg( ids ) ); + url = KURL( TQString( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=%1&tool=KBibTeX&[email protected]" ).arg( ids ) ); data = downloadHTML( url ); - if ( data != QString::null && !m_aborted ) + if ( data != TQString::null && !m_aborted ) { buffer.open( IO_WriteOnly ); - QTextStream ts( &buffer ); - ts.setEncoding( QTextStream::UnicodeUTF8 ); + TQTextStream ts( &buffer ); + ts.setEncoding( TQTextStream::UnicodeUTF8 ); ts << data << endl; buffer.close(); buffer.open( IO_ReadOnly ); - QDomDocument doc( "efetch'ed" ); + TQDomDocument doc( "efetch'ed" ); doc.setContent( &buffer ); - QDomElement docElem = doc.documentElement(); + TQDomElement docElem = doc.documentElement(); WebQueryPubMedResultParser resultParser; connect( &resultParser, SIGNAL( foundEntry( BibTeX::Entry*, bool ) ), this, SIGNAL( foundEntry( BibTeX::Entry*, bool ) ) ); resultParser.parse( docElem ); @@ -155,8 +155,8 @@ namespace KBibTeX } else if ( !m_aborted ) { - QString message = KIO::NetAccess::lastErrorString(); - message.prepend( QString( i18n( "Querying database '%1' failed." ) ).arg( title() ) ); + TQString message = KIO::NetAccess::lastErrorString(); + message.prepend( TQString( i18n( "Querying database '%1' failed." ) ).arg( title() ) ); KMessageBox::error( m_parent, message ); setEndSearch( WebQuery::statusError ); } @@ -165,10 +165,10 @@ namespace KBibTeX } else if ( !m_aborted ) { - QString message = KIO::NetAccess::lastErrorString(); + TQString message = KIO::NetAccess::lastErrorString(); if ( message.isEmpty() ) message.prepend( '\n' ); - message.prepend( QString( i18n( "Querying database '%1' failed." ) ).arg( title() ) ); + message.prepend( TQString( i18n( "Querying database '%1' failed." ) ).arg( title() ) ); KMessageBox::error( m_parent, message ); setEndSearch( WebQuery::statusError ); } @@ -176,7 +176,7 @@ namespace KBibTeX setEndSearch( WebQuery::statusAborted ); } - WebQueryPubMedStructureParserQuery::WebQueryPubMedStructureParserQuery( QValueList<int> *intList ) : QXmlDefaultHandler(), m_intList( intList ) + WebQueryPubMedStructureParserQuery::WebQueryPubMedStructureParserQuery( TQValueList<int> *intList ) : TQXmlDefaultHandler(), m_intList( intList ) { m_intList->clear(); } @@ -186,13 +186,13 @@ namespace KBibTeX // nothing } - bool WebQueryPubMedStructureParserQuery::startElement( const QString & /*namespaceURI*/, const QString & /*localName*/, const QString & /*qName*/, const QXmlAttributes & /*atts*/ ) + bool WebQueryPubMedStructureParserQuery::startElement( const TQString & /*namespaceURI*/, const TQString & /*localName*/, const TQString & /*qName*/, const TQXmlAttributes & /*atts*/ ) { - concatString = QString(); + concatString = TQString(); return TRUE; } - bool WebQueryPubMedStructureParserQuery::endElement( const QString & /*namespaceURI*/, const QString & /*localName*/, const QString & qName ) + bool WebQueryPubMedStructureParserQuery::endElement( const TQString & /*namespaceURI*/, const TQString & /*localName*/, const TQString & qName ) { if ( qName == "Id" ) { @@ -205,23 +205,23 @@ namespace KBibTeX return TRUE; } - bool WebQueryPubMedStructureParserQuery::characters( const QString & ch ) + bool WebQueryPubMedStructureParserQuery::characters( const TQString & ch ) { concatString.append( ch ); return TRUE; } - WebQueryPubMedResultParser::WebQueryPubMedResultParser( ) : QObject() + WebQueryPubMedResultParser::WebQueryPubMedResultParser( ) : TQObject() { // nothing } - void WebQueryPubMedResultParser::parse( const QDomElement& rootElement ) + void WebQueryPubMedResultParser::parse( const TQDomElement& rootElement ) { if ( rootElement.tagName() == "PubmedArticleSet" ) - for ( QDomNode n = rootElement.firstChild(); !n.isNull(); n = n.nextSibling() ) + for ( TQDomNode n = rootElement.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement e = n.toElement(); if ( !e.isNull() && e.tagName() == "PubmedArticle" ) { BibTeX::Entry * entry = new BibTeX::Entry( BibTeX::Entry::etMisc, "PubMed" ); @@ -236,26 +236,26 @@ namespace KBibTeX // nothing } - void WebQueryPubMedResultParser::parsePubmedArticle( const QDomElement& element, BibTeX::Entry *entry ) + void WebQueryPubMedResultParser::parsePubmedArticle( const TQDomElement& element, BibTeX::Entry *entry ) { - for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + for ( TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement e = n.toElement(); if ( !e.isNull() && e.tagName() == "MedlineCitation" ) parseMedlineCitation( e, entry ); } } - void WebQueryPubMedResultParser::parseMedlineCitation( const QDomElement& element, BibTeX::Entry *entry ) + void WebQueryPubMedResultParser::parseMedlineCitation( const TQDomElement& element, BibTeX::Entry *entry ) { - for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + for ( TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement e = n.toElement(); if ( !e.isNull() ) { if ( e.tagName() == "PMID" ) { - entry->setId( QString( "PubMed_%1" ).arg( e.text() ) ); + entry->setId( TQString( "PubMed_%1" ).arg( e.text() ) ); /** add url to pubmed website */ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftURL ); @@ -264,15 +264,15 @@ namespace KBibTeX field = new BibTeX::EntryField( BibTeX::EntryField::ftURL ); entry->addField( field ); } - field->setValue( new BibTeX::Value( QString( "http://www.ncbi.nlm.nih.gov/pubmed/" ).append( e.text() ) ) ); + field->setValue( new BibTeX::Value( TQString( "http://www.ncbi.nlm.nih.gov/pubmed/" ).append( e.text() ) ) ); } else if ( e.tagName() == "Article" ) parseArticle( e, entry ); else if ( e.tagName() == "MedlineJournalInfo" ) { - for ( QDomNode n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) + for ( TQDomNode n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - QDomElement e2 = n2.toElement(); + TQDomElement e2 = n2.toElement(); if ( e2.tagName() == "MedlineTA" ) { BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftJournal ); @@ -290,11 +290,11 @@ namespace KBibTeX } - void WebQueryPubMedResultParser::parseArticle( const QDomElement& element, BibTeX::Entry *entry ) + void WebQueryPubMedResultParser::parseArticle( const TQDomElement& element, BibTeX::Entry *entry ) { - for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + for ( TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement e = n.toElement(); if ( e.tagName() == "Journal" ) { @@ -313,7 +313,7 @@ namespace KBibTeX } else if ( e.tagName() == "Pagination" ) { - QDomElement medlinePgn = e.firstChild().toElement(); // may fail? + TQDomElement medlinePgn = e.firstChild().toElement(); // may fail? if ( !medlinePgn.text().isEmpty() ) { BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftPages ); @@ -327,7 +327,7 @@ namespace KBibTeX } else if ( e.tagName() == "Abstract" ) { - QDomElement abstractText = e.firstChild().toElement(); + TQDomElement abstractText = e.firstChild().toElement(); BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftAbstract ); if ( field == NULL ) { @@ -351,11 +351,11 @@ namespace KBibTeX } } - void WebQueryPubMedResultParser::parseJournal( const QDomElement& element, BibTeX::Entry *entry ) + void WebQueryPubMedResultParser::parseJournal( const TQDomElement& element, BibTeX::Entry *entry ) { - for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + for ( TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement e = n.toElement(); if ( e.tagName() == "ISSN" ) { @@ -382,11 +382,11 @@ namespace KBibTeX } } - void WebQueryPubMedResultParser::parseJournalIssue( const QDomElement& element, BibTeX::Entry *entry ) + void WebQueryPubMedResultParser::parseJournalIssue( const TQDomElement& element, BibTeX::Entry *entry ) { - for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + for ( TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement e = n.toElement(); if ( e.tagName() == "Volume" ) { @@ -413,11 +413,11 @@ namespace KBibTeX } } - void WebQueryPubMedResultParser::parsePubDate( const QDomElement& element, BibTeX::Entry *entry ) + void WebQueryPubMedResultParser::parsePubDate( const TQDomElement& element, BibTeX::Entry *entry ) { - for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + for ( TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement e = n.toElement(); if ( e.tagName() == "Year" ) { @@ -431,7 +431,7 @@ namespace KBibTeX } else if ( e.tagName() == "Month" ) { - QString month = e.text().lower(); + TQString month = e.text().lower(); BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftMonth ); if ( field == NULL ) { @@ -444,8 +444,8 @@ namespace KBibTeX } else if ( e.tagName() == "MedlineDate" ) { - QStringList frags = QStringList::split( QRegExp( "\\s+" ), e.text() ); - for ( QStringList::Iterator it = frags.begin(); it != frags.end(); ++it ) + TQStringList frags = TQStringList::split( TQRegExp( "\\s+" ), e.text() ); + for ( TQStringList::Iterator it = frags.begin(); it != frags.end(); ++it ) { bool ok; int num = ( *it ).toInt( &ok ); @@ -458,7 +458,7 @@ namespace KBibTeX entry->addField( field ); } BibTeX::Value *value = new BibTeX::Value(); - value->items.append( new BibTeX::MacroKey( QString::number( num ) ) ); + value->items.append( new BibTeX::MacroKey( TQString::number( num ) ) ); field->setValue( value ); } else if ( !ok && ( *it ).length() == 3 ) @@ -478,20 +478,20 @@ namespace KBibTeX } } - void WebQueryPubMedResultParser::parseAuthorList( const QDomElement& element, BibTeX::Entry *entry ) + void WebQueryPubMedResultParser::parseAuthorList( const TQDomElement& element, BibTeX::Entry *entry ) { if ( element.attribute( "CompleteYN", "Y" ) == "Y" ) { - QStringList authorList; - for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + TQStringList authorList; + for ( TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement e = n.toElement(); if ( e.tagName() == "Author" && e.attribute( "ValidYN", "Y" ) == "Y" ) { - QString lastName = QString::null, firstName = QString::null; - for ( QDomNode n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) + TQString lastName = TQString::null, firstName = TQString::null; + for ( TQDomNode n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - QDomElement e2 = n2.toElement(); + TQDomElement e2 = n2.toElement(); if ( e2.tagName() == "LastName" ) lastName = e2.text(); else if ( e2.tagName() == "CollectiveName" ) @@ -499,7 +499,7 @@ namespace KBibTeX else if ( e2.tagName() == "FirstName" || e2.tagName() == "ForeName" ) firstName = e2.text(); } - QString name = lastName; + TQString name = lastName; if ( !firstName.isNull() && !firstName.isEmpty() ) { if ( name.isNull() ) name = "UNSET"; @@ -520,11 +520,11 @@ namespace KBibTeX Settings *settings = Settings::self(); BibTeX::PersonContainer *personContainer = new BibTeX::PersonContainer( settings->editing_FirstNameFirst ); value->items.append( personContainer ); - for ( QStringList::Iterator sli = authorList.begin(); sli != authorList.end(); ++sli ) + for ( TQStringList::Iterator sli = authorList.begin(); sli != authorList.end(); ++sli ) { - QStringList nameParts = QStringList::split( '|', *sli ); - QString firstName = nameParts.count() > 1 ? nameParts[0] : ""; - QString lastName = nameParts[nameParts.count() - 1]; + TQStringList nameParts = TQStringList::split( '|', *sli ); + TQString firstName = nameParts.count() > 1 ? nameParts[0] : ""; + TQString lastName = nameParts[nameParts.count() - 1]; personContainer->persons.append( new BibTeX::Person( firstName, lastName, settings->editing_FirstNameFirst ) ); } field->setValue( value ); |