<commit_before>#include <QWheelEvent>
#include <QtDebug>

#include "dacttreeview.h"

void DactTreeView::wheelEvent(QWheelEvent * event)
{
	// If the control modifier key isn't pressed, handle this wheel
	// even as any other event: pan the scene... probably.
	if (event->modifiers() != Qt::ControlModifier)
		return QGraphicsView::wheelEvent(event);
	
	// if it is not vertical scrolling, we ignore it.
	if (event->orientation() != Qt::Vertical)
		return;
	
	// according to the QWheelEvent docs
	qreal degree = event->delta() / 8; 
	
	// zoomFactor has to be something around 1.
	// NEVER BE ZERO OR YOU WILL RUIN THE MATRIX
	// Todo: adjust this formula. It works ok on my magic trackpad, but
	// I haven't tested it with a real mouse or anything.
	// Todo: maybe use the ZOOM_IN_FACTOR and ZOOM_OUT_FACTOR constants
	//qreal zoomFactor = 1.0 + degree / 360;
	
	qreal zoomFactor = 1.0 + degree / 180;
	
	if (zoomFactor > 2.0)
		zoomFactor = 2.0;
	else if (zoomFactor <= 0.0)
		zoomFactor = 0.1;
	
	// Todo: zoom in on the position on the mouse, like Google maps does.
	scale(zoomFactor, zoomFactor);
}<commit_msg>Zoom in at the position of the mouse cursor.<commit_after>#include <QWheelEvent>
#include <QtDebug>

#include "dacttreeview.h"

void DactTreeView::wheelEvent(QWheelEvent * event)
{
	// If the control modifier key isn't pressed, handle this wheel
	// even as any other event: pan the scene... probably.
	if (event->modifiers() != Qt::ControlModifier)
		return QGraphicsView::wheelEvent(event);
	
	// if it is not vertical scrolling, we ignore it.
	if (event->orientation() != Qt::Vertical)
		return;
	
	// according to the QWheelEvent docs
	qreal degree = event->delta() / 8; 
	
	// zoomFactor has to be something around 1.
	// NEVER BE ZERO OR YOU WILL RUIN THE MATRIX
	// Todo: adjust this formula. It works ok on my magic trackpad, but
	// I haven't tested it with a real mouse or anything.
	// Todo: maybe use the ZOOM_IN_FACTOR and ZOOM_OUT_FACTOR constants
	//qreal zoomFactor = 1.0 + degree / 360;
	
	qreal zoomFactor = 1.0 + degree / 180;
	
	if (zoomFactor > 2.0)
		zoomFactor = 2.0;
	else if (zoomFactor <= 0.0)
		zoomFactor = 0.1;
	
	// TODO: some kind of limit which prevents zooming in or out too far.
	// because being able to do that is silly.
	
	// Zoom in on position of the mouse (like Google Maps)
	setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
	scale(zoomFactor, zoomFactor);
	
	event->accept();
}
{'fraction_non_alphanumeric': 0.1076986076986077, 'fraction_numerical': 0.01638001638001638, 'mean_word_length': 3.507380073800738, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, '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': '5750141', 'n_tokens_mistral': 866, 'n_tokens_neox': 781, 'n_words': 302}