summaryrefslogtreecommitdiffstats
path: root/src/fetch/isbndbfetcher.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/isbndbfetcher.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/isbndbfetcher.cpp')
-rw-r--r--src/fetch/isbndbfetcher.cpp138
1 files changed, 69 insertions, 69 deletions
diff --git a/src/fetch/isbndbfetcher.cpp b/src/fetch/isbndbfetcher.cpp
index 5ffc379..92fb084 100644
--- a/src/fetch/isbndbfetcher.cpp
+++ b/src/fetch/isbndbfetcher.cpp
@@ -25,10 +25,10 @@
#include <kstandarddirs.h>
#include <kconfig.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>
namespace {
static const int ISBNDB_RETURNS_PER_REQUEST = 10;
@@ -39,8 +39,8 @@ namespace {
using Tellico::Fetch::ISBNdbFetcher;
-ISBNdbFetcher::ISBNdbFetcher(QObject* parent_, const char* name_)
- : Fetcher(parent_, name_), m_xsltHandler(0),
+ISBNdbFetcher::ISBNdbFetcher(TQObject* tqparent_, const char* name_)
+ : Fetcher(tqparent_, name_), m_xsltHandler(0),
m_limit(ISBNDB_MAX_RETURNS_TOTAL), m_page(1), m_total(-1), m_countOffset(0),
m_job(0), m_started(false) {
}
@@ -50,11 +50,11 @@ ISBNdbFetcher::~ISBNdbFetcher() {
m_xsltHandler = 0;
}
-QString ISBNdbFetcher::defaultName() {
+TQString ISBNdbFetcher::defaultName() {
return i18n("ISBNdb.com");
}
-QString ISBNdbFetcher::source() const {
+TQString ISBNdbFetcher::source() const {
return m_name.isEmpty() ? defaultName() : m_name;
}
@@ -66,7 +66,7 @@ void ISBNdbFetcher::readConfigHook(const KConfigGroup& config_) {
Q_UNUSED(config_);
}
-void ISBNdbFetcher::search(FetchKey key_, const QString& value_) {
+void ISBNdbFetcher::search(FetchKey key_, const TQString& value_) {
m_key = key_;
m_value = value_.stripWhiteSpace();
m_started = true;
@@ -76,7 +76,7 @@ void ISBNdbFetcher::search(FetchKey key_, const QString& value_) {
m_countOffset = 0;
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;
}
@@ -94,35 +94,35 @@ void ISBNdbFetcher::doSearch() {
// myDebug() << "ISBNdbFetcher::search() - value = " << value_ << endl;
- KURL u(QString::fromLatin1(ISBNDB_BASE_URL));
- u.addQueryItem(QString::fromLatin1("access_key"), QString::fromLatin1(ISBNDB_APP_ID));
- u.addQueryItem(QString::fromLatin1("results"), QString::fromLatin1("details,authors,subjects,texts"));
- u.addQueryItem(QString::fromLatin1("page_number"), QString::number(m_page));
+ KURL u(TQString::tqfromLatin1(ISBNDB_BASE_URL));
+ u.addQueryItem(TQString::tqfromLatin1("access_key"), TQString::tqfromLatin1(ISBNDB_APP_ID));
+ u.addQueryItem(TQString::tqfromLatin1("results"), TQString::tqfromLatin1("details,authors,subjects,texts"));
+ u.addQueryItem(TQString::tqfromLatin1("page_number"), TQString::number(m_page));
switch(m_key) {
case Title:
- u.addQueryItem(QString::fromLatin1("index1"), QString::fromLatin1("title"));
- u.addQueryItem(QString::fromLatin1("value1"), m_value);
+ u.addQueryItem(TQString::tqfromLatin1("index1"), TQString::tqfromLatin1("title"));
+ u.addQueryItem(TQString::tqfromLatin1("value1"), m_value);
break;
case Person:
// yes, this also queries titles, too, it's a limitation of the isbndb api service
- u.addQueryItem(QString::fromLatin1("index1"), QString::fromLatin1("combined"));
- u.addQueryItem(QString::fromLatin1("value1"), m_value);
+ u.addQueryItem(TQString::tqfromLatin1("index1"), TQString::tqfromLatin1("combined"));
+ u.addQueryItem(TQString::tqfromLatin1("value1"), m_value);
break;
case Keyword:
- u.addQueryItem(QString::fromLatin1("index1"), QString::fromLatin1("full"));
- u.addQueryItem(QString::fromLatin1("value1"), m_value);
+ u.addQueryItem(TQString::tqfromLatin1("index1"), TQString::tqfromLatin1("full"));
+ u.addQueryItem(TQString::tqfromLatin1("value1"), m_value);
break;
case ISBN:
- u.addQueryItem(QString::fromLatin1("index1"), QString::fromLatin1("isbn"));
+ u.addQueryItem(TQString::tqfromLatin1("index1"), TQString::tqfromLatin1("isbn"));
{
// only grab first value
- QString v = m_value.section(QChar(';'), 0);
+ TQString v = m_value.section(TQChar(';'), 0);
v.remove('-');
- u.addQueryItem(QString::fromLatin1("value1"), v);
+ u.addQueryItem(TQString::tqfromLatin1("value1"), v);
}
break;
@@ -134,10 +134,10 @@ void ISBNdbFetcher::doSearch() {
// myDebug() << "ISBNdbFetcher::search() - 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 ISBNdbFetcher::stop() {
@@ -154,8 +154,8 @@ void ISBNdbFetcher::stop() {
emit signalDone(this);
}
-void ISBNdbFetcher::slotData(KIO::Job*, const QByteArray& data_) {
- QDataStream stream(m_data, IO_WriteOnly | IO_Append);
+void ISBNdbFetcher::slotData(KIO::Job*, const TQByteArray& data_) {
+ TQDataStream stream(m_data, IO_WriteOnly | IO_Append);
stream.writeRawBytes(data_.data(), data_.size());
}
@@ -178,26 +178,26 @@ void ISBNdbFetcher::slotComplete(KIO::Job* job_) {
#if 0
kdWarning() << "Remove debug from isbndbfetcher.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
- QDomDocument dom;
+ TQDomDocument dom;
if(!dom.setContent(m_data, false)) {
kdWarning() << "ISBNdbFetcher::slotComplete() - server did not return valid XML." << endl;
return;
}
if(m_total == -1) {
- QDomNode n = dom.documentElement().namedItem(QString::fromLatin1("BookList"));
- QDomElement e = n.toElement();
+ TQDomNode n = dom.documentElement().namedItem(TQString::tqfromLatin1("BookList"));
+ TQDomElement e = n.toElement();
if(!e.isNull()) {
- m_total = e.attribute(QString::fromLatin1("total_results"), QString::number(-1)).toInt();
+ m_total = e.attribute(TQString::tqfromLatin1("total_results"), TQString::number(-1)).toInt();
}
}
@@ -210,7 +210,7 @@ void ISBNdbFetcher::slotComplete(KIO::Job* job_) {
}
// 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();
@@ -224,15 +224,15 @@ void ISBNdbFetcher::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("cr_year")).isEmpty()) {
- desc += QChar('/') + entry->field(QString::fromLatin1("cr_year"));
- } else if(!entry->field(QString::fromLatin1("pub_year")).isEmpty()){
- desc += QChar('/') + entry->field(QString::fromLatin1("pub_year"));
+ TQString desc = entry->field(TQString::tqfromLatin1("author"))
+ + TQChar('/') + entry->field(TQString::tqfromLatin1("publisher"));
+ if(!entry->field(TQString::tqfromLatin1("cr_year")).isEmpty()) {
+ desc += TQChar('/') + entry->field(TQString::tqfromLatin1("cr_year"));
+ } else if(!entry->field(TQString::tqfromLatin1("pub_year")).isEmpty()){
+ desc += TQChar('/') + entry->field(TQString::tqfromLatin1("pub_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);
++m_numResults;
@@ -241,10 +241,10 @@ void ISBNdbFetcher::slotComplete(KIO::Job* job_) {
// are there any additional results to get?
m_hasMoreResults = m_page * ISBNDB_RETURNS_PER_REQUEST < m_total;
- const int currentTotal = QMIN(m_total, m_limit);
+ const int currentTotal = TQMIN(m_total, m_limit);
if(m_page * ISBNDB_RETURNS_PER_REQUEST < currentTotal) {
int foundCount = (m_page-1) * ISBNDB_RETURNS_PER_REQUEST + coll->entryCount();
- message(i18n("Results from %1: %2/%3").arg(source()).arg(foundCount).arg(m_total), MessageHandler::Status);
+ message(i18n("Results from %1: %2/%3").tqarg(source()).tqarg(foundCount).tqarg(m_total), MessageHandler::tqStatus);
++m_page;
m_countOffset = 0;
doSearch();
@@ -265,32 +265,32 @@ Tellico::Data::EntryPtr ISBNdbFetcher::fetchEntry(uint uid_) {
}
// if the publisher id is set, then we need to grab the real publisher name
- const QString id = entry->field(QString::fromLatin1("pub_id"));
+ const TQString id = entry->field(TQString::tqfromLatin1("pub_id"));
if(!id.isEmpty()) {
- KURL u(QString::fromLatin1(ISBNDB_BASE_URL));
- u.setFileName(QString::fromLatin1("publishers.xml"));
- u.addQueryItem(QString::fromLatin1("access_key"), QString::fromLatin1(ISBNDB_APP_ID));
- u.addQueryItem(QString::fromLatin1("index1"), QString::fromLatin1("publisher_id"));
- u.addQueryItem(QString::fromLatin1("value1"), id);
+ KURL u(TQString::tqfromLatin1(ISBNDB_BASE_URL));
+ u.setFileName(TQString::tqfromLatin1("publishers.xml"));
+ u.addQueryItem(TQString::tqfromLatin1("access_key"), TQString::tqfromLatin1(ISBNDB_APP_ID));
+ u.addQueryItem(TQString::tqfromLatin1("index1"), TQString::tqfromLatin1("publisher_id"));
+ u.addQueryItem(TQString::tqfromLatin1("value1"), id);
- QDomDocument dom = FileHandler::readXMLFile(u, true);
+ TQDomDocument dom = FileHandler::readXMLFile(u, true);
if(!dom.isNull()) {
- QString pub = dom.documentElement().namedItem(QString::fromLatin1("PublisherList"))
- .namedItem(QString::fromLatin1("PublisherData"))
- .namedItem(QString::fromLatin1("Name"))
+ TQString pub = dom.documentElement().namedItem(TQString::tqfromLatin1("PublisherList"))
+ .namedItem(TQString::tqfromLatin1("PublisherData"))
+ .namedItem(TQString::tqfromLatin1("Name"))
.toElement().text();
if(!pub.isEmpty()) {
- entry->setField(QString::fromLatin1("publisher"), pub);
+ entry->setField(TQString::tqfromLatin1("publisher"), pub);
}
}
- entry->setField(QString::fromLatin1("pub_id"), QString());
+ entry->setField(TQString::tqfromLatin1("pub_id"), TQString());
}
return entry;
}
void ISBNdbFetcher::initXSLTHandler() {
- QString xsltfile = locate("appdata", QString::fromLatin1("isbndb2tellico.xsl"));
+ TQString xsltfile = locate("appdata", TQString::tqfromLatin1("isbndb2tellico.xsl"));
if(xsltfile.isEmpty()) {
kdWarning() << "ISBNdbFetcher::initXSLTHandler() - can not locate isbndb2tellico.xsl." << endl;
return;
@@ -314,14 +314,14 @@ void ISBNdbFetcher::updateEntry(Data::EntryPtr entry_) {
// limit to top 5 results
m_limit = 5;
- QString isbn = entry_->field(QString::fromLatin1("isbn"));
+ TQString isbn = entry_->field(TQString::tqfromLatin1("isbn"));
if(!isbn.isEmpty()) {
search(Fetch::ISBN, isbn);
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()) {
m_limit = 10; // raise limit so more possibility of match
search(Fetch::Title, t);
@@ -332,18 +332,18 @@ void ISBNdbFetcher::updateEntry(Data::EntryPtr entry_) {
emit signalDone(this); // always need to emit this if not continuing with the search
}
-Tellico::Fetch::ConfigWidget* ISBNdbFetcher::configWidget(QWidget* parent_) const {
- return new ISBNdbFetcher::ConfigWidget(parent_, this);
+Tellico::Fetch::ConfigWidget* ISBNdbFetcher::configWidget(TQWidget* tqparent_) const {
+ return new ISBNdbFetcher::ConfigWidget(tqparent_, this);
}
-ISBNdbFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const ISBNdbFetcher*/*=0*/)
- : Fetch::ConfigWidget(parent_) {
- QVBoxLayout* l = new QVBoxLayout(optionsWidget());
- l->addWidget(new QLabel(i18n("This source has no options."), optionsWidget()));
+ISBNdbFetcher::ConfigWidget::ConfigWidget(TQWidget* tqparent_, const ISBNdbFetcher*/*=0*/)
+ : Fetch::ConfigWidget(tqparent_) {
+ TQVBoxLayout* l = new TQVBoxLayout(optionsWidget());
+ l->addWidget(new TQLabel(i18n("This source has no options."), optionsWidget()));
l->addStretch();
}
-QString ISBNdbFetcher::ConfigWidget::preferredName() const {
+TQString ISBNdbFetcher::ConfigWidget::preferredName() const {
return ISBNdbFetcher::defaultName();
}