1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4     Rosegarden
5     A MIDI and audio sequencer and musical notation editor.
6     Copyright 2000-2021 the Rosegarden development team.
7 
8     Other copyrights also apply to some parts of this work.  Please
9     see the AUTHORS file and individual file headers for details.
10 
11     This program is free software; you can redistribute it and/or
12     modify it under the terms of the GNU General Public License as
13     published by the Free Software Foundation; either version 2 of the
14     License, or (at your option) any later version.  See the file
15     COPYING included with this distribution for more information.
16 */
17 
18 #ifndef RG_CHORD_H
19 #define RG_CHORD_H
20 
21 #include "Fingering.h"
22 #include "base/Event.h"
23 #include "misc/Debug.h"
24 
25 #include <QString>
26 
27 #include <rosegardenprivate_export.h>
28 
29 namespace Rosegarden
30 {
31 
32 class Event;
33 
34 namespace Guitar
35 {
36 
37 class Chord
38 {
39     friend bool operator<(const Chord&, const Chord&);
40 
41 public:
42     static const std::string EventType;
43     static const short EventSubOrdering;
44 
45     Chord();
46     Chord(const QString& root, const QString& ext = QString());
47     Chord(const Event&);
48 
49     Event* getAsEvent(timeT absoluteTime) const;
50 
isEmpty()51     bool isEmpty() const   { return m_root.isEmpty(); }
52     //@@@ bool operator!() const { return !m_root; }
53 
isUserChord()54     bool isUserChord() const { return m_isUserChord; }
setUserChord(bool c)55     void setUserChord(bool c) { m_isUserChord = c; }
56 
getRoot()57     QString getRoot() const { return m_root; }
setRoot(QString r)58     void setRoot(QString r) { m_root = r; }
59 
getExt()60     QString getExt() const { return m_ext; }
setExt(QString r)61     void setExt(QString r) { m_ext = r.isEmpty() ? QString() : r; }
62 
63     bool hasAltBass() const;
64 
getFingering()65     Fingering getFingering() const { return m_fingering; }
setFingering(Fingering f)66     void setFingering(Fingering f) { m_fingering = f; }
67 
68     struct ChordCmp
69     {
operatorChordCmp70         bool operator()(const Chord &e1, const Chord &e2) const {
71             return e1 < e2;
72         }
operatorChordCmp73         bool operator()(const Chord *e1, const Chord *e2) const {
74             return *e1 < *e2;
75         }
76     };
77 
78 protected:
79 
80     QString m_root;
81     QString m_ext;
82 
83     Fingering m_fingering;
84 
85     bool m_isUserChord;
86 };
87 
88 bool operator<(const Chord&, const Chord&);
89 
90 }
91 
92 ROSEGARDENPRIVATE_EXPORT QDebug &operator<<(QDebug &, const Rosegarden::Guitar::Chord &);
93 
94 }
95 
96 #endif /*RG_CHORD_H*/
97