/* * PickObjectDelegate.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * */ #pragma once #include class MapController; VCMI_LIB_NAMESPACE_BEGIN class CGObjectInstance; VCMI_LIB_NAMESPACE_END class PickObjectDelegate : public QItemDelegate { Q_OBJECT public: PickObjectDelegate(MapController &); PickObjectDelegate(MapController &, std::function); template static bool typedFilter(const CGObjectInstance * o) { return dynamic_cast(o) != nullptr; } QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const override; public slots: void onObjectPicked(const CGObjectInstance *); private: MapController & controller; std::function filter; mutable QModelIndex modelIndex; };