2022-10-08 22:32:02 +02:00
|
|
|
/*
|
|
|
|
* armywidget.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
|
2022-09-18 01:23:17 +02:00
|
|
|
|
2022-10-16 13:37:01 +02:00
|
|
|
#include "../StdInc.h"
|
2022-09-18 01:23:17 +02:00
|
|
|
#include <QDialog>
|
|
|
|
#include "../lib/mapObjects/CArmedInstance.h"
|
|
|
|
|
|
|
|
const int TOTAL_SLOTS = 7;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ArmyWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ArmyWidget : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ArmyWidget(CArmedInstance &, QWidget *parent = nullptr);
|
|
|
|
~ArmyWidget();
|
|
|
|
|
|
|
|
void obtainData();
|
|
|
|
bool commitChanges();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int searchItemIndex(int slotId, CreatureID creId) const;
|
|
|
|
|
|
|
|
Ui::ArmyWidget *ui;
|
|
|
|
CArmedInstance & army;
|
2023-09-10 16:56:41 +02:00
|
|
|
std::array<QSpinBox*, TOTAL_SLOTS> uiCounts;
|
2022-09-18 01:23:17 +02:00
|
|
|
std::array<QComboBox*, TOTAL_SLOTS> uiSlots;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ArmyDelegate : public QStyledItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
using QStyledItemDelegate::QStyledItemDelegate;
|
|
|
|
|
|
|
|
ArmyDelegate(CArmedInstance &);
|
|
|
|
|
|
|
|
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:
|
|
|
|
CArmedInstance & army;
|
|
|
|
};
|
|
|
|
|