commit 6b2ccc49f14103a4a4755b6c20713a85374b4648
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Sat Apr 5 10:05:11 2025 +0200

    Display "pretty" targets also in selected labels widget
---
 src/frontends/qt/GuiRef.cpp  | 24 ++++++++++++++++++++++++
 src/frontends/qt/GuiRef.h    |  2 ++
 src/frontends/qt/ui/RefUi.ui | 15 +++++++++++++--
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp
index 5552207d8a..4baddd0ed4 100644
--- a/src/frontends/qt/GuiRef.cpp
+++ b/src/frontends/qt/GuiRef.cpp
@@ -152,6 +152,7 @@ GuiRef::GuiRef(GuiView & lv)
 
        setFocusProxy(filter_);
        refsTW->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+       
selectedLV->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
 }
 
 
@@ -467,6 +468,8 @@ void GuiRef::addClicked()
        selectedLV->addTopLevelItem(item);
        selectedLV->setCurrentItem(item);
 
+       updateSelectedPrettyTargets();
+
        changed_adaptor();
 }
 
@@ -626,12 +629,29 @@ void GuiRef::updateContents()
 
        updateRefs();
        enableBoxes();
+
+       // Set or update "pretty" targets
+       updateSelectedPrettyTargets();
+
        // Activate OK/Apply buttons if the users inserts a new ref
        // and we have a valid pre-setting.
        bc().setValid(isValid() && new_inset);
 }
 
 
+void GuiRef::updateSelectedPrettyTargets()
+{
+       QList<QTreeWidgetItem *> selRefs = selectedLV->findItems("*", 
Qt::MatchWildcard);
+       for (int i = 0; i < selRefs.size(); ++i) {
+               for (auto const & theref : refs_) {
+                       if (get<0>(theref) == 
qstring_to_ucs4(selRefs.at(i)->data(0, Qt::UserRole).toString())) {
+                               selRefs.at(i)->setText(1, 
toqstr(get<2>(theref)));
+                               break;
+                       }
+               }
+       }
+}
+
 void GuiRef::applyView()
 {
        QList<QTreeWidgetItem *> selRefs = selectedLV->findItems("*", 
Qt::MatchWildcard);
@@ -929,6 +949,9 @@ void GuiRef::updateRefs()
                        Buffer const * buf = theBufferList().getBuffer(name);
                        buf->getLabelList(refs_);
                }
+       } else {
+               refs_.clear();
+               buffer().masterBuffer()->getLabelList(refs_);
        }
        bool const enable_tw = (show_labels) ? !refs_.empty()
                                             : isTargetAvailable(target);
@@ -1027,6 +1050,7 @@ bool GuiRef::initialiseParams(std::string const & sdata)
                QTreeWidgetItem * item = new QTreeWidgetItem(selectedLV);
                item->setText(0, toqstr(sr));
                item->setData(0, Qt::UserRole, toqstr(sr));
+               item->setText(1, qt_("Unknown[[ref target]]"));
                selRefsItems.append(item);
        }
        if (!selRefsItems.empty()) {
diff --git a/src/frontends/qt/GuiRef.h b/src/frontends/qt/GuiRef.h
index fcd1822c98..631b06fac6 100644
--- a/src/frontends/qt/GuiRef.h
+++ b/src/frontends/qt/GuiRef.h
@@ -118,6 +118,8 @@ private:
        bool isTargetAvailable(QString const &);
        ///
        void getTargetChildren(QModelIndex &, QAbstractItemModel *, 
QTreeWidgetItem *, QString const &);
+       ///
+       void updateSelectedPrettyTargets();
 
        /// contains the search box
        FancyLineEdit * filter_;
diff --git a/src/frontends/qt/ui/RefUi.ui b/src/frontends/qt/ui/RefUi.ui
index da932cf27a..a0158b15f2 100644
--- a/src/frontends/qt/ui/RefUi.ui
+++ b/src/frontends/qt/ui/RefUi.ui
@@ -169,12 +169,23 @@
        <property name="indentation">
         <number>0</number>
        </property>
+       <property name="columnCount">
+        <number>2</number>
+       </property>
        <attribute name="headerVisible">
-        <bool>false</bool>
+        <bool>true</bool>
        </attribute>
+       <attribute name="headerDefaultSectionSize">
+        <number>150</number>
+       </attribute>
+       <column>
+        <property name="text">
+         <string notr="true">Label</string>
+        </property>
+       </column>
        <column>
         <property name="text">
-         <string notr="true">1</string>
+         <string>Reference counter value</string>
         </property>
        </column>
       </widget>
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to