mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced interaction with QGraphicsItem to Editor::NumberedItem.
This commit is contained in:
parent
78b25c694e
commit
6acd9f18ad
3 changed files with 8 additions and 8 deletions
|
@ -43,7 +43,7 @@ std::shared_ptr<Scene> EnsureScene(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
using ItemPtr = Scene::ItemPtr;
|
using ItemPtr = std::shared_ptr<QGraphicsItem>;
|
||||||
|
|
||||||
Paint::Paint(
|
Paint::Paint(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
|
|
@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Editor {
|
namespace Editor {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ItemPtr = Scene::ItemPtr;
|
using ItemPtr = std::shared_ptr<NumberedItem>;
|
||||||
|
|
||||||
bool SkipMouseEvent(not_null<QGraphicsSceneMouseEvent*> event) {
|
bool SkipMouseEvent(not_null<QGraphicsSceneMouseEvent*> event) {
|
||||||
return event->isAccepted() || (event->button() == Qt::RightButton);
|
return event->isAccepted() || (event->button() == Qt::RightButton);
|
||||||
|
@ -66,7 +66,7 @@ void Scene::removeItem(not_null<QGraphicsItem*> item) {
|
||||||
removeItem(*it);
|
removeItem(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::removeItem(const ItemPtr &item) {
|
void Scene::removeItem(const std::shared_ptr<QGraphicsItem> &item) {
|
||||||
// Scene loses ownership of an item.
|
// Scene loses ownership of an item.
|
||||||
QGraphicsScene::removeItem(item.get());
|
QGraphicsScene::removeItem(item.get());
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ std::vector<ItemPtr> Scene::items(
|
||||||
auto copyItems = _items;
|
auto copyItems = _items;
|
||||||
|
|
||||||
ranges::sort(copyItems, [&](ItemPtr a, ItemPtr b) {
|
ranges::sort(copyItems, [&](ItemPtr a, ItemPtr b) {
|
||||||
const auto numA = static_cast<NumberedItem*>(a.get())->number();
|
const auto numA = a->number();
|
||||||
const auto numB = static_cast<NumberedItem*>(b.get())->number();
|
const auto numB = b->number();
|
||||||
return (order == Qt::AscendingOrder) ? (numA < numB) : (numA > numB);
|
return (order == Qt::AscendingOrder) ? (numA < numB) : (numA > numB);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class NumberedItem;
|
||||||
|
|
||||||
class Scene final : public QGraphicsScene {
|
class Scene final : public QGraphicsScene {
|
||||||
public:
|
public:
|
||||||
using ItemPtr = std::shared_ptr<QGraphicsItem>;
|
using ItemPtr = std::shared_ptr<NumberedItem>;
|
||||||
|
|
||||||
Scene(const QRectF &rect);
|
Scene(const QRectF &rect);
|
||||||
~Scene();
|
~Scene();
|
||||||
|
@ -33,9 +33,9 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] std::vector<ItemPtr> items(
|
[[nodiscard]] std::vector<ItemPtr> items(
|
||||||
Qt::SortOrder order = Qt::DescendingOrder) const;
|
Qt::SortOrder order = Qt::DescendingOrder) const;
|
||||||
void addItem(std::shared_ptr<NumberedItem> item);
|
void addItem(ItemPtr item);
|
||||||
void removeItem(not_null<QGraphicsItem*> item);
|
void removeItem(not_null<QGraphicsItem*> item);
|
||||||
void removeItem(const ItemPtr &item);
|
void removeItem(const std::shared_ptr<QGraphicsItem> &item);
|
||||||
[[nodiscard]] rpl::producer<> addsItem() const;
|
[[nodiscard]] rpl::producer<> addsItem() const;
|
||||||
[[nodiscard]] rpl::producer<> removesItem() const;
|
[[nodiscard]] rpl::producer<> removesItem() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue