Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,198 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Operator Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
#include <ProjectDataManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <QSet>
|
||||
|
||||
namespace ProjectDataManagement
|
||||
{
|
||||
|
||||
inline uint qHash(GearClass gc)
|
||||
{
|
||||
return ::qHash(gc.underlying());
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// OperatorManagementModel
|
||||
// --------------------------------------------------------
|
||||
class /* OPMCHANGEPASSWORDGUI_EXPORT*/ ChargeTableDialogModel final : public LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::ChargeType>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
IsVisible,
|
||||
PredefinedName,
|
||||
ShortName,
|
||||
LongName,
|
||||
DirectImpact,
|
||||
TopAttack,
|
||||
BurstOfFire,
|
||||
AirBurst,
|
||||
Unarmed,
|
||||
ShortTime,
|
||||
FireAndForget,
|
||||
ShortTimeScanning,
|
||||
DisEntity
|
||||
};
|
||||
|
||||
enum Offsets
|
||||
{
|
||||
None = 0,
|
||||
Grandparent = 0,
|
||||
ShortTimeChild1 = 1500,
|
||||
ShortTimeChild2 = 1600,
|
||||
ShortTimeChild3 = 1700,
|
||||
ShortTimeChild4 = 1800,
|
||||
ShortTimeChild5 = 1900,
|
||||
|
||||
DirectImpactGrandparent = 0,
|
||||
TopAttackGrandparent = 0,
|
||||
DirectImpactChild = 1000,
|
||||
TopAttackChild = 1000,
|
||||
BurstOfFireParent = 2000,
|
||||
BurstOfFireChild = 3000,
|
||||
AirBurstParent = 4000,
|
||||
AirBurstChild = 5000,
|
||||
UnarmedParent = 6000,
|
||||
UnarmedChild = 7000,
|
||||
FireAndForgetParent = 10000,
|
||||
FireAndForgetChild = 11000,
|
||||
ShortTimeScanningParent = 20000,
|
||||
ShortTimeScanningChild = 21000
|
||||
};
|
||||
|
||||
explicit ChargeTableDialogModel(bool isOrganiser, QObject *parent = nullptr);
|
||||
~ChargeTableDialogModel();
|
||||
|
||||
bool initModel(const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtc, const QSet<GearClass> &gearClasses = {GearClass::DuelSim});
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
bool setData(const QModelIndex &idx, const QVariant &value, int role = Qt::EditRole) override final;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override final
|
||||
{
|
||||
Qt::ItemFlags flags(LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::ChargeType>::flags(index));
|
||||
switch (index.column())
|
||||
{
|
||||
case IsVisible:
|
||||
case DirectImpact:
|
||||
case TopAttack:
|
||||
case AirBurst:
|
||||
case BurstOfFire:
|
||||
case Unarmed:
|
||||
case ShortTime:
|
||||
case ShortTimeScanning:
|
||||
case FireAndForget:
|
||||
flags.setFlag(Qt::ItemIsUserCheckable);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
QVector<ChargeType> getChargeTypesWithChangedVisibility() const;
|
||||
|
||||
bool isFiltered( const ProjectDataManagement::ChargeType &data, DataModification modType ) const override;
|
||||
|
||||
QSet<int> selectedCharges() const;
|
||||
|
||||
|
||||
template<typename T>
|
||||
bool setValues(const T &uleisCodes, bool includeChildren = false)
|
||||
{
|
||||
m_visibleCharges.clear();
|
||||
if (includeChildren && !m_isOrganiser)
|
||||
{
|
||||
std::vector<int> inclusive = chargesIncludingChildren(uleisCodes);
|
||||
for (auto val : inclusive)
|
||||
m_visibleCharges.insert(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto val : uleisCodes)
|
||||
{
|
||||
m_visibleCharges.insert(val);
|
||||
}
|
||||
}
|
||||
emit dataChanged(index(0, 0), index(m_vecData.size()-1, columnCount()-1));
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static std::vector<int> chargesIncludingChildren(const T &parentalCharges)
|
||||
{
|
||||
std::vector<int> retVal;
|
||||
for (auto val : parentalCharges)
|
||||
{
|
||||
if (val < 1000)
|
||||
retVal.push_back(val);
|
||||
else if (val > 3000)
|
||||
continue;
|
||||
|
||||
if (val >= 47 && val <= 76)
|
||||
{
|
||||
for (const auto &type : ALL_TAS)
|
||||
retVal.push_back(type + val);
|
||||
}
|
||||
else if (val > 2000 && val < 3000)
|
||||
{
|
||||
for (const auto &type : ALL_ULEIS)
|
||||
retVal.push_back(type + val);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static bool isBaseCharge(int type) { return (type < 1000 || (type > 2000 && type < 3000));}
|
||||
static int baseCharge(int chargeTypeId);
|
||||
|
||||
template<typename T>
|
||||
static int chargeCountBaseCharges(const T &chargeTypes)
|
||||
{
|
||||
QSet<int> tmp;
|
||||
for (int type : chargeTypes)
|
||||
tmp.insert(baseCharge(type));
|
||||
return tmp.size();
|
||||
}
|
||||
|
||||
signals:
|
||||
void chargeVisibilityChanged(bool hasChanges);
|
||||
|
||||
private:
|
||||
bool isFiltered(int chargeTypeId) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
// For not always decoding JSON Properties, store temp visibility seperately:
|
||||
QSet<int> m_visibleCharges;
|
||||
// Charge type ids, whose Visibility changed:
|
||||
QSet<int> m_differences;
|
||||
QSet<GearClass> m_gearClasses;
|
||||
bool m_isOrganiser;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
static const QVector<int> ALL_ULEIS;
|
||||
static const QVector<int> ALL_TAS;
|
||||
|
||||
// We could store all ChargeTypes by ULEIS Code in a seperate map.
|
||||
// Then, we could put names/DIS/data to the respective column if a Code >3000 is defined.
|
||||
// Nevertheless, the row data copy is the master. But that's only altered in organiser mode.
|
||||
};
|
||||
|
||||
} // namespace ProjectDataManagement
|
||||
Reference in new issue
Block a user