<commit_before>#include <QFile>
#include <QFileDialog>
#include <QFuture>
#include <QGraphicsSvgItem>
#include <QGraphicsScene>
#include <QHash>
#include <QLineEdit>
#include <QList>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QPainter>
#include <QPoint>
#include <QPrintDialog>
#include <QPrinter>
#include <QSettings>
#include <QSize>
#include <QString>
#include <QStringList>
#include <QSvgRenderer>
#include <QTextStream>
#include <Qt>
#include <QtConcurrentRun>
#include <QtDebug>

#include <cstdlib>
#include <stdexcept>
#include <string>
#include <sstream>
#include <vector>

#include <AlpinoCorpus/CorpusReader.hh>

#include "DactMainWindow.h"
#include "DactFilterWindow.h"
#include "XPathValidator.hh"
#include "XSLTransformer.hh"
#include "ui_DactMainWindow.h"

using namespace alpinocorpus;
using namespace std;

DactMainWindow::DactMainWindow(QWidget *parent) :
    QMainWindow(parent),
    d_ui(QSharedPointer<Ui::DactMainWindow>(new Ui::DactMainWindow)),
    d_dactHelpWindow(new DactHelpWindow(this, Qt::Window)),
    d_filterWindow(0),
    d_queryWindow(0),
    d_macrosWindow(0),
    d_xpathValidator(new XPathValidator)
{
    d_ui->setupUi(this);
    d_ui->filterLineEdit->setValidator(d_xpathValidator.data());
    d_ui->queryLineEdit->setValidator(d_xpathValidator.data());
    readSettings();
    createTransformers();
    createActions();
}

DactMainWindow::DactMainWindow(const QString &corpusPath, QWidget *parent) :
    QMainWindow(parent),
    d_ui(new Ui::DactMainWindow),
    d_dactHelpWindow(new DactHelpWindow(this, Qt::Window)),
    d_filterWindow(0),
    d_queryWindow(0),
    d_macrosWindow(0),
    d_xpathValidator(new XPathValidator)
{
    d_ui->setupUi(this);
    d_ui->filterLineEdit->setValidator(d_xpathValidator.data());
    d_ui->queryLineEdit->setValidator(&*d_xpathValidator);
    readSettings();
    createTransformers();
    d_corpusPath = corpusPath;

    this->setWindowTitle(QString("Dact - %1").arg(corpusPath));
    createActions();

    d_corpusReader = QSharedPointer<CorpusReader>(
        CorpusReader::newCorpusReader(d_corpusPath));

    addFiles();
}

DactMainWindow::~DactMainWindow()
{
}

void DactMainWindow::aboutDialog()
{
    QMessageBox::about(this, "About Dact", "Please report bugs at: http://github.com/danieldk/dact");
}

void DactMainWindow::addFiles()<commit_msg>When quitting when a filter is still running, wait until the filter is done.<commit_after>#include <QFile>
#include <QFileDialog>
#include <QFuture>
#include <QGraphicsSvgItem>
#include <QGraphicsScene>
#include <QHash>
#include <QLineEdit>
#include <QList>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QPainter>
#include <QPoint>
#include <QPrintDialog>
#include <QPrinter>
#include <QSettings>
#include <QSize>
#include <QString>
#include <QStringList>
#include <QSvgRenderer>
#include <QTextStream>
#include <Qt>
#include <QtConcurrentRun>
#include <QtDebug>

#include <cstdlib>
#include <stdexcept>
#include <string>
#include <sstream>
#include <vector>

#include <AlpinoCorpus/CorpusReader.hh>

#include "DactMainWindow.h"
#include "DactFilterWindow.h"
#include "XPathValidator.hh"
#include "XSLTransformer.hh"
#include "ui_DactMainWindow.h"

using namespace alpinocorpus;
using namespace std;

DactMainWindow::DactMainWindow(QWidget *parent) :
    QMainWindow(parent),
    d_ui(QSharedPointer<Ui::DactMainWindow>(new Ui::DactMainWindow)),
    d_dactHelpWindow(new DactHelpWindow(this, Qt::Window)),
    d_filterWindow(0),
    d_queryWindow(0),
    d_macrosWindow(0),
    d_xpathValidator(new XPathValidator)
{
    d_ui->setupUi(this);
    d_ui->filterLineEdit->setValidator(d_xpathValidator.data());
    d_ui->queryLineEdit->setValidator(d_xpathValidator.data());
    readSettings();
    createTransformers();
    createActions();
}

DactMainWindow::DactMainWindow(const QString &corpusPath, QWidget *parent) :
    QMainWindow(parent),
    d_ui(new Ui::DactMainWindow),
    d_dactHelpWindow(new DactHelpWindow(this, Qt::Window)),
    d_filterWindow(0),
    d_queryWindow(0),
    d_macrosWindow(0),
    d_xpathValidator(new XPathValidator)
{
    d_ui->setupUi(this);
    d_ui->filterLineEdit->setValidator(d_xpathValidator.data());
    d_ui->queryLineEdit->setValidator(&*d_xpathValidator);
    readSettings();
    createTransformers();
    d_corpusPath = corpusPath;

    this->setWindowTitle(QString("Dact - %1").arg(corpusPath));
    createActions();

    d_corpusReader = QSharedPointer<CorpusReader>(
        CorpusReader::newCorpusReader(d_corpusPath));

    addFiles();
}

DactMainWindow::~DactMainWindow()
{
    if (d_xpathFilterResult.isRunning())
        d_xpathFilterResult.waitForFinished();
}

void DactMainWindow::aboutDialog()
{
    QMessageBox::about(this, "About Dact", "Please report bugs at: http://github.com/danieldk/dact");
}

void DactMainWindow::addFiles()
{'fraction_non_alphanumeric': 0.1354918539905135, 'fraction_numerical': 0.0028871932357187047, 'mean_word_length': 6.217261904761905, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 87, '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': '2633206', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1695, 'n_words': 287}