Commit d79f0485 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

parser: Item: Rework subitems creation

Delegate subitem creation to the parent item. This way we can access the
internals of the parent item upon creation, and the item is created in
place.
This will also ease up privatization of the Item type, since we don't
want it to be publicly available for creation
parent dfaa6bed
......@@ -192,9 +192,8 @@ void VLCMetadataService::mediaToItem( VLC::Media& media, parser::Task::Item& ite
assert( vlcMedia != nullptr );
// Always add 1 to the playlist/subitem index, as 0 is an invalid index
// in this context
parser::Task::Item subItem{ vlcMedia->mrl(), i + 1u };
parser::Task::Item& subItem = item.createSubItem( vlcMedia->mrl(), i + 1u );
mediaToItem( *vlcMedia, subItem );
item.addSubItem( std::move( subItem ) );
}
}
}
......
......@@ -185,9 +185,10 @@ const std::vector<Task::Item>& Task::Item::subItems() const
return m_subItems;
}
void Task::Item::addSubItem( Task::Item item )
Task::Item& Task::Item::createSubItem( std::string mrl, unsigned int playlistIndex )
{
m_subItems.emplace_back( std::move( item ) );
m_subItems.emplace_back( std::move( mrl ), playlistIndex );
return m_subItems.back();
}
int64_t Task::Item::duration() const
......
......@@ -161,7 +161,7 @@ public:
void setMrl( std::string mrl );
const std::vector<Item>& subItems() const;
void addSubItem( Item mrl );
Item& createSubItem( std::string mrl, unsigned int playlistIndex );
int64_t duration() const;
void setDuration( int64_t duration );
......
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