[LyX/master] Make paper search function accessible and customizable

Juergen Spitzmueller spitz at lyx.org
Thu Aug 27 06:23:02 UTC 2020


commit 8365eabd6f978d8bdc7fbcfabba83548ae409d94
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Thu Aug 27 08:45:41 2020 +0200

    Make paper search function accessible and customizable
---
 lib/Makefile.am                   |    1 -
 lib/configure.py                  |    3 +-
 lib/doc/UserGuide.lyx             |  421 +++++++++++++++++++++----------------
 lib/scripts/lyxpaperview          |   26 ---
 lib/scripts/prefs2prefs_prefs.py  |    3 +-
 lib/ui/stdcontext.inc             |    2 +-
 src/BiblioInfo.cpp                |   11 +-
 src/BiblioInfo.h                  |    5 +-
 src/LyXRC.cpp                     |   41 ++++-
 src/LyXRC.h                       |   16 +-
 src/frontends/qt/GuiPrefs.cpp     |   22 ++-
 src/frontends/qt/GuiPrefs.h       |    3 +
 src/frontends/qt/GuiView.cpp      |   10 +-
 src/frontends/qt/qt_helpers.cpp   |   16 +-
 src/frontends/qt/qt_helpers.h     |    9 +-
 src/frontends/qt/ui/PrefEditUi.ui |  291 +++++++++++++++-----------
 src/insets/InsetCitation.cpp      |   15 +-
 17 files changed, 528 insertions(+), 367 deletions(-)

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 6b5a120..dfe1986 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2511,7 +2511,6 @@ dist_scripts_DATA += \
 	scripts/legacy_lyxpreview2ppm.py \
 	scripts/listerrors \
 	scripts/lyxpak.py \
-	scripts/lyxpaperview \
 	scripts/lyxpaperview.py \
 	scripts/lyxpreview2bitmap.py \
 	scripts/lyxpreview_tools.py \
diff --git a/lib/configure.py b/lib/configure.py
index b708edf..1547000 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1310,13 +1310,12 @@ def checkOtherEntries():
         rc_entry = [ r'\nomencl_command "makeindex -s nomencl.ist"' ])
     checkProg('a python-pygments driver command', ['pygmentize'],
         rc_entry = [ r'\pygmentize_command "%%"' ])
-    checkProg('external script for searching and showing citation sources',
-        ['lyxpaperview', 'lyxpaperview.py'], rc_entry = [ r'\citation_search_view "%%"' ])
     ## FIXME: OCTAVE is not used anywhere
     # path, OCTAVE = checkProg('Octave', ['octave'])
     ## FIXME: MAPLE is not used anywhere
     # path, MAPLE = checkProg('Maple', ['maple'])
     # Add the rest of the entries (no checkProg is required)
