Commit af362766 authored by Yann Boucher's avatar Yann Boucher
Browse files

Now supports drawing multiple cells by holding left mouse button and moving

parent e3b7103a
Pipeline #78342 passed with stages
in 17 seconds
......@@ -39,6 +39,7 @@ public:
protected:
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
private:
GridView& m_gridview;
......
......@@ -24,6 +24,9 @@ public:
explicit StructureLibraryView(QWidget *parent = nullptr);
~StructureLibraryView();
protected:
void mouseMoveEvent(QMouseEvent* event);
signals:
void structure_copied(const Structure& s);
......
......@@ -28,6 +28,8 @@ Cette classe représente le widget utilisé pour l'affichage et l'interaction av
#include "structurereader.hpp"
// FIXME : faire en sorte que le tooltip soit correctement mis à jour à chaque fois
class GridItem : public QGraphicsRectItem
{
public:
......@@ -146,6 +148,29 @@ void GridGraphicsView::mousePressEvent(QMouseEvent *event)
QGraphicsView::mousePressEvent(event);
}
void GridGraphicsView::mouseMoveEvent(QMouseEvent *event)
{
QGraphicsItem* gitem_ptr = itemAt(event->pos());
GridItem* item = dynamic_cast<GridItem*>(gitem_ptr);
if (event->buttons() == Qt::LeftButton && item)
{
unsigned state = m_gridview.current_pen();
item->setBrush(QBrush(stateColor_to_QColor(m_gridview.alphabet().getState(state).getColor())));
item->cell_state = state;
item->update();
}
else if (event->buttons() == Qt::RightButton && item)
{
QGraphicsView::mouseMoveEvent(event);
item->setSelected(true);
}
else
QGraphicsView::mouseMoveEvent(event);
}
GridView::GridView(QWidget *parent)
: QFrame(parent), m_width(10), m_height(10)
{
......
......@@ -26,7 +26,7 @@ StructureLibraryView::StructureLibraryView(QWidget *parent) :
connect(ui->tree, &QTreeWidget::itemClicked, this, &StructureLibraryView::update_info);
connect(ui->tree, &QTreeWidget::itemDoubleClicked, this, &StructureLibraryView::create_drag);
connect(ui->button_copy, &QPushButton::pressed, this, &StructureLibraryView::copy_button_clicked);
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, [this](const QString&)
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, [this](const QString&)
{
load_structures();
});
......@@ -37,6 +37,11 @@ StructureLibraryView::~StructureLibraryView()
delete ui;
}
void StructureLibraryView::mouseMoveEvent(QMouseEvent *event)
{
qDebug() << event->pos() << "\n";
}
void StructureLibraryView::load_structures()
{
// clear the previously watched directories
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment