<commit_before>#include "ui/package_view.h"

#include <QDebug>
#include <QDragEnterEvent>
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
#include <QGraphicsScene>
#include <QMimeData>
#include <QTimeLine>

#include "core/registry.h"
#include "elements/package.h"
#include "nodes/node.h"
#include "ui/elements_list.h"
#include "ui/link_item.h"

PackageView::PackageView(elements::Package *const a_package)
  : QGraphicsView{ new QGraphicsScene }
  , m_package{ (a_package ? a_package : new elements::Package) }
  , m_scene{ scene() }
  , m_inputs{ new nodes::Node }
  , m_outputs{ new nodes::Node }
  , m_gridLarge{ new QGraphicsItemGroup }
  , m_gridSmall{ new QGraphicsItemGroup }
  , m_standalone{ !a_package }
{
  setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing |
                 QPainter::SmoothPixmapTransform);
  setDragMode(QGraphicsView::ScrollHandDrag);
  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  setResizeAnchor(QGraphicsView::NoAnchor);
  setTransformationAnchor(QGraphicsView::AnchorViewCenter);
  setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  setObjectName("PackageView");

  m_scene->setSceneRect(-32000, -32000, 64000, 64000);
  m_scene->setObjectName("PackageViewScene");

  QBrush brush{ QColor(169, 169, 169, 32) };
  //  QBrush brush{ QColor(244, 53, 64, 255) }; // RED
  //  QBrush brush{ QColor(232, 0, 99, 255) }; // PINK
  //  QBrush brush{ QColor(154, 41, 169, 255) }; // PURPLE
  //  QBrush brush{ QColor(101, 63, 176, 255) }; // DEEP PURPLE
  //  QBrush brush{ QColor(62, 84, 174, 255) }; // INDIGO
  //  QBrush brush{ QColor(29, 151, 237, 255) }; // BLUE
  //  QBrush brush{ QColor(0, 170, 238, 255) }; // LIGHT BLUE
  //  QBrush brush{ QColor(0, 188, 208, 255) }; // CYAN
  //  QBrush brush{ QColor(0, 149, 134, 255) }; // TEAL
  //  QBrush brush{ QColor(75, 173, 88, 255) }; // GREEN
  //  QBrush brush{ QColor(137, 193, 86, 255) }; // LIGHT GREEN
  //  QBrush brush{ QColor(203, 217, 81, 255) }; // LIME
  //  QBrush brush{ QColor(254, 231, 86, 255) }; // YELLOW
  //  QBrush brush{ QColor(254, 187, 59, 255) }; // AMBER
  //  QBrush brush{ QColor(254, 144, 50, 255) }; // ORANGE
  //  QBrush brush{ QColor(254, 74, 53, 255) }; // DEEP ORANGE
  //  QBrush brush{ QColor(120, 83, 74, 255) }; // BROWN
  //  QBrush brush{ QColor(156, 156, 156, 255) }; // GREY
  //  QBrush brush{ QColor(95, 124, 136, 255) }; // BLUE GREY
  //  QBrush brush{ QColor(58, 66, 71, 255) }; // DARK GREY
  m_scene->setBackgroundBrush(brush);

  createGrid();

  setAcceptDrops(true);

  using NodeType = nodes::Node::Type;
  m_inputs->setPos(-600.0, 0.0);
  m_inputs->setType(NodeType::eInputs);
  m_inputs->setElement(m_package);
  m_inputs->setIcon(":/elements/logic/inputs.png");
  m_inputs->setPackageView(this);
  m_inputs->iconify();
  m_outputs->setPos(600.0, 0.0);
  m_outputs->setType(NodeType::eOutputs);
  m_outputs->setElement(m_package);
  m_outputs->setIcon(":/elements/logic/outputs.png");
  m_outputs->setPackageView(this);
  m_outputs->iconify();

  m_scene->addItem(m_inputs);
  m_scene->addItem(m_outputs);
  m_package->startDispatchThread();
}

PackageView::~PackageView()
{
  if (m_standalone) {
    qDebug() << "Stopping thread";
    m_package->quitDispatchThread();
    delete m_package;
  }
}

void PackageView::dragEnterEvent(QDragEnterEvent *a_event)
{
  if (a_event->mimeData()->hasText()) {
    auto const pathString = a_event->mimeData()->text();
    auto const name = a_event->mimeData()->data("metadata/name");
    auto const icon = a_event->mimeData()->data("metadata/icon");<commit_msg>Remove debug message from ~PackageView<commit_after>#include "ui/package_view.h"

#include <QDebug>
#include <QDragEnterEvent>
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
#include <QGraphicsScene>
#include <QMimeData>
#include <QTimeLine>

#include "core/registry.h"
#include "elements/package.h"
#include "nodes/node.h"
#include "ui/elements_list.h"
#include "ui/link_item.h"

PackageView::PackageView(elements::Package *const a_package)
  : QGraphicsView{ new QGraphicsScene }
  , m_package{ (a_package ? a_package : new elements::Package) }
  , m_scene{ scene() }
  , m_inputs{ new nodes::Node }
  , m_outputs{ new nodes::Node }
  , m_gridLarge{ new QGraphicsItemGroup }
  , m_gridSmall{ new QGraphicsItemGroup }
  , m_standalone{ !a_package }
{
  setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing |
                 QPainter::SmoothPixmapTransform);
  setDragMode(QGraphicsView::ScrollHandDrag);
  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  setResizeAnchor(QGraphicsView::NoAnchor);
  setTransformationAnchor(QGraphicsView::AnchorViewCenter);
  setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  setObjectName("PackageView");

  m_scene->setSceneRect(-32000, -32000, 64000, 64000);
  m_scene->setObjectName("PackageViewScene");

  QBrush brush{ QColor(169, 169, 169, 32) };
  //  QBrush brush{ QColor(244, 53, 64, 255) }; // RED
  //  QBrush brush{ QColor(232, 0, 99, 255) }; // PINK
  //  QBrush brush{ QColor(154, 41, 169, 255) }; // PURPLE
  //  QBrush brush{ QColor(101, 63, 176, 255) }; // DEEP PURPLE
  //  QBrush brush{ QColor(62, 84, 174, 255) }; // INDIGO
  //  QBrush brush{ QColor(29, 151, 237, 255) }; // BLUE
  //  QBrush brush{ QColor(0, 170, 238, 255) }; // LIGHT BLUE
  //  QBrush brush{ QColor(0, 188, 208, 255) }; // CYAN
  //  QBrush brush{ QColor(0, 149, 134, 255) }; // TEAL
  //  QBrush brush{ QColor(75, 173, 88, 255) }; // GREEN
  //  QBrush brush{ QColor(137, 193, 86, 255) }; // LIGHT GREEN
  //  QBrush brush{ QColor(203, 217, 81, 255) }; // LIME
  //  QBrush brush{ QColor(254, 231, 86, 255) }; // YELLOW
  //  QBrush brush{ QColor(254, 187, 59, 255) }; // AMBER
  //  QBrush brush{ QColor(254, 144, 50, 255) }; // ORANGE
  //  QBrush brush{ QColor(254, 74, 53, 255) }; // DEEP ORANGE
  //  QBrush brush{ QColor(120, 83, 74, 255) }; // BROWN
  //  QBrush brush{ QColor(156, 156, 156, 255) }; // GREY
  //  QBrush brush{ QColor(95, 124, 136, 255) }; // BLUE GREY
  //  QBrush brush{ QColor(58, 66, 71, 255) }; // DARK GREY
  m_scene->setBackgroundBrush(brush);

  createGrid();

  setAcceptDrops(true);

  using NodeType = nodes::Node::Type;
  m_inputs->setPos(-600.0, 0.0);
  m_inputs->setType(NodeType::eInputs);
  m_inputs->setElement(m_package);
  m_inputs->setIcon(":/elements/logic/inputs.png");
  m_inputs->setPackageView(this);
  m_inputs->iconify();
  m_outputs->setPos(600.0, 0.0);
  m_outputs->setType(NodeType::eOutputs);
  m_outputs->setElement(m_package);
  m_outputs->setIcon(":/elements/logic/outputs.png");
  m_outputs->setPackageView(this);
  m_outputs->iconify();

  m_scene->addItem(m_inputs);
  m_scene->addItem(m_outputs);
  m_package->startDispatchThread();
}

PackageView::~PackageView()
{
  if (m_standalone) {
    m_package->quitDispatchThread();
    delete m_package;
  }
}

void PackageView::dragEnterEvent(QDragEnterEvent *a_event)
{
  if (a_event->mimeData()->hasText()) {
    auto const pathString = a_event->mimeData()->text();
    auto const name = a_event->mimeData()->data("metadata/name");
    auto const icon = a_event->mimeData()->data("metadata/icon");
{'fraction_non_alphanumeric': 0.16516516516516516, 'fraction_numerical': 0.0687960687960688, 'mean_word_length': 4.290252707581227, 'pattern_counts': {'":': 4, '<': 19, '<?xml version=': 0, '>': 71, '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': '3198938', 'n_tokens_mistral': 3202, 'n_tokens_neox': 2649, 'n_words': 540}