📄 eventfilterdialog.cpp
字号:
cfg->readUnsignedNumEntry("durationto", (m_noteDurationToComboBox->count() - 1)));}voidEventFilterDialog::slotToggleAll(){ RG_DEBUG << "EventFilterDialog::slotToggleAll()" << endl; m_pitchFromSpinBox ->setValue(0); m_pitchToSpinBox ->setValue(127); m_velocityFromSpinBox ->setValue(0); m_velocityToSpinBox ->setValue(127); m_noteDurationFromComboBox ->setCurrentItem(11); // hard coded; should be variable m_noteDurationToComboBox ->setCurrentItem(0); // 0 = unlimited; 11 = 0}voidEventFilterDialog::slotToggleNone(){ RG_DEBUG << "EventFilterDialog::slotToggleNone()" << endl; m_pitchFromSpinBox ->setValue(0); m_pitchToSpinBox ->setValue(0); m_velocityFromSpinBox ->setValue(0); m_velocityToSpinBox ->setValue(0); m_noteDurationFromComboBox ->setCurrentItem(11); m_noteDurationToComboBox ->setCurrentItem(11);}voidEventFilterDialog::slotOk(){ cfg->setGroup(EventFilterDialogConfigGroup); cfg->writeEntry("pitchinclude", m_notePitchIncludeComboBox->currentItem()); cfg->writeEntry("pitchfrom", m_pitchFromSpinBox->value()); cfg->writeEntry("pitchto", m_pitchToSpinBox->value()); cfg->writeEntry("velocityinclude", m_noteVelocityIncludeComboBox->currentItem()); cfg->writeEntry("velocityfrom", m_velocityFromSpinBox->value()); cfg->writeEntry("velocityto", m_velocityToSpinBox->value()); cfg->writeEntry("durationinclude", m_noteDurationIncludeComboBox->currentItem()); cfg->writeEntry("durationfrom", m_noteDurationFromComboBox->currentItem()); cfg->writeEntry("durationto", m_noteDurationToComboBox->currentItem()); accept();}voidEventFilterDialog::slotPitchFromChanged(int pitch){ if (pitch > m_pitchToSpinBox->value()) m_pitchToSpinBox->setValue(pitch);}voidEventFilterDialog::slotPitchToChanged(int pitch){ if (pitch < m_pitchFromSpinBox->value()) m_pitchFromSpinBox->setValue(pitch);}voidEventFilterDialog::slotVelocityFromChanged(int velocity){ if (velocity > m_velocityToSpinBox->value()) m_velocityToSpinBox->setValue(velocity);}voidEventFilterDialog::slotVelocityToChanged(int velocity){ if (velocity < m_velocityFromSpinBox->value()) m_velocityFromSpinBox->setValue(velocity);}voidEventFilterDialog::slotDurationFromChanged(int index){ if (index < m_noteDurationToComboBox->currentItem()) m_noteDurationToComboBox->setCurrentItem(index);}voidEventFilterDialog::slotDurationToChanged(int index){ if (index > m_noteDurationFromComboBox->currentItem()) m_noteDurationFromComboBox->setCurrentItem(index);}voidEventFilterDialog::slotPitchFromChooser(){ PitchPickerDialog dialog(this, m_pitchFromSpinBox->value(), i18n("Lowest pitch")); if (dialog.exec() == QDialog::Accepted) { m_pitchFromSpinBox->setValue(dialog.getPitch()); }}voidEventFilterDialog::slotPitchToChooser(){ PitchPickerDialog dialog(this, m_pitchToSpinBox->value(), i18n("Highest pitch")); if (dialog.exec() == QDialog::Accepted) { m_pitchToSpinBox->setValue(dialog.getPitch()); }}longEventFilterDialog::getDurationFromIndex(int index){ switch (index) { // 0 case 11: return 0; // 1/96 case 10: return long(Note(Note::SixtyFourthNote).getDuration() / 3); // 1/64 case 9 : return long(Note(Note::SixtyFourthNote).getDuration()); // 1/48 case 8 : return long(Note(Note::ThirtySecondNote).getDuration() / 3); // 1/32 case 7 : return long(Note(Note::ThirtySecondNote).getDuration()); // 1/24 case 6 : return long(Note(Note::SixteenthNote).getDuration() / 3); // 1/16 case 5 : return long(Note(Note::SixteenthNote).getDuration()); // 1/8 case 4 : return long(Note(Note::EighthNote).getDuration()); // 1/4 case 3 : return long(Note(Note::QuarterNote).getDuration()); // 1/2 case 2 : return long(Note(Note::HalfNote).getDuration()); // 1/1 case 1 : return long(Note(Note::WholeNote).getDuration()); // unlimited case 0 : return LONG_MAX; } // failsafe return LONG_MAX;}voidEventFilterDialog::invert(EventFilterDialog::filterRange &foo){ long c = foo.first; foo.first = foo.second; foo.second = c;}EventFilterDialog::filterRangeEventFilterDialog::getPitch(){ EventFilterDialog::filterRange foo; foo.first = m_pitchFromSpinBox->value(); foo.second = m_pitchToSpinBox ->value(); if (!pitchIsInclusive()) invert(foo); return foo;}EventFilterDialog::filterRangeEventFilterDialog::getVelocity(){ EventFilterDialog::filterRange foo; foo.first = m_velocityFromSpinBox->value(); foo.second = m_velocityToSpinBox ->value(); if (!velocityIsInclusive()) invert(foo); return foo;}EventFilterDialog::filterRangeEventFilterDialog::getDuration(){ EventFilterDialog::filterRange foo; foo.first = getDurationFromIndex(m_noteDurationFromComboBox->currentItem()); foo.second = getDurationFromIndex(m_noteDurationToComboBox ->currentItem()); if (!durationIsInclusive()) invert(foo); return foo;}boolEventFilterDialog::keepEvent(Event* const &e){ if ((*e).isa(Note::EventType)) { long property = 0; // pitch (*e).get<Int>(BaseProperties::PITCH, property); if (!eventInRange(getPitch(), property)) { RG_DEBUG << "EventFilterDialog::keepEvent(): rejecting event; pitch " << property << " out of range." << endl; return false; } property = 0; // velocity (*e).get<Int>(BaseProperties::VELOCITY, property); if (!EventFilterDialog::eventInRange(getVelocity(), property)) { RG_DEBUG << "EventFilterDialog::keepEvent(): rejecting event; velocity " << property << " out of range." << endl; return false; } property = 0; // duration property = (*e).getNotationDuration(); if (!EventFilterDialog::eventInRange(getDuration(), property)) { RG_DEBUG << "EventFilterDialog::keepEvent(): rejecting event; duration " << property << " out of range." << endl; return false; } property = 0; return true; } return false;}}#include "EventFilterDialog.moc"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -