mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved SaveState from Editor::BaseItem to Editor::NumberedItem.
This commit is contained in:
parent
1e3044fbf4
commit
9be122710d
4 changed files with 50 additions and 4 deletions
|
@ -60,6 +60,16 @@ bool NumberedItem::isUndidStatus() const {
|
||||||
return _status == Status::Undid;
|
return _status == Status::Undid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NumberedItem::save(SaveState state) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void NumberedItem::restore(SaveState state) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NumberedItem::hasState(SaveState state) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void NumberedItem::setStatus(Status status) {
|
void NumberedItem::setStatus(Status status) {
|
||||||
if (status != _status) {
|
if (status != _status) {
|
||||||
_status = status;
|
_status = status;
|
||||||
|
@ -416,13 +426,18 @@ void ItemBase::save(SaveState state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemBase::restore(SaveState state) {
|
void ItemBase::restore(SaveState state) {
|
||||||
const auto &saved = (state == SaveState::Keep) ? _keeped : _saved;
|
if (!hasState(state)) {
|
||||||
if (!saved.zValue) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const auto &saved = (state == SaveState::Keep) ? _keeped : _saved;
|
||||||
applyData(saved.data);
|
applyData(saved.data);
|
||||||
setZValue(saved.zValue);
|
setZValue(saved.zValue);
|
||||||
setVisible(saved.visible);
|
setVisible(saved.visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ItemBase::hasState(SaveState state) const {
|
||||||
|
const auto &saved = (state == SaveState::Keep) ? _keeped : _saved;
|
||||||
|
return saved.zValue;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Editor
|
} // namespace Editor
|
||||||
|
|
|
@ -40,6 +40,10 @@ public:
|
||||||
void setStatus(Status status);
|
void setStatus(Status status);
|
||||||
[[nodiscard]] bool isNormalStatus() const;
|
[[nodiscard]] bool isNormalStatus() const;
|
||||||
[[nodiscard]] bool isUndidStatus() const;
|
[[nodiscard]] bool isUndidStatus() const;
|
||||||
|
|
||||||
|
virtual void save(SaveState state);
|
||||||
|
virtual void restore(SaveState state);
|
||||||
|
virtual bool hasState(SaveState state) const;
|
||||||
private:
|
private:
|
||||||
int _number = 0;
|
int _number = 0;
|
||||||
Status _status = Status::Normal;
|
Status _status = Status::Normal;
|
||||||
|
@ -73,8 +77,9 @@ public:
|
||||||
|
|
||||||
void updateZoom(float64 zoom);
|
void updateZoom(float64 zoom);
|
||||||
|
|
||||||
void save(SaveState state);
|
bool hasState(SaveState state) const override;
|
||||||
void restore(SaveState state);
|
void save(SaveState state) override;
|
||||||
|
void restore(SaveState state) override;
|
||||||
protected:
|
protected:
|
||||||
enum HandleType {
|
enum HandleType {
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -38,4 +38,24 @@ bool ItemLine::collidesWithPath(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ItemLine::save(SaveState state) {
|
||||||
|
if (state == SaveState::Keep) {
|
||||||
|
_keeped = true;
|
||||||
|
} else if (state == SaveState::Save) {
|
||||||
|
_saved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemLine::restore(SaveState state) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ItemLine::hasState(SaveState state) const {
|
||||||
|
if (state == SaveState::Keep) {
|
||||||
|
return _keeped;
|
||||||
|
} else if (state == SaveState::Save) {
|
||||||
|
return _saved;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Editor
|
} // namespace Editor
|
||||||
|
|
|
@ -19,6 +19,10 @@ public:
|
||||||
QPainter *p,
|
QPainter *p,
|
||||||
const QStyleOptionGraphicsItem *option,
|
const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget) override;
|
QWidget *widget) override;
|
||||||
|
|
||||||
|
bool hasState(SaveState state) const override;
|
||||||
|
void save(SaveState state) override;
|
||||||
|
void restore(SaveState state) override;
|
||||||
protected:
|
protected:
|
||||||
bool collidesWithItem(
|
bool collidesWithItem(
|
||||||
const QGraphicsItem *,
|
const QGraphicsItem *,
|
||||||
|
@ -30,6 +34,8 @@ private:
|
||||||
const QPixmap _pixmap;
|
const QPixmap _pixmap;
|
||||||
const QRectF _rect;
|
const QRectF _rect;
|
||||||
|
|
||||||
|
bool _saved, _keeped = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Editor
|
} // namespace Editor
|
||||||
|
|
Loading…
Add table
Reference in a new issue