⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventeditdialog.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//*    Rosegarden    A MIDI and audio sequencer and musical notation editor.     This program is Copyright 2000-2007        Guillaume Laurent   <glaurent@telegraph-road.org>,        Chris Cannam        <cannam@all-day-breakfast.com>,        Richard Bown        <richard.bown@ferventsoftware.com>     The moral rights of Guillaume Laurent, Chris Cannam, and Richard    Bown to claim authorship of this work have been asserted.     Other copyrights also apply to some parts of this work.  Please    see the AUTHORS file and individual file headers for details.     This program is free software; you can redistribute it and/or    modify it under the terms of the GNU General Public License as    published by the Free Software Foundation; either version 2 of the    License, or (at your option) any later version.  See the file    COPYING included with this distribution for more information.*/#include "EventEditDialog.h"#include <klocale.h>#include "misc/Strings.h"#include "base/Event.h"#include "base/MidiTypes.h"#include "base/NotationTypes.h"#include "base/PropertyName.h"#include "base/RealTime.h"#include "gui/editors/notation/NotePixmapFactory.h"#include <kdialogbase.h>#include <kmessagebox.h>#include <qcheckbox.h>#include <qfont.h>#include <qgrid.h>#include <qgroupbox.h>#include <qhbox.h>#include <qlabel.h>#include <qlineedit.h>#include <qobject.h>#include <qobjectlist.h>#include <qpushbutton.h>#include <qscrollview.h>#include <qsize.h>#include <qspinbox.h>#include <qstring.h>#include <qtooltip.h>#include <qvbox.h>#include <qwidget.h>namespace Rosegarden{EventEditDialog::EventEditDialog(QWidget *parent,                                 const Event &event,                                 bool editable) :        KDialogBase(parent, 0, true, i18n(editable ? "Advanced Event Edit" : "Advanced Event Viewer"),                    (editable ? (Ok | Cancel) : Ok)),        m_durationDisplay(0),        m_durationDisplayAux(0),        m_persistentGrid(0),        m_nonPersistentGrid(0),        m_nonPersistentView(0),        m_originalEvent(event),        m_event(event),        m_type(event.getType()),        m_absoluteTime(event.getAbsoluteTime()),        m_duration(event.getDuration()),        m_subOrdering(event.getSubOrdering()),        m_modified(false){    QVBox *vbox = makeVBoxMainWidget();    QGroupBox *intrinsicBox = new QGroupBox                              (1, Horizontal, i18n("Intrinsics"), vbox);    QGrid *intrinsicGrid = new QGrid(4, QGrid::Horizontal, intrinsicBox);    new QLabel(i18n("Event type: "), intrinsicGrid);    new QLabel("", intrinsicGrid);    new QLabel("", intrinsicGrid);    QLineEdit *lineEdit = new QLineEdit(intrinsicGrid);    lineEdit->setText(strtoqstr(event.getType()));    new QLabel(i18n("Absolute time: "), intrinsicGrid);    new QLabel("", intrinsicGrid);    new QLabel("", intrinsicGrid);    QSpinBox *absoluteTime = new QSpinBox                             (INT_MIN, INT_MAX, Note(Note::Shortest).getDuration(), intrinsicGrid);    absoluteTime->setValue(event.getAbsoluteTime());    QObject::connect(absoluteTime, SIGNAL(valueChanged(int)),                     this, SLOT(slotAbsoluteTimeChanged(int)));    slotAbsoluteTimeChanged(event.getAbsoluteTime());    new QLabel(i18n("Duration: "), intrinsicGrid);    m_durationDisplay = new QLabel("(note)", intrinsicGrid);    m_durationDisplay->setMinimumWidth(20);    m_durationDisplayAux = new QLabel("(note)", intrinsicGrid);    m_durationDisplayAux->setMinimumWidth(20);    QSpinBox *duration = new QSpinBox                         (0, INT_MAX, Note(Note::Shortest).getDuration(), intrinsicGrid);    duration->setValue(event.getDuration());    QObject::connect(duration, SIGNAL(valueChanged(int)),                     this, SLOT(slotDurationChanged(int)));    slotDurationChanged(event.getDuration());    new QLabel(i18n("Sub-ordering: "), intrinsicGrid);    new QLabel("", intrinsicGrid);    new QLabel("", intrinsicGrid);    QSpinBox *subOrdering = new QSpinBox( -100, 100, 1, intrinsicGrid);    subOrdering->setValue(event.getSubOrdering());    QObject::connect(subOrdering, SIGNAL(valueChanged(int)),                     this, SLOT(slotSubOrderingChanged(int)));    slotSubOrderingChanged(event.getSubOrdering());    QGroupBox *persistentBox = new QGroupBox                               (1, Horizontal, i18n("Persistent properties"), vbox);    m_persistentGrid = new QGrid(4, QGrid::Horizontal, persistentBox);    QLabel *label = new QLabel(i18n("Name"), m_persistentGrid);    QFont font(label->font());    font.setItalic(true);    label->setFont(font);    label = new QLabel(i18n("Type"), m_persistentGrid);    label->setFont(font);    label = new QLabel(i18n("Value"), m_persistentGrid);    label->setFont(font);    label = new QLabel("", m_persistentGrid);    label->setFont(font);    Event::PropertyNames p = event.getPersistentPropertyNames();    for (Event::PropertyNames::iterator i = p.begin();            i != p.end(); ++i) {        addPersistentProperty(*i);    }    p = event.getNonPersistentPropertyNames();    if (p.begin() == p.end()) {        m_nonPersistentView = 0;        m_nonPersistentGrid = 0;    } else {        QGroupBox *nonPersistentBox = new QGroupBox                                      (1, Horizontal, i18n("Non-persistent properties"), vbox);        new QLabel(i18n("These are cached values, lost if the event is modified."),                   nonPersistentBox);        m_nonPersistentView = new QScrollView(nonPersistentBox);        //m_nonPersistentView->setHScrollBarMode(QScrollView::AlwaysOff);        m_nonPersistentView->setResizePolicy(QScrollView::AutoOneFit);        m_nonPersistentGrid = new QGrid                              (4, QGrid::Horizontal, m_nonPersistentView->viewport());        m_nonPersistentView->addChild(m_nonPersistentGrid);        m_nonPersistentGrid->setSpacing(4);        m_nonPersistentGrid->setMargin(5);        label = new QLabel(i18n("Name       "), m_nonPersistentGrid);        label->setFont(font);        label = new QLabel(i18n("Type       "), m_nonPersistentGrid);        label->setFont(font);        label = new QLabel(i18n("Value      "), m_nonPersistentGrid);        label->setFont(font);        label = new QLabel("", m_nonPersistentGrid);        label->setFont(font);        for (Event::PropertyNames::iterator i = p.begin();                i != p.end(); ++i) {            new QLabel(strtoqstr(*i), m_nonPersistentGrid, strtoqstr(*i));            new QLabel(strtoqstr(event.getPropertyTypeAsString(*i)), m_nonPersistentGrid, strtoqstr(*i));            new QLabel(strtoqstr(event.getAsString(*i)), m_nonPersistentGrid, strtoqstr(*i));            QPushButton *button = new QPushButton("P", m_nonPersistentGrid, strtoqstr(*i));            button->setFixedSize(QSize(24, 24));            QToolTip::add                (button, i18n("Make persistent"));            QObject::connect(button, SIGNAL(clicked()),                             this, SLOT(slotPropertyMadePersistent()));        }    }}voidEventEditDialog::addPersistentProperty(const PropertyName &name){    QLabel *label = new QLabel(strtoqstr(name), m_persistentGrid, strtoqstr(name));    label->show();    label = new QLabel(strtoqstr(m_originalEvent.getPropertyTypeAsString(name)),                       m_persistentGrid, strtoqstr(name));    label->show();    PropertyType type(m_originalEvent.getPropertyType(name));    switch (type) {    case Int: {                int min = INT_MIN, max = INT_MAX;                // DMM - constrain program changes to a useful range of values                // Might other types have a similar need for such limits?                if (m_originalEvent.isa(ProgramChange::EventType)) {                min = 0;                max = 127;            }        QSpinBox *spinBox = new QSpinBox                            (min, max, 1, m_persistentGrid, strtoqstr(name));        spinBox->setValue(m_originalEvent.get<Int>(name));        QObject::connect(spinBox, SIGNAL(valueChanged(int)),                         this, SLOT(slotIntPropertyChanged(int)));        spinBox->show();        break;    }case UInt: {        int min = 0;        int max = UINT_MAX;        if (m_originalEvent.isa(ProgramChange::EventType)) {                min = 0;                max = 65535;            }            QSpinBox *spinBox = new QSpinBox                                (min, max, 1, m_persistentGrid, strtoqstr(name));            spinBox->setValue(m_originalEvent.get<UInt>(name));            QObject::connect(spinBox, SIGNAL(valueChanged(int)),                             this, SLOT(slotIntPropertyChanged(int)));            spinBox->show();            break;        }    case RealTimeT: {            RealTime realTime = m_originalEvent.get<RealTimeT>(name);            QHBox* hbox = new QHBox(m_persistentGrid);            // seconds            //            QSpinBox *spinBox = new QSpinBox                                (INT_MIN, INT_MAX, 1,                                 hbox, strtoqstr(name) + "%sec");            spinBox->setValue(realTime.sec);            QObject::connect(spinBox, SIGNAL(valueChanged(int)),                             this, SLOT(slotRealTimePropertyChanged(int)));            // nseconds            //            spinBox = new QSpinBox                      (INT_MIN, INT_MAX, 1,                       hbox, strtoqstr(name) + "%nsec");            spinBox->setValue(realTime.nsec);            QObject::connect(spinBox, SIGNAL(valueChanged(int)),                             this, SLOT(slotRealTimePropertyChanged(int)));            spinBox->show();            break;        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -