Changeset 191
- Timestamp:
- 06/12/08 21:43:01 (5 years ago)
- Location:
- trunk/gui/src
- Files:
-
- 4 modified
-
PreferencesDialog.cpp (modified) (1 diff)
-
PreferencesDialog.h (modified) (1 diff)
-
widgets/midiTable.cpp (modified) (5 diffs)
-
widgets/midiTable.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/src/PreferencesDialog.cpp
r188 r191 378 378 379 379 380 /*381 void PreferencesDialog::setupMidiTable()382 {383 actionManager *aH = actionManager::getInstance();384 midiMap *mM = midiMap::getInstance();385 386 QStringList items;387 items << tr( "Event" ) << tr( "Param." ) << tr( "Action" )388 << tr( "Param." );389 390 391 int rowCount;392 393 rowCount = ( mM->getMMCMap() ).size();394 395 tableWidget->setRowCount( 0 );396 tableWidget->setColumnCount( 4 );397 398 tableWidget->verticalHeader()->hide();399 400 tableWidget->setHorizontalHeaderLabels( items );401 402 403 tableWidget->setFixedWidth( 500 );404 tableWidget->setColumnWidth( 0 , 175 );405 tableWidget->setColumnWidth( 1, 73 );406 tableWidget->setColumnWidth( 2, 175 );407 tableWidget->setColumnWidth( 3 , 73 );408 409 410 rowCount= 0;411 412 std::map< QString , action *> mmcMap = mM->getMMCMap();413 std::map< QString , action *>::iterator dIter(mmcMap.begin());414 415 416 for( dIter = mmcMap.begin(); dIter != mmcMap.end(); dIter++ )417 {418 tableWidget->insertRow( tableWidget->rowCount() );419 QString eventString = dIter->first;420 421 QComboBox *eventBox = new QComboBox();422 eventBox->insertItems( rowCount , aH->getEventList() );423 eventBox->setCurrentIndex( eventBox->findText(eventString) );424 tableWidget->setCellWidget( rowCount, 0, eventBox );425 426 QSpinBox *eventParameterSpinner = new QSpinBox();427 tableWidget->setCellWidget( rowCount , 1, eventParameterSpinner );428 429 action * pAction = mM->getMMCAction( eventString );430 431 QComboBox *actionBox = new QComboBox();432 actionBox->insertItems(rowCount,aH->getActionList());433 actionBox->setCurrentIndex ( actionBox->findText(pAction->getType() ) );434 tableWidget->setCellWidget( rowCount , 2, actionBox );435 436 437 QString actionParameter;438 if( pAction->getParameterList().size() != 0 ){439 actionParameter = pAction->getParameterList().at(0);440 }441 442 QSpinBox *actionParameterSpinner = new QSpinBox();443 444 bool ok;445 actionParameterSpinner->setValue( actionParameter.toInt(&ok,10) );446 447 tableWidget->setCellWidget( rowCount , 3, actionParameterSpinner );448 rowCount++;449 }450 451 for( int note = 0; note < 128; note++ ){452 453 QString eventString = "NOTE";454 455 action * pAction = mM->getNoteAction( note );456 457 if( pAction->getType() != "NOTHING" ){458 459 tableWidget->insertRow( tableWidget->rowCount() );460 QComboBox *eventBox = new QComboBox();461 eventBox->insertItems( rowCount , aH->getEventList() );462 eventBox->setCurrentIndex( eventBox->findText(eventString) );463 tableWidget->setCellWidget( rowCount, 0, eventBox );464 465 QSpinBox *eventParameterSpinner = new QSpinBox();466 tableWidget->setCellWidget( rowCount , 1, eventParameterSpinner );467 eventParameterSpinner->setValue( note );468 469 QComboBox *actionBox = new QComboBox();470 actionBox->insertItems(rowCount,aH->getActionList());471 actionBox->setCurrentIndex ( actionBox->findText(pAction->getType() ) );472 tableWidget->setCellWidget( rowCount , 2, actionBox );473 474 475 QString actionParameter;476 QSpinBox *actionParameterSpinner = new QSpinBox();477 478 if( pAction->getParameterList().size() > 0 ){479 actionParameter = pAction->getParameterList().at(0);480 bool ok;481 actionParameterSpinner->setValue( actionParameter.toInt(&ok,10) );482 }483 484 tableWidget->setCellWidget( rowCount , 3, actionParameterSpinner );485 rowCount++;486 }487 }488 489 tableWidget->insertRow( tableWidget->rowCount() );490 491 QComboBox *eventBox = new QComboBox();492 eventBox->insertItems( rowCount , aH->getEventList() );493 tableWidget->setCellWidget( rowCount, 0, eventBox );494 495 QSpinBox *eventParameterSpinner = new QSpinBox();496 eventParameterSpinner->setEnabled( false );497 tableWidget->setCellWidget( rowCount , 1, eventParameterSpinner );498 499 QComboBox *actionBox = new QComboBox();500 actionBox->insertItems( rowCount, aH->getActionList() );501 tableWidget->setCellWidget( rowCount, 2, actionBox );502 503 QSpinBox *actionParameterSpinner = new QSpinBox();504 tableWidget->setCellWidget( rowCount, 3, actionParameterSpinner );505 }506 507 508 void PreferencesDialog::saveMidiTable(){509 510 delete midiMap::getInstance();511 midiMap *mM = midiMap::getInstance();512 513 514 int row = 0;515 516 for( row = 0; row < tableWidget->rowCount(); row++ ){517 518 QComboBox * eventCombo = dynamic_cast <QComboBox *> ( tableWidget->cellWidget( row, 0 ) );519 520 QSpinBox * eventSpinner = dynamic_cast <QSpinBox *> ( tableWidget->cellWidget( row, 1 ) );521 522 QComboBox * actionCombo = dynamic_cast <QComboBox *> ( tableWidget->cellWidget( row, 2 ) );523 524 QSpinBox * actionSpinner = dynamic_cast <QSpinBox *> ( tableWidget->cellWidget( row, 3 ) );525 526 527 528 QString eventString;529 QString actionString;530 531 532 if( eventCombo->currentText() != "" && actionCombo->currentText() != "" ){533 eventString = eventCombo->currentText();534 535 actionString = actionCombo->currentText();536 537 action * pAction = new action( actionString );538 539 if( actionSpinner->cleanText() != ""){540 pAction->addParameter( actionSpinner->cleanText() );541 }542 543 if( eventString.left(3) == "MMC" ){544 mM->registerMMCEvent( eventString , pAction );545 }546 547 if( eventString.left(4) == "NOTE" ){548 mM->registerNoteEvent( eventSpinner->cleanText().toInt() , pAction );549 }550 }551 }552 553 }554 */555 556 380 void PreferencesDialog::updateDriverInfo() 557 381 { -
trunk/gui/src/PreferencesDialog.h
r188 r191 55 55 private: 56 56 bool m_bNeedDriverRestart; 57 58 //void setupMidiTable();59 //void saveMidiTable();60 61 57 void updateDriverInfo(); 62 58 }; -
trunk/gui/src/widgets/midiTable.cpp
r189 r191 22 22 23 23 #include "midiTable.h" 24 25 #include <iostream>26 24 27 25 #include <hydrogen/midiMap.h> … … 46 44 int myRow = 0; 47 45 48 for( myRow = 0; myRow < rowCount ; myRow++)46 for( myRow = 0; myRow <= rowCount ; myRow++) 49 47 { 50 48 delete cellWidget(myRow,0); … … 55 53 } 56 54 55 57 56 void midiTable::updateTable(){ 58 57 59 ERRORLOG("update"); 60 61 } 62 63 void midiTable::insertNewRow(QString eventString, int argument ) 58 59 if( (rowCount-1) > 0 ) 60 { 61 QComboBox * eventCombo = dynamic_cast <QComboBox *> ( cellWidget( rowCount-1, 0 ) ); 62 QComboBox * actionCombo = dynamic_cast <QComboBox *> ( cellWidget( rowCount-1, 2 ) ); 63 64 if( eventCombo == NULL or actionCombo == NULL) return; 65 66 if( actionCombo->currentText() != "" and eventCombo->currentText() != "" ){ 67 insertNewRow("", "", 0, 0); 68 } 69 } 70 } 71 72 void midiTable::insertNewRow(QString actionString , QString eventString, int eventParameter , int actionParameter) 64 73 { 65 74 actionManager *aH = actionManager::getInstance(); 66 midiMap *mM = midiMap::getInstance();67 68 action * pAction;69 int eventSpinnerValue = 0;70 71 if ( eventString != "NOTE"){72 pAction = mM->getMMCAction( eventString );73 eventSpinnerValue = argument;74 } else {75 pAction = mM->getNoteAction( argument );76 }77 78 if( pAction->getType() == "NOTHING" ) return;79 80 75 81 76 insertRow( rowCount ); 77 78 int oldRowCount = rowCount; 79 80 rowCount++; 82 81 83 82 QComboBox *eventBox = new QComboBox(); 84 83 connect( eventBox , SIGNAL( currentIndexChanged( int ) ) , this , SLOT( updateTable() ) ); 85 eventBox->insertItems( rowCount , aH->getEventList() );84 eventBox->insertItems( oldRowCount , aH->getEventList() ); 86 85 eventBox->setCurrentIndex( eventBox->findText(eventString) ); 87 setCellWidget( rowCount, 0, eventBox );86 setCellWidget( oldRowCount, 0, eventBox ); 88 87 89 88 90 89 QSpinBox *eventParameterSpinner = new QSpinBox(); 91 setCellWidget( rowCount , 1, eventParameterSpinner );92 eventParameterSpinner->setValue( event SpinnerValue);90 setCellWidget( oldRowCount , 1, eventParameterSpinner ); 91 eventParameterSpinner->setValue( eventParameter ); 93 92 94 93 95 94 QComboBox *actionBox = new QComboBox(); 96 actionBox->insertItems(rowCount,aH->getActionList()); 97 actionBox->setCurrentIndex ( actionBox->findText(pAction->getType() ) ); 98 setCellWidget( rowCount , 2, actionBox ); 99 100 101 QString actionParameter; 102 if( pAction->getParameterList().size() != 0 ){ 103 actionParameter = pAction->getParameterList().at(0); 104 } 95 actionBox->insertItems( oldRowCount, aH->getActionList()); 96 actionBox->setCurrentIndex ( actionBox->findText( actionString ) ); 97 setCellWidget( oldRowCount , 2, actionBox ); 98 99 105 100 QSpinBox *actionParameterSpinner = new QSpinBox(); 106 bool ok; 107 108 setCellWidget( rowCount , 3, actionParameterSpinner ); 109 actionParameterSpinner->setValue( actionParameter.toInt(&ok,10) ); 110 111 rowCount++; 101 102 setCellWidget( oldRowCount , 3, actionParameterSpinner ); 103 actionParameterSpinner->setValue( actionParameter); 104 105 112 106 } 113 107 114 108 void midiTable::setupMidiTable() 115 109 { 116 actionManager *aH = actionManager::getInstance();117 110 midiMap *mM = midiMap::getInstance(); 118 111 … … 136 129 137 130 138 139 131 bool ok; 140 132 std::map< QString , action *> mmcMap = mM->getMMCMap(); 141 133 std::map< QString , action *>::iterator dIter(mmcMap.begin()); 142 134 143 135 144 136 for( dIter = mmcMap.begin(); dIter != mmcMap.end(); dIter++ ) 145 137 { 146 insertNewRow( dIter->first , 0 ); 138 action * pAction = dIter->second; 139 QString actionParameter; 140 int actionParameterInteger = 0; 141 142 if( pAction->getParameterList().size() != 0 ){ 143 actionParameter = pAction->getParameterList().at(0); 144 actionParameterInteger = actionParameter.toInt(&ok,10); 145 } 146 147 insertNewRow(pAction->getType() , dIter->first , 0 , actionParameterInteger ); 147 148 } 148 149 149 150 for( int note = 0; note < 128; note++ ) 150 151 { 151 insertNewRow("NOTE",note); 152 } 153 154 insertRow( rowCount ); 155 156 157 QComboBox *eventBox = new QComboBox(); 158 connect( eventBox , SIGNAL( currentIndexChanged( int ) ) , this , SLOT( updateTable() ) ); 159 eventBox->insertItems( rowCount , aH->getEventList() ); 160 setCellWidget( rowCount, 0, eventBox ); 161 162 QSpinBox *eventParameterSpinner = new QSpinBox(); 163 eventParameterSpinner->setEnabled( false ); 164 setCellWidget( rowCount , 1, eventParameterSpinner ); 165 166 QComboBox *actionBox = new QComboBox(); 167 actionBox->insertItems( rowCount, aH->getActionList() ); 168 setCellWidget( rowCount, 2, actionBox ); 169 170 QSpinBox *actionParameterSpinner = new QSpinBox(); 171 setCellWidget( rowCount, 3, actionParameterSpinner ); 152 action * pAction = mM->getNoteAction( note ); 153 QString actionParameter; 154 int actionParameterInteger = 0; 155 156 if( pAction->getParameterList().size() != 0 ){ 157 actionParameter = pAction->getParameterList().at(0); 158 actionParameterInteger = actionParameter.toInt(&ok,10); 159 } 160 161 if ( pAction->getType() == "NOTHING" ) continue; 162 163 insertNewRow(pAction->getType() , "NOTE" , note , actionParameterInteger ); 164 } 165 166 insertNewRow("","",0,0); 167 172 168 } 173 169 … … 178 174 midiMap *mM = midiMap::getInstance(); 179 175 180 181 176 int row = 0; 182 177 183 for( row = 0; row < =rowCount; row++ ){178 for( row = 0; row < rowCount; row++ ){ 184 179 185 180 QComboBox * eventCombo = dynamic_cast <QComboBox *> ( cellWidget( row, 0 ) ); -
trunk/gui/src/widgets/midiTable.h
r189 r191 40 40 void setupMidiTable(); 41 41 void saveMidiTable(); 42 void insertNewRow(QString, int);42 void insertNewRow(QString, QString, int, int); 43 43 44 44 private slots: