1 #include "SegmentCollectionPrototype.h" 2 3 namespace ADM_qtScript 4 { SegmentCollectionPrototype(QObject * parent,IEditor * editor)5 SegmentCollectionPrototype::SegmentCollectionPrototype(QObject* parent, IEditor* editor) : 6 QtScriptObject(editor) 7 { 8 this->setParent(parent); 9 this->_editor = editor; 10 } 11 getLength()12 QScriptValue SegmentCollectionPrototype::getLength() 13 { 14 return this->_editor->getNbSegment(); 15 } 16 getTotalDuration(void)17 QScriptValue SegmentCollectionPrototype::getTotalDuration(void) 18 { 19 return (double)this->_editor->getVideoDuration(); 20 } 21 add(QScriptValue startTime,QScriptValue duration,QScriptValue videoIndex)22 QScriptValue SegmentCollectionPrototype::add(QScriptValue startTime, QScriptValue duration, QScriptValue videoIndex) 23 { 24 if (!this->_editor->getVideoCount()) 25 { 26 return this->throwError(QString(QT_TR_NOOP("A video must be open to perform this operation."))); 27 } 28 29 QScriptValue result; 30 31 while (true) 32 { 33 result = this->validateNumber("videoIndex", videoIndex, 0, this->_editor->getVideoCount()); 34 35 if (!result.isUndefined()) 36 { 37 break; 38 } 39 40 this->_editor->addSegment(videoIndex.toNumber(), startTime.toNumber(), duration.toNumber()); 41 42 result = this->_editor->getNbSegment() - 1; 43 44 break; 45 } 46 47 return result; 48 } 49 clear()50 void SegmentCollectionPrototype::clear() 51 { 52 if (this->_editor->getVideoCount()) 53 { 54 this->_editor->clearSegment(); 55 } 56 } 57 } 58