tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / dbgui / PivotLayoutTreeListLabel.cxx
blobe4a2276dacee8e3bbddac2f64e0c9b28dd80f65c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
12 #include <memory>
13 #include <PivotLayoutTreeListLabel.hxx>
14 #include <PivotLayoutDialog.hxx>
16 #include <vcl/event.hxx>
17 #include <pivot.hxx>
19 ScPivotLayoutTreeListLabel::ScPivotLayoutTreeListLabel(std::unique_ptr<weld::TreeView> xControl)
20 : ScPivotLayoutTreeListBase(std::move(xControl), LABEL_LIST)
21 , maDataItem(0)
23 mxControl->connect_key_press(LINK(this, ScPivotLayoutTreeListLabel, KeyInputHdl));
26 ScPivotLayoutTreeListLabel::~ScPivotLayoutTreeListLabel()
29 void ScPivotLayoutTreeListLabel::FillLabelFields(ScDPLabelDataVector& rLabelVector)
31 mxControl->clear();
32 maItemValues.clear();
34 for (std::unique_ptr<ScDPLabelData> const & pLabelData : rLabelVector)
36 ScItemValue* pValue = new ScItemValue(pLabelData->maName, pLabelData->mnCol, pLabelData->mnFuncMask);
37 maItemValues.push_back(std::unique_ptr<ScItemValue>(pValue));
38 if (pLabelData->mbDataLayout)
40 maDataItem = maItemValues.size() - 1;
43 if (pLabelData->mnOriginalDim < 0 && !pLabelData->mbDataLayout)
45 mxControl->append(weld::toId(pValue), pLabelData->maName);
50 void ScPivotLayoutTreeListLabel::InsertEntryForSourceTarget(weld::TreeView& rSource, int /*nTarget*/)
52 if (&rSource == mxControl.get())
53 return;
54 rSource.remove(rSource.get_selected_index());
57 bool ScPivotLayoutTreeListLabel::IsDataElement(SCCOL nColumn)
59 return (nColumn == PIVOT_DATA_FIELD || nColumn == maDataItem);
62 ScItemValue* ScPivotLayoutTreeListLabel::GetItem(SCCOL nColumn)
64 if (nColumn == PIVOT_DATA_FIELD)
65 return maItemValues[maDataItem].get();
66 return maItemValues[nColumn].get();
69 IMPL_LINK(ScPivotLayoutTreeListLabel, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
71 vcl::KeyCode aCode = rKeyEvent.GetKeyCode();
72 sal_uInt16 nCode = aCode.GetCode();
74 if (nCode == KEY_DELETE)
76 int nEntry = mxControl->get_cursor_index();
77 if (nEntry != -1)
78 mxControl->remove(nEntry);
79 return true;
82 return false;
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */