diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-03-05 16:11:12 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-03-05 21:02:19 +0100 |
commit | d616b6a92665855d2ba0ebc2a3064505a4947e06 (patch) | |
tree | dc17f53295b6743ef4a4ce6755c693f58f16a4c7 /sc | |
parent | a6b2e86917dc0f54dbaebe11ce7d3dfd97b4b3fa (diff) |
restore calc navigator custom tooltip
Change-Id: Ic378364e0d6c5eb704872ec9a3c73f63c222855a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90049
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/content.hxx | 5 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 40 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/navigatorpanel.ui | 1 |
3 files changed, 41 insertions, 5 deletions
diff --git a/sc/source/ui/inc/content.hxx b/sc/source/ui/inc/content.hxx index 3411d9438228..87d093b79c5d 100644 --- a/sc/source/ui/inc/content.hxx +++ b/sc/source/ui/inc/content.hxx @@ -90,12 +90,12 @@ class ScContentTree @param rnRootIndex Root index of specified entry is returned. @param rnChildIndex Index of the entry inside its root is returned (or SC_CONTENT_NOCHILD if entry is root). @param pEntry The entry to examine. */ - void GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, weld::TreeIter* pEntry) const; + void GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, const weld::TreeIter* pEntry) const; /** Returns the child index of the specified listbox entry. @param pEntry The entry to examine or NULL for the selected entry. @return Index of the entry inside its root or SC_CONTENT_NOCHILD if entry is root. */ - sal_uLong GetChildIndex(weld::TreeIter* pEntry) const; + sal_uLong GetChildIndex(const weld::TreeIter* pEntry) const; ScDocument* GetSourceDocument(); @@ -118,6 +118,7 @@ class ScContentTree DECL_LINK(KeyInputHdl, const KeyEvent&, bool); DECL_LINK(AsyncStoreNavigatorSettings, void*, void); DECL_LINK(CommandHdl, const CommandEvent&, bool); + DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString); DECL_LINK(DragBeginHdl, bool&, bool); public: diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 9f7bb3ef2696..d1b66b8f6f34 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -139,6 +139,7 @@ ScContentTree::ScContentTree(std::unique_ptr<weld::TreeView> xTreeView, ScNaviga m_xTreeView->connect_mouse_release(LINK(this, ScContentTree, MouseReleaseHdl)); m_xTreeView->connect_key_press(LINK(this, ScContentTree, KeyInputHdl)); m_xTreeView->connect_popup_menu(LINK(this, ScContentTree, CommandHdl)); + m_xTreeView->connect_query_tooltip(LINK(this, ScContentTree, QueryTooltipHdl)); rtl::Reference<TransferDataContainer> xHelper(m_xTransferObj.get()); m_xTreeView->enable_drag_source(xHelper, DND_ACTION_COPYMOVE | DND_ACTION_LINK); @@ -235,7 +236,7 @@ void ScContentTree::InsertContent( ScContentId nType, const OUString& rValue ) } } -void ScContentTree::GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, weld::TreeIter* pEntry) const +void ScContentTree::GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, const weld::TreeIter* pEntry) const { rnRootIndex = ScContentId::ROOT; rnChildIndex = SC_CONTENT_NOCHILD; @@ -282,11 +283,11 @@ void ScContentTree::GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChild } } -sal_uLong ScContentTree::GetChildIndex(weld::TreeIter* pEntry) const +sal_uLong ScContentTree::GetChildIndex(const weld::TreeIter* pEntry) const { ScContentId nRoot; sal_uLong nChild; - GetEntryIndexes( nRoot, nChild, pEntry ); + GetEntryIndexes(nRoot, nChild, pEntry); return nChild; } @@ -606,6 +607,39 @@ IMPL_LINK(ScContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) return bDone; } +IMPL_LINK(ScContentTree, QueryTooltipHdl, const weld::TreeIter&, rEntry, OUString) +{ + OUString aHelpText; + + std::unique_ptr<weld::TreeIter> xParent(m_xTreeView->make_iterator(&rEntry)); + if (!m_xTreeView->iter_parent(*xParent)) + xParent.reset(); + + if (!xParent) // Top-Level ? + { + aHelpText = OUString::number(m_xTreeView->iter_n_children(rEntry)) + + " " + m_xTreeView->get_text(rEntry); + } + else if (m_xTreeView->iter_compare(*xParent, *m_aRootNodes[ScContentId::NOTE]) == 0) + { + aHelpText = m_xTreeView->get_text(rEntry); // notes as help text + } + else if (m_xTreeView->iter_compare(*xParent, *m_aRootNodes[ScContentId::AREALINK]) == 0) + { + auto nIndex = GetChildIndex(&rEntry); + if (nIndex != SC_CONTENT_NOCHILD) + { + const ScAreaLink* pLink = GetLink(nIndex); + if (pLink) + { + aHelpText = pLink->GetFile(); // source file as help text + } + } + } + + return aHelpText; +} + ScDocument* ScContentTree::GetSourceDocument() { if (bHiddenDoc) diff --git a/sc/uiconfig/scalc/ui/navigatorpanel.ui b/sc/uiconfig/scalc/ui/navigatorpanel.ui index 48fa789f8748..86e9a999682b 100644 --- a/sc/uiconfig/scalc/ui/navigatorpanel.ui +++ b/sc/uiconfig/scalc/ui/navigatorpanel.ui @@ -287,6 +287,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="has_tooltip">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="model">liststore1</property> |