MuseScore  3.4
Music composition and notation
instrwidget.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2014 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __INSTRWIDGET_H__
14 #define __INSTRWIDGET_H__
15 
16 #include "ui_instrwidget.h"
17 #include "libmscore/clef.h"
18 
19 class QTreeWidgetItem;
20 
21 namespace Ms {
22 
23 //class EditInstrument;
24 class InstrumentTemplate;
25 class Instrument;
26 class Part;
27 class Staff;
28 class StaffType;
29 class Score;
30 class InstrumentGenre;
31 
32 enum class ListItemOp : char { KEEP, I_DELETE, ADD, UPDATE };
33 enum { PART_LIST_ITEM = QTreeWidgetItem::UserType, STAFF_LIST_ITEM };
34 
35 //---------------------------------------------------------
36 // PartListItem
37 //---------------------------------------------------------
38 
39 class PartListItem : public QTreeWidgetItem {
40 
41  public:
45 
46  PartListItem(Part* p, QTreeWidget* lv);
47  PartListItem(const InstrumentTemplate* i, QTreeWidget* lv);
48  bool visible() const;
49  void setVisible(bool val);
50  void updateClefs();
51  };
52 
53 //---------------------------------------------------------
54 // StaffListItem
55 //---------------------------------------------------------
56 
57 class StaffListItem : public QObject, public QTreeWidgetItem {
58  Q_OBJECT
59  int _partIdx;
60  bool _linked;
61  ClefTypeList _defaultClefType; // clef for "normal" stafftype
62  ClefTypeList _clefType; // actual clef
63  QComboBox* _staffTypeCombo { nullptr };
64  Staff* _staff { 0 };
66  static int customStandardIdx;
67  static int customPercussionIdx;
68  static int customTablatureIdx;
69  static constexpr int CUSTOM_STAFF_TYPE_IDX = -1000;
70 
71  int staffTypeIdx(int idx) const;
72 
73  private slots:
74  void staffTypeChanged(int);
75 
76  public:
77  StaffListItem();
79 
80  int partIdx() const { return _partIdx; }
81  void setPartIdx(int val);
82 
83  void setClefType(const ClefTypeList& val);
84  const ClefTypeList& clefType() const { return _clefType; }
85 
86  void setDefaultClefType(const ClefTypeList& val) { _defaultClefType = val; }
87  const ClefTypeList& defaultClefType() const { return _defaultClefType; }
88 
89  void setLinked(bool val);
90  bool linked() const { return _linked; }
91  void setStaffType(const StaffType*);
92  void setStaffType(int);
93  const StaffType* staffType() const;
94  int staffTypeIdx() const;
95  void initStaffTypeCombo(bool forceRecreate = false);
96 
97  QComboBox* staffTypeCombo() { return _staffTypeCombo; }
98 
99  Staff* staff() const { return _staff; }
100  void setStaff(Staff* s) { _staff = s; }
101  ListItemOp op() const { return _op; }
102  void setOp(ListItemOp v) { _op = v; }
103  };
104 
105 //---------------------------------------------------------
106 // InstrumentTemplateListItem
107 //---------------------------------------------------------
108 
109 class InstrumentTemplateListItem : public QTreeWidgetItem {
111  QString _group;
112 
113  public:
114  InstrumentTemplateListItem(QString group, QTreeWidget* parent);
116  InstrumentTemplateListItem(InstrumentTemplate* i, QTreeWidget* parent);
117 
118  InstrumentTemplate* instrumentTemplate() const { return _instrumentTemplate; }
119  virtual QString text(int col) const;
120  };
121 
122 
123 //---------------------------------------------------------
124 // InstrumentsWidget
125 //---------------------------------------------------------
126 
127 class InstrumentsWidget : public QWidget, public Ui::InstrumentsWidget {
128  Q_OBJECT
129 
130  private slots:
131  void on_instrumentList_itemSelectionChanged();
132  void on_instrumentList_itemActivated(QTreeWidgetItem* item, int);
133  void on_partiturList_itemSelectionChanged();
134  void on_addButton_clicked();
135  void on_removeButton_clicked();
136  void on_upButton_clicked();
137  void on_downButton_clicked();
138  StaffListItem* on_addStaffButton_clicked();
139  void on_addLinkedStaffButton_clicked();
140 
141  void on_instrumentSearch_textChanged(const QString &);
142 
143  void on_instrumentGenreFilter_currentIndexChanged(int);
144  void filterInstrumentsByGenre(QTreeWidget *, QString);
145 
146  public slots:
147  void buildTemplateList();
148 
149  signals:
150  void completeChanged(bool);
151 
152  public:
153  InstrumentsWidget(QWidget* parent = 0);
154  void genPartList(Score*);
155  void init();
156  void createInstruments(Score*);
157  QTreeWidget* getPartiturList();
158  };
159 
160 extern void populateInstrumentList(QTreeWidget* instrumentList);
161 extern void populateGenreCombo(QComboBox* combo);
162 
163 } // namespace Ms
164 
165 extern QList<Ms::InstrumentGenre *> instrumentGenres;
166 
167 #endif
168 
static int customTablatureIdx
Definition: instrwidget.h:68
Global staff data not directly related to drawing.
Definition: staff.h:62
InstrumentTemplate * instrumentTemplate() const
Definition: instrwidget.h:118
Definition: instrwidget.h:109
Definition: instrwidget.h:39
ListItemOp op() const
Definition: instrwidget.h:101
static int customPercussionIdx
Definition: instrwidget.h:67
int partIdx() const
Definition: instrwidget.h:80
void createInstruments(Score *score, QList< MTrack > &tracks)
Definition: importmidi_instrument.cpp:385
void setOp(ListItemOp v)
Definition: instrwidget.h:102
bool _linked
Definition: instrwidget.h:60
void setStaff(Staff *s)
Definition: instrwidget.h:100
Definition: clef.h:81
Staff * staff() const
Definition: instrwidget.h:99
Definition of classes Clef.
ClefTypeList _clefType
Definition: instrwidget.h:62
Definition: score.h:391
InstrumentTemplate * _instrumentTemplate
Definition: instrwidget.h:110
Definition: instrwidget.h:33
Definition: instrwidget.h:57
void populateInstrumentList(QTreeWidget *instrumentList)
Definition: instrwidget.cpp:420
Part * part
Definition: instrwidget.h:43
QList< InstrumentGenre * > instrumentGenres
Definition: instrtemplate.cpp:27
ClefTypeList _defaultClefType
Definition: instrwidget.h:61
void setDefaultClefType(const ClefTypeList &val)
Definition: instrwidget.h:86
Definition: aeolus.cpp:26
static int customStandardIdx
Definition: instrwidget.h:66
ListItemOp
Definition: instrwidget.h:32
QString _group
Definition: instrwidget.h:111
Definition: stafftype.h:173
void populateGenreCombo(QComboBox *combo)
Definition: instrwidget.cpp:399
const ClefTypeList & clefType() const
Definition: instrwidget.h:84
Definition: instrwidget.h:33
bool linked() const
Definition: instrwidget.h:90
const ClefTypeList & defaultClefType() const
Definition: instrwidget.h:87
Definition: instrwidget.h:127
int _partIdx
Definition: instrwidget.h:59
ListItemOp op
Definition: instrwidget.h:42
Definition: instrtemplate.h:48
QComboBox * staffTypeCombo()
Definition: instrwidget.h:97
Definition: part.h:47
const InstrumentTemplate * it
Definition: instrwidget.h:44