diff options
Diffstat (limited to 'src/fetch/srufetcher.cpp')
-rw-r--r-- | src/fetch/srufetcher.cpp | 228 |
1 files changed, 114 insertions, 114 deletions
diff --git a/src/fetch/srufetcher.cpp b/src/fetch/srufetcher.cpp index 1d7289b..96ca7d4 100644 --- a/src/fetch/srufetcher.cpp +++ b/src/fetch/srufetcher.cpp @@ -35,9 +35,9 @@ #include <kaccelmanager.h> #include <knuminput.h> -#include <qlabel.h> -#include <qlayout.h> -#include <qwhatsthis.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqwhatsthis.h> //#define SRU_DEBUG @@ -51,12 +51,12 @@ namespace { using Tellico::Fetch::SRUFetcher; using Tellico::Fetch::SRUConfigWidget; -SRUFetcher::SRUFetcher(QObject* parent_, const char* name_) - : Fetcher(parent_, name_), m_job(0), m_MARCXMLHandler(0), m_MODSHandler(0), m_started(false) { +SRUFetcher::SRUFetcher(TQObject* tqparent_, const char* name_) + : Fetcher(tqparent_, name_), m_job(0), m_MARCXMLHandler(0), m_MODSHandler(0), m_started(false) { } -SRUFetcher::SRUFetcher(const QString& name_, const QString& host_, uint port_, const QString& path_, - QObject* parent_) : Fetcher(parent_), +SRUFetcher::SRUFetcher(const TQString& name_, const TQString& host_, uint port_, const TQString& path_, + TQObject* tqparent_) : Fetcher(tqparent_), m_host(host_), m_port(port_), m_path(path_), m_job(0), m_MARCXMLHandler(0), m_MODSHandler(0), m_started(false) { m_name = name_; // m_name is protected in super class @@ -69,11 +69,11 @@ SRUFetcher::~SRUFetcher() { m_MODSHandler = 0; } -QString SRUFetcher::defaultName() { +TQString SRUFetcher::defaultName() { return i18n("SRU Server"); } -QString SRUFetcher::source() const { +TQString SRUFetcher::source() const { return m_name.isEmpty() ? defaultName() : m_name; } @@ -92,14 +92,14 @@ void SRUFetcher::readConfigHook(const KConfigGroup& config_) { if(m_path.isEmpty()) { m_path = config_.readEntry("Database"); } - if(!m_path.startsWith(QChar('/'))) { + if(!m_path.startsWith(TQChar('/'))) { m_path.prepend('/'); } - m_format = config_.readEntry("Format", QString::fromLatin1("mods")); + m_format = config_.readEntry("Format", TQString::tqfromLatin1("mods")); m_fields = config_.readListEntry("Custom Fields"); } -void SRUFetcher::search(FetchKey key_, const QString& value_) { +void SRUFetcher::search(FetchKey key_, const TQString& value_) { if(m_host.isEmpty() || m_path.isEmpty()) { myDebug() << "SRUFetcher::search() - settings are not set!" << endl; stop(); @@ -109,35 +109,35 @@ void SRUFetcher::search(FetchKey key_, const QString& value_) { m_started = true; #ifdef SRU_DEBUG - KURL u = KURL::fromPathOrURL(QString::fromLatin1("/home/robby/sru.xml")); + KURL u = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/sru.xml")); #else KURL u; - u.setProtocol(QString::fromLatin1("http")); + u.setProtocol(TQString::tqfromLatin1("http")); u.setHost(m_host); u.setPort(m_port); u.setPath(m_path); - u.addQueryItem(QString::fromLatin1("operation"), QString::fromLatin1("searchRetrieve")); - u.addQueryItem(QString::fromLatin1("version"), QString::fromLatin1("1.1")); - u.addQueryItem(QString::fromLatin1("maximumRecords"), QString::number(SRU_MAX_RECORDS)); - u.addQueryItem(QString::fromLatin1("recordSchema"), m_format); + u.addQueryItem(TQString::tqfromLatin1("operation"), TQString::tqfromLatin1("searchRetrieve")); + u.addQueryItem(TQString::tqfromLatin1("version"), TQString::tqfromLatin1("1.1")); + u.addQueryItem(TQString::tqfromLatin1("maximumRecords"), TQString::number(SRU_MAX_RECORDS)); + u.addQueryItem(TQString::tqfromLatin1("recordSchema"), m_format); const int type = Kernel::self()->collectionType(); - QString str = QChar('"') + value_ + QChar('"'); + TQString str = TQChar('"') + value_ + TQChar('"'); switch(key_) { case Title: - u.addQueryItem(QString::fromLatin1("query"), QString::fromLatin1("dc.title=") + str); + u.addQueryItem(TQString::tqfromLatin1("query"), TQString::tqfromLatin1("dc.title=") + str); break; case Person: { - QString s; + TQString s; if(type == Data::Collection::Book || type == Data::Collection::Bibtex) { - s = QString::fromLatin1("author=") + str + QString::fromLatin1(" or dc.author=") + str; + s = TQString::tqfromLatin1("author=") + str + TQString::tqfromLatin1(" or dc.author=") + str; } else { - s = QString::fromLatin1("dc.creator=") + str + QString::fromLatin1(" or dc.editor=") + str; + s = TQString::tqfromLatin1("dc.creator=") + str + TQString::tqfromLatin1(" or dc.editor=") + str; } - u.addQueryItem(QString::fromLatin1("query"), s); + u.addQueryItem(TQString::tqfromLatin1("query"), s); } break; @@ -146,7 +146,7 @@ void SRUFetcher::search(FetchKey key_, const QString& value_) { str.remove('-'); // limit to first isbn str = str.section(';', 0, 0); - u.addQueryItem(QString::fromLatin1("query"), QString::fromLatin1("bath.isbn=") + str); + u.addQueryItem(TQString::tqfromLatin1("query"), TQString::tqfromLatin1("bath.isbn=") + str); break; case LCCN: @@ -155,22 +155,22 @@ void SRUFetcher::search(FetchKey key_, const QString& value_) { str.remove('-'); str = str.section(';', 0, 0); // also try formalized lccn - QString lccn = LCCNValidator::formalize(str); - u.addQueryItem(QString::fromLatin1("query"), - QString::fromLatin1("bath.lccn=") + str + - QString::fromLatin1(" or bath.lccn=") + lccn + TQString lccn = LCCNValidator::formalize(str); + u.addQueryItem(TQString::tqfromLatin1("query"), + TQString::tqfromLatin1("bath.lccn=") + str + + TQString::tqfromLatin1(" or bath.lccn=") + lccn ); } break; case Keyword: - u.addQueryItem(QString::fromLatin1("query"), str); + u.addQueryItem(TQString::tqfromLatin1("query"), str); break; case Raw: { - QString key = value_.section('=', 0, 0).stripWhiteSpace(); - QString str = value_.section('=', 1).stripWhiteSpace(); + TQString key = value_.section('=', 0, 0).stripWhiteSpace(); + TQString str = value_.section('=', 1).stripWhiteSpace(); u.addQueryItem(key, str); } break; @@ -184,10 +184,10 @@ void SRUFetcher::search(FetchKey key_, const QString& value_) { // myDebug() << u.prettyURL() << 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 SRUFetcher::stop() { @@ -203,8 +203,8 @@ void SRUFetcher::stop() { emit signalDone(this); } -void SRUFetcher::slotData(KIO::Job*, const QByteArray& data_) { - QDataStream stream(m_data, IO_WriteOnly | IO_Append); +void SRUFetcher::slotData(KIO::Job*, const TQByteArray& data_) { + TQDataStream stream(m_data, IO_WriteOnly | IO_Append); stream.writeRawBytes(data_.data(), data_.size()); } @@ -224,24 +224,24 @@ void SRUFetcher::slotComplete(KIO::Job* job_) { } Data::CollPtr coll; - QString msg; + TQString msg; - const QString result = QString::fromUtf8(m_data, m_data.size()); + const TQString result = TQString::fromUtf8(m_data, m_data.size()); // first check for SRU errors - const QString& diag = XML::nsZingDiag; + const TQString& diag = XML::nsZingDiag; Import::XMLImporter xmlImporter(result); - QDomDocument dom = xmlImporter.domDocument(); + TQDomDocument dom = xmlImporter.domDocument(); - QDomNodeList diagList = dom.elementsByTagNameNS(diag, QString::fromLatin1("diagnostic")); + TQDomNodeList diagList = dom.elementsByTagNameNS(diag, TQString::tqfromLatin1("diagnostic")); for(uint i = 0; i < diagList.count(); ++i) { - QDomElement elem = diagList.item(i).toElement(); - QDomNodeList nodeList1 = elem.elementsByTagNameNS(diag, QString::fromLatin1("message")); - QDomNodeList nodeList2 = elem.elementsByTagNameNS(diag, QString::fromLatin1("details")); + TQDomElement elem = diagList.item(i).toElement(); + TQDomNodeList nodeList1 = elem.elementsByTagNameNS(diag, TQString::tqfromLatin1("message")); + TQDomNodeList nodeList2 = elem.elementsByTagNameNS(diag, TQString::tqfromLatin1("details")); for(uint j = 0; j < nodeList1.count(); ++j) { - QString d = nodeList1.item(j).toElement().text(); + TQString d = nodeList1.item(j).toElement().text(); if(!d.isEmpty()) { - QString d2 = nodeList2.item(j).toElement().text(); + TQString d2 = nodeList2.item(j).toElement().text(); if(!d2.isEmpty()) { d += " (" + d2 + ')'; } @@ -252,7 +252,7 @@ void SRUFetcher::slotComplete(KIO::Job* job_) { } } - QString modsResult; + TQString modsResult; if(m_format == Latin1Literal("mods")) { modsResult = result; } else if(m_format == Latin1Literal("marcxml") && initMARCXMLHandler()) { @@ -275,7 +275,7 @@ void SRUFetcher::slotComplete(KIO::Job* job_) { } if(coll && !msg.isEmpty()) { - message(msg, coll->entryCount() == 0 ? MessageHandler::Warning : MessageHandler::Status); + message(msg, coll->entryCount() == 0 ? MessageHandler::Warning : MessageHandler::tqStatus); } if(!coll) { @@ -289,46 +289,46 @@ void SRUFetcher::slotComplete(KIO::Job* job_) { const StringMap customFields = SRUFetcher::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()); } } Data::EntryVec entries = coll->entries(); for(Data::EntryVec::Iterator entry = entries.begin(); entry != entries.end(); ++entry) { - QString desc; + TQString desc; switch(coll->type()) { case Data::Collection::Book: - 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")); + 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")); } break; case Data::Collection::Video: - desc = entry->field(QString::fromLatin1("studio")) - + QChar('/') - + entry->field(QString::fromLatin1("director")) - + QChar('/') - + entry->field(QString::fromLatin1("year")); + desc = entry->field(TQString::tqfromLatin1("studio")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("director")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("year")); break; case Data::Collection::Album: - desc = entry->field(QString::fromLatin1("artist")) - + QChar('/') - + entry->field(QString::fromLatin1("label")) - + QChar('/') - + entry->field(QString::fromLatin1("year")); + desc = entry->field(TQString::tqfromLatin1("artist")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("label")) + + TQChar('/') + + entry->field(TQString::tqfromLatin1("year")); break; default: break; } - 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, entry); emit signalResultFound(r); } @@ -341,20 +341,20 @@ Tellico::Data::EntryPtr SRUFetcher::fetchEntry(uint uid_) { void SRUFetcher::updateEntry(Data::EntryPtr entry_) { // myDebug() << "SRUFetcher::updateEntry() - " << source() << ": " << entry_->title() << endl; - QString isbn = entry_->field(QString::fromLatin1("isbn")); + TQString isbn = entry_->field(TQString::tqfromLatin1("isbn")); if(!isbn.isEmpty()) { search(Fetch::ISBN, isbn); return; } - QString lccn = entry_->field(QString::fromLatin1("lccn")); + TQString lccn = entry_->field(TQString::tqfromLatin1("lccn")); if(!lccn.isEmpty()) { search(Fetch::LCCN, lccn); 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; @@ -369,7 +369,7 @@ bool SRUFetcher::initMARCXMLHandler() { return true; } - QString xsltfile = locate("appdata", QString::fromLatin1("MARC21slim2MODS3.xsl")); + TQString xsltfile = locate("appdata", TQString::tqfromLatin1("MARC21slim2MODS3.xsl")); if(xsltfile.isEmpty()) { kdWarning() << "SRUFetcher::initHandlers() - can not locate MARC21slim2MODS3.xsl." << endl; return false; @@ -393,7 +393,7 @@ bool SRUFetcher::initMODSHandler() { return true; } - QString xsltfile = locate("appdata", QString::fromLatin1("mods2tellico.xsl")); + TQString xsltfile = locate("appdata", TQString::tqfromLatin1("mods2tellico.xsl")); if(xsltfile.isEmpty()) { kdWarning() << "SRUFetcher::initHandlers() - can not locate mods2tellico.xsl." << endl; return false; @@ -412,79 +412,79 @@ bool SRUFetcher::initMODSHandler() { return true; } -Tellico::Fetch::Fetcher::Ptr SRUFetcher::libraryOfCongress(QObject* parent_) { - return new SRUFetcher(i18n("Library of Congress (US)"), QString::fromLatin1("z3950.loc.gov"), 7090, - QString::fromLatin1("voyager"), parent_); +Tellico::Fetch::Fetcher::Ptr SRUFetcher::libraryOfCongress(TQObject* tqparent_) { + return new SRUFetcher(i18n("Library of Congress (US)"), TQString::tqfromLatin1("z3950.loc.gov"), 7090, + TQString::tqfromLatin1("voyager"), tqparent_); } // static Tellico::StringMap SRUFetcher::customFields() { StringMap map; - map[QString::fromLatin1("address")] = i18n("Address"); - map[QString::fromLatin1("abstract")] = i18n("Abstract"); + map[TQString::tqfromLatin1("address")] = i18n("Address"); + map[TQString::tqfromLatin1("abstract")] = i18n("Abstract"); return map; } -Tellico::Fetch::ConfigWidget* SRUFetcher::configWidget(QWidget* parent_) const { - return new SRUConfigWidget(parent_, this); +Tellico::Fetch::ConfigWidget* SRUFetcher::configWidget(TQWidget* tqparent_) const { + return new SRUConfigWidget(tqparent_, this); } -SRUConfigWidget::SRUConfigWidget(QWidget* parent_, const SRUFetcher* fetcher_ /*=0*/) - : ConfigWidget(parent_) { - QGridLayout* l = new QGridLayout(optionsWidget(), 4, 2); +SRUConfigWidget::SRUConfigWidget(TQWidget* tqparent_, const SRUFetcher* fetcher_ /*=0*/) + : ConfigWidget(tqparent_) { + TQGridLayout* l = new TQGridLayout(optionsWidget(), 4, 2); l->setSpacing(4); l->setColStretch(1, 10); int row = -1; - QLabel* label = new QLabel(i18n("Hos&t: "), optionsWidget()); + TQLabel* label = new TQLabel(i18n("Hos&t: "), optionsWidget()); l->addWidget(label, ++row, 0); m_hostEdit = new GUI::LineEdit(optionsWidget()); - connect(m_hostEdit, SIGNAL(textChanged(const QString&)), SLOT(slotSetModified())); - connect(m_hostEdit, SIGNAL(textChanged(const QString&)), SIGNAL(signalName(const QString&))); - connect(m_hostEdit, SIGNAL(textChanged(const QString&)), SLOT(slotCheckHost())); + connect(m_hostEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotSetModified())); + connect(m_hostEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SIGNAL(signalName(const TQString&))); + connect(m_hostEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotCheckHost())); l->addWidget(m_hostEdit, row, 1); - QString w = i18n("Enter the host name of the server."); - QWhatsThis::add(label, w); - QWhatsThis::add(m_hostEdit, w); + TQString w = i18n("Enter the host name of the server."); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_hostEdit, w); label->setBuddy(m_hostEdit); - label = new QLabel(i18n("&Port: "), optionsWidget()); + label = new TQLabel(i18n("&Port: "), optionsWidget()); l->addWidget(label, ++row, 0); m_portSpinBox = new KIntSpinBox(0, 999999, 1, SRU_DEFAULT_PORT, 10, optionsWidget()); - connect(m_portSpinBox, SIGNAL(valueChanged(int)), SLOT(slotSetModified())); + connect(m_portSpinBox, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotSetModified())); l->addWidget(m_portSpinBox, row, 1); - w = i18n("Enter the port number of the server. The default is %1.").arg(SRU_DEFAULT_PORT); - QWhatsThis::add(label, w); - QWhatsThis::add(m_portSpinBox, w); + w = i18n("Enter the port number of the server. The default is %1.").tqarg(SRU_DEFAULT_PORT); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_portSpinBox, w); label->setBuddy(m_portSpinBox); - label = new QLabel(i18n("Path: "), optionsWidget()); + label = new TQLabel(i18n("Path: "), optionsWidget()); l->addWidget(label, ++row, 0); m_pathEdit = new GUI::LineEdit(optionsWidget()); - connect(m_pathEdit, SIGNAL(textChanged(const QString&)), SLOT(slotSetModified())); + connect(m_pathEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotSetModified())); l->addWidget(m_pathEdit, row, 1); w = i18n("Enter the path to the database used by the server."); - QWhatsThis::add(label, w); - QWhatsThis::add(m_pathEdit, w); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_pathEdit, w); label->setBuddy(m_pathEdit); - label = new QLabel(i18n("Format: "), optionsWidget()); + label = new TQLabel(i18n("Format: "), optionsWidget()); l->addWidget(label, ++row, 0); m_formatCombo = new GUI::ComboBox(optionsWidget()); - m_formatCombo->insertItem(QString::fromLatin1("MODS"), QString::fromLatin1("mods")); - m_formatCombo->insertItem(QString::fromLatin1("MARCXML"), QString::fromLatin1("marcxml")); - m_formatCombo->insertItem(QString::fromLatin1("Dublin Core"), QString::fromLatin1("dc")); - connect(m_formatCombo, SIGNAL(activated(int)), SLOT(slotSetModified())); + m_formatCombo->insertItem(TQString::tqfromLatin1("MODS"), TQString::tqfromLatin1("mods")); + m_formatCombo->insertItem(TQString::tqfromLatin1("MARCXML"), TQString::tqfromLatin1("marcxml")); + m_formatCombo->insertItem(TQString::tqfromLatin1("Dublin Core"), TQString::tqfromLatin1("dc")); + connect(m_formatCombo, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSetModified())); l->addWidget(m_formatCombo, row, 1); w = i18n("Enter the result format used by the server."); - QWhatsThis::add(label, w); - QWhatsThis::add(m_formatCombo, w); + TQWhatsThis::add(label, w); + TQWhatsThis::add(m_formatCombo, w); label->setBuddy(m_formatCombo); l->setRowStretch(++row, 1); // now add additional fields widget - addFieldsWidget(SRUFetcher::customFields(), fetcher_ ? fetcher_->m_fields : QStringList()); + addFieldsWidget(SRUFetcher::customFields(), fetcher_ ? fetcher_->m_fields : TQStringList()); if(fetcher_) { m_hostEdit->setText(fetcher_->m_host); @@ -496,7 +496,7 @@ SRUConfigWidget::SRUConfigWidget(QWidget* parent_, const SRUFetcher* fetcher_ /* } void SRUConfigWidget::saveConfig(KConfigGroup& config_) { - QString s = m_hostEdit->text().stripWhiteSpace(); + TQString s = m_hostEdit->text().stripWhiteSpace(); if(!s.isEmpty()) { config_.writeEntry("Host", s); } @@ -516,15 +516,15 @@ void SRUConfigWidget::saveConfig(KConfigGroup& config_) { slotSetModified(false); } -QString SRUConfigWidget::preferredName() const { - QString s = m_hostEdit->text(); +TQString SRUConfigWidget::preferredName() const { + TQString s = m_hostEdit->text(); return s.isEmpty() ? SRUFetcher::defaultName() : s; } void SRUConfigWidget::slotCheckHost() { - QString s = m_hostEdit->text(); + TQString s = m_hostEdit->text(); // someone might be pasting a full URL, check that - if(s.find(':') > -1 || s.find('/') > -1) { + if(s.tqfind(':') > -1 || s.tqfind('/') > -1) { KURL u(s); if(u.isValid()) { m_hostEdit->setText(u.host()); |