<commit_before>#include "scientisttabledialog.h"
#include "ui_scientisttabledialog.h"

ScientistTableDialog::ScientistTableDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ScientistTableDialog)
{
    // Fjarlægir '?' hjálp takkann
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    ui->setupUi(this);
    displayAllScientists();
   // on_ScientistSearch_textChanged(); <- þarf ekki
}

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

void ScientistTableDialog::displayAllScientists()
{
    vector<Scientist> scientists = scientistService.getScientists();
    ui->ScientistTable->setRowCount(scientists.size());

    qDebug() << scientists.size() << endl;

    for(unsigned int i = 0; i < scientists.size(); i++)
    {
       ui->ScientistTable->setItem(i, 0, new QTableWidgetItem(QString::fromStdString(scientists[i].getName())));
       ui->ScientistTable->setItem(i, 1, new QTableWidgetItem(QString::fromStdString(scientists[i].getGender())));
       ui->ScientistTable->setItem(i, 2, new QTableWidgetItem(QString::number(scientists[i].getDateOfBirth())));
       ui->ScientistTable->setItem(i, 3, new QTableWidgetItem(QString::number(scientists[i].getDateOfDeath())));

    }
}

void ScientistTableDialog::displayScientists(vector<Scientist> scientists)
{
    ui->ScientistTable->clearContents();


    for(unsigned int i = 0; i < scientists.size(); i++)
    {
        ui->ScientistTable->setItem(i, 0, new QTableWidgetItem(QString::fromStdString(scientists[i].getName())));
        ui->ScientistTable->setItem(i, 1, new QTableWidgetItem(QString::fromStdString(scientists[i].getGender())));
        ui->ScientistTable->setItem(i, 2, new QTableWidgetItem(QString::number(scientists[i].getDateOfBirth())));
        ui->ScientistTable->setItem(i, 3, new QTableWidgetItem(QString::number(scientists[i].getDateOfDeath())));
        if(scientists[i].getDateOfDeath() == 0)
            ui->ScientistTable->setItem(i, 3, new QTableWidgetItem("Alive"));
        else
            ui->ScientistTable->setItem(i, 3, new QTableWidgetItem(QString::number(scientists[i].getDateOfDeath())));
    }

}

void ScientistTableDialog::on_AddANewScientist_clicked()
{
    AddScientistDialog addScientistDialog(this);
    int addScientistReturnValue = addScientistDialog.exec();
}

void ScientistTableDialog::on_ScientistSearch_textChanged()
{
    string input = ui->ScientistSearch->text().toStdString();

    vector<Scientist> scientists = scientistService.searchName(input);
    displayScientists(scientists);
}

void ScientistTableDialog::on_editDelete_clicked()
{
    EditDeletScientist editDeletScientist(this);
    editDeletScientist.exec();
}<commit_msg>alive<commit_after>#include "scientisttabledialog.h"
#include "ui_scientisttabledialog.h"

ScientistTableDialog::ScientistTableDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ScientistTableDialog)
{
    // Fjarlægir '?' hjálp takkann
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    ui->setupUi(this);
    displayAllScientists();
}

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

void ScientistTableDialog::displayAllScientists()
{
    vector<Scientist> scientists = scientistService.getScientists();
    ui->ScientistTable->setRowCount(scientists.size());

    qDebug() << scientists.size() << endl;

    for(unsigned int i = 0; i < scientists.size(); i++)
    {
        ui->ScientistTable->setItem(i, 0, new QTableWidgetItem(QString::fromStdString(scientists[i].getName())));
        ui->ScientistTable->setItem(i, 1, new QTableWidgetItem(QString::fromStdString(scientists[i].getGender())));
        ui->ScientistTable->setItem(i, 2, new QTableWidgetItem(QString::number(scientists[i].getDateOfBirth())));
        if(scientists[i].getDateOfDeath() == 0)
            ui->ScientistTable->setItem(i, 3, new QTableWidgetItem("Alive"));
        else
            ui->ScientistTable->setItem(i, 3, new QTableWidgetItem(QString::number(scientists[i].getDateOfDeath())));
    }
}

void ScientistTableDialog::displayScientists(vector<Scientist> scientists)
{
    ui->ScientistTable->clearContents();


    for(unsigned int i = 0; i < scientists.size(); i++)
    {
        ui->ScientistTable->setItem(i, 0, new QTableWidgetItem(QString::fromStdString(scientists[i].getName())));
        ui->ScientistTable->setItem(i, 1, new QTableWidgetItem(QString::fromStdString(scientists[i].getGender())));
        ui->ScientistTable->setItem(i, 2, new QTableWidgetItem(QString::number(scientists[i].getDateOfBirth())));
        if(scientists[i].getDateOfDeath() == 0)
            ui->ScientistTable->setItem(i, 3, new QTableWidgetItem("Alive"));
        else
            ui->ScientistTable->setItem(i, 3, new QTableWidgetItem(QString::number(scientists[i].getDateOfDeath())));
    }

}

void ScientistTableDialog::on_AddANewScientist_clicked()
{
    AddScientistDialog addScientistDialog(this);
    int addScientistReturnValue = addScientistDialog.exec();
}

void ScientistTableDialog::on_ScientistSearch_textChanged()
{
    string input = ui->ScientistSearch->text().toStdString();

    vector<Scientist> scientists = scientistService.searchName(input);
    displayScientists(scientists);
}

void ScientistTableDialog::on_editDelete_clicked()
{
    EditDeletScientist editDeletScientist(this);
    editDeletScientist.exec();
}
{'fraction_non_alphanumeric': 0.14568177578809924, 'fraction_numerical': 0.005036373810856184, 'mean_word_length': 5.315665488810365, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 63, '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': '3421642', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1693, 'n_words': 226}