[vlmc-devel] Commands: Handle grouping resize comnmands
Hugo Beauzée-Luyssen
git at videolan.org
Sun Oct 30 02:02:12 CEST 2016
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sun Oct 30 01:32:24 2016 +0200| [56c5a2de4a0c23b801a0e97e636d5c399b583d99] | committer: Hugo Beauzée-Luyssen
Commands: Handle grouping resize comnmands
> https://code.videolan.org/videolan/vlmc/commit/56c5a2de4a0c23b801a0e97e636d5c399b583d99
---
src/Commands/Commands.cpp | 57 ++++++++++++++++++++++++++++++++++-------------
src/Commands/Commands.h | 21 +++++++++++------
2 files changed, 55 insertions(+), 23 deletions(-)
diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index cd5f5e7..a0e7f5c 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -243,22 +243,24 @@ Commands::Clip::Remove::internalUndo()
Commands::Clip::Resize::Resize( std::shared_ptr<SequenceWorkflow> const& workflow,
const QUuid& uuid, qint64 newBegin, qint64 newEnd, qint64 newPos ) :
- m_workflow( workflow ),
- m_clip( workflow->clip( uuid ) ),
- m_newBegin( newBegin ),
- m_newEnd( newEnd ),
- m_newPos( newPos )
+ m_workflow( workflow )
{
- if ( m_clip->uuid.isNull() == true )
+ auto clip = workflow->clip( uuid );
+ if ( clip == nullptr )
{
invalidate();
return;
}
- m_oldBegin = m_clip->clip->begin();
- m_oldEnd = m_clip->clip->end();
- m_oldPos = m_clip->pos;
+ m_infos.append( Info{
+ clip,
+ newBegin,
+ clip->clip->begin(),
+ newEnd,
+ clip->clip->end(),
+ newPos,
+ clip->pos
+ });
retranslate();
-
}
void
@@ -267,20 +269,43 @@ Commands::Clip::Resize::retranslate()
setText( tr( "Resizing clip" ) );
}
+bool
+Commands::Clip::Resize::mergeWith( const QUndoCommand* command )
+{
+ auto cmd = static_cast<const Resize*>( command );
+ if ( cmd->m_infos.count() > 1 )
+ return false;
+ const auto& linkedClips = m_infos[0].clip->linkedClips;
+ if ( linkedClips.contains( cmd->m_infos[0].clip->uuid ) == false )
+ return false;
+ m_infos += cmd->m_infos[0];
+ return true;
+}
+
+int
+Commands::Clip::Resize::id() const
+{
+ return static_cast<int>( Commands::Id::Resize );
+}
+
void
Commands::Clip::Resize::internalRedo()
{
- bool ret = m_workflow->resizeClip( m_clip->uuid, m_newBegin, m_newEnd, m_newPos );
- if ( ret == false )
- invalidate();
+ for ( const auto& info : m_infos )
+ {
+ if ( m_workflow->resizeClip( info.clip->uuid, info.newBegin, info.newEnd, info.newPos ) == false )
+ invalidate();
+ }
}
void
Commands::Clip::Resize::internalUndo()
{
- bool ret = m_workflow->resizeClip( m_clip->uuid, m_oldBegin, m_oldEnd, m_oldPos );
- if ( ret == false )
- invalidate();
+ for ( const auto& info : m_infos )
+ {
+ if ( m_workflow->resizeClip( info.clip->uuid, info.oldBegin, info.oldEnd, info.oldPos ) == false )
+ invalidate();
+ }
}
Commands::Clip::Split::Split( std::shared_ptr<SequenceWorkflow> const& workflow,
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index 36eed46..0afca5e 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -50,6 +50,7 @@ namespace Commands
enum class Id
{
Move,
+ Resize,
};
#ifdef HAVE_GUI
@@ -153,16 +154,22 @@ namespace Commands
virtual void internalRedo();
virtual void internalUndo();
virtual void retranslate();
+ virtual bool mergeWith( const QUndoCommand* cmd );
+ virtual int id() const;
private:
std::shared_ptr<SequenceWorkflow> m_workflow;
- QSharedPointer<SequenceWorkflow::ClipInstance> m_clip;
- qint64 m_newBegin;
- qint64 m_oldBegin;
- qint64 m_newEnd;
- qint64 m_oldEnd;
- qint64 m_newPos;
- qint64 m_oldPos;
+ struct Info
+ {
+ QSharedPointer<SequenceWorkflow::ClipInstance> clip;
+ qint64 newBegin;
+ qint64 oldBegin;
+ qint64 newEnd;
+ qint64 oldEnd;
+ qint64 newPos;
+ qint64 oldPos;
+ };
+ QVector<Info> m_infos;
};
class Split : public Generic
More information about the Vlmc-devel
mailing list