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

159 lines
3.9 KiB
C++
Executable File

/**
* @RDE_HEADER@
* MVC model
* $Id$
* $HeadURL$
* $Author$
* Created by Mike Wille, SLSE, 2014-10-01
*/
#pragma once
#include "Event.h"
#include "Item.h"
#include <LtsTimelineClassic/ltstimelineclassic_export.h>
#include <QAbstractItemModel>
#include <NGLLogger/INGLLogger.h>
namespace LtsTimelineClassic
{
/**
* @brief MVC model
*/
class LTSTIMELINECLASSIC_EXPORT AbstractTimelineModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit AbstractTimelineModel(/*bool getEventListsRecursive = true,*/ QObject *parent = nullptr);
~AbstractTimelineModel();
void retranslate();
/**
* @brief returns the root item
* @return root item
*/
Item *getRootItem();
Event *getEvent(int uniqueId); // WARNING: unique ids are not unique between events and markers.... grrr
//void invalidateItemForEvent(int uniqueId);
void invalidateTimeline();
/**
* @brief refreshes the model data, which triggers all views to refresh also
*/
void refreshData();
qint64 highestPositionedItem() const { return m_highestPositionedItem; }
qint64 lowestPositionedItem() const { return m_lowestPositionedItem; }
protected:
NGL::INGLLogger &m_logger;
protected:
/**
* @brief adds an event to the model
* @param event event to add to item
*/
void addEvent(Event *event);
/**
* @brief returns coherant data of row & column for the view
* @param index row & column
* @param role what kind of data is needed by the view
* @return variable data
*/
QVariant data(const QModelIndex &index, int role) const;
/**
* @brief flags of the coherant data of row & column has (what is allowed, what is not)
* @param index row & column
* @return flags
*/
Qt::ItemFlags flags(const QModelIndex &index) const;
/**
* @brief returns the header text for the coherant column
* @param section column
* @param orientation use Qt::Horizontal
* @param role what kind of data is needed by the view
* @return variable data
*/
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
/**
* @brief
* @param index
* @return
*/
Item *itemFromIndex(const QModelIndex &idx) const;
/**
* @brief model internal method
* @param row
* @param column
* @param parent
* @return
*/
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
/**
* @brief model internal method
* @param index
* @return
*/
QModelIndex parent(const QModelIndex &index) const;
/**
* @brief model internal method
* @param parent
* @return
*/
int rowCount(const QModelIndex &parent = QModelIndex()) const;
/**
* @brief model internal method
* @param parent
* @return
*/
int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual qint64 currentTime() const = 0;
//ItemList m_itemList; NO: m_rootItem has children [a item list huh] // to keep scope to all items - especially for the EventFactory which can now add to all events
qint64 m_highestPositionedItem;
qint64 m_lowestPositionedItem;
bool m_getEventListsRecursive;
Item *m_rootItem;
Item *m_markersItem; // NOTE: autodeleted by m_rootItem on its deletion
signals:
/**
* @brief signals when event is right-clicked (was triggered by ActiveEvent)
* @param position position of the mouse when right-clicked
* @param affectedEvent event that was right-clicked
*/
void signalContextMenu(const QPoint &position, Event *affectedEvent);
/**
* @brief signals that an event has been clicked (for use with standard-action) (was triggered by ActiveEvent)
* @param affectedEvent event that was clicked
*/
void signalClicked(Event *affectedEvent);
void signalToolTip(const QPoint &p, Event *e);
};
} // namespace LtsTimelineClassic