<commit_before>#include "inscriptiontablemodel.h"
#include "guiutil.h"
#include "bitcoinrpc.h"
#include "base58.h"
#include "walletmodel.h"
#include "util.h"
#include "ui_interface.h"

#include <QFont>
#include <QColor>
#include <QDateTime>

/*
#include "json/json_spirit_reader_template.h"
#include "json/json_spirit_writer_template.h"
#include "json/json_spirit_utils.h"
*/

#include <boost/algorithm/string.hpp>

#include <stdlib.h>

using namespace boost;
// using namespace json_spirit;

struct InscriptionTableEntry
{

    QString inscription;
    QDateTime date;

    InscriptionTableEntry() {}
    InscriptionTableEntry(const QString &inscription, const QDateTime &date):
        inscription(inscription),date(date) {}
};

class InscriptionTablePriv
{
public:
    InscriptionTablePriv(CWallet *wallet, InscriptionTableModel *parent):
        wallet(wallet),
        parent(parent)
        {
        }
    CWallet *wallet;
    InscriptionTableModel *parent;
    QList<InscriptionTableEntry> cachedInscriptionTable;

    void getLastInscription()
    {
        std::vector<std::pair<std::string, int> > vTxResults;
        this->wallet->GetTxMessages(vTxResults);

        QDateTime inscription_date = QDateTime::currentDateTime();

        std::string inscription = vTxResults[0].first;
#if QT_VERSION < 0x058000
        inscription_date.setMSecsSinceEpoch((qint64)vTxResults[0].second*1000);
#else
        inscription_date.setSecsSinceEpoch((qint64)vTxResults[0].second);
#endif
        cachedInscriptionTable.append(
            InscriptionTableEntry(
                QString::fromStdString(inscription),
                inscription_date
                ));
    }

    void getAllInscriptions()
    {
        std::vector<std::pair<std::string, int> > vTxResults;
        this->wallet->GetTxMessages(vTxResults);
        QDateTime inscription_date = QDateTime::currentDateTime();

        for(std::vector<std::pair<std::string, int> >::size_type i = 0; i != vTxResults.size(); i++) {
            std::string inscription = vTxResults[i].first;
#if QT_VERSION < 0x058000
            inscription_date.setMSecsSinceEpoch((qint64)vTxResults[i].second*1000);
#else
            inscription_date.setSecsSinceEpoch((qint64)vTxResults[i].second);
#endif
            cachedInscriptionTable.append(
                InscriptionTableEntry(
                    QString::fromStdString(inscription),
                    inscription_date
            ));
        }
    }

    void getInscriptions()
    {
        std::vector<std::pair<std::string, int> > vTxResults;
        this->wallet->GetMyTxMessages(vTxResults);
        QDateTime inscription_date = QDateTime::currentDateTime();

        for(std::vector<std::pair<std::string, int> >::size_type i = 0; i != vTxResults.size(); i++) {
            std::string inscription = vTxResults[i].first;
#if QT_VERSION < 0x058000
            inscription_date.setMSecsSinceEpoch((qint64)vTxResults[i].second*1000);
#else
            inscription_date.setSecsSinceEpoch((qint64)vTxResults[i].second);
#endif
            cachedInscriptionTable.append(
                InscriptionTableEntry(
                    QString::fromStdString(inscription),
                    inscription_date
                ));
        }
    }

    void refreshTable()
    {
        cachedInscriptionTable.clear();
        getInscriptions();
    }

    int size()
    {
        return cachedInscriptionTable.size();
    }

    InscriptionTableEntry *index(int idx)
    {
        if(idx >= 0 && idx < cachedInscriptionTable.size())
        {
            return &cachedInscriptionTable[idx];
        }
        else
        {
            return 0;
        }
    }

    QString describe(InscriptionTableEntry *rec)
    {

        QString strHTML;

        strHTML.reserve(4000);
        strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
        strHTML += "<b>Inscription content:</b> " + rec->inscription + "<br>";
        strHTML += "<b>Inscription date:</b> " + rec->date.toString() + "<br>";
        return strHTML;


    }
};


InscriptionTableModel::InscriptionTableModel(CWallet *wallet, WalletModel *parent) :
    QAbstractTableModel(parent),
    wallet(wallet),
    priv(0)
{
    columns << tr("Inscription content      ") ;
    columns << tr("Inscription date         ") ;
    priv = new InscriptionTablePriv(wallet, this);
    priv->refreshTable();
}

InscriptionTableModel::~InscriptionTableModel()
{
    delete priv;
}

int InscriptionTableModel::rowCount(const QModelIndex &parent) const
{
    Q_UNUSED(parent);
    return priv->size();
}

int InscriptionTableModel::columnCount(const QModelIndex &parent) const
{
    Q_UNUSED(parent);
    return columns.length();
}

void InscriptionTableModel::refreshInscriptionTable()
{
    if (this) {
        printf("Refreshing inscription table");
        priv->refreshTable();
        Q_EMIT layoutChanged();
    } else {
        printf("Inscriptiontable uninitialised.");
    }
}<commit_msg>add FIXME<commit_after>#include "inscriptiontablemodel.h"
#include "guiutil.h"
#include "bitcoinrpc.h"
#include "base58.h"
#include "walletmodel.h"
#include "util.h"
#include "ui_interface.h"

#include <QFont>
#include <QColor>
#include <QDateTime>

/*
#include "json/json_spirit_reader_template.h"
#include "json/json_spirit_writer_template.h"
#include "json/json_spirit_utils.h"
*/

#include <boost/algorithm/string.hpp>

#include <stdlib.h>

using namespace boost;
// using namespace json_spirit;

struct InscriptionTableEntry
{

    QString inscription;
    QDateTime date;

    InscriptionTableEntry() {}
    InscriptionTableEntry(const QString &inscription, const QDateTime &date):
        inscription(inscription),date(date) {}
};

class InscriptionTablePriv
{
public:
    InscriptionTablePriv(CWallet *wallet, InscriptionTableModel *parent):
        wallet(wallet),
        parent(parent)
        {
        }
    CWallet *wallet;
    InscriptionTableModel *parent;
    QList<InscriptionTableEntry> cachedInscriptionTable;

    void getLastInscription()
    {
        std::vector<std::pair<std::string, int> > vTxResults;
        this->wallet->GetTxMessages(vTxResults);

        QDateTime inscription_date = QDateTime::currentDateTime();

        std::string inscription = vTxResults[0].first;
#if QT_VERSION < 0x058000
        inscription_date.setMSecsSinceEpoch((qint64)vTxResults[0].second*1000);
#else
        inscription_date.setSecsSinceEpoch((qint64)vTxResults[0].second);
#endif
        cachedInscriptionTable.append(
            InscriptionTableEntry(
                QString::fromStdString(inscription),
                inscription_date
                ));
    }

    void getAllInscriptions()
    {
        std::vector<std::pair<std::string, int> > vTxResults;
        this->wallet->GetTxMessages(vTxResults);
        QDateTime inscription_date = QDateTime::currentDateTime();

        for(std::vector<std::pair<std::string, int> >::size_type i = 0; i != vTxResults.size(); i++) {
            std::string inscription = vTxResults[i].first;
#if QT_VERSION < 0x058000
            inscription_date.setMSecsSinceEpoch((qint64)vTxResults[i].second*1000);
#else
            inscription_date.setSecsSinceEpoch((qint64)vTxResults[i].second);
#endif
            cachedInscriptionTable.append(
                InscriptionTableEntry(
                    QString::fromStdString(inscription),
                    inscription_date
            ));
        }
    }

    void getInscriptions()
    {
        std::vector<std::pair<std::string, int> > vTxResults;
        this->wallet->GetMyTxMessages(vTxResults);
        QDateTime inscription_date = QDateTime::currentDateTime();

        for(std::vector<std::pair<std::string, int> >::size_type i = 0; i != vTxResults.size(); i++) {
            std::string inscription = vTxResults[i].first;
#if QT_VERSION < 0x058000
            inscription_date.setMSecsSinceEpoch((qint64)vTxResults[i].second*1000);
#else
            inscription_date.setSecsSinceEpoch((qint64)vTxResults[i].second);
#endif
            cachedInscriptionTable.append(
                InscriptionTableEntry(
                    QString::fromStdString(inscription),
                    inscription_date
                ));
        }
    }

    void refreshTable()
    {
        cachedInscriptionTable.clear();
        getInscriptions();
    }

    int size()
    {
        return cachedInscriptionTable.size();
    }

    InscriptionTableEntry *index(int idx)
    {
        if(idx >= 0 && idx < cachedInscriptionTable.size())
        {
            return &cachedInscriptionTable[idx];
        }
        else
        {
            return 0;
        }
    }

    QString describe(InscriptionTableEntry *rec)
    {

        QString strHTML;

        strHTML.reserve(4000);
        strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
        strHTML += "<b>Inscription content:</b> " + rec->inscription + "<br>";
        strHTML += "<b>Inscription date:</b> " + rec->date.toString() + "<br>";
        return strHTML;


    }
};


InscriptionTableModel::InscriptionTableModel(CWallet *wallet, WalletModel *parent) :
    QAbstractTableModel(parent),
    wallet(wallet),
    priv(0)
{
    columns << tr("Inscription content      ") ;
    columns << tr("Inscription date         ") ;
    priv = new InscriptionTablePriv(wallet, this);
    priv->refreshTable();
}

InscriptionTableModel::~InscriptionTableModel()
{
    delete priv;
}

int InscriptionTableModel::rowCount(const QModelIndex &parent) const
{
    Q_UNUSED(parent);
    return priv->size();
}

int InscriptionTableModel::columnCount(const QModelIndex &parent) const
{
    Q_UNUSED(parent);
    return columns.length();
}

void InscriptionTableModel::refreshInscriptionTable()
{
    /* FIXME: Use explicit check for NULL */
    if (this) {
        printf("Refreshing inscription table");
        priv->refreshTable();
        Q_EMIT layoutChanged();
    } else {
        printf("Inscriptiontable uninitialised.");
    }
}
{'fraction_non_alphanumeric': 0.12150656115396173, 'fraction_numerical': 0.011820094160072122, 'mean_word_length': 2.943127962085308, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 75, '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': '1763384', 'n_tokens_mistral': 3089, 'n_tokens_neox': 2971, 'n_words': 495}