> Looks good. One nitpick:
>
> +                       if (!branchlist.find(branch)) {
> +                               branchCO->addItem(toqstr(branch + _("
> (master)")), toqstr(branch));
>
> I'd use boost format for this:
>
> branchCO->addItem(
>         toqstr(bformat( _("%1$s[[branch]] (%2$s)[[master]]"),
>                toqstr(branch), qt_("master"))));
>
> since with RTL scripts your precomposed string will be wrong I think.
>
> --
> Jürgen

Thanks for the suggestion, I've updated the patch.


> Looks good. One point though: for some reason, you use QComboBox::currentData, which is only present in Qt >=5.2. This will break Qt4.
>
>
> JMarc

Now with "(master)" suffix in combobox labels we cannot use them directly as branch names. Is is OK to disable this for Qt4 alltogether, as README says that LyX is only compilable on Qt4?


Yuriy


From 716cc9991d1025614424b7ceaa6761ab0f817083 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <[email protected]>
Date: Fri, 7 Oct 2022 17:41:46 +0300
Subject: [PATCH] Show branches from master document in branch inset dialog

---
 src/frontends/qt/GuiBranch.cpp | 42 +++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/src/frontends/qt/GuiBranch.cpp b/src/frontends/qt/GuiBranch.cpp
index 24b6977390..3a1625306f 100644
--- a/src/frontends/qt/GuiBranch.cpp
+++ b/src/frontends/qt/GuiBranch.cpp
@@ -22,9 +22,13 @@
 
 #include "insets/InsetBranch.h"
 
+#include "support/gettext.h"
+#include "support/lstrings.h"
+
 #include <QPushButton>
 
 using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 namespace frontend {
@@ -40,21 +44,43 @@ GuiBranch::GuiBranch(QWidget * parent) : 
InsetParamsWidget(parent)
 void GuiBranch::paramsToDialog(Inset const * inset)
 {
        InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
-       typedef BranchList::const_iterator const_iterator;
-       BranchList const & branchlist = ib->buffer().params().branchlist();
+       Buffer const & buf = ib->buffer();
+       BranchList const & branchlist = buf.params().branchlist();
        docstring const cur_branch = ib->branch();
 
        branchCO->clear();
-       const_iterator const begin = branchlist.begin();
-       const_iterator const end = branchlist.end();
        int id = 0;
        int count = 0;
-       for (const_iterator it = begin; it != end; ++it, ++count) {
-               docstring const & branch = it->branch();
+       for (Branch const & it : branchlist) {
+               docstring const & branch = it.branch();
+#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
+               branchCO->addItem(toqstr(branch), toqstr(branch));
+#else
                branchCO->addItem(toqstr(branch));
+#endif
                if (cur_branch == branch)
                        id = count;
+               ++count;
+       }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
+       // Add branches from master
+       Buffer const * masterBuf = buf.masterBuffer();
+       if (masterBuf != &buf) {
+               BranchList const & masterBranchlist = 
masterBuf->params().branchlist();
+               for (Branch const & it : masterBranchlist) {
+                       docstring const & branch = it.branch();
+                       if (!branchlist.find(branch)) {
+                               branchCO->addItem(
+                                       toqstr(bformat(_("%1$s[[branch]] 
(%2$s)[[master]]"),
+                                                  branch, _("master"))),
+                                       toqstr(branch));
+                               if (cur_branch == branch)
+                                       id = count;
+                               ++count;
+                       }
+               }
        }
+#endif
        branchCO->setCurrentIndex(id);
        invertedCB->setChecked(ib->params().inverted);
 }
@@ -62,7 +88,11 @@ void GuiBranch::paramsToDialog(Inset const * inset)
 
 docstring GuiBranch::dialogToParams() const
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
+       InsetBranchParams 
params(qstring_to_ucs4(branchCO->currentData().toString()), 
invertedCB->isChecked());
+#else
        InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()), 
invertedCB->isChecked());
+#endif
        return from_utf8(InsetBranch::params2string(params));
 }
 
-- 
2.28.0.windows.1

-- 
lyx-devel mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to