84 lines
2.1 KiB
C++
Executable File
84 lines
2.1 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* AreaModel
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Norbert Thoden, NLE, 2020-06-29
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <ParticipantManagement/logger.h>
|
|
#include <ParticipantManagement/ppm_dtc.h>
|
|
#include <LtsWidgets/lts_abstract_table_model.h>
|
|
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
|
|
|
namespace ParticipantManagement
|
|
{
|
|
|
|
// --------------------------------------------------------
|
|
// AreaModel
|
|
// --------------------------------------------------------
|
|
class AreaModel final : public LtsWidgets::LtsAbstractTableModel<ShootbackArea>
|
|
{
|
|
Q_OBJECT
|
|
using BaseClass = LtsWidgets::LtsAbstractTableModel<ShootbackArea>;
|
|
|
|
public:
|
|
enum Columns
|
|
{
|
|
Id,
|
|
// main config
|
|
Name,
|
|
Coords
|
|
};
|
|
|
|
explicit AreaModel(QObject *parent = nullptr);
|
|
|
|
bool initModel(const TargetInformation &targetInformation);
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
|
|
QVariant data(const QModelIndex &, int) const override;
|
|
|
|
const QVector<ShootbackArea> &getData() const { return m_vecData; }
|
|
std::vector<ShootbackArea> getDataStdVector() const { return std::vector<ShootbackArea>(m_vecData.begin(), m_vecData.end()); }
|
|
|
|
Q_SIGNALS:
|
|
void signalAreaNamesChanged();
|
|
|
|
private Q_SLOTS:
|
|
void onShootbackAreaChanged(const ShootbackArea &data,
|
|
const DataModification modType);
|
|
void updateColumnFilter();
|
|
|
|
private:
|
|
friend class AreaProxyModel;
|
|
|
|
// column filter
|
|
QSet<QString> m_usedNames;
|
|
|
|
LOGGER_T m_logger;
|
|
};
|
|
|
|
// --------------------------------------------------------
|
|
// AreaProxyModel
|
|
// --------------------------------------------------------
|
|
class AreaProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
using BaseClass = LtsWidgets::LtsColumnFilterProxyModel;
|
|
|
|
public:
|
|
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
|
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
|
|
|
protected:
|
|
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
|
|
|
protected:
|
|
AreaModel *m_sourceModel{nullptr};
|
|
};
|
|
|
|
} //namespace ParticipantManagement
|