diff options
Diffstat (limited to 'src/fetch/crossreffetcher.cpp')
-rw-r--r-- | src/fetch/crossreffetcher.cpp | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/src/fetch/crossreffetcher.cpp b/src/fetch/crossreffetcher.cpp index 8c5d303..6840e6d 100644 --- a/src/fetch/crossreffetcher.cpp +++ b/src/fetch/crossreffetcher.cpp @@ -29,10 +29,10 @@ #include <klineedit.h> #include <kactivelabel.h> -#include <qlabel.h> -#include <qwhatsthis.h> -#include <qlayout.h> -#include <qfile.h> +#include <tqlabel.h> +#include <tqwhatsthis.h> +#include <tqlayout.h> +#include <tqfile.h> // #define CROSSREF_TEST @@ -44,8 +44,8 @@ namespace { using Tellico::Fetch::CrossRefFetcher; -CrossRefFetcher::CrossRefFetcher(QObject* parent_) - : Fetcher(parent_), m_xsltHandler(0), m_job(0), m_started(false) { +CrossRefFetcher::CrossRefFetcher(TQObject* tqparent_) + : Fetcher(tqparent_), m_xsltHandler(0), m_job(0), m_started(false) { } CrossRefFetcher::~CrossRefFetcher() { @@ -53,11 +53,11 @@ CrossRefFetcher::~CrossRefFetcher() { m_xsltHandler = 0; } -QString CrossRefFetcher::defaultName() { - return QString::fromLatin1("CrossRef"); +TQString CrossRefFetcher::defaultName() { + return TQString::tqfromLatin1("CrossRef"); } -QString CrossRefFetcher::source() const { +TQString CrossRefFetcher::source() const { return m_name.isEmpty() ? defaultName() : m_name; } @@ -66,7 +66,7 @@ bool CrossRefFetcher::canFetch(int type) const { } void CrossRefFetcher::readConfigHook(const KConfigGroup& config_) { - QString s = config_.readEntry("User"); + TQString s = config_.readEntry("User"); if(!s.isEmpty()) { m_user = s; } @@ -76,19 +76,19 @@ void CrossRefFetcher::readConfigHook(const KConfigGroup& config_) { } } -void CrossRefFetcher::search(FetchKey key_, const QString& value_) { +void CrossRefFetcher::search(FetchKey key_, const TQString& value_) { m_key = key_; m_value = value_.stripWhiteSpace(); m_started = true; if(m_user.isEmpty() || m_password.isEmpty()) { - message(i18n("%1 requires a username and password.").arg(source()), MessageHandler::Warning); + message(i18n("%1 requires a username and password.").tqarg(source()), MessageHandler::Warning); stop(); return; } 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; } @@ -104,10 +104,10 @@ void CrossRefFetcher::search(FetchKey key_, const QString& value_) { } 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 CrossRefFetcher::stop() { @@ -124,8 +124,8 @@ void CrossRefFetcher::stop() { emit signalDone(this); } -void CrossRefFetcher::slotData(KIO::Job*, const QByteArray& data_) { - QDataStream stream(m_data, IO_WriteOnly | IO_Append); +void CrossRefFetcher::slotData(KIO::Job*, const TQByteArray& data_) { + TQDataStream stream(m_data, IO_WriteOnly | IO_Append); stream.writeRawBytes(data_.data(), data_.size()); } @@ -148,11 +148,11 @@ void CrossRefFetcher::slotComplete(KIO::Job* job_) { #if 0 kdWarning() << "Remove debug from crossreffetcher.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 @@ -166,7 +166,7 @@ void CrossRefFetcher::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(); @@ -182,13 +182,13 @@ void CrossRefFetcher::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); } @@ -199,19 +199,19 @@ void CrossRefFetcher::slotComplete(KIO::Job* job_) { Tellico::Data::EntryPtr CrossRefFetcher::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); } @@ -223,9 +223,9 @@ Tellico::Data::EntryPtr CrossRefFetcher::fetchEntry(uint uid_) { void CrossRefFetcher::initXSLTHandler() { #ifdef CROSSREF_USE_UNIXREF - QString xsltfile = locate("appdata", QString::fromLatin1("unixref2tellico.xsl")); + TQString xsltfile = locate("appdata", TQString::tqfromLatin1("unixref2tellico.xsl")); #else - QString xsltfile = locate("appdata", QString::fromLatin1("crossref2tellico.xsl")); + TQString xsltfile = locate("appdata", TQString::tqfromLatin1("crossref2tellico.xsl")); #endif if(xsltfile.isEmpty()) { kdWarning() << "CrossRefFetcher::initXSLTHandler() - can not locate xslt file." << endl; @@ -245,16 +245,16 @@ void CrossRefFetcher::initXSLTHandler() { } } -KURL CrossRefFetcher::searchURL(FetchKey key_, const QString& value_) const { - KURL u(QString::fromLatin1(CROSSREF_BASE_URL)); +KURL CrossRefFetcher::searchURL(FetchKey key_, const TQString& value_) const { + KURL u(TQString::tqfromLatin1(CROSSREF_BASE_URL)); #ifdef CROSSREF_USE_UNIXREF - u.addQueryItem(QString::fromLatin1("format"), QString::fromLatin1("unixref")); + u.addQueryItem(TQString::tqfromLatin1("format"), TQString::tqfromLatin1("unixref")); #endif - u.addQueryItem(QString::fromLatin1("req_dat"), QString::fromLatin1("ourl_%1:%2").arg(m_user, m_password)); + u.addQueryItem(TQString::tqfromLatin1("req_dat"), TQString::tqfromLatin1("ourl_%1:%2").tqarg(m_user, m_password)); switch(key_) { case DOI: - u.addQueryItem(QString::fromLatin1("rft_id"), QString::fromLatin1("info:doi/%1").arg(value_)); + u.addQueryItem(TQString::tqfromLatin1("rft_id"), TQString::tqfromLatin1("info:doi/%1").tqarg(value_)); break; default: @@ -263,14 +263,14 @@ KURL CrossRefFetcher::searchURL(FetchKey key_, const QString& value_) const { } #ifdef CROSSREF_TEST - u = KURL::fromPathOrURL(QString::fromLatin1("/home/robby/crossref.xml")); + u = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/crossref.xml")); #endif myDebug() << "CrossRefFetcher::search() - url: " << u.url() << endl; return u; } void CrossRefFetcher::updateEntry(Data::EntryPtr entry_) { - QString doi = entry_->field(QString::fromLatin1("doi")); + TQString doi = entry_->field(TQString::tqfromLatin1("doi")); if(!doi.isEmpty()) { search(Fetch::DOI, doi); return; @@ -278,7 +278,7 @@ void CrossRefFetcher::updateEntry(Data::EntryPtr entry_) { #if 0 // 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); @@ -298,13 +298,13 @@ void CrossRefFetcher::updateEntrySynchronous(Data::EntryPtr entry) { myDebug() << "CrossRefFetcher::updateEntrySynchronous() - username and password is required" << endl; return; } - QString doi = entry->field(QString::fromLatin1("doi")); + TQString doi = entry->field(TQString::tqfromLatin1("doi")); if(doi.isEmpty()) { return; } KURL u = searchURL(DOI, doi); - QString xml = FileHandler::readTextFile(u, true, true); + TQString xml = FileHandler::readTextFile(u, true, true); if(xml.isEmpty()) { return; } @@ -317,7 +317,7 @@ void CrossRefFetcher::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) { @@ -326,13 +326,13 @@ void CrossRefFetcher::updateEntrySynchronous(Data::EntryPtr entry) { } } -Tellico::Fetch::ConfigWidget* CrossRefFetcher::configWidget(QWidget* parent_) const { - return new CrossRefFetcher::ConfigWidget(parent_, this); +Tellico::Fetch::ConfigWidget* CrossRefFetcher::configWidget(TQWidget* tqparent_) const { + return new CrossRefFetcher::ConfigWidget(tqparent_, this); } -CrossRefFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const CrossRefFetcher* fetcher_) - : Fetch::ConfigWidget(parent_) { - QGridLayout* l = new QGridLayout(optionsWidget(), 4, 2); +CrossRefFetcher::ConfigWidget::ConfigWidget(TQWidget* tqparent_, const CrossRefFetcher* fetcher_) + : Fetch::ConfigWidget(tqparent_) { + TQGridLayout* l = new TQGridLayout(optionsWidget(), 4, 2); l->setSpacing(4); l->setColStretch(1, 10); @@ -347,26 +347,26 @@ CrossRefFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const CrossRefFetc ++row; l->addMultiCellWidget(al, row, row, 0, 1); // richtext gets weird with size - al->setMinimumWidth(al->sizeHint().width()); + al->setMinimumWidth(al->tqsizeHint().width()); - QLabel* label = new QLabel(i18n("&Username: "), optionsWidget()); + TQLabel* label = new TQLabel(i18n("&Username: "), optionsWidget()); l->addWidget(label, ++row, 0); m_userEdit = new KLineEdit(optionsWidget()); - connect(m_userEdit, SIGNAL(textChanged(const QString&)), SLOT(slotSetModified())); + connect(m_userEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotSetModified())); l->addWidget(m_userEdit, row, 1); - QString w = i18n("A username and password is required to access the CrossRef service. The password is " + TQString w = i18n("A username and password is required to access the CrossRef service. The password is " "stored as plain text in the Tellico configuration file."); - QWhatsThis::add(label, w); - QWhatsThis::add(m_userEdit, w); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_userEdit, w); label->setBuddy(m_userEdit); - label = new QLabel(i18n("&Password: "), optionsWidget()); + label = new TQLabel(i18n("&Password: "), optionsWidget()); l->addWidget(label, ++row, 0); m_passEdit = new KLineEdit(optionsWidget()); - connect(m_passEdit, SIGNAL(textChanged(const QString&)), SLOT(slotSetModified())); + connect(m_passEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotSetModified())); l->addWidget(m_passEdit, row, 1); - QWhatsThis::add(label, w); - QWhatsThis::add(m_passEdit, w); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_passEdit, w); label->setBuddy(m_passEdit); if(fetcher_) { @@ -376,7 +376,7 @@ CrossRefFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const CrossRefFetc } void CrossRefFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) { - QString s = m_userEdit->text(); + TQString s = m_userEdit->text(); config_.writeEntry("User", s); s = m_passEdit->text(); @@ -385,7 +385,7 @@ void CrossRefFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) { slotSetModified(false); } -QString CrossRefFetcher::ConfigWidget::preferredName() const { +TQString CrossRefFetcher::ConfigWidget::preferredName() const { return CrossRefFetcher::defaultName(); } |