7#ifndef __KIS_TIME_RANGE_H
8#define __KIS_TIME_RANGE_H
10#include "kritaimage_export.h"
15#include <boost/operators.hpp>
19class KRITAIMAGE_EXPORT
KisTimeSpan :
public boost::equality_comparable<KisTimeSpan>
39 inline int end()
const {
44 return m_end >= m_start ? m_end - m_start + 1 : 0;
48 return m_end == std::numeric_limits<int>::min();
52 return (m_end >= m_start) || (m_end == std::numeric_limits<int>::min() && m_start >= 0);
56 if (m_end == std::numeric_limits<int>::min()) {
57 return m_start <= time;
60 return m_start <= time && time <= m_end;
64 m_start = qMin(time, m_start);
65 m_end = qMax(time, m_end);
70 if (!isValid() || !other.
isValid()) {
77 }
else if (isInfinite()) {
78 return (contains(other.
start()) || contains(other.
end()));
81 const int selfMin = qMin(start(), end());
82 const int selfMax = qMax(start(), end());
83 const int otherMin = qMin(other.
start(), other.
end());
84 const int otherMax = qMax(other.
start(), other.
end());
85 return (selfMax >= otherMin) && (selfMin <= otherMax );
97 return KisTimeSpan(start, std::numeric_limits<int>::min());
120 result.
m_end = std::numeric_limits<int>::min();
121 }
else if (!isValid()) {
132 this->m_start = result.
m_start;
133 this->m_end = result.
m_end;
161 this->m_start = result.
m_start;
162 this->m_end = result.
m_end;
172 void KRITAIMAGE_EXPORT
saveValue(QDomElement *parent,
const QString &tag,
const KisTimeSpan &range);
173 bool KRITAIMAGE_EXPORT
loadValue(
const QDomElement &parent,
const QString &tag,
KisTimeSpan *range);
bool contains(int time) const
KisTimeSpan operator|(const KisTimeSpan &rhs) const
const KisTimeSpan & operator|=(const KisTimeSpan &rhs)
KisTimeSpan(int start, int end)
const KisTimeSpan & operator&=(const KisTimeSpan &rhs)
static KisTimeSpan infinite(int start)
static KisTimeSpan fromTimeWithDuration(int start, int duration)
bool operator==(const KisTimeSpan &rhs) const
KisTimeSpan operator&(const KisTimeSpan &rhs) const
static KisTimeSpan fromTimeToTime(int start, int end)
bool overlaps(const KisTimeSpan &other) const
Q_DECLARE_METATYPE(KisPaintopLodLimitations)
KRITAIMAGE_EXPORT QDebug operator<<(QDebug dbg, const KisTimeSpan &r)
void saveValue(QDomElement *parent, const QString &tag, const QSize &size)
bool loadValue(const QDomElement &e, float *v)