Krita Source Code Documentation
Loading...
Searching...
No Matches
StoryboardItem Class Reference

This class stores a list of StoryboardChild objects and provides functionality to manipulate the list. Specific item type must be stored at specific indices. More...

#include <StoryboardItem.h>

+ Inheritance diagram for StoryboardItem:

Public Types

enum  childType {
  FrameNumber , ItemName , DurationSecond , DurationFrame ,
  Comments
}
 This enum defines the data type to be stored at particular indices. More...
 

Public Member Functions

void appendChild (QVariant data)
 
QSharedPointer< StoryboardChildchild (int row) const
 
int childCount () const
 
void cloneChildrenFrom (const StoryboardItem &other)
 
void insertChild (int row, QVariant data=QVariant())
 
void loadXML (const QDomElement &itemNode)
 
void moveChild (int from, int to)
 
void removeChild (int row)
 
 StoryboardItem ()
 
 StoryboardItem (const StoryboardItem &other)
 
QDomElement toXML (QDomDocument doc)
 
 ~StoryboardItem ()
 

Static Public Member Functions

static StoryboardItemList cloneStoryboardItemList (const StoryboardItemList &list)
 

Private Attributes

QVector< QSharedPointer< StoryboardChild > > m_childData
 

Detailed Description

This class stores a list of StoryboardChild objects and provides functionality to manipulate the list. Specific item type must be stored at specific indices.

Parameters
childTypeenum for the indices and corresponding data type to be stored.

Definition at line 151 of file StoryboardItem.h.

Member Enumeration Documentation

◆ childType

This enum defines the data type to be stored at particular indices.

Parameters
FrameNumberStore the frame number at index 0. Data type stored here should be ThumbnailData.
ItemNameStore the item name at index 1. Data type stored here should be string.
DurationSecondStore the duration in second at index 2. Data type should be int.
DurationFrameStore the duration in frame at index 3. Data type should be int.
CommentsStore the comments at indices greater_than_or_equal_to to index 4. Data type should be CommentBox.
Enumerator
FrameNumber 

Store the frame number at index 0. Data type stored here should be ThumbnailData.

ItemName 

Store the item name at index 1. Data type stored here should be string.

DurationSecond 

Store the duration in second at index 2. Data type stored here should be int.

DurationFrame 

Store the duration in frame at index 3. Data type stored here should be int.

Comments 

Store the comments at indices greater_than_or_equal_to to index 4. Data type stored here should be CommentBox.

Definition at line 181 of file StoryboardItem.h.

181 {
182
190 ItemName,
203 };
@ DurationFrame
Store the duration in frame at index 3. Data type stored here should be int.
@ FrameNumber
Store the frame number at index 0. Data type stored here should be ThumbnailData.
@ DurationSecond
Store the duration in second at index 2. Data type stored here should be int.
@ ItemName
Store the item name at index 1. Data type stored here should be string.
@ Comments
Store the comments at indices greater_than_or_equal_to to index 4. Data type stored here should be Co...

Constructor & Destructor Documentation

◆ StoryboardItem() [1/2]

StoryboardItem::StoryboardItem ( )
explicit

Definition at line 14 of file StoryboardItem.cpp.

15 : m_childData()
16{}
QVector< QSharedPointer< StoryboardChild > > m_childData

◆ StoryboardItem() [2/2]

StoryboardItem::StoryboardItem ( const StoryboardItem & other)

Definition at line 18 of file StoryboardItem.cpp.

19 : QEnableSharedFromThis<StoryboardItem>()
20 , m_childData()
21{
22 cloneChildrenFrom(other);
23}
void cloneChildrenFrom(const StoryboardItem &other)

References cloneChildrenFrom().

◆ ~StoryboardItem()

StoryboardItem::~StoryboardItem ( )

Definition at line 25 of file StoryboardItem.cpp.

26{
27 m_childData.clear();
28}

References m_childData.

Member Function Documentation

◆ appendChild()

void StoryboardItem::appendChild ( QVariant data)

Definition at line 30 of file StoryboardItem.cpp.

31{
33 child->setParent(sharedFromThis());
34 m_childData.append(child);
35}
This class makes up the StoryboardItem class. It consists of pointer to its parent item and the data ...
QSharedPointer< StoryboardChild > child(int row) const
QSharedPointer< T > toQShared(T *ptr)

References child(), m_childData, and toQShared().

◆ child()

QSharedPointer< StoryboardChild > StoryboardItem::child ( int row) const

Definition at line 69 of file StoryboardItem.cpp.

70{
71 if (row < 0 || row >= m_childData.size()) {
72 return nullptr;
73 }
74 return m_childData.at(row);
75}

References m_childData.

◆ childCount()

int StoryboardItem::childCount ( ) const

Definition at line 64 of file StoryboardItem.cpp.

65{
66 return m_childData.count();
67}

References m_childData.

◆ cloneChildrenFrom()

