~ubuntu-branches/ubuntu/raring/muse/raring-proposed

« back to all changes in this revision

Viewing changes to muse/trackdrummapupdater.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2012-11-22 01:16:59 UTC
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: package-import@ubuntu.com-20121122011659-a2fwbf33ceqe1s0t
Tags: upstream-2.1~rc1
ImportĀ upstreamĀ versionĀ 2.1~rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=========================================================
 
2
//  MusE
 
3
//  Linux Music Editor
 
4
//  $Id: trackdrummapupdater.cpp,v 1.59.2.52 2011/12/27 20:25:58 flo93 Exp $
 
5
//
 
6
//  (C) Copyright 2011 Florian Jung (florian.a.jung (at) web.de)
 
7
//
 
8
//  This program is free software; you can redistribute it and/or
 
9
//  modify it under the terms of the GNU General Public License
 
10
//  as published by the Free Software Foundation; version 2 of
 
11
//  the License, or (at your option) any later version.
 
12
//
 
13
//  This program is distributed in the hope that it will be useful,
 
14
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
//  GNU General Public License for more details.
 
17
//
 
18
//  You should have received a copy of the GNU General Public License
 
19
//  along with this program; if not, write to the Free Software
 
20
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
21
//
 
22
//=========================================================
 
23
 
 
24
#include "trackdrummapupdater.h"
 
25
#include "song.h"
 
26
#include "globals.h"
 
27
 
 
28
namespace MusECore {
 
29
 
 
30
using MusEGlobal::song;
 
31
 
 
32
TrackDrummapUpdater::TrackDrummapUpdater()
 
33
{
 
34
  connect(song,SIGNAL(songChanged(MusECore::SongChangedFlags_t)), this, SLOT(songChanged(MusECore::SongChangedFlags_t)));
 
35
}
 
36
 
 
37
void TrackDrummapUpdater::songChanged(MusECore::SongChangedFlags_t flags)
 
38
{
 
39
  if (flags & (SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED |
 
40
               SC_PART_INSERTED  | SC_PART_REMOVED  | SC_PART_MODIFIED  |
 
41
               SC_EVENT_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED ) )
 
42
  {
 
43
    bool changed=false;
 
44
    for (iTrack t=song->tracks()->begin(); t!=song->tracks()->end(); t++)
 
45
    {
 
46
      MidiTrack* track=dynamic_cast<MidiTrack*>(*t);
 
47
      if (track && track->auto_update_drummap())
 
48
        changed=true;
 
49
    }
 
50
    
 
51
    if (changed)
 
52
    {
 
53
      // allow recursion. there will be no more recursion, because this
 
54
      // is only executed when something other than SC_DRUMMAP happens
 
55
      song->update(SC_DRUMMAP, true); 
 
56
    }
 
57
    
 
58
  }
 
59
}
 
60
 
 
61
} //namespace MusECore