1 /* This file is part of the KDE project 2 * Copyright (C) 2007 Marijn Kruisselbrink <mkruisselbrink@kde.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 #ifndef MUSIC_CORE_VOICEBAR_H 20 #define MUSIC_CORE_VOICEBAR_H 21 22 #include <QObject> 23 #include <QRectF> 24 25 namespace MusicCore { 26 27 class Voice; 28 class Bar; 29 class VoiceElement; 30 31 /** 32 * A VoiceBar contains the music elements in a specific voice in a specific bar. A VoiceBar is in many ways 33 * simply a wrapper around a QList containing the actual music elements. 34 */ 35 class VoiceBar : public QObject 36 { 37 Q_OBJECT 38 public: 39 /** 40 * Creates a new empty voice bar. 41 */ 42 explicit VoiceBar(Bar* bar); 43 44 /** 45 * Destructor. 46 */ 47 ~VoiceBar() override; 48 49 Bar* bar(); 50 51 /** 52 * Returns the number of elements in the bar. 53 */ 54 int elementCount() const; 55 56 /** 57 * Returns the element at the given index in this bar. 58 * 59 * @param index the index of the element to return 60 */ 61 VoiceElement* element(int index); 62 63 int indexOfElement(VoiceElement* element); 64 65 /** 66 * Adds an element to this bar. You should not add an element to more than one bar, because when the bar is deleted 67 * all elements in the bar are also deleted. 68 * 69 * @param element the element to add to this bar 70 */ 71 void addElement(VoiceElement* element); 72 73 /** 74 * Inserts an element into this bar. You should not add an element to more than one bar, because when the bar is deleted 75 * all elements in the bar are also deleted. 76 * 77 * @param element the element to insert into the bar 78 * @param before the index of the element before which to insert the element 79 */ 80 void insertElement(VoiceElement* element, int before); 81 82 /** 83 * Inserts an element into the bar. You should not add an element to more than one bar, because when the bar is deleted 84 * all elements in the bar are also deleted. 85 * 86 * @param element the element to insert into the bar 87 * @param before the element before which to insert the element 88 */ 89 void insertElement(VoiceElement* element, VoiceElement* before); 90 91 /** 92 * Removes an element from this bar. If deleteElement is true, the element is not only removed but also deleted. 93 * 94 * @param index the index of the element to remove 95 * @param deleteElement should the element not only be removed but also deleted 96 */ 97 void removeElement(int index, bool deleteElement = true); 98 99 /** 100 * Removes an element from this bar. If deleteElement is true, the element is not only removed but also deleted. 101 * 102 * @param element the element to remove 103 * @param deleteElement should the element not only be removed but also deleted 104 */ 105 void removeElement(VoiceElement* element, bool deleteElement = true); 106 107 void updateAccidentals(); 108 private: 109 class Private; 110 Private * const d; 111 }; 112 113 } // namespace MusicCore 114 115 #endif // MUSIC_CORE_VOICEBAR_H 116