1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/mapeditor/inspector/portraitwidget.h
2023-10-13 20:15:29 +02:00

65 lines
1.3 KiB
C++

/*
* portraitwidget.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 <QDialog>
#include "../../lib/mapObjects/CGHeroInstance.h"
namespace Ui {
class PortraitWidget;
}
class PortraitWidget : public QDialog
{
Q_OBJECT
public:
explicit PortraitWidget(CGHeroInstance &, QWidget *parent = nullptr);
~PortraitWidget();
void obtainData();
void commitChanges();
void resizeEvent(QResizeEvent *) override;
private slots:
void on_isDefault_toggled(bool checked);
void on_buttonNext_clicked();
void on_buttonPrev_clicked();
private:
void drawPortrait();
Ui::PortraitWidget *ui;
QGraphicsScene scene;
QPixmap pixmap;
CGHeroInstance & hero;
int portraitIndex;
};
class PortraitDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
using QStyledItemDelegate::QStyledItemDelegate;
PortraitDelegate(CGHeroInstance &);
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
private:
CGHeroInstance & hero;
};