[office/tellico/4.2] src: Disable multiple value searching for the sources that don't support

Robby Stephenson <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 0b96bc33f257654bc0ca885f7a00f7049f07d2ae by Robby Stephenson.
Committed on 17/08/2026 at 00:54.
Pushed by rstephenson into branch '4.2'.

Disable multiple value searching for the sources that don't support

M  +9    -0    src/fetch/bibliosharefetcher.cpp
M  +2    -1    src/fetch/bibliosharefetcher.h
M  +5    -0    src/fetch/dbcfetcher.cpp
M  +1    -0    src/fetch/dbcfetcher.h
M  +4    -0    src/fetch/fetcher.h
M  +5    -0    src/fetch/ibsfetcher.cpp
M  +1    -0    src/fetch/ibsfetcher.h
M  +5    -0    src/fetch/isfdbfetcher.cpp
M  +1    -0    src/fetch/isfdbfetcher.h
M  +5    -0    src/fetch/opdsfetcher.cpp
M  +1    -0    src/fetch/opdsfetcher.h
M  +5    -0    src/fetch/springerfetcher.cpp
M  +1    -0    src/fetch/springerfetcher.h
M  +8    -2    src/fetchdialog.cpp
M  +1    -0    src/fetchdialog.h
M  +8    -0    src/tests/fetchertest.cpp

https://invent.kde.org/office/tellico/-/commit/0b96bc33f257654bc0ca885f7a00f7049f07d2ae

diff --git a/src/fetch/bibliosharefetcher.cpp b/src/fetch/bibliosharefetcher.cpp
index 1f0a23fe3..dfa479b4d 100644
--- a/src/fetch/bibliosharefetcher.cpp
+++ b/src/fetch/bibliosharefetcher.cpp
@@ -65,6 +65,15 @@ QString BiblioShareFetcher::attribution() const {
   return TC_I18N3(providedBy, QStringLiteral("https://www.booknetcanada.ca/biblioshare"), QStringLiteral("BNC BiblioShare"));
 }
 
+bool BiblioShareFetcher::canSearch(FetchKey k) const {
+  return k == ISBN;
+}
+
+// only single values
+bool BiblioShareFetcher::canSearchMultiple() const {
+  return false;
+}
+
 bool BiblioShareFetcher::canFetch(int type) const {
   return type == Data::Collection::Book || type == Data::Collection::Bibtex;
 }
diff --git a/src/fetch/bibliosharefetcher.h b/src/fetch/bibliosharefetcher.h
index 0b4f8635a..6072ff290 100644
--- a/src/fetch/bibliosharefetcher.h
+++ b/src/fetch/bibliosharefetcher.h
@@ -45,7 +45,8 @@ public:
 
   virtual QString source() const override;
   virtual QString attribution() const override;
-  virtual bool canSearch(FetchKey k) const override { return k == ISBN; }
+  virtual bool canSearch(FetchKey k) const override;
+  virtual bool canSearchMultiple() const override;
   virtual Type type() const override { return BiblioShare; }
   virtual bool canFetch(int type) const override;
   virtual void readConfigHook(const KConfigGroup& config) override;
diff --git a/src/fetch/dbcfetcher.cpp b/src/fetch/dbcfetcher.cpp
index 185fbac37..9ec17adb0 100644
--- a/src/fetch/dbcfetcher.cpp
+++ b/src/fetch/dbcfetcher.cpp
@@ -56,6 +56,11 @@ bool DBCFetcher::canSearch(Fetch::FetchKey k) const {
   return k == Title || k == Person || k == Keyword || k == ISBN;
 }
 
+// only single ISBN values
+bool DBCFetcher::canSearchMultiple() const {
+  return false;
+}
+
 bool DBCFetcher::canFetch(int type) const {
   return type == Data::Collection::Book || type == Data::Collection::Bibtex;
 }
diff --git a/src/fetch/dbcfetcher.h b/src/fetch/dbcfetcher.h
index a6dac363b..b745df82a 100644
--- a/src/fetch/dbcfetcher.h
+++ b/src/fetch/dbcfetcher.h
@@ -52,6 +52,7 @@ public:
    */
   virtual QString source() const override;
   virtual bool canSearch(FetchKey k) const override;
+  virtual bool canSearchMultiple() const override;
   virtual Type type() const override { return DBC; }
   virtual bool canFetch(int type) const override;
   virtual void readConfigHook(const KConfigGroup& config) override;
diff --git a/src/fetch/fetcher.h b/src/fetch/fetcher.h
index 821086992..c5e28c2bb 100644
--- a/src/fetch/fetcher.h
+++ b/src/fetch/fetcher.h
@@ -70,6 +70,10 @@ public:
    * Returns true if the fetcher can search using a certain key.
    */
   virtual bool canSearch(FetchKey key) const = 0;
