diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-14 16:45:39 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-15 15:00:56 +0200 |
commit | 299e128b5175f4c3d794848ab51e81d14385a547 (patch) | |
tree | b2af5ebbd9c2692e121f0b6ba064d34bfef60a1a /vcl/source/window | |
parent | 0abbf64dc1ebe9f12523a69ce1cfd25fe189d869 (diff) |
replace TimeSpinButton with FormattedSpinButton
with a TimeFormatter rather than have duplicate functionality
Change-Id: I99f1f2aabee5f81485f97755ba3675870317cfb9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98791
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/window')
-rw-r--r-- | vcl/source/window/builder.cxx | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 368c4292fd06..6a02b7a9f86d 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -354,78 +354,6 @@ namespace weld return bRet; } - IMPL_LINK_NOARG(TimeSpinButton, spin_button_cursor_position, Entry&, void) - { - int nStartPos, nEndPos; - m_xSpinButton->get_selection_bounds(nStartPos, nEndPos); - - const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); - const int nTimeArea = ::TimeFormatter::GetTimeArea(m_eFormat, m_xSpinButton->get_text(), nEndPos, - rLocaleData); - - int nIncrements = 1; - - if (nTimeArea == 1) - nIncrements = 1000 * 60 * 60; - else if (nTimeArea == 2) - nIncrements = 1000 * 60; - else if (nTimeArea == 3) - nIncrements = 1000; - - m_xSpinButton->set_increments(nIncrements, nIncrements * 10); - } - - IMPL_LINK_NOARG(TimeSpinButton, spin_button_value_changed, SpinButton&, void) - { - signal_value_changed(); - } - - IMPL_LINK(TimeSpinButton, spin_button_output, SpinButton&, rSpinButton, void) - { - int nStartPos, nEndPos; - rSpinButton.get_selection_bounds(nStartPos, nEndPos); - rSpinButton.set_text(format_number(rSpinButton.get_value())); - rSpinButton.set_position(nEndPos); - } - - IMPL_LINK(TimeSpinButton, spin_button_input, int*, result, bool) - { - const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); - tools::Time aResult(0); - bool bRet = ::TimeFormatter::TextToTime(m_xSpinButton->get_text(), aResult, m_eFormat, true, rLocaleData); - if (bRet) - *result = ConvertValue(aResult); - return bRet; - } - - void TimeSpinButton::update_width_chars() - { - int min, max; - m_xSpinButton->get_range(min, max); - auto width = std::max(m_xSpinButton->get_pixel_size(format_number(min)).Width(), - m_xSpinButton->get_pixel_size(format_number(max)).Width()); - int chars = ceil(width / m_xSpinButton->get_approximate_digit_width()); - m_xSpinButton->set_width_chars(chars); - } - - tools::Time TimeSpinButton::ConvertValue(int nValue) - { - tools::Time aTime(0); - aTime.MakeTimeFromMS(nValue); - return aTime; - } - - int TimeSpinButton::ConvertValue(const tools::Time& rTime) - { - return rTime.GetMSFromTime(); - } - - OUString TimeSpinButton::format_number(int nValue) const - { - const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); - return ::TimeFormatter::FormatTime(ConvertValue(nValue), m_eFormat, TimeFormat::Hour24, true, rLocaleData); - } - EntryTreeView::EntryTreeView(std::unique_ptr<Entry> xEntry, std::unique_ptr<TreeView> xTreeView) : m_xEntry(std::move(xEntry)) , m_xTreeView(std::move(xTreeView)) |