<commit_before>#include <QTabBar>
#include "qclosabletabwidget.h"


QClosableTabWidget::QClosableTabWidget(QWidget *parent)
	: QTabWidget(parent)
{
	tabBar()->installEventFilter(this);
}

bool QClosableTabWidget::eventFilter(QObject *o, QEvent *e)
{
	if (o == tabBar() && e->type() == QEvent::MouseButtonPress)
	{
		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(e);
		if (mouseEvent->button() == Qt::MiddleButton)
		{
			int index = tabBar()->tabAt(mouseEvent->pos());
			widget(index)->deleteLater();
			removeTab(index);
			return true;
		}
	}

	return QTabWidget::eventFilter(o, e);
}
<commit_msg>Disable middle click close for unclosable tabs<commit_after>#include <QTabBar>
#include "qclosabletabwidget.h"


QClosableTabWidget::QClosableTabWidget(QWidget *parent)
	: QTabWidget(parent)
{
	tabBar()->installEventFilter(this);
}

bool QClosableTabWidget::eventFilter(QObject *o, QEvent *e)
{
	if (o == tabBar() && e->type() == QEvent::MouseButtonPress)
	{
		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(e);
		if (mouseEvent->button() == Qt::MiddleButton)
		{
			int index = tabBar()->tabAt(mouseEvent->pos());
			QWidget *w = widget(index);

			// Unclosable tabs have a maximum width of 16777214 (default: 16777215)
			if (w->maximumWidth() != 16777214)
			{
				w->deleteLater();
				removeTab(index);
				return true;
			}
		}
	}

	return QTabWidget::eventFilter(o, e);
}

{'fraction_non_alphanumeric': 0.16080402010050251, 'fraction_numerical': 0.01722900215362527, 'mean_word_length': 5.223214285714286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 20, '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': '751127', 'n_tokens_mistral': 567, 'n_tokens_neox': 502, 'n_words': 92}