<commit_before>#include "DBManager.h"
#include "HouseManager.h"

HouseManager* HouseManager::m_pInstance = nullptr;

HouseManager*
HouseManager::instance()
{
    if(m_pInstance == nullptr){
        m_pInstance = new HouseManager();

        // TODO ???
    }

    return m_pInstance;
}

HouseManager::~HouseManager()
{
    // TODO ???
    while(!m_Houses.isEmpty()){
        House* currentHouse = m_Houses.front();
        m_Houses.pop_front();
        if(currentHouse != nullptr)
            delete currentHouse;
    }
}

void
HouseManager::reloadFromDatabase()
{
    // TODO
}

void
HouseManager::saveToDatabase()
{
    // TODO
}

HouseManager::HouseManager()
{
    // TODO
    addDefaultData();
}

HouseManager::HouseManager(const HouseManager& hm)
{
    Q_UNUSED(hm)
}

void
HouseManager::addDefaultData()
{
    PriestInfo* pi = createPriestInfo();
    if(pi != nullptr){
        pi->setFirstName("Eufigeniu");
        pi->setLastName("Agamemnon");
    }

    County* county = createCounty();
    if(county != nullptr){
        county->setName("Sibiu");
    }

    Deanery* dioceza = createDeanery();
    if(dioceza != nullptr){
        dioceza->setName("<NAME>");
    }

    Locality* loc = createLocality();
    if(loc != nullptr){
        LocalizedName locName;
        locName[DBManager::instance()->findLanguage(QString("Romanian"))->Id()] = "Sat Test";
        locName[DBManager::instance()->findLanguage(QString("German"))->Id()] = "Test Dorf";
        locName[DBManager::instance()->findLanguage(QString("Hungarian"))->Id()] = "Test Falu";
        locName[DBManager::instance()->findLanguage(QString("Saxon"))->Id()] = "Test Dorfen";
        loc->setName(locName);
        if(county != nullptr){
            loc->setCounty(county->Id());
        }
    }

    Shire* shire = createShire();
    if(shire != nullptr){
        shire->setName("Testenshire");
    }

    TaxInfo* ti = createTaxInfo();
    if(ti != nullptr){
        ti->setDescription("Taxa pe smen");
        ti->setName("SmenTax");
        ti->setFormula("Se ia valoarea S de smen si se inmulteste cu valoarea V de valoare. Rezultatul se varsa la buget.");
    }

    auto ii = createImageInfo();
    if(ii != nullptr){
        ii->setName("Test image");
        ii->setDetails("Aceasta poza reprezinta un detaliu al smenurilor");<commit_msg>fixed crash (missing null pointer check)<commit_after>#include "DBManager.h"
#include "HouseManager.h"

HouseManager* HouseManager::m_pInstance = nullptr;

HouseManager*
HouseManager::instance()
{
    if(m_pInstance == nullptr){
        m_pInstance = new HouseManager();

        // TODO ???
    }

    return m_pInstance;
}

HouseManager::~HouseManager()
{
    // TODO ???
    while(!m_Houses.isEmpty()){
        House* currentHouse = m_Houses.front();
        m_Houses.pop_front();
        if(currentHouse != nullptr)
            delete currentHouse;
    }
}

void
HouseManager::reloadFromDatabase()
{
    // TODO
}

void
HouseManager::saveToDatabase()
{
    // TODO
}

HouseManager::HouseManager()
{
    // TODO
    addDefaultData();
}

HouseManager::HouseManager(const HouseManager& hm)
{
    Q_UNUSED(hm)
}

void
HouseManager::addDefaultData()
{
    PriestInfo* pi = createPriestInfo();
    if(pi != nullptr){
        pi->setFirstName("Eufigeniu");
        pi->setLastName("Agamemnon");
    }

    County* county = createCounty();
    if(county != nullptr){
        county->setName("Sibiu");
    }

    Deanery* dioceza = createDeanery();
    if(dioceza != nullptr){
        dioceza->setName("<NAME>");
    }

    Locality* loc = createLocality();
    if(loc != nullptr){
        LocalizedName locName;
        Language* lang = DBManager::instance()->findLanguage(QString("Romanian"));
        if(lang != nullptr)
            locName[lang->Id()] = "Sat Test";

        lang = DBManager::instance()->findLanguage(QString("German"));
        if(lang != nullptr)
            locName[lang->Id()] = "Test Dorf";

        lang = DBManager::instance()->findLanguage(QString("Hungarian"));
        if(lang != nullptr)
            locName[lang->Id()] = "Test Falu";

        lang = DBManager::instance()->findLanguage(QString("Saxon"));
        if(lang != nullptr)
            locName[lang->Id()] = "Test Dorfen";

        loc->setName(locName);
        if(county != nullptr){
            loc->setCounty(county->Id());
        }
    }

    Shire* shire = createShire();
    if(shire != nullptr){
        shire->setName("Testenshire");
    }

    TaxInfo* ti = createTaxInfo();
    if(ti != nullptr){
        ti->setDescription("Taxa pe smen");
        ti->setName("SmenTax");
        ti->setFormula("Se ia valoarea S de smen si se inmulteste cu valoarea V de valoare. Rezultatul se varsa la buget.");
    }

    auto ii = createImageInfo();
    if(ii != nullptr){
        ii->setName("Test image");
        ii->setDetails("Aceasta poza reprezinta un detaliu al smenurilor");
{'fraction_non_alphanumeric': 0.15817474933497033, 'fraction_numerical': 0.0, 'mean_word_length': 2.888623707239459, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, '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': '2831128', 'n_tokens_mistral': 1612, 'n_tokens_neox': 1564, 'n_words': 287}