#include #include "Shot.h" #include Shot::Shot(Segment *parentSegment) : Segment(parentSegment) { } Shot::Shot(qint64 position, TransitionType transitionType, Segment *parentSegment, Segment::Source source) : Segment(position, parentSegment, source), m_transitionType(transitionType), m_end(-1) { m_camera = new QVector(2); for (int i(0); i < m_camera->size(); i++) m_camera->replace(i, -1); } Shot::~Shot() { } void Shot::read(const QJsonObject &json) { m_source = static_cast(json["source"].toInt()); m_transitionType = static_cast(json["trans"].toInt()); m_end = -1; m_camera = new QVector(2); QJsonArray camArray = json["cam"].toArray(); for (int i(0); i < m_camera->size(); i++) m_camera->replace(i, camArray[i].toInt()); Segment::read(json); } void Shot::write(QJsonObject &json) const { json["source"] = m_source; json["trans"] = m_transitionType; QJsonArray camArray; for (int i = 0; i < m_camera->size(); i++) camArray.append(m_camera->at(i)); json["cam"] = camArray; Segment::write(json); } QString Shot::display() const { return "Shot " + QString::number(row()+1); } /////////////// // modifiers // /////////////// void Shot::setEnd(qint64 end) { m_end = end; } void Shot::setCamera(int nCamera, Segment::Source source) { m_camera->replace(source, nCamera); } /////////////// // accessors // /////////////// int Shot::getNumber() const { return row() + 1; } qint64 Shot::getEnd() { return m_end; } int Shot::getCamera(Segment::Source source) const { return m_camera->value(source); } QString Shot::getLabel() const { int nCamera = m_camera->value(Segment::Manual); if (nCamera != -1) return "C" + QString::number(nCamera); else return QString(); } QMap Shot::getSpeakerList(VideoFrame::SpeakerSource source) { QMap speakerList; QString speakerLabel; VideoFrame *frame; int n; for (int i(0); i < childCount(); i++) { speakerLabel = (frame = dynamic_cast(child(i)))->getSpeaker(source); if (!speakerLabel.isEmpty()) { n = speakerList.value(speakerLabel); speakerList.insert(speakerLabel, ++n); } } return speakerList; }