diff options
author | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
commit | e40fc849149dd97c248866a4a1d026dda5e57b62 (patch) | |
tree | b12b358f3b3a0608001d30403358f8443118ec5f /attic/muse2-oom/muse2/muse/liste | |
parent | 1bd4f2e8d9745cabb667b043171cad22c8577768 (diff) |
clean3
Diffstat (limited to 'attic/muse2-oom/muse2/muse/liste')
-rw-r--r-- | attic/muse2-oom/muse2/muse/liste/CMakeLists.txt | 97 | ||||
-rw-r--r-- | attic/muse2-oom/muse2/muse/liste/editctrlbase.ui | 875 | ||||
-rw-r--r-- | attic/muse2-oom/muse2/muse/liste/editevent.cpp | 897 | ||||
-rw-r--r-- | attic/muse2-oom/muse2/muse/liste/editevent.h | 198 | ||||
-rw-r--r-- | attic/muse2-oom/muse2/muse/liste/listedit.cpp | 927 | ||||
-rw-r--r-- | attic/muse2-oom/muse2/muse/liste/listedit.h | 79 |
6 files changed, 3073 insertions, 0 deletions
diff --git a/attic/muse2-oom/muse2/muse/liste/CMakeLists.txt b/attic/muse2-oom/muse2/muse/liste/CMakeLists.txt new file mode 100644 index 00000000..4c0b61a4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/liste/CMakeLists.txt @@ -0,0 +1,97 @@ +#============================================================================= +# MusE +# Linux Music Editor +# $Id:$ +# +# Copyright (C) 2002-2006 by Werner Schweer and others +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#============================================================================= + +## +## Expand Qt macros in source files +## +QT4_WRAP_CPP ( liste_mocs + # listedit.h + # ctrllistedit.h + # tracklistedit.h + # partlistedit.h + # ieventdialog.h + editevent.h + listedit.h + ) + +## +## UI files +## +file (GLOB liste_ui_files + editctrlbase.ui + ) +QT4_WRAP_UI ( liste_uis ${liste_ui_files} ) + +## +## List of source files to compile +## +file (GLOB liste_source_files + # listedit.cpp + # ctrllistedit.cpp + # partlistedit.cpp + # tracklistedit.cpp + # ieventdialog.cpp + editevent.cpp + listedit.cpp + ) + +## +## Define target +## +add_library ( liste SHARED + ${liste_source_files} + ${liste_mocs} + ${liste_uis} + ) + +## +## Append to the list of translations +## +set (FILES_TO_TRANSLATE + ${FILES_TO_TRANSLATE} + ${liste_source_files} + ${liste_ui_files} + CACHE INTERNAL "" + ) + +## +## Compilation flags and target name +## +set_target_properties( liste + PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC" + OUTPUT_NAME muse_liste + ) + +## +## Linkage +## +target_link_libraries ( liste + ${QT_LIBRARIES} + awl + widgets + ) + +## +## Install location +## +install(TARGETS liste + DESTINATION ${MusE_MODULES_DIR} + ) + diff --git a/attic/muse2-oom/muse2/muse/liste/editctrlbase.ui b/attic/muse2-oom/muse2/muse/liste/editctrlbase.ui new file mode 100644 index 00000000..7b4d68ec --- /dev/null +++ b/attic/muse2-oom/muse2/muse/liste/editctrlbase.ui @@ -0,0 +1,875 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>EditCtrlBase</class> + <widget class="QDialog" name="EditCtrlBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>601</width> + <height>413</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Edit Controller Event</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout"> + <item row="0" column="3"> + <widget class="QLabel" name="textLabel1"> + <property name="text"> + <string>Time Position</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="textLabel1_2"> + <property name="text"> + <string>Available Controller:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QPushButton" name="buttonNewController"> + <property name="text"> + <string>Create New Controller</string> + </property> + <property name="shortcut"> + <string/> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="Awl::PosEdit" name="timePos"/> + </item> + <item row="1" column="3" rowspan="2" colspan="2"> + <widget class="QStackedWidget" name="widgetStack"> + <property name="palette"> + <palette> + <active> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>238</red> + <green>234</green> + <blue>222</blue> + </color> + </brush> + </colorrole> + <colorrole role="Light"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Midlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>246</red> + <green>244</green> + <blue>238</blue> + </color> + </brush> + </colorrole> + <colorrole role="Dark"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>119</red> + <green>117</green> + <blue>111</blue> + </color> + </brush> + </colorrole> + <colorrole role="Mid"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>158</red> + <green>155</green> + <blue>147</blue> + </color> + </brush> + </colorrole> + <colorrole role="Text"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="BrightText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ButtonText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>104</red> + <green>137</green> + <blue>236</blue> + </color> + </brush> + </colorrole> + <colorrole role="Shadow"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Highlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + </brush> + </colorrole> + <colorrole role="HighlightedText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Link"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="LinkVisited"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>238</red> + <green>234</green> + <blue>222</blue> + </color> + </brush> + </colorrole> + <colorrole role="Light"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Midlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Dark"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>119</red> + <green>117</green> + <blue>111</blue> + </color> + </brush> + </colorrole> + <colorrole role="Mid"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>158</red> + <green>155</green> + <blue>147</blue> + </color> + </brush> + </colorrole> + <colorrole role="Text"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="BrightText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ButtonText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>104</red> + <green>137</green> + <blue>236</blue> + </color> + </brush> + </colorrole> + <colorrole role="Shadow"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Highlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + </brush> + </colorrole> + <colorrole role="HighlightedText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Link"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>192</blue> + </color> + </brush> + </colorrole> + <colorrole role="LinkVisited"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>128</red> + <green>0</green> + <blue>128</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + </brush> + </colorrole> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>238</red> + <green>234</green> + <blue>222</blue> + </color> + </brush> + </colorrole> + <colorrole role="Light"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Midlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Dark"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>119</red> + <green>117</green> + <blue>111</blue> + </color> + </brush> + </colorrole> + <colorrole role="Mid"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>158</red> + <green>155</green> + <blue>147</blue> + </color> + </brush> + </colorrole> + <colorrole role="Text"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + </brush> + </colorrole> + <colorrole role="BrightText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ButtonText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>104</red> + <green>137</green> + <blue>236</blue> + </color> + </brush> + </colorrole> + <colorrole role="Shadow"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Highlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + </brush> + </colorrole> + <colorrole role="HighlightedText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Link"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>192</blue> + </color> + </brush> + </colorrole> + <colorrole role="LinkVisited"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>128</red> + <green>0</green> + <blue>128</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <widget class="QWidget" name="WStackPage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>140</width> + <height>349</height> + </rect> + </property> + <layout class="QGridLayout"> + <item row="3" column="0" colspan="2"> + <widget class="QSlider" name="valSlider"> + <property name="maximum"> + <number>127</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="controllerName"> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="text"> + <string>textLabel3</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="textLabel4"> + <property name="text"> + <string>Value</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel2"> + <property name="text"> + <string>Controller</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="valSpinBox"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="0" column="1"> + <spacer name="spacer2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <widget class="QWidget" name="WStackPage2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>100</width> + <height>30</height> + </rect> + </property> + <layout class="QGridLayout"> + <item row="2" column="0"> + <widget class="QLabel" name="textLabel2_2"> + <property name="text"> + <string>H-Bank</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="textLabel3"> + <property name="text"> + <string>L-Bank</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="textLabel4_2"> + <property name="text"> + <string>Program</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="hbank"> + <property name="specialValueText"> + <string>off</string> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>128</number> + </property> + <property name="value"> + <number>0</number> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="lbank"> + <property name="specialValueText"> + <string>off</string> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>128</number> + </property> + <property name="value"> + <number>0</number> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QSpinBox" name="program"> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>128</number> + </property> + </widget> + </item> + <item row="0" column="0" colspan="2"> + <spacer name="spacer4"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>140</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QPushButton" name="patchName"> + <property name="text"> + <string>pushButton4</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item row="4" column="0" colspan="5"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="Horizontal Spacing2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>&OK</string> + </property> + <property name="shortcut"> + <string/> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonCancel"> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="shortcut"> + <string/> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="3" column="0" colspan="5"> + <widget class="Line" name="line1"> + <property name="frameShape"> + <enum>QFrame::HLine</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="lineWidth"> + <number>3</number> + </property> + <property name="midLineWidth"> + <number>2</number> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QListWidget" name="ctrlList"> + </widget> + </item> + <item row="2" column="1"> + <spacer name="spacer3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>60</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="2" rowspan="3"> + <widget class="Line" name="line2"> + <property name="frameShape"> + <enum>QFrame::VLine</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="lineWidth"> + <number>3</number> + </property> + <property name="midLineWidth"> + <number>2</number> + </property> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>Awl::PosEdit</class> + <extends>QWidget</extends> + <header>awl/posedit.h</header> + <container>0</container> + </customwidget> + </customwidgets> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>MyDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>MyDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>valSlider</sender> + <signal>valueChanged(int)</signal> + <receiver>valSpinBox</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>valSpinBox</sender> + <signal>valueChanged(int)</signal> + <receiver>valSlider</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/liste/editevent.cpp b/attic/muse2-oom/muse2/muse/liste/editevent.cpp new file mode 100644 index 00000000..b162a3e6 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/liste/editevent.cpp @@ -0,0 +1,897 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: editevent.cpp,v 1.12.2.6 2009/02/02 21:38:00 terminator356 Exp $ +// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> + +#include <QBoxLayout> +#include <QHBoxLayout> +#include <QGridLayout> +#include <QLabel> +#include <QListWidget> +#include <QMenu> +#include <QMessageBox> +#include <QPushButton> +#include <QRadioButton> +#include <QSlider> +#include <QSpinBox> +#include <QTextEdit> +#include <QVBoxLayout> + +#include "awl/posedit.h" + +#include "song.h" +#include "event.h" +#include "midictrl.h" +#include "editevent.h" +#include "pitchedit.h" +#include "intlabel.h" +#include "globals.h" +///#include "posedit.h" +#include "gconfig.h" +#include "midiport.h" +#include "midiedit/drummap.h" +#include "instruments/minstrument.h" +#include "midi.h" + +//--------------------------------------------------------- +// string2qhex +//--------------------------------------------------------- + +QString string2hex(const unsigned char* data, int len) + { + QString d; + QString s; + for (int i = 0; i < len; ++i) { + if ((i > 0) && ((i % 8)==0)) { + d += "\n"; + } + else if (i) + d += " "; + d += s.sprintf("%02x", data[i]); + } + return d; + } + +//--------------------------------------------------------- +// hex2string +//--------------------------------------------------------- + +char* hex2string(QWidget* parent, const char* src, int& len) + { + char buffer[2048]; + char* dst = buffer; + + while (*src) { + while (*src == ' ' || *src == '\n') + ++src; + char* ep; + long val = strtol(src, &ep, 16); + if (ep == src) { + QMessageBox::information(parent, + QString("MusE"), + QWidget::tr("Cannot convert sysex string")); + return 0; + } + src = ep; + *dst++ = val; + if (dst - buffer >= 2048) { + QMessageBox::information(parent, + QString("MusE"), + QWidget::tr("Hex String too long (2048 bytes limit)")); + return 0; + } + } + len = dst - buffer; + if(len == 0) + return 0; + char* b = new char[len+1]; + memcpy(b, buffer, len); + b[len] = 0; + return b; + } + +//--------------------------------------------------------- +// getEvent +//--------------------------------------------------------- + +Event EditNoteDialog::getEvent(int tick, const Event& event, QWidget* parent) + { + EditNoteDialog* dlg = new EditNoteDialog(tick, event, parent); + Event nevent; + if (dlg->exec() == QDialog::Accepted) { + nevent = dlg->event(); + } + delete dlg; + return nevent; + } + +Event EditSysexDialog::getEvent(int tick, const Event& event, QWidget* parent) + { + EditSysexDialog* dlg = new EditSysexDialog(tick, event, parent); + Event nevent; + if (dlg->exec() == QDialog::Accepted) { + nevent = dlg->event(); + } + delete dlg; + return nevent; + } + +Event EditMetaDialog::getEvent(int tick, const Event& event, QWidget* parent) + { + EditEventDialog* dlg = new EditMetaDialog(tick, event, parent); + Event nevent; + if (dlg->exec() == QDialog::Accepted) { + nevent = dlg->event(); + } + delete dlg; + return nevent; + } + +Event EditCAfterDialog::getEvent(int tick, const Event& event, QWidget* parent) + { + EditEventDialog* dlg = new EditCAfterDialog(tick, event, parent); + Event nevent; + if (dlg->exec() == QDialog::Accepted) { + nevent = dlg->event(); + } + delete dlg; + return nevent; + } + +Event EditPAfterDialog::getEvent(int tick, const Event& event, QWidget* parent) + { + EditEventDialog* dlg = new EditPAfterDialog(tick, event, parent); + Event nevent; + if (dlg->exec() == QDialog::Accepted) { + nevent = dlg->event(); + } + delete dlg; + return nevent; + } + +//--------------------------------------------------------- +// EditEventDialog +//--------------------------------------------------------- + +EditEventDialog::EditEventDialog(QWidget* parent) + : QDialog(parent) + { + QVBoxLayout* xlayout = new QVBoxLayout; + layout1 = new QGridLayout; // ddskrjo this + xlayout->addLayout(layout1); + + //--------------------------------------------------- + // Ok, Cancel + //--------------------------------------------------- + + QBoxLayout* w5 = new QHBoxLayout; // ddskrjo this + QPushButton* okB = new QPushButton(tr("Ok")); + okB->setDefault(true); + QPushButton* cancelB = new QPushButton(tr("Cancel")); + okB->setFixedWidth(80); + cancelB->setFixedWidth(80); + w5->addWidget(okB); + w5->addSpacing(12); + w5->addWidget(cancelB); + w5->addStretch(1); + xlayout->addLayout(w5); + setLayout(xlayout); + connect(cancelB, SIGNAL(clicked()), SLOT(reject())); + connect(okB, SIGNAL(clicked()), SLOT(accept())); + } + +//--------------------------------------------------------- +// EditNoteDialog +//--------------------------------------------------------- + +EditNoteDialog::EditNoteDialog(int tick, const Event& event, + QWidget* parent) + : QDialog(parent) + { + setupUi(this); + if (!event.empty()) { + epos->setValue(tick); + il1->setValue(event.lenTick()); + pl->setValue(event.pitch()); + il2->setValue(event.velo()); + il3->setValue(event.veloOff()); + } + else { + epos->setValue(tick); + il1->setValue(96); + pl->setValue(64); + il2->setValue(100); + il3->setValue(0); + } + } + +//--------------------------------------------------------- +// EditNoteDialog::event +//--------------------------------------------------------- + +Event EditNoteDialog::event() + { + Event event(Note); + event.setTick(epos->pos().tick()); + event.setA(pl->value()); + event.setB(il2->value()); + event.setC(il3->value()); + event.setLenTick(il1->value()); + return event; + } + +//--------------------------------------------------------- +// EditSysExDialog +//--------------------------------------------------------- + +EditSysexDialog::EditSysexDialog(int tick, const Event& event, + QWidget* parent) + : QDialog(parent) + { + setupUi(this); + sysex = 0; + if (!event.empty()) { + epos->setValue(tick); + edit->setText(string2hex(event.data(), event.dataLen())); + } + else { + epos->setValue(tick); + } + } + +//--------------------------------------------------------- +// ~EditSysexDialog +//--------------------------------------------------------- + +EditSysexDialog::~EditSysexDialog() + { + if (sysex) + delete sysex; + } + +//--------------------------------------------------------- +// EditSysExDialog::event +//--------------------------------------------------------- + +Event EditSysexDialog::event() + { + Event event(Sysex); + event.setTick(epos->pos().tick()); + event.setData(sysex, len); + return event; + } + +//--------------------------------------------------------- +// accept +//--------------------------------------------------------- + +void EditSysexDialog::accept() + { + QString qsrc = edit->toPlainText(); + QByteArray ba = qsrc.toLatin1(); + const char* src = ba.constData(); + + sysex = (unsigned char*)hex2string(this, src, len); + if (sysex) + QDialog::accept(); + } + +//--------------------------------------------------------- +// EditMetaDialog +//--------------------------------------------------------- + +EditMetaDialog::EditMetaDialog(int tick, const Event& ev, + QWidget* parent) + : EditEventDialog(parent) + { + meta = 0; + setWindowTitle(tr("MusE: Enter Meta Event")); + + QLabel* l1 = new QLabel(tr("Time Position")); + ///epos = new PosEdit; + epos = new Awl::PosEdit; + + QLabel* l2 = new QLabel(tr("Meta Type")); + il2 = new IntLabel(-1, 0, 127, this, -1); + il2->setFixedWidth(100); + il2->setFrame(true); + il2->setDark(); + typeLabel = new QLabel; + typeLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + QHBoxLayout* typeLayout = new QHBoxLayout; + typeLayout->addWidget(il2); + typeLayout->addWidget(typeLabel); + typeLayout->addStretch(); + + hexButton = new QRadioButton(tr("Enter Hex")); + hexButton->setChecked(true); + connect(hexButton, SIGNAL(toggled(bool)), SLOT(toggled(bool))); + + edit = new QTextEdit; + edit->setFont(config.fonts[5]); + + if (!ev.empty()) { + epos->setValue(tick); + il2->setValue(ev.dataA()); + toggled(true); + edit->setText(string2hex(ev.data(), ev.dataLen())); + } + else { + epos->setValue(tick); + il2->setValue(0); + } + + typeChanged(il2->value()); + connect(il2, SIGNAL(valueChanged(int)), SLOT(typeChanged(int))); + + layout1->addWidget(l1, 0, 0); + layout1->addWidget(epos, 0, 1, Qt::AlignLeft); + layout1->addWidget(l2, 1, 0); + + //layout1->addWidget(il2, 1, 1, AlignLeft); + layout1->addLayout(typeLayout, 1, 1); + + //layout1->addMultiCellWidget(hexButton, 2, 2, 0, 1); + //layout1->addMultiCellWidget(edit, 3, 3, 0, 1); + layout1->addWidget(hexButton, 2, 0, 1, 2); + layout1->addWidget(edit, 3, 0, 1, 2); + } + +//--------------------------------------------------------- +// typeChanged +//--------------------------------------------------------- + +void EditMetaDialog::typeChanged(int val) +{ + typeLabel->setText(midiMetaName(val)); +} + +//--------------------------------------------------------- +// toggled +//--------------------------------------------------------- + +void EditMetaDialog::toggled(bool flag) + { + QString qsrc = edit->toPlainText(); + QByteArray ba = qsrc.toLatin1(); + const char* src = ba.constData(); + edit->clear(); + + QString dst; + if (flag) { // convert to hex + dst = string2hex((unsigned char*)src, strlen(src)); + } + else { // convert to string + int len; + dst = hex2string(this, src, len); + } + edit->setText(dst); + } + +//--------------------------------------------------------- +// ~EditMetaDialog +//--------------------------------------------------------- + +EditMetaDialog::~EditMetaDialog() + { + if (meta) + delete meta; + } + +//--------------------------------------------------------- +// EditMetaDialog::event +//--------------------------------------------------------- + +Event EditMetaDialog::event() + { + Event event(Meta); + event.setTick(epos->pos().tick()); + event.setA(il2->value()); + event.setData(meta, len); // TODO ?? + return event; + } + +//--------------------------------------------------------- +// accept +//--------------------------------------------------------- + +void EditMetaDialog::accept() + { + QString qsrc = edit->toPlainText(); + QByteArray ba = qsrc.toLatin1(); + const char* src = ba.constData(); + if (!hexButton->isChecked()) { + meta = (unsigned char*)strdup(src); + len = strlen(src); + QDialog::accept(); + return; + } + + meta = (unsigned char*)hex2string(this, src, len); + if (meta) + QDialog::accept(); + } + +//--------------------------------------------------------- +// EditCAfterDialog +//--------------------------------------------------------- + +EditCAfterDialog::EditCAfterDialog(int tick, const Event& event, + QWidget* parent) + : EditEventDialog(parent) + { + setWindowTitle(tr("MusE: Enter Channel Aftertouch")); + + QLabel* l1 = new QLabel(tr("Time Position")); + ///epos = new PosEdit; + epos = new Awl::PosEdit; + + QLabel* l2 = new QLabel(tr("Pressure")); + il2 = new IntLabel(-1, 0, 127, this, -1); + il2->setFrame(true); + il2->setDark(); + + QSlider* slider = new QSlider(Qt::Horizontal); + slider->setMinimum(0); + slider->setMaximum(127); + slider->setPageStep(1); + slider->setValue(0); + + connect(slider, SIGNAL(valueChanged(int)), il2, SLOT(setValue(int))); + connect(il2, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int))); + + if (!event.empty()) { + epos->setValue(tick); + il2->setValue(event.dataA()); + slider->setValue(event.dataA()); + } + else { + epos->setValue(tick); + il2->setValue(64); + slider->setValue(64); + } + + layout1->addWidget(l1, 0, 0); + layout1->addWidget(epos, 0, 1, Qt::AlignLeft); + layout1->addWidget(l2, 1, 0); + layout1->addWidget(il2, 1, 1, Qt::AlignLeft); + //layout1->addMultiCellWidget(slider, 2, 2, 0, 1); + layout1->addWidget(slider, 2, 0, 1, 2); + } + +//--------------------------------------------------------- +// EditCAfterDialog::event +//--------------------------------------------------------- + +Event EditCAfterDialog::event() + { + Event event(CAfter); + event.setTick(epos->pos().tick()); + event.setA(il2->value()); + return event; + } + +//--------------------------------------------------------- +// EditPAfterDialog +//--------------------------------------------------------- + +EditPAfterDialog::EditPAfterDialog(int tick, const Event& event, + QWidget* parent) + : EditEventDialog(parent) + { + setWindowTitle(tr("MusE: Enter Poly Aftertouch")); + + QLabel* l1 = new QLabel(tr("Time Position")); + ///epos = new PosEdit; + epos = new Awl::PosEdit; + + QLabel* l2 = new QLabel(tr("Pitch")); + pl = new PitchEdit; + QLabel* l3 = new QLabel(tr("Pressure")); + il2 = new IntLabel(-1, 0, 127, this, -1); + il2->setFrame(true); + il2->setDark(); + + QSlider* slider = new QSlider(Qt::Horizontal); + slider->setMinimum(0); + slider->setMaximum(127); + slider->setPageStep(1); + slider->setValue(0); + + connect(slider, SIGNAL(valueChanged(int)), il2, SLOT(setValue(int))); + connect(il2, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int))); + + if (!event.empty()) { + epos->setValue(tick); + pl->setValue(event.pitch()); + il2->setValue(event.dataB()); + slider->setValue(event.dataB()); + } + else { + epos->setValue(tick); + pl->setValue(64); + il2->setValue(64); + slider->setValue(64); + } + + layout1->addWidget(l1, 0, 0); + layout1->addWidget(epos, 0, 1, Qt::AlignLeft); + layout1->addWidget(l2, 1, 0); + layout1->addWidget(pl, 1, 1, Qt::AlignLeft); + layout1->addWidget(l3, 2, 0); + layout1->addWidget(il2, 2, 1, Qt::AlignLeft); + //layout1->addMultiCellWidget(slider, 3, 3, 0, 1); + layout1->addWidget(slider, 3, 0, 1, 2); + } + +//--------------------------------------------------------- +// EditPAfterDialog::event +//--------------------------------------------------------- + +Event EditPAfterDialog::event() + { + Event event(PAfter); + event.setTick(epos->pos().tick()); + event.setA(pl->value()); + event.setB(il2->value()); + return event; + } +//--------------------------------------------------------- +// getEvent +//--------------------------------------------------------- + +Event EditCtrlDialog::getEvent(int tick, const Event& event, + const MidiPart* part, QWidget* parent) + { + EditCtrlDialog* dlg = new EditCtrlDialog(tick, event, part, parent); + Event nevent; + if (dlg->exec() == QDialog::Accepted) { + nevent = dlg->event(); + } + delete dlg; + return nevent; + } + +//--------------------------------------------------------- +// EditCtrlDialog::event +//--------------------------------------------------------- + +Event EditCtrlDialog::event() + { + Event event(Controller); + event.setTick(timePos->pos().tick()); + event.setA(num); + if (num == CTRL_PROGRAM) + event.setB(val); + else + event.setB(valSlider->value() + midiPorts[part->track()->outPort()].midiController(num)->bias()); + return event; + } + +//--------------------------------------------------------- +// EditCtrlDialog +// PosEdit* timePos; +// QSlider* valSlider; +// QSpinBox* valSpinBox; +// QLabel* controllerName; +// QListWidget* ctrlList; +// QPushButton* buttonNewController; +//--------------------------------------------------------- + +EditCtrlDialog::EditCtrlDialog(int tick, const Event& event, + const MidiPart* p, QWidget* parent) + : QDialog(parent), part(p) + { + setupUi(this); + widgetStack->setAutoFillBackground(true); + val = 0; + num = 0; + if (!event.empty()) { + num = event.dataA(); + val = event.dataB(); + } + + ///pop = new QMenu(this); + //pop->setCheckable(false);//not necessary in Qt4 + + MidiTrack* track = part->track(); + int portn = track->outPort(); + MidiPort* port = &midiPorts[portn]; + bool isDrum = track->type() == Track::DRUM; + MidiCtrlValListList* cll = port->controller(); + + ctrlList->clear(); + ctrlList->setSelectionMode(QAbstractItemView::SingleSelection); + + // + // populate list of available controller + // + + std::list<QString> sList; + typedef std::list<QString>::iterator isList; + + for (iMidiCtrlValList i = cll->begin(); i != cll->end(); ++i) { + MidiCtrlValList* cl = i->second; + int num = cl->num(); + + // dont show drum specific controller if not a drum track + if ((num & 0xff) == 0xff) { + if (!isDrum) + continue; + } + MidiController* c = port->midiController(num); + isList i = sList.begin(); + for (; i != sList.end(); ++i) { + if (*i == c->name()) + break; + } + if (i == sList.end()) + sList.push_back(c->name()); + } + MidiController* mc = port->midiController(num); + int idx = 0; + int selectionIndex = 0; + for (isList i = sList.begin(); i != sList.end(); ++i, ++idx) { + ctrlList->addItem(*i); + if (mc->name() == *i) + selectionIndex = idx; + } + ctrlList->item(selectionIndex)->setSelected(true); + + valSlider->setRange(mc->minVal(), mc->maxVal()); + valSpinBox->setRange(mc->minVal(), mc->maxVal()); + + controllerName->setText(mc->name()); + + if(!event.empty()) + { + if(num == CTRL_PROGRAM) + { + widgetStack->setCurrentIndex(1); + updatePatch(); + } + else + { + widgetStack->setCurrentIndex(0); + valSlider->setValue(val - mc->bias()); + } + } + else + ctrlListClicked(ctrlList->selectedItems()[0]); + connect(ctrlList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(ctrlListClicked(QListWidgetItem*))); + connect(buttonNewController, SIGNAL(clicked()), SLOT(newController())); + connect(hbank, SIGNAL(valueChanged(int)), SLOT(programChanged())); + connect(lbank, SIGNAL(valueChanged(int)), SLOT(programChanged())); + connect(program, SIGNAL(valueChanged(int)), SLOT(programChanged())); + connect(patchName, SIGNAL(released()), SLOT(instrPopup())); + connect(buttonCancel, SIGNAL(clicked()), SLOT(reject())); + connect(buttonOk, SIGNAL(clicked()), SLOT(accept())); + timePos->setValue(tick); + + } +//--------------------------------------------------------- +// newController +//--------------------------------------------------------- + +void EditCtrlDialog::newController() + { + QMenu* pup = new QMenu(this); + //pup->setCheckable(this);//not necessary in Qt4 + // + // populate popup with all controllers available for + // current instrument + // + MidiTrack* track = part->track(); + int portn = track->outPort(); + MidiPort* port = &midiPorts[portn]; + MidiInstrument* instr = port->instrument(); + MidiControllerList* mcl = instr->controller(); + + MidiCtrlValListList* cll = port->controller(); + int channel = track->outChannel(); + int nn = 0; + for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) + { + if(cll->find(channel, ci->second->num()) == cll->end()) + { + QAction* act = pup->addAction(ci->second->name()); + act->setData(nn); + ++nn; + } + } + QAction* rv = pup->exec(buttonNewController->mapToGlobal(QPoint(0,0))); + if (rv) { + QString s = rv->text(); + for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) { + MidiController* mc = ci->second; + if (mc->name() == s) { + if(cll->find(channel, mc->num()) == cll->end()) + { + MidiCtrlValList* vl = new MidiCtrlValList(mc->num()); + cll->add(channel, vl); + //song->update(SC_MIDI_CONTROLLER_ADD); + } + for (int idx = 0; ;++idx) { + QString str = ctrlList->item(idx)->text(); + if (s == str) + { + ctrlList->item(idx)->setSelected(true); + ctrlListClicked(ctrlList->item(idx)); + break; + } + if (str.isNull()) { + ctrlList->addItem(s); + ctrlList->item(idx)->setSelected(true); + ctrlListClicked(ctrlList->item(idx)); + break; + } + } + + break; + } + } + } + delete pup; + } +//--------------------------------------------------------- +// ctrlListClicked +//--------------------------------------------------------- + +void EditCtrlDialog::ctrlListClicked(QListWidgetItem* item) + { + if (item == 0) + return; + QString s(item->text()); + + MidiTrack* track = part->track(); + int portn = track->outPort(); + MidiPort* port = &midiPorts[portn]; + MidiCtrlValListList* cll = port->controller(); + + iMidiCtrlValList i; + for (i = cll->begin(); i != cll->end(); ++i) { + MidiCtrlValList* cl = i->second; + num = cl->num(); + MidiController* c = port->midiController(num); + if (s == c->name()) { + if (num == CTRL_PROGRAM) { + widgetStack->setCurrentIndex(1); + + val = c->initVal(); + if(val == CTRL_VAL_UNKNOWN) + val = 0; + updatePatch(); + } + else { + widgetStack->setCurrentIndex(0); + valSlider->setRange(c->minVal(), c->maxVal()); + valSpinBox->setRange(c->minVal(), c->maxVal()); + controllerName->setText(s); + val = c->initVal(); + + if(val == CTRL_VAL_UNKNOWN || val == 0) + { + switch(num) + { + case CTRL_PANPOT: + val = 64 - c->bias(); + break; + case CTRL_VOLUME: + val = 100; + break; + default: + val = 0; + break; + } + } + valSlider->setValue(val); + } + break; + } + } + if (i == cll->end()) + printf("controller %s not found!\n", s.toLatin1().constData()); + } + +//--------------------------------------------------------- +// updatePatch +//--------------------------------------------------------- + +void EditCtrlDialog::updatePatch() + { + MidiTrack* track = part->track(); + int port = track->outPort(); + int channel = track->outChannel(); + MidiInstrument* instr = midiPorts[port].instrument(); + patchName->setText(instr->getPatchName(channel, val, song->mtype(), track->type() == Track::DRUM)); + + int hb = ((val >> 16) & 0xff) + 1; + if (hb == 0x100) + hb = 0; + int lb = ((val >> 8) & 0xff) + 1; + if (lb == 0x100) + lb = 0; + int pr = (val & 0xff) + 1; + if (pr == 0x100) + pr = 0; + + hbank->blockSignals(true); + lbank->blockSignals(true); + program->blockSignals(true); + + hbank->setValue(hb); + lbank->setValue(lb); + program->setValue(pr); + + hbank->blockSignals(false); + lbank->blockSignals(false); + program->blockSignals(false); + } + +//--------------------------------------------------------- +// instrPopup +//--------------------------------------------------------- + +void EditCtrlDialog::instrPopup() + { + MidiTrack* track = part->track(); + int channel = track->outChannel(); + int port = track->outPort(); + MidiInstrument* instr = midiPorts[port].instrument(); + + ///instr->populatePatchPopup(pop, channel, song->mtype(), track->type() == Track::DRUM); + QMenu* pup = new QMenu(this); + instr->populatePatchPopup(pup, channel, song->mtype(), track->type() == Track::DRUM); + + ///if(pop->actions().count() == 0) + /// return; + if(pup->actions().count() == 0) + { + delete pup; + return; + } + + ///QAction* rv = pop->exec(patchName->mapToGlobal(QPoint(10,5))); + QAction* rv = pup->exec(patchName->mapToGlobal(QPoint(10,5))); + if (rv) { + val = rv->data().toInt(); + updatePatch(); + } + + delete pup; + } + +//--------------------------------------------------------- +// programChanged +//--------------------------------------------------------- + +void EditCtrlDialog::programChanged() + { +// MidiTrack* track = part->track(); +// int channel = track->outChannel(); +// int port = track->outPort(); + int hb = hbank->value(); + int lb = lbank->value(); + int prog = program->value(); + + if (hb > 0 && hb < 129) + hb -= 1; + else + hb = 0xff; + if (lb > 0 && lb < 129) + lb -= 1; + else + lb = 0xff; + if (prog > 0 && prog < 129) + prog -= 1; + else + prog = 0xff; + + val = (hb << 16) + (lb << 8) + prog; + updatePatch(); + } + diff --git a/attic/muse2-oom/muse2/muse/liste/editevent.h b/attic/muse2-oom/muse2/muse/liste/editevent.h new file mode 100644 index 00000000..454e6a69 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/liste/editevent.h @@ -0,0 +1,198 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: editevent.h,v 1.6.2.1 2008/05/21 00:28:53 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __EDIT_EVENT_H__ +#define __EDIT_EVENT_H__ + +#include "ui_editnotedialogbase.h" +#include "ui_editsysexdialogbase.h" +#include "ui_editctrlbase.h" +#include "event.h" + +namespace Awl { + class PosEdit; + }; + +///class PosEdit; +class IntLabel; +class PitchEdit; +class QDialog; +class QLabel; +class QGridLayout; +class QTextEdit; +class QRadioButton; +class MidiPart; +class QListWidgetItem; +class QMenu; +//--------------------------------------------------------- +// EditEventDialog +//--------------------------------------------------------- + +class EditEventDialog : public QDialog { + Q_OBJECT + + protected: + QGridLayout* layout1; + + public: + EditEventDialog(QWidget* parent=0); + virtual Event event() = 0; + }; + +//--------------------------------------------------------- +// EditNoteDialog +//--------------------------------------------------------- + +class EditNoteDialog : public QDialog, public Ui::EditNoteDialogBase { + Q_OBJECT + + public: + EditNoteDialog(int tick, const Event&, + QWidget* parent=0); + static Event getEvent(int tick, const Event&, + QWidget* parent = 0); + virtual Event event(); + }; + +//--------------------------------------------------------- +// EditSysExDialog +//--------------------------------------------------------- + +class EditSysexDialog : public QDialog, public Ui::EditSysexDialogBase { + Q_OBJECT + + unsigned char* sysex; + int len; + + protected: + QGridLayout* layout; + + private slots: + virtual void accept(); + + public: + EditSysexDialog(int tick, const Event&, + QWidget* parent=0); + ~EditSysexDialog(); + static Event getEvent(int tick, const Event&, + QWidget* parent = 0); + virtual Event event(); + }; + +//--------------------------------------------------------- +// EditCtrlDialog +//--------------------------------------------------------- + +class EditCtrlDialog : public QDialog, public Ui::EditCtrlBase { + Q_OBJECT + + int num; // controller number + int val; // controller value (for prog. changes) + + const MidiPart* part; + ///QMenu* pop; + + void updatePatch(); + + private slots: + void ctrlListClicked(QListWidgetItem*); + void newController(); + void programChanged(); + void instrPopup(); + + protected: + QGridLayout* layout; + + + public: + EditCtrlDialog(int tick, const Event&, + const MidiPart*, QWidget* parent=0); + static Event getEvent(int tick, const Event&, const MidiPart*, + QWidget* parent = 0); + virtual Event event(); + }; + +//--------------------------------------------------------- +// EditMetaDialog +//--------------------------------------------------------- + +class EditMetaDialog : public EditEventDialog { + Q_OBJECT + + unsigned char* meta; + int len; + ///PosEdit* epos; + Awl::PosEdit* epos; + QTextEdit* edit; + IntLabel* il2; + QRadioButton* hexButton; + QLabel* typeLabel; + + protected: + QGridLayout* layout; + + private slots: + virtual void accept(); + void toggled(bool); + void typeChanged(int); + + public: + EditMetaDialog(int tick, const Event&, + QWidget* parent=0); + ~EditMetaDialog(); + static Event getEvent(int tick, const Event&, + QWidget* parent = 0); + virtual Event event(); + }; + +//--------------------------------------------------------- +// EditCAfterDialog +//--------------------------------------------------------- + +class EditCAfterDialog : public EditEventDialog { + Q_OBJECT + + ///PosEdit* epos; + Awl::PosEdit* epos; + IntLabel* il2; + + protected: + QGridLayout* layout; + + public: + EditCAfterDialog(int tick, const Event&, + QWidget* parent=0); + static Event getEvent(int tick, const Event&, + QWidget* parent = 0); + virtual Event event(); + }; + +//--------------------------------------------------------- +// EditPAfterDialog +//--------------------------------------------------------- + +class EditPAfterDialog : public EditEventDialog { + Q_OBJECT + + ///PosEdit* epos; + Awl::PosEdit* epos; + PitchEdit* pl; + IntLabel* il2; + + protected: + QGridLayout* layout; + + public: + EditPAfterDialog(int tick, const Event&, + QWidget* parent=0); + static Event getEvent(int tick, const Event&, + QWidget* parent = 0); + virtual Event event(); + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/liste/listedit.cpp b/attic/muse2-oom/muse2/muse/liste/listedit.cpp new file mode 100644 index 00000000..3f29176c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/liste/listedit.cpp @@ -0,0 +1,927 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: listedit.cpp,v 1.11.2.11 2009/05/24 21:43:44 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QAction> +#include <QActionGroup> +#include <QCloseEvent> +#include <QKeyEvent> +#include <QMenu> +#include <QMenuBar> +#include <QSignalMapper> +#include <QToolBar> +#include <QTreeWidgetItem> + +#include "listedit.h" +#include "mtscale.h" +#include "globals.h" +#include "icons.h" +#include "editevent.h" +#include "xml.h" +#include "pitchedit.h" +#include "song.h" +#include "audio.h" +#include "shortcuts.h" +#include "midi.h" +#include "event.h" +#include "midiport.h" +#include "midictrl.h" + +//--------------------------------------------------------- +// EventListItem +//--------------------------------------------------------- + +class EventListItem : public QTreeWidgetItem { + public: + Event event; + MidiPart* part; + + EventListItem(QTreeWidget* parent, Event ev, MidiPart* p) + : QTreeWidgetItem(parent) { + event = ev; + part = p; + } + virtual QString text(int col) const; + + + virtual bool operator< ( const QTreeWidgetItem & other ) const + { + int col = other.treeWidget()->sortColumn(); + EventListItem* eli = (EventListItem*) &other; + switch(col) + { + case 0: + return event.tick() < eli->event.tick(); + break; + case 1: + return part->tick() + event.tick() < (eli->part->tick() + eli->event.tick()); + break; + case 2: + return text(col).localeAwareCompare(other.text(col)) < 0; + break; + case 3: + return part->track()->outChannel() < eli->part->track()->outChannel(); + break; + case 4: + return event.dataA() < eli->event.dataA(); + break; + case 5: + return event.dataB() < eli->event.dataB(); + break; + case 6: + return event.dataC() < eli->event.dataC(); + break; + case 7: + return event.lenTick() < eli->event.lenTick(); + break; + case 8: + return text(col).localeAwareCompare(other.text(col)) < 0; + break; + default: + break; + } + return 0; + } + }; + +/*--------------------------------------------------------- + * midi_meta_name + *---------------------------------------------------------*/ + +static QString midiMetaComment(const Event& ev) + { + int meta = ev.dataA(); + QString s = midiMetaName(meta); + + switch (meta) { + case 0: + case 0x2f: + case 0x51: + case 0x54: + case 0x58: + case 0x59: + case 0x74: + case 0x7f: return s; + + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 0x0a: + case 0x0b: + case 0x0c: + case 0x0d: + case 0x0e: + case 0x0f: + { + s += QString(": "); + const char* txt = (char*)(ev.data()); + int len = ev.dataLen(); + char buffer[len+1]; + memcpy(buffer, txt, len); + buffer[len] = 0; + + for (int i = 0; i < len; ++i) { + if (buffer[i] == '\n' || buffer[i] == '\r') + buffer[i] = ' '; + } + return s + QString(buffer); + } + + case 0x20: + case 0x21: + default: + { + s += QString(": "); + int i; + int len = ev.lenTick(); + int n = len > 10 ? 10 : len; + for (i = 0; i < n; ++i) { + if (i >= ev.dataLen()) + break; + s += QString(" 0x"); + QString k; + k.setNum(ev.data()[i] & 0xff, 16); + s += k; + } + if (i == 10) + s += QString("..."); + return s; + } + } + } + +//--------------------------------------------------------- +// closeEvent +//--------------------------------------------------------- + +void ListEdit::closeEvent(QCloseEvent* e) + { + emit deleted((unsigned long)this); + e->accept(); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void ListEdit::songChanged(int type) + { + if (type == 0) + return; + if (type & (SC_PART_REMOVED | SC_PART_MODIFIED + | SC_PART_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED + | SC_EVENT_INSERTED | SC_SELECTION)) { + if (type & (SC_PART_REMOVED | SC_PART_INSERTED)) + genPartlist(); + // close window if editor has no parts anymore + if (parts()->empty()) { + close(); + return; + } + liste->setSortingEnabled(false); + if (type == SC_SELECTION) { + bool update = false; + QTreeWidgetItem* ci = 0; + for (int row = 0; row < liste->topLevelItemCount(); ++row) { + QTreeWidgetItem* i = liste->topLevelItem(row); + if (i->isSelected() ^ ((EventListItem*)i)->event.selected()) { + i->setSelected(((EventListItem*)i)->event.selected()); + if (i->isSelected()) + ci = i; + update = true; + } + } + if (update) { + if (ci) + liste->setCurrentItem(ci); + //liste->update(); + } + } + else { + curPart = 0; + curTrack = 0; + liste->clear(); + for (iPart p = parts()->begin(); p != parts()->end(); ++p) { + MidiPart* part = (MidiPart*) (p->second); + if (part->sn() == curPartId) + curPart = part; + EventList* el = part->events(); + for (iEvent i = el->begin(); i != el->end(); ++i) { + EventListItem* item = new EventListItem(liste, i->second, part); + for (int col = 0; col < liste->columnCount(); ++col) + item->setText(col, item->text(col)); + item->setSelected(i->second.selected()); + if (item->event.tick() == (unsigned) selectedTick) { //prevent compiler warning: comparison of signed/unsigned) + liste->setCurrentItem(item); + item->setSelected(true); + liste->scrollToItem(item, QAbstractItemView::EnsureVisible); + } + } + } + } + + // p3.3.34 + //if (curPart == 0) + // curPart = (MidiPart*)(parts()->begin()->second); + //curTrack = curPart->track(); + if(!curPart) + { + if(!parts()->empty()) + { + curPart = (MidiPart*)(parts()->begin()->second); + if(curPart) + curTrack = curPart->track(); + else + curPart = 0; + } + } + } + liste->setSortingEnabled(true); + } + +//--------------------------------------------------------- +// text +//--------------------------------------------------------- + +QString EventListItem::text(int col) const + { + QString s; + QString commentLabel; + switch(col) { + case 0: + s.setNum(event.tick()); + break; + case 1: + { + int t = event.tick() + part->tick(); + int bar, beat; + unsigned tick; + AL::sigmap.tickValues(t, &bar, &beat, &tick); + s.sprintf("%04d.%02d.%03d", bar+1, beat+1, tick); + } + break; + case 2: + switch(event.type()) { + case Note: + s = QString("Note"); + break; + case Controller: + { + const char* cs; + switch (midiControllerType(event.dataA())) { + case MidiController::Controller7: cs = "Ctrl7"; break; + case MidiController::Controller14: cs = "Ctrl14"; break; + case MidiController::RPN: cs = "RPN"; break; + case MidiController::NRPN: cs = "NRPN"; break; + case MidiController::Pitch: cs = "Pitch"; break; + case MidiController::Program: cs = "Program"; break; + case MidiController::RPN14: cs = "RPN14"; break; + case MidiController::NRPN14: cs = "NRPN14"; break; + default: cs = "Ctrl?"; break; + } + s = QString(cs); + } + break; + case Sysex: + { + commentLabel = QString("len "); + QString k; + k.setNum(event.dataLen()); + commentLabel += k; + commentLabel += QString(" "); + + commentLabel += nameSysex(event.dataLen(), event.data()); + int i; + for (i = 0; i < 10; ++i) { + if (i >= event.dataLen()) + break; + commentLabel += QString(" 0x"); + QString k; + k.setNum(event.data()[i] & 0xff, 16); + commentLabel += k; + } + if (i == 10) + commentLabel += QString("..."); + } + s = QString("SysEx"); + break; + case PAfter: + s = QString("PoAT"); + break; + case CAfter: + s = QString("ChAT"); + break; + case Meta: + commentLabel = midiMetaComment(event); + s = QString("Meta"); + break; + case Wave: + break; + default: + printf("unknown event type %d\n", event.type()); + } + break; + case 3: + s.setNum(part->track()->outChannel() + 1); + break; + case 4: + if (event.isNote() || event.type() == PAfter) + s = pitch2string(event.dataA()); + else if (event.type() == Controller) + s.setNum(event.dataA() & 0xffff); // mask off type bits + else + s.setNum(event.dataA()); + break; + case 5: + if(event.type() == Controller && + midiControllerType(event.dataA()) == MidiController::Program) + { + int val = event.dataB(); + int hb = ((val >> 16) & 0xff) + 1; + if (hb == 0x100) + hb = 0; + int lb = ((val >> 8) & 0xff) + 1; + if (lb == 0x100) + lb = 0; + int pr = (val & 0xff) + 1; + if (pr == 0x100) + pr = 0; + s.sprintf("%d-%d-%d", hb, lb, pr); + } + else + s.setNum(event.dataB()); + break; + case 6: + s.setNum(event.dataC()); + break; + case 7: + s.setNum(event.lenTick()); + break; + case 8: + switch(event.type()) { + case Controller: + { + MidiPort* mp = &midiPorts[part->track()->outPort()]; + MidiController* mc = mp->midiController(event.dataA()); + s = mc->name(); + } + break; + case Sysex: + { + s = QString("len "); + QString k; + k.setNum(event.dataLen()); + s += k; + s += QString(" "); + + commentLabel += nameSysex(event.dataLen(), event.data()); + int i; + for (i = 0; i < 10; ++i) { + if (i >= event.dataLen()) + break; + s += QString(" 0x"); + QString k; + k.setNum(event.data()[i] & 0xff, 16); + s += k; + } + if (i == 10) + s += QString("..."); + } + break; + case Meta: + s = midiMetaComment(event); + break; + default: + break; + } + break; + + } + return s; + } + +//--------------------------------------------------------- +// ListEdit +//--------------------------------------------------------- + +ListEdit::ListEdit(PartList* pl) + : MidiEditor(0, 0, pl) + { + insertItems = new QActionGroup(this); + insertItems->setExclusive(false); + insertNote = new QAction(QIcon(*note1Icon), tr("insert Note"), insertItems); + insertSysEx = new QAction(QIcon(*sysexIcon), tr("insert SysEx"), insertItems); + insertCtrl = new QAction(QIcon(*ctrlIcon), tr("insert Ctrl"), insertItems); + insertMeta = new QAction(QIcon(*metaIcon), tr("insert Meta"), insertItems); + insertCAfter = new QAction(QIcon(*cafterIcon), tr("insert Channel Aftertouch"), insertItems); + insertPAfter = new QAction(QIcon(*pafterIcon), tr("insert Poly Aftertouch"), insertItems); + + connect(insertNote, SIGNAL(activated()), SLOT(editInsertNote())); + connect(insertSysEx, SIGNAL(activated()), SLOT(editInsertSysEx())); + connect(insertCtrl, SIGNAL(activated()), SLOT(editInsertCtrl())); + connect(insertMeta, SIGNAL(activated()), SLOT(editInsertMeta())); + connect(insertCAfter, SIGNAL(activated()), SLOT(editInsertCAfter())); + connect(insertPAfter, SIGNAL(activated()), SLOT(editInsertPAfter())); + + //---------Pulldown Menu---------------------------- + + QSignalMapper *editSignalMapper = new QSignalMapper(this); + + menuEdit = menuBar()->addMenu(tr("&Edit")); + menuEdit->addActions(undoRedo->actions()); + + menuEdit->addSeparator(); +#if 0 + QAction *cutAction = menuEdit->addAction(QIcon(*editcutIconSet), tr("Cut")); + connect(cutAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); + editSignalMapper->setMapping(cutAction, EList::CMD_CUT); + cutAction->setShortcut(Qt::CTRL+Qt::Key_X); + QAction *copyAction = menuEdit->addAction(QIcon(*editcopyIconSet), tr("Copy")); + connect(copyAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); + editSignalMapper->setMapping(cutAction, EList::CMD_COPY); + copyAction->setShortcut(Qt::CTRL+Qt::Key_C); + QAction *pasteAction = menuEdit->addAction(QIcon(*editpasteIconSet), tr("Paste")); + connect(pasteAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); + editSignalMapper->setMapping(cutAction, EList::CMD_PASTE); + pasteAction->setShortcut(Qt::CTRL+Qt::Key_V); + menuEdit->insertSeparator(); +#endif + QAction *deleteAction = menuEdit->addAction(tr("Delete Events")); + connect(deleteAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); + editSignalMapper->setMapping(deleteAction, CMD_DELETE); + deleteAction->setShortcut(Qt::Key_Delete); + menuEdit->addSeparator(); + + menuEdit->addActions(insertItems->actions()); + + connect(editSignalMapper, SIGNAL(mapped(int)), SLOT(cmd(int))); + + //---------ToolBar---------------------------------- + + listTools = addToolBar(tr("List tools")); + listTools->addActions(undoRedo->actions()); + + QToolBar* insertTools = addToolBar(tr("Insert tools")); + insertTools->addActions(insertItems->actions()); + + // + //--------------------------------------------------- + // liste + //--------------------------------------------------- + // + + liste = new QTreeWidget(mainw); + QFontMetrics fm(liste->font()); + int n = fm.width('9'); + int b = 24; + int c = fm.width(QString("Val B")); + int sortIndW = n * 3; + liste->setAllColumnsShowFocus(true); + liste->sortByColumn(0, Qt::AscendingOrder); + + liste->setSelectionMode(QAbstractItemView::ExtendedSelection); + + QStringList columnnames; + columnnames << tr("Tick") + << tr("Bar") + << tr("Type") + << tr("Ch") + << tr("Val A") + << tr("Val B") + << tr("Val C") + << tr("Len") + << tr("Comment"); + + liste->setHeaderLabels(columnnames); + + liste->setColumnWidth(0, n * 6 + b); + liste->setColumnWidth(1, fm.width(QString("9999.99.999")) + b); + liste->setColumnWidth(2, fm.width(QString("Program")) + b); + liste->setColumnWidth(3, n * 2 + b + sortIndW); + liste->setColumnWidth(4, c + b + sortIndW); + liste->setColumnWidth(5, c + b + sortIndW); + liste->setColumnWidth(6, c + b + sortIndW); + liste->setColumnWidth(7, n * 4 + b + sortIndW); + liste->setColumnWidth(8, fm.width(QString("MainVolume")) + 70); + + connect(liste, SIGNAL(itemSelectionChanged()), SLOT(selectionChanged())); + connect(liste, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(doubleClicked(QTreeWidgetItem*))); + //--------------------------------------------------- + // Rest + //--------------------------------------------------- + + mainGrid->setRowStretch(1, 100); + mainGrid->setColumnStretch(0, 100); + mainGrid->addWidget(liste, 1, 0, 2, 1); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + songChanged(-1); + + // p3.3.34 + // Was crashing because of -1 stored, because there was an invalid + // part pointer stored. + //curPart = (MidiPart*)(pl->begin()->second); + if(pl->empty()) + { + curPart = 0; + curPartId = -1; + } + else + { + curPart = (MidiPart*)pl->begin()->second; + if(curPart) + curPartId = curPart->sn(); + else + { + curPart = 0; + curPartId = -1; + } + } + + initShortcuts(); + } + +//--------------------------------------------------------- +// ~ListEdit +//--------------------------------------------------------- + +ListEdit::~ListEdit() + { + // undoRedo->removeFrom(listTools); // p4.0.6 Removed + } + +//--------------------------------------------------------- +// editInsertNote +//--------------------------------------------------------- + +void ListEdit::editInsertNote() + { + // p3.3.34 + if(!curPart) + return; + + Event event = EditNoteDialog::getEvent(curPart->tick(), Event(), this); + if (!event.empty()) { + //No events before beginning of part + take Part offset into consideration + unsigned tick = event.tick(); + if (tick < curPart->tick()) + tick = 0; + else + tick-= curPart->tick(); + event.setTick(tick); + // Indicate do undo, and do not handle port controller values. + //audio->msgAddEvent(event, curPart); + audio->msgAddEvent(event, curPart, true, false, false); + } + } + +//--------------------------------------------------------- +// editInsertSysEx +//--------------------------------------------------------- + +void ListEdit::editInsertSysEx() + { + // p3.3.34 + if(!curPart) + return; + + Event event = EditSysexDialog::getEvent(curPart->tick(), Event(), this); + if (!event.empty()) { + //No events before beginning of part + take Part offset into consideration + unsigned tick = event.tick(); + if (tick < curPart->tick()) + tick = 0; + else + tick-= curPart->tick(); + event.setTick(tick); + // Indicate do undo, and do not handle port controller values. + //audio->msgAddEvent(event, curPart); + audio->msgAddEvent(event, curPart, true, false, false); + } + } + +//--------------------------------------------------------- +// editInsertCtrl +//--------------------------------------------------------- + +void ListEdit::editInsertCtrl() + { + // p3.3.34 + if(!curPart) + return; + + Event event = EditCtrlDialog::getEvent(curPart->tick(), Event(), curPart, this); + if (!event.empty()) { + //No events before beginning of part + take Part offset into consideration + unsigned tick = event.tick(); + if (tick < curPart->tick()) + tick = 0; + else + tick-= curPart->tick(); + event.setTick(tick); + // Indicate do undo, and do port controller values and clone parts. + //audio->msgAddEvent(event, curPart); + audio->msgAddEvent(event, curPart, true, true, true); + } + } + +//--------------------------------------------------------- +// editInsertMeta +//--------------------------------------------------------- + +void ListEdit::editInsertMeta() + { + // p3.3.34 + if(!curPart) + return; + + Event event = EditMetaDialog::getEvent(curPart->tick(), Event(), this); + if (!event.empty()) { + //No events before beginning of part + take Part offset into consideration + unsigned tick = event.tick(); + if (tick < curPart->tick()) + tick = 0; + else + tick-= curPart->tick(); + event.setTick(tick); + // Indicate do undo, and do not handle port controller values. + //audio->msgAddEvent(event, curPart); + audio->msgAddEvent(event, curPart, true, false, false); + } + } + +//--------------------------------------------------------- +// editInsertCAfter +//--------------------------------------------------------- + +void ListEdit::editInsertCAfter() + { + // p3.3.34 + if(!curPart) + return; + + Event event = EditCAfterDialog::getEvent(curPart->tick(), Event(), this); + if (!event.empty()) { + //No events before beginning of part + take Part offset into consideration + unsigned tick = event.tick(); + if (tick < curPart->tick()) + tick = 0; + else + tick-= curPart->tick(); + event.setTick(tick); + // Indicate do undo, and do not handle port controller values. + //audio->msgAddEvent(event, curPart); + audio->msgAddEvent(event, curPart, true, false, false); + } + } + +//--------------------------------------------------------- +// editInsertPAfter +//--------------------------------------------------------- + +void ListEdit::editInsertPAfter() + { + // p3.3.34 + if(!curPart) + return; + + Event ev; + Event event = EditPAfterDialog::getEvent(curPart->tick(), ev, this); + if (!event.empty()) { + //No events before beginning of part + take Part offset into consideration + unsigned tick = event.tick(); + if (tick < curPart->tick()) + tick = 0; + else + tick-= curPart->tick(); + event.setTick(tick); + // Indicate do undo, and do not handle port controller values. + //audio->msgAddEvent(event, curPart); + audio->msgAddEvent(event, curPart, true, false, false); + } + } + +//--------------------------------------------------------- +// editEvent +//--------------------------------------------------------- + +void ListEdit::editEvent(Event& event, MidiPart* part) + { + int tick = event.tick() + part->tick(); + Event nevent; + switch(event.type()) { + case Note: + nevent = EditNoteDialog::getEvent(tick, event, this); + break; + case Controller: + nevent = EditCtrlDialog::getEvent(tick, event, part, this); + break; + case Sysex: + nevent = EditSysexDialog::getEvent(tick, event, this); + break; + case PAfter: + nevent = EditPAfterDialog::getEvent(tick, event, this); + break; + case CAfter: + nevent = EditCAfterDialog::getEvent(tick, event, this); + break; + case Meta: + nevent = EditMetaDialog::getEvent(tick, event, this); + break; + default: + return; + } + if (!nevent.empty()) { + // TODO: check for event != nevent + int tick = nevent.tick() - part->tick(); + nevent.setTick(tick); + if (tick < 0) + printf("event not in part %d - %d - %d, not changed\n", part->tick(), + nevent.tick(), part->tick() + part->lenTick()); + else + { + if(event.type() == Controller) + // Indicate do undo, and do port controller values and clone parts. + //audio->msgChangeEvent(event, nevent, part); + audio->msgChangeEvent(event, nevent, part, true, true, true); + else + // Indicate do undo, and do not do port controller values and clone parts. + //audio->msgChangeEvent(event, nevent, part); + audio->msgChangeEvent(event, nevent, part, true, false, false); + } + } + } + +//--------------------------------------------------------- +// readStatus +//--------------------------------------------------------- + +void ListEdit::readStatus(Xml& xml) + { + for (;;) { + Xml::Token token = xml.parse(); + const QString& tag = xml.s1(); + if (token == Xml::Error || token == Xml::End) + break; + switch (token) { + case Xml::TagStart: + if (tag == "midieditor") + MidiEditor::readStatus(xml); + else + xml.unknown("ListEdit"); + break; + case Xml::TagEnd: + if (tag == "listeditor") + return; + default: + break; + } + } + } + +//--------------------------------------------------------- +// writeStatus +//--------------------------------------------------------- + +void ListEdit::writeStatus(int level, Xml& xml) const + { + writePartList(level, xml); + xml.tag(level++, "listeditor"); + MidiEditor::writeStatus(level, xml); + xml.tag(level, "/listeditor"); + } + +//--------------------------------------------------------- +// selectionChanged +//--------------------------------------------------------- + +void ListEdit::selectionChanged() + { + bool update = false; + for (int row = 0; row < liste->topLevelItemCount(); ++row) { + QTreeWidgetItem* i = liste->topLevelItem(row); + if (i->isSelected() ^ ((EventListItem*)i)->event.selected()) { + ((EventListItem*)i)->event.setSelected(i->isSelected()); + update = true; + } + } + if (update) + song->update(SC_SELECTION); + } + +//--------------------------------------------------------- +// doubleClicked +//--------------------------------------------------------- + +void ListEdit::doubleClicked(QTreeWidgetItem* item) + { + EventListItem* ev = (EventListItem*) item; + selectedTick = ev->event.tick(); + editEvent(ev->event, ev->part); + } + +//--------------------------------------------------------- +// cmd +//--------------------------------------------------------- + +void ListEdit::cmd(int cmd) + { + switch(cmd) { + case CMD_DELETE: + bool found = false; + for (int row = 0; row < liste->topLevelItemCount(); ++row) + { + QTreeWidgetItem* i = liste->topLevelItem(row); + EventListItem *item = (EventListItem *) i; + if (i->isSelected() || item->event.selected()) + { + found = true; + break; + } + } + if(!found) + break; + song->startUndo(); + + EventListItem *deletedEvent=NULL; + for (int row = 0; row < liste->topLevelItemCount(); ++row) { + QTreeWidgetItem* i = liste->topLevelItem(row); + EventListItem *item = (EventListItem *) i; + + if (i->isSelected() || item->event.selected()) { + deletedEvent=item; + // Indicate no undo, and do port controller values and clone parts. + //audio->msgDeleteEvent(item->event, item->part, false); + audio->msgDeleteEvent(item->event, item->part, false, true, true); + } + } + + unsigned int nextTick=0; + // find biggest tick + for (int row = 0; row < liste->topLevelItemCount(); ++row) { + QTreeWidgetItem* i = liste->topLevelItem(row); + EventListItem *item = (EventListItem *) i; + if (item->event.tick() > nextTick && item != deletedEvent) + nextTick=item->event.tick(); + } + // check if there's a tick that is "just" bigger than the deleted + for (int row = 0; row < liste->topLevelItemCount(); ++row) { + QTreeWidgetItem* i = liste->topLevelItem(row); + EventListItem *item = (EventListItem *) i; + if (item->event.tick() >= deletedEvent->event.tick() && + item->event.tick() < nextTick && + item != deletedEvent ) { + nextTick=item->event.tick(); + } + } + selectedTick=nextTick; + song->endUndo(SC_EVENT_MODIFIED); + //printf("selected tick = %d\n", selectedTick); + //emit selectionChanged(); + break; + } + } + +//--------------------------------------------------------- +// configChanged +//--------------------------------------------------------- + +void ListEdit::configChanged() + { + initShortcuts(); + } + +//--------------------------------------------------------- +// initShortcuts +//--------------------------------------------------------- + +void ListEdit::initShortcuts() + { + insertNote->setShortcut(shortcuts[SHRT_LE_INS_NOTES].key); + insertSysEx->setShortcut(shortcuts[SHRT_LE_INS_SYSEX].key); + insertCtrl->setShortcut(shortcuts[SHRT_LE_INS_CTRL].key); + insertMeta->setShortcut(shortcuts[SHRT_LE_INS_META].key); + insertCAfter->setShortcut(shortcuts[SHRT_LE_INS_CHAN_AFTERTOUCH].key); + insertPAfter->setShortcut(shortcuts[SHRT_LE_INS_POLY_AFTERTOUCH].key); + } + +//--------------------------------------------------------- +// viewKeyPressEvent +//--------------------------------------------------------- + +void ListEdit::keyPressEvent(QKeyEvent* event) + { +int key = event->key(); +if (key == Qt::Key_Escape) { + close(); + return; + } + } diff --git a/attic/muse2-oom/muse2/muse/liste/listedit.h b/attic/muse2-oom/muse2/muse/liste/listedit.h new file mode 100644 index 00000000..5cf60a59 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/liste/listedit.h @@ -0,0 +1,79 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: listedit.h,v 1.3.2.3 2006/09/19 22:03:33 spamatica Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __LIST_EDIT_H__ +#define __LIST_EDIT_H__ + +#include "midieditor.h" +#include "noteinfo.h" +#include "cobject.h" + +class QAction; +class QActionGroup; +class QCloseEvent; +class QKeyEvent; +class QTreeWidget; +class QTreeWidgetItem; + + +class Event; +class MidiTrack; +class PartList; +class MidiPart; +class MidiPart; +class Xml; + +//--------------------------------------------------------- +// ListEdit +//--------------------------------------------------------- + +class ListEdit : public MidiEditor { + QTreeWidget* liste; + QMenu* menuEdit; + QActionGroup* insertItems; + QToolBar* listTools; + MidiTrack* curTrack; + MidiPart* curPart; + int selectedTick; + int curPartId; + + enum { CMD_DELETE }; + + Q_OBJECT + virtual void closeEvent(QCloseEvent*); + virtual void keyPressEvent(QKeyEvent*); + void initShortcuts(); + QAction *insertNote, *insertSysEx, *insertCtrl, *insertMeta, *insertCAfter, *insertPAfter; + + private slots: + void editInsertNote(); + void editInsertSysEx(); + void editInsertCtrl(); + void editInsertMeta(); + void editInsertCAfter(); + void editInsertPAfter(); + void editEvent(Event&, MidiPart*); + void selectionChanged(); + void doubleClicked(QTreeWidgetItem*); + void cmd(int cmd); + void configChanged(); + + public slots: + void songChanged(int); + + signals: + void deleted(unsigned long); + + public: + ListEdit(PartList*); + ~ListEdit(); + virtual void readStatus(Xml&); + virtual void writeStatus(int, Xml&) const; + }; + +#endif + |