1 //=============================================================================
2 //  MuseScore
3 //  Linux Music Score Editor
4 //
5 //  Copyright (C) 2002-2011 Werner Schweer and others
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 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //=============================================================================
19 
20 /**
21  \file
22  Implementation of class Selection plus other selection related functions.
23 */
24 
25 #include "libmscore/select.h"
26 #include "selectnotedialog.h"
27 #include "libmscore/element.h"
28 #include "libmscore/system.h"
29 #include "libmscore/score.h"
30 #include "libmscore/chord.h"
31 #include "libmscore/sym.h"
32 #include "libmscore/segment.h"
33 #include "musescore.h"
34 
35 namespace Ms {
36 
37 //---------------------------------------------------------
38 //   SelectDialog
39 //---------------------------------------------------------
40 
SelectNoteDialog(const Note * _n,QWidget * parent)41 SelectNoteDialog::SelectNoteDialog(const Note* _n, QWidget* parent)
42    : QDialog(parent)
43       {
44       setObjectName("SelectNoteDialog");
45       setupUi(this);
46       setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
47       n = _n;
48       notehead->setText(NoteHead::group2userName(n->headGroup()));
49       pitch->setText(n->tpcUserName());
50       string->setText(QString::number(n->string()+1));
51       type->setText(n->noteTypeUserName());
52       durationType->setText(tr("%1 Note").arg(n->chord()->durationType().durationTypeUserName()));
53       durationTicks->setText(n->chord()->durationUserName());
54       name->setText(tpc2name(n->tpc(), NoteSpellingType::STANDARD, NoteCaseType::AUTO, false));
55       inSelection->setEnabled(n->score()->selection().isRange());
56       MuseScore::restoreGeometry(this);
57       }
58 
59 //---------------------------------------------------------
60 //   setPattern
61 //---------------------------------------------------------
62 
setPattern(NotePattern * p)63 void SelectNoteDialog::setPattern(NotePattern* p)
64       {
65       if (sameNotehead->isChecked())
66             p->notehead = n->headGroup();
67       if (samePitch->isChecked())
68             p->pitch = n->pitch();
69       if (sameString->isChecked())
70             p->string = n->string();
71       if (sameName->isChecked())
72             p->tpc = n->tpc();
73       if (sameType->isChecked())
74             p->type = n->noteType();
75       if (sameDurationType->isChecked())
76             p->durationType = n->chord()->actualDurationType();
77       if (sameBeat->isChecked())
78             p->beat = n->beat();
79       else
80             p->beat = Fraction(0,0);
81       if (sameMeasure->isChecked())
82             p->measure = n->findMeasure();
83       else
84             p->measure = nullptr;
85       if (sameDurationTicks->isChecked())
86             p->durationTicks = n->chord()->actualTicks();
87       else
88             p->durationTicks = Fraction(-1,1);
89       if (sameStaff->isChecked()) {
90             p->staffStart = n->staffIdx();
91             p->staffEnd = n->staffIdx() + 1;
92             }
93       else if (inSelection->isChecked()) {
94             p->staffStart = n->score()->selection().staffStart();
95             p->staffEnd = n->score()->selection().staffEnd();
96             }
97       else {
98             p->staffStart = -1;
99             p->staffEnd = -1;
100             }
101 
102       p->voice   = sameVoice->isChecked() ? n->voice() : -1;
103       if (sameSystem->isChecked())
104             p->system = n->chord()->segment()->system();
105       }
106 
107 //---------------------------------------------------------
108 //   hideEvent
109 //---------------------------------------------------------
110 
hideEvent(QHideEvent * event)111 void SelectNoteDialog::hideEvent(QHideEvent* event)
112       {
113       MuseScore::saveGeometry(this);
114       QWidget::hideEvent(event);
115       }
116 
117 }
118 
119