summaryrefslogtreecommitdiffstats
path: root/src/fetch/arxivfetcher.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
commit2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 (patch)
tree18a8f0f4ac5a86dacfa74c3537551ec39bc85e75 /src/fetch/arxivfetcher.cpp
parent1d90725a4001fab9d3922b2cbcceeee5e2d1686f (diff)
downloadtellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.tar.gz
tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.zip
TQt4 port tellico
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1239054 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/fetch/arxivfetcher.cpp')
-rw-r--r--src/fetch/arxivfetcher.cpp122
1 files changed, 61 insertions, 61 deletions
diff --git a/src/fetch/arxivfetcher.cpp b/src/fetch/arxivfetcher.cpp
index 442ef30..b176d88 100644
--- a/src/fetch/arxivfetcher.cpp
+++ b/src/fetch/arxivfetcher.cpp
@@ -27,9 +27,9 @@
#include <kstandarddirs.h>
#include <kconfig.h>
-#include <qdom.h>
-#include <qlabel.h>
-#include <qlayout.h>
+#include <tqdom.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
//#define ARXIV_TEST
@@ -40,8 +40,8 @@ namespace {
using Tellico::Fetch::ArxivFetcher;
-ArxivFetcher::ArxivFetcher(QObject* parent_)
- : Fetcher(parent_), m_xsltHandler(0), m_start(0), m_job(0), m_started(false) {
+ArxivFetcher::ArxivFetcher(TQObject* tqparent_)
+ : Fetcher(tqparent_), m_xsltHandler(0), m_start(0), m_job(0), m_started(false) {
}
ArxivFetcher::~ArxivFetcher() {
@@ -49,11 +49,11 @@ ArxivFetcher::~ArxivFetcher() {
m_xsltHandler = 0;
}
-QString ArxivFetcher::defaultName() {
+TQString ArxivFetcher::defaultName() {
return i18n("arXiv.org");
}
-QString ArxivFetcher::source() const {
+TQString ArxivFetcher::source() const {
return m_name.isEmpty() ? defaultName() : m_name;
}
@@ -64,7 +64,7 @@ bool ArxivFetcher::canFetch(int type) const {
void ArxivFetcher::readConfigHook(const KConfigGroup&) {
}
-void ArxivFetcher::search(FetchKey key_, const QString& value_) {
+void ArxivFetcher::search(FetchKey key_, const TQString& value_) {
m_key = key_;
m_value = value_.stripWhiteSpace();
m_started = true;
@@ -80,7 +80,7 @@ void ArxivFetcher::continueSearch() {
void ArxivFetcher::doSearch() {
if(!canFetch(Kernel::self()->collectionType())) {
- message(i18n("%1 does not allow searching for this collection type.").arg(source()), MessageHandler::Warning);
+ message(i18n("%1 does not allow searching for this collection type.").tqarg(source()), MessageHandler::Warning);
stop();
return;
}
@@ -96,10 +96,10 @@ void ArxivFetcher::doSearch() {
}
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 ArxivFetcher::stop() {
@@ -116,8 +116,8 @@ void ArxivFetcher::stop() {
emit signalDone(this);
}
-void ArxivFetcher::slotData(KIO::Job*, const QByteArray& data_) {
- QDataStream stream(m_data, IO_WriteOnly | IO_Append);
+void ArxivFetcher::slotData(KIO::Job*, const TQByteArray& data_) {
+ TQDataStream stream(m_data, IO_WriteOnly | IO_Append);
stream.writeRawBytes(data_.data(), data_.size());
}
@@ -140,11 +140,11 @@ void ArxivFetcher::slotComplete(KIO::Job* job_) {
#if 0
kdWarning() << "Remove debug from arxivfetcher.cpp" << 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
@@ -158,21 +158,21 @@ void ArxivFetcher::slotComplete(KIO::Job* job_) {
}
if(m_total == -1) {
- QDomDocument dom;
+ TQDomDocument dom;
if(!dom.setContent(m_data, true /*namespace*/)) {
kdWarning() << "ArxivFetcher::slotComplete() - server did not return valid XML." << endl;
return;
}
// total is top level element, with attribute totalResultsAvailable
- QDomNodeList list = dom.elementsByTagNameNS(QString::fromLatin1("http://a9.com/-/spec/opensearch/1.1/"),
- QString::fromLatin1("totalResults"));
+ TQDomNodeList list = dom.elementsByTagNameNS(TQString::tqfromLatin1("http://a9.com/-/spec/opensearch/1.1/"),
+ TQString::tqfromLatin1("totalResults"));
if(list.count() > 0) {
m_total = list.item(0).toElement().text().toInt();
}
}
// assume result is always utf-8
- QString str = m_xsltHandler->applyStylesheet(QString::fromUtf8(m_data, m_data.size()));
+ TQString str = m_xsltHandler->applyStylesheet(TQString::fromUtf8(m_data, m_data.size()));
Import::TellicoImporter imp(str);
Data::CollPtr coll = imp.collection();
@@ -188,13 +188,13 @@ void ArxivFetcher::slotComplete(KIO::Job* job_) {
// might get aborted
break;
}
- QString desc = entry->field(QString::fromLatin1("author"))
- + QChar('/') + entry->field(QString::fromLatin1("publisher"));
- if(!entry->field(QString::fromLatin1("year")).isEmpty()) {
- desc += QChar('/') + entry->field(QString::fromLatin1("year"));
+ TQString desc = entry->field(TQString::tqfromLatin1("author"))
+ + TQChar('/') + entry->field(TQString::tqfromLatin1("publisher"));
+ if(!entry->field(TQString::tqfromLatin1("year")).isEmpty()) {
+ desc += TQChar('/') + entry->field(TQString::tqfromLatin1("year"));
}
- SearchResult* r = new SearchResult(this, entry->title(), desc, entry->field(QString::fromLatin1("isbn")));
+ SearchResult* r = new SearchResult(this, entry->title(), desc, entry->field(TQString::tqfromLatin1("isbn")));
m_entries.insert(r->uid, Data::EntryPtr(entry));
emit signalResultFound(r);
}
@@ -207,19 +207,19 @@ void ArxivFetcher::slotComplete(KIO::Job* job_) {
Tellico::Data::EntryPtr ArxivFetcher::fetchEntry(uint uid_) {
Data::EntryPtr entry = m_entries[uid_];
// if URL but no cover image, fetch it
- if(!entry->field(QString::fromLatin1("url")).isEmpty()) {
+ if(!entry->field(TQString::tqfromLatin1("url")).isEmpty()) {
Data::CollPtr coll = entry->collection();
- Data::FieldPtr field = coll->fieldByName(QString::fromLatin1("cover"));
+ Data::FieldPtr field = coll->fieldByName(TQString::tqfromLatin1("cover"));
if(!field && !coll->imageFields().isEmpty()) {
field = coll->imageFields().front();
} else if(!field) {
- field = new Data::Field(QString::fromLatin1("cover"), i18n("Front Cover"), Data::Field::Image);
+ field = new Data::Field(TQString::tqfromLatin1("cover"), i18n("Front Cover"), Data::Field::Image);
coll->addField(field);
}
if(entry->field(field).isEmpty()) {
- QPixmap pix = NetAccess::filePreview(entry->field(QString::fromLatin1("url")));
+ TQPixmap pix = NetAccess::filePreview(entry->field(TQString::tqfromLatin1("url")));
if(!pix.isNull()) {
- QString id = ImageFactory::addImage(pix, QString::fromLatin1("PNG"));
+ TQString id = ImageFactory::addImage(pix, TQString::tqfromLatin1("PNG"));
if(!id.isEmpty()) {
entry->setField(field, id);
}
@@ -230,7 +230,7 @@ Tellico::Data::EntryPtr ArxivFetcher::fetchEntry(uint uid_) {
}
void ArxivFetcher::initXSLTHandler() {
- QString xsltfile = locate("appdata", QString::fromLatin1("arxiv2tellico.xsl"));
+ TQString xsltfile = locate("appdata", TQString::tqfromLatin1("arxiv2tellico.xsl"));
if(xsltfile.isEmpty()) {
kdWarning() << "ArxivFetcher::initXSLTHandler() - can not locate arxiv2tellico.xsl." << endl;
return;
@@ -249,34 +249,34 @@ void ArxivFetcher::initXSLTHandler() {
}
}
-KURL ArxivFetcher::searchURL(FetchKey key_, const QString& value_) const {
- KURL u(QString::fromLatin1(ARXIV_BASE_URL));
- u.addQueryItem(QString::fromLatin1("start"), QString::number(m_start));
- u.addQueryItem(QString::fromLatin1("max_results"), QString::number(ARXIV_RETURNS_PER_REQUEST));
+KURL ArxivFetcher::searchURL(FetchKey key_, const TQString& value_) const {
+ KURL u(TQString::tqfromLatin1(ARXIV_BASE_URL));
+ u.addQueryItem(TQString::tqfromLatin1("start"), TQString::number(m_start));
+ u.addQueryItem(TQString::tqfromLatin1("max_results"), TQString::number(ARXIV_RETURNS_PER_REQUEST));
// quotes should be used if spaces are present, just use all the time
- QString quotedValue = '"' + value_ + '"';
+ TQString quotedValue = '"' + value_ + '"';
switch(key_) {
case Title:
- u.addQueryItem(QString::fromLatin1("search_query"), QString::fromLatin1("ti:%1").arg(quotedValue));
+ u.addQueryItem(TQString::tqfromLatin1("search_query"), TQString::tqfromLatin1("ti:%1").tqarg(quotedValue));
break;
case Person:
- u.addQueryItem(QString::fromLatin1("search_query"), QString::fromLatin1("au:%1").arg(quotedValue));
+ u.addQueryItem(TQString::tqfromLatin1("search_query"), TQString::tqfromLatin1("au:%1").tqarg(quotedValue));
break;
case Keyword:
// keyword gets to use all the words without being quoted
- u.addQueryItem(QString::fromLatin1("search_query"), QString::fromLatin1("all:%1").arg(value_));
+ u.addQueryItem(TQString::tqfromLatin1("search_query"), TQString::tqfromLatin1("all:%1").tqarg(value_));
break;
case ArxivID:
{
// remove prefix and/or version number
- QString value = value_;
- value.remove(QRegExp(QString::fromLatin1("^arxiv:"), false));
- value.remove(QRegExp(QString::fromLatin1("v\\d+$")));
- u.addQueryItem(QString::fromLatin1("search_query"), QString::fromLatin1("id:%1").arg(value));
+ TQString value = value_;
+ value.remove(TQRegExp(TQString::tqfromLatin1("^arxiv:"), false));
+ value.remove(TQRegExp(TQString::tqfromLatin1("v\\d+$")));
+ u.addQueryItem(TQString::tqfromLatin1("search_query"), TQString::tqfromLatin1("id:%1").tqarg(value));
}
break;
@@ -286,21 +286,21 @@ KURL ArxivFetcher::searchURL(FetchKey key_, const QString& value_) const {
}
#ifdef ARXIV_TEST
- u = KURL::fromPathOrURL(QString::fromLatin1("/home/robby/arxiv.xml"));
+ u = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/arxiv.xml"));
#endif
myDebug() << "ArxivFetcher::search() - url: " << u.url() << endl;
return u;
}
void ArxivFetcher::updateEntry(Data::EntryPtr entry_) {
- QString id = entry_->field(QString::fromLatin1("arxiv"));
+ TQString id = entry_->field(TQString::tqfromLatin1("arxiv"));
if(!id.isEmpty()) {
search(Fetch::ArxivID, id);
return;
}
// optimistically try searching for title and rely on Collection::sameEntry() to figure things out
- QString t = entry_->field(QString::fromLatin1("title"));
+ TQString t = entry_->field(TQString::tqfromLatin1("title"));
if(!t.isEmpty()) {
search(Fetch::Title, t);
return;
@@ -314,13 +314,13 @@ void ArxivFetcher::updateEntrySynchronous(Data::EntryPtr entry) {
if(!entry) {
return;
}
- QString arxiv = entry->field(QString::fromLatin1("arxiv"));
+ TQString arxiv = entry->field(TQString::tqfromLatin1("arxiv"));
if(arxiv.isEmpty()) {
return;
}
KURL u = searchURL(ArxivID, arxiv);
- QString xml = FileHandler::readTextFile(u, true, true);
+ TQString xml = FileHandler::readTextFile(u, true, true);
if(xml.isEmpty()) {
return;
}
@@ -333,33 +333,33 @@ void ArxivFetcher::updateEntrySynchronous(Data::EntryPtr entry) {
}
// assume result is always utf-8
- QString str = m_xsltHandler->applyStylesheet(xml);
+ TQString str = m_xsltHandler->applyStylesheet(xml);
Import::TellicoImporter imp(str);
Data::CollPtr coll = imp.collection();
if(coll && coll->entryCount() > 0) {
myLog() << "ArxivFetcher::updateEntrySynchronous() - found Arxiv result, merging" << endl;
Data::Collection::mergeEntry(entry, coll->entries().front(), false /*overwrite*/);
// the arxiv id might have a version#
- entry->setField(QString::fromLatin1("arxiv"),
- coll->entries().front()->field(QString::fromLatin1("arxiv")));
+ entry->setField(TQString::tqfromLatin1("arxiv"),
+ coll->entries().front()->field(TQString::tqfromLatin1("arxiv")));
}
}
-Tellico::Fetch::ConfigWidget* ArxivFetcher::configWidget(QWidget* parent_) const {
- return new ArxivFetcher::ConfigWidget(parent_, this);
+Tellico::Fetch::ConfigWidget* ArxivFetcher::configWidget(TQWidget* tqparent_) const {
+ return new ArxivFetcher::ConfigWidget(tqparent_, this);
}
-ArxivFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const ArxivFetcher*)
- : Fetch::ConfigWidget(parent_) {
- QVBoxLayout* l = new QVBoxLayout(optionsWidget());
- l->addWidget(new QLabel(i18n("This source has no options."), optionsWidget()));
+ArxivFetcher::ConfigWidget::ConfigWidget(TQWidget* tqparent_, const ArxivFetcher*)
+ : Fetch::ConfigWidget(tqparent_) {
+ TQVBoxLayout* l = new TQVBoxLayout(optionsWidget());
+ l->addWidget(new TQLabel(i18n("This source has no options."), optionsWidget()));
l->addStretch();
}
void ArxivFetcher::ConfigWidget::saveConfig(KConfigGroup&) {
}
-QString ArxivFetcher::ConfigWidget::preferredName() const {
+TQString ArxivFetcher::ConfigWidget::preferredName() const {
return ArxivFetcher::defaultName();
}