<commit_before>#include "DatasetBrowser.h"
#include "ui_DatasetBrowser.h"
#include <QDebug>
#include "dataset/MSRDailyActivity3D.h"
#include "dataset/MSRDailyDepthInstance.h"
#include "dataset/MSRDailySkeletonInstance.h"
#include "dataset/MSR3Action3D.h"
#include "InstanceWidgetItem.h"
#include <QGuiApplication>


using namespace dai;

DatasetBrowser::DatasetBrowser(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DatasetBrowser)
{
    ui->setupUi(this);

    m_viewer = NULL;
    m_dataset = NULL;
    loadDataset( (Dataset::DatasetType) ui->comboDataset->currentIndex());

    // Connect Signals
    connect(ui->listActivities, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(listItemChange(QListWidgetItem*)));
    connect(ui->listActors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(listItemChange(QListWidgetItem*)));
    connect(ui->listSamples, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(listItemChange(QListWidgetItem*)));
    connect(ui->listInstances, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(instanceItemActivated(QListWidgetItem*)));
    connect(ui->comboType, SIGNAL(currentIndexChanged(int)), this, SLOT(comboBoxChange(int)));
}

DatasetBrowser::~DatasetBrowser()
{
    ui->listActivities->clear();
    ui->listActors->clear();
    ui->listSamples->clear();
    ui->listInstances->clear();
    delete ui;
}

void DatasetBrowser::closeEvent(QCloseEvent * event)
{
    Q_UNUSED(event);
    QMainWindow* parent =  dynamic_cast<QMainWindow*>(this->parent());
    parent->show();
}

void DatasetBrowser::listItemChange(QListWidgetItem * item)
{
    Q_UNUSED(item);
    loadInstances();
}

void DatasetBrowser::comboBoxChange(int index)
{
    Q_UNUSED(index);
    loadInstances();
}

void DatasetBrowser::instanceItemActivated(QListWidgetItem * item)
{
    InstanceWidgetItem* instanceItem = dynamic_cast<InstanceWidgetItem*>(item);
    InstanceInfo& info = instanceItem->getInfo();
    DataInstance* instance = NULL;

    if (info.getType() == InstanceInfo::Depth)
        instance = m_dataset->getDepthInstance(info);
    else if (info.getType() == InstanceInfo::Skeleton) {
        instance = m_dataset->getSkeletonInstance(info);
    }

    InstanceViewer* viewer = NULL;

    if (ui->checkBoxSameViewer->isChecked()) {
        if (m_viewer == NULL) {
            m_viewer = new InstanceViewer;
            connect(m_viewer, SIGNAL(viewerClose(InstanceViewer*)), this, SLOT(viewerClosed(InstanceViewer*)));
        }
        viewer = m_viewer;
    } else {
        viewer = new InstanceViewer;
        connect(viewer, SIGNAL(viewerClose(InstanceViewer*)), this, SLOT(viewerClosed(InstanceViewer*)));<commit_msg>Fix openning a not supported data instance<commit_after>#include "DatasetBrowser.h"
#include "ui_DatasetBrowser.h"
#include <QDebug>
#include "dataset/MSRDailyActivity3D.h"
#include "dataset/MSRDailyDepthInstance.h"
#include "dataset/MSRDailySkeletonInstance.h"
#include "dataset/MSR3Action3D.h"
#include "InstanceWidgetItem.h"
#include <QGuiApplication>


using namespace dai;

DatasetBrowser::DatasetBrowser(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DatasetBrowser)
{
    ui->setupUi(this);

    m_viewer = NULL;
    m_dataset = NULL;
    loadDataset( (Dataset::DatasetType) ui->comboDataset->currentIndex());

    // Connect Signals
    connect(ui->listActivities, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(listItemChange(QListWidgetItem*)));
    connect(ui->listActors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(listItemChange(QListWidgetItem*)));
    connect(ui->listSamples, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(listItemChange(QListWidgetItem*)));
    connect(ui->listInstances, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(instanceItemActivated(QListWidgetItem*)));
    connect(ui->comboType, SIGNAL(currentIndexChanged(int)), this, SLOT(comboBoxChange(int)));
}

DatasetBrowser::~DatasetBrowser()
{
    ui->listActivities->clear();
    ui->listActors->clear();
    ui->listSamples->clear();
    ui->listInstances->clear();
    delete ui;
}

void DatasetBrowser::closeEvent(QCloseEvent * event)
{
    Q_UNUSED(event);
    QMainWindow* parent =  dynamic_cast<QMainWindow*>(this->parent());
    parent->show();
}

void DatasetBrowser::listItemChange(QListWidgetItem * item)
{
    Q_UNUSED(item);
    loadInstances();
}

void DatasetBrowser::comboBoxChange(int index)
{
    Q_UNUSED(index);
    loadInstances();
}

void DatasetBrowser::instanceItemActivated(QListWidgetItem * item)
{
    InstanceWidgetItem* instanceItem = dynamic_cast<InstanceWidgetItem*>(item);
    InstanceInfo& info = instanceItem->getInfo();
    DataInstance* instance = NULL;

    if (info.getType() == InstanceInfo::Depth)
        instance = m_dataset->getDepthInstance(info);
    else if (info.getType() == InstanceInfo::Skeleton) {
        instance = m_dataset->getSkeletonInstance(info);
    }
    else {
        return;
    }

    InstanceViewer* viewer = NULL;

    if (ui->checkBoxSameViewer->isChecked()) {
        if (m_viewer == NULL) {
            m_viewer = new InstanceViewer;
            connect(m_viewer, SIGNAL(viewerClose(InstanceViewer*)), this, SLOT(viewerClosed(InstanceViewer*)));
        }
        viewer = m_viewer;
    } else {
        viewer = new InstanceViewer;
        connect(viewer, SIGNAL(viewerClose(InstanceViewer*)), this, SLOT(viewerClosed(InstanceViewer*)));
{'fraction_non_alphanumeric': 0.13832157445228369, 'fraction_numerical': 0.0011139992573338284, 'mean_word_length': 5.0732807215332585, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 57, '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': '4916061', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1732, 'n_words': 265}