<commit_before>#include "roomview.h"
#include "arearect.h"

RoomView::RoomView(QWidget *parent) :
    QGraphicsView(parent)
{
    active_room = 0;
    connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
            this, SLOT(showContextMenu(const QPoint &)));
}

void RoomView::addArea()
{
    updateRoomView();
    world->rooms()->addRoomArea(active_room, QRect(QPoint(20, 20), QSize(64, 64)));
    AreaRect *area_rect = new AreaRect(active_room->areas().last());
    scenes[active_room]->addItem(area_rect);
}

void RoomView::showContextMenu(const QPoint &point)
{
    QMenu *menu = new QMenu;
    menu->addAction(tr("Set background"), this, SLOT(setBackground()));
    menu->addSeparator();
    menu->addAction(tr("Add an area"), this, SLOT(addArea()));
    menu->exec(mapToGlobal(point));
}

void RoomView::setBackground()
{
    updateRoomView();
    QString bgFile = QFileDialog::getOpenFileName(this,"Select the background file",
                                                  QDir::currentPath(),
                                                  "Images (*.png *.xpm *.jpg *.gif)");
    QPixmap bg(bgFile);
    if (bg.isNull())
        return;

    bg = bg.scaled(world->getSize());

    world->rooms()->setRoomBackground(active_room, bg);
    scenes[active_room]->addPixmap(bg);
}

void RoomView::updateRoomView()
{
    if (!scenes.contains(active_room))
        scenes.insert(active_room,
                      new QGraphicsScene(QRectF(QRect(QPoint(0, 0), world->getSize()))));

    setScene(scenes[active_room]);
}

void RoomView::setWorld(World *world)
{
    this->world = world;
    if (active_room == 0)
    {
        world->rooms()->appendRoom("Room 0");
        active_room = world->rooms()->at(0);
    }
}

void RoomView::changeActiveRoom(QModelIndex index)
{
    active_room = world->rooms()->at(index.row());
    updateRoomView();
}<commit_msg>QRectF(QRect) is the same of doing QRectF in updateRoomView of RoomView class<commit_after>#include "roomview.h"
#include "arearect.h"

RoomView::RoomView(QWidget *parent) :
    QGraphicsView(parent)
{
    active_room = 0;
    connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
            this, SLOT(showContextMenu(const QPoint &)));
}

void RoomView::addArea()
{
    updateRoomView();
    world->rooms()->addRoomArea(active_room, QRect(QPoint(20, 20), QSize(64, 64)));
    AreaRect *area_rect = new AreaRect(active_room->areas().last());
    scenes[active_room]->addItem(area_rect);
}

void RoomView::showContextMenu(const QPoint &point)
{
    QMenu *menu = new QMenu;
    menu->addAction(tr("Set background"), this, SLOT(setBackground()));
    menu->addSeparator();
    menu->addAction(tr("Add an area"), this, SLOT(addArea()));
    menu->exec(mapToGlobal(point));
}

void RoomView::setBackground()
{
    updateRoomView();
    QString bgFile = QFileDialog::getOpenFileName(this,"Select the background file",
                                                  QDir::currentPath(),
                                                  "Images (*.png *.xpm *.jpg *.gif)");
    QPixmap bg(bgFile);
    if (bg.isNull())
        return;

    bg = bg.scaled(world->getSize());

    world->rooms()->setRoomBackground(active_room, bg);
    scenes[active_room]->addPixmap(bg);
}

void RoomView::updateRoomView()
{
    if (!scenes.contains(active_room))
        scenes.insert(active_room,
                      new QGraphicsScene(QRectF(QPoint(0, 0), world->getSize())));

    setScene(scenes[active_room]);
}

void RoomView::setWorld(World *world)
{
    this->world = world;
    if (active_room == 0)
    {
        world->rooms()->appendRoom("Room 0");
        active_room = world->rooms()->at(0);
    }
}

void RoomView::changeActiveRoom(QModelIndex index)
{
    active_room = world->rooms()->at(index.row());
    updateRoomView();
}
{'fraction_non_alphanumeric': 0.1596440722323999, 'fraction_numerical': 0.007327924627060979, 'mean_word_length': 3.2561247216035634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '898901', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1202, 'n_words': 211}