implement entire project in nodes
Project items are now represented directly in nodes opening up more versatility and possibilities. This is the first iteration of this and will be buggy. Need to test thoroughly.
This commit is contained in:
@@ -27,80 +27,65 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
Item::Type Folder::type() const
|
||||
Folder::Folder()
|
||||
{
|
||||
return kFolder;
|
||||
}
|
||||
|
||||
bool Folder::CanHaveChildren() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon Folder::icon()
|
||||
QIcon Folder::icon() const
|
||||
{
|
||||
return icon::Folder;
|
||||
}
|
||||
|
||||
void Folder::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, uint version, const QAtomicInt *cancelled)
|
||||
bool ChildExistsWithNameInternal(const Folder* n, const QString& s)
|
||||
{
|
||||
XMLAttributeLoop(reader, attr) {
|
||||
if (cancelled && *cancelled) {
|
||||
return;
|
||||
}
|
||||
foreach (const Node::OutputConnection& c, n->output_connections()) {
|
||||
Node* connected = c.second.node();
|
||||
|
||||
if (attr.name() == QStringLiteral("name")) {
|
||||
set_name(attr.value().toString());
|
||||
} else if (attr.name() == QStringLiteral("ptr")) {
|
||||
xml_node_data.item_ptrs.insert(attr.value().toULongLong(), this);
|
||||
}
|
||||
}
|
||||
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
if (cancelled && *cancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
Item* child;
|
||||
|
||||
if (reader->name() == QStringLiteral("folder")) {
|
||||
child = new Folder();
|
||||
} else if (reader->name() == QStringLiteral("footage")) {
|
||||
child = new Footage();
|
||||
} else if (reader->name() == QStringLiteral("sequence")) {
|
||||
child = new Sequence();
|
||||
if (connected->GetLabel() == s) {
|
||||
return true;
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
continue;
|
||||
}
|
||||
Folder* subfolder = dynamic_cast<Folder*>(connected);
|
||||
|
||||
child->setParent(this);
|
||||
child->Load(reader, xml_node_data, version, cancelled);
|
||||
if (subfolder && ChildExistsWithNameInternal(subfolder, s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Folder::Save(QXmlStreamWriter *writer) const
|
||||
bool Folder::ChildExistsWithName(const QString &s) const
|
||||
{
|
||||
writer->writeAttribute(QStringLiteral("name"), name());
|
||||
return ChildExistsWithNameInternal(this, s);
|
||||
}
|
||||
|
||||
writer->writeAttribute(QStringLiteral("ptr"), QString::number(reinterpret_cast<quintptr>(this)));
|
||||
void Folder::OutputConnectedEvent(const QString &output, const NodeInput &input)
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
foreach (Item* child, children()) {
|
||||
switch (child->type()) {
|
||||
case Item::kFootage:
|
||||
writer->writeStartElement(QStringLiteral("footage"));
|
||||
break;
|
||||
case Item::kSequence:
|
||||
writer->writeStartElement(QStringLiteral("sequence"));
|
||||
break;
|
||||
case Item::kFolder:
|
||||
writer->writeStartElement(QStringLiteral("folder"));
|
||||
break;
|
||||
}
|
||||
Item* item = dynamic_cast<Item*>(input.node());
|
||||
|
||||
child->Save(writer);
|
||||
if (item) {
|
||||
// The insert index is always our "count" because we only support appending in our internal
|
||||
// model. For sorting/organizing, a QSortFilterProxyModel is used instead.
|
||||
emit BeginInsertItem(item, item_child_count());
|
||||
item_children_.append(item);
|
||||
emit EndInsertItem();
|
||||
}
|
||||
}
|
||||
|
||||
writer->writeEndElement(); // footage/folder/sequence
|
||||
void Folder::OutputDisconnectedEvent(const QString &output, const NodeInput &input)
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
Item* item = dynamic_cast<Item*>(input.node());
|
||||
|
||||
if (item) {
|
||||
int child_index = item_children_.indexOf(item);
|
||||
emit BeginRemoveItem(item, child_index);
|
||||
item_children_.removeAt(child_index);
|
||||
emit EndRemoveItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user