]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiCitation.cpp
Consider possibility of empty tooltip
[lyx.git] / src / frontends / qt4 / GuiCitation.cpp
index 10c91670afbb4a6985973102aa4015c7f976e89f..5889d68f7c7abd668f41f78a624715aab0007c8f 100644 (file)
@@ -25,6 +25,7 @@
 #include "BufferView.h"
 #include "BiblioInfo.h"
 #include "BufferParams.h"
+#include "TextClass.h"
 #include "FuncRequest.h"
 
 #include "insets/InsetCommand.h"
@@ -123,7 +124,7 @@ GuiCitation::GuiCitation(GuiView & lv)
 
        connect(citationStyleCO, SIGNAL(activated(int)),
                this, SLOT(on_citationStyleCO_currentIndexChanged(int)));
-       connect(fulllistCB, SIGNAL(clicked()),
+       connect(starredCB, SIGNAL(clicked()),
                this, SLOT(changed()));
        connect(forceuppercaseCB, SIGNAL(clicked()),
                this, SLOT(changed()));
@@ -179,7 +180,7 @@ void GuiCitation::applyView()
 {
        int const choice = max(0, citationStyleCO->currentIndex());
        style_ = choice;
-       bool const full  = fulllistCB->isChecked();
+       bool const full  = starredCB->isChecked();
        bool const force = forceuppercaseCB->isChecked();
 
        QString const before = textBeforeED->text();
@@ -246,9 +247,10 @@ void GuiCitation::updateControls(BiblioInfo const & bi)
 
 void GuiCitation::updateFormatting(CitationStyle currentStyle)
 {
+       BufferParams const bp = documentBuffer().params();
        bool const force = currentStyle.forceUpperCase;
-       bool const full = currentStyle.fullAuthorList &&
-               documentBuffer().params().fullAuthorList();
+       bool const starred = currentStyle.hasStarredVersion;
+       bool const full = starred && bp.fullAuthorList();
        bool const textbefore = currentStyle.textBefore;
        bool const textafter = currentStyle.textAfter;
 
@@ -256,13 +258,37 @@ void GuiCitation::updateFormatting(CitationStyle currentStyle)
                selectedLV->model()->rowCount() > 0;
 
        forceuppercaseCB->setEnabled(force && haveSelection);
-       fulllistCB->setEnabled(full && haveSelection);
+       starredCB->setEnabled(full && haveSelection);
        textBeforeED->setEnabled(textbefore && haveSelection);
        textBeforeLA->setEnabled(textbefore && haveSelection);
        textAfterED->setEnabled(textafter && haveSelection);
        textAfterLA->setEnabled(textafter && haveSelection);
        citationStyleCO->setEnabled(haveSelection);
        citationStyleLA->setEnabled(haveSelection);
+
+       // Check if we have a custom string/tooltip for the starred version
+       if (starred && !currentStyle.stardesc.empty()) {
+               string val =
+                       bp.documentClass().getCiteMacro(bp.citeEngineType(), currentStyle.stardesc);
+               docstring guistring;
+               if (!val.empty()) {
+                       guistring = translateIfPossible(from_utf8(val));
+                       starredCB->setText(toqstr(guistring));
+                       starredCB->setEnabled(haveSelection);
+               }
+               if (!currentStyle.startooltip.empty()) {
+                       val = bp.documentClass().getCiteMacro(bp.citeEngineType(),
+                                                             currentStyle.startooltip);
+                       if (!val.empty())
+                               guistring = translateIfPossible(from_utf8(val));
+               }
+               // Tooltip might also be empty
+               starredCB->setToolTip(toqstr(guistring));
+       } else {
+               // This is the default meaning of the starred commands
+               starredCB->setText(qt_("All aut&hors"));
+               starredCB->setToolTip(qt_("Always list all authors (rather than using \"et al.\")"));
+       }
 }
 
 
@@ -516,7 +542,7 @@ void GuiCitation::applyParams(int const choice, bool full, bool force,
                after.clear();
 
        cs.forceUpperCase &= force;
-       cs.fullAuthorList &= full;
+       cs.hasStarredVersion &= full;
        string const command = citationStyleToString(cs);
 
        params_.setCmdName(command);
@@ -555,9 +581,10 @@ void GuiCitation::init()
 
        // Initialize the citation formatting
        string const & cmd = params_.getCmdName();
-       CitationStyle const cs = citationStyleFromString(cmd);
+       CitationStyle const cs =
+               citationStyleFromString(cmd, documentBuffer().params());
        forceuppercaseCB->setChecked(cs.forceUpperCase);
-       fulllistCB->setChecked(cs.fullAuthorList &&
+       starredCB->setChecked(cs.hasStarredVersion &&
                documentBuffer().params().fullAuthorList());
        textBeforeED->setText(toqstr(params_["before"]));
        textAfterED->setText(toqstr(params_["after"]));
@@ -576,7 +603,7 @@ void GuiCitation::init()
                // Find the citation style
                vector<string> const & cmds = citeCmds_;
                vector<string>::const_iterator cit =
-                       std::find(cmds.begin(), cmds.end(), cs.cmd);
+                       std::find(cmds.begin(), cmds.end(), cs.name);
                int i = 0;
                if (cit != cmds.end())
                        i = int(cit - cmds.begin());