diff options
Diffstat (limited to 'src/fetch/entrezfetcher.cpp')
-rw-r--r-- | src/fetch/entrezfetcher.cpp | 232 |
1 files changed, 116 insertions, 116 deletions
diff --git a/src/fetch/entrezfetcher.cpp b/src/fetch/entrezfetcher.cpp index 14b9e20..83fee42 100644 --- a/src/fetch/entrezfetcher.cpp +++ b/src/fetch/entrezfetcher.cpp @@ -26,10 +26,10 @@ #include <kstandarddirs.h> #include <kio/job.h> -#include <qdom.h> -#include <qlabel.h> -#include <qlayout.h> -#include <qfile.h> +#include <tqdom.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqfile.h> //#define ENTREZ_TEST @@ -45,18 +45,18 @@ namespace { using Tellico::Fetch::EntrezFetcher; -EntrezFetcher::EntrezFetcher(QObject* parent_, const char* name_) : Fetcher(parent_, name_), m_xsltHandler(0), +EntrezFetcher::EntrezFetcher(TQObject* tqparent_, const char* name_) : Fetcher(tqparent_, name_), m_xsltHandler(0), m_step(Begin), m_started(false) { } EntrezFetcher::~EntrezFetcher() { } -QString EntrezFetcher::defaultName() { +TQString EntrezFetcher::defaultName() { return i18n("Entrez Database"); } -QString EntrezFetcher::source() const { +TQString EntrezFetcher::source() const { return m_name.isEmpty() ? defaultName() : m_name; } @@ -65,14 +65,14 @@ bool EntrezFetcher::canFetch(int type) const { } void EntrezFetcher::readConfigHook(const KConfigGroup& config_) { - QString s = config_.readEntry("Database", QString::fromLatin1(ENTREZ_DEFAULT_DATABASE)); // default to pubmed + TQString s = config_.readEntry("Database", TQString::tqfromLatin1(ENTREZ_DEFAULT_DATABASE)); // default to pubmed if(!s.isEmpty()) { m_dbname = s; } m_fields = config_.readListEntry("Custom Fields"); } -void EntrezFetcher::search(FetchKey key_, const QString& value_) { +void EntrezFetcher::search(FetchKey key_, const TQString& value_) { m_started = true; m_start = 1; m_total = -1; @@ -84,36 +84,36 @@ void EntrezFetcher::search(FetchKey key_, const QString& value_) { return; } if(m_dbname.isEmpty()) { - m_dbname = QString::fromLatin1(ENTREZ_DEFAULT_DATABASE); + m_dbname = TQString::tqfromLatin1(ENTREZ_DEFAULT_DATABASE); } #ifdef ENTREZ_TEST - KURL u = KURL::fromPathOrURL(QString::fromLatin1("/home/robby/esearch.xml")); + KURL u = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/esearch.xml")); #else - KURL u(QString::fromLatin1(ENTREZ_BASE_URL)); - u.addPath(QString::fromLatin1(ENTREZ_SEARCH_CGI)); - u.addQueryItem(QString::fromLatin1("tool"), QString::fromLatin1("Tellico")); - u.addQueryItem(QString::fromLatin1("retmode"), QString::fromLatin1("xml")); - u.addQueryItem(QString::fromLatin1("usehistory"), QString::fromLatin1("y")); - u.addQueryItem(QString::fromLatin1("retmax"), QString::fromLatin1("1")); // we're just getting the count - u.addQueryItem(QString::fromLatin1("db"), m_dbname); - u.addQueryItem(QString::fromLatin1("term"), value_); + KURL u(TQString::tqfromLatin1(ENTREZ_BASE_URL)); + u.addPath(TQString::tqfromLatin1(ENTREZ_SEARCH_CGI)); + u.addQueryItem(TQString::tqfromLatin1("tool"), TQString::tqfromLatin1("Tellico")); + u.addQueryItem(TQString::tqfromLatin1("retmode"), TQString::tqfromLatin1("xml")); + u.addQueryItem(TQString::tqfromLatin1("usehistory"), TQString::tqfromLatin1("y")); + u.addQueryItem(TQString::tqfromLatin1("retmax"), TQString::tqfromLatin1("1")); // we're just getting the count + u.addQueryItem(TQString::tqfromLatin1("db"), m_dbname); + u.addQueryItem(TQString::tqfromLatin1("term"), value_); switch(key_) { case Title: - u.addQueryItem(QString::fromLatin1("field"), QString::fromLatin1("titl")); + u.addQueryItem(TQString::tqfromLatin1("field"), TQString::tqfromLatin1("titl")); break; case Person: - u.addQueryItem(QString::fromLatin1("field"), QString::fromLatin1("auth")); + u.addQueryItem(TQString::tqfromLatin1("field"), TQString::tqfromLatin1("auth")); break; case Keyword: // for Tellico Keyword searches basically mean search for any field matching -// u.addQueryItem(QString::fromLatin1("field"), QString::fromLatin1("word")); +// u.addQueryItem(TQString::tqfromLatin1("field"), TQString::tqfromLatin1("word")); break; case PubmedID: - u.addQueryItem(QString::fromLatin1("field"), QString::fromLatin1("pmid")); + u.addQueryItem(TQString::tqfromLatin1("field"), TQString::tqfromLatin1("pmid")); break; case DOI: @@ -131,10 +131,10 @@ void EntrezFetcher::search(FetchKey key_, const QString& value_) { m_step = Search; // myLog() << "EntrezFetcher::doSearch() - url: " << u.url() << endl; m_job = KIO::get(u, false, false); - connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)), - SLOT(slotData(KIO::Job*, const QByteArray&))); - connect(m_job, SIGNAL(result(KIO::Job*)), - SLOT(slotComplete(KIO::Job*))); + connect(m_job, TQT_SIGNAL(data(KIO::Job*, const TQByteArray&)), + TQT_SLOT(slotData(KIO::Job*, const TQByteArray&))); + connect(m_job, TQT_SIGNAL(result(KIO::Job*)), + TQT_SLOT(slotComplete(KIO::Job*))); } void EntrezFetcher::continueSearch() { @@ -156,8 +156,8 @@ void EntrezFetcher::stop() { emit signalDone(this); } -void EntrezFetcher::slotData(KIO::Job*, const QByteArray& data_) { - QDataStream stream(m_data, IO_WriteOnly | IO_Append); +void EntrezFetcher::slotData(KIO::Job*, const TQByteArray& data_) { + TQDataStream stream(m_data, IO_WriteOnly | IO_Append); stream.writeRawBytes(data_.data(), data_.size()); } @@ -179,11 +179,11 @@ void EntrezFetcher::slotComplete(KIO::Job* job_) { #if 0 kdWarning() << "Remove debug from entrezfetcher.cpp: " << __LINE__ << endl; - QFile f(QString::fromLatin1("/tmp/test.xml")); + TQFile f(TQString::tqfromLatin1("/tmp/test.xml")); if(f.open(IO_WriteOnly)) { - QTextStream t(&f); - t.setEncoding(QTextStream::UnicodeUTF8); - t << QCString(m_data, m_data.size()+1); + TQTextStream t(&f); + t.setEncoding(TQTextStream::UnicodeUTF8); + t << TQCString(m_data, m_data.size()+1); } f.close(); #endif @@ -205,7 +205,7 @@ void EntrezFetcher::slotComplete(KIO::Job* job_) { } void EntrezFetcher::searchResults() { - QDomDocument dom; + TQDomDocument dom; if(!dom.setContent(m_data, false)) { kdWarning() << "EntrezFetcher::searchResults() - server did not return valid XML." << endl; stop(); @@ -213,8 +213,8 @@ void EntrezFetcher::searchResults() { } // find Count, QueryKey, and WebEnv elements int count = 0; - for(QDomNode n = dom.documentElement().firstChild(); !n.isNull(); n = n.nextSibling()) { - QDomElement e = n.toElement(); + for(TQDomNode n = dom.documentElement().firstChild(); !n.isNull(); n = n.nextSibling()) { + TQDomElement e = n.toElement(); if(e.isNull()) { continue; } @@ -239,71 +239,71 @@ void EntrezFetcher::searchResults() { void EntrezFetcher::doSummary() { #ifdef ENTREZ_TEST - KURL u = KURL::fromPathOrURL(QString::fromLatin1("/home/robby/esummary.xml")); + KURL u = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/esummary.xml")); #else - KURL u(QString::fromLatin1(ENTREZ_BASE_URL)); - u.addPath(QString::fromLatin1(ENTREZ_SUMMARY_CGI)); - u.addQueryItem(QString::fromLatin1("tool"), QString::fromLatin1("Tellico")); - u.addQueryItem(QString::fromLatin1("retmode"), QString::fromLatin1("xml")); - u.addQueryItem(QString::fromLatin1("retstart"), QString::number(m_start)); - u.addQueryItem(QString::fromLatin1("retmax"), QString::number(QMIN(m_total-m_start-1, ENTREZ_MAX_RETURNS_TOTAL))); - u.addQueryItem(QString::fromLatin1("usehistory"), QString::fromLatin1("y")); - u.addQueryItem(QString::fromLatin1("db"), m_dbname); - u.addQueryItem(QString::fromLatin1("query_key"), m_queryKey); - u.addQueryItem(QString::fromLatin1("WebEnv"), m_webEnv); + KURL u(TQString::tqfromLatin1(ENTREZ_BASE_URL)); + u.addPath(TQString::tqfromLatin1(ENTREZ_SUMMARY_CGI)); + u.addQueryItem(TQString::tqfromLatin1("tool"), TQString::tqfromLatin1("Tellico")); + u.addQueryItem(TQString::tqfromLatin1("retmode"), TQString::tqfromLatin1("xml")); + u.addQueryItem(TQString::tqfromLatin1("retstart"), TQString::number(m_start)); + u.addQueryItem(TQString::tqfromLatin1("retmax"), TQString::number(TQMIN(m_total-m_start-1, ENTREZ_MAX_RETURNS_TOTAL))); + u.addQueryItem(TQString::tqfromLatin1("usehistory"), TQString::tqfromLatin1("y")); + u.addQueryItem(TQString::tqfromLatin1("db"), m_dbname); + u.addQueryItem(TQString::tqfromLatin1("query_key"), m_queryKey); + u.addQueryItem(TQString::tqfromLatin1("WebEnv"), m_webEnv); #endif m_step = Summary; // myLog() << "EntrezFetcher::searchResults() - url: " << u.url() << endl; m_job = KIO::get(u, false, false); - connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)), - SLOT(slotData(KIO::Job*, const QByteArray&))); - connect(m_job, SIGNAL(result(KIO::Job*)), - SLOT(slotComplete(KIO::Job*))); + connect(m_job, TQT_SIGNAL(data(KIO::Job*, const TQByteArray&)), + TQT_SLOT(slotData(KIO::Job*, const TQByteArray&))); + connect(m_job, TQT_SIGNAL(result(KIO::Job*)), + TQT_SLOT(slotComplete(KIO::Job*))); } void EntrezFetcher::summaryResults() { - QDomDocument dom; + TQDomDocument dom; if(!dom.setContent(m_data, false)) { kdWarning() << "EntrezFetcher::summaryResults() - server did not return valid XML." << endl; stop(); return; } // top child is eSummaryResult - // all children are DocSum - for(QDomNode n = dom.documentElement().firstChild(); !n.isNull(); n = n.nextSibling()) { - QDomElement e = n.toElement(); + // all tqchildren are DocSum + for(TQDomNode n = dom.documentElement().firstChild(); !n.isNull(); n = n.nextSibling()) { + TQDomElement e = n.toElement(); if(e.isNull() || e.tagName() != Latin1Literal("DocSum")) { continue; } - QDomNodeList nodes = e.elementsByTagName(QString::fromLatin1("Id")); + TQDomNodeList nodes = e.elementsByTagName(TQString::tqfromLatin1("Id")); if(nodes.count() == 0) { myDebug() << "EntrezFetcher::summaryResults() - no Id elements" << endl; continue; } int id = nodes.item(0).toElement().text().toInt(); - QString title, pubdate, authors; - nodes = e.elementsByTagName(QString::fromLatin1("Item")); + TQString title, pubdate, authors; + nodes = e.elementsByTagName(TQString::tqfromLatin1("Item")); for(uint j = 0; j < nodes.count(); ++j) { - if(nodes.item(j).toElement().attribute(QString::fromLatin1("Name")) == Latin1Literal("Title")) { + if(nodes.item(j).toElement().attribute(TQString::tqfromLatin1("Name")) == Latin1Literal("Title")) { title = nodes.item(j).toElement().text(); - } else if(nodes.item(j).toElement().attribute(QString::fromLatin1("Name")) == Latin1Literal("PubDate")) { + } else if(nodes.item(j).toElement().attribute(TQString::tqfromLatin1("Name")) == Latin1Literal("PubDate")) { pubdate = nodes.item(j).toElement().text(); - } else if(nodes.item(j).toElement().attribute(QString::fromLatin1("Name")) == Latin1Literal("AuthorList")) { - QStringList list; - for(QDomNode aNode = nodes.item(j).firstChild(); !aNode.isNull(); aNode = aNode.nextSibling()) { - // lazy, assume all children Items are authors + } else if(nodes.item(j).toElement().attribute(TQString::tqfromLatin1("Name")) == Latin1Literal("AuthorList")) { + TQStringList list; + for(TQDomNode aNode = nodes.item(j).firstChild(); !aNode.isNull(); aNode = aNode.nextSibling()) { + // lazy, assume all tqchildren Items are authors if(aNode.nodeName() == Latin1Literal("Item")) { list << aNode.toElement().text(); } } - authors = list.join(QString::fromLatin1("; ")); + authors = list.join(TQString::tqfromLatin1("; ")); } if(!title.isEmpty() && !pubdate.isEmpty() && !authors.isEmpty()) { break; // done now } } - SearchResult* r = new SearchResult(this, title, pubdate + '/' + authors, QString()); + SearchResult* r = new SearchResult(this, title, pubdate + '/' + authors, TQString()); m_matches.insert(r->uid, id); emit signalResultFound(r); } @@ -319,7 +319,7 @@ Tellico::Data::EntryPtr EntrezFetcher::fetchEntry(uint uid_) { return entry; } - if(!m_matches.contains(uid_)) { + if(!m_matches.tqcontains(uid_)) { return 0; } @@ -333,33 +333,33 @@ Tellico::Data::EntryPtr EntrezFetcher::fetchEntry(uint uid_) { int id = m_matches[uid_]; #ifdef ENTREZ_TEST - KURL u = KURL::fromPathOrURL(QString::fromLatin1("/home/robby/pubmed.xml")); + KURL u = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/pubmed.xml")); #else - KURL u(QString::fromLatin1(ENTREZ_BASE_URL)); - u.addPath(QString::fromLatin1(ENTREZ_FETCH_CGI)); - u.addQueryItem(QString::fromLatin1("tool"), QString::fromLatin1("Tellico")); - u.addQueryItem(QString::fromLatin1("retmode"), QString::fromLatin1("xml")); - u.addQueryItem(QString::fromLatin1("rettype"), QString::fromLatin1("abstract")); - u.addQueryItem(QString::fromLatin1("db"), m_dbname); - u.addQueryItem(QString::fromLatin1("id"), QString::number(id)); + KURL u(TQString::tqfromLatin1(ENTREZ_BASE_URL)); + u.addPath(TQString::tqfromLatin1(ENTREZ_FETCH_CGI)); + u.addQueryItem(TQString::tqfromLatin1("tool"), TQString::tqfromLatin1("Tellico")); + u.addQueryItem(TQString::tqfromLatin1("retmode"), TQString::tqfromLatin1("xml")); + u.addQueryItem(TQString::tqfromLatin1("rettype"), TQString::tqfromLatin1("abstract")); + u.addQueryItem(TQString::tqfromLatin1("db"), m_dbname); + u.addQueryItem(TQString::tqfromLatin1("id"), TQString::number(id)); #endif // now it's sychronous, and we know that it's utf8 - QString xmlOutput = FileHandler::readTextFile(u, false /*quiet*/, true /*utf8*/); + TQString xmlOutput = FileHandler::readTextFile(u, false /*quiet*/, true /*utf8*/); if(xmlOutput.isEmpty()) { kdWarning() << "EntrezFetcher::fetchEntry() - unable to download " << u << endl; return 0; } #if 0 kdWarning() << "EntrezFetcher::fetchEntry() - turn me off!" << endl; - QFile f1(QString::fromLatin1("/tmp/test-entry.xml")); + TQFile f1(TQString::tqfromLatin1("/tmp/test-entry.xml")); if(f1.open(IO_WriteOnly)) { - QTextStream t(&f1); - t.setEncoding(QTextStream::UnicodeUTF8); + TQTextStream t(&f1); + t.setEncoding(TQTextStream::UnicodeUTF8); t << xmlOutput; } f1.close(); #endif - QString str = m_xsltHandler->applyStylesheet(xmlOutput); + TQString str = m_xsltHandler->applyStylesheet(xmlOutput); Import::TellicoImporter imp(str); Data::CollPtr coll = imp.collection(); if(!coll) { @@ -376,40 +376,40 @@ Tellico::Data::EntryPtr EntrezFetcher::fetchEntry(uint uid_) { Data::EntryPtr e = coll->entries().front(); // try to get a link, but only if necessary - if(m_fields.contains(QString::fromLatin1("url"))) { - KURL link(QString::fromLatin1(ENTREZ_BASE_URL)); - link.addPath(QString::fromLatin1(ENTREZ_LINK_CGI)); - link.addQueryItem(QString::fromLatin1("tool"), QString::fromLatin1("Tellico")); - link.addQueryItem(QString::fromLatin1("cmd"), QString::fromLatin1("llinks")); - link.addQueryItem(QString::fromLatin1("db"), m_dbname); - link.addQueryItem(QString::fromLatin1("dbfrom"), m_dbname); - link.addQueryItem(QString::fromLatin1("id"), QString::number(id)); - - QDomDocument linkDom = FileHandler::readXMLFile(link, false /* namespace */, true /* quiet */); + if(m_fields.tqcontains(TQString::tqfromLatin1("url"))) { + KURL link(TQString::tqfromLatin1(ENTREZ_BASE_URL)); + link.addPath(TQString::tqfromLatin1(ENTREZ_LINK_CGI)); + link.addQueryItem(TQString::tqfromLatin1("tool"), TQString::tqfromLatin1("Tellico")); + link.addQueryItem(TQString::tqfromLatin1("cmd"), TQString::tqfromLatin1("llinks")); + link.addQueryItem(TQString::tqfromLatin1("db"), m_dbname); + link.addQueryItem(TQString::tqfromLatin1("dbfrom"), m_dbname); + link.addQueryItem(TQString::tqfromLatin1("id"), TQString::number(id)); + + TQDomDocument linkDom = FileHandler::readXMLFile(link, false /* namespace */, true /* quiet */); // need eLinkResult/LinkSet/IdUrlList/IdUrlSet/ObjUrl/Url - QDomNode linkNode = linkDom.namedItem(QString::fromLatin1("eLinkResult")) - .namedItem(QString::fromLatin1("LinkSet")) - .namedItem(QString::fromLatin1("IdUrlList")) - .namedItem(QString::fromLatin1("IdUrlSet")) - .namedItem(QString::fromLatin1("ObjUrl")) - .namedItem(QString::fromLatin1("Url")); + TQDomNode linkNode = linkDom.namedItem(TQString::tqfromLatin1("eLinkResult")) + .namedItem(TQString::tqfromLatin1("LinkSet")) + .namedItem(TQString::tqfromLatin1("IdUrlList")) + .namedItem(TQString::tqfromLatin1("IdUrlSet")) + .namedItem(TQString::tqfromLatin1("ObjUrl")) + .namedItem(TQString::tqfromLatin1("Url")); if(!linkNode.isNull()) { - QString u = linkNode.toElement().text(); + TQString u = linkNode.toElement().text(); // myDebug() << u << endl; if(!u.isEmpty()) { - if(!coll->hasField(QString::fromLatin1("url"))) { - Data::FieldPtr field = new Data::Field(QString::fromLatin1("url"), i18n("URL"), Data::Field::URL); + if(!coll->hasField(TQString::tqfromLatin1("url"))) { + Data::FieldPtr field = new Data::Field(TQString::tqfromLatin1("url"), i18n("URL"), Data::Field::URL); field->setCategory(i18n("Miscellaneous")); coll->addField(field); } - e->setField(QString::fromLatin1("url"), u); + e->setField(TQString::tqfromLatin1("url"), u); } } } const StringMap customFields = EntrezFetcher::customFields(); for(StringMap::ConstIterator it = customFields.begin(); it != customFields.end(); ++it) { - if(!m_fields.contains(it.key())) { + if(!m_fields.tqcontains(it.key())) { coll->removeField(it.key()); } } @@ -419,7 +419,7 @@ Tellico::Data::EntryPtr EntrezFetcher::fetchEntry(uint uid_) { } void EntrezFetcher::initXSLTHandler() { - QString xsltfile = locate("appdata", QString::fromLatin1("pubmed2tellico.xsl")); + TQString xsltfile = locate("appdata", TQString::tqfromLatin1("pubmed2tellico.xsl")); if(xsltfile.isEmpty()) { kdWarning() << "EntrezFetcher::initXSLTHandler() - can not locate pubmed2tellico.xsl." << endl; return; @@ -441,19 +441,19 @@ void EntrezFetcher::initXSLTHandler() { void EntrezFetcher::updateEntry(Data::EntryPtr entry_) { // myDebug() << "EntrezFetcher::updateEntry()" << endl; - QString s = entry_->field(QString::fromLatin1("pmid")); + TQString s = entry_->field(TQString::tqfromLatin1("pmid")); if(!s.isEmpty()) { search(PubmedID, s); return; } - s = entry_->field(QString::fromLatin1("doi")); + s = entry_->field(TQString::tqfromLatin1("doi")); if(!s.isEmpty()) { search(DOI, s); return; } - s = entry_->field(QString::fromLatin1("title")); + s = entry_->field(TQString::tqfromLatin1("title")); if(!s.isEmpty()) { search(Title, s); return; @@ -463,18 +463,18 @@ void EntrezFetcher::updateEntry(Data::EntryPtr entry_) { emit signalDone(this); // always need to emit this if not continuing with the search } -Tellico::Fetch::ConfigWidget* EntrezFetcher::configWidget(QWidget* parent_) const { - return new EntrezFetcher::ConfigWidget(parent_, this); +Tellico::Fetch::ConfigWidget* EntrezFetcher::configWidget(TQWidget* tqparent_) const { + return new EntrezFetcher::ConfigWidget(tqparent_, this); } -EntrezFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const EntrezFetcher* fetcher_/*=0*/) - : Fetch::ConfigWidget(parent_) { - QVBoxLayout* l = new QVBoxLayout(optionsWidget()); - l->addWidget(new QLabel(i18n("This source has no options."), optionsWidget())); +EntrezFetcher::ConfigWidget::ConfigWidget(TQWidget* tqparent_, const EntrezFetcher* fetcher_/*=0*/) + : Fetch::ConfigWidget(tqparent_) { + TQVBoxLayout* l = new TQVBoxLayout(optionsWidget()); + l->addWidget(new TQLabel(i18n("This source has no options."), optionsWidget())); l->addStretch(); // now add additional fields widget - addFieldsWidget(EntrezFetcher::customFields(), fetcher_ ? fetcher_->m_fields : QStringList()); + addFieldsWidget(EntrezFetcher::customFields(), fetcher_ ? fetcher_->m_fields : TQStringList()); } void EntrezFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) { @@ -482,16 +482,16 @@ void EntrezFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) { slotSetModified(false); } -QString EntrezFetcher::ConfigWidget::preferredName() const { +TQString EntrezFetcher::ConfigWidget::preferredName() const { return EntrezFetcher::defaultName(); } //static Tellico::StringMap EntrezFetcher::customFields() { StringMap map; - map[QString::fromLatin1("institution")] = i18n("Institution"); - map[QString::fromLatin1("abstract")] = i18n("Abstract"); - map[QString::fromLatin1("url")] = i18n("URL"); + map[TQString::tqfromLatin1("institution")] = i18n("Institution"); + map[TQString::tqfromLatin1("abstract")] = i18n("Abstract"); + map[TQString::tqfromLatin1("url")] = i18n("URL"); return map; } |