First steps towards making the playlist behave nicely with respect to grouped tracks...
[amarok.git] / src / playlist / UndoCommands.cpp
blob816b69f6e48afdf822c1c9a081ca5a25f367d721
1 /***************************************************************************
2 * copyright : (C) 2007 Ian Monroe <ian@monroe.nu> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License version 2 *
6 * as published by the Free Software Foundation. *
7 ***************************************************************************/
10 #include "TheInstances.h"
11 #include "UndoCommands.h"
13 using namespace Playlist;
14 using namespace Qt;
16 AddTracksCmd::AddTracksCmd( QUndoCommand* parent, int row, Meta::TrackList tracks )
17 : QUndoCommand( i18n("Tracks Added"), parent )
18 , m_tracks( tracks )
19 , m_row( row )
20 { }
23 void
24 AddTracksCmd::redo()
26 The::playlistModel()->insertTracksCommand( m_row, m_tracks );
29 void
30 AddTracksCmd::undo()
32 The::playlistModel()->removeRowsCommand( m_row, m_tracks.size() );
35 RemoveTracksCmd::RemoveTracksCmd( QUndoCommand* parent, int position, int numOfRows )
36 : QUndoCommand( i18n("Tracks Removed"), parent )
37 , m_numOfRows( numOfRows )
38 , m_position( position )
39 { }
41 void
42 RemoveTracksCmd::redo()
44 m_tracks = The::playlistModel()->removeRowsCommand( m_position, m_numOfRows );
47 void
48 RemoveTracksCmd::undo()
50 The::playlistModel()->insertTracksCommand( m_position, m_tracks );