summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-11-26 14:05:56 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-11-26 21:11:48 +0100
commitc8afb4000f178badaf63c2f38fd3fbc12ec832f3 (patch)
tree65bb8d7e673e80635bd3adc27c608ad8a90336b6 /vcl
parentb1e73fd49661e07e6085310f3f6ecc6ade2a3762 (diff)
tdf#129037 add a way to select multiple entries of a ListBox together
Change-Id: I362a9e9e644e15f0dd3aeb691973a0979d17eeb0 Reviewed-on: https://gerrit.libreoffice.org/83771 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/listbox.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index 2de9f387011a..a93a9e52dde4 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -1071,6 +1071,36 @@ void ListBox::SelectEntryPos( sal_Int32 nPos, bool bSelect )
}
}
+void ListBox::SelectEntriesPos( const std::vector<sal_Int32>& rPositions, bool bSelect )
+{
+ if (!mpImplLB)
+ return;
+
+ bool bCallListeners = false;
+
+ const sal_Int32 nCurrentPos = mpImplLB->GetCurrentPos();
+ const auto nEntryCount = mpImplLB->GetEntryList()->GetEntryCount();
+ const auto nMRUCount = mpImplLB->GetEntryList()->GetMRUCount();
+
+ for (auto nPos : rPositions)
+ {
+ if (0 <= nPos && nPos < nEntryCount)
+ {
+ mpImplLB->SelectEntry(nPos + nMRUCount, bSelect);
+ if (nCurrentPos != nPos && bSelect)
+ bCallListeners = true;
+ }
+ }
+
+ //Only when bSelect == true, send both Selection & Focus events
+ if (bCallListeners)
+ {
+ CallEventListeners(VclEventId::ListboxSelect);
+ if (HasFocus())
+ CallEventListeners(VclEventId::ListboxFocus);
+ }
+}
+
void ListBox::SetEntryData( sal_Int32 nPos, void* pNewData )
{
mpImplLB->SetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount(), pNewData );