+  /**
+   * Returns true if the fetcher can search for multiple ISBN, UPC, or LCCN values
+   */
+  virtual bool canSearchMultiple() const { return true; }
   /**
    * Allow sources to provide custom labels for user-defined keys
    */
diff --git a/src/fetch/ibsfetcher.cpp b/src/fetch/ibsfetcher.cpp
index 20c5da63a..0e80ff3f6 100644
--- a/src/fetch/ibsfetcher.cpp
+++ b/src/fetch/ibsfetcher.cpp
@@ -75,6 +75,11 @@ bool IBSFetcher::canSearch(Fetch::FetchKey k) const {
   return k == Title || k == Person || k == ISBN;
 }
 
+// only single ISBN values
+bool IBSFetcher::canSearchMultiple() const {
+  return false;
+}
+
 void IBSFetcher::readConfigHook(const KConfigGroup& config_) {
   Q_UNUSED(config_);
 }
diff --git a/src/fetch/ibsfetcher.h b/src/fetch/ibsfetcher.h
index 22733b637..169304a9b 100644
--- a/src/fetch/ibsfetcher.h
+++ b/src/fetch/ibsfetcher.h
@@ -54,6 +54,7 @@ public:
   virtual QString source() const override;
   virtual bool isSearching() const override { return m_started; }
   virtual bool canSearch(FetchKey k) const override;
+  virtual bool canSearchMultiple() const override;
   virtual void stop() override;
   virtual Data::EntryPtr fetchEntryHook(uint uid) override;
   virtual Type type() const override { return IBS; }
diff --git a/src/fetch/isfdbfetcher.cpp b/src/fetch/isfdbfetcher.cpp
index 3ed1fc932..c39a71e3e 100644
--- a/src/fetch/isfdbfetcher.cpp
+++ b/src/fetch/isfdbfetcher.cpp
@@ -62,6 +62,11 @@ bool ISFDBFetcher::canSearch(Fetch::FetchKey k) const {
   return k == ISBN || k == LCCN;
 }
 
+// only single values
+bool ISFDBFetcher::canSearchMultiple() const {
+  return false;
+}
+
 bool ISFDBFetcher::canFetch(int type) const {
   return type == Data::Collection::Book;
 }
diff --git a/src/fetch/isfdbfetcher.h b/src/fetch/isfdbfetcher.h
index b306b852e..9db0111f2 100644
--- a/src/fetch/isfdbfetcher.h
+++ b/src/fetch/isfdbfetcher.h
@@ -54,6 +54,7 @@ public:
   virtual QString source() const override;
   virtual QString attribution() const override;
   virtual bool canSearch(FetchKey k) const override;
+  virtual bool canSearchMultiple() const override;
   virtual Type type() const override { return ISFDB; }
   virtual bool canFetch(int type) const override;
   virtual void readConfigHook(const KConfigGroup& config) override;
diff --git a/src/fetch/opdsfetcher.cpp b/src/fetch/opdsfetcher.cpp
index a9bb6efae..ebb13aa82 100644
--- a/src/fetch/opdsfetcher.cpp
+++ b/src/fetch/opdsfetcher.cpp
@@ -167,6 +167,11 @@ bool OPDSFetcher::canSearch(Fetch::FetchKey k) const {
   return k == Title || k == Keyword || k == ISBN;
 }
 
+// only single values
+bool OPDSFetcher::canSearchMultiple() const {
+  return false;
+}
+
 bool OPDSFetcher::canFetch(int type) const {
   return type == Data::Collection::Book || type == Data::Collection::Bibtex;
 }
diff --git a/src/fetch/opdsfetcher.h b/src/fetch/opdsfetcher.h
index da74102e9..85667778e 100644
--- a/src/fetch/opdsfetcher.h
+++ b/src/fetch/opdsfetcher.h
@@ -65,6 +65,7 @@ public:
   virtual QString icon() const override;
   virtual bool isSearching() const override { return m_started; }
   virtual bool canSearch(FetchKey k) const override;
+  virtual bool canSearchMultiple() const override;
   virtual void stop() override;
   virtual Data::EntryPtr fetchEntryHook(uint uid) override;
   virtual Type type() const override { return OPDS; }
diff --git a/src/fetch/springerfetcher.cpp b/src/fetch/springerfetcher.cpp
index aafbb1990..4b28e69de 100644
--- a/src/fetch/springerfetcher.cpp
+++ b/src/fetch/springerfetcher.cpp
@@ -67,6 +67,11 @@ bool SpringerFetcher::canSearch(Fetch::FetchKey k) const  {
   return k == Title || k == Person || k == Keyword || k == ISBN || k == DOI;
 }
 
+// only single ISBN values
+bool SpringerFetcher::canSearchMultiple() const {
+  return false;
+}
+
 bool SpringerFetcher::canFetch(int type) const {
   return type == Data::Collection::Bibtex;
 }
diff --git a/src/fetch/springerfetcher.h b/src/fetch/springerfetcher.h
index f357ac21b..255ea05dc 100644
--- a/src/fetch/springerfetcher.h
+++ b/src/fetch/springerfetcher.h
@@ -48,6 +48,7 @@ public:
   virtual QString source() const override;
   virtual QString attribution() const override;
   virtual bool canSearch(FetchKey k) const override;
+  virtual bool canSearchMultiple() const override;
   virtual Type type() const override { return Springer; }
   virtual bool canFetch(int type) const override;
   virtual void readConfigHook(const KConfigGroup& config) override;
diff --git a/src/fetchdialog.cpp b/src/fetchdialog.cpp
index cc02c264e..d60bf0a54 100644
--- a/src/fetchdialog.cpp
+++ b/src/fetchdialog.cpp
@@ -136,6 +136,7 @@ FetchDialog::FetchDialog(QWidget* parent_)
     , m_started(false)
     , m_resultCount(0)
     , m_treeWasResized(false)
+    , m_canSearchMultiple(true)
     , m_barcodePreview(nullptr)
     , m_barcodeRecognitionThread(nullptr) {
   setModal(false);
@@ -684,7 +685,10 @@ void FetchDialog::slotInit() {
 void FetchDialog::slotKeyChanged(int idx_) {
   const int key = m_keyCombo->itemData(idx_).toInt();
   if(key == Fetch::ISBN || key == Fetch::UPC || key == Fetch::LCCN) {
-    m_multipleISBN->setEnabled(true);
+    if(!m_canSearchMultiple) {
+      m_multipleISBN->setChecked(false); // uncheck if not allowed
+    }
+    m_multipleISBN->setEnabled(m_canSearchMultiple);
     if(key == Fetch::ISBN) {
       m_valueLineEdit->setValidator(new ISBNValidator(this));
     } else if(key == Fetch::UPC) {
@@ -705,7 +709,6 @@ void FetchDialog::slotKeyChanged(int idx_) {
   } else {
     m_multipleISBN->setChecked(false);
     m_multipleISBN->setEnabled(false);
-//    slotMultipleISBN(false);
     m_valueLineEdit->setValidator(nullptr);
   }
 
@@ -728,6 +731,9 @@ void FetchDialog::slotSourceChanged(const QString& source_) {
     return;
   }
 
+  // does the fetcher support searching for multiple values?
+  m_canSearchMultiple = (*fIt)->canSearchMultiple();
+
   static const auto map = Fetch::Manager::self()->keyMap();
   const int curr = m_keyCombo->currentData().toInt();
   m_keyCombo->clear();
diff --git a/src/fetchdialog.h b/src/fetchdialog.h
index ce5ad0d6f..6bb33029c 100644
--- a/src/fetchdialog.h
+++ b/src/fetchdialog.h
@@ -147,6 +147,7 @@ private:
   QList<Fetch::FetchResult*> m_results;
   int m_collType;
   bool m_treeWasResized;
+  bool m_canSearchMultiple;
 
   QLabel* m_barcodePreview;
   barcodeRecognition::barcodeRecognitionThread* m_barcodeRecognitionThread;
diff --git a/src/tests/fetchertest.cpp b/src/tests/fetchertest.cpp
index 1866138d7..bd5e9a4d2 100644
--- a/src/tests/fetchertest.cpp
+++ b/src/tests/fetchertest.cpp
@@ -61,6 +61,14 @@ void FetcherTest::testType() {
     QVERIFY(!f->canFetch(Tellico::Fetch::FetchLast)); // invalid
     QVERIFY(!f->canSearch(Tellico::Fetch::Raw)); // don't expose Raw to user
 
+    // semantically, any fetcher that says no multiple values implies
+    // that it can otherwise search single ISBN, UPC, or LCCN values
+    if(!f->canSearchMultiple()) {
+      QVERIFY(f->canSearch(Tellico::Fetch::ISBN) ||
+              f->canSearch(Tellico::Fetch::UPC) ||
+              f->canSearch(Tellico::Fetch::LCCN));
+    }
+
     Tellico::Data::Collection::Type cType = Tellico::Data::Collection::Base;
     // BoardGame is the last collection type (currently)
     while(!f->canFetch(cType) && cType <= Tellico::Data::Collection::BoardGame) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.