<commit_before>#include "functions.h"
#include "filenamewindow.h"
#include "ui_filenamewindow.h"
#include "image.h"

FilenameWindow::FilenameWindow(QString value, QWidget *parent) : QDialog(parent), ui(new Ui::FilenameWindow)
{
	ui->setupUi(this);

	#if USE_QSCINTILLA
		m_scintilla = new QsciScintilla(this);
		QsciLexerJavaScript *lexer = new QsciLexerJavaScript(this);
		m_scintilla->setLexer(lexer);
	#else
		m_scintilla = new QTextEdit(this);
	#endif

	connect(ui->radioJavascript, SIGNAL(toggled(bool)), m_scintilla, SLOT(setEnabled(bool)));
	ui->verticalLayout->insertWidget(ui->verticalLayout->count() - 1, m_scintilla);

	if (value.startsWith("javascript:"))
	{
		value = value.right(value.length() - 11);
		m_scintilla->setText(value);
		ui->lineClassic->setEnabled(false);
		ui->radioJavascript->toggle();
	}
	else
	{
		ui->lineClassic->setText(value);
		m_scintilla->setEnabled(false);
		ui->radioClassic->toggle();
	}

	connect(this, &QDialog::accepted, this, &FilenameWindow::send);
}

FilenameWindow::~FilenameWindow()
{
	delete ui;
}

void FilenameWindow::on_lineClassic_textChanged(QString text)
{
	ui->labelValidator->setText(validateFilename(text));

	QRegExp date("%date:([^%]+)%");
	int pos = 0;
	text = text.replace("\\", "\\\\").replace("'", "\\'");

	while ((pos = date.indexIn(text, pos)) != -1)
	{
		QString cap = date.cap(1);
		QString format = "";
		for (int i = 0; i < cap.length(); ++i)
		{
			QChar c = cap.at(i);
			if (c == "Y")
			{ format += "' + date.getFullYear() + '"; }
			else if (c == "M")
			{ format += "' + date.getMonth() + '"; }
			else if (c == "d")
			{ format += "' + date.getDate() + '"; }
			else if (c == "h")
			{ format += "' + date.getHours() + '"; }
			else if (c == "m")
			{ format += "' + date.getMinutes() + '"; }
			else if (c == "s")
			{ format += "' + date.getSeconds() + '"; }
			else
			{ format += c; }
		}

		text = text.left(pos) + format + text.mid(pos + date.matchedLength());
		pos += date.matchedLength();
	}

	QString value = "'"+text.replace(QRegExp("%([^%]+)%"), "' + \\1 + '").remove(" + '' + ").trimmed()+"'";
	if (value.startsWith("' + "))
	{ value = value.right(value.length() - 4); }
	if (value.startsWith("'' + "))
	{ value = value.right(value.length() - 5); }
	if (value.endsWith(" + '"))
	{ value = value.left(value.length() - 4); }
	if (value.endsWith(" + ''"))
	{ value = value.left(value.length() - 5); }

	m_scintilla->setText(value);
}<commit_msg>Fix compilation error included by commit 3dd8632<commit_after>#include "functions.h"
#include "filenamewindow.h"
#include "ui_filenamewindow.h"
#include "image.h"

FilenameWindow::FilenameWindow(QString value, QWidget *parent) : QDialog(parent), ui(new Ui::FilenameWindow)
{
	ui->setupUi(this);

	#if USE_QSCINTILLA
		m_scintilla = new QsciScintilla(this);
		QsciLexerJavaScript *lexer = new QsciLexerJavaScript(this);
		m_scintilla->setLexer(lexer);
	#else
		m_scintilla = new QTextEdit(this);
	#endif

	connect(ui->radioJavascript, SIGNAL(toggled(bool)), m_scintilla, SLOT(setEnabled(bool)));
	ui->verticalLayout->insertWidget(ui->verticalLayout->count() - 1, m_scintilla);

	if (value.startsWith("javascript:"))
	{
		value = value.right(value.length() - 11);
		m_scintilla->setText(value);
		ui->lineClassic->setEnabled(false);
		ui->radioJavascript->toggle();
	}
	else
	{
		ui->lineClassic->setText(value);
		m_scintilla->setEnabled(false);
		ui->radioClassic->toggle();
	}

	connect(this, &QDialog::accepted, this, &FilenameWindow::send);
}

FilenameWindow::~FilenameWindow()
{
	delete ui;
}

void FilenameWindow::on_lineClassic_textChanged(QString text)
{
	ui->labelValidator->setText(validateFilename(text));

	QRegExp date("%date:([^%]+)%");
	int pos = 0;
	text = text.replace("\\", "\\\\").replace("'", "\\'");

	while ((pos = date.indexIn(text, pos)) != -1)
	{
		QString cap = date.cap(1);
		QString format = "";
		for (int i = 0; i < cap.length(); ++i)
		{
			QChar c = cap.at(i);
			if (c == 'Y')
			{ format += "' + date.getFullYear() + '"; }
			else if (c == 'M')
			{ format += "' + date.getMonth() + '"; }
			else if (c == 'd')
			{ format += "' + date.getDate() + '"; }
			else if (c == 'h')
			{ format += "' + date.getHours() + '"; }
			else if (c == 'm')
			{ format += "' + date.getMinutes() + '"; }
			else if (c == 's')
			{ format += "' + date.getSeconds() + '"; }
			else
			{ format += c; }
		}

		text = text.left(pos) + format + text.mid(pos + date.matchedLength());
		pos += date.matchedLength();
	}

	QString value = "'"+text.replace(QRegExp("%([^%]+)%"), "' + \\1 + '").remove(" + '' + ").trimmed()+"'";
	if (value.startsWith("' + "))
	{ value = value.right(value.length() - 4); }
	if (value.startsWith("'' + "))
	{ value = value.right(value.length() - 5); }
	if (value.endsWith(" + '"))
	{ value = value.left(value.length() - 4); }
	if (value.endsWith(" + ''"))
	{ value = value.left(value.length() - 5); }

	m_scintilla->setText(value);
}
{'fraction_non_alphanumeric': 0.22457713470552274, 'fraction_numerical': 0.005909924597513756, 'mean_word_length': 4.0965732087227416, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '1972365', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1852, 'n_words': 328}