File indexing completed on 2024-05-12 05:09:42
0001 /*************************************************************************** 0002 Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #ifndef TELLICO_SRUFETCHER_H 0026 #define TELLICO_SRUFETCHER_H 0027 0028 #include "fetcher.h" 0029 #include "configwidget.h" 0030 0031 #include <QPointer> 0032 0033 class QSpinBox; 0034 0035 class KJob; 0036 namespace KIO { 0037 class StoredTransferJob; 0038 } 0039 0040 namespace Tellico { 0041 class XSLTHandler; 0042 namespace GUI { 0043 class LineEdit; 0044 class ComboBox; 0045 class StringMapWidget; 0046 } 0047 namespace Fetch { 0048 0049 /** 0050 * A fetcher for SRU servers. 0051 * Right now, only MODS is supported. 0052 * 0053 * @author Robby Stephenson 0054 */ 0055 class SRUFetcher : public Fetcher { 0056 Q_OBJECT 0057 0058 public: 0059 /** 0060 */ 0061 SRUFetcher(QObject* parent); 0062 SRUFetcher(const QString& name, const QString& host, uint port, 0063 const QString& dbname, const QString& format, 0064 QObject* parent); 0065 /** 0066 */ 0067 virtual ~SRUFetcher(); 0068 0069 /** 0070 */ 0071 virtual QString source() const Q_DECL_OVERRIDE; 0072 virtual bool isSearching() const Q_DECL_OVERRIDE { return m_started; } 0073 virtual bool canSearch(FetchKey k) const Q_DECL_OVERRIDE; 0074 virtual void stop() Q_DECL_OVERRIDE; 0075 virtual Data::EntryPtr fetchEntryHook(uint uid) Q_DECL_OVERRIDE; 0076 virtual Type type() const Q_DECL_OVERRIDE { return SRU; } 0077 virtual bool canFetch(int type) const Q_DECL_OVERRIDE; 0078 virtual void readConfigHook(const KConfigGroup& config) Q_DECL_OVERRIDE; 0079 0080 virtual Fetch::ConfigWidget* configWidget(QWidget* parent) const Q_DECL_OVERRIDE; 0081 0082 class ConfigWidget; 0083 friend class ConfigWidget; 0084 0085 static QString defaultName(); 0086 static QString defaultIcon(); 0087 static StringHash allOptionalFields(); 0088 0089 static Fetcher::Ptr libraryOfCongress(QObject* parent); 0090 0091 private Q_SLOTS: 0092 void slotComplete(KJob* job); 0093 0094 private: 0095 virtual void search() Q_DECL_OVERRIDE; 0096 virtual FetchRequest updateRequest(Data::EntryPtr entry) Q_DECL_OVERRIDE; 0097 bool initMARCXMLHandler(); 0098 bool initMODSHandler(); 0099 bool initSRWHandler(); 0100 0101 QString m_scheme; 0102 QString m_host; 0103 uint m_port; 0104 QString m_path; 0105 QString m_format; 0106 StringMap m_queryMap; 0107 0108 QHash<uint, Data::EntryPtr> m_entries; 0109 QPointer<KIO::StoredTransferJob> m_job; 0110 XSLTHandler* m_MARCXMLHandler; 0111 XSLTHandler* m_MODSHandler; 0112 XSLTHandler* m_SRWHandler; 0113 bool m_started; 0114 }; 0115 0116 class SRUFetcher::ConfigWidget : public Fetch::ConfigWidget { 0117 Q_OBJECT 0118 0119 public: 0120 explicit ConfigWidget(QWidget* parent_, const SRUFetcher* fetcher = nullptr); 0121 virtual void saveConfigHook(KConfigGroup& config) Q_DECL_OVERRIDE; 0122 virtual QString preferredName() const Q_DECL_OVERRIDE; 0123 0124 private Q_SLOTS: 0125 void slotCheckHost(); 0126 0127 private: 0128 GUI::ComboBox* m_schemeCombo; 0129 GUI::LineEdit* m_hostEdit; 0130 QSpinBox* m_portSpinBox; 0131 GUI::LineEdit* m_pathEdit; 0132 GUI::ComboBox* m_formatCombo; 0133 GUI::StringMapWidget* m_queryTree; 0134 }; 0135 0136 } // end namespace 0137 } // end namespace 0138 #endif