Logo Search packages:      
Sourcecode: cb2bib version File versions


 *   Copyright (C) 2004-2009 by Pere Constans
 *   constans@molspaces.com
 *   cb2Bib version 1.3.0. Licensed under the GNU GPL version 3.
 *   See the LICENSE file that comes with this distribution.
#include "c2bConfigure.h"

#include "c2b.h"
#include "c2bConfigureFR.h"
#include "c2bFileDialog.h"
#include "c2bSettings.h"
#include "c2bUtils.h"

#include <QColorDialog>
#include <QHeaderView>
#include <QStatusTipEvent>

/** \page c2bconf Configuration

- \ref c2bconf_annote
- \ref c2bconf_bibtex
- \ref c2bconf_clipboard
- \ref c2bconf_documents
- \ref c2bconf_files
- \ref c2bconf_fonts
- \ref c2bconf_network
- \ref c2bconf_utilities

\section c2bconf_annote Configuring Annote

    - <b>Annote Cascading Style Sheet (CSS)</b> \n This file contains the style
    sheet to personalize the appearance of the HTML notes generated by the
    cb2Bib. The cb2Bib distribution includes the <tt>tex2html.css</tt> file as
    a CSS template.

    - <b>jsMath Directory</b> \n The mathematical notation in the text notes is
    displayed by
    <a href="http://www.math.union.edu/~dpvc/jsMath/" target="_blank">jsMath</a>.
    The jsMath is a Java Script library. Its location must be specified inside
    the HTML files in order to be known by the browser.

    - <b>Include CSS in HTML</b> \n Styles for the notes will be included, if
    checked, into the HTML file. In this way, all the information, text and
    layout, is contained in one single file.

    - <b>Use relative links</b> \n If checked, linked local files will be set
    relative to the current HTML document.

    - <b>Annote Viewer Fonts</b> \n Selects default and monospaced fonts for
    the Annote viewer. Changes in the fonts might need restarting the viewer
    unless using some of the latest QtWebKit libraries. The viewer is disabled
    if the cb2Bib was not compiled and linked against WebKit. Note also that
    fonts specified in the CSS prevail over this selection.

\section c2bconf_bibtex Configuring BibTeX

    - <b>Author and Editor Name Format</b> \n Sets Authors and Editor names in
    abbreviated or full form, if the latter is available.

    - <b>Journal Name Format</b> \n Sets output journal names in abbreviated or
    full form. Note that this feature only works if journal names are found in
    the <tt>Journal Abbreviation List file</tt>.

    - <b>CiteID Pattern</b> \n Specifies the pattern for formatting cite's ID.
    Predefined placeholders are available as a context menu, by right-clicking
    this edit line. Placeholders will be substituted by the actual reference
    field values. See \ref citeid_placeholders for descriptions.

    - <b>Convert entry strings to LaTeX</b> \n If checked, cb2Bib converts
    special characters to LaTeX commands. Most BibTeX import filters do not
    process LaTeX escaped characters. Therefore, keeping this box unchecked can
    be appropriate when using cb2Bib as a temporary media to transfer
    references to non BibTeX reference managers.

    - <b>Set 'title' in double braces</b> \n If checked, it writes extra braces
    in title. This will keep capitalization as is, when processed by BibTeX.

    - <b>Postprocess 'month'</b> \n If checked, cb2Bib elaborates the 'month'
    string on a BibTeX fashion. E.g., 'April 1' becomes '"1~" # apr'. No
    processing is done if the input string is not written in English.

    - <b>Try Heuristic Guess if recognition fails</b> \n If checked, and the
    automatic recognition fails, cb2Bib tries to catch some of the fields of
    the reference through an heuristic set of rules. See \ref heuristic_guess.

    - <b>Page Number Separator</b> \n Sets number separator, e.g., ' - ' or '
    -- '. Spaces count. It applies also to multiple <tt>volume</tt>,
    <tt>number</tt>, and <tt>year</tt> cases.

    - <b>External BibTeX Postprocessing</b> \n Use this box to select a BibTeX
    postprocessing external tool. The name of the executable, the command
    arguments and the output file extension are required fields. Arguments, any
    number, are passed to the executable. For the sake of generality, it is
    required to specify the <tt>\%finput</tt> and <tt>\%foutput</tt>
    placeholders. The first one is later substituted by the current BibTeX
    filename. The second one is substituted by the current filename with the
    specified output extension. <b>Caution:</b> Be careful if using the same
    file extension for input and output, e.g., using <tt>bib</tt> because you
    want to use a beautifier or a sorting script. The cb2Bib has no control on
    external disk modifications. Moreover, if the script fails, the input data
    might be lost. See also \ref keyboard.

\section c2bconf_clipboard Configuring Clipboard

    - <b>Replace/Remove from Input Stream</b> \n If checked, input stream is
    preprocessed by performing a customizable set of string
    substitutions/removals. This option is mainly intended to remove image HTML
    <tt>alt</tt> tags. Although not visible, <tt>alt</tt> tags reach the
    clipboard when selecting and copying text. Author lists with email icons
    may contain <tt>alt</tt> strings that would interfere with the author names
    processing. In addition, this option is also appropriate to help
    translating special characters to Unicode and LaTeX. Use it carefully, as
    to avoid unwanted or unsuspected substitutions. See also \ref bibproc.

    - <b>External Clipboard Preparsing Command</b> \n Preparses input stream
    through an external, user-defined tool. Use the box bellow to specify its
    name and path. cb2Bib executes the command <tt>tool_name tmp_inputfile
    tmp_outputfile</tt>. You might consider a wrapper shell script to fullfill
    this particular syntax requirement. Two examples, <tt>isi2bib</tt> and
    <tt>ris2bib</tt> are provided. To test them, make sure the
    <a href="http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html"
    target="_blank">BibUtils Package</a>
    is available on your machine. Otherwise, modify these scripts according to
    your needs. See also \ref keyboard, \ref bibproc, and the examples \ref
    ex_isi_format and \ref ex_ris.

    - <b>Perform always, as part of an automatic extraction</b> \n Performs
    preparsing each time the recognition engine is invoked. <b>Caution:</b>
    cb2Bib, when not in disconnected mode, starts the recognition engine each
    time the clipboard changes. Thus, it might send arbitrary data to the
    external parsing tool. The tool might not be prepared to handle <b>'any
    data'</b> and might fall into a sort of <b>'infinite loop'</b>. cb2Bib
    kills the external tool after a reasonable waiting. But, if the tool is
    called through a wrapper script, killing the script will not end the tool
    itself. Therefore, <b>check this box only when needed</b>. If you write
    your own preparser, design it as to write no data to output file whenever
    it can not process an input properly. When the preparser produces no data,
    the cb2Bib sends instead the input stream to the recognition engine. In
    this way, preparsing and normal cb2Bib functioning will work harmoniously.

    - <b>Do not show log</b> \n If unchecked, the external process messages,
    and the input and output streams are shown in a log window. Showing output
    logs is useful for debugging purposes.

    - <b>Add document metadata to Input Stream</b> \n When checked, if the
    document linked to a reference contains relevant metadata, then metadata
    will be added to the current clipboard contents. The metadata is included
    at the time of adding the document to the current reference, e. g., when
    dropping a file into the cb2Bib panel. If the document has BibTeX
    information, the cb2Bib will automatically set the corresponding fields. If
    it has not, but relevant bibliographic information is found, this data is
    only added to the clipboard panel. To insert it in the edit lines, activate
    the Heuristic Guess (Alt+G). The option <b>Prepend</b> or <b>Append</b> to
    the clipboard contents is provided for conveniently writing regular
    expressions considering metadata contents. File documents are linked to the
    references by the BibTeX tag 'file'. See also \ref metadata.

\section c2bconf_documents Configuring Documents

    - <b>Rename and Copy/Move document files to Directory</b> \n If selected,
    each file 'drag and dropped' onto the cb2Bib main window is renamed to
    <tt>citeID.pdf</tt> (or citeID.ps, citeID.dvi, etc.) and moved to the
    storage directory. If unselected, the file URL is written to the
    <tt>file</tt> bibkeyword, without any renaming or moving of the file. The
    actual copy/move action is scheduled and performed once the reference is
    accepted, e.g., once it is saved.

    - <b>Copy or Move document files</b> \n Choose whether copy or move Network
    Files dropped onto the cb2Bib main window. See also <b>Use External
    Network Client</b>.

    - <b>Set directory relative to the BibTeX File Directory</b> \n If checked,
    the document file is copied/moved to the current BibTeX file directory. If
    the Documents Directory box contains a <b>relative directory</b> it will be
    added to the file name. For example, if it contains <tt>articles</tt>,
    files will be copied to <tt>/current_bibtex_path/articles/</tt>. An
    absolute path in the Documents Directory box will be ignored in this
    context. Note that the file dialog returns here relative file addresses.
    Consequently, only the necessary portion of the full name, instead of the
    fullpath filename, is written to the BibTeX entry. File retrieving from
    within the cb2Bib browser will be relative to the BibTeX file absolute
    \n Use this option if you plan to store in a same or a related directory
    the BibTeX and document files. This option is appropriate for storing
    bibliographic collections in removal devices. Likewise, when the cb2Bib is
    launched in USB mode, by means of the command line switch '--conf', the
    alternate option is not available. See \ref relnotes084 and \ref

    - <b>Insert BibTeX metadata to document files</b> \n If checked, the cb2Bib
    will write bibliographic metadata to the linked document, once the current
    reference is accepted and saved. See also \ref metadata.

    - <b>ExifTool Metadata writer</b> \n The cb2Bib uses
    <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/" target="_blank">ExifTool</a>
    for writing bibliographic metadata to the attached documents. Select here the
    ExifTool path name.

\section c2bconf_files Configuring Files

    - <b>Journal Abbreviation List File</b> \n This file contains a list of
    journal names equivalences: a capital-letter acronym, standard abbreviated
    form, and full name of the journal. If an input journal name is recognized,
    cb2Bib will use the standard abbreviated form for the <tt>journal</tt>
    bibkey. If your usual journal were not within the distributed, default
    <tt>abbreviations.txt</tt>, you could edit this file, or point to a
    personalized abbreviation file. <b>Note:</b> Changes in the abbreviation
    file only take place after reestarting cb2Bib.

    - <b>Regular Expression List File</b> \n The cb2Bib distribution includes
    the file <tt>regexps.txt</tt> with a few set of rules for reference
    extraction. This includes most of the scientific literature. Extracting
    from email alerts or publisher abstract pages is a <em>volatile</em> task.
    Information does not follow a standardized structure. Extraction pattern
    may then change as often as the web design needs to. Besides, such
    extraction from the clipboard is system dependent, in a way that produces
    different formatting of the text copies on different systems. You can use
    your personalized <tt>regexps.txt</tt> file, for testing, debugging
    -regular expressions are reloaded each time the automatic recognition
    engine executes-, and fullfiling your particular extraction needs.

    - <b>Bookmarks and Network Query Info File</b> \n The cb2Bib distribution
    includes the file <tt>netqinf.txt</tt> that contains bookmarks data, and
    server related information for bibliographic querying. Note that the cb2Bib
    treats bibliographic queries as generalized net bookmarks. This allows
    accessing almost any online bibliographic resource. Check this file for
    implementations details and customization.

    - <b>Browser Cascading Style Sheet (CSS)</b> \n This file contains the
    style sheet to configure the appearance of the bibliographic references
    when viewed in browser mode. The cb2Bib distribution includes the
    <tt>references.css</tt> file as a CSS example.

    - <b>Search In Files Cache Directory</b> \n Directory containing internal
    data for Search In Files functionality. If an existing directory is
    selected the cb2Bib will write all internal data on it. If otherwise, cache
    data will be written on the same directory from where BibTeX are searched.
    It might be, therefore, convenient to group all this files in a separate
    directory that does not need to be backup, and that can easily be deleted
    whenever desired.

\section c2bconf_fonts Configuring Fonts

    - <b>Font Selector</b> \n Selects the main window and editor font family
    and size.

    - <b>Context Colors</b> \n Doubleclick on context color items to select
    syntax highlighter font color. Besides syntax highlighting, and to ease
    manual bibliographic extractions, cb2Bib has the following coloring
    convention. 'cb2Bib unrelevant text' colors non-word, non-digit, and
    cb2Bib's internal tags. 'cb2Bib relevant text' refers to the reference's
    year. 'cb2Bib highly relevant' attempts to guess text sectioning,
    highlighting 'abstract', 'introduction', and 'keywords'.

\section c2bconf_network Configuring Network

    - <b>Use External Network Client</b> \n The cb2Bib manages local and
    network files in an equivalent manner. Network file retrieving, however,
    requires sometimes password and/or cookies administration. The KDE desktop
    incorporates <tt>kfmclient</tt> utility. A command <tt>kfmclient
    (copy|move|exec) orig [dest]</tt> permits copying or moving files, with
    <tt>kfmclient</tt> taking care of advanced browsing preferences. By
    checking this box, cb2Bib will use the specified file manger client.

    - <b>Use Proxy</b> \n If checked, the cb2Bib will access the network
    through a proxy host. Set the Host name, the Port, and the proxy Type. A
    login dialog will appear if the proxy requires authentication. Login data
    is not stored, it must be entered at each session.

    - <b>Perform Network Queries after automatic reference extractions</b> \n
    Network queries can be used to complete a partial reference extraction. For
    instance, provided a reference 'J. Name, 25, 103' and an appropriate
    pattern to extract it, cb2Bib will attempt to complete the reference
    automatically. No query is performed if automatic reference extraction was
    tagged as BibTeX.

    - <b>Download document if available</b> \n If checked, cb2Bib downloads
    document files to the directory specified in <b>Rename and Copy/Move
    document files to Directory</b>. See also the file <tt>netqinf.txt</tt> for
    details. Download is scheduled and performed once the reference is
    accepted, e.g., once it is saved.

    - <b>Keep Query temporary files (Debug Only)</b> \n cb2Bib may use up to
    three temporary files to perform a network query. If this box is checked,
    the temporary files are not deleted. This facilitates the testing and
    customization of the information file <tt>netqinf.txt</tt>.

\section c2bconf_utilities Configuring Utilities

    - <b>To plain text converter</b> \n Selects the external
    <tt>some_format_to_text</tt> tool that cb2Bib uses to convert document
    files prior to reference extraction and searching. cb2Bib executes the line
    command <tt>converter [options] inputfile tmp_output.txt</tt>, where
    <tt>[options]</tt> are user defined arguments. As a default, cb2Bib
    launches <tt>pdftotext</tt>, a PDF to text utility found in many platforms.
    Default arguments are <tt>-f 1 -l 1</tt> to extract only the first, title
    page when used within PDFImport, and <tt>-raw</tt>, to convert the complete
    document when used within Search in Files. Appropriate for PDFImport could
    also be a document metadata extractor. Often metadata contains structured
    information regarding document authors, title, and source. A simple shell
    script wrapper could be the following <tt>any2text_search</tt>:

   # Convert documents to text according to filename extension
   # any2text_search input_fn.ext output_fn.txt
   set ext = $1:e
   if ( $ext == 'djvu' ) then
      /usr/bin/djvutxt "$1" "$2"
      if ($status) exit 1
   else if ( $ext == 'chm' ) then
      (/usr/bin/archmage -d "$1" > "$2") >& /dev/null
      if ($status) exit 1
      /usr/bin/pdftotext -raw "$1" "$2"
      if ($status) exit 1


c2bConfigure::c2bConfigure(QWidget* parentw) : QDialog(parentw)
    resize(QSize(1, 1)); // Set it at minimum size
    settings = c2bSettingsP;

    for (int i = 0; i < ui.contentsWidget->count(); ++i)
        ui.contentsWidget->item(i)->setStatusTip(tr("Configure %1").arg(ui.contentsWidget->item(i)->text()));
    connect(ui.contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
            this, SLOT(changePage(QListWidgetItem*, QListWidgetItem*)));
    ui.contentsWidget->setCurrentItem(ui.contentsWidget->item(settings->value("c2bConfigure/CurrentPage", 0).toInt()));
    connect(ui.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
    connect(ui.buttonBox, SIGNAL(helpRequested()), this, SLOT(help()));

    // Annote
    connect(ui.AnnoteCssDir, SIGNAL(clicked()), this, SLOT(getAnnoteCssFile()));
    connect(ui.jsMathDir, SIGNAL(clicked()), this, SLOT(getjsMathDirectory()));
    fontSelection(settings->value("c2bAnnote/Font").value<QFont>(), ui.af_familycombo, ui.af_psizecombo);
    fontSelection(settings->value("c2bAnnote/FixedFont").value<QFont>(), ui.aff_familycombo, ui.aff_psizecombo);
#ifndef C2B_WEBKIT

    // BibTeX
    connect(ui.PostprocessBibTeXDir, SIGNAL(clicked()), this, SLOT(getPostprocessBibTeXBin()));

    // Clipboard
    connect(ui.FindReplaceInput, SIGNAL(toggled(bool)), this, SLOT(updateFindReplaceInputButtons()));
    QStringList FindReplaceInputList = settings->value("cb2Bib/FindReplaceInputList").toStringList();
    QStringList::Iterator i = FindReplaceInputList.begin();
    while (i != FindReplaceInputList.end())
        QStringList spLine = (*i).split("|");
        new QTreeWidgetItem(ui.FindReplaceList, spLine);
    connect(ui.FindReplaceList, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(FindReplaceDialog_Edit()));
    connect(ui.FindReplaceList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(updateFindReplaceInputButtons()));
    connect(ui.FRNew, SIGNAL(clicked()), this, SLOT(FindReplaceDialog_New()));
    connect(ui.FREdit, SIGNAL(clicked()), this, SLOT(FindReplaceDialog_Edit()));
    connect(ui.FRDelete, SIGNAL(clicked()), this, SLOT(FindReplaceDialog_Delete()));
    QString PreAppendMetadata = settings->value("cb2Bib/PreAppendMetadata").toString();
    if (PreAppendMetadata == "prepend")
    else if (PreAppendMetadata == "append")
    if (ui.AddMetadata->isChecked())
    connect(ui.AddMetadata, SIGNAL(toggled(bool)), ui.PreAppendMetadata, SLOT(setEnabled(bool)));
    connect(ui.PreparserDir, SIGNAL(clicked()), this, SLOT(getPreparserBin()));

    // Documents
    connect(ui.PdfDir, SIGNAL(clicked()), this, SLOT(getPdfDirectory()));
    QString CopyMovePdf = settings->value("cb2Bib/CopyMovePdf").toString();
    if (CopyMovePdf == "copy")
    else if (CopyMovePdf == "move")
    if (ui.MovePdf->isChecked())
    connect(ui.MovePdf, SIGNAL(toggled(bool)), ui.RenameCopyMovePdf, SLOT(setEnabled(bool)));
    connect(ui.ExifToolDir, SIGNAL(clicked()), this, SLOT(getExifToolBin()));

    // Files
    connect(ui.JournalDir, SIGNAL(clicked()), this, SLOT(getJournalFile()));
    connect(ui.RegularExpressionDir, SIGNAL(clicked()), this, SLOT(getRegularExpressionFile()));
    connect(ui.NetworkDir, SIGNAL(clicked()), this, SLOT(getNetworkFile()));
    connect(ui.BrowserCssDir, SIGNAL(clicked()), this, SLOT(getBrowserCssFile()));
    connect(ui.CacheDir, SIGNAL(clicked()), this, SLOT(getCacheDirectory()));

    // Fonts
    c2bMonoFont = settings->c2bMonoFont;
    fontSelection(c2bMonoFont, ui.familycombo, ui.psizecombo);
    connect(ui.familycombo, SIGNAL(activated(const QString&)), this, SLOT(comboFamilyChanged(const QString&)));
    connect(ui.psizecombo, SIGNAL(activated(const QString&)), this, SLOT(comboSizeChanged(const QString&)));
    QHashIterator<QString, QColor*> cit(colors.colorList);
    while (cit.hasNext())
        QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(cit.key()));
        item->setData(0, Qt::DecorationRole, *cit.value());
        item->setData(0, Qt::TextColorRole, *cit.value());
        ui.ColorList->insertTopLevelItem(0, item);
    ui.ColorList->sortItems(0, Qt::AscendingOrder);
    connect(ui.ColorList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(changeContextColor(QTreeWidgetItem*)));
    connect(ui.ColorList, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(changeContextColor(QTreeWidgetItem*)));

    // Network
    connect(ui.FmClientCopyDir, SIGNAL(clicked()), this, SLOT(getFmClientCopyBin()));
    connect(ui.FmClientMoveDir, SIGNAL(clicked()), this, SLOT(getFmClientMoveBin()));
    ui.ProxyHostName->setText(settings->value("cb2Bib/ProxyHostName", QString()).toString());
    QValidator* proxyPortValidator = new QIntValidator(0, 999999, this);

    // Utilities
    connect(ui.PdfImportPdf2TextDir, SIGNAL(clicked()), this, SLOT(getPdfImportPdf2TextBin()));
    connect(ui.BibSearcherPdf2TextDir, SIGNAL(clicked()), this, SLOT(getBibSearcherPdf2TextBin()));


void c2bConfigure::setPage(int index)

void c2bConfigure::accept()

void c2bConfigure::apply()
    settings->setValue("c2bConfigure/CurrentPage", ui.contentsWidget->row(ui.contentsWidget->currentItem()));

    // Annote
    settings->setFilename("c2bAnnote/AnnoteCssFile", ui.AnnoteCssFile->text());
    settings->setFilename("c2bAnnote/jsMathDirectory", ui.jsMathDirectory->text());
    settings->setValue("c2bAnnote/IncludeCSS", ui.IncludeCSS->isChecked());
    settings->setValue("c2bAnnote/UseRelativeLinks", ui.UseRelativeLinks->isChecked());
    settings->setValue("c2bAnnote/Font", selectedFont(ui.af_familycombo, ui.af_psizecombo));
    settings->setValue("c2bAnnote/FixedFont", selectedFont(ui.aff_familycombo, ui.aff_psizecombo));

    // BibTeX
    settings->setValue("cb2Bib/PostprocessMonth", ui.PostprocessMonth->isChecked());
    settings->setValue("cb2Bib/ConvertReferenceToLaTeX", ui.ConvertReferenceToLaTeX->isChecked());
    settings->setValue("cb2Bib/UseDoubleBraces", ui.UseDoubleBraces->isChecked());
    settings->setValue("cb2Bib/UseFullNames", ui.UseFullNames->isChecked());
    settings->setValue("cb2Bib/SetJournalsToFullname", ui.SetJournalsToFullname->isChecked());
    settings->setFilename("cb2Bib/PostprocessBibTeXBin", ui.PostprocessBibTeXBin->text());
    settings->setValue("cb2Bib/PostprocessBibTeXArg", ui.PostprocessBibTeXArg->text());
    settings->setValue("cb2Bib/PostprocessBibTeXExt", ui.PostprocessBibTeXExt->text());
    settings->setValue("cb2Bib/DoHeuristicGuess", ui.DoHeuristicGuess->isChecked());
    settings->setValue("cb2Bib/PageNumberSeparator", ui.PageNumberSeparator->text());
    settings->setValue("cb2Bib/CiteIdPattern", ui.CiteIdPattern->text());

    // Clipboard
    QStringList FindReplaceInputList;
    QTreeWidgetItemIterator it(ui.FindReplaceList);
    while (*it)
        QTreeWidgetItem* item = *it;
        QString Line = QString("%1|%2|%3").arg(item->text(0)).arg(item->text(1)).arg(item->text(2));
    if (FindReplaceInputList.isEmpty())
        FindReplaceInputList = C2B_FIND_REPLACE_LIST.split("^e");
        settings->setValue("cb2Bib/FindReplaceInput", false);
        settings->setValue("cb2Bib/FindReplaceInput", ui.FindReplaceInput->isChecked());
    settings->setValue("cb2Bib/FindReplaceInputList", FindReplaceInputList);
    QString PreAppendMetadata;
    if (ui.Prepend->isChecked())
        PreAppendMetadata = "prepend";
        PreAppendMetadata = "append";
    settings->setValue("cb2Bib/PreAppendMetadata", PreAppendMetadata);
    settings->setValue("cb2Bib/AddMetadata", ui.AddMetadata->isChecked());
    settings->setValue("cb2Bib/PreparserAutomatic", ui.PreparserAutomatic->isChecked());
    settings->setValue("cb2Bib/PreparserShowLog", !ui.PreparserShowLog->isChecked());
    settings->setFilename("cb2Bib/PreparserBin", ui.PreparserBin->text());

    // Documents
    QString CopyMovePdf;
    if (ui.Copy->isChecked())
        CopyMovePdf = "copy";
        CopyMovePdf = "move";
    settings->setValue("cb2Bib/CopyMovePdf", CopyMovePdf);
    settings->setValue("cb2Bib/MovePdf", ui.MovePdf->isChecked());
    settings->setFilename("cb2Bib/PdfDirectory", ui.PdfDirectory->text());
    settings->setValue("cb2Bib/RelativePdfDirectory", ui.RelativePdfDirectory->isChecked());
    settings->setValue("cb2Bib/InsertMetadata", ui.InsertMetadata->isChecked());
    settings->setFilename("cb2Bib/ExifToolBin", ui.ExifToolBin->text());

    // Files
    settings->setFilename("cb2Bib/JournalFile", ui.JournalFile->text());
    settings->setFilename("cb2Bib/RegularExpressionFile", ui.RegularExpressionFile->text());
    settings->setFilename("cb2Bib/NetworkFile", ui.NetworkFile->text());
    settings->setFilename("cb2Bib/BrowserCssFile", ui.BrowserCssFile->text());
    settings->setFilename("cb2Bib/CacheDirectory", ui.CacheDirectory->text());

    // Fonts
    settings->setValue("cb2Bib/MonoFont", c2bMonoFont);

    // Network
    settings->setValue("cb2Bib/FmClient", ui.FmClient->isChecked());
    settings->setFilename("cb2Bib/FmClientCopyBin", ui.FmClientCopyBin->text());
    settings->setFilename("cb2Bib/FmClientMoveBin", ui.FmClientMoveBin->text());
    settings->setValue("cb2Bib/FmClientCopyArg", ui.FmClientCopyArg->text().simplified());
    settings->setValue("cb2Bib/FmClientMoveArg", ui.FmClientMoveArg->text().simplified());
    settings->setValue("cb2Bib/UseProxy", ui.UseProxy->isChecked());
    settings->setValue("cb2Bib/ProxyHostName", ui.ProxyHostName->text().trimmed());
    settings->setValue("cb2Bib/ProxyPort", ui.ProxyPort->text().trimmed());
    settings->setValue("cb2Bib/ProxyType", ui.ProxyType->currentIndex());
    settings->setValue("cb2Bib/AutomaticQuery", ui.AutomaticQuery->isChecked());
    settings->setValue("cb2Bib/AutomaticPdfDownload", ui.AutomaticPdfDownload->isChecked());
    settings->setValue("cb2Bib/KeepTmpNQFiles", ui.KeepTmpNQFiles->isChecked());

    // Utilities
    settings->setValue("c2bPdfImport/Pdf2TextArg", ui.PdfImportPdf2TextArg->text().simplified());
    settings->setFilename("c2bPdfImport/Pdf2TextBin", ui.PdfImportPdf2TextBin->text());
    settings->setValue("c2bBibSearcher/Pdf2TextArg", ui.BibSearcherPdf2TextArg->text().simplified());
    settings->setFilename("c2bBibSearcher/Pdf2TextBin", ui.BibSearcherPdf2TextBin->text());

    // Notify settings

void c2bConfigure::comboFamilyChanged(const QString& family)
    ui.samplelineedit->setFont(QFont(family, ui.psizecombo->currentText().toInt()));

void c2bConfigure::comboSizeChanged(const QString& pt)
    ui.samplelineedit->setFont(QFont(ui.familycombo->currentText(), pt.toInt()));

void c2bConfigure::FindReplaceDialog_Delete()
    QTreeWidgetItem* item = ui.FindReplaceList->currentItem();
    delete item;
    item = ui.FindReplaceList->currentItem();
    if (item)

void c2bConfigure::FindReplaceDialog_Edit()
    QTreeWidgetItem* item = ui.FindReplaceList->currentItem();
    if (item)
        c2bConfigureFR* frD = new c2bConfigureFR(item, this);
        delete frD;

void c2bConfigure::FindReplaceDialog_New()
    QStringList newlist;
    newlist << "" << "" << "";
    QTreeWidgetItem* fri = new QTreeWidgetItem(ui.FindReplaceList, newlist);
    c2bConfigureFR* frD = new c2bConfigureFR(fri, this);
    if (frD->exec() != QDialog::Accepted)
        delete fri;
    delete frD;

void c2bConfigure::updateFindReplaceInputButtons()
    if (!ui.FindReplaceInput->isChecked())
        if (ui.FindReplaceList->topLevelItemCount() > 0)

void c2bConfigure::getAnnoteCssFile()
    QString fn = ui.AnnoteCssFile->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, tr("Select CSS filename"),
                     fn, tr("Cascading Style Sheets (*.css);;All (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getjsMathDirectory()
    QString new_dir = c2bFileDialog::getExistingDirectory(this, tr("Select jsMath directory"), ui.jsMathDirectory->text());
    if (!new_dir.isEmpty())

void c2bConfigure::getJournalFile()
    QString fn = ui.JournalFile->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, tr("Select a filename (Restart to apply changes)"),
                     fn, tr("cb2Bib Journal Lists (*.txt);;All (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getRegularExpressionFile()
    QString fn = ui.RegularExpressionFile->text();
    QString new_fn = c2bFileDialog::getFilename(this, "", fn, tr("cb2Bib RegExp Lists (*.txt);;All (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getNetworkFile()
    QString fn = ui.NetworkFile->text();
    QString new_fn = c2bFileDialog::getFilename(this, "", fn, tr("cb2Bib Network Query Info (*.txt);;All (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getBrowserCssFile()
    QString fn = ui.BrowserCssFile->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, tr("Select a filename (Restart editor to apply changes)"),
                     fn, tr("Cascading Style Sheets (*.css);;All (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getFmClientCopyBin()
    QString fn = ui.FmClientCopyBin->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, "", fn, tr("File Manager Client executable (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getPreparserBin()
    QString fn = ui.PreparserBin->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, "", fn, tr("External Parser executable (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getFmClientMoveBin()
    QString fn = ui.FmClientMoveBin->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, "", fn, tr("File Manager Client executable (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getPostprocessBibTeXBin()
    QString fn = ui.PostprocessBibTeXBin->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, "", fn, tr("BibTeX Postprocess executable (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getPdfImportPdf2TextBin()
    QString fn = ui.PdfImportPdf2TextBin->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, "", fn, tr("PDF to text converter (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getBibSearcherPdf2TextBin()
    QString fn = ui.BibSearcherPdf2TextBin->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, "", fn, tr("PDF to text converter (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getExifToolBin()
    QString fn = ui.ExifToolBin->text();
    QString new_fn = c2bFileDialog::getOpenFilename(this, "", fn, tr("ExifTool (*)"));
    if (!new_fn.isEmpty())

void c2bConfigure::getCacheDirectory()
    QString new_dir = c2bFileDialog::getExistingDirectory(this, tr("Select a cache directory"), ui.CacheDirectory->text());
    if (!new_dir.isEmpty())

void c2bConfigure::getPdfDirectory()
    QString dir = c2bUtils::documentAbsoluteName(ui.RelativePdfDirectory->isChecked(), settings->fileName("cb2Bib/BibTeXFile"),
                  ui.PdfDirectory->text(), "");
    QString new_dir = c2bFileDialog::getExistingDirectory(this, tr("Select documents directory"), dir);
    if (!new_dir.isEmpty())
        new_dir = c2bUtils::documentDirName(ui.RelativePdfDirectory->isChecked(), settings->fileName("cb2Bib/BibTeXFile"), new_dir);

void c2bConfigure::populateFontCombos()
    QFontDatabase db;
    QList<int> sizes = db.standardSizes();
    QList<int>::Iterator it = sizes.begin();
    while (it != sizes.end())
        ui.psizecombo->insertItem(0, QString::number(*it));
        ui.af_psizecombo->insertItem(0, QString::number(*it));
        ui.aff_psizecombo->insertItem(0, QString::number(*it));

void c2bConfigure::fontSelection(const QFont& f, QFontComboBox* fc, QComboBox* sc)
    int p_font_size = f.pointSize();
    int i = 0;
    while (i < sc->count())
        if (sc->itemText(i) == QString::number(p_font_size))

QFont c2bConfigure::selectedFont(QFontComboBox* fc, QComboBox* sc) const
    QFont f = fc->currentFont();
    return f;

void c2bConfigure::changeContextColor(QTreeWidgetItem* item)
    QColor newColor = QColorDialog::getColor(item->textColor(0), this);
    if (newColor.isValid())
        item->setData(0, Qt::TextColorRole, newColor);
        item->setData(0, Qt::DecorationRole, newColor);
        colors.updateColor(newColor, item->text(0));

void c2bConfigure::changePage(QListWidgetItem* current, QListWidgetItem* previous)
    if (!current)
        current = previous;
    setWindowTitle(tr("Configure %1 - cb2Bib").arg(current->text()));

bool c2bConfigure::event(QEvent* qevent)
    if (qevent->type() == QEvent::StatusTip)
        return true;
        return QWidget::event(qevent);

void c2bConfigure::help()
    c2bUtils::displayHelp("http://www.molspaces.com/d_cb2bib-c2bconf.php#c2bconf_" +

Generated by  Doxygen 1.6.0   Back to index