Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* IntervalModel
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Fröbel, SLSE, 2017-07-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
/**
|
||||
* Model for the Timeline so it can be shown in a TabView.
|
||||
* This is a poor man's version as the timeline is displayed in a table.
|
||||
* Later it will probably be replaced by something more usable.
|
||||
* @author Christian Fröbel
|
||||
*/
|
||||
class IntervalModel : public LtsWidgets::LtsAbstractTableModel<AvaTimelinePart>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Start = 0,
|
||||
End,
|
||||
Duration,
|
||||
};
|
||||
|
||||
IntervalModel();
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
void reset();
|
||||
|
||||
bool isEmpty() const { return m_vecData.isEmpty(); }
|
||||
|
||||
void setCurrentPosition(AvaTimePoint pos, bool forceSignal = false);
|
||||
boost::optional<AvaTimePoint> currentPosition() const { return m_currentPos; }
|
||||
|
||||
/**
|
||||
* If the current position is within an interval:
|
||||
* - and the position is at least 2s into the interval, return that
|
||||
* - otherwise return the previous interval (unless there is none).
|
||||
* If the current position is between two intervals return the one before
|
||||
* the current position.
|
||||
*/
|
||||
const AvaTimelinePart &previousInterval() const;
|
||||
const AvaTimelinePart &nextInterval() const;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Emitted if the current interval changed either due to
|
||||
* setCurrentPosition() or reset().
|
||||
* There must not always be a current interval as the current position
|
||||
* can also be between two intervals.
|
||||
* @param rowIndex might be invalid if the current position is between intervals.
|
||||
*/
|
||||
void currentIntervalChanged(bool hasPreviousInterval, bool hasNextInterval, const QModelIndex &rowIndex);
|
||||
|
||||
public slots:
|
||||
void setTimezoneHoursOffset(int timezoneHoursOffset);
|
||||
|
||||
private:
|
||||
QString dateTimeToStringy(const QDateTime &dt) const;
|
||||
QString msecsSinceEpochToStringy(qint64 msecs) const;
|
||||
|
||||
/**
|
||||
* A HalfIndex denotes the current position within or between intervals.
|
||||
* The counting of indices is done as follows:
|
||||
* -1 0 1 2 3 4 5 6 7
|
||||
* ----- ----- ----- ----- # intervals 0...3
|
||||
* Examples:
|
||||
* within interval with index i => halfIndex = 2*i
|
||||
* before interval with index i => halfIndex = 2*i-1
|
||||
* after interval with index i => halfIndex = 2*i+1
|
||||
*/
|
||||
using HalfIndex = int;
|
||||
HalfIndex intervalForPos(AvaTimePoint pos) const;
|
||||
|
||||
boost::optional<AvaTimePoint> m_currentPos;
|
||||
boost::optional<HalfIndex> m_currentInterval;
|
||||
|
||||
int m_timezoneHoursOffset = 0;
|
||||
};
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Reference in new issue
Block a user