tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / miscdlgs / gototabdlg.cxx
blob078f24f251805a9d70d091e59d0e871ec11a50a2
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 */
11 #undef SC_DLLIMPLEMENTATION
13 #include <gototabdlg.hxx>
15 ScGoToTabDlg::ScGoToTabDlg(weld::Window* pParent)
16 : GenericDialogController(pParent, u"modules/scalc/ui/gotosheetdialog.ui"_ustr,
17 u"GoToSheetDialog"_ustr)
18 , m_xFrameMask(m_xBuilder->weld_frame(u"frame-mask"_ustr))
19 , m_xEnNameMask(m_xBuilder->weld_entry(u"entry-mask"_ustr))
20 , m_xFrameSheets(m_xBuilder->weld_frame(u"frame-sheets"_ustr))
21 , m_xLb(m_xBuilder->weld_tree_view(u"treeview"_ustr))
23 m_xLb->set_selection_mode(SelectionMode::Single);
24 m_xLb->set_size_request(-1, m_xLb->get_height_rows(10));
25 m_xLb->connect_row_activated(LINK(this, ScGoToTabDlg, DblClkHdl));
26 m_xEnNameMask->connect_changed(LINK(this, ScGoToTabDlg, FindNameHdl));
29 ScGoToTabDlg::~ScGoToTabDlg() {}
31 void ScGoToTabDlg::SetDescription(const OUString& rTitle, const OUString& rEntryLabel,
32 const OUString& rListLabel, const OUString& rDlgHelpId,
33 const OUString& rEnHelpId, const OUString& rLbHelpId)
35 m_xDialog->set_title(rTitle);
36 m_xFrameMask->set_label(rEntryLabel);
37 m_xFrameSheets->set_label(rListLabel);
38 m_xDialog->set_help_id(rDlgHelpId);
39 m_xEnNameMask->set_help_id(rEnHelpId);
40 m_xLb->set_help_id(rLbHelpId);
43 void ScGoToTabDlg::Insert(const OUString& rString, bool bSelected)
45 maCacheSheetsNames.push_back(rString);
46 m_xLb->append_text(rString);
47 if (bSelected)
48 m_xLb->select(m_xLb->n_children() - 1);
51 OUString ScGoToTabDlg::GetSelectedEntry() const { return m_xLb->get_selected_text(); }
53 IMPL_LINK_NOARG(ScGoToTabDlg, DblClkHdl, weld::TreeView&, bool)
55 m_xDialog->response(RET_OK);
56 return true;
59 IMPL_LINK_NOARG(ScGoToTabDlg, FindNameHdl, weld::Entry&, void)
61 const OUString aMask = m_xEnNameMask->get_text();
62 m_xLb->clear();
63 if (aMask.isEmpty())
65 for (const OUString& s : maCacheSheetsNames)
67 m_xLb->append_text(s);
70 else
72 for (const OUString& s : maCacheSheetsNames)
74 if (s.indexOf(aMask) >= 0)
76 m_xLb->append_text(s);
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */