mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Code review fix
This commit is contained in:
		| @@ -194,7 +194,7 @@ void AbstractViewportLayer::redraw(const std::vector<QRectF> & areas) | ||||
| 	redrawSectors(intersectingSectors); | ||||
| } | ||||
|  | ||||
| QRectF AbstractViewportLayer::getObjectArea(const CGObjectInstance * object) | ||||
| QRectF AbstractViewportLayer::getObjectArea(const CGObjectInstance * object) const | ||||
| { | ||||
| 	auto pos = object->pos; | ||||
| 	int x = ((pos.x + 1) * tileSize) - (object->getWidth() * tileSize);	//Qt set 0,0 point on the top right corner, CGObjectInstance on the bottom left | ||||
| @@ -233,13 +233,13 @@ void AbstractViewportLayer::redrawSectors(std::set<QGraphicsItem *> & sectors) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| const QList<QGraphicsItem *> AbstractViewportLayer::getAllSectors()	//returning const is necessary to avoid "range-loop might detach Qt container" problem | ||||
| const QList<QGraphicsItem *> AbstractViewportLayer::getAllSectors() const	//returning const is necessary to avoid "range-loop might detach Qt container" problem | ||||
| { | ||||
| 	QList<QGraphicsItem *> emptyList; | ||||
| 	return items ? items->childItems() : emptyList; | ||||
| } | ||||
|  | ||||
| std::set<QGraphicsItem *> AbstractViewportLayer::getContainingSectors(const std::vector<int3> & tiles) | ||||
| std::set<QGraphicsItem *> AbstractViewportLayer::getContainingSectors(const std::vector<int3> & tiles) const | ||||
| { | ||||
| 	std::set<QGraphicsItem *> result; | ||||
| 	for (QGraphicsItem * existingSector : getAllSectors()) { | ||||
| @@ -255,7 +255,7 @@ std::set<QGraphicsItem *> AbstractViewportLayer::getContainingSectors(const std: | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| std::set<QGraphicsItem *> AbstractViewportLayer::getIntersectingSectors(const std::vector<QRectF> & areas) | ||||
| std::set<QGraphicsItem *> AbstractViewportLayer::getIntersectingSectors(const std::vector<QRectF> & areas) const | ||||
| { | ||||
| 	std::set<QGraphicsItem *> result; | ||||
| 	for (QGraphicsItem * existingSector : getAllSectors()) { | ||||
|   | ||||
| @@ -75,15 +75,15 @@ protected: | ||||
| 	void redrawWithSurroundingTiles(const std::vector<int3> & tiles); | ||||
| 	void redraw(const std::set<CGObjectInstance *> & objects); | ||||
| 	void redraw(const std::vector<QRectF> & areas); | ||||
| 	QRectF getObjectArea(const CGObjectInstance * object); | ||||
| 	QRectF getObjectArea(const CGObjectInstance * object) const; | ||||
| private: | ||||
| 	void addSector(QGraphicsItem * item); | ||||
| 	void removeSector(QGraphicsItem * item); | ||||
| 	void redrawSectors(std::set<QGraphicsItem *> & items); | ||||
| 	const QList<QGraphicsItem *> getAllSectors(); | ||||
| 	const QList<QGraphicsItem *> getAllSectors() const; | ||||
|  | ||||
| 	std::set<QGraphicsItem *> getContainingSectors(const std::vector<int3> & tiles); | ||||
| 	std::set<QGraphicsItem *> getIntersectingSectors(const std::vector<QRectF> & areas); | ||||
| 	std::set<QGraphicsItem *> getContainingSectors(const std::vector<int3> & tiles) const; | ||||
| 	std::set<QGraphicsItem *> getIntersectingSectors(const std::vector<QRectF> & areas) const; | ||||
| 	std::unique_ptr<QGraphicsItemGroup> items; | ||||
| 	const int sectorSizeInTiles = 10; | ||||
| 	const int sectorSize = sectorSizeInTiles * tileSize; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user