<commit_before>// Copyright (c) 2015 The Hivemind Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
extern "C" {
#include "linalg/src/tc_mat.h"
}
#include "resolvevotecoltablemodel.h"
#include "resolvevotedialog.h"
#include "resolvevotegraph.h"
#include "resolvevoteinputtablemodel.h"
#include "resolvevoterowtablemodel.h"
#include "walletmodel.h"

#include <QApplication>
#include <QClipboard>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QItemSelection>
#include <QItemSelectionModel>
#include <QKeyEvent>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QScrollArea>
#include <QSplitter>
#include <QString>
#include <QTableView>
#include <QTabWidget>
#include <QVBoxLayout>

ResolveVoteDialog::ResolveVoteDialog(QWidget *parent)
    : QDialog(parent),
    vote(0),
    model(0)
{
    /* starting data: start with minimum defualts */
    vote = tc_vote_ctr(2, 1);
    vote->NA = 0.138042e-30;
    vote->alpha = 0.10;
    vote->tol = 0.10;

    // oldrep
    double **rep = vote->rvecs[TC_VOTE_OLD_REP]->a;
    rep[0][0] = 0.5;
    rep[1][0] = 0.5;

    // Binary / scaled
    double **isbin = vote->cvecs[TC_VOTE_IS_BINARY]->a;
    for(uint32_t j=0; j < vote->nc; j++)
        isbin[0][j] = (j < 4)? 1.0: 0;

    // Vote matrix
    double **m = vote->M->a;
    m[0][0] = 1.0;
    m[1][0] = 1.0;

    // RC
    int rc = tc_vote_proc(vote);

    /* gui styling */
    setWindowTitle(tr("Resolve Vote Scenarios"));
    setMinimumSize(800, 200);

    QSplitter *splitter = new QSplitter(Qt::Vertical);

    // Vertical layout to contain input and output widgets
    QVBoxLayout *vlayout = new QVBoxLayout(this);
    vlayout->setContentsMargins(0,0,0,0);

    // Add input widget
    QWidget *inputWidget = new QWidget();
    splitter->addWidget(inputWidget);

    // Add output widget
    QWidget *outputWidget = new QWidget();
    splitter->addWidget(outputWidget);

    // Add splitter
    vlayout->addWidget(splitter);

    // Contain input widget in groupbox
    QVBoxLayout *vilayout = new QVBoxLayout(inputWidget);
    vilayout->setContentsMargins(0,0,0,0);
    QGroupBox *groupbox1 = new QGroupBox(tr("Input"));
    QVBoxLayout *vi1layout = new QVBoxLayout();
    groupbox1->setLayout(vi1layout);
    vilayout->addWidget(groupbox1);

    // Contain output widget in groupbox
    QVBoxLayout *volayout = new QVBoxLayout(outputWidget);
    volayout->setContentsMargins(0,0,0,0);
    QGroupBox *groupbox2 = new QGroupBox(tr("Output"));
    QVBoxLayout *vo1layout = new QVBoxLayout();
    groupbox2->setLayout(vo1layout);
    volayout->addWidget(groupbox2);

    /* vi1layout (input)       */

    /* input params */
    /*   # Voters    [   ]    # Decisions [   ]                  */
    /*   alpha       [   ]    tol         [   ]     NA    [   ]  */
    QGridLayout *g1layout = new QGridLayout();

    g1layout->setHorizontalSpacing(0);
    g1layout->setColumnStretch(0, 1);
    g1layout->setColumnStretch(1, 2);
    g1layout->setColumnStretch(2, 1); /* space */
    g1layout->setColumnStretch(3, 1);
    g1layout->setColumnStretch(4, 2);
    g1layout->setColumnStretch(5, 1); /* space */
    g1layout->setColumnStretch(6, 1);
    g1layout->setColumnStretch(7, 2);
    vi1layout->addLayout(g1layout);

    // #Voters value display<commit_msg>Fix spacing on input view, use automatic column stretching better for multiple resolutions, update comments to current ui<commit_after>// Copyright (c) 2015 The Hivemind Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
extern "C" {
#include "linalg/src/tc_mat.h"
}
#include "resolvevotecoltablemodel.h"
#include "resolvevotedialog.h"
#include "resolvevotegraph.h"
#include "resolvevoteinputtablemodel.h"
#include "resolvevoterowtablemodel.h"
#include "walletmodel.h"

#include <QApplication>
#include <QClipboard>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QItemSelection>
#include <QItemSelectionModel>
#include <QKeyEvent>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QScrollArea>
#include <QSplitter>
#include <QString>
#include <QTableView>
#include <QTabWidget>
#include <QVBoxLayout>

ResolveVoteDialog::ResolveVoteDialog(QWidget *parent)
    : QDialog(parent),
    vote(0),
    model(0)
{
    /* starting data: start with minimum defualts */
    vote = tc_vote_ctr(2, 1);
    vote->NA = 0.138042e-30;
    vote->alpha = 0.10;
    vote->tol = 0.10;

    // oldrep
    double **rep = vote->rvecs[TC_VOTE_OLD_REP]->a;
    rep[0][0] = 0.5;
    rep[1][0] = 0.5;

    // Binary / scaled
    double **isbin = vote->cvecs[TC_VOTE_IS_BINARY]->a;
    for(uint32_t j=0; j < vote->nc; j++)
        isbin[0][j] = (j < 4)? 1.0: 0;

    // Vote matrix
    double **m = vote->M->a;
    m[0][0] = 1.0;
    m[1][0] = 1.0;

    // RC
    int rc = tc_vote_proc(vote);

    /* gui styling */
    setWindowTitle(tr("Resolve Vote Scenarios"));
    setMinimumSize(800, 200);

    QSplitter *splitter = new QSplitter(Qt::Vertical);

    // Vertical layout to contain input and output widgets
    QVBoxLayout *vlayout = new QVBoxLayout(this);
    vlayout->setContentsMargins(0,0,0,0);

    // Add input widget
    QWidget *inputWidget = new QWidget();
    splitter->addWidget(inputWidget);

    // Add output widget
    QWidget *outputWidget = new QWidget();
    splitter->addWidget(outputWidget);

    // Add splitter
    vlayout->addWidget(splitter);

    // Contain input widget in groupbox
    QVBoxLayout *vilayout = new QVBoxLayout(inputWidget);
    vilayout->setContentsMargins(0,0,0,0);
    QGroupBox *groupbox1 = new QGroupBox(tr("Input"));
    QVBoxLayout *vi1layout = new QVBoxLayout();
    groupbox1->setLayout(vi1layout);
    vilayout->addWidget(groupbox1);

    // Contain output widget in groupbox
    QVBoxLayout *volayout = new QVBoxLayout(outputWidget);
    volayout->setContentsMargins(0,0,0,0);
    QGroupBox *groupbox2 = new QGroupBox(tr("Output"));
    QVBoxLayout *vo1layout = new QVBoxLayout();
    groupbox2->setLayout(vo1layout);
    volayout->addWidget(groupbox2);

    /* vi1layout (input)       */

    /* input params */
    // {# voters}       [] {-}{+} {alpha}   []
    // {# Decisions}    [] {-}{+} {tol}     [] {NA} []
    QGridLayout *g1layout = new QGridLayout();
    g1layout->setHorizontalSpacing(5);
    g1layout->setVerticalSpacing(5);
    vi1layout->addLayout(g1layout);

    // #Voters value display
{'fraction_non_alphanumeric': 0.14454837766734874, 'fraction_numerical': 0.02747734580532008, 'mean_word_length': 3.5833891493636973, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 102, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6932708', 'n_tokens_mistral': 2538, 'n_tokens_neox': 2405, 'n_words': 515}