+    addToRC(r'''\citation_search_view "python -tt $$s/scripts/lyxpaperview.py"''')
     addToRC(r'''\copier    fig        "python -tt $$s/scripts/fig_copy.py $$i $$o"
 \copier    pstex      "python -tt $$s/scripts/tex_copy.py $$i $$o $$l"
 \copier    pdftex     "python -tt $$s/scripts/tex_copy.py $$i $$o $$l"
diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx
index 2efde46..49fa689 100644
--- a/lib/doc/UserGuide.lyx
+++ b/lib/doc/UserGuide.lyx
@@ -8742,12 +8742,14 @@ Verbatim
 \end_layout
 
 \begin_layout Verbatim
+
 This is Verbatim.
 \end_layout
 
 \begin_layout Verbatim
 \noindent
 \align block
+
 The following 2 lines are empty:
 \end_layout
 
@@ -8760,6 +8762,7 @@ The following 2 lines are empty:
 \end_layout
 
 \begin_layout Verbatim
+
 Almost everything is allowed in Verbatim:"%&$§#~'`
 \backslash
 }][{|
@@ -8783,6 +8786,7 @@ Verbatim
 \end_layout
 
 \begin_layout Verbatim*
+
 This is Verbatim*.
 \end_layout
 
@@ -31648,184 +31652,6 @@ Additional Features
 \end_layout
 
 \begin_layout Subsection
-
-\change_inserted 5863208 1598273424
-Bibliography entries allowing external view of the cited material
-\end_layout
-
-\begin_layout Standard
-
-\change_inserted 5863208 1598273449
-\SpecialChar LyX
- supports viewing the material the selected citation points to – though
- you need to satisfy some conditions so the 
-\family sans
-Open
-\begin_inset space ~
-\end_inset
-
-Citation
-\begin_inset space ~
-\end_inset
-
-Content
-\family default
- in the context menu of the citation inset is active and working.
-\end_layout
-
-\begin_layout Standard
-
-\change_inserted 5863208 1598270259
-There are several ways how to make this feature available:
-\end_layout
-
-\begin_layout Itemize
-
-\change_inserted 5863208 1598273631
-Have citations entries including any of the following fields: 
-\begin_inset Flex Code
-status open
-
-\begin_layout Plain Layout
-
-\change_inserted 5863208 1598273574
-url
-\change_unchanged
-
-\end_layout
-
-\end_inset
-
- or 
-\begin_inset Flex Code
-status open
-
-\begin_layout Plain Layout
-
-\change_inserted 5863208 1598273595
-doi
-\change_unchanged
-
-\end_layout
-
-\end_inset
-
- for BibTeX, 
-\begin_inset Flex Code
-status open
-
-\begin_layout Plain Layout
-
-\change_inserted 5863208 1598273611
-eprint
-\change_unchanged
-
-\end_layout
-
-\end_inset
-
- for BibLaTeX (covering arXiv, JSTOR, PubMed, HDL, Google Books 
-\begin_inset Flex Code
-status open
-
-\begin_layout Plain Layout
-
-\change_inserted 5863208 1598273631
-eprinttype
-\change_unchanged
-
-\end_layout
-
-\end_inset
-
-).
- This will launch web browser with the appropriate link.
-\end_layout
-
-\begin_layout Itemize
-
-\change_inserted 5863208 1598273665
-Having fields pointing to local files on your disk: 
-\begin_inset Flex Code
-status open
-
-\begin_layout Plain Layout
-
-\change_inserted 5863208 1598273656
-file
-\change_unchanged
-
-\end_layout
-
-\end_inset
-
- (filled by JabRef), 
-\begin_inset Flex Code
-status open
-
-\begin_layout Plain Layout
-
-\change_inserted 5863208 1598273665
-localfile
-\change_unchanged
-
-\end_layout
-
-\end_inset
-
- (filled by KBibTeX).
- This will launch appropriate file viewer.
- At the moment only absolute paths are accepted.
-\change_unchanged
-
-\end_layout
-
-\begin_layout Itemize
-
-\change_inserted 5863208 1598273865
-Supplying your own script named either 
-\begin_inset Flex Code
-status open
-
-\begin_layout Plain Layout
-
-\change_inserted 5863208 1598273683
-lyxpaperview
-\change_unchanged
-
-\end_layout
-
-\end_inset
-
- or 
-\begin_inset Flex Code
-status open
-
-\begin_layout Plain Layout
-
-\change_inserted 5863208 1598273697
-lyxpaperview.py
-\change_unchanged
-
-\end_layout
-
-\end_inset
-
-, which takes year and first author name as an input.
- It will be responsibility of this script to search for the appropriate
- file on your disk and launch the viewer.
- This script needs to be found among other executables so 
-\family sans
-Tools\SpecialChar menuseparator
-Reconfigure
-\family default
- can recognize it.
- Example templates with identical names can be found within your installation.
-\change_unchanged
-
-\end_layout
-
-\begin_layout Subsection
 Citation Format
 \begin_inset Index idx
 status collapsed
@@ -32350,6 +32176,192 @@ General text after
  fields you can add pre- and postnotes that apply to the whole list.
 \end_layout
 
+\begin_layout Subsection
+
+\change_inserted -712698321 1598509964
+\begin_inset CommandInset label
+LatexCommand label
+name "subsec:Opening-cited-documents"
+
+\end_inset
+
+Opening cited documents from within \SpecialChar LyX
+
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1598509000
+\SpecialChar LyX
+ supports opening documents selected citations point to via the 
+\family sans
+Try
+\begin_inset space ~
+\end_inset
+
+to
+\begin_inset space ~
+\end_inset
+
+Open
+\begin_inset space ~
+\end_inset
+
+Citation
+\begin_inset space ~
+\end_inset
+
+Content\SpecialChar ldots
+
+\family default
+ context menu if specific conditions are met:
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted -712698321 1598509037
+If citation entries include any of the fields 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1598508820
+url
+\end_layout
+
+\end_inset
+
+ or 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1598508820
+doi
+\end_layout
+
+\end_inset
+
+ for BibTeX, 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1598508820
+eprint
+\end_layout
+
+\end_inset
+
+ for BibLaTeX (covering arXiv, JSTOR, PubMed, HDL, Google Books 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1598508820
+eprinttype
+\end_layout
+
+\end_inset
+
+), the action will launch a web browser with the appropriate link.
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted -712698321 1598509157
+If citation entries include any of the fields 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1598508820
+file
+\end_layout
+
+\end_inset
+
+ (filled by JabRef) or 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1598508820
+localfile
+\end_layout
+
+\end_inset
+
+ (filled by KBibTeX) containing an URL that points to a file on your local
+ drive, the action will launch an appropriate file viewer.
+ At the moment only absolute paths are accepted.
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1598509196
+Note that \SpecialChar LyX
+ does not check if the URLs are valid.
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1598509866
+In addition to that, \SpecialChar LyX
+ also searches your disk for matching files if you
+ enable 
+\family sans
+Search drive for cited files
+\family default
+ in 
+\family sans
+Tools\SpecialChar menuseparator
+Preferences\SpecialChar ldots
+\SpecialChar menuseparator
+Edit\SpecialChar menuseparator
+Control
+\family default
+.
+ It uses the tokens supplied at 
+\family sans
+Pattern
+\family default
+ in the same preferences section (by default: year and authors).
+ Any of the tokens in the pattern must occur in the title (at arbitrary
+ position).
+ The pattern syntax uses specific keywords.
+ These are basically Bib\SpecialChar TeX
+ keys embraced in 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1598509565
+%
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+, but there are also special keys, which are documented in the Customization
+ manual, sec.
+ 
+\emph on
+Cite format description
+\emph default
+.
+\change_unchanged
+
+\end_layout
+
 \begin_layout Section
 Index
 \begin_inset Index idx
@@ -49818,6 +49830,59 @@ Math Macros
 Math
 \emph default
  manual.
+\change_inserted -712698321 1598509726
+
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1598509987
+The option 
+\family sans
+Search drive for cited files
+\family default
+ allows \SpecialChar LyX
+ to query your disk for cited documents when using the 
+\family sans
+Try
+\begin_inset space ~
+\end_inset
+
+to
+\begin_inset space ~
+\end_inset
+
+Open
+\begin_inset space ~
+\end_inset
+
+Citation
+\begin_inset space ~
+\end_inset
+
+Content\SpecialChar ldots
+
+\family default
+ context menu on a citation.
+ The 
+\family sans
+Patterns
+\family default
+ field determines the search pattern.
+ See sec.
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:Opening-cited-documents"
+
+\end_inset
+
+ for details.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Subsubsection
diff --git a/lib/scripts/lyxpaperview b/lib/scripts/lyxpaperview
deleted file mode 100755
index 5d7ea3c..0000000
--- a/lib/scripts/lyxpaperview
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-
-#This is just an example of an external script for finding corresponding file to the citation of the form Author + Year.
-#You will need to accomodate it to your particular situation.
-#
-#Syntax: paperview Year Author
-#Output: absolute path to the file(s)
-#
-#Dependencies:
-#1) mlocate/updatedb or similar package installed and running.
-#2) stored papers must contain first author name and year of publication in filename.
-
-VIEWER=qpdfview
-MAX_RESULTS=2
-
-name="$2"
-year="$1"
-
-if [ -z "$name" ]; then exit; fi
-
-FILE=`locate -i "$name" | grep -Ei '\.pdf$|\.ps$' | grep "$year" | head -n $MAX_RESULTS`
-
-
-#Putting in background necessary so that LyX does not wait for viewer to end
-$VIEWER ${FILE} &
-
diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py
index d22d758..322990a 100644
--- a/lib/scripts/prefs2prefs_prefs.py
+++ b/lib/scripts/prefs2prefs_prefs.py
@@ -130,7 +130,8 @@
 #   No convergence necessary.
 
 # Incremented to format 33, by sanda
-#   Add \citation_search_view.
+#   Add \citation_search, \citation_search_pattern
+#   and \citation_search_view.
 #   No conversion necessary.
 
 
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index ec2f563..c3156e4 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -128,7 +128,7 @@ Menuset
 		CiteStyles
 		Separator
 		Item "Settings...|S" "inset-settings"
-		Item "Open Citation Content...|O" "inset-edit"
+		Item "Try to Open Citation Content...|O" "inset-edit"
 	End
 
 
diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index a517768..5ec3986 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -996,7 +996,7 @@ docstring BibTeXInfo::expandFormat(docstring const & format,
 
 
 docstring const & BibTeXInfo::getInfo(BibTeXInfoList const & xrefs,
-	Buffer const & buf, CiteItem const & ci) const
+	Buffer const & buf, CiteItem const & ci, docstring const & format_in) const
 {
 	bool const richtext = ci.richtext;
 
@@ -1013,8 +1013,9 @@ docstring const & BibTeXInfo::getInfo(BibTeXInfoList const & xrefs,
 
 	CiteEngineType const engine_type = buf.params().citeEngineType();
 	DocumentClass const & dc = buf.params().documentClass();
-	docstring const & format =
-		from_utf8(dc.getCiteFormat(engine_type, to_utf8(entry_type_)));
+	docstring const & format = format_in.empty()? 
+				from_utf8(dc.getCiteFormat(engine_type, to_utf8(entry_type_)))
+			      : format_in;
 	int counter = 0;
 	info_ = expandFormat(format, xrefs, counter, buf,
 		ci, false, false);
@@ -1388,7 +1389,7 @@ docstring const BiblioInfo::getYear(docstring const & key, Buffer const & buf, b
 
 
 docstring const BiblioInfo::getInfo(docstring const & key,
-	Buffer const & buf, CiteItem const & ci) const
+	Buffer const & buf, CiteItem const & ci, docstring const & format) const
 {
 	BiblioInfo::const_iterator it = find(key);
 	if (it == end())
@@ -1400,7 +1401,7 @@ docstring const BiblioInfo::getInfo(docstring const & key,
 		if (xrefit != end())
 			xrefptrs.push_back(&(xrefit->second));
 	}
-	return data.getInfo(xrefptrs, buf, ci);
+	return data.getInfo(xrefptrs, buf, ci, format);
 }
 
 
diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h
index ddf1daa..bc385f2 100644
--- a/src/BiblioInfo.h
+++ b/src/BiblioInfo.h
@@ -75,7 +75,8 @@ public:
 	/// \return formatted BibTeX data suitable for framing.
 	/// \param vector of pointers to crossref/xdata information
 	docstring const & getInfo(BibTeXInfoList const & xrefs,
-			Buffer const & buf, CiteItem const & ci) const;
+				  Buffer const & buf, CiteItem const & ci,
+				  docstring const & format = docstring()) const;
 	/// \return formatted BibTeX data for a citation label
 	docstring const getLabel(BibTeXInfoList const xrefs,
 		Buffer const & buf, docstring const & format,
@@ -227,7 +228,7 @@ public:
 	/// output any richtext tags marked in the citation format and escape < and >
 	/// elsewhere, and the general output context.
 	docstring const getInfo(docstring const & key, Buffer const & buf,
-			CiteItem const & ci) const;
+			CiteItem const & ci, docstring const & format = docstring()) const;
 	/// \return formatted BibTeX data for citation labels.
 	/// Citation labels can have more than one key.
 	docstring const getLabel(std::vector<docstring> keys, Buffer const & buf,
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index e3bb0de..eb5d0dc 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -78,6 +78,8 @@ LexerKeyword lyxrcTags[] = {
 	{ "\\bind_file", LyXRC::RC_BINDFILE },
 	{ "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
 	{ "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
+	{ "\\citation_search", LyXRC::RC_CITATION_SEARCH },
+	{ "\\citation_search_pattern", LyXRC::RC_CITATION_SEARCH_PATTERN },
 	{ "\\citation_search_view", LyXRC::RC_CITATION_SEARCH_VIEW },
 	{ "\\close_buffer_with_last_view", LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW },
 	{ "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
@@ -680,8 +682,18 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
 			}
 			break;
 
+		case RC_CITATION_SEARCH:
+			lexrc >> citation_search;
+			break;
+
+		case RC_CITATION_SEARCH_PATTERN:
+			if (lexrc.next())
+				citation_search_pattern = lexrc.getString();
+			break;
+
 		case RC_CITATION_SEARCH_VIEW:
-			lexrc >> citation_search_view;
+			if (lexrc.next())
+				citation_search_view = lexrc.getString();
 			break;
 
 		case RC_CT_ADDITIONS_UNDERLINED:
@@ -1607,11 +1619,32 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
 		if (tag != RC_LAST)
 			break;
 		// fall through
+	case RC_CITATION_SEARCH:
+		if (ignore_system_lyxrc ||
+		    citation_search != system_lyxrc.citation_search) {
+			os << "# Set to true to use script to search\n"
+			   << "# locl disk for citation targets.\n"
+			   << "\\citation_search "
+			   << convert<string>(citation_search)
+			   << '\n';
+		}
+		if (tag != RC_LAST)
+			break;
+		// fall through
 	case RC_CITATION_SEARCH_VIEW:
 		if (ignore_system_lyxrc ||
 		    citation_search_view != system_lyxrc.citation_search_view) {
-			os << "\\citaton_search_view "
-			   << citation_search_view << '\n';
+			os << "\\citation_search_view \""
+			   << citation_search_view << "\"\n";
+		}
+		if (tag != RC_LAST)
+			break;
+		// fall through
+	case RC_CITATION_SEARCH_PATTERN:
+		if (ignore_system_lyxrc ||
+		    citation_search_pattern != system_lyxrc.citation_search_pattern) {
+			os << "\\citation_search_pattern \""
+			   << citation_search_pattern << "\"\n";
 		}
 		if (tag != RC_LAST)
 			break;
@@ -2788,6 +2821,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
 	case LyXRC::RC_BIBTEX_ALTERNATIVES:
 	case LyXRC::RC_BIBTEX_COMMAND:
 	case LyXRC::RC_BINDFILE:
+	case LyXRC::RC_CITATION_SEARCH:
+	case LyXRC::RC_CITATION_SEARCH_PATTERN:
 	case LyXRC::RC_CITATION_SEARCH_VIEW:
 	case LyXRC::RC_CHECKLASTFILES:
 	case LyXRC::RC_COMPLETION_CURSOR_TEXT:
diff --git a/src/LyXRC.h b/src/LyXRC.h
index d795d34..0917952 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -53,6 +53,8 @@ public:
 		RC_BINDFILE,
 		RC_CHECKLASTFILES,
 		RC_CHKTEX_COMMAND,
+		RC_CITATION_SEARCH,
+		RC_CITATION_SEARCH_PATTERN,
 		RC_CITATION_SEARCH_VIEW,
 		RC_COMPLETION_CURSOR_TEXT,
 		RC_COMPLETION_INLINE_DELAY,
@@ -244,13 +246,15 @@ public:
 	/// default paper size for local xdvi/dvips/ghostview/whatever
 	/// command to run chktex incl. options
 	std::string chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
-	// Name of external script, which searches for file corresponding to a 
-	// given citation. At this moment only script lyxpaperview[.py] is supported
-	// (search for pdf based on author+year), but we can generalize if requested.
-	// Citation context menu item "Open Citation Content" will be always enabled
-	// if the name of this script in nonempty (last resort when citation entry
-	// does not contain neccessary info.
+	/// Use external script to search for file corresponding to a 
+	/// given citation.
+	bool citation_search = false;
+	/// Name of external script which searches for file corresponding to a 
+	/// given citation. At this moment only script lyxpaperview.p is supported
+	/// (search for pdf or ps based on specific items)
 	std::string citation_search_view;
+	/// Items to search for in citation_search_view
+	std::string citation_search_pattern = "%year% %abbrvciteauthor%";
 	/// all available commands to run bibtex incl. options
 	CommandSet bibtex_alternatives;
 	/// command to run bibtex incl. options
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index 1fe4447..ad1ee8e 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -2756,7 +2756,9 @@ PrefEdit::PrefEdit(GuiPreferences * form)
 		this, SIGNAL(changed()));
 	connect(cursorWidthSB, SIGNAL(valueChanged(int)),
 		this, SIGNAL(changed()));
-	connect(fullscreenLimitGB, SIGNAL(clicked()),
+	connect(citationSearchCB, SIGNAL(toggled(bool)),
+		this, SIGNAL(changed()));
+	connect(citationSearchLE, SIGNAL(textChanged(QString)),
 		this, SIGNAL(changed()));
 	connect(fullscreenWidthSB, SIGNAL(valueChanged(int)),
 		this, SIGNAL(changed()));
@@ -2773,6 +2775,14 @@ PrefEdit::PrefEdit(GuiPreferences * form)
 }
 
 
+void PrefEdit::on_fullscreenLimitCB_toggled(bool const state)
+{
+	fullscreenWidthSB->setEnabled(state);
+	fullscreenWidthLA->setEnabled(state);
+	changed();
+}
+
+
 void PrefEdit::applyRC(LyXRC & rc) const
 {
 	rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
@@ -2787,13 +2797,15 @@ void PrefEdit::applyRC(LyXRC & rc) const
 		case 2:	rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST;	break;
 	}
 	rc.cursor_width = cursorWidthSB->value();
+	rc.citation_search = citationSearchCB->isChecked();
+	rc.citation_search_pattern = fromqstr(citationSearchLE->text());
 	rc.full_screen_toolbars = toggleToolbarsCB->isChecked();
 	rc.full_screen_scrollbar = toggleScrollbarCB->isChecked();
 	rc.full_screen_statusbar = toggleStatusbarCB->isChecked();
 	rc.full_screen_tabbar = toggleTabbarCB->isChecked();
 	rc.full_screen_menubar = toggleMenubarCB->isChecked();
 	rc.full_screen_width = fullscreenWidthSB->value();
-	rc.full_screen_limit = fullscreenLimitGB->isChecked();
+	rc.full_screen_limit = fullscreenLimitCB->isChecked();
 }
 
 
@@ -2807,13 +2819,17 @@ void PrefEdit::updateRC(LyXRC const & rc)
 	groupEnvironmentsCB->setChecked(rc.group_layouts);
 	macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);
 	cursorWidthSB->setValue(rc.cursor_width);
+	citationSearchCB->setChecked(rc.citation_search);
+	citationSearchLE->setText(toqstr(rc.citation_search_pattern));
 	toggleScrollbarCB->setChecked(rc.full_screen_scrollbar);
 	toggleStatusbarCB->setChecked(rc.full_screen_statusbar);
 	toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
 	toggleTabbarCB->setChecked(rc.full_screen_tabbar);
 	toggleMenubarCB->setChecked(rc.full_screen_menubar);
 	fullscreenWidthSB->setValue(rc.full_screen_width);
-	fullscreenLimitGB->setChecked(rc.full_screen_limit);
+	fullscreenLimitCB->setChecked(rc.full_screen_limit);
+	fullscreenWidthSB->setEnabled(rc.full_screen_limit);
+	fullscreenWidthLA->setEnabled(rc.full_screen_limit);
 }
 
 
diff --git a/src/frontends/qt/GuiPrefs.h b/src/frontends/qt/GuiPrefs.h
index 8bd264e..433439d 100644
--- a/src/frontends/qt/GuiPrefs.h
+++ b/src/frontends/qt/GuiPrefs.h
@@ -452,6 +452,9 @@ public:
 
 	void applyRC(LyXRC & rc) const;
 	void updateRC(LyXRC const & rc);
+
+public Q_SLOTS:
+	void on_fullscreenLimitCB_toggled(bool);
 };
 
 
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 5c1c357..b5bfe50 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -4624,9 +4624,15 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 			dr.screenUpdate(Update::Force);
 			break;
 
-		case LFUN_CITATION_OPEN:
-			frontend::showTarget(argument);
+		case LFUN_CITATION_OPEN: {
+			string pdfv, psv;
+			if (theFormats().getFormat("pdf"))
+				pdfv = theFormats().getFormat("pdf")->viewer();
+			if (theFormats().getFormat("ps"))
+				psv = theFormats().getFormat("ps")->viewer();
+			frontend::showTarget(argument, pdfv, psv);
 			break;
+		}
 
 		default:
 			// The LFUN must be for one of BufferView, Buffer or Cursor;
diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp
index 92ee029..f064d50 100644
--- a/src/frontends/qt/qt_helpers.cpp
+++ b/src/frontends/qt/qt_helpers.cpp
@@ -298,15 +298,21 @@ void showDirectory(FileName const & directory)
 		LYXERR0("Unable to open QUrl even though dir exists!");
 }
 
-void showTarget(string const & target){
+void showTarget(string const & target, string const & pdfv, string const & psv){
 	LYXERR(Debug::INSETS, "Showtarget:" << target << "\n");
-	if (prefixIs(target,"EXTERNAL ")) {
-		if (lyxrc.citation_search_view.empty())
+	if (prefixIs(target, "EXTERNAL ")) {
+		if (!lyxrc.citation_search)
 			return;
-		string tmp,tar;
+		string tmp, tar, opts;
 		tar = split(target, tmp, ' ');
+		if (!pdfv.empty())
+			opts = " -v " + pdfv;
+		if (!psv.empty())
+			opts += " -w " + psv;
+		if (!opts.empty())
+			opts += " ";
 		FuncRequest cmd = FuncRequest(LFUN_VC_COMMAND,"U . \"" +
-		                  lyxrc.citation_search_view + " " + tar + "\"");
+		                  lyxrc.citation_search_view + " " + opts + tar + "\"");
 		lyx::dispatch(cmd);
 		return;
 	}
diff --git a/src/frontends/qt/qt_helpers.h b/src/frontends/qt/qt_helpers.h
index 967ee5f..f0e535f 100644
--- a/src/frontends/qt/qt_helpers.h
+++ b/src/frontends/qt/qt_helpers.h
@@ -101,9 +101,12 @@ void setSectionResizeMode(QHeaderView * view,
 	QHeaderView::ResizeMode mode);
 /// Shows a directory in OSs file browser
 void showDirectory(support::FileName const & directory);
-/// handle request for showing citation content - shows pdf or
-/// web page in target; external script can be used for pdf view
-void showTarget(std::string const & target);
+/// handle request for showing citation content - shows pdf/ps or
+/// web page in target; external script can be used for pdf/ps view
+/// \p pdfv takes a pad viewer, \p psv a ps viewer
+void showTarget(std::string const & target,
+		std::string const & pdfv,
+		std::string const & psv);
 
 } // namespace frontend
 
diff --git a/src/frontends/qt/ui/PrefEditUi.ui b/src/frontends/qt/ui/PrefEditUi.ui
index 987dc92..fe36a5b 100644
--- a/src/frontends/qt/ui/PrefEditUi.ui
+++ b/src/frontends/qt/ui/PrefEditUi.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>494</width>
-    <height>614</height>
+    <width>610</width>
+    <height>552</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -19,8 +19,8 @@
   <property name="windowTitle">
    <string/>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
+  <layout class="QGridLayout" name="gridLayout_3">
+   <item row="0" column="0">
     <widget class="QGroupBox" name="scrollGB">
      <property name="title">
       <string>Editing</string>
@@ -32,6 +32,19 @@
       <bool>true</bool>
      </property>
      <layout class="QGridLayout" name="gridLayout">
+      <item row="8" column="3">
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
       <item row="2" column="0" colspan="2">
        <widget class="QCheckBox" name="scrollBelowCB">
         <property name="text">
@@ -39,14 +52,7 @@
         </property>
        </widget>
       </item>
-      <item row="5" column="0" colspan="2">
-       <widget class="QCheckBox" name="sortEnvironmentsCB">
-        <property name="text">
-         <string>Sort &environments alphabetically</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="1" colspan="2">
+      <item row="1" column="2">
        <spacer name="horizontalSpacer_3">
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
@@ -59,14 +65,85 @@
         </property>
        </spacer>
       </item>
-      <item row="0" column="0">
+      <item row="8" column="0" colspan="3">
+       <widget class="QComboBox" name="macroEditStyleCO">
+        <item>
+         <property name="text">
+          <string>Edit Math Macros inline with a box around</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Edit Math Macros inline with the name in the status bar</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Edit Math Macros with a parameter list (like in LyX < 1.6)</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item row="4" column="0" colspan="2">
+       <widget class="QCheckBox" name="copyCTMarkupCB">
+        <property name="toolTip">
+         <string>If this is checked, deleted and added text in change tracking mode will not be resolved on copy/paste operations and when moving content from/to insets</string>
+        </property>
+        <property name="text">
+         <string>&Keep change tracking markup on copy and paste</string>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="0" rowspan="2" colspan="2">
+       <widget class="QCheckBox" name="sortEnvironmentsCB">
+        <property name="text">
+         <string>Sort &environments alphabetically</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0" colspan="2">
        <widget class="QCheckBox" name="cursorFollowsCB">
         <property name="text">
          <string>Cursor &follows scrollbar</string>
         </property>
        </widget>
       </item>
-      <item row="1" column="0">
+      <item row="9" column="0" colspan="3">
+       <layout class="QHBoxLayout" name="horizontalLayout_5">
+        <item>
+         <widget class="QCheckBox" name="citationSearchCB">
+          <property name="statusTip">
+           <string>If this is activated, LyX will search your disk for matching files when clicking on "Try to Open Citation Content..." in the citation context menu</string>
+          </property>
+          <property name="text">
+           <string>Search &drive for cited files</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_3">
+          <item>
+           <widget class="QLabel" name="citationSearchLA">
+            <property name="text">
+             <string>Patte&rn:</string>
+            </property>
+            <property name="buddy">
+             <cstring>citationSearchLE</cstring>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLineEdit" name="citationSearchLE">
+            <property name="toolTip">
+             <string>Define search pattern (see UserGuide for syntax)</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+       </layout>
+      </item>
+      <item row="1" column="0" colspan="2">
        <layout class="QHBoxLayout" name="horizontalLayout">
         <item>
          <widget class="QLabel" name="label_3">
@@ -99,26 +176,6 @@
         </item>
        </layout>
       </item>
-      <item row="7" column="2">
-       <spacer name="horizontalSpacer">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>40</width>
-          <height>20</height>
-         </size>
-        </property>
-       </spacer>
-      </item>
-      <item row="6" column="0" colspan="2">
-       <widget class="QCheckBox" name="groupEnvironmentsCB">
-        <property name="text">
-         <string>&Group environments by their category</string>
-        </property>
-       </widget>
-      </item>
       <item row="3" column="0" colspan="2">
        <widget class="QCheckBox" name="macLikeCursorMovementCB">
         <property name="toolTip">
@@ -129,39 +186,17 @@
         </property>
        </widget>
       </item>
-      <item row="7" column="0" colspan="2">
-       <widget class="QComboBox" name="macroEditStyleCO">
-        <item>
-         <property name="text">
-          <string>Edit Math Macros inline with a box around</string>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string>Edit Math Macros inline with the name in the status bar</string>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string>Edit Math Macros with a parameter list (like in LyX < 1.6)</string>
-         </property>
-        </item>
-       </widget>
-      </item>
-      <item row="4" column="0">
-       <widget class="QCheckBox" name="copyCTMarkupCB">
-        <property name="toolTip">
-         <string>If this is checked, deleted and added text in change tracking mode will not be resolved on copy/paste operations and when moving content from/to insets</string>
-        </property>
+      <item row="7" column="0">
+       <widget class="QCheckBox" name="groupEnvironmentsCB">
         <property name="text">
-         <string>&Keep change tracking markup on copy and paste</string>
+         <string>&Group environments by their category</string>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
-   <item>
+   <item row="1" column="0">
     <widget class="QGroupBox" name="fullscreenGB">
      <property name="title">
       <string>Fullscreen</string>
@@ -186,92 +221,101 @@
         </property>
        </widget>
       </item>
-      <item row="1" column="0">
-       <widget class="QCheckBox" name="toggleScrollbarCB">
+      <item row="0" column="1">
+       <widget class="QCheckBox" name="toggleMenubarCB">
         <property name="text">
-         <string>Hide scr&ollbar</string>
+         <string>Hide &menubar</string>
         </property>
        </widget>
       </item>
-      <item row="2" column="0">
-       <widget class="QCheckBox" name="toggleTabbarCB">
+      <item row="0" column="2">
+       <widget class="QCheckBox" name="toggleScrollbarCB">
         <property name="text">
-         <string>Hide &tabbar</string>
+         <string>Hide scr&ollbar</string>
         </property>
        </widget>
       </item>
-      <item row="3" column="0">
-       <widget class="QCheckBox" name="toggleMenubarCB">
-        <property name="text">
-         <string>Hide &menubar</string>
+      <item row="0" column="3" rowspan="2">
+       <spacer name="horizontalSpacer_4">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
         </property>
-       </widget>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>146</width>
+          <height>38</height>
+         </size>
+        </property>
+       </spacer>
       </item>
-      <item row="4" column="0">
+      <item row="1" column="0">
        <widget class="QCheckBox" name="toggleStatusbarCB">
         <property name="text">
          <string>Hide sta&tusbar</string>
         </property>
        </widget>
       </item>
-      <item row="5" column="0">
-       <widget class="QGroupBox" name="fullscreenLimitGB">
-        <property name="title">
-         <string>&Limit text width</string>
-        </property>
-        <property name="flat">
-         <bool>true</bool>
-        </property>
-        <property name="checkable">
-         <bool>true</bool>
+      <item row="1" column="1">
+       <widget class="QCheckBox" name="toggleTabbarCB">
+        <property name="text">
+         <string>H&ide tabbar</string>
         </property>
-        <layout class="QGridLayout" name="gridLayout_3">
-         <item row="0" column="0">
-          <widget class="QLabel" name="label_2">
-           <property name="text">
-            <string>Screen used (&pixels):</string>
-           </property>
-           <property name="buddy">
-            <cstring>fullscreenWidthSB</cstring>
-           </property>
-          </widget>
-         </item>
-         <item row="0" column="1">
-          <widget class="QSpinBox" name="fullscreenWidthSB">
-           <property name="minimum">
-            <number>0</number>
-           </property>
-           <property name="maximum">
-            <number>10000</number>
-           </property>
-           <property name="singleStep">
-            <number>10</number>
-           </property>
-           <property name="value">
-            <number>700</number>
-           </property>
-          </widget>
-         </item>
-        </layout>
        </widget>
       </item>
-      <item row="4" column="1">
-       <spacer name="horizontalSpacer_2">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>157</width>
-          <height>20</height>
-         </size>
-        </property>
-       </spacer>
+      <item row="2" column="0" colspan="4">
+       <layout class="QHBoxLayout" name="horizontalLayout_4">
+        <item>
+         <widget class="QCheckBox" name="fullscreenLimitCB">
+          <property name="text">
+           <string>&Limit text width</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="fullscreenWidthLA">
+          <property name="text">
+           <string>Screen used (pi&xels):</string>
+          </property>
+          <property name="buddy">
+           <cstring>fullscreenWidthSB</cstring>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="fullscreenWidthSB">
+          <property name="minimum">
+           <number>0</number>
+          </property>
+          <property name="maximum">
+           <number>10000</number>
+          </property>
+          <property name="singleStep">
+           <number>10</number>
+          </property>
+          <property name="value">
+           <number>700</number>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_2">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>157</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
       </item>
      </layout>
     </widget>
    </item>
-   <item>
+   <item row="2" column="0">
     <spacer>
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -293,7 +337,6 @@
   <tabstop>scrollBelowCB</tabstop>
   <tabstop>macLikeCursorMovementCB</tabstop>
   <tabstop>sortEnvironmentsCB</tabstop>
-  <tabstop>groupEnvironmentsCB</tabstop>
   <tabstop>macroEditStyleCO</tabstop>
  </tabstops>
  <includes>
diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp
index 7ae75b8..df722aa 100644
--- a/src/insets/InsetCitation.cpp
+++ b/src/insets/InsetCitation.cpp
@@ -206,13 +206,18 @@ void InsetCitation::openCitation()
 	docstring const & key = getParam("key");
 
 	vector<docstring> keys = getVectorFromString(key);
-	docstring year, author, doi, url, file;
+	docstring titledata, doi, url, file;
 	for (docstring const & kvar : keys) {
-		year = bi.getYear(kvar, buffer(), false);
-		author = bi.getAuthorOrEditorList(kvar, buffer());
+		CiteItem ci;
+		titledata = bi.getInfo(kvar, buffer(), ci,
+				       from_ascii(lyxrc.citation_search_pattern));
+		// some cleanup: commas and " and ", as used in name lists,
+		// are not expected in file names
+		titledata = subst(titledata, ',', char());
+		titledata = subst(titledata, from_ascii(" and "), from_ascii(" "));
 		bi.getLocators(kvar, doi, url, file);
 		LYXERR(Debug::INSETS, "Locators: doi:" << doi << " url:"
-		        << url << " file:" << file << " author:" << author << " year:" << year);
+		        << url << " file:" << file << " title data:" << titledata);
 		docstring locator;
 		if (!file.empty()) {
 			locator = file;
@@ -221,7 +226,7 @@ void InsetCitation::openCitation()
 		} else if (!url.empty()) {
 			locator = url;
 		} else {
-			locator = "EXTERNAL " +  year + " " + author;
+			locator = "EXTERNAL " + titledata;
 		}
 		FuncRequest cmd = FuncRequest(LFUN_CITATION_OPEN, locator);
 		lyx::dispatch(cmd);


More information about the lyx-cvs mailing list