[Libreoffice-commits] core.git: include/vcl vcl/source
Jim Raykowski (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 18 23:23:30 UTC 2019
include/vcl/svimpbox.hxx | 3 +
vcl/source/treelist/svimpbox.cxx | 95 ++++++++++++++++++++++++---------------
2 files changed, 63 insertions(+), 35 deletions(-)
New commits:
commit 888ac516aacbc30a8e9331f6aba7684228568871
Author: Jim Raykowski <raykowj at gmail..com>
AuthorDate: Fri Oct 11 17:14:22 2019 -0800
Commit: Jim Raykowski <raykowj at gmail.com>
CommitDate: Sat Oct 19 01:22:06 2019 +0200
tdf#128058 Make ctrl * expand/collapse tree list entries
Provides same expand all behavior as ctrl + and provides for ctrl - like
behavior but instead of collapsing all to root only collapses to focused
entry aka cursor entry.
Change-Id: Ib65dd98857dd083f77d4bec873c2fa7a4212550a
Reviewed-on: https://gerrit.libreoffice.org/80702
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze at documentfoundation.org>
Tested-by: Heiko Tietze <heiko.tietze at documentfoundation.org>
diff --git a/include/vcl/svimpbox.hxx b/include/vcl/svimpbox.hxx
index aba51a91ed9e..924e9783af9d 100644
--- a/include/vcl/svimpbox.hxx
+++ b/include/vcl/svimpbox.hxx
@@ -204,6 +204,9 @@ private:
bool AreChildrenTransient() const { return m_bAreChildrenTransient; }
void SetChildrenNotTransient() { m_bAreChildrenTransient = false; }
+ void ExpandAll();
+ void CollapseTo(SvTreeListEntry* pParentToCollapse);
+
protected:
VclPtr<SvTreeListBox> m_pView;
VclPtr<ScrollBar> m_aVerSBar;
diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index 5595d9bcb19d..a936c4a3f9e4 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -2095,6 +2095,51 @@ void SvImpLBox::MouseMove( const MouseEvent& rMEvt)
m_aSelEng.SelMouseMove( rMEvt );
}
+void SvImpLBox::ExpandAll()
+{
+ sal_uInt16 nRefDepth = m_pTree->GetDepth(m_pCursor);
+ SvTreeListEntry* pCur = m_pTree->Next(m_pCursor);
+ while (pCur && m_pTree->GetDepth(pCur) > nRefDepth)
+ {
+ if (pCur->HasChildren() && !m_pView->IsExpanded(pCur))
+ m_pView->Expand(pCur);
+ pCur = m_pTree->Next(pCur);
+ }
+}
+
+void SvImpLBox::CollapseTo(SvTreeListEntry* pParentToCollapse)
+{
+ // collapse all parents until we get to the given parent to collapse
+ if (pParentToCollapse)
+ {
+ sal_uInt16 nRefDepth;
+ // special case explorer: if the root only has a single
+ // entry, don't collapse the root entry
+ if (m_pTree->GetChildList(nullptr).size() < 2)
+ {
+ nRefDepth = 1;
+ pParentToCollapse = m_pCursor;
+ while (m_pTree->GetParent(pParentToCollapse)
+ && m_pTree->GetDepth(m_pTree->GetParent(pParentToCollapse)) > 0)
+ {
+ pParentToCollapse = m_pTree->GetParent(pParentToCollapse);
+ }
+ }
+ else
+ nRefDepth = m_pTree->GetDepth(pParentToCollapse);
+
+ if (m_pView->IsExpanded(pParentToCollapse))
+ m_pView->Collapse(pParentToCollapse);
+ SvTreeListEntry* pCur = m_pTree->Next(pParentToCollapse);
+ while (pCur && m_pTree->GetDepth(pCur) > nRefDepth)
+ {
+ if (pCur->HasChildren() && m_pView->IsExpanded(pCur))
+ m_pView->Collapse(pCur);
+ pCur = m_pTree->Next(pCur);
+ }
+ }
+}
+
bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
{
m_aEditIdle.Stop();
@@ -2404,16 +2449,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
if (!m_pView->IsExpanded(m_pCursor))
m_pView->Expand(m_pCursor);
if (bMod1)
- {
- sal_uInt16 nRefDepth = m_pTree->GetDepth(m_pCursor);
- SvTreeListEntry* pCur = m_pTree->Next(m_pCursor);
- while (pCur && m_pTree->GetDepth(pCur) > nRefDepth)
- {
- if (pCur->HasChildren() && !m_pView->IsExpanded(pCur))
- m_pView->Expand(pCur);
- pCur = m_pTree->Next(pCur);
- }
- }
+ ExpandAll();
break;
case KEY_A:
@@ -2427,38 +2463,27 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
if (m_pView->IsExpanded(m_pCursor))
m_pView->Collapse(m_pCursor);
if (bMod1)
+ CollapseTo(m_pTree->GetRootLevelParent(m_pCursor));
+ break;
+
+ case KEY_MULTIPLY:
+ if( bMod1 )
{
- // collapse all parents until we get to the root
- SvTreeListEntry* pParentToCollapse = m_pTree->GetRootLevelParent(m_pCursor);
- if (pParentToCollapse)
+ // only try to expand/collapse if sublist is expandable,
+ // otherwise ignore the key press
+ if( IsExpandable() )
{
- sal_uInt16 nRefDepth;
- // special case explorer: if the root only has a single
- // entry, don't collapse the root entry
- if (m_pTree->GetChildList(nullptr).size() < 2)
+ if (!m_pView->IsExpanded(m_pCursor))
{
- nRefDepth = 1;
- pParentToCollapse = m_pCursor;
- while (m_pTree->GetParent(pParentToCollapse)
- && m_pTree->GetDepth(m_pTree->GetParent(pParentToCollapse)) > 0)
- {
- pParentToCollapse = m_pTree->GetParent(pParentToCollapse);
- }
+ m_pView->Expand(m_pCursor);
+ ExpandAll();
}
else
- nRefDepth = 0;
-
- if (m_pView->IsExpanded(pParentToCollapse))
- m_pView->Collapse(pParentToCollapse);
- SvTreeListEntry* pCur = m_pTree->Next(pParentToCollapse);
- while (pCur && m_pTree->GetDepth(pCur) > nRefDepth)
- {
- if (pCur->HasChildren() && m_pView->IsExpanded(pCur))
- m_pView->Collapse(pCur);
- pCur = m_pTree->Next(pCur);
- }
+ CollapseTo(m_pCursor);
}
}
+ else
+ bKeyUsed = false;
break;
case KEY_DIVIDE :
More information about the Libreoffice-commits
mailing list