Files
qt5-legatus-legacy/Lts/Common/LtsTimelineClassic/Event.h
T
2026-08-13 18:33:10 +02:00

180 lines
5.1 KiB
C++
Executable File

/**
* @RDE_HEADER@
* base class for received events
* $Id$
* $HeadURL$
* $Author$
* Created by Mike Wille, SLSE, 2014-10-01
*/
#pragma once
#include <LtsTimelineClassic/ltstimelineclassic_export.h>
#include <QColor>
#include <QJsonObject>
#include <QStringList>
#include <LtsUtilsCore/qpoint3d.h>
class QPainter;
class QRect;
namespace LtsSession
{
class LtsSession;
}
namespace LtsTimelineClassic
{
/**
* base container class for received events (event sets and markers)
* to avoid a total rewrite, Event class still exists and the getters access the EventSet class
*/
class LTSTIMELINECLASSIC_EXPORT Event // contains informations about an event, which is visualisized in the second column of the treeview, and can be painted on something
{
public:
enum ButtonType
{
ActiveEvent,
EventBlock,
};
typedef void (*EventPaintFunc)(QPainter *, const QRect &);
static void drawCustomEventGraphicTriangle(QPainter *painter, const QRect &rect);
static void drawCustomEventGraphicInvertTriangle(QPainter *painter, const QRect &rect);
static void drawCustomEventGraphicEllipse(QPainter *painter, const QRect &rect);
static void drawCustomEventGraphicRect(QPainter *painter, const QRect &rect);
static void drawCustomEventGraphicRoundedRect(QPainter *painter, const QRect &rect);
static void drawMultipleEventGraphic(QPainter *painter, const QRect &rect);
Event() = default;
Event(int uniqueId, int typeId, qint64 startTime, qint64 endTime,
int playerId, int partyId, int equipmentId, const QStringList &path,
const EventPaintFunc &paintFunc, const QColor &paintColor,
const QJsonObject &detailData, int subEventId = -1,
const LtsUtils::QPoint3D &pos = LtsUtils::QPoint3D(),
LtsSession::LtsSession *session = nullptr);
/**
* @brief returns event actuator
* @return actuator string list
*/
QStringList getActuator() const { return m_path; }
int typeId() const { return m_typeId; }
int uniqueId() const { return m_uniqueId; }
int getSubEventID() const;
QColor getColor() const { return m_eventColor; }
EventPaintFunc getPaintFunc() const { return m_paintFunc; }
/**
* @brief returns event start time as qint64
* @return start time as msecssinceepoch
*/
qint64 startTime() const { return m_startTime; }
qint64 endTime() const { return m_endTime; }
/**
* @brief returns a manipulated version of event end time as qint64 (returns current time, when end time equals -1)
* @return end time as msecssinceepoch
*/
//qint64 endTime() const;
/**
* @brief other than getEndT, this method returns the real end time (can be 0 or -1)
* @return
*/
//qint64 realEndTime() const { return m_endTime; }
const QJsonObject &detailData() const { return m_detailData; }
void setDetailData(const QJsonObject &detailData) { m_detailData = detailData; }
void setEndT(qint64 newEnd);
/**
* @brief returns event duration in seconds
* @return duration in seconds
*/
qint64 duration(bool ignoreLiveEvents = false) const;
int playerId() const { return m_playerId; }
void setPlayerId(int playerId) { m_playerId = playerId; }
int partyId() const { return m_partyId; }
void setPartyId(int teamId) { m_partyId = teamId; }
int equipmentId() const { return m_equipmentId; }
void setEquipmentId(int eqId) { m_equipmentId = eqId; }
QString getShortActuator() const;
bool positionValid() const { return !std::isnan(m_position.x()) && !std::isnan(m_position.y()); }
const LtsUtils::QPoint3D &position() const { return m_position; }
QPointF pos2d() const { return QPointF(m_position.x(), m_position.y()); }
void setPosition(const LtsUtils::QPoint3D &pos) { m_position = pos; }
/**
* @brief hide tells the model to not be shown on the view
*/
void hide();
/**
* @brief show tells the model to be shown on the view
*/
void show();
/**
* @brief tells if this event should be shown or not
* @return true for show, false for hide
*/
bool isVisible() const { return m_visible; }
/**
* @brief sets the visibility on the value of 'visibility'
* @param visibility true if visible, false if hidden
*/
void setVisible(bool visibility = true);
void setDeleted() { m_deleted = true; }
bool isDeleted() const { return m_deleted; }
protected:
QStringList m_path;
QJsonObject m_detailData;
// geo pos:
LtsUtils::QPoint3D m_position;
EventPaintFunc m_paintFunc = nullptr; // TODO: replace me with a more secure std::function !
LtsSession::LtsSession *m_session = nullptr;
QColor m_eventColor;
qint64 m_startTime = -1;
qint64 m_endTime = -1;
mutable qint64 m_duration = -1;
int m_uniqueId = -1;
int m_typeId = -1;
int m_subEventId = -1; // for events which are one sub-events of many (sub-event-lists)
int m_playerId = -1;
int m_partyId = -1;
int m_equipmentId = -1;
bool m_deleted = false; // would take a while to implement a real free, so this is a quick workaround (do not draw if deleted)
bool m_visible = false;
private:
//NGL::INGLLogger &m_logger;
static bool checkDuration(); // currently not needed..
};
}