Commit daa83782 authored by Sashmita Raghav's avatar Sashmita Raghav

Add class to handle subtitles definition and comparison

parent 74db9ca9
......@@ -203,3 +203,61 @@ PlaylistState::ClipState stateFromBool(std::pair<bool, bool> av)
return PlaylistState::Disabled;
}
}
SubtitledTime::SubtitledTime()
: m_starttime(0)
, m_endtime(0)
{
}
SubtitledTime::SubtitledTime(const GenTime &start, QString sub, const GenTime &end)
: m_starttime(start)
, m_subtitle(sub)
, m_endtime(end)
{
}
QString SubtitledTime::subtitle()
{
return m_subtitle;
}
GenTime SubtitledTime::start()
{
return m_starttime;
}
GenTime SubtitledTime::end()
{
return m_endtime;
}
void SubtitledTime::setSubtitle(const QString& sub)
{
m_subtitle = sub;
}
void SubtitledTime::setEndTime(const GenTime& end)
{
m_endtime = end;
}
bool SubtitledTime::operator>(const SubtitledTime& op) const
{
return(m_starttime > op.m_starttime && m_endtime > op.m_endtime && m_starttime > op.m_endtime);
}
bool SubtitledTime::operator<(const SubtitledTime& op) const
{
return(m_starttime < op.m_starttime && m_endtime < op.m_endtime && m_endtime < op.m_starttime);
}
bool SubtitledTime::operator==(const SubtitledTime& op) const
{
return(m_starttime == op.m_starttime && m_endtime == op.m_endtime);
}
bool SubtitledTime::operator!=(const SubtitledTime& op) const
{
return(m_starttime != op.m_starttime && m_endtime != op.m_endtime);
}
......@@ -260,6 +260,34 @@ private:
int m_type{0};
};
class SubtitledTime
{
public:
SubtitledTime();
SubtitledTime(const GenTime &start, QString sub, const GenTime &end);
QString subtitle();
GenTime start();
GenTime end();
void setSubtitle(const QString &sub);
void setEndTime(const GenTime &end);
/* Implementation of > operator; Works identically as with basic types. */
bool operator>(const SubtitledTime &op) const;
/* Implementation of < operator; Works identically as with basic types. */
bool operator<(const SubtitledTime &op) const;
/* Implementation of == operator; Works identically as with basic types. */
bool operator==(const SubtitledTime &op) const;
/* Implementation of != operator; Works identically as with basic types. */
bool operator!=(const SubtitledTime &op) const;
private:
GenTime m_starttime;
QString m_subtitle;
GenTime m_endtime;
};
QDebug operator<<(QDebug qd, const ItemInfo &info);
// we provide hash function for qstring and QPersistentModelIndex
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment