#include "stringtableviewer.h"
#include "ui_stringtableviewer.h"

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

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

void StringTableViewer::SetStringTable(const XStringTable *aStringTable) {
    ui->tableWidget_Strings->clear();

    ui->tableWidget_Strings->setRowCount(aStringTable->GetRowCount());
    ui->tableWidget_Strings->setColumnCount(aStringTable->GetColumnCount());

    int currentIndex = 0;
    for (auto value : *aStringTable->GetValues()) {

        QTableWidgetItem *tableKeyItem = new QTableWidgetItem();
        tableKeyItem->setText(value->GetName());
        ui->tableWidget_Strings->setItem(currentIndex, 0, tableKeyItem);

        QTableWidgetItem *tableValItem = new QTableWidgetItem();
        tableValItem->setText(value->GetString());
        ui->tableWidget_Strings->setItem(currentIndex, 1, tableValItem);

        currentIndex++;
    }
}