void StoryboardItem::cloneChildrenFrom ( const StoryboardItem & other)

Definition at line 37 of file StoryboardItem.cpp.

38{
39 m_childData.clear();
40 for (int i = 0; i < other.m_childData.count(); i++) {
42 child->setParent(sharedFromThis());
43 m_childData.append(child);
44 }
45}

References child(), m_childData, and toQShared().

◆ cloneStoryboardItemList()

StoryboardItemList StoryboardItem::cloneStoryboardItemList ( const StoryboardItemList & list)
static

Definition at line 123 of file StoryboardItem.cpp.

124{
125 StoryboardItemList clonedList;
126 for (auto i = 0; i < list.count(); i++) {
127 StoryboardItemSP item = toQShared( new StoryboardItem(*list.at(i)) );
128 item->cloneChildrenFrom(*list.at(i));
129 clonedList.append(item);
130 }
131 return clonedList;
132}

References StoryboardItem(), and toQShared().

◆ insertChild()

void StoryboardItem::insertChild ( int row,
QVariant data = QVariant() )

Definition at line 47 of file StoryboardItem.cpp.

48{
50 child->setParent(sharedFromThis());
51 m_childData.insert(row, child);
52}

References child(), m_childData, and toQShared().

◆ loadXML()

void StoryboardItem::loadXML ( const QDomElement & itemNode)

Definition at line 100 of file StoryboardItem.cpp.

101{
102 ThumbnailData thumbnail;
103 thumbnail.frameNum = itemNode.attribute("frame").toInt();
104 appendChild(QVariant::fromValue<ThumbnailData>(thumbnail));
105 appendChild(itemNode.attribute("item-name"));
106 appendChild(itemNode.attribute("duration-second").toInt());
107 appendChild(itemNode.attribute("duration-frame").toInt());
108
109 for (QDomElement commentNode = itemNode.firstChildElement(); !commentNode.isNull(); commentNode = commentNode.nextSiblingElement()) {
110 if (commentNode.nodeName().toUpper() != "COMMENT") continue;
111
112 CommentBox comment;
113 if (commentNode.hasAttribute("content")) {
114 comment.content = commentNode.attribute("content");
115 }
116 if (commentNode.hasAttribute("scroll-value")) {
117 comment.scrollValue = commentNode.attribute("scroll-value");
118 }
119 appendChild(QVariant::fromValue<CommentBox>(comment));
120 }
121}
This class is a simple combination of two QVariants. It can be converted to and from QVariant type an...
QVariant scrollValue
the value of the scroll bar of the comment scrollbar
QVariant content
the text content of the Comment
void appendChild(QVariant data)
This class is a simple combination of two QVariants. It can be converted to and from QVariant type an...
QVariant frameNum
the frame number corresponding to this item in the timeline docker

References appendChild(), CommentBox::content, ThumbnailData::frameNum, and CommentBox::scrollValue.

◆ moveChild()

void StoryboardItem::moveChild ( int from,
int to )

Definition at line 59 of file StoryboardItem.cpp.

60{
61 m_childData.move(from, to);
62}

References m_childData.

◆ removeChild()

void StoryboardItem::removeChild ( int row)

Definition at line 54 of file StoryboardItem.cpp.

55{
56 m_childData.removeAt(row);
57}

References m_childData.

◆ toXML()

QDomElement StoryboardItem::toXML ( QDomDocument doc)

Definition at line 77 of file StoryboardItem.cpp.

78{
79 QDomElement itemElement = doc.createElement("storyboarditem");
80
81 int frame = qvariant_cast<ThumbnailData>(child(FrameNumber)->data()).frameNum.toInt();
82 itemElement.setAttribute("frame", frame);
83 itemElement.setAttribute("item-name", child(ItemName)->data().toString());
84 itemElement.setAttribute("duration-second", child(DurationSecond)->data().toInt());
85 itemElement.setAttribute("duration-frame", child(DurationFrame)->data().toInt());
86
87 for (int i = Comments; i < childCount(); i++) {
88 CommentBox comment = qvariant_cast<CommentBox>(child(i)->data());
89 QDomElement commentElement = doc.createElement("comment");
90
91 commentElement.setAttribute("content", comment.content.toString());
92 commentElement.setAttribute("scroll-value", comment.scrollValue.toInt());
93
94 itemElement.appendChild(commentElement);
95 }
96
97 return itemElement;
98}
int childCount() const
int toInt(const QString &str, bool *ok=nullptr)
QString toString(const QString &value)

References child(), childCount(), Comments, CommentBox::content, DurationFrame, DurationSecond, FrameNumber, ItemName, and CommentBox::scrollValue.

Member Data Documentation

◆ m_childData

QVector<QSharedPointer<StoryboardChild> > StoryboardItem::m_childData
private

Definition at line 206 of file StoryboardItem.h.


The documentation for this class was generated from the following files: