Skip to content

Commit

Permalink
fixed one Bug.
Browse files Browse the repository at this point in the history
Text Bug.
Fixed Crash.
  • Loading branch information
parisa-hr committed Dec 28, 2021
1 parent 940031f commit 31bc9b6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Base/baseitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class BaseItem: public QGraphicsItem
// Q_OBJECT

public:
enum
{
Type = UserType + 1
};

explicit BaseItem(QObject *parent = nullptr);

QRectF rect() const;
Expand All @@ -24,6 +29,11 @@ class BaseItem: public QGraphicsItem

void setColor(const QColor &color);

int type() const override
{
return Type;
}

private:
QRectF _rect = QRectF(0, 0, 100, 100);
QBrush _brush = Qt::yellow;
Expand Down
5 changes: 5 additions & 0 deletions src/Base/diagrambase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ DiagramBase::DiagramBase(QWidget *parent):

connect(_menuBar, &MenuBar::doRedo, ObjectKeeper::instance()->getUndoStack(), &QUndoStack::redo);
}
cmd = new ShapeCommand();
}

DiagramBase::~DiagramBase()
Expand Down Expand Up @@ -642,6 +643,10 @@ void DiagramBase::InsertDiagramText()
_textItem->setZValue(101);
_textItem->setFont(font);

cmd->setItem(_textItem);

ObjectKeeper::instance()->createCommand(cmd);

scene->addItem(_textItem);
}

Expand Down
1 change: 1 addition & 0 deletions src/Base/diagrambase.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private slots:
QAction *undoAction;
QAction *redoAction;
DiagramTextItem *_textItem;
ShapeCommand *cmd;
};

#endif // DIAGRAMBASE_H
2 changes: 2 additions & 0 deletions src/Base/diagramscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <src/commonItems/arrow.h>
#include <src/commonItems/communicationpath.h>
#include <src/commonItems/dasharrow.h>
#include <QDebug>

DiagramScene *DiagramScene::sInstance = nullptr;

Expand All @@ -26,6 +27,7 @@ DiagramScene::DiagramScene(QObject *parent):

if (item)
{
qDebug() << "Item Type " << item->type();
resizer = QSharedPointer<GraphicsItemResizer>::create(item);
resizer->setBrush(QColor(64, 64, 64));
resizer->setMinSize(QSizeF(30, 30));
Expand Down
4 changes: 1 addition & 3 deletions src/Base/diagramtextitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DiagramTextItem: public QGraphicsTextItem
Type = UserType + 3
};

DiagramTextItem( QGraphicsItem *parent = nullptr);
DiagramTextItem(QGraphicsItem *parent = nullptr);

int type() const override
{
Expand All @@ -29,8 +29,6 @@ class DiagramTextItem: public QGraphicsTextItem
void selectedChange(QGraphicsItem *item);

protected:


QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;

void focusOutEvent(QFocusEvent *event) override;
Expand Down

0 comments on commit 31bc9b6

Please sign in to comment.