Skip to content

Commit

Permalink
scene: Add isBackground()
Browse files Browse the repository at this point in the history
  • Loading branch information
Tectu committed May 11, 2024
1 parent dd6387a commit 2191015
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions qschematic/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ Scene::removeItem(const std::shared_ptr<Items::Item> item)
return true;
}

bool
Scene::isBackground(const QGraphicsItem* item) const
{
// Note: Using dynamic_cast instead of qgraphicsitem_cast becase we are not registering the background as a custom
// item.

return dynamic_cast<const Background*>(item) == _background;
}

QList<std::shared_ptr<Items::Item>>
Scene::items() const
{
Expand Down
10 changes: 10 additions & 0 deletions qschematic/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ namespace QSchematic
return ret;
}

/**
* Check whether an item is the current background item.
*
* @param item The item to check.
* @return Whether the item is the current background item.
*/
[[nodiscard]]
bool
isBackground(const QGraphicsItem* item) const;

QList<std::shared_ptr<Items::Item>> itemsAt(const QPointF& scenePos, Qt::SortOrder order = Qt::DescendingOrder) const;
std::vector<std::shared_ptr<Items::Item>> selectedItems() const;
std::vector<std::shared_ptr<Items::Item>> selectedTopLevelItems() const;
Expand Down

0 comments on commit 2191015

Please sign in to comment.