mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-04 09:42:40 +02:00
46 lines
1008 B
C++
46 lines
1008 B
C++
/*
|
|
* 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 <QItemDelegate>
|
|
|
|
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<bool(const CGObjectInstance *)>);
|
|
|
|
template<class T>
|
|
static bool typedFilter(const CGObjectInstance * o)
|
|
{
|
|
return dynamic_cast<const T*>(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<bool(const CGObjectInstance *)> filter;
|
|
mutable QModelIndex modelIndex;
|
|
};
|