<commit_before>#include "editor.hpp"
#include <QBoxLayout>
#include <QStatusBar>
#include <QMenuBar>
#include <QContextMenuEvent>

Editor::Editor(QWidget* parent)
{
	QWidget *widget = new QWidget;
	setCentralWidget(widget);

	QWidget *topFiller = new QWidget;
	topFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

	QWidget *bottomFiller = new QWidget;
	bottomFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

	QVBoxLayout *layout = new QVBoxLayout;
	layout->setMargin(5);
	layout->addWidget(topFiller);
	layout->addWidget(bottomFiller);
	widget->setLayout(layout);

	createActions();
	createMenus();

	QString message = tr("A context menu is available by right-clicking");
	statusBar()->showMessage(message);

	setMinimumSize(160, 160);

}

Editor::~Editor()
{
}

void Editor::Load(const std::string & archive)
{

}

void Editor::createActions()
{
	//FILE ACTIONS
	newAct = new QAction(tr("&New"), this);
	newAct->setShortcuts(QKeySequence::New);
	newAct->setStatusTip(tr("Create a new file"));
	connect(newAct, &QAction::triggered, this, &Editor::newFile);

	openAct = new QAction(tr("&Open"), this);
	openAct->setShortcuts(QKeySequence::Open);
	openAct->setStatusTip(tr("Open a new archive"));
	connect(openAct, &QAction::triggered, this, &Editor::open);

	saveAct = new QAction(tr("&Save"), this);
	saveAct->setShortcuts(QKeySequence::Save);
	saveAct->setStatusTip(tr("Save opened archive"));
	connect(saveAct, &QAction::triggered, this, &Editor::save);

	saveAsAct = new QAction(tr("Save&As"), this);
	saveAsAct->setShortcuts(QKeySequence::SaveAs);
	saveAsAct->setStatusTip(tr("Save opened archive"));
	connect(saveAsAct, &QAction::triggered, this, &Editor::saveAs);

	exitAct = new QAction(tr("&Exit"), this);
	exitAct->setShortcuts(QKeySequence::Quit);
	exitAct->setStatusTip(tr("Exit program"));
	connect(exitAct, &QAction::triggered, this, &Editor::exit);
	//EDIT ACTIONS
	undoAct = new QAction(tr("&Undo"), this);
	undoAct->setShortcuts(QKeySequence::Undo);
	undoAct->setStatusTip(tr("Undo last action"));
	connect(undoAct, &QAction::triggered, this, &Editor::undo);

	redoAct = new QAction(tr("&Redo"), this);
	redoAct->setShortcuts(QKeySequence::Redo);
	redoAct->setStatusTip(tr("Redo last action"));
	connect(redoAct, &QAction::triggered, this, &Editor::redo);

	cutAct = new QAction(tr("&Cut"), this);
	cutAct->setShortcuts(QKeySequence::Cut);
	cutAct->setStatusTip(tr("Cut selection"));
	connect(cutAct, &QAction::triggered, this, &Editor::cut);

	copyAct = new QAction(tr("&Copy"), this);
	copyAct->setShortcuts(QKeySequence::Copy);
	copyAct->setStatusTip(tr("Copy selection"));
	connect(copyAct, &QAction::triggered, this, &Editor::copy);

	pasteAct = new QAction(tr("&Paste"), this);
	pasteAct->setShortcuts(QKeySequence::Paste);
	pasteAct->setStatusTip(tr("Paste at cursor"));
	connect(pasteAct, &QAction::triggered, this, &Editor::paste);
	//ABOUT
	aboutAct = new QAction(tr("&About"), this);
	aboutAct->setStatusTip(tr("Info about this program"));
	connect(aboutAct, &QAction::triggered, this, &Editor::about);

	aboutQtAct = new QAction(tr("About &Qt"), this);
	aboutQtAct->setStatusTip(tr("Info about Qt"));
	connect(aboutQtAct, &QAction::triggered, this, &Editor::aboutQt);
}

void Editor::createMenus()
{
	fileMenu = menuBar()->addMenu(tr("&File"));
	fileMenu->addAction(newAct);
	fileMenu->addAction(openAct);
	fileMenu->addAction(saveAct);
	fileMenu->addAction(saveAsAct);
	fileMenu->addSeparator();
	fileMenu->addAction(exitAct);

	editMenu = menuBar()->addMenu(tr("&Edit"));
	editMenu->addAction(undoAct);
	editMenu->addAction(redoAct);
	editMenu->addSeparator();
	editMenu->addAction(cutAct);
	editMenu->addAction(copyAct);
	editMenu->addAction(pasteAct);
	editMenu->addSeparator();

	helpMenu = menuBar()->addMenu(tr("&Help"));
	helpMenu->addAction(aboutAct);
	helpMenu->addAction(aboutQtAct);
}

#ifndef QT_NO_CONTEXTMENU
void Editor::contextMenuEvent(QContextMenuEvent *event)
{
	QMenu menu(this);
	menu.addAction(cutAct);
	menu.addAction(copyAct);
	menu.addAction(pasteAct);
	menu.exec(event->globalPos());
}
#endif // QT_NO_CONTEXTMENU

void Editor::newFile()
{
}

void Editor::open()
{
	
}

void Editor::save()
{
}

void Editor::saveAs()
{
}

void Editor::undo()
{
}

void Editor::redo()
{
}

void Editor::cut()
{
}

void Editor::copy()
{<commit_msg>Added first file dialogs<commit_after>#include "editor.hpp"
#include <QBoxLayout>
#include <QStatusBar>
#include <QMenuBar>
#include <QFileDialog>
#include <QContextMenuEvent>

Editor::Editor(QWidget* parent)
{
	QWidget *widget = new QWidget;
	setCentralWidget(widget);

	QWidget *topFiller = new QWidget;
	topFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

	QWidget *bottomFiller = new QWidget;
	bottomFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

	QVBoxLayout *layout = new QVBoxLayout;
	layout->setMargin(5);
	layout->addWidget(topFiller);
	layout->addWidget(bottomFiller);
	widget->setLayout(layout);

	createActions();
	createMenus();

	QString message = tr("A context menu is available by right-clicking");
	statusBar()->showMessage(message);

	setMinimumSize(300, 200);

}

Editor::~Editor()
{
}

void Editor::Load(const std::string & archive)
{

}

void Editor::createActions()
{
	//FILE ACTIONS
	newAct = new QAction(tr("&New"), this);
	newAct->setShortcuts(QKeySequence::New);
	newAct->setStatusTip(tr("Create a new file"));
	connect(newAct, &QAction::triggered, this, &Editor::newFile);

	openAct = new QAction(tr("&Open"), this);
	openAct->setShortcuts(QKeySequence::Open);
	openAct->setStatusTip(tr("Open a new archive"));
	connect(openAct, &QAction::triggered, this, &Editor::open);

	saveAct = new QAction(tr("&Save"), this);
	saveAct->setShortcuts(QKeySequence::Save);
	saveAct->setStatusTip(tr("Save opened archive"));
	connect(saveAct, &QAction::triggered, this, &Editor::save);

	saveAsAct = new QAction(tr("Save&As"), this);
	saveAsAct->setShortcuts(QKeySequence::SaveAs);
	saveAsAct->setStatusTip(tr("Save opened archive"));
	connect(saveAsAct, &QAction::triggered, this, &Editor::saveAs);

	exitAct = new QAction(tr("&Exit"), this);
	exitAct->setShortcuts(QKeySequence::Quit);
	exitAct->setStatusTip(tr("Exit program"));
	connect(exitAct, &QAction::triggered, this, &Editor::exit);
	//EDIT ACTIONS
	undoAct = new QAction(tr("&Undo"), this);
	undoAct->setShortcuts(QKeySequence::Undo);
	undoAct->setStatusTip(tr("Undo last action"));
	connect(undoAct, &QAction::triggered, this, &Editor::undo);

	redoAct = new QAction(tr("&Redo"), this);
	redoAct->setShortcuts(QKeySequence::Redo);
	redoAct->setStatusTip(tr("Redo last action"));
	connect(redoAct, &QAction::triggered, this, &Editor::redo);

	cutAct = new QAction(tr("&Cut"), this);
	cutAct->setShortcuts(QKeySequence::Cut);
	cutAct->setStatusTip(tr("Cut selection"));
	connect(cutAct, &QAction::triggered, this, &Editor::cut);

	copyAct = new QAction(tr("&Copy"), this);
	copyAct->setShortcuts(QKeySequence::Copy);
	copyAct->setStatusTip(tr("Copy selection"));
	connect(copyAct, &QAction::triggered, this, &Editor::copy);

	pasteAct = new QAction(tr("&Paste"), this);
	pasteAct->setShortcuts(QKeySequence::Paste);
	pasteAct->setStatusTip(tr("Paste at cursor"));
	connect(pasteAct, &QAction::triggered, this, &Editor::paste);
	//ABOUT
	aboutAct = new QAction(tr("&About"), this);
	aboutAct->setStatusTip(tr("Info about this program"));
	connect(aboutAct, &QAction::triggered, this, &Editor::about);

	aboutQtAct = new QAction(tr("About &Qt"), this);
	aboutQtAct->setStatusTip(tr("Info about Qt"));
	connect(aboutQtAct, &QAction::triggered, this, &Editor::aboutQt);
}

void Editor::createMenus()
{
	fileMenu = menuBar()->addMenu(tr("&File"));
	fileMenu->addAction(newAct);
	fileMenu->addAction(openAct);
	fileMenu->addAction(saveAct);
	fileMenu->addAction(saveAsAct);
	fileMenu->addSeparator();
	fileMenu->addAction(exitAct);

	editMenu = menuBar()->addMenu(tr("&Edit"));
	editMenu->addAction(undoAct);
	editMenu->addAction(redoAct);
	editMenu->addSeparator();
	editMenu->addAction(cutAct);
	editMenu->addAction(copyAct);
	editMenu->addAction(pasteAct);
	editMenu->addSeparator();

	helpMenu = menuBar()->addMenu(tr("&Help"));
	helpMenu->addAction(aboutAct);
	helpMenu->addAction(aboutQtAct);
}

#ifndef QT_NO_CONTEXTMENU
void Editor::contextMenuEvent(QContextMenuEvent *event)
{
	QMenu menu(this);
	menu.addAction(cutAct);
	menu.addAction(copyAct);
	menu.addAction(pasteAct);
	menu.exec(event->globalPos());
}
#endif // QT_NO_CONTEXTMENU

void Editor::newFile()
{
}

void Editor::open()
{
	auto fileName = QFileDialog::getOpenFileName(this,
    tr("Open Archive"), "", tr("Big Files (*.big)"));
}

void Editor::save()
{
	auto fileName = QFileDialog::getSaveFileName(this,
    tr("Save Archive"), "", tr("Big Files (*.big)"));
}

void Editor::saveAs()
{
}

void Editor::undo()
{
}

void Editor::redo()
{
}

void Editor::cut()
{
}

void Editor::copy()
{
{'fraction_non_alphanumeric': 0.17984722534261963, 'fraction_numerical': 0.0015726802965625702, 'mean_word_length': 7.745579567779961, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 108, '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': '1972917', 'n_tokens_mistral': 3221, 'n_tokens_neox': 3135, 'n_words': 537}