<commit_before>#include <ui/tag_scroll_view.h>

#include <QWheelEvent>
#include <QScrollBar>

TagScrollView::TagScrollView(
        QWidget* parent
    ) : QScrollArea( parent ), scale_factor_( 1. )
{
    setBackgroundRole( QPalette::Dark );
    setAutoFillBackground( true );
}

TagScrollView::~TagScrollView()
{
}

void TagScrollView::zoom_in()
{
    // safeguard
    if( scale_factor_ > 10. ) {
        return;
    }

    scale_by( 1.25 );
}

void TagScrollView::zoom_out()
{
    // safeguard
    if( scale_factor_ < 0.05 ) {
        return;
    }

    scale_by( 0.8 ); // = 1 / 1.25
}

void TagScrollView::fit_to_view()
{
    widget()->adjustSize();
}

void TagScrollView::scale_by(
        float factor
    )
{
    if( factor <= 0. ) {<commit_msg>implement image fit to scroll view<commit_after>#include <ui/tag_scroll_view.h>

#include <QWheelEvent>
#include <QScrollBar>

TagScrollView::TagScrollView(
        QWidget* parent
    ) : QScrollArea( parent ), scale_factor_( 1. )
{
    setBackgroundRole( QPalette::Dark );
    setAutoFillBackground( true );
}

TagScrollView::~TagScrollView()
{
}

void TagScrollView::zoom_in()
{
    // safeguard
    if( scale_factor_ > 10. ) {
        return;
    }

    scale_by( 1.25 );
}

void TagScrollView::zoom_out()
{
    // safeguard
    if( scale_factor_ < 0.05 ) {
        return;
    }

    scale_by( 0.8 ); // = 1 / 1.25
}

void TagScrollView::fit_to_view()
{
    QSize widget_size = widget()->size();
    widget_size.scale( size(), Qt::KeepAspectRatio );
    widget()->resize( widget_size );
}

void TagScrollView::scale_by(
        float factor
    )
{
    if( factor <= 0. ) {
{'fraction_non_alphanumeric': 0.14539877300613496, 'fraction_numerical': 0.0196319018404908, 'mean_word_length': 2.8833333333333333, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3190512', 'n_tokens_mistral': 616, 'n_tokens_neox': 582, 'n_words': 108}