~paulbrianstewart/ubuntu/oneiric/tellico/852247-Formatting-Fix

« back to all changes in this revision

Viewing changes to src/fetch/entrezfetcher.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-01-31 19:33:05 UTC
  • mfrom: (0.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20080131193305-9l01m5gfhykl6pkl
Tags: 1.3-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control: build-dep on kdepim-dev
  - debian/control: drop versioned python from tellico-data suggests
  - debian/rules: call dh_icons

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "../filehandler.h"
20
20
#include "../translators/xslthandler.h"
21
21
#include "../translators/tellicoimporter.h"
 
22
#include "../tellico_debug.h"
22
23
 
23
24
#include <klocale.h>
24
25
#include <kconfig.h>
63
64
  return type == Data::Collection::Bibtex;
64
65
}
65
66
 
66
 
void EntrezFetcher::readConfigHook(KConfig* config_, const QString& group_) {
67
 
  KConfigGroupSaver groupSaver(config_, group_);
68
 
  QString s = config_->readEntry("Database", QString::fromLatin1("pubmed")); // default to pubmed
 
67
void EntrezFetcher::readConfigHook(const KConfigGroup& config_) {
 
68
  QString s = config_.readEntry("Database", QString::fromLatin1(ENTREZ_DEFAULT_DATABASE)); // default to pubmed
69
69
  if(!s.isEmpty()) {
70
70
    m_dbname = s;
71
71
  }
72
 
  m_fields = config_->readListEntry("Custom Fields");
 
72
  m_fields = config_.readListEntry("Custom Fields");
73
73
}
74
74
 
75
75
void EntrezFetcher::search(FetchKey key_, const QString& value_) {
78
78
  m_total = -1;
79
79
 
80
80
// only search if current collection is a bibliography
81
 
  if(Kernel::self()->collectionType() != Data::Collection::Bibtex) {
 
81
  if(!canFetch(Kernel::self()->collectionType())) {
82
82
    myDebug() << "EntrezFetcher::search() - collection type mismatch, stopping" << endl;
83
83
    stop();
84
84
    return;
112
112
//      u.addQueryItem(QString::fromLatin1("field"), QString::fromLatin1("word"));
113
113
      break;
114
114
 
 
115
    case PubmedID:
 
116
      u.addQueryItem(QString::fromLatin1("field"), QString::fromLatin1("pmid"));
 
117
      break;
 
118
 
115
119
    case Raw:
116
120
      u.setQuery(u.query() + '&' + value_);
117
121
      break;
294
298
        }
295
299
        authors = list.join(QString::fromLatin1("; "));
296
300
      }
297
 
      if(!title.isNull() && !pubdate.isNull() && !authors.isNull()) {
 
301
      if(!title.isEmpty() && !pubdate.isEmpty() && !authors.isEmpty()) {
298
302
        break; // done now
299
303
      }
300
304
    }
368
372
    myDebug() << "EntrezFetcher::fetchEntry() - collection has multiple entries, taking first one" << endl;
369
373
  }
370
374
 
371
 
  Data::EntryPtr e = coll->entries()[0];
 
375
  Data::EntryPtr e = coll->entries().front();
372
376
 
373
377
  // try to get a link, but only if necessary
374
378
  if(m_fields.contains(QString::fromLatin1("url"))) {
375
379
    KURL link(QString::fromLatin1(ENTREZ_BASE_URL));
376
380
    link.addPath(QString::fromLatin1(ENTREZ_LINK_CGI));
377
 
    link.addQueryItem(QString::fromLatin1("tool"),  QString::fromLatin1("Tellico"));
 
381
    link.addQueryItem(QString::fromLatin1("tool"),   QString::fromLatin1("Tellico"));
378
382
    link.addQueryItem(QString::fromLatin1("cmd"),    QString::fromLatin1("llinks"));
379
383
    link.addQueryItem(QString::fromLatin1("db"),     m_dbname);
380
384
    link.addQueryItem(QString::fromLatin1("dbfrom"), m_dbname);
434
438
  }
435
439
}
436
440
 
 
441
void EntrezFetcher::updateEntry(Data::EntryPtr entry_) {
 
442
//  myDebug() << "EntrezFetcher::updateEntry()" << endl;
 
443
  QString s = entry_->field(QString::fromLatin1("pmid"));
 
444
  if(!s.isEmpty()) {
 
445
    search(PubmedID, s);
 
446
    return;
 
447
  }
 
448
 
 
449
  s = entry_->field(QString::fromLatin1("title"));
 
450
  if(!s.isEmpty()) {
 
451
    search(Title, s);
 
452
    return;
 
453
  }
 
454
 
 
455
  myDebug() << "EntrezFetcher::updateEntry() - insufficient info to search" << endl;
 
456
  emit signalDone(this); // always need to emit this if not continuing with the search
 
457
}
 
458
 
437
459
Tellico::Fetch::ConfigWidget* EntrezFetcher::configWidget(QWidget* parent_) const {
438
460
  return new EntrezFetcher::ConfigWidget(parent_, this);
439
461
}
448
470
  addFieldsWidget(EntrezFetcher::customFields(), fetcher_ ? fetcher_->m_fields : QStringList());
449
471
}
450
472
 
451
 
void EntrezFetcher::ConfigWidget::saveConfig(KConfig* config_) {
 
473
void EntrezFetcher::ConfigWidget::saveConfig(KConfigGroup& config_) {
452
474
  saveFieldsConfig(config_);
453
475
  slotSetModified(false);
454
476
}