"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/cb2Bib.cpp" (12 Feb 2021, 104590 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cb2Bib.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0.0_vs_2.0.1.

    1 /***************************************************************************
    2  *   Copyright (C) 2004-2021 by Pere Constans
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *   See the LICENSE file that comes with this distribution.
    6  ***************************************************************************/
    7 #include "cb2Bib.h"
    8 
    9 #include "c2b.h"
   10 #include "c2bBibMenu.h"
   11 #include "c2bBibParser.h"
   12 #include "c2bCiterWidget.h"
   13 #include "c2bClipEdit.h"
   14 #include "c2bClipboard.h"
   15 #include "c2bEditor.h"
   16 #include "c2bFileDialog.h"
   17 #include "c2bNetworkQuery.h"
   18 #include "c2bPdfImport.h"
   19 #include "c2bPostprocess.h"
   20 #include "c2bSaveRegExp.h"
   21 #include "c2bSearchInFiles.h"
   22 #include "c2bSettings.h"
   23 #include "c2bTextBrowser.h"
   24 #include "c2bUtils.h"
   25 
   26 #include <bibSearcher.h>
   27 #include <network.h>
   28 
   29 #include <QtWidgets>
   30 
   31 
   32 /** \page overview Overview
   33 
   34   cb2Bib is a free, open source, and multiplatform application for rapidly
   35   extracting unformatted, or unstandardized bibliographic references from email
   36   alerts, journal Web pages, and PDF files.
   37 
   38   cb2Bib facilitates the capture of single references from unformatted and non
   39   standard sources. Output references are written in BibTeX. Article files can
   40   be easily linked and renamed by dragging them onto the cb2Bib window.
   41   Additionally, it permits editing and browsing BibTeX files, citing
   42   references, searching references and the full contents of the referenced
   43   documents, inserting bibliographic metadata to documents, and writing short
   44   notes that interrelate several references.
   45 
   46   <b>Current version: cb2Bib GET_VERSION</b>. See \ref changelog for a
   47   detailed list of changes and acknowledgments, and \ref relnotes for
   48   additional notes and information.
   49 
   50   See \ref relnotes201.
   51 
   52 <p>&nbsp;</p>
   53 
   54 GET_TABLE_OF_CONTENTS
   55 
   56 <p>&nbsp;</p>
   57 \section descrip Description
   58 
   59 
   60   cb2Bib reads the clipboard text contents and process it against a set of
   61   predefined patterns. If this automatic detection is successful, cb2Bib
   62   formats the clipboard data according to the structured BibTeX reference
   63   syntax.
   64 
   65   Otherwise, if no predefined format pattern is found or if detection proves to
   66   be difficult, manual data extraction is greatly simplified by cb2Bib. In most
   67   cases, such manual data extraction will provide with a new, personalized
   68   pattern to be included within the predefined pattern set for future automatic
   69   extractions.
   70 
   71   Once the bibliographic reference is correctly extracted, it is added to a
   72   specified BibTeX database file. Optionally, document files are renamed to a
   73   DocumentID filename and moved to a desired directory as a personal article
   74   library, and their metadata is updated with the bibliographic reference. See
   75   \ref metadata section.
   76 
   77   cb2Bib facilitates writing short notes related to bibliographic collections.
   78   Notes are written using a minimalist markup on a plain text editor, and can
   79   latter be converted to HTML. Related references and links become easily
   80   accessible on any browser or by the embedded cb2Bib viewer. See \ref
   81   relnotes110.
   82 
   83   <p>&nbsp;</p>
   84 \section usage Using cb2Bib
   85 
   86 \subsection procedure Procedure
   87 
   88   - <b>Select the reference to import from the email or web browser</b> \n On
   89   Unix machines, cb2Bib automatically detects mouse selections and clipboard
   90   changes. On Windows machines, copy or Ctrl-C is necessary to activate cb2Bib
   91   automatic processing.
   92 
   93   - <b>cb2Bib automatic processing</b> \n Once text is selected cb2Bib
   94   initiates the automatic reference extraction. It uses the predefined patterns
   95   from file <tt>regexp.txt</tt> to attempt automatic extraction. See \ref
   96   c2bconf_files section for setting the user predefined pattern matching
   97   expression file. After a successful detection bibliographic fields appear on
   98   the cb2Bib item line edits. Manual editing is possible at this stage.
   99 
  100   - <b>cb2Bib manual processing</b> \n If no predefined format pattern is found
  101   or if detection proves to be difficult, a manual data extraction must be
  102   performed. Select, either using mouse or Shift+arrow keys, the reference
  103   fields from the cb2Bib clipboard area. A popup menu will appear after
  104   selection is made. Choose the corresponding bibliographic field. See \ref
  105   entrytype. If operating with the keyboard, first letter of the field is set
  106   as a menu shortcut. Then, typing 'A' sets selection to 'author', or '+A' to
  107   'add authors'. Selection is postprocessed and added to the cb2Bib item line
  108   edit. cb2Bib field tags will show on the cb2Bib clipboard area. Once the
  109   manual processing is done, cb2Bib clipboard area will contain the matching
  110   pattern. The pattern can be further edited and stored to the
  111   <tt>regexp.txt</tt> file using <b>Insert Regular Expression</b>, Alt+I. See
  112   the \ref clipboard and \ref regexpeditor sections.
  113 
  114   - <b>Download reference to cb2Bib</b> \n cb2Bib has the built-in
  115   functionality to interact with publishers "Download reference to Citation
  116   Manager" service. Choose BibTeX format, or any other format that you can
  117   translate using <b>External Clipboard Preparsing Command</b>. See \ref
  118   keyboard, <b>Alt C</b>. Click "Download" from your browser. When asked "Open
  119   with..." select cb2Bib. cb2Bib will be launched if no running instance is
  120   found. If already running, it will place the downloaded reference to the
  121   clipboard, and it will start processing. Make sure your running instance is
  122   aware of clipboard changes. See \ref c2bbuttons. For convenience, the shell
  123   script <tt>c2bimport</tt>, and the desktop config file
  124   <tt>c2bimport.desktop</tt> are also provided.
  125 
  126   - <b>Adding documents</b> \n PDF and other documents can be added to the
  127   BibTeX reference by dragging the file icon and dropping it into the cb2Bib's
  128   panel. Optionally, document files, are renamed to a DocumentID filename and
  129   moved to a desired directory as a personal article library (See \ref
  130   c2bconf_documents section). Linked to a reference documents correspond to the
  131   BibTeX tag <tt>file</tt>. Usual reference manager software will permit to
  132   retrieve and visualize these files. Download, copy and/or moving is scheduled
  133   and performed once the reference is accepted, e.g., once it is saved by
  134   pressing <b>Save Reference</b> button.
  135 
  136   - <b>Multiple retrieving from PDF files</b> \n Multiple PDF or convertible to
  137   text files can be sequentially processed by dragging a set of files into
  138   cb2Bib's PDFImport dialog. By starting the processing button, files are
  139   sequentially converted to text and send to cb2Bib clipboard panel for
  140   reference extraction. See \ref pdfimport for details.
  141 
  142   - <b>Journal-Volume-Page Queries</b> \n Takes input Journal, Volume, and
  143   first page from the corresponding edit lines and attempts to complete the
  144   reference. Additionally, queries consider <tt>title</tt>, <tt>DOI</tt>, and
  145   an <tt>excerpt</tt>, which is a simplified clipboard panel contents. See \ref
  146   c2bconf_network section, the distribution file <tt>netqinf.txt</tt>, and \ref
  147   relnotes035 for customization and details.
  148 
  149   - <b>BibTeX Editor</b> \n cb2Bib includes a practical text editor suitable
  150   for corrections and additions. cb2Bib capabilities are readily available
  151   within the editor. E.g., the reference is first sent to cb2Bib by selecting
  152   it, and later retrieved from cb2Bib to the editor using 'right click' +
  153   'Paste Current BibTeX'. Interconversions Unicode <-> LaTeX, long <->
  154   abbreviated journal name, and adding/renaming PDF files are easily available.
  155   BibTeX Editor is also accessible through a shell command line. See \ref
  156   commandline and \ref bibeditor.
  157 
  158 
  159 \subsection c2bbuttons Buttons Functionality
  160 
  161   - \b About \n About cb2Bib, bookmarks, and online help.
  162 
  163   - \b Configure \n Configure cb2Bib. See \ref configuration section.
  164 
  165   - <b>Search references</b> \n Opens the cb2Bib's search dialog. The search is
  166   performed either on the current BibTeX file, or for all BibTeX files on the
  167   current directory. Optionally, the search is extended to reference's files.
  168   Hits are displayed on an editor window. See \ref bibsearch. See also \ref
  169   c2bconf_utilities section to configure the external to text converter.
  170 
  171   - \b PDFImport \n Launches cb2Bib's PDFImport window. Files dragged into
  172   PDFImport window are sequentially translated to text and sent to cb2Bib
  173   clipboard panel. cb2Bib automatic and manual capabilities are then easily
  174   available to extract and supervise reference extractions. See \ref pdfimport.
  175 
  176   - \b Exit \n Exits cb2Bib.
  177 
  178   - <b>Dis/Connect Clipboard</b> \n Toggles automatic cb2Bib and desktop
  179   clipboard connection. While the automatic cb2Bib-clipboard connection permits
  180   reducing keystrokes, the disconnected mode is needed in cases where multiple
  181   mouse selections or copies are required to complete a reference extraction.
  182   See also \ref relnotes041 and \ref relnotes021 if you experience problems
  183   with this feature.
  184 
  185   - <b>Network Reference Query</b> \n Starts Network Query. It usually takes
  186   input Journal, Volume, and first page from the corresponding edit lines and
  187   attempts to complete the reference. See \ref c2bconf_network network section
  188   to customize querying. See the distribution file <tt>netqinf.txt</tt> and
  189   also \ref relnotes035 for the details.
  190 
  191   - <b>View BibTeX Reference</b> \n View current reference as will be output to
  192   the BibTeX file. Eventual manual changes should be done on the item line
  193   edit.
  194 
  195   - <b>Save Reference</b> \n Inserts the current bibliographic reference to the
  196   output BibTeX file. This action decides whether or not a reference is
  197   accepted. Scheduled actions such as PDF downloading, copying or renaming will
  198   be performed at this time.
  199 
  200   - <b>Open BibTeX File</b> \n Opens the current BibTeX output file. Right
  201   click within the BibTeX Editor window for its particular functionality. See
  202   also \ref bibeditor.
  203 
  204 
  205 \subsection keyboard Additional Keyboard Functionality
  206 
  207   Most keyboard shortcuts are customizable. See \ref c2bconf_shortcuts. In the
  208   following, default shortcuts are used to describe functionality.
  209 
  210   - <b>Alt A</b> \n Starts \ref c2bannote. Specify the note's filename in the
  211   dialog. A new note is created if the file name does not exist. The cb2Bib
  212   Annote is opened as a separate program. Exiting cb2Bib will not exit the
  213   note's viewer. On the viewer, pressing key E launches the default text
  214   editor. The viewer will track the editor, and will update the note's display
  215   each time the editor saves it. The viewer's functionality is disabled if
  216   cb2Bib was not compiled and linked against WebKit. See \ref commandline to
  217   use Annote in command line mode.
  218 
  219   - <b>Alt B</b> \n Edits the Bookmarks and Network Query Info file
  220   <tt>netqinf.txt</tt>.
  221 
  222   - <b>Alt C</b> \n Preparses cb2Bib's clipboard through a user specified
  223   external script or tool. Preparsing is necessary to catch formatted
  224   references that can not be easily extracted using recognition patterns, or
  225   that are written in ambiguous formats. Many available scripts or specific
  226   user-written tools can be incorporated to cb2Bib through this external
  227   preparsing capability. In addition, simple, one-line scripts can be used
  228   within PDFImport to provide, for instance, the journal name when missing from
  229   the PDF first page. The cb2Bib distribution contains the sample scripts
  230   <tt>isi2bib</tt> and <tt>ris2bib</tt> that convert ISI and RIS formatted
  231   strings to BibTeX. See \ref c2bconf_clipboard for details.
  232 
  233   - <b>Alt D</b> \n Deletes temporary BibTeX output file. This permits using
  234   cb2Bib output files as temporary media to transfer references to a preferred
  235   reference manager and preferred format. <b>Caution</b>: This feature is not
  236   intended for the users who actually store their references in one or several
  237   BibTeX files. Remember to import references prior to delete cb2Bib output
  238   file.
  239 
  240   - <b>Alt E</b> \n Edits the regular expression file. It permits an easy
  241   access and modification of stored extraction patterns. New patterns are
  242   conveniently added to to the regular expression file by using the <b>RegExp
  243   Editor</b> button functionality.
  244 
  245   - <b>Alt F</b> \n Launches a file dialog for selecting the source file name
  246   for the BibTeX entry <tt>file</tt>. Selected files are displayed either, as
  247   the actual source filename, or, as the target filename, depending on the file
  248   copy/rename/move settings. See \ref c2bconf_documents. Alternatively to
  249   <b>Alt F</b>, documents can be easily linked to a reference by dragging the
  250   document file and dropping it to the cb2Bib panel.
  251 
  252   - <b>Alt I</b> \n Edits and optionally inserts the current regular
  253     expression pattern. See the \ref clipboard and \ref regexpeditor sections.
  254 
  255   - <b>Alt J</b> \n Edits the Journal Abbreviations file.
  256 
  257   - <b>Alt O</b> \n Opens the currently linked document for browsing. Documents
  258   can be easily linked to a reference by dragging the document file and
  259   dropping it to the cb2Bib panel, or with <b>Alt F</b>. Linked documents
  260   correspond to the BibTeX tag <tt>file</tt>.
  261 
  262   - <b>Alt P</b> \n Postprocess BibTeX output file. It launches a user
  263   specified script or program to postprocess the current BibTeX file. The
  264   cb2Bib distribution contains two sample scripts. One, <tt>bib2pdf</tt> is a
  265   shell script for running <tt>latex</tt> and <tt>bibtex</tt>; this permits to
  266   check the BibTeX file for possible errors, and to easily produce a suitable
  267   output for printing. The other one, <tt>bib2end.bat</tt> is a batch script
  268   for running <tt>bib2xml</tt> and <tt>xml2end</tt>, which converts references
  269   into Endnote format. See \ref c2bconf_bibtex for details.
  270 
  271   - <b>Alt R</b> \n Restarts cb2Bib automatic engine. Takes input data not
  272   from the system clipboard but from the cb2Bib clipboard panel. This permits
  273   editting the input stream from poorly translated PDF captions, correcting for
  274   author superscripts, or helps in debugging regular expressions.
  275 
  276   - <b>Alt W</b> \n Writes current reference to the source document file. This
  277   option is intended for writing and updating bibliographic metadata to
  278   document files without needing to use BibTeX files. Only local and writable
  279   files are considered.
  280 
  281   - <b>Alt X</b> \n Check Repeated looks for existing references in the BibTeX
  282   directory similar to the current one. The search is done for exact cite ID,
  283   and for title and author field values, or, if empty, for booktitle and
  284   editor,using the
  285   \htmlonly
  286   <a href="https://arxiv.org/abs/0705.0751" target="_blank">approximate string</a>
  287   \endhtmlonly
  288   search pattern. See also \ref c2bconf_bibtex.
  289 
  290   - <b>F4</b> \n Toggles between Main and Other Fields reference edit tabs.
  291 
  292   - <b>Esc</b> \n Quits cb2Bib popup menu. The cb2Bib menu pops up each time a
  293   selection in made in the clipboard panel. This saves keystrokes in a normal
  294   bibliographic extraction. Press <b>Esc</b> or <b>Right Click</b> mouse button
  295   if you need to gain access to the editor cut/copy/paste functionality
  296   instead.
  297 
  298 
  299   <p>&nbsp;</p>
  300 
  301 \section detail Advanced Features
  302   Advanced features, and processing and extraction details are described in the
  303   following sections:
  304     - \ref faq_automatic_extraction
  305     - \ref clipboard
  306     - \ref authorproc
  307     - \ref journalproc
  308     - \ref heuristics
  309     - \ref regexpeditor
  310 
  311   Configuration information is described in the following sections:
  312     - \ref configuration
  313     - \ref predefinedplaceholders
  314 
  315   Utilities and modules are described in the following sections:
  316     - \ref bibsearch
  317     - \ref bibeditor
  318     - \ref pdfimport
  319     - \ref metadata
  320     - \ref commandline
  321     - \ref c2bannote
  322     - \ref c2bciter
  323 
  324 
  325   <p>&nbsp;</p>
  326 
  327 \section requirements Requirements
  328 
  329 \subsection requirements_comp Compilation
  330   To compile cb2Bib, the following libraries must be present and accessible:
  331 
  332     - Qt 5.7.0 or later from
  333     \htmlonly
  334     <a href="https://www.qt.io/download" target="_blank">Qt Project</a>.
  335     \endhtmlonly
  336     On a Linux platform with Qt preinstalled, make sure that the <tt>devel</tt>
  337     packages and Qt tools are also present.
  338 
  339     - QtWebKit or QtWebEngine library (optional) to compile cb2Bib Annote
  340     viewer. No special action/flag is needed during compilation.
  341 
  342     - Compression libraries
  343     \htmlonly
  344     <a href="https://lz4.github.io/lz4/" target="_blank">LZ4</a>
  345     \endhtmlonly
  346      or
  347     \htmlonly
  348     <a href="https://www.oberhumer.com/opensource/lzo/" target="_blank">LZO</a>
  349     \endhtmlonly
  350      (optional). To chose a particular one, type <tt>configure --enable-lz4</tt> or <tt>configure --enable-lzo</tt>.
  351      On machines with SSE4 instruction set, the
  352     \htmlonly
  353     <a href="https://github.com/ConorStokes/LZSSE/" target="_blank">LZSSE</a>
  354     \endhtmlonly
  355      compressor can be used in place of LZ4 and LZO, by typing <tt>configure --enable-lzsse</tt>.
  356      If none of the above compressors were appropiate on a particular platform, type <tt>configure --enable-qt-zlib</tt>
  357      before compiling.
  358 
  359     - X11 header files if compiling on Unix platforms. Concretely, headers
  360     <tt>X11/Xlib.h</tt> and <tt>X11/Xatom.h</tt> are needed.
  361 
  362     - The header files <tt>fcntl.h</tt> and <tt>unistd.h</tt> from
  363     <tt>glibc-devel</tt> package are also required. Otherwise compilation will
  364     fail with <tt>`::close' undeclared</tt>.
  365 
  366 \subsection requirements_run Deployment
  367     Although not needed for running cb2Bib, the following tools extend cb2Bib
  368     applicability:
  369 
  370     - <tt>MathJax</tt>, available at
  371     \htmlonly
  372     <a href="https://www.mathjax.org/" target="_blank">https://www.mathjax.org</a>,
  373     \endhtmlonly
  374     for displaying mathematical notation. Simply, download and unzip it in a desired directory. See \ref c2bconf_annote.
  375 
  376     - <tt>ExifTool</tt>, version 7.31 or later, available at
  377     \htmlonly
  378     <a href="https://exiftool.org/" target="_blank">https://exiftool.org</a>,
  379     \endhtmlonly
  380     for metadata insertion.
  381 
  382     - <tt>pdftotext</tt>, found packaged as <tt>xpdf</tt>, and downloadable from
  383     \htmlonly
  384     <a href="https://www.xpdfreader.com/download.html" target="_blank">https://www.xpdfreader.com/download.html</a>.
  385     \endhtmlonly
  386 
  387     - The <tt>bib2xml</tt> and <tt>xml2end</tt>
  388     \htmlonly
  389     <a href="http://bibutils.refbase.org/" target="_blank">BibUtils</a>,
  390     \endhtmlonly
  391     for the postprocessing script <tt>bib2end.bat</tt> on Windows platforms.
  392 
  393     - LaTeX packages, for checking BibTeX files correctness and for references
  394     printing through the shell script <tt>bib2pdf</tt>.
  395 
  396 
  397   <p>&nbsp;</p>
  398 \section credits Credits and License
  399 
  400   The cb2Bib icons are taken from the <em>Oxygen</em>, <em>Crystal SVG</em>,
  401   and <em>Noia</em> icon sets, to be found at the
  402   \htmlonly
  403   <a href="https://kde.org/" target="_blank">KDE Desktop Environment</a>.
  404   \endhtmlonly
  405   Several people has contributed with suggestions, bug reports or patches. For
  406   a detailed list of acknowledgments see the \ref changelog.
  407 
  408   The cb2Bib program is licensed under the terms of the
  409   \htmlonly
  410   <a href="https://www.gnu.org/licenses/gpl-3.0.html" target="_blank">GNU General Public License</a>
  411   \endhtmlonly
  412   version 3.
  413 
  414   <p>&nbsp;</p>
  415 
  416 >  <b><em>GET_UPDATEDON</em></b> \n
  417 >  <em>First released version 0.1.0 on 2004-06-29.</em> \n
  418 >  &copy; <em>2004-2021 Pere Constans</em> \n
  419 
  420 */
  421 
  422 
  423 /** \page relnotes Release Notes
  424 
  425 \section relnotes201 Release Note cb2Bib 2.0.1
  426 
  427 
  428   To optimize search on PDF's contents, cb2Bib keeps a cache with the extracted
  429   text streams, that are compressed to reduce disk space and reading overhead.
  430   Nowadays, compressors with extremely high decompression speed are available.
  431   Two of them are LZSSE, for SSE4 capable architectures, and LZ4, for a broader
  432   range of CPUs. These two compressors can now be used by cb2Bib, with the
  433   latter set as the default compression library in cb2Bib builds. When
  434   upgrading to version 2.0.1, the <b>first search</b> on the document
  435   collection will recreate the cache, and this step <b>will be noticeably
  436   slow</b>.
  437 
  438   Additionally, cb2Bib 2.0.1 includes original, optimized text matching code
  439   for AVX2 capable architectures that is used for search matching and BibTeX
  440   parsing. This code is <b>not set</b> in default builds and needs to be
  441   explicitly enabled at compilation time.
  442 
  443   Finally, it is important mentioning the inclusion in version 2.0.1 of stemmed
  444   context search, see \ref contextsearch for details, and contributed feedback
  445   in handling citations and extending cite commands to markdown syntax, see
  446   \ref predefinedplaceholders.
  447 
  448   <p>&nbsp;</p>
  449 */
  450 
  451 
  452 /** \page relnotes Release Notes
  453 
  454 \section relnotes200 Release Note cb2Bib 2.0.0
  455 
  456   Throughout the 1.9.x series, the cb2Bib sources were updated to the improved
  457   string processing capabilities of Qt5 and PCRE libraries. This update has
  458   brought a remarkable speedup for in-document searches and full search
  459   indexing.
  460 
  461   Alternate normalization of journal titles and abbreviations, upgrading jsMath
  462   to MathJax, extending network queries syntax, and a PDF user manual are the
  463   additional enhancements in cb2Bib 2.0.0.
  464 
  465   Back in version 0.3.3, cb2Bib introduced network queries to obtain the data
  466   for a citation. While convenient, queries to publishers' websites were
  467   difficult to setup and fragile. Nowadays, fortunately, arXiv, PubMed and
  468   Crossref offer structured APIs. These interfaces provide to the end user an
  469   easy setup for completing bibliographic citations.
  470 
  471   <p>&nbsp;</p>
  472 */
  473 
  474 
  475 /** \page relnotes Release Notes
  476 
  477 \section relnotes190 Release Note cb2Bib 1.9.0
  478 
  479   The cb2Bib sources have been ported to Qt5. To highlight this major update
  480   in library requirements the version number is set to 1.9.0. Later, once
  481   stabilized and new functionality related to Qt5 enhancements are applied,
  482   version number will be set to 2.
  483 
  484   At this point cb2Bib has exactly the same functionality as its preceding
  485   version 1.5.0. To build the program, however, only qmake and its related
  486   config procedure are available. The cmake scripts have not yet been ported.
  487 
  488   Qt5 brings important enhancements related to regular expressions and string
  489   processing. Some careful updates to the cb2Bib sources are needed to fully
  490   benefit from them. They will implemented through the 1.9.x series. We
  491   expect by then a performance boost on full text, regular expression based
  492   searches.
  493 
  494   <p>&nbsp;</p>
  495 */
  496 
  497 
  498 /** \page relnotes Release Notes
  499 
  500 \section relnotes150 Release Note cb2Bib 1.5.0
  501 
  502   Included in version 1.5.0 sources there is a patch for XPDF 3.0.4, the
  503   default tool to convert PDF documents to plain text. The modified code
  504   separates superscripts to avoid words being joined to reference numbers and
  505   author names joined to affiliations' glyphs. Interested users will need to
  506   download the package, apply the patch, and compile it.
  507 
  508   Additionally, this version improves converted text postprocessing. This
  509   step normalizes character codes, reverts ligatures, restores when possible
  510   orphan diacritics and broken words, and undoes text hyphenation.
  511 
  512   Conversion to text and postprocessing is important for reference extraction,
  513   and document indexing and searching. It is therefore recommended to delete
  514   cached document-to-text data to benefit from the present improvements. cb2Bib
  515   stores cached texts in *c2b files in an user specified directory. After that,
  516   by performing a search or initiating indexing an updated cache will be
  517   created.
  518 
  519   <p>&nbsp;</p>
  520 */
  521 
  522 
  523 /** \page relnotes Release Notes
  524 
  525 \section relnotes147 Release Note cb2Bib 1.4.7
  526 
  527   Approximate and context searches effectively locate our references of
  528   interest. As collections grow in size, and low performance devices,
  529   netbooks and tablets, start being used, complete document searches become
  530   demanding. Besides, it is often not clear what to query for, and then a
  531   glossary of terms provides guidance. Often too, interest lies on subsetting
  532   documents by being similar to a given one.
  533 
  534   Version 1.4.7 adds a pragmatic term or keyword extraction from the document
  535   contents. Accepted keywords are set as the substrings appearing at least
  536   twice in one document, appearing at least in three documents, and
  537   conforming to predefined part-of-speech (POS) sequences. Keyword extraction
  538   is performed by either clicking on <tt>Index Documents</tt> at the
  539   <tt>c2bciter</tt> desktop tray menu, or, by typing <tt>cb2bib --index
  540   [bibdirname]</tt> on a shell. During extraction, the <tt>Part Of Speech
  541   (POS) Lexicon</tt> distribution file must be available and readable. On
  542   termination, indexing files are saved on the <tt>Search In Files Cache
  543   Directory</tt>. Simply copying this directory will synchronize keyword
  544   indexing to a second computer.
  545 
  546   After refreshing <tt>c2bciter</tt> module, pressing key G displays the
  547   glossary of terms. On a reference, pressing K displays its list of
  548   keywords. Pressing R on a keyword lists the references related to that
  549   keyword. Pressing R on a reference lists similarly related references.
  550   Similarity is assessed based on keyword occurrences. Left and Right keys
  551   provide previous and next navigation. Pressing V on either a reference
  552   keyword, or a keyword reference, visualizes the keyword excerpts from the
  553   reference's document. To close excerpt dialog press Esc or Left keys.
  554 
  555 
  556   See also \ref c2bciter, \ref c2bconf_files, and \ref commandline.
  557 
  558   <p>&nbsp;</p>
  559 */
  560 
  561 
  562 /** \page relnotes Release Notes
  563 
  564 \section relnotes140 Release Note cb2Bib 1.4.0
  565 
  566   The <tt>c2bciter</tt> module was introduced in version 1.3.0. Its name, as
  567   it was described, states its purpose of being "aimed to ease inserting
  568   citation IDs into documents". In fact, it does have such functionality.
  569   And, it has also another, equally important one: it provides a very fast
  570   way to retrieve a given work from our personal collections.
  571 
  572   Retrieving is accomplished through pre-sorted views of the references and
  573   filtering. Both, views and filtering, scale on the (tens of) thousands
  574   references. Usually, we recall a work from its publication year, a few
  575   words from its title, or (some of the letters of) one of its authors names.
  576   Often, what we remember is when a reference was included into our
  577   collection. Therefore, having such a chronological view was desirable.
  578 
  579   The implementation of this sorted-by-inclusion-date view was not done
  580   during the 1.3.x series, but postponed to version 1.4.0; somehow, to
  581   indicate that some sort of 'proprietary' BibTeX tag might be required to
  582   specify inclusion timestamps. I have been reluctant through the cb2Bib's
  583   life span to introduce 'cb2Bib-only' tags in the BibTeX outputs. I believe
  584   that there is little gain, and it costs, possibly, breaking
  585   interoperability.
  586 
  587   In the end, the choice was to not write any 'timestamp' tag in references.
  588   Instead, <tt>c2bciter</tt> checks for the last modified date of the linked
  589   documents to build an approximated chronological view. The advantage is
  590   that all, not just 'version 1.4.0 or later', references are sorted.
  591   Furthermore, if a reference is later corrected, and the document metadata
  592   is updated too, the modification date is reflected in the view. The obvious
  593   inconvenience is that no such sorting can be done for references without an
  594   attached document.
  595 
  596 
  597   See also \ref c2bciter.
  598 
  599   <p>&nbsp;</p>
  600 */
  601 
  602 /** \page relnotes Release Notes
  603 
  604 \section relnotes130 Release Note cb2Bib 1.3.0
  605 
  606   When version 0.2.7 came up, it was mentioned in \ref relnotes027 that cb2Bib
  607   'doesn't have the means to automatically discern an author name from a
  608   department or street name'. I forgot mentioning, that I did not expect cb2Bib
  609   would have had such a feature. Since the last \ref relnotes110, the cb2Bib
  610   internals had changed significantly. Some changes, such heuristic recognition
  611   for interlaced authors and affiliations, get easily noticed. Other changes,
  612   however, do not, and need additional explanation.
  613 
  614   From version 1.2.3, the switches <tt>--txt2bib</tt> and <tt>--doc2bib</tt>
  615   set cb2Bib to work on console mode. The non-exact nature of the involved
  616   extractions makes logging necessary. On Windows, graphic or console modes
  617   must be decided not at run time, but when the application is built. So far,
  618   logging and globing were missing. This release adds the convenience wrapper
  619   <tt>c2bconsole</tt>. Typing <tt>c2bconsole --txt2bib i*.txt out.bib</tt>, for
  620   instance, will work as it does in the other platforms.
  621 
  622   Lists of references are now sorted case and diacritic insensitive. For some
  623   languages such a choice is not the expected one, and some operating systems
  624   offer local-aware collation. Due to usual inconsistencies and inaccuracies
  625   in references, this decision was taken to group together 'Density Matrix'
  626   with 'Density-matrix', and
  627   \htmlonly
  628   M&#248;ller
  629   \endhtmlonly
  630   with Moller, which, in a personal collection, most probably, refer to the
  631   same concept and to the same person. Additionally, document to text
  632   converted strings are now clean from extraneous, non-textual symbols.
  633   Therefore, recreating cache files is recommended.
  634 
  635   Finally, this release introduces a new module, named <tt>c2bciter</tt>, and
  636   aimed to ease inserting citation IDs into documents. The module should
  637   ideally stay idle at the system tray, and be recalled as needed by pressing
  638   a global, desktop shortcut. This functionality, while desirable, and usual
  639   in dictionaries, is platform and desktop dependent. On KDE there are
  640   currently known issues when switching among virtual desktops.
  641 
  642   See also \ref c2bciter, and \ref commandline.
  643 
  644   <p>&nbsp;</p>
  645 */
  646 
  647 /** \page relnotes Release Notes
  648 
  649 \section relnotes110 Release Note cb2Bib 1.1.0
  650 
  651   A frequent request from cb2Bib users has been to expand the command line
  652   functionality. So far few progress has been seen in this regard. First, the
  653   addition of in-document searches and reading/inserting metadata were
  654   priorities. Second, cb2Bib is not the tool to interconvert among
  655   bibliographic formats. And third, cb2Bib is designed to involve the user in
  656   the search process, in the archiving and validation of the discovered works
  657   and references.
  658 
  659   For the latter reason, and for not knowing a priori how would such a tool
  660   be designed, the cb2Bib internals had been interlaced to its graphical
  661   interface. At the time of version 0.7.0, when the graphical libraries
  662   changed, and a major refactoring was required, the code started moving
  663   toward a better modularization and structure. The current release pushes
  664   code organization further. As a result, it adds two new command line
  665   switches: <tt>--html-annote</tt> and <tt>--view-annote</tt>.
  666 
  667   The new cb2Bib module is named after the BibTeX key 'annote'. Annote is not
  668   for a 'one reference annotation' though. Instead, Annote is for short notes
  669   that interrelate several references. Annote takes a plain text note, with
  670   minimal or no markup, inserts the bibliographic citations, and converts it
  671   to a HTML page with links to the referenced documents.
  672 
  673   From within cb2Bib, to write your notes, type Alt+A, enter a filename, either
  674   new or existing, and once in Annote, type E to launch your default text
  675   editor. For help, type F1. Each time you save the document the viewer will be
  676   updated. To display mathematical notations, install
  677   \htmlonly
  678   <a href="http://www.math.union.edu/~dpvc/jsMath/" target="_blank">jsMath</a>
  679   \endhtmlonly
  680   locally. And, remember, code refactoring introduces bugs.
  681 
  682   See also \ref c2bannote and \ref commandline.
  683 
  684   <p>&nbsp;</p>
  685 */
  686 
  687 /** \page relnotes Release Notes
  688 
  689 \section relnotes100 Release Note cb2Bib 1.0.0
  690 
  691   Approximately four years ago the first cb2Bib was released. It included the
  692   possibility of easily linking a document to its bibliographic reference, in a
  693   handy way, by dragging the file to the main (at that time, single) panel.
  694   Now, in version 1.0.0, when a file is dropped, cb2Bib scans the document for
  695   metadata packets, and checks, in a rather experimental way, whether or not
  696   they contain relevant bibliographic information.
  697 
  698   Publishers metadata might or might not be accurate. Some, for instance,
  699   assign the DOI to the key Title. cb2Bib extracts possibly relevant key-value
  700   pairs and adds them to clipboard panel. Whenever key-value pairs are found
  701   accurate, just pressing Alt+G imports them to the line edits. If keys with
  702   the prefix <tt>bibtex</tt> are found, their values are automatically
  703   imported.
  704 
  705   The preparsed metadata that is added to the clipboard panel begins with
  706   <tt>[Bibliographic Metadata</tt> and ends with <tt>/Bibliographic
  707   Metadata]</tt>. Therefore, if you are using PDFImport together with a set
  708   of regular expressions, such that they contain the begin (^) or end ($)
  709   anchors, you can safely replace them by the above tags. In this manner,
  710   existing regular expressions remain useful with this minor change. And,
  711   with the advantage that, if recognition fails for a given document,
  712   metadata might give the hardest fields to extract from a PDF article,
  713   which are author and title.
  714 
  715   See also \ref metadata.
  716 
  717 
  718   <p>&nbsp;</p>
  719 */
  720 
  721 /** \page relnotes Release Notes
  722 
  723 \section relnotes084 Release Note cb2Bib 0.8.4
  724 
  725   The previous cb2Bib release added the command line option <tt>--conf
  726   [full_path]cb2bib.conf</tt> to specify the settings location. This feature
  727   was intended, mainly, as a clean way to run the program on a host computer
  728   from a removable drive. The work done focused on arranging the command line
  729   and settings related code. It was left for a later release to solve some
  730   requirements regarding the managing of file pathnames and temporary files.
  731 
  732   This release addresses these two points. Now, when cb2Bib is launched as
  733   <tt>cb2bib --conf</tt> --without a configuration filename-- it treats
  734   filenames as being relative to the cb2Bib actual location. Temporary files,
  735   if needed, will be placed at this location as well. Therefore, no data is
  736   being written on the host, and cb2Bib works independently of the actual
  737   address that the host assigns to the removable drive.
  738 
  739   The Windows' un/installer cleans/sets configuration data on the registry.
  740   Being aware of this particular, it might be better not to install the
  741   program directly to the USB drive. Just copy the cb2Bib base directory from
  742   a home/own computer to the removable drive, and then run it on the host
  743   computer as <tt>cb2bib --conf</tt>.
  744 
  745   <p>&nbsp;</p>
  746 */
  747 
  748 /** \page relnotes Release Notes
  749 
  750 \section relnotes083 Release Note cb2Bib 0.8.3
  751 
  752   cb2Bib accepts several arguments on its command line to access specific
  753   functionality. So far, the command <tt>cb2bib tmp_ref</tt> permits
  754   importing references from the browser, whenever a <em>download to reference
  755   manager</em> choice is available. In addition, the command <tt>cb2bib
  756   --bibedit ref.bib</tt> directly launches the BibTeX editor for file
  757   browsing and editing.
  758 
  759   This release adds the command line option <tt>--conf
  760   [full_path]cb2bib.conf</tt> to specifically set a file where all internal
  761   settings are being retrieved and stored. This has two interesting
  762   applications. On one hand, it easily permits switching from several sets of
  763   extraction rules, since the files <tt>abbreviations.txt</tt>,
  764   <tt>regexps.txt</tt>, and <tt>netqinf.txt</tt> are all stored in the
  765   cb2Bib's settings. And, on the other hand, it allows installing the program
  766   on a USB flash drive, and cleanly running it on any (e. g., library)
  767   computer. Settings can be stored and kept on the external device, and
  768   therefore, no data will be written on the registry or settings directory of
  769   the host computer.
  770 
  771   So far, however, this feature should be regarded as experimental. The Qt
  772   library to which cb2Bib is linked does read/write access to system settings
  773   in a few places (concretely, in file and color dialogs). On Unix and Mac OS
  774   systems this access can be modified by setting the environment variable
  775   DAG_CONFIG_HOME. No such workaround is presently available in Windows.
  776 
  777   See \ref commandline for a detailed syntax description.
  778 
  779   <p>&nbsp;</p>
  780 */
  781 
  782 /** \page relnotes Release Notes
  783 
  784 \section relnotes081 Release Note cb2Bib 0.8.1
  785 
  786   Several changes in this release affect installation and deployment. First,
  787   the cb2Bib internals for settings management has been reorganized. Version
  788   0.8.1 will not read previous settings, as user colors, file locations, etc.
  789   On Unix, settings are stored at <tt>~/.config/MOLspaces/cb2Bib.conf</tt>.
  790   This file can be removed, or renamed. On Windows, it is recommended to
  791   uninstall previous versions before upgrading.
  792 
  793   Second, cb2Bib tags are not shown by default. Instead, it is shown plain,
  794   raw clipboard data, as it is easier to identify with the original source.
  795   To write a regular expression, right click, on the menu, check 'View Tagged
  796   Clipboard Data', and perform the extraction from this view.
  797 
  798   And finally, cb2Bib adds the tag <<excerpt>> for network queries. It takes a
  799   simplified version of the clipboard contents and sends it to, e.g. Google
  800   Scholar. From there, one can easily import BibTeX references related to that
  801   contents. Therefore one should unchecked in most cases the 'Perform Network
  802   Queries after automatic reference extractions' box.
  803 
  804   <p>&nbsp;</p>
  805 */
  806 
  807 /** \page relnotes Release Notes
  808 
  809 \section relnotes072 Release Note cb2Bib 0.7.2
  810 
  811   cb2Bib reads the clipboard contents, processes it, and places it to the
  812   main cb2Bib's panel. If clipboard contents can be recognized as a
  813   reference, it writes the corresponding BibTeX entry. If not, the user can
  814   interact from the cb2Bib panel and complete or correct the reference.
  815   Additionally, this process permits to write down a regular expression
  816   matching the reference's pattern.
  817 
  818   To ease pattern writing, cb2Bib preprocesses the raw input data. This can
  819   consider format conversion by external tools and general substitutions, in
  820   addition to including some special tags. The resulting preprocessed data is
  821   usually less readable. A particularly illustrating case is when input data
  822   comes from a PDF article.
  823 
  824   cb2Bib now optionally presents input data, as raw, unprocessed data. This
  825   preserves the block text format of the source, and thus identifying the
  826   relevant bibliographic fields by visual inspection is more straightforward.
  827   In this raw mode view panel, interaction works in a similar manner. Except
  828   that, no conversions or substitutions are seen there, and that no regular
  829   expression tags are written.
  830 
  831   <p>&nbsp;</p>
  832 */
  833 
  834 /** \page relnotes Release Notes
  835 
  836 \section relnotes070 Release Note cb2Bib 0.7.0
  837 
  838   This release moves forward cb2Bib base requirement to Qt 4.2.0. Compilation
  839   errors related to rehighlight() library calls, kindly reported by Bongard,
  840   Seemann, and Luisser, should not appear anymore. File/URL opening is
  841   carried now by this library, in a desktop integrated manner. Additionally,
  842   Gnome users will enjoy better integration, as Cleanlooks widget style is
  843   available.
  844 
  845   All known regressions in 0.6.9x series have been fixed. Also, a few minor
  846   improvements have been included. In particular, file selection dialogs
  847   display navigation history, and BibTeX output file can be conveniently
  848   selected from the list of '*.bib' files at the current directory. Such a
  849   feature will be specially useful to users that sort references in thematic
  850   files located at a given directory.
  851 
  852   <p>&nbsp;</p>
  853 */
  854 
  855 /** \page relnotes Release Notes
  856 
  857 \section relnotes0691 Release Note cb2Bib 0.6.91
  858 
  859   This release fixes a regression in the cb2Bib network capabilities.
  860   Network, and hence querying was erratic, both for the internal HTTP
  861   routines and for external clients. In addition to this fix, the
  862   <tt>netqinf.txt</tt> has been updated. PubMed is working again. Queries are
  863   also extended to include DOI's. A possible applicability will be for
  864   indexing a set of PDF articles with PDFImport. If the article contains its
  865   DOI number, and 'Perform Network Queries after automatic reference
  866   extractions' is checked, chances are that automatic extractions will work
  867   smooth.
  868 
  869   <p>&nbsp;</p>
  870 */
  871 
  872 /** \page relnotes Release Notes
  873 
  874 \section relnotes0690 Release Note cb2Bib 0.6.90
  875 
  876   cb2Bib has been ported from Qt3 to Qt4, a migration in its underlying system
  877   library. Qt experienced many changes and improvements in this major release
  878   upgrade. Relevant to cb2Bib, these changes will provide a better file
  879   management, word completion, faster searches, and better desktop integration.
  880 
  881   Upgrading to Qt4 it is not a "plug and recompile" game. Thorough
  882   refactoring and rewriting was required. The resulting cb2Bib code is
  883   cleaner and more suitable to further development. As one might expect,
  884   major upgrades introduce new bugs that must be fixed. The cb2Bib 0.6.90 is
  885   actually a preview version. It has approximately the same functionality
  886   than its predecessor. So, no additions were considered at this point. Its
  887   use, bug reporting, and feedback are encouraged. This will help to get
  888   sooner a stable cb2Bib 0.7.
  889 
  890   To compile it, type <tt>./configure</tt> as usual. The <tt>configure</tt>
  891   script calls the <tt>qmake</tt> tool to generate an appropriate
  892   <tt>Makefile</tt>. To make sure the right, Qt4 <tt>qmake</tt> is invocated,
  893   you can setup <tt>QTDIR</tt> environment variable prior to
  894   <tt>./configure</tt>. The <tt>configure</tt>'s call statement will then be
  895   <tt>'$QTDIR/bin/qmake'</tt>. E. g., type <tt>'setenv QTDIR /usr'</tt> if
  896   <tt>qmake</tt> happens to be at the directory<tt>/usr/bin</tt>.
  897 
  898   <p>&nbsp;</p>
  899 */
  900 
  901 /** \page relnotes Release Notes
  902 
  903 \section relnotes060 Release Note cb2Bib 0.6.0
  904 
  905   cb2Bib uses the internal tags <tt><<NewLine_n>></tt> and <tt><<Tab_n>></tt>
  906   to ease the creation of regular expressions for reference extraction. New
  907   line and tabular codes from the input stream are substituted by these
  908   numbered tags. Numbering new lines and tabulars gives an extra safety when
  909   writing down a regular expression. E. g., suppose field title is 'anything'
  910   between '<tt><<NewLine1>></tt> and <tt><<NewLine2>></tt>'. We can then easily
  911   write 'anything' as '.+' without the risk of overextending the caption to
  912   several '\\n' codes. On the other hand, one still can use
  913   <tt><<NewLine\\d>></tt> if not interested in a specific numbering. All these
  914   internal tags are later removed, once cb2Bib postprocesses the entry fields.
  915 
  916   The cb2Bib identified so far new lines by checking for '\\n' codes. I was
  917   unaware that this was a platform dependent, as well as a not completely
  918   accurate way of detecting new lines. McKay Euan reported that
  919   <tt><<NewLine_n>></tt> tags were not appearing as expected in the MacOSX
  920   version. I later learn that MacOSX uses '\\r' codes, and that Windows uses
  921   '\\r\\n', instead of '\\n' for new line encoding.
  922 
  923   This release addresses this issue. It is supposed now that the cb2Bib
  924   regular expressions will be more transferable among the different
  925   platforms. Extraction from plain text sources is expected to be completely
  926   platform independent. Extraction from web pages will still remain browser
  927   dependent. In fact, each browser adds its peculiar interpretation of a
  928   given HTML source. For example, in Wiley webpages we see the sectioning
  929   header 'Abstract' in its source and in several browsers, but we see, and
  930   get, 'ABSTRACT' if using Konqueror.
  931 
  932   What we pay for this more uniform approach is, however, a <b>break in
  933   compatibility</b> with previous versions of cb2Bib. Unix/Linux users should
  934   not expect many differences, though. Only one from the nine regular
  935   expressions in the examples needed to be modified, and the two contributed
  936   regular expressions work perfectly without any change. Windows users will
  937   not see a duplication of <tt><<NewLine_n>></tt> tags. To update previous
  938   expressions it should be enough just shifting the <tt><<NewLine_n>></tt>
  939   numbering. And, of course, any working regular expression that does not
  940   uses <tt><<NewLine_n>></tt> tags will still be working in this new version.
  941 
  942   Finally, just to mention that I do not have a MacOSX to test any of the
  943   cb2Bib releases in this particular platform. I am therefore assuming that
  944   these changes will fix the problem at hand. If otherwise, please, let me
  945   know. Also, let me know if release 0.6.0 'break' your own expressions. I
  946   consider this release a sort of experimental or beta version, and the
  947   previous version 0.5.3, will still be available during this testing period.
  948 
  949   <p>&nbsp;</p>
  950 */
  951 
  952 /** \page relnotes Release Notes
  953 
  954 \section relnotes050 Release Note cb2Bib 0.5.0
  955 
  956   Two issues had appeared regarding cb2Bib installation and deployment on
  957   MacOSX platforms.
  958 
  959   First, if you encounter a 'nothing to install'-error during installation on
  960   MacOSX 10.4.x using the cb2Bib binary installer available at naranja.umh.es/~atg/,
  961   please delete the cb2bib-receipts from <tt>/Library/Receipts</tt> and then
  962   rerun the installer. See also M. Bongard's clarifying note 'MACOSX 10.4.X
  963   "NOTHING TO INSTALL"-ERROR' for details.
  964 
  965   Second, and also extensible to other cb2Bib platform versions, if PDFImport
  966   issues the error message 'Failed to call <i>some_format_to_text</i>' tool,
  967   make sure such a tool is installed and available. Go to
  968   Configure->PDFImport, click at the 'Select External Convert Tool' button,
  969   and navigate to set its full path. Since version 0.5.0 the default full
  970   path for the MacOSX is already set, and pointing to
  971   <tt>/usr/local/bin/pdftotext</tt>.
  972 
  973   <p>&nbsp;</p>
  974 */
  975 
  976 /** \page relnotes Release Notes
  977 
  978 \section relnotes041 Release Note cb2Bib 0.4.1
  979 
  980   Qt/KDE applications emit notifications whenever they change the clipboard
  981   contents. cb2Bib uses these notifications to automatically start its
  982   'clipboard to BibTeX' processing. Other applications, however, does not
  983   notify about them. Since version 0.2.1, see \ref relnotes021, cb2Bib started
  984   checking the clipboard periodically. This checking was later disabled as a
  985   default, needing a few lines of code to be uncomented to activate it. Without
  986   such a checking, cb2Bib appears unresponsive when selecting/copying from
  987   e.g., acroread or Mozilla. This release includes the class
  988   <tt>clipboardpoll</tt> written by L. Lunak for the KDE's Klipper. Checking is
  989   performed in a very optimized way. This checking is enabled by default. If
  990   you experience problems with this feature, or if the required X11 headers
  991   aren't available, consider disabling it by typing <tt>./configure
  992   --disable-cbpoll</tt> prior to compilation. This will disable checking
  993   completely. If the naive, old checking is preferred, uncomment the four usual
  994   lines, <tt>./configure --disable-cbpoll</tt>, and compile.
  995 
  996   <p>&nbsp;</p>
  997 */
  998 
  999 /** \page relnotes Release Notes
 1000 
 1001 \section relnotes035 Release Note cb2Bib 0.3.5
 1002 
 1003   Releases 0.3.3 and 0.3.4 brought querying functionality to cb2Bib. In
 1004   essence, cb2Bib was rearranged to accommodate copying and opening of
 1005   network files. Queries were then implemented as user customizable HTML
 1006   posts to journal databases. In addition, these arrangements permitted
 1007   defining convenience, dynamic bookmarks that were placed at the cb2Bib's
 1008   'About' panel.
 1009 
 1010   cb2Bib contains three viewing panels: 'About', 'Clipboard' and 'View
 1011   BibTeX', being the 'Clipboard' panel the main working area. To keep cb2Bib
 1012   simple, only two buttons, 'About' and 'View BibTeX', are set to navigate
 1013   through the panels. The 'About' and 'View BibTeX' buttons are toggle
 1014   buttons for momentarily displaying their corresponding panels. Guidance was
 1015   so far provided by enabling/disabling the buttons.
 1016 
 1017   After the bookmark introduction, the 'About' panel has greatly increased
 1018   its usefullness. Button functionality has been slightly redesigned now to
 1019   avoid as many keystrokes and mouse clicks as possible. The buttons remain
 1020   switchable, but they no longer disable the other buttons. User is guided by
 1021   icon changes instead. Hopefully these changes will not be confusing or
 1022   counterintuitive.
 1023 
 1024   Bookmarks and querying functionality are customizable through the
 1025   <tt>netqinf.txt</tt> file, which is editable by pressing the <tt>Alt+B</tt>
 1026   keys. Supported queries are of the form 'Journal-Volume-First Page'. cb2Bib
 1027   parses <tt>netqinf.txt</tt> each time a query is performed. It looks for
 1028   <tt>journal=<i>Full_Name|[code]</i></tt> to obtain the required information
 1029   for a specific journal. Empty, '<tt>journal=</tt>' entries have a meaning
 1030   of 'any journal'. New in this release, cb2Bib will test all possible
 1031   queries for a given journal instead of giving up at the first <tt><i>No
 1032   article found</i></tt> message. The query process stops at the first
 1033   successfull hit or, otherwise, once <tt>netqinf.txt</tt> is parsed
 1034   completely (in an equivalent way as the automatic pattern recognition
 1035   works). This permits querying multiple -and incomplete- journal databases.
 1036 
 1037   Users should order the <tt>netqinf.txt</tt> file in a way it is more
 1038   convenient. E.g., put PubMed in front of JACS if desired an automatic
 1039   extraction. Or JACS in front of PubMed and extract from the journal web
 1040   page, if author accented characters are wanted.
 1041 
 1042   So far, this querying functionality is still tagged as
 1043   <em>experimental</em>. Either the querying itself or its syntax seem quite
 1044   successful. However, downloading of PDF files, on windows OS + T1 network,
 1045   <b>was found to freeze</b> once progress reaches the 30-50%. Any feedback
 1046   on this issue will be greatly appreciated. Also, information on
 1047   <tt>kfmclient</tt> equivalent tools for non KDE desktops would be worth to
 1048   be included in the cb2Bib documentation.
 1049 
 1050   <p>&nbsp;</p>
 1051 */
 1052 
 1053 /** \page relnotes Release Notes
 1054 
 1055 \section relnotes030 Release Note cb2Bib 0.3.0
 1056 
 1057   cb2Bib considers the whole set of authors as an author-string pattern. This
 1058   string is later postprocessed, without requirements on the actual number of
 1059   authors it may contain, or on how the names are written. Once considered
 1060   author-string patterns, the extraction of bibliographic references by means
 1061   of regular expressions becomes relatively simple.
 1062 
 1063 
 1064   There are situations, however, where several author-strings are required.
 1065   The following box shows one of these cases. Authors are grouped according
 1066   to their affiliations. Selecting from 'F. N. First' to 'F. N. Fifth' would
 1067   include 'First Affiliation' within the author string. Cleaning up whatever
 1068   wording 'First Affiliation' may contain is a rather ill-posed problem.
 1069   Instead, cb2Bib includes an <tt>Add Authors</tt> option. The way of
 1070   operation is then to select 'F. N. First, F. N. Second, F. N. Third' and
 1071   chose <tt>Authors</tt> and right after, select 'F. N. Fourth and F. N.
 1072   Fifth' and chose <tt>Add Authors</tt>.
 1073 
 1074 \verbatim
 1075                                              Journal Name, 10, 1100-1105, 2004
 1076 
 1077                       AN EXAMPLE WITH MULTIPLE AUTHOR SETS
 1078 
 1079                      F. N. First, F. N. Second, F. N. Third
 1080                                 First Affiliation
 1081 
 1082                            F. N. Fourth and F. N. Fifth
 1083                                 Second Affiliation
 1084 
 1085   Abstract: Select from "Journal Name ..." to "... second author set.". The 'F.
 1086   N. First, F. N. Second, F. N. Third' author string is automatically processed
 1087   as one author set, while 'F. N. Fourth and F. N. Fifth' is processed as
 1088   another, second author set.
 1089 \endverbatim
 1090 
 1091   At this point in the manual extraction, the user was faced with a red
 1092   <tt><<moreauthors>></tt> tag in the cb2Bib clipboard panel. The
 1093   <tt><<moreauthors>></tt> tag was intended to warn the user about the fact
 1094   that cb2Bib would not be able to consider the resulting extraction pattern
 1095   as a valid, general regular expression. Usual regular expressions are built
 1096   up from an a priori known level of nesting. In these cases, however, the
 1097   level of nesting is variable. It depends on the number of different
 1098   affiliations occurring in a particular reference.
 1099 
 1100   So far the <tt><<moreauthors>></tt> tag has become a true FAQ about cb2Bib
 1101   and a source of many confusions. There is no real need, however, for such
 1102   an user warning. The <tt><<moreauthors>></tt> has therefore been removed
 1103   and cb2Bib has taken an step further, to its 0.3.0 version.
 1104 
 1105   The cb2Bib 0.3.0 manual extraction works as usual. By clicking
 1106   <tt>Authors</tt> the Authors edit line is reseted and selection contents
 1107   moved there. Alternatively, if <tt>Add Authors</tt> is clicked, selection
 1108   contents is added to the author field. On this version, however, both
 1109   operations are tagged as <tt><<author>></tt> (singular form, as it is the
 1110   BibTeX keyword for Authors). The generated extraction pattern can now
 1111   contain any number of <tt><<author>></tt> fields.
 1112 
 1113   In automatic mode, cb2Bib now adds all <tt>author</tt> captions to Authors.
 1114   In this way, cb2Bib can treat interlaced author-affiliation cases.
 1115   Obviously, users needing such extractions will have to write particular
 1116   regular expressions for cases with one set of authors, for two sets, and so
 1117   on. Eventhough it is not rare a work having a hundred of authors, it would
 1118   be quite umprobable that they were working on so many different
 1119   institutions. Therefore, few regular expressions should actually be
 1120   required in practice. Although not elegant, this breaks what was a cb2Bib
 1121   limitation and broadens its use when extracting from PDF sources. Remember
 1122   here to sort these regular expressions in decreasing order, since at
 1123   present, cb2Bib stops at the first hit. Also, consider <tt>Any Pattern</tt>
 1124   to get ride of the actual affiliation contents, as you might not want to
 1125   extract authors addresses.
 1126 
 1127   <p>&nbsp;</p>
 1128 */
 1129 
 1130 /** \page relnotes Release Notes
 1131 
 1132 \section relnotes027 Release Note cb2Bib 0.2.7
 1133 
 1134   The cb2Bib 0.2.7 release introduces multiple retrieving from PDF files. PDF
 1135   documents are becoming more and more widely used, not only to transfer and
 1136   printing articles, but also are substituting the personal paper files and
 1137   classifiers for the electronic equivalents.
 1138 
 1139   cb2Bib is intended to help updating personal databases of papers. It is a
 1140   tool focused on what is left behind in database retrieving. Cases such as
 1141   email alerts, or inter colleague references and PDF sharing are example
 1142   situations. Though in an electronic format, sources are not standardized or
 1143   not globally used as to permit using habitual import filters in reference
 1144   managers. cb2Bib is designed to consider a direct user intervention, either
 1145   by creating its own useful filters or by a simple copy-paste assistance
 1146   when handtyping.
 1147 
 1148   Hopefully someday cb2Bib will be able to take that old directory, with
 1149   perhaps a few hundreds of papers, to automatically index the references and
 1150   rename the files by author, in a consistent manner. The required mechanism
 1151   is already there, in this version. But I guess that this new feature will
 1152   manifest some present limitations in cb2Bib. For instance, most printed and
 1153   PDF papers interlace author names and affiliations. cb2Bib doesn't have the
 1154   means to automatically discern an author name from a department or street
 1155   name. So far one needs to manually use the 'Add to Authors' feature to deal
 1156   with these situations. Also, the managing of regular expressions needs
 1157   developing, specially thinking in the spread variety of design patterns in
 1158   publications.
 1159 
 1160   In summary, this current version is already useful in classifying and
 1161   extracting the reference of that couple of papers that someone send right
 1162   before submitting a work. A complete unsupervised extraction is still far
 1163   away, however.
 1164 
 1165   <p>&nbsp;</p>
 1166 */
 1167 
 1168 /** \page relnotes Release Notes
 1169 
 1170 \section relnotes021 Release Note cb2Bib 0.2.1
 1171 
 1172   The cb2Bib mechanism 'select-and-catch' failed in some cases. Acrobat and
 1173   Mozilla selections were not always notified to cb2Bib. Indeed, this 'window
 1174   manager - application' connection seems to be broken on a KDE 3.3.0 Qt 3.3.3
 1175   system.
 1176 
 1177   The cb2Bib 0.2.1 continues to listen to system clipboard change
 1178   notifications, whenever they are received and whenever cb2Bib is on
 1179   connected mode. Additionally, the cb2Bib 0.2.1 periodically checks for
 1180   changes in the system clipboard. Checks are performed every second,
 1181   approximately. This permits cb2Bib to work as usual, although one could
 1182   experience 1-2 seconds delays in systems where the automatic notification
 1183   is broken.
 1184 
 1185   If the 'select-and-catch' functionality appears 'sticky', possibly
 1186   happening while using non KDE applications from where text is selected,
 1187   check the source file <tt>c2bclipboard</tt><tt>.cpp</tt>, look for
 1188   <tt>'Setting timer'</tt>, and set variable <tt>interval</tt> to 1000. This
 1189   is the interval of time in ms that cb2Bib will use to check for clipboard
 1190   changes.
 1191 
 1192   <p>&nbsp;</p>
 1193 */
 1194 
 1195 
 1196 cb2Bib::cb2Bib(QWidget* parentw)
 1197     : QMainWindow(parentw), _connected(false), _is_check_repeated_done(false), _modified(false), _tagged_view_mode(false)
 1198 {
 1199     _settingsP = c2bSettingsP;
 1200     ui.setupUi(this);
 1201     connect(ui.id, SIGNAL(textChanged(QString)), this, SLOT(setWindowTitle(QString)));
 1202 
 1203     // Creating cb2Bib global resources
 1204     c2b* c2b_resources = new c2b(this, this);
 1205     connect(c2b_resources, SIGNAL(statusMessage(QString)), this, SLOT(showMessage(QString)));
 1206     connect(c2b_resources, SIGNAL(searchInFiles(QString,QString)), this, SLOT(doSearchInFiles(QString,QString)));
 1207 
 1208     // Actions and shortcuts
 1209     c2bUtils::addSeparator(this);
 1210     addAction(ui.checkRepeatedAction);
 1211     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.checkRepeatedAction);
 1212     c2bUtils::addSeparator(this);
 1213     addAction(ui.clearFieldsAction);
 1214     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.clearFieldsAction);
 1215     addAction(ui.guessFieldsAction);
 1216     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.guessFieldsAction);
 1217     addAction(ui.startEngineAction);
 1218     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.startEngineAction);
 1219     c2bUtils::addSeparator(this);
 1220     addAction(ui.preparseClipboardAction);
 1221     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.preparseClipboardAction);
 1222     addAction(ui.postprocessBibTeXAction);
 1223     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.postprocessBibTeXAction);
 1224     c2bUtils::addSeparator(this);
 1225     addAction(ui.editBookmarksAction);
 1226     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.editBookmarksAction);
 1227     addAction(ui.editAbbreviationsAction);
 1228     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.editAbbreviationsAction);
 1229     addAction(ui.editRegExpsAction);
 1230     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.editRegExpsAction);
 1231     c2bUtils::addSeparator(this);
 1232     addAction(ui.openAnnoteAction);
 1233     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.openAnnoteAction);
 1234     c2bUtils::addSeparator(this);
 1235     addAction(ui.insertRegExpAction);
 1236     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.insertRegExpAction);
 1237     addAction(ui.viewTaggedClipEditAction);
 1238     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.viewTaggedClipEditAction);
 1239     setAcceptDrops(true);
 1240 
 1241     c2bUtils::addSeparator(ui.file);
 1242     ui.file->addAction(ui.selectFileAction);
 1243     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.selectFileAction);
 1244     ui.file->addAction(ui.openFileDocumentAction);
 1245     _settingsP->setKeysequence("Shortcuts/cb2Bib/", ui.openFileDocumentAction);
 1246     ui.openFileDocumentAction->setEnabled(false);
 1247 
 1248     QShortcut* sc(new QShortcut(this));
 1249     _settingsP->setKeysequence("Shortcuts/cb2Bib/Delete Temporary BibTeX File", sc);
 1250     connect(sc, SIGNAL(activated()), this, SLOT(deleteTmpBib()));
 1251     sc = new QShortcut(this);
 1252     _settingsP->setKeysequence("Shortcuts/cb2Bib/Write Metadata to Document", sc);
 1253     connect(sc, SIGNAL(activated()), this, SLOT(addMetadata()));
 1254     sc = new QShortcut(this);
 1255     _settingsP->setKeysequence("Shortcuts/cb2Bib/Toggle Reference Tabs", sc);
 1256     connect(sc, SIGNAL(activated()), this, SLOT(toggleReferenceTabs()));
 1257     sc = new QShortcut(QKeySequence(Qt::Key_F2), this); // Made consistent with c2bCiter and c2bEditor
 1258     connect(sc, SIGNAL(activated()), this, SLOT(hide()));
 1259 
 1260     ClipEdit = new c2bClipEdit(c2bClipEdit::Editor, this);
 1261     ClipEdit->setObjectName("ClipEdit");
 1262     ClipEdit->addActions(actions());
 1263     ui.stackedWidget->addWidget(ClipEdit);
 1264 
 1265     AboutBrowser = new c2bTextBrowser(this);
 1266     AboutBrowser->setObjectName("AboutBrowser");
 1267     AboutBrowser->addActions(actions());
 1268     ui.stackedWidget->addWidget(AboutBrowser);
 1269 
 1270     BibBrowser = new c2bClipEdit(c2bClipEdit::Browser, this);
 1271     BibBrowser->setObjectName("BibBrowser");
 1272     BibBrowser->addActions(actions());
 1273     ui.stackedWidget->addWidget(BibBrowser);
 1274     connect(AboutBrowser, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
 1275     connect(AboutBrowser, SIGNAL(highlighted(QString)), this, SLOT(showLink(QString)));
 1276 
 1277     // Connect Actions
 1278     connect(ui.checkRepeatedAction, SIGNAL(triggered()), this, SLOT(checkRepeated()));
 1279     connect(ui.clearFieldsAction, SIGNAL(triggered()), this, SLOT(c2bInit()));
 1280     connect(ui.editAbbreviationsAction, SIGNAL(triggered()), this, SLOT(abbreviationsEditor()));
 1281     connect(ui.editBookmarksAction, SIGNAL(triggered()), this, SLOT(bookmarksEditor()));
 1282     connect(ui.editRegExpsAction, SIGNAL(triggered()), this, SLOT(regExpsEditor()));
 1283     connect(ui.guessFieldsAction, SIGNAL(triggered()), this, SLOT(guessFields()));
 1284     connect(ui.insertRegExpAction, SIGNAL(triggered()), this, SLOT(insertRegExp()));
 1285     connect(ui.openAnnoteAction, SIGNAL(triggered()), this, SLOT(openAnnote()));
 1286     connect(ui.openFileDocumentAction, SIGNAL(triggered()), this, SLOT(openFileDocument()));
 1287     connect(ui.postprocessBibTeXAction, SIGNAL(triggered()), this, SLOT(postprocessBibTeX()));
 1288     connect(ui.preparseClipboardAction, SIGNAL(triggered()), this, SLOT(preparseClipboard()));
 1289     connect(ui.selectFileAction, SIGNAL(triggered()), this, SLOT(selectFile()));
 1290     connect(ui.startEngineAction, SIGNAL(triggered()), this, SLOT(restartEngine()));
 1291     connect(ui.viewTaggedClipEditAction, SIGNAL(triggered(bool)), this, SLOT(setTaggedClipEditMode(bool)));
 1292     setBibMenu();
 1293     _pdfImportP = 0;
 1294     _searchInFilesP = 0;
 1295     setTaggedClipEditMode(false);
 1296 
 1297     // Set checkRepeated
 1298     ui.checkRepeatedAction->setVisible(false);
 1299     connect(ui.author, SIGNAL(textChanged(QString)), this, SLOT(updateCheckRepeatedAction()));
 1300     connect(ui.booktitle, SIGNAL(textChanged(QString)), this, SLOT(updateCheckRepeatedAction()));
 1301     connect(ui.editor, SIGNAL(textChanged(QString)), this, SLOT(updateCheckRepeatedAction()));
 1302     connect(ui.id, SIGNAL(textChanged(QString)), this, SLOT(updateCheckRepeatedAction()));
 1303     connect(ui.title, SIGNAL(textChanged(QString)), this, SLOT(updateCheckRepeatedAction()));
 1304 
 1305     // cb2Bib Settings
 1306     loadSettings();
 1307     connect(_settingsP, SIGNAL(newSettings()), this, SLOT(loadSettings()));
 1308     resize(_settingsP->value("cb2Bib/size", size()).toSize());
 1309     ui.bibtexfile->completer()->setCompletionMode(QCompleter::PopupCompletion);
 1310     updateBibfile(_settingsP->fileName("cb2Bib/BibTeXFile"));
 1311 
 1312     // Setting Bibliographic Parser
 1313     _bpP = c2b::bibParser();
 1314     setWidgetMapping();
 1315     ui.AddBibB->setEnabled(_modified);
 1316 
 1317     // Setting cb2bib network queries
 1318     _netQP = new c2bNetworkQuery(_bpP, c2b::net(), this);
 1319     connect(_netQP, SIGNAL(statusMessage(QString)), c2b_resources, SIGNAL(statusMessage(QString)));
 1320     connect(_netQP, SIGNAL(queryEnded(bool,QString,QString)), this, SLOT(netQueryEnded(bool,QString,QString)));
 1321 
 1322     // Set citer
 1323     if (_settingsP->cl_citer)
 1324     {
 1325         _citerP = new c2bCiterWidget;
 1326         _citerP->setTrayIcon();
 1327         _citerP->load();
 1328         connect(_citerP, SIGNAL(openAnnote()), this, SLOT(openAnnote()));
 1329         connect(_citerP, SIGNAL(openFile(QString)), this, SLOT(bibEditor(QString)));
 1330     }
 1331     else
 1332         _citerP = 0;
 1333 
 1334     // Connecting cb2Bib clipboard and start
 1335     c2bClipboard* cbP = c2b::clipboard();
 1336     connect(cbP, SIGNAL(cbDataChanged(QString)), this, SLOT(dataChanged(QString)));
 1337     on_ConnectB_clicked(); // Set button and update _connected
 1338     dataChanged(QString());
 1339     if (_settingsP->cl_bibedit)
 1340         initAsBibTeXEditor();
 1341 }
 1342 
 1343 cb2Bib::~cb2Bib()
 1344 {
 1345     delete _citerP;
 1346     delete _searchInFilesP;
 1347 }
 1348 
 1349 
 1350 /****************************************************************************
 1351 
 1352   GUI FUNCTIONALITY
 1353 
 1354 *****************************************************************************/
 1355 
 1356 void cb2Bib::show()
 1357 {
 1358     if (_settingsP->cl_citer && _citerP)
 1359         _citerP->toggleVisible();
 1360     else if (!_settingsP->cl_bibedit)
 1361         QMainWindow::show();
 1362 }
 1363 
 1364 void cb2Bib::on_ViewAboutB_clicked()
 1365 {
 1366     if (ui.stackedWidget->currentWidget() == AboutBrowser)
 1367     {
 1368         ui.stackedWidget->setCurrentWidget(ClipEdit);
 1369         ClipEdit->setFocus();
 1370     }
 1371     else
 1372     {
 1373         const QColor linkColor(palette().buttonText().color());
 1374         const QString sheet(QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name()));
 1375         AboutBrowser->document()->setDefaultStyleSheet(sheet);
 1376         const QString AboutS(
 1377             tr("<br /><br /><p align=\"center\"><b>cb2Bib %1</b></p>"
 1378                "<p align=\"center\">"
 1379                "Bibliographic Reference Extracting and Managing Tool<br />"
 1380                "<p align=\"center\"><img src=\":/icons/icons/cb2bib128.png\"></p>"
 1381                "<p align=\"center\">"
 1382                "<a href=\"https://www.molspaces.com/cb2bib/\">"
 1383                "cb2Bib Help and User's Guide</a></p><br />"
 1384                "<p align=\"center\">Additional Functionality:</p>"
 1385                "<table border=\"1\" align=\"center\" cellspacing=\"0\" cellpadding=\"4\">"
 1386                "<thead><tr>"
 1387                "<th>Keys</th><th>Description</th></tr>"
 1388                "</thead><tbody><tr>"
 1389                "<td>" +
 1390                _settingsP->ksname("Shortcuts/cb2Bib/Check Repeated") + "</td><td>Check repeated</td></tr><tr>"
 1391                "<td>" +
 1392                _settingsP->ksname("Shortcuts/cb2Bib/Delete Temporary BibTeX File") +
 1393                "</td><td>Delete temporary BibTeX file</td></tr><tr>"
 1394                "<td>" +
 1395                _settingsP->ksname("Shortcuts/cb2Bib/Edit Bookmarks") + "</td><td>Edit bookmarks</td></tr><tr>"
 1396                "<td>" +
 1397                _settingsP->ksname("Shortcuts/cb2Bib/Edit Journal Abbreviations") +
 1398                "</td><td>Edit journal abbreviations</td></tr><tr>"
 1399                "<td>" +
 1400                _settingsP->ksname("Shortcuts/cb2Bib/Edit Regular Expressions") +
 1401                "</td><td>Edit regular expressions</td></tr><tr>"
 1402                "<td>" +
 1403                _settingsP->ksname("Shortcuts/cb2Bib/Insert Regular Expression") +
 1404                "</td><td>Insert regular expression</td></tr><tr>"
 1405                "<td>" +
 1406                _settingsP->ksname("Shortcuts/cb2Bib/Open Document") + "</td><td>Open document</td></tr><tr>"
 1407                "<td>" +
 1408                _settingsP->ksname("Shortcuts/cb2Bib/Postprocess BibTeX") + "</td><td>Postprocess BibTeX</td></tr><tr>"
 1409                "<td>" +
 1410                _settingsP->ksname("Shortcuts/cb2Bib/Preparse Clipboard") + "</td><td>Preparse clipboard</td></tr><tr>"
 1411                "<td>" +
 1412                _settingsP->ksname("Shortcuts/cb2Bib/Restart Recognition") + "</td><td>Restart recognition</td></tr><tr>"
 1413                "<td>" +
 1414                _settingsP->ksname("Shortcuts/cb2Bib/Select Document File") + "</td><td>Select document file</td></tr><tr>"
 1415                "<td>" +
 1416                _settingsP->ksname("Shortcuts/cb2Bib/Annote Editor") + "</td><td>Open cb2Bib Annote</td></tr><tr>"
 1417                "<td>" +
 1418                _settingsP->ksname("Shortcuts/cb2Bib/Toggle Reference Tabs") +
 1419                "</td><td>Toggle reference tabs</td></tr><tr>"
 1420                "<td>" +
 1421                _settingsP->ksname("Shortcuts/cb2Bib/Write Metadata to Document") +
 1422                "</td><td>Write metadata to document</td></tr><tr>"
 1423                "<td>Esc</td><td>Quit cb2Bib popup menu</td></tr><tr>"
 1424                "<td>Right Click</td><td>Show cb2Bib main panel popup menu"
 1425                "</td></tr></tbody>"
 1426                "</table>"
 1427                "<br /> %2 <br />"
 1428                "<p align=\"center\">Copyright (C) 2004-2021 by Pere Constans<br />"
 1429                "<a href=\"https://www.molspaces.com/cb2bib/\">"
 1430                "https://www.molspaces.com/cb2bib/</a></p>&nbsp;"
 1431                "<p align=\"center\"><i>cb2Bib is licensed under the terms of the "
 1432                "<a href=\"https://www.gnu.org/licenses/gpl-3.0.html\">"
 1433                "GNU General Public License</a> version 3"
 1434                "</i><br /></p>&nbsp;")
 1435             .arg(C2B_VERSION, c2b::netqinf()->bookmarksToHtml()));
 1436         const int scrollPosition(AboutBrowser->verticalScrollBar()->value());
 1437         AboutBrowser->setHtml(AboutS);
 1438         AboutBrowser->verticalScrollBar()->setValue(scrollPosition);
 1439         ui.stackedWidget->setCurrentWidget(AboutBrowser);
 1440         AboutBrowser->setFocus();
 1441     }
 1442     updateViewButtons();
 1443 }
 1444 
 1445 void cb2Bib::on_ConfigureB_clicked()
 1446 {
 1447     c2b::configure();
 1448 }
 1449 
 1450 void cb2Bib::on_SearchInFilesB_clicked()
 1451 {
 1452     doSearchInFiles();
 1453 }
 1454 
 1455 void cb2Bib::on_PdfImportB_clicked()
 1456 {
 1457     if (!_pdfImportP)
 1458     {
 1459         _pdfImportP = new c2bPdfImport;
 1460         _pdfImportP->setAttribute(Qt::WA_DeleteOnClose);
 1461         connect(this, SIGNAL(addedBibToFile(QString)), _pdfImportP, SLOT(processNext()));
 1462         connect(this, SIGNAL(endedProcessing(bool)), _pdfImportP, SLOT(referenceExtacted(bool)));
 1463         connect(_pdfImportP, SIGNAL(textProcessed(QString)), this, SLOT(forceDataChange(QString)));
 1464         connect(_pdfImportP, SIGNAL(fileProcessed(QString)), this, SLOT(fileDropped(QString)));
 1465         connect(_pdfImportP, SIGNAL(saveReferenceRequest()), this, SLOT(on_AddBibB_clicked()));
 1466         connect(_pdfImportP, SIGNAL(setClipboardDisabled(bool)), ui.ConnectB, SLOT(setDisabled(bool)));
 1467         showMessage(tr("PDF Import launched."));
 1468     }
 1469     _pdfImportP->show();
 1470 }
 1471 
 1472 void cb2Bib::on_ExitB_clicked()
 1473 {
 1474     c2b::instance()->exitRequested();
 1475 }
 1476 
 1477 void cb2Bib::on_ConnectB_clicked()
 1478 {
 1479     if (_connected)
 1480     {
 1481         ui.ConnectB->setIcon(QIcon(C2B_ICON_DIR + C2B_ICON_DISCONNECT_B));
 1482         ui.ConnectB->setStatusTip(buttonStatusTip(tr("Connect clipboard"), ui.ConnectB->shortcut()));
 1483         _connected = false;
 1484     }
 1485     else
 1486     {
 1487         ui.ConnectB->setIcon(QIcon(C2B_ICON_DIR + C2B_ICON_CONNECT_B));
 1488         ui.ConnectB->setStatusTip(buttonStatusTip(tr("Disconnect clipboard"), ui.ConnectB->shortcut()));
 1489         _connected = true;
 1490     }
 1491 }
 1492 
 1493 void cb2Bib::on_MakeNetworkQueryB_clicked()
 1494 {
 1495     makeNetQuery();
 1496 }
 1497 
 1498 void cb2Bib::on_ViewBibB_clicked()
 1499 {
 1500     if (ui.stackedWidget->currentWidget() == BibBrowser)
 1501     {
 1502         ui.stackedWidget->setCurrentWidget(ClipEdit);
 1503         ClipEdit->setFocus();
 1504     }
 1505     else
 1506     {
 1507         BibBrowser->updatePlainText(_bpP->toBibTeX());
 1508         ui.stackedWidget->setCurrentWidget(BibBrowser);
 1509         BibBrowser->setFocus();
 1510     }
 1511     updateViewButtons();
 1512 }
 1513 
 1514 void cb2Bib::on_AddBibB_clicked()
 1515 {
 1516     // Prepare Save Reference to file
 1517     ui.AddBibB->setEnabled(false);
 1518     if (!_is_check_repeated_done && _settingsP->value("cb2Bib/CheckRepeatedOnSave").toBool())
 1519     {
 1520         _is_check_repeated_done = true;
 1521         if (isReferenceRepeated())
 1522         {
 1523             ui.AddBibB->setEnabled(_modified);
 1524             return;
 1525         }
 1526     }
 1527     QFile bibtexfile(ui.bibtexfile->currentText());
 1528     bool is_writable;
 1529     if (bibtexfile.exists())
 1530         is_writable = bibtexfile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
 1531     else
 1532         is_writable = bibtexfile.open(QIODevice::WriteOnly | QIODevice::Text);
 1533     if (!is_writable)
 1534     {
 1535         QMessageBox::information(this, tr("Information - cb2Bib"),
 1536                                  tr("Unable to open file %1 for writing.\nError: '%2'.")
 1537                                  .arg(ui.bibtexfile->currentText(), bibtexfile.errorString()),
 1538                                  QMessageBox::Ok);
 1539         ui.AddBibB->setEnabled(_modified);
 1540         return;
 1541     }
 1542     if (_dropped_document_file.isEmpty() || ui.file->text().isEmpty() || !_settingsP->value("cb2Bib/MovePdf").toBool())
 1543     {
 1544         _target_document_file.clear();
 1545         addToFile(true);
 1546     }
 1547     else
 1548     {
 1549         _target_document_file = c2bUtils::documentAbsoluteName(
 1550                                     _settingsP->value("cb2Bib/RelativePdfDirectory").toBool(), ui.bibtexfile->currentText(),
 1551                                     _settingsP->fileName("cb2Bib/PdfDirectory"), ui.file->text());
 1552         const QString doc_dir_name(QFileInfo(_target_document_file).absolutePath());
 1553         QDir doc_dir(doc_dir_name);
 1554         if (!doc_dir.exists())
 1555             if (!doc_dir.mkpath(doc_dir_name))
 1556             {
 1557                 QMessageBox::information(this, tr("Information - cb2Bib"),
 1558                                          tr("Unable to create directory %1.").arg(doc_dir_name), QMessageBox::Ok);
 1559                 ui.AddBibB->setEnabled(_modified);
 1560                 return;
 1561             }
 1562         const network::Action CopyMovePdf(network::actionType(_settingsP->value("cb2Bib/CopyMovePdf").toString()));
 1563         c2b::net()->getFile(_dropped_document_file, _target_document_file, CopyMovePdf, this, SLOT(addToFile(bool)));
 1564     }
 1565 }
 1566 
 1567 void cb2Bib::on_EditBibTeXB_clicked()
 1568 {
 1569     bibEditor(ui.bibtexfile->currentText());
 1570 }
 1571 
 1572 void cb2Bib::on_BibTeXDir_clicked()
 1573 {
 1574     const QString fn(c2bFileDialog::getFilename(this, "Select a BibTeX filename", ui.bibtexfile->currentText(),
 1575                      "BibTeX (*.bib);;All (*)"));
 1576     if (!fn.isEmpty())
 1577         updateBibfile(fn);
 1578 }
 1579 
 1580 void cb2Bib::loadSettings()
 1581 {
 1582     ClipEdit->setFont(_settingsP->c2bMonoFont);
 1583     BibBrowser->setFont(_settingsP->c2bMonoFont);
 1584     AboutBrowser->setFont(_settingsP->c2bMonoFont);
 1585 
 1586     ui.AddBibB->setShortcut(QKeySequence::Save);
 1587     ui.EditBibTeXB->setShortcut(QKeySequence::Open);
 1588     ui.SearchInFilesB->setShortcut(QKeySequence::Find);
 1589     ui.ExitB->setShortcut(QKeySequence::Quit);
 1590 
 1591     ui.BibTeXDir->setShortcut(_settingsP->keysequence("Shortcuts/cb2Bib/Select BibTeX File"));
 1592     ui.ConfigureB->setShortcut(_settingsP->keysequence("Shortcuts/cb2Bib/Button Configure"));
 1593     ui.ConnectB->setShortcut(_settingsP->keysequence("Shortcuts/cb2Bib/Button Toggle Connection"));
 1594     ui.MakeNetworkQueryB->setShortcut(_settingsP->keysequence("Shortcuts/cb2Bib/Button Network Query"));
 1595     ui.PdfImportB->setShortcut(_settingsP->keysequence("Shortcuts/cb2Bib/Button Start PDFImport"));
 1596     ui.ViewAboutB->setShortcut(_settingsP->keysequence("Shortcuts/cb2Bib/Button About and Bookmarks"));
 1597     ui.ViewBibB->setShortcut(_settingsP->keysequence("Shortcuts/cb2Bib/Button View BibTeX"));
 1598 
 1599     ui.AddBibB->setStatusTip(buttonStatusTip(tr("Save reference to BibTeX file"), ui.AddBibB->shortcut()));
 1600     ui.BibTeXDir->setStatusTip(buttonStatusTip(tr("Select BibTeX file"), ui.BibTeXDir->shortcut()));
 1601     ui.ConfigureB->setStatusTip(buttonStatusTip(tr("Configure cb2Bib"), ui.ConfigureB->shortcut()));
 1602     ui.ConnectB->setStatusTip(
 1603         buttonStatusTip(_connected ? tr("Disconnect clipboard") : tr("Connect clipboard"), ui.ConnectB->shortcut()));
 1604     ui.EditBibTeXB->setStatusTip(buttonStatusTip(tr("Open BibTeX file"), ui.EditBibTeXB->shortcut()));
 1605     ui.ExitB->setStatusTip(buttonStatusTip(tr("Close all windows and exit"), ui.ExitB->shortcut()));
 1606     ui.MakeNetworkQueryB->setStatusTip(
 1607         buttonStatusTip(tr("Network query for current reference"), ui.MakeNetworkQueryB->shortcut()));
 1608     ui.PdfImportB->setStatusTip(
 1609         buttonStatusTip(tr("Import references from a set of PDF files"), ui.PdfImportB->shortcut()));
 1610     ui.SearchInFilesB->setStatusTip(
 1611         buttonStatusTip(tr("Search BibTeX file for references"), ui.SearchInFilesB->shortcut()));
 1612     updateViewButtons();
 1613 }
 1614 
 1615 QString cb2Bib::buttonStatusTip(const QString& ms, const QKeySequence& ks) const
 1616 {
 1617     if (ks.isEmpty())
 1618         return ms;
 1619     else
 1620         return ms + QLatin1String("  -  ") + ks.toString(QKeySequence::NativeText);
 1621 }
 1622 
 1623 void cb2Bib::updateViewButtons()
 1624 {
 1625     QWidget* viewing = ui.stackedWidget->currentWidget();
 1626     if (viewing == BibBrowser)
 1627     {
 1628         ui.ViewBibB->setIcon(QIcon(C2B_ICON_DIR + C2B_ICON_VIEWC2B_B));
 1629         ui.ViewAboutB->setIcon(QIcon(C2B_ICON_DIR + C2B_ICON_ABOUT_B));
 1630         ui.ViewBibB->setStatusTip(buttonStatusTip(tr("View cb2Bib clipboard"), ui.ViewBibB->shortcut()));
 1631         ui.ViewAboutB->setStatusTip(
 1632             buttonStatusTip(tr("About cb2bib and cb2bib bookmarks"), ui.ViewAboutB->shortcut()));
 1633     }
 1634     else if (viewing == AboutBrowser)
 1635     {
 1636         ui.ViewBibB->setIcon(QIcon(C2B_ICON_DIR + C2B_ICON_VIEWBIB_B));
 1637         ui.ViewAboutB->setIcon(QIcon(C2B_ICON_DIR + C2B_ICON_ABOUT_B_BACK));
 1638         ui.ViewBibB->setStatusTip(buttonStatusTip(tr("View BibTeX for current reference"), ui.ViewBibB->shortcut()));
 1639         ui.ViewAboutB->setStatusTip(buttonStatusTip(tr("Back to cb2Bib clipboard"), ui.ViewAboutB->shortcut()));
 1640     }
 1641     else
 1642     {
 1643         ui.ViewBibB->setIcon(QIcon(C2B_ICON_DIR + C2B_ICON_VIEWBIB_B));
 1644         ui.ViewAboutB->setIcon(QIcon(C2B_ICON_DIR + C2B_ICON_ABOUT_B));
 1645         ui.ViewBibB->setStatusTip(buttonStatusTip(tr("View BibTeX for current reference"), ui.ViewBibB->shortcut()));
 1646         ui.ViewAboutB->setStatusTip(
 1647             buttonStatusTip(tr("About cb2bib and cb2bib bookmarks"), ui.ViewAboutB->shortcut()));
 1648     }
 1649 }
 1650 
 1651 void cb2Bib::toggleReferenceTabs()
 1652 {
 1653     if (ui.tabWidget->currentIndex() == 0)
 1654         ui.tabWidget->setCurrentIndex(1);
 1655     else
 1656         ui.tabWidget->setCurrentIndex(0);
 1657 }
 1658 
 1659 void cb2Bib::updateBibfile(const QString& fn)
 1660 {
 1661     ui.bibtexfile->clear();
 1662     QFileInfo fi(fn);
 1663     const QStringList flist(fi.isDir() ? c2bUtils::filesInDir(fn, QStringList() << "*.bib")
 1664                             : c2bUtils::filesInDir(fi.absolutePath(), QStringList() << "*.bib"));
 1665     for (int i = 0; i < flist.count(); ++i)
 1666         ui.bibtexfile->addItem(flist.at(i));
 1667     const int index(ui.bibtexfile->findText(fn));
 1668     if (index == -1)
 1669         ui.bibtexfile->setEditText(fn);
 1670     else
 1671         ui.bibtexfile->setCurrentIndex(index);
 1672 }
 1673 
 1674 void cb2Bib::showLink(const QString& ln)
 1675 {
 1676     statusBar()->showMessage(c2b::encodeLink(ln), C2B_MESSAGE_TIME);
 1677 }
 1678 
 1679 void cb2Bib::showMessage(const QString& ms)
 1680 {
 1681     statusBar()->showMessage(ms, C2B_MESSAGE_TIME);
 1682 }
 1683 
 1684 void cb2Bib::dragEnterEvent(QDragEnterEvent* qevent)
 1685 {
 1686     if (qevent->mimeData()->hasUrls())
 1687         qevent->acceptProposedAction();
 1688 }
 1689 
 1690 void cb2Bib::dropEvent(QDropEvent* qevent)
 1691 {
 1692     QList<QUrl> fns = qevent->mimeData()->urls();
 1693     if (fns.count() > 0)
 1694     {
 1695         if (fns.at(0).scheme() == "file")
 1696         {
 1697             c2bUtils::setWidgetOnTop(this);
 1698             fileDroppedByUser(fns.at(0).toLocalFile().trimmed());
 1699         }
 1700         else
 1701             fileDroppedByUser(fns.at(0).toString().trimmed());
 1702     }
 1703     qevent->acceptProposedAction();
 1704 }
 1705 
 1706 void cb2Bib::fileDroppedByUser(const QString& fn)
 1707 {
 1708     if (fn.isEmpty())
 1709         return;
 1710     bool has_bibtex(false);
 1711     if (_settingsP->value("cb2Bib/AddMetadata").toBool())
 1712     {
 1713         const QString metadata(c2b::documentMetadata(fn));
 1714         if (!metadata.isEmpty())
 1715         {
 1716             QString text(ClipEdit->toPlainText());
 1717             if (_settingsP->value("cb2Bib/PreAppendMetadata").toString() == "prepend")
 1718                 text = metadata + text;
 1719             else
 1720                 text = text + '\n' + metadata;
 1721             has_bibtex = _bpP->hasBibTeX(metadata);
 1722             if (has_bibtex)
 1723                 forceDataChange(text);
 1724             else
 1725                 ClipEdit->setText(text);
 1726         }
 1727     }
 1728     fileDropped(fn);
 1729     if (!has_bibtex)
 1730         showMessage(tr("Scheduled inclusion of file '%1'.").arg(fn));
 1731     if (QFileInfo::exists(fn))
 1732         _settingsP->setFilename("cb2Bib/LastDroppedFile", fn);
 1733 }
 1734 
 1735 void cb2Bib::fileDropped(const QString& fn)
 1736 {
 1737     if (fn.isEmpty())
 1738         return;
 1739     _dropped_document_file = fn.trimmed();
 1740     ui.openFileDocumentAction->setEnabled(true);
 1741     ui.openFileDocumentAction->setText(tr("Open '%1'").arg(_dropped_document_file));
 1742     setDocumentFilename();
 1743     if (_settingsP->value("cb2Bib/MovePdf").toBool())
 1744         ui.file->setStatusTip(tr("From file '%1'.").arg(_dropped_document_file));
 1745 }
 1746 
 1747 void cb2Bib::closeEvent(QCloseEvent* qevent)
 1748 {
 1749     if (_pdfImportP)
 1750         _pdfImportP->close();
 1751     if (_searchInFilesP)
 1752         _searchInFilesP->close();
 1753     _settingsP->setValue("cb2Bib/size", size());
 1754     _settingsP->setFilename("cb2Bib/BibTeXFile", QFileInfo(ui.bibtexfile->currentText()).absoluteFilePath());
 1755     qevent->accept();
 1756 }
 1757 
 1758 void cb2Bib::setTaggedClipEditMode(bool tagged)
 1759 {
 1760     _tagged_view_mode = tagged;
 1761     ui.insertRegExpAction->setEnabled(tagged);
 1762     ClipEdit->setTaggedViewMode(tagged);
 1763     if (_tagged_view_mode)
 1764         _bib_menu->setAnyPatternText(tr("Any Pattern"));
 1765     else
 1766         _bib_menu->setAnyPatternText(tr("Delete"));
 1767     ui.stackedWidget->setCurrentWidget(ClipEdit);
 1768     ClipEdit->setFocus();
 1769     updateViewButtons();
 1770 }
 1771 
 1772 void cb2Bib::doSearchInFiles(const QString& string, const QString& fn)
 1773 {
 1774     if (!_searchInFilesP)
 1775     {
 1776         _searchInFilesP = new c2bSearchInFiles(ui.bibtexfile->currentText());
 1777         connect(ui.bibtexfile, SIGNAL(editTextChanged(QString)), _searchInFilesP, SLOT(setBibTeXFile(QString)));
 1778         connect(_searchInFilesP, SIGNAL(searchDone(QString,bibSearcher*)), this,
 1779                 SLOT(bibEditor(QString,bibSearcher*)));
 1780         showMessage(tr("BibTeX Search launched."));
 1781     }
 1782     if (fn.isEmpty())
 1783         _searchInFilesP->setBibTeXFile(ui.bibtexfile->currentText());
 1784     else
 1785         _searchInFilesP->setBibTeXFile(fn);
 1786     _searchInFilesP->setCurrentText(string);
 1787     _searchInFilesP->show();
 1788 }
 1789 
 1790 void cb2Bib::setWindowTitle(const QString& title)
 1791 {
 1792     if (title.isEmpty())
 1793         QMainWindow::setWindowTitle(tr("cb2Bib"));
 1794     else
 1795         QMainWindow::setWindowTitle(tr("%1 - cb2Bib").arg(title));
 1796 }
 1797 
 1798 
 1799 /****************************************************************************
 1800 
 1801   CB2BIB FUNCTIONALITY
 1802 
 1803 *****************************************************************************/
 1804 
 1805 void cb2Bib::setWidgetMapping()
 1806 {
 1807     _bpP->addField("abstract", ui.abstract);
 1808     _bpP->addField("address", ui.address);
 1809     _bpP->addField("annote", ui.annote);
 1810     _bpP->addField("author", ui.author);
 1811     _bpP->addField("booktitle", ui.booktitle);
 1812     _bpP->addField("chapter", ui.chapter);
 1813     _bpP->addField("doi", ui.doi);
 1814     _bpP->addField("edition", ui.edition);
 1815     _bpP->addField("editor", ui.editor);
 1816     _bpP->addField("eprint", ui.eprint);
 1817     _bpP->addField("file", ui.file);
 1818     _bpP->addField("id", ui.id);
 1819     _bpP->addField("institution", ui.institution);
 1820     _bpP->addField("isbn", ui.isbn);
 1821     _bpP->addField("issn", ui.issn);
 1822     _bpP->addField("journal", ui.journal);
 1823     _bpP->addField("keywords", ui.keywords);
 1824     _bpP->addField("month", ui.month);
 1825     _bpP->addField("note", ui.note);
 1826     _bpP->addField("number", ui.number);
 1827     _bpP->addField("organization", ui.organization);
 1828     _bpP->addField("pages", ui.pages);
 1829     _bpP->addField("publisher", ui.publisher);
 1830     _bpP->addField("school", ui.school);
 1831     _bpP->addField("series", ui.series);
 1832     _bpP->addField("title", ui.title);
 1833     _bpP->addField("url", ui.url);
 1834     _bpP->addField("volume", ui.volume);
 1835     _bpP->addField("year", ui.year);
 1836     _bpP->addTypes(ui.typecombo);
 1837     _bpP->setWidgetMapping();
 1838     connect(_bpP, SIGNAL(bibModified(bool)), this, SLOT(bibModified(bool)));
 1839 }
 1840 
 1841 void cb2Bib::setBibMenu()
 1842 {
 1843     _bib_menu = new c2bBibMenu(this);
 1844     connect(_bib_menu->addAuthorAction(), SIGNAL(triggered()), this, SLOT(addAuthors()));
 1845     connect(_bib_menu->addEditorAction(), SIGNAL(triggered()), this, SLOT(addEditors()));
 1846     connect(_bib_menu->anyPatternAction(), SIGNAL(triggered()), this, SLOT(anyPattern()));
 1847     connect(ClipEdit, SIGNAL(userEndedSelection(QPoint)), this, SLOT(readField(QPoint)));
 1848 }
 1849 
 1850 void cb2Bib::readField(const QPoint& position)
 1851 {
 1852     QAction* action = _bib_menu->exec(position);
 1853     if (!action)
 1854         return;
 1855     const QString field(action->data().toString());
 1856     if (field.isEmpty())
 1857         return;
 1858     _bpP->setField(field, ClipEdit->textCursor().selectedText());
 1859     ClipEdit->insertTag("<<" + field + ">>");
 1860 }
 1861 
 1862 void cb2Bib::addAuthors()
 1863 {
 1864     _bpP->setField("addauthors", ClipEdit->textCursor().selectedText(), ui.author->text());
 1865     ClipEdit->insertTag("<<author>>");
 1866     if (_tagged_view_mode)
 1867         showMessage(tr("Info: Creating a pattern with multiple author sets."));
 1868 }
 1869 
 1870 void cb2Bib::addEditors()
 1871 {
 1872     _bpP->setField("addeditors", ClipEdit->textCursor().selectedText(), ui.editor->text());
 1873     ClipEdit->insertTag("<<editor>>");
 1874     if (_tagged_view_mode)
 1875         showMessage(tr("Info: Creating a pattern with multiple ui.editor sets."));
 1876 }
 1877 
 1878 void cb2Bib::anyPattern()
 1879 {
 1880     if (_tagged_view_mode)
 1881         ClipEdit->insertTag("<AnyPattern>");
 1882     else
 1883         ClipEdit->insertPlainText(QString());
 1884 }
 1885 
 1886 void cb2Bib::preparseClipboard()
 1887 {
 1888     c2bPreparse(_raw_input_data);
 1889 }
 1890 
 1891 void cb2Bib::restartEngine()
 1892 {
 1893     const QString text(ClipEdit->toPlainText());
 1894     if (!text.isEmpty())
 1895         c2bParse(text);
 1896 }
 1897 
 1898 void cb2Bib::guessFields()
 1899 {
 1900     const QString text(ClipEdit->toPlainText());
 1901     if (!text.isEmpty())
 1902     {
 1903         const QString keep_dropped_article_file(_dropped_document_file);
 1904         c2bInit();
 1905         _bpP->guessFields(text);
 1906         fileDropped(keep_dropped_article_file);
 1907         processingEnded();
 1908     }
 1909 }
 1910 
 1911 void cb2Bib::dataChanged(const QString& str)
 1912 {
 1913     bool do_allow(isVisible());
 1914     if (ui.stackedWidget->currentWidget() == ClipEdit)
 1915     {
 1916         if (ClipEdit->textCursor().hasSelection())
 1917             do_allow = false;
 1918     }
 1919     else if (ui.stackedWidget->currentWidget() == BibBrowser)
 1920     {
 1921         if (BibBrowser->textCursor().hasSelection())
 1922             do_allow = false;
 1923     }
 1924     if (_connected && ui.ConnectB->isEnabled() && do_allow)
 1925         forceDataChange(str);
 1926 }
 1927 
 1928 void cb2Bib::forceDataChange(const QString& str)
 1929 {
 1930     if (!str.isEmpty())
 1931     {
 1932         _raw_input_data = str.trimmed();
 1933         if (_settingsP->value("cb2Bib/PreparserAutomatic").toBool())
 1934             c2bPreparse(str);
 1935         else
 1936             c2bParse(str);
 1937     }
 1938 }
 1939 
 1940 void cb2Bib::c2bInit()
 1941 {
 1942     _dropped_document_file.clear();
 1943     ui.openFileDocumentAction->setEnabled(false);
 1944     ui.openFileDocumentAction->setText(tr("Open File Document"));
 1945     ui.file->setStatusTip(QString());
 1946     disconnect(_bpP, SIGNAL(setDocumentFilename()), this, SLOT(setDocumentFilename()));
 1947     _bpP->clearCurrentReference();
 1948     _is_check_repeated_done = false;
 1949     _modified = false;
 1950     ui.AddBibB->setEnabled(_modified);
 1951 }
 1952 
 1953 void cb2Bib::c2bParse(const QString& text)
 1954 {
 1955     c2bInit();
 1956     QString out_text, out_tagtext;
 1957     _bpP->parse(text, &out_text, &out_tagtext);
 1958     ClipEdit->setText(out_text, out_tagtext);
 1959     processingEnded();
 1960 }
 1961 
 1962 void cb2Bib::c2bPreparse(const QString& text)
 1963 {
 1964     QString out_text;
 1965     _bpP->preparse(text, &out_text);
 1966     if (!out_text.isEmpty())
 1967         c2bParse(out_text);
 1968 }
 1969 
 1970 void cb2Bib::deleteTmpBib()
 1971 {
 1972     QMessageBox msgBox(this);
 1973     QPushButton* deleteButton = msgBox.addButton(tr("&Delete"), QMessageBox::DestructiveRole);
 1974     msgBox.setDefaultButton(msgBox.addButton(QMessageBox::Cancel));
 1975     msgBox.setWindowTitle(tr("Confirmation - cb2Bib"));
 1976     msgBox.setText(tr("Delete temporary BibTeX file %1 ?").arg(ui.bibtexfile->currentText()));
 1977     msgBox.setIcon(QMessageBox::Question);
 1978     msgBox.exec();
 1979     if (msgBox.clickedButton() == deleteButton)
 1980     {
 1981         QFile BibFile(ui.bibtexfile->currentText());
 1982         if (BibFile.remove())
 1983             showMessage(tr("File %1 deleted.").arg(ui.bibtexfile->currentText()));
 1984         else
 1985             QMessageBox::warning(
 1986                 this, tr("Warning - cb2Bib"),
 1987                 tr("Unable to delete the file %1.\nError: '%2'").arg(ui.bibtexfile->currentText(), BibFile.errorString()),
 1988                 QMessageBox::Ok);
 1989     }
 1990 }
 1991 
 1992 void cb2Bib::insertRegExp()
 1993 {
 1994     QStringList pattern;
 1995 
 1996     // Extracting Reference Type
 1997     pattern.append(ui.typecombo->currentText());
 1998 
 1999     // Extracting Field Order
 2000     QString order(ClipEdit->toPlainText());
 2001     QRegExp rx("<<(" + _bpP->bibliographicFields().join("|") + ")>>");
 2002     QStringList list;
 2003     int ipos(0);
 2004     while (ipos >= 0)
 2005     {
 2006         ipos = rx.indexIn(order, ipos);
 2007         if (ipos > -1)
 2008         {
 2009             list += rx.cap(1);
 2010             ipos += rx.matchedLength();
 2011             c2bUtils::debug(rx.cap(1));
 2012         }
 2013     }
 2014     order = list.join(" ");
 2015     c2bUtils::debug(order);
 2016     pattern.append(order);
 2017 
 2018     // Parsing Regular Expression
 2019     QString str('^' + QRegExp::escape(ClipEdit->toPlainText()) + '$');
 2020     str.replace(QRegExp("<<abstract>>"), "(.+)");
 2021     str.replace(QRegExp("<<address>>"), "(.+)");
 2022     str.replace(QRegExp("<<annote>>"), "(.+)");
 2023     str.replace(QRegExp("<AnyPattern>"), ".+");
 2024     str.replace(QRegExp("<<author>>"), "(.+)");
 2025     str.replace(QRegExp("<<booktitle>>"), "(.+)");
 2026     str.replace(QRegExp("<<chapter>>"), "(\\d+)");
 2027     str.replace(QRegExp("<<doi>>"), "(10\\.[\\d\\.]+/\\S+)");
 2028     str.replace(QRegExp("<<edition>>"), "(.+)");
 2029     str.replace(QRegExp("<<editor>>"), "(.+)");
 2030     str.replace(QRegExp("<<eprint>>"), "(.+)");
 2031     str.replace(QRegExp("<<file>>"), "(\\S+)");
 2032     str.replace(QRegExp("<<institution>>"), "(.+)");
 2033     str.replace(QRegExp("<<isbn>>"), "(.+)");
 2034     str.replace(QRegExp("<<issn>>"), "(.+)");
 2035     str.replace(QRegExp("<<journal>>"), "(.+)");
 2036     str.replace(QRegExp("<<keywords>>"), "(.+)");
 2037     str.replace(QRegExp("<<month>>"), "(.+)");
 2038     str.replace(QRegExp("<<note>>"), "(.+)");
 2039     str.replace(QRegExp("<<number>>"), "(\\d+)");
 2040     str.replace(QRegExp("<<organization>>"), "(.+)");
 2041     str.replace(QRegExp("<<pages>>"), "([\\d\\-" + QString(QChar(8211)) + "\\s]+)");
 2042     str.replace(QRegExp("<<publisher>>"), "(.+)");
 2043     str.replace(QRegExp("<<school>>"), "(.+)");
 2044     str.replace(QRegExp("<<series>>"), "(.+)");
 2045     str.replace(QRegExp("<<title>>"), "(.+)");
 2046     str.replace(QRegExp("<<url>>"), "(\\S+)");
 2047     str.replace(QRegExp("<<volume>>"), "(\\d+)");
 2048     str.replace(QRegExp("<<year>>"), "(\\d\\d\\d\\d)");
 2049     c2bUtils::debug(str);
 2050     pattern.append(str);
 2051 
 2052     // User Editting
 2053     c2bSaveRegExp Sdiag(pattern, _raw_input_data, this);
 2054     connect(c2b::clipboard(), SIGNAL(cbDataChanged(QString)), &Sdiag, SLOT(updateInput(QString)));
 2055     connect(&Sdiag, SIGNAL(savePatternInfo(QString,QString)), this, SLOT(savePattern(QString,QString)));
 2056     ui.ConnectB->setDisabled(true);
 2057     if (Sdiag.exec() == QDialog::Rejected)
 2058         showMessage(tr("Cancelled."));
 2059     ui.ConnectB->setDisabled(false);
 2060 }
 2061 
 2062 void cb2Bib::savePattern(const QString& rx, const QString& rxname)
 2063 {
 2064     const QString regular_expression_f(_settingsP->fileName("cb2Bib/RegularExpressionFile"));
 2065     QFile file(regular_expression_f);
 2066     bool fopen;
 2067     if (file.exists())
 2068         fopen = file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
 2069     else
 2070         fopen = file.open(QIODevice::WriteOnly | QIODevice::Text);
 2071 
 2072     if (fopen)
 2073     {
 2074         QTextStream stream(&file);
 2075         stream.setCodec("UTF-8");
 2076         stream.setAutoDetectUnicode(true);
 2077         stream << ("# cb2Bib " + C2B_VERSION + "  Pattern:") << endl << rxname << endl << rx << endl << endl;
 2078         file.close();
 2079         showMessage(tr("Pattern '%1' added to %2.").arg(rxname, regular_expression_f));
 2080     }
 2081     else
 2082         QMessageBox::warning(
 2083             this, tr("Warning - cb2Bib"),
 2084             tr("Unable to open the file %1 for writing.\nError: '%2'.").arg(regular_expression_f, file.errorString()),
 2085             QMessageBox::Ok);
 2086     c2bUtils::debug("signal:");
 2087     c2bUtils::debug(rx);
 2088     c2bUtils::debug(rxname);
 2089 }
 2090 
 2091 void cb2Bib::setDocumentFilename()
 2092 {
 2093     disconnect(_bpP, SIGNAL(setDocumentFilename()), this, SLOT(setDocumentFilename()));
 2094     if (_dropped_document_file.isEmpty())
 2095         return;
 2096     ui.file->setText(_bpP->documentFilename(_dropped_document_file, ui.bibtexfile->currentText()));
 2097     connect(_bpP, SIGNAL(setDocumentFilename()), this, SLOT(setDocumentFilename()));
 2098 }
 2099 
 2100 void cb2Bib::addToFile(bool ready)
 2101 {
 2102     if (!ready)
 2103     {
 2104         QMessageBox::information(this, tr("Information - cb2Bib"),
 2105                                  tr("Not ready to add reference.\n%2").arg(c2b::net()->errorString()), QMessageBox::Ok);
 2106         ui.AddBibB->setEnabled(_modified);
 2107         return;
 2108     }
 2109     QFile file(ui.bibtexfile->currentText());
 2110     bool fopen;
 2111     if (file.exists())
 2112         fopen = file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
 2113     else
 2114         fopen = file.open(QIODevice::WriteOnly | QIODevice::Text);
 2115 
 2116     if (fopen)
 2117     {
 2118         QTextStream stream(&file);
 2119         stream.setCodec("UTF-8");
 2120         stream.setAutoDetectUnicode(true);
 2121         stream << _bpP->toBibTeX();
 2122         file.close();
 2123         c2b::showMessage(tr("Bib Item %1 added to %2.").arg(ui.id->text(), ui.bibtexfile->currentText()));
 2124         if (_settingsP->value("cb2Bib/InsertMetadata").toBool())
 2125             if (!_target_document_file.isEmpty())
 2126                 if (!c2b::metaParser()->insertMetadata(_bpP->currentReference(), _target_document_file))
 2127                     c2b::showMessage(tr("Unable to insert metadata to file %1.").arg(_target_document_file));
 2128         _is_check_repeated_done = false;
 2129         _modified = false;
 2130         ui.AddBibB->setEnabled(_modified);
 2131         emit addedBibToFile(ui.bibtexfile->currentText());
 2132     }
 2133     else
 2134         QMessageBox::warning(
 2135             this, tr("Warning - cb2Bib"),
 2136             tr("Unable to open file %1 for writing.\nError: '%2'.").arg(ui.bibtexfile->currentText(), file.errorString()),
 2137             QMessageBox::Ok);
 2138 }
 2139 
 2140 void cb2Bib::addMetadata()
 2141 {
 2142     if (!_dropped_document_file.isEmpty())
 2143     {
 2144         if (QFileInfo(_dropped_document_file).isWritable() &&
 2145             c2b::metaParser()->insertMetadata(_bpP->currentReference(), _dropped_document_file))
 2146             c2b::showMessage(tr("Inserted metadata to file %1.").arg(_dropped_document_file));
 2147         else
 2148             c2b::showMessage(tr("Unable to insert metadata to file %1.").arg(_dropped_document_file));
 2149     }
 2150 }
 2151 
 2152 void cb2Bib::postprocessBibTeX()
 2153 {
 2154     c2bPostprocess* ppBib = new c2bPostprocess(ui.bibtexfile->currentText(), this);
 2155     showMessage(tr("BibTeX Postprocessing launched."));
 2156     if (ppBib->exec() != QDialog::Accepted)
 2157         showMessage(tr("BibTeX Postprocessing exited."));
 2158 }
 2159 
 2160 void cb2Bib::bookmarksEditor()
 2161 {
 2162     if (_openDocuments.contains("bookmark_network_editor"))
 2163     {
 2164         c2bUtils::setWidgetOnTop(_openDocuments.value("bookmark_network_editor"));
 2165         return;
 2166     }
 2167     c2bEditor* ed = new c2bEditor(_settingsP->fileName("cb2Bib/NetworkFile"), c2bEditor::NetQInfo, this);
 2168     ed->setObjectName("bookmark_network_editor");
 2169     _openDocuments.insert("bookmark_network_editor", ed);
 2170     ui.editBookmarksAction->setEnabled(false);
 2171     connect(ed, SIGNAL(restartQuery()), this, SLOT(makeNetQuery()));
 2172     connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(updateOpenDocuments(QObject*)));
 2173     connect(ed, SIGNAL(openFile(QString)), this, SLOT(bibEditor(QString)));
 2174     ed->show();
 2175     showMessage(tr("Bookmark File Editor launched."));
 2176 }
 2177 
 2178 void cb2Bib::abbreviationsEditor()
 2179 {
 2180     c2bEditor* ed = new c2bEditor(_settingsP->fileName("cb2Bib/JournalFile"), c2bEditor::JAbbrev, this);
 2181     ed->setObjectName("journal_abbreviations_editor");
 2182     _openDocuments.insert("journal_abbreviations_editor", ed);
 2183     ui.editAbbreviationsAction->setEnabled(false);
 2184     connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(updateOpenDocuments(QObject*)));
 2185     connect(ed, SIGNAL(openFile(QString)), this, SLOT(bibEditor(QString)));
 2186     connect(ed, SIGNAL(openBookmarks()), this, SLOT(bookmarksEditor()));
 2187     ed->show();
 2188     showMessage(tr("Journal Abbreviations Editor launched."));
 2189 }
 2190 
 2191 void cb2Bib::regExpsEditor()
 2192 {
 2193     c2bEditor* ed = new c2bEditor(_settingsP->fileName("cb2Bib/RegularExpressionFile"), c2bEditor::RegExp, this);
 2194     ed->setObjectName("regular_expression_editor");
 2195     _openDocuments.insert("regular_expression_editor", ed);
 2196     ui.editRegExpsAction->setEnabled(false);
 2197     connect(ed, SIGNAL(restartEngine()), this, SLOT(restartEngine()));
 2198     connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(updateOpenDocuments(QObject*)));
 2199     connect(ed, SIGNAL(openFile(QString)), this, SLOT(bibEditor(QString)));
 2200     connect(ed, SIGNAL(openBookmarks()), this, SLOT(bookmarksEditor()));
 2201     ed->show();
 2202     showMessage(tr("RegExp File Editor launched."));
 2203 }
 2204 
 2205 void cb2Bib::annoteEditor(const QString& annotefile)
 2206 {
 2207     c2bEditor* ed = new c2bEditor(annotefile, c2bEditor::Annote, this);
 2208     ed->setObjectName("annote_editor");
 2209     _openDocuments.insert("annote_editor", ed);
 2210     connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(updateOpenDocuments(QObject*)));
 2211     connect(ed, SIGNAL(openFile(QString)), this, SLOT(bibEditor(QString)));
 2212     connect(ed, SIGNAL(openBookmarks()), this, SLOT(bookmarksEditor()));
 2213     ed->show();
 2214     showMessage(tr("Annote Editor launched."));
 2215 }
 2216 
 2217 void cb2Bib::initAsBibTeXEditor()
 2218 {
 2219     for (int i = 0; i < _settingsP->cl_bibedit_filenames.count(); ++i)
 2220         bibEditor(_settingsP->cl_bibedit_filenames.at(i));
 2221 }
 2222 
 2223 void cb2Bib::bibEditor(const QString& bibtexfile, bibSearcher* searcher)
 2224 {
 2225     if (bibtexfile.isEmpty())
 2226         return;
 2227     if (_openDocuments.contains(bibtexfile))
 2228     {
 2229         c2bUtils::setWidgetOnTop(_openDocuments.value(bibtexfile));
 2230         return;
 2231     }
 2232     c2bEditor* ed = new c2bEditor(bibtexfile, searcher, this);
 2233     ed->setObjectName(ed->editorFilename());
 2234     _openDocuments.insert(ed->editorFilename(), ed);
 2235     connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(updateOpenDocuments(QObject*)));
 2236     connect(ed, SIGNAL(openFile(QString)), this, SLOT(bibEditor(QString)));
 2237     connect(ed, SIGNAL(openBookmarks()), this, SLOT(bookmarksEditor()));
 2238     connect(ed, SIGNAL(editFileRenamed(QString,QString)), this, SLOT(updateOpenDocuments(QString,QString)));
 2239     ed->show();
 2240     showMessage(tr("BibTeX Editor launched."));
 2241 }
 2242 
 2243 void cb2Bib::updateOpenDocuments(QObject* obj)
 2244 {
 2245     _openDocuments.remove(obj->objectName());
 2246 
 2247     if (!_openDocuments.contains("bookmark_network_editor"))
 2248         ui.editBookmarksAction->setEnabled(true);
 2249     if (!_openDocuments.contains("journal_abbreviations_editor"))
 2250         ui.editAbbreviationsAction->setEnabled(true);
 2251     if (!_openDocuments.contains("regular_expression_editor"))
 2252         ui.editRegExpsAction->setEnabled(true);
 2253 
 2254     if (_settingsP->cl_bibedit && _openDocuments.count() == 0 && isHidden())
 2255         close();
 2256 }
 2257 
 2258 void cb2Bib::updateOpenDocuments(const QString& old_name, const QString& new_name)
 2259 {
 2260     c2bEditor* ed = _openDocuments.take(old_name);
 2261     if (ed)
 2262     {
 2263         if (ed->objectName() == "bookmark_network_editor" || ed->objectName() == "journal_abbreviations_editor" ||
 2264             ed->objectName() == "regular_expression_editor" || ed->objectName() == "annote_editor")
 2265             return;
 2266         ed->setObjectName(new_name);
 2267         _openDocuments.insert(new_name, ed);
 2268         updateBibfile(new_name);
 2269     }
 2270 }
 2271 
 2272 void cb2Bib::bibModified(bool modified)
 2273 {
 2274     _modified = modified;
 2275     ui.AddBibB->setEnabled(_modified);
 2276     if (ui.stackedWidget->currentWidget() == BibBrowser)
 2277         BibBrowser->updatePlainText(_bpP->toBibTeX());
 2278 }
 2279 
 2280 void cb2Bib::updateCheckRepeatedAction()
 2281 {
 2282     // Do not use anyAuthor/anyTitle, _bpP->currentReference() might not yet be set
 2283     ui.checkRepeatedAction->setVisible(!ui.author->text().isEmpty() || !ui.title->text().isEmpty() ||
 2284                                        !ui.editor->text().isEmpty() || !ui.booktitle->text().isEmpty() ||
 2285                                        !ui.id->text().isEmpty());
 2286 }
 2287 
 2288 void cb2Bib::checkRepeated()
 2289 {
 2290     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 2291     isReferenceRepeated();
 2292     QApplication::restoreOverrideCursor();
 2293 }
 2294 
 2295 bool cb2Bib::isReferenceRepeated()
 2296 {
 2297     QFileInfo fi(ui.bibtexfile->currentText());
 2298     showMessage(tr("Checking for similar references at %1.").arg(fi.absolutePath()));
 2299     bibSearcher searcher(_bpP, fi.absolutePath());
 2300     searcher.exec();
 2301     const bool repeated(searcher.hitsCount() > 0);
 2302     if (repeated)
 2303     {
 2304         QApplication::processEvents();
 2305         bibEditor(fi.absolutePath(), &searcher);
 2306         QApplication::processEvents();
 2307         if (searcher.hitsCount() == 1)
 2308             c2b::showMessage(tr("Found %1 similar reference.").arg(searcher.hitsCount()));
 2309         else
 2310             c2b::showMessage(tr("Found %1 similar references.").arg(searcher.hitsCount()));
 2311     }
 2312     else
 2313         showMessage(tr("No similar references found at %1.").arg(fi.absolutePath()));
 2314     return repeated;
 2315 }
 2316 
 2317 
 2318 /****************************************************************************
 2319 
 2320   NETWORK FUNCTIONALITY
 2321 
 2322 *****************************************************************************/
 2323 
 2324 void cb2Bib::makeNetQuery()
 2325 {
 2326     if (!ui.MakeNetworkQueryB->isEnabled())
 2327     {
 2328         showMessage(tr("Currently processing previous query. Resubmit later."));
 2329         return;
 2330     }
 2331     ui.MakeNetworkQueryB->setEnabled(false);
 2332     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 2333     _netQP->submitQuery(_bpP->currentReference(), ClipEdit->toPlainText(), !_pdfImportP);
 2334 }
 2335 
 2336 void cb2Bib::netQueryEnded(bool succeeded, const QString& targetPDF, const QString& targetBib)
 2337 {
 2338     if (!succeeded)
 2339     {
 2340         emit endedProcessing(false);
 2341         c2b::showMessage(tr("Query submission information. %1").arg(_netQP->errorString()));
 2342     }
 2343     else if (targetPDF.isEmpty() && targetBib.isEmpty())
 2344     {
 2345         emit endedProcessing(false);
 2346         c2b::showMessage(tr("Query submitted. %1").arg(_netQP->errorString()));
 2347     }
 2348     else
 2349     {
 2350         const QString previous_article_file(
 2351             _dropped_document_file); // Keep dropped file in case this is auto recognized
 2352         forceDataChange(targetBib);
 2353         if (_bpP->isAutoRecognized() && !targetPDF.isEmpty())
 2354             fileDropped(targetPDF);
 2355         else if (_bpP->isAutoRecognized())
 2356             fileDropped(previous_article_file);
 2357     }
 2358     QApplication::restoreOverrideCursor();
 2359     ui.MakeNetworkQueryB->setEnabled(true);
 2360 }
 2361 
 2362 void cb2Bib::processingEnded()
 2363 {
 2364     if (_settingsP->value("cb2Bib/AutomaticQuery").toBool())
 2365         if (ui.MakeNetworkQueryB->isEnabled() && !_bpP->autoRecognizedString().contains("BibTeX"))
 2366         {
 2367             makeNetQuery();
 2368             return;
 2369         }
 2370     if (_pdfImportP)
 2371         fileDropped(_pdfImportP->processedFile);
 2372     emit endedProcessing(_bpP->isAutoRecognized());
 2373 }
 2374 
 2375 void cb2Bib::linkClicked(const QUrl& ln)
 2376 {
 2377     // Encode link sets dynamic link.
 2378     c2bUtils::openFile(c2b::encodeLink(ln.toString()), this);
 2379 }
 2380 
 2381 void cb2Bib::openFileDocument()
 2382 {
 2383     if (!_dropped_document_file.isEmpty())
 2384         c2bUtils::openFile(_dropped_document_file, this);
 2385 }
 2386 
 2387 void cb2Bib::selectFile()
 2388 {
 2389     const QString fn(c2bFileDialog::getOpenFilename(
 2390                          this, QString(), _settingsP->fileName("cb2Bib/LastDroppedFile"),
 2391                          "Portable Document Format (*.pdf);;DjVu (*.djvu);;Post Script (*.ps);;TeX (*.tex);;All (*)"));
 2392     if (!fn.isEmpty())
 2393         fileDroppedByUser(fn);
 2394 }
 2395 
 2396 void cb2Bib::openAnnote()
 2397 {
 2398     const QString fn(c2bFileDialog::getFilename(this, QString(), _settingsP->fileName("cb2Bib/LastAnnoteFile"),
 2399                      "Annote HTML output (*.tex.html);;LaTeX (*.tex);;All (*)"));
 2400     if (fn.isEmpty())
 2401         return;
 2402     const QString tex_fn(QString(fn).remove(QRegExp("\\.html$")));
 2403     if (!QFileInfo::exists(tex_fn))
 2404     {
 2405         const QString empty_note("%\\c2b_bibtex_directory{" + QFileInfo(ui.bibtexfile->currentText()).absolutePath() +
 2406                                  "}\n%\\c2b_makeindex\n\n\n\\title{New Note}\n\n\n\n");
 2407         if (!c2bUtils::stringToFile(empty_note, tex_fn))
 2408         {
 2409             QMessageBox::information(this, tr("Information - cb2Bib"),
 2410                                      tr("Unable to create new note %1.\nCheck writing permission.").arg(tex_fn),
 2411                                      QMessageBox::Ok);
 2412             return;
 2413         }
 2414     }
 2415     _settingsP->setFilename("cb2Bib/LastAnnoteFile", fn);
 2416 #ifdef C2B_USE_QWEB
 2417     const QStringList flags(QStringList() << "--view-annote" << fn << _settingsP->confCommandFlags());
 2418     QProcess::startDetached(QCoreApplication::applicationFilePath(), flags);
 2419 #else
 2420     annoteEditor(tex_fn);
 2421 #endif
 2422 }