Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions canvaswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,16 @@ void CanvasWidget::mousePressEvent(QMouseEvent *event) {

selected = NULL;
transformation = NONE;
if (!shapes.size ())
return;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition looks to do not have any sense b/c there will not be any loop if size is 0

for(unsigned i = shapes.size(); i > 0; i--) {
if(shapes[i - 1]->belongs(pressedPoint)) {
//Нажали на фигуру
toFront(i - 1); //переместилю фигуру вперед
selected = shapes[shapes.size() - 1]; //Запоминаем последню выбранную фигуры
if (selected != NULL && selectedShapes.size() == 1)
if (!selected)
continue;
if (selectedShapes.size() == 1)
emit shapeSelected(selected->getType());
//Проверяем нажатие на контроллер масштабирования (левый верхний)
if(selected->isTopLeft(pressedPoint, epsilon)) {
Expand Down Expand Up @@ -169,6 +173,8 @@ void CanvasWidget::mousePressEvent(QMouseEvent *event) {

void CanvasWidget::mouseMoveEvent(QMouseEvent *event) {

if (!transformation)
return;
if((event->buttons()) & Qt::LeftButton) {
Point2D currentPoint;
currentPoint.x = event->localPos().x();
Expand Down Expand Up @@ -221,7 +227,7 @@ void CanvasWidget::mouseMoveEvent(QMouseEvent *event) {
selected->select(true);

setModified(true);
}
}

update();
}
Expand Down
7 changes: 4 additions & 3 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <svgstyleparse.h>
#include <svgfigureparser.h>
#include <QApplication>

#include "colordialogbutton.h"

Expand Down Expand Up @@ -66,7 +67,7 @@ MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::keyReleaseEvent(QKeyEvent * event) {
void MainWindow::keyReleaseEvent(QKeyEvent * /*event*/) {
canvas->pressedKeyCode = 0;
}

Expand Down Expand Up @@ -273,7 +274,7 @@ bool MainWindow::saveFileByText(QString fileName, QString text) {
QTextStream out(&file);
out <<text;
}

return true;
}

bool MainWindow::saveFileByData(QString fileName)
Expand All @@ -294,7 +295,7 @@ bool MainWindow::saveFileByData(QString fileName)
out.setVersion(QDataStream::Qt_5_0);
out <<canvas->shapes.data();
}

return true;
}


Expand Down
Loading