tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / dbgui / sortkeydlg.cxx
blobc4c4e72d6b22975ccd1df6582a24472c4bb5b2cc
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/.
8 */
10 #include <memory>
11 #include <sortkeydlg.hxx>
12 #include <comphelper/lok.hxx>
13 #include <vcl/svapp.hxx>
15 #include <scresid.hxx>
16 #include <strings.hrc>
18 ScSortKeyItem::ScSortKeyItem(weld::Container* pParent)
19 : m_xBuilder(Application::CreateBuilder(pParent, u"modules/scalc/ui/sortkey.ui"_ustr))
20 , m_xFrame(m_xBuilder->weld_frame(u"SortKeyFrame"_ustr))
21 , m_xLbSort(m_xBuilder->weld_combo_box(u"sortlb"_ustr))
22 , m_xBtnUp(m_xBuilder->weld_radio_button(u"up"_ustr))
23 , m_xBtnDown(m_xBuilder->weld_radio_button(u"down"_ustr))
24 , m_xLabel(m_xBuilder->weld_label(u"lbColRow"_ustr))
25 , m_pParent(pParent)
27 // tdf#136155 let the other elements in the dialog determine the width of the
28 // combobox
29 m_xLbSort->set_size_request(m_xLbSort->get_approximate_digit_width() * 12, -1);
30 // keep the UI static when switching the labels
31 const sal_Int32 nChars = std::max( ScResId(SCSTR_COLUMN).getLength(), ScResId(SCSTR_ROW).getLength() ) + 2; // +2 to avoid cut-off labels on kf5/gen
32 m_xLabel->set_size_request( m_xLabel->get_approximate_digit_width() * nChars, -1);
35 ScSortKeyItem::~ScSortKeyItem()
37 m_pParent->move(m_xFrame.get(), nullptr);
40 void ScSortKeyItem::DisableField()
42 m_xFrame->set_sensitive(false);
45 void ScSortKeyItem::EnableField()
47 m_xFrame->set_sensitive(true);
50 ScSortKeyWindow::ScSortKeyWindow(weld::Container* pBox)
51 : m_pBox(pBox)
55 ScSortKeyWindow::~ScSortKeyWindow()
59 void ScSortKeyWindow::AddSortKey( sal_uInt16 nItemNumber )
61 ScSortKeyItem* pSortKeyItem = new ScSortKeyItem(m_pBox);
63 // Set Sort key number
64 OUString aLine = pSortKeyItem->m_xFrame->get_label() +
65 OUString::number( nItemNumber );
66 pSortKeyItem->m_xFrame->set_label(aLine);
68 // for ui-testing. Distinguish the sort keys
69 if (!comphelper::LibreOfficeKit::isActive())
71 if ( m_aSortKeyItems.size() > 0 )
73 pSortKeyItem->m_xLbSort->set_buildable_name(
74 pSortKeyItem->m_xLbSort->get_buildable_name() + OUString::number(m_aSortKeyItems.size() + 1));
78 m_aSortKeyItems.push_back(std::unique_ptr<ScSortKeyItem>(pSortKeyItem));
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */