[tellico] /: Add a DBUS option for filtering exported entries.

Robby Stephenson null at kde.org
Fri Jul 7 02:15:15 UTC 2017


Git commit 098d5fe1c57971aae98af6f9d4cfe6f6b2c44202 by Robby Stephenson.
Committed on 07/07/2017 at 02:13.
Pushed by rstephenson into branch 'master'.

Add a DBUS option for filtering exported entries.

Existing DBUS commands continue to work. The 'filtered' boolean
argument defaults to false, meaning no filter. If 'filtered' is true,
then the current filter is used to limit the exported entries.

Also update the documentation.

BUG: 382035
FIXED-IN: true

M  +4    -0    ChangeLog
M  +12   -6    doc/advanced.docbook
M  +2    -2    src/dbusinterface.cpp
M  +11   -11   src/dbusinterface.h
M  +2    -3    src/exportdialog.cpp
M  +1    -1    src/exportdialog.h
M  +3    -2    src/mainwindow.cpp
M  +1    -1    src/mainwindow.h

https://commits.kde.org/tellico/098d5fe1c57971aae98af6f9d4cfe6f6b2c44202

diff --git a/ChangeLog b/ChangeLog
index f3048361..80462fce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-07-06  Robby Stephenson  <robby at periapsis.org>
+
+	* Add DBUS option for filtering exported entries (Bug 382035).
+
 2017-07-02  Robby Stephenson  <robby at periapsis.org>
 
 	* Fixed bug of running out of memory when writing very large XML files (Bug 380832).
diff --git a/doc/advanced.docbook b/doc/advanced.docbook
index 4a0b1e81..aba4f9bc 100644
--- a/doc/advanced.docbook
+++ b/doc/advanced.docbook
@@ -47,11 +47,11 @@ bool importTellico(QString file, QString action)
 bool importBibtex(QString file, QString action)
 bool importMODS(QString file, QString action)
 bool importRIS(QString file, QString action)
-bool exportXML(QString file)
-bool exportZip(QString file)
-bool exportBibtex(QString file)
-bool exportHTML(QString file)
-bool exportCSV(QString file)
+bool exportXML(QString file, bool filtered)
+bool exportZip(QString file, bool filtered)
+bool exportBibtex(QString file, bool filtered)
+bool exportHTML(QString file, bool filtered)
+bool exportCSV(QString file, bool filtered)
 QList<int> selectedEntries()
 QList<int> filteredEntries()
 void openFile(QString file)
@@ -64,7 +64,7 @@ For the four import commands, the first argument is the file to import, and the
 </para>
 
 <para>
-The current open collection in &appname; may be exported to a file, in either Tellico &XML; format, Tellico ZIP format, Bibtex, &HTML;, or comma-separated values (CSV).
+The current open collection in &appname; may be exported to a file, in either Tellico &XML; format, Tellico ZIP format, Bibtex, &HTML;, or comma-separated values (CSV). The export commands take an optional argument to specify whether the collection should be limited to the current filter or not.
 </para>
 
 <para>A list of the entry IDs currently selected or being filtered is able to facilitate showing or updating entries in the view.</para>
@@ -131,6 +131,12 @@ Here are some examples for scripting &appname; using the &DBus; interface.
 </screen>
 
 <screen width="40">
+<emphasis>Export a Bibtex file using the current filter</emphasis>
+<prompt>%</prompt> <userinput>qdbus org.kde.tellico /Tellico org.kde.tellico.exportBibtex ~/documents/reference.bib true</userinput>
+<computeroutput>true</computeroutput>
+</screen>
+
+<screen width="40">
 <emphasis>Echo the citation key of the current selection</emphasis>
 <prompt>%</prompt> <userinput>qdbus org.kde.tellico /Collections org.kde.tellico.selectedBibtexKeys</userinput>
 <computeroutput>stephenson2004</computeroutput>
diff --git a/src/dbusinterface.cpp b/src/dbusinterface.cpp
index 3133639b..97f6084a 100644
--- a/src/dbusinterface.cpp
+++ b/src/dbusinterface.cpp
@@ -82,8 +82,8 @@ bool ApplicationInterface::importFile(Tellico::Import::Format format, const QUrl
   return m_mainWindow->importFile(format, url, action);
 }
 
-bool ApplicationInterface::exportCollection(Tellico::Export::Format format, const QUrl& url) {
-  return m_mainWindow->exportCollection(format, url);
+bool ApplicationInterface::exportCollection(Tellico::Export::Format format, const QUrl& url, bool filtered) {
+  return m_mainWindow->exportCollection(format, url, filtered);
 }
 
 CollectionInterface::CollectionInterface(QObject* parent_) : QObject(parent_) {
diff --git a/src/dbusinterface.h b/src/dbusinterface.h
index eb7e0646..7ced2993 100644
--- a/src/dbusinterface.h
+++ b/src/dbusinterface.h
@@ -54,16 +54,16 @@ public Q_SLOTS:
   Q_SCRIPTABLE bool importRIS(const QString& file, const QString& action)
     { return importFile(Import::RIS, QUrl::fromUserInput(file), actionType(action)); }
 
-  Q_SCRIPTABLE bool exportXML(const QString& file)
-    { return exportCollection(Export::TellicoXML, QUrl::fromUserInput(file)); }
-  Q_SCRIPTABLE bool exportZip(const QString& file)
-    { return exportCollection(Export::TellicoZip, QUrl::fromUserInput(file)); }
-  Q_SCRIPTABLE bool exportBibtex(const QString& file)
-    { return exportCollection(Export::Bibtex, QUrl::fromUserInput(file)); }
-  Q_SCRIPTABLE bool exportHTML(const QString& file)
-    { return exportCollection(Export::HTML, QUrl::fromUserInput(file)); }
-  Q_SCRIPTABLE bool exportCSV(const QString& file)
-    { return exportCollection(Export::CSV, QUrl::fromUserInput(file)); }
+  Q_SCRIPTABLE bool exportXML(const QString& file, bool filtered=false)
+    { return exportCollection(Export::TellicoXML, QUrl::fromUserInput(file), filtered); }
+  Q_SCRIPTABLE bool exportZip(const QString& file, bool filtered=false)
+    { return exportCollection(Export::TellicoZip, QUrl::fromUserInput(file), filtered); }
+  Q_SCRIPTABLE bool exportBibtex(const QString& file, bool filtered=false)
+    { return exportCollection(Export::Bibtex, QUrl::fromUserInput(file), filtered); }
+  Q_SCRIPTABLE bool exportHTML(const QString& file, bool filtered=false)
+    { return exportCollection(Export::HTML, QUrl::fromUserInput(file), filtered); }
+  Q_SCRIPTABLE bool exportCSV(const QString& file, bool filtered=false)
+    { return exportCollection(Export::CSV, QUrl::fromUserInput(file), filtered); }
 
   Q_SCRIPTABLE QList<int> selectedEntries() const;
   Q_SCRIPTABLE QList<int> filteredEntries() const;
@@ -74,7 +74,7 @@ public Q_SLOTS:
 
 private:
   virtual bool importFile(Import::Format format, const QUrl& url, Import::Action action);
-  virtual bool exportCollection(Export::Format format, const QUrl& url);
+  virtual bool exportCollection(Export::Format format, const QUrl& url, bool filtered);
 
   Import::Action actionType(const QString& actionName);
 
diff --git a/src/exportdialog.cpp b/src/exportdialog.cpp
index 078d92a9..495c56d1 100644
--- a/src/exportdialog.cpp
+++ b/src/exportdialog.cpp
@@ -287,11 +287,10 @@ Tellico::Export::Target ExportDialog::exportTarget(Tellico::Export::Format forma
 }
 
 // static
-bool ExportDialog::exportCollection(Data::CollPtr coll_, Tellico::Export::Format format_, const QUrl& url_) {
+bool ExportDialog::exportCollection(Data::CollPtr coll_, Data::EntryList entries_, Export::Format format_, const QUrl& url_) {
   QScopedPointer<Export::Exporter> exp(exporter(format_, coll_));
-
   exp->setURL(url_);
-  exp->setEntries(coll_->entries());
+  exp->setEntries(entries_);
 
   KConfigGroup config(KSharedConfig::openConfig(), "ExportOptions");
   long options = 0;
diff --git a/src/exportdialog.h b/src/exportdialog.h
index e898275b..dcb2b10b 100644
--- a/src/exportdialog.h
+++ b/src/exportdialog.h
@@ -53,7 +53,7 @@ public:
   bool exportURL(const QUrl& url=QUrl()) const;
 
   static Export::Target exportTarget(Export::Format format);
-  static bool exportCollection(Data::CollPtr coll, Export::Format format, const QUrl& url);
+  static bool exportCollection(Data::CollPtr coll, Data::EntryList entries, Export::Format format, const QUrl& url);
 
 private Q_SLOTS:
   void slotSaveOptions();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 21e5d9de..d9e1f4d9 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2025,7 +2025,7 @@ bool MainWindow::importFile(Tellico::Import::Format format_, const QUrl& url_, T
   return !failed; // return true means success
 }
 
-bool MainWindow::exportCollection(Tellico::Export::Format format_, const QUrl& url_) {
+bool MainWindow::exportCollection(Tellico::Export::Format format_, const QUrl& url_, bool filtered_) {
   if(!url_.isValid()) {
     myDebug() << "invalid URL:" << url_;
     return false;
@@ -2048,7 +2048,8 @@ bool MainWindow::exportCollection(Tellico::Export::Format format_, const QUrl& u
     return false;
   }
 
-  return ExportDialog::exportCollection(coll, format_, url_);
+  return ExportDialog::exportCollection(coll, filtered_ ? Controller::self()->visibleEntries() : coll->entries(),
+                                        format_, url_);
 }
 
 bool MainWindow::showEntry(Data::ID id) {
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 95332cee..cf48ea65 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -127,7 +127,7 @@ public:
   /**
    * Used by DCOP to export to a file.
    */
-  virtual bool exportCollection(Export::Format format, const QUrl& url);
+  virtual bool exportCollection(Export::Format format, const QUrl& url, bool filtered);
   /**
    * Used by DCOP
    */


More information about the kde-doc-english mailing list