1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Address part of feedback

This commit is contained in:
nordsoft 2022-10-09 00:32:02 +04:00
parent 5743310aec
commit d3d1306ef0
10 changed files with 107 additions and 30 deletions

View File

@ -1,3 +1,13 @@
/*
* armywidget.cpp, 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
*
*/
#include "armywidget.h"
#include "ui_armywidget.h"
#include "CCreatureHandler.h"

View File

@ -1,5 +1,13 @@
#ifndef ARMYWIDGET_H
#define ARMYWIDGET_H
/*
* 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
#include <QDialog>
#include "../lib/mapObjects/CArmedInstance.h"
@ -46,4 +54,3 @@ private:
CArmedInstance & army;
};
#endif // ARMYWIDGET_H

View File

@ -1,3 +1,12 @@
/*
* inspector.cpp, 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
*
*/
#include "StdInc.h"
#include "inspector.h"
#include "../lib/CArtHandler.h"

View File

@ -1,5 +1,13 @@
#ifndef INSPECTOR_H
#define INSPECTOR_H
/*
* inspector.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 <QTableWidget>
#include <QTableWidgetItem>
@ -151,4 +159,3 @@ public:
QStringList options;
};
#endif // INSPECTOR_H

View File

@ -1,3 +1,12 @@
/*
* messagewidget.cpp, 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
*
*/
#include "messagewidget.h"
#include "ui_messagewidget.h"

View File

@ -1,6 +1,13 @@
#ifndef MESSAGEWIDGET_H
#define MESSAGEWIDGET_H
/*
* messagewidget.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>
namespace Ui {
@ -34,4 +41,3 @@ public:
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
};
#endif // MESSAGEWIDGET_H

View File

@ -1,3 +1,12 @@
/*
* rewardswidget.cpp, 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
*
*/
#include "rewardswidget.h"
#include "ui_rewardswidget.h"
#include "../lib/VCMI_Lib.h"

View File

@ -1,6 +1,13 @@
#ifndef REWARDSWIDGET_H
#define REWARDSWIDGET_H
/*
* rewardswidget.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/CGPandoraBox.h"
#include "../lib/mapping/CMap.h"
@ -75,5 +82,3 @@ private:
CGPandoraBox & pandora;
const CMap & map;
};
#endif // REWARDSWIDGET_H

View File

@ -1,3 +1,12 @@
/*
* townbuildingswidget.cpp, 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
*
*/
#include "townbulidingswidget.h"
#include "ui_townbulidingswidget.h"
#include "../lib/CModHandler.h"
@ -159,30 +168,27 @@ void TownBulidingsWidget::addBuildings(const CTown & ctown)
ui->treeView->resizeColumnToContents(2);
}
std::set<BuildingID> TownBulidingsWidget::getForbiddenBuildings()
std::set<BuildingID> TownBulidingsWidget::getBuildingsFromModel(int modelColumn, Qt::CheckState checkState)
{
std::set<BuildingID> result;
for(int i = 0; i < model.rowCount(); ++i)
{
if(auto * item = model.item(i, 1))
if(item->checkState() == Qt::Unchecked)
if(auto * item = model.item(i, modelColumn))
if(item->checkState() == checkState)
result.emplace(item->data(Qt::UserRole).toInt());
}
return result;
}
std::set<BuildingID> TownBulidingsWidget::getForbiddenBuildings()
{
return getBuildingsFromModel(1, Qt::Unchecked);
}
std::set<BuildingID> TownBulidingsWidget::getBuiltBuildings()
{
std::set<BuildingID> result;
for(int i = 0; i < model.rowCount(); ++i)
{
if(auto * item = model.item(i, 2))
if(item->checkState() == Qt::Checked)
result.emplace(item->data(Qt::UserRole).toInt());
}
return result;
return getBuildingsFromModel(2, Qt::Checked);
}
void TownBulidingsWidget::on_treeView_expanded(const QModelIndex &index)

View File

@ -1,5 +1,13 @@
#ifndef TOWNBULIDINGSWIDGET_H
#define TOWNBULIDINGSWIDGET_H
/*
* townbuildingswidget.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/CGTownInstance.h"
@ -28,6 +36,8 @@ private slots:
void on_treeView_collapsed(const QModelIndex &index);
private:
std::set<BuildingID> getBuildingsFromModel(int modelColumn, Qt::CheckState checkState);
Ui::TownBulidingsWidget *ui;
CGTownInstance & town;
mutable QStandardItemModel model;
@ -50,4 +60,3 @@ private:
//std::set<BuildingID>
};
#endif // TOWNBULIDINGSWIDGET_H