<commit_before>// Copyright 2015, <NAME> and the other displaz contributors.
// Use of this code is governed by the BSD-style license found in LICENSE.txt

#include "geometrycollection.h"

#include "tinyformat.h"
#include "fileloader.h"

#include <QRegExp>

GeometryCollection::GeometryCollection(QObject* parent)
    : QAbstractListModel(parent)
{ }


void GeometryCollection::clear()
{
    if (m_geometries.size())
    {
        emit beginRemoveRows(QModelIndex(), 0, (int)m_geometries.size()-1);
        m_geometries.clear();
        emit endRemoveRows();
    }
}

int GeometryCollection::findMatchingRow(const QRegExp & filenameRegex)
{
    for (unsigned row = 0; row < m_geometries.size(); row++)
    {
        if (filenameRegex.exactMatch(m_geometries[row]->label()))
            return row;
    }
    return -1;
}

void GeometryCollection::unloadFiles(const QRegExp & filenameRegex)
{
    while (true)
    {
        int row = findMatchingRow(filenameRegex);

        if (row == -1)
            break;

        this->removeRows(row, 1, QModelIndex());
    }
}


int GeometryCollection::rowCount(const QModelIndex & parent) const
{
    if (parent.isValid())
        return 0;
    return (int)m_geometries.size();
}


QVariant GeometryCollection::data(const QModelIndex & index, int role) const
{
    if (!index.isValid())
        return QVariant();
    if (role == Qt::DisplayRole)
        return m_geometries[index.row()]->label();
    return QVariant();
}<commit_msg>Add tooltip to geometry list showing full file path<commit_after>// Copyright 2015, <NAME> and the other displaz contributors.
// Use of this code is governed by the BSD-style license found in LICENSE.txt

#include "geometrycollection.h"

#include "tinyformat.h"
#include "fileloader.h"

#include <QRegExp>

GeometryCollection::GeometryCollection(QObject* parent)
    : QAbstractListModel(parent)
{ }


void GeometryCollection::clear()
{
    if (m_geometries.size())
    {
        emit beginRemoveRows(QModelIndex(), 0, (int)m_geometries.size()-1);
        m_geometries.clear();
        emit endRemoveRows();
    }
}

int GeometryCollection::findMatchingRow(const QRegExp & filenameRegex)
{
    for (unsigned row = 0; row < m_geometries.size(); row++)
    {
        if (filenameRegex.exactMatch(m_geometries[row]->label()))
            return row;
    }
    return -1;
}

void GeometryCollection::unloadFiles(const QRegExp & filenameRegex)
{
    while (true)
    {
        int row = findMatchingRow(filenameRegex);

        if (row == -1)
            break;

        this->removeRows(row, 1, QModelIndex());
    }
}


int GeometryCollection::rowCount(const QModelIndex & parent) const
{
    if (parent.isValid())
        return 0;
    return (int)m_geometries.size();
}


QVariant GeometryCollection::data(const QModelIndex & index, int role) const
{
    if (!index.isValid())
        return QVariant();
    switch (role)
    {
        case Qt::DisplayRole:
            return m_geometries[index.row()]->label();
        case Qt::ToolTipRole:
            return m_geometries[index.row()]->fileName();
    }
    return QVariant();
}
{'fraction_non_alphanumeric': 0.12689210950080515, 'fraction_numerical': 0.007085346215780998, 'mean_word_length': 3.20297699594046, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 14, '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': '3278459', 'n_tokens_mistral': 990, 'n_tokens_neox': 955, 'n_words': 225}