68
74
m_view->setAlternatingRowColors(true);
69
75
m_view->setModel(m_proxy);
70
76
m_view->setSortingEnabled(false);
71
//QAbstractItemView::NoSelection
72
77
m_view->setSelectionMode(QAbstractItemView::SingleSelection);
73
78
connect( m_view->selectionModel(),
74
79
SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)),
209
214
actionCollection()->addAction("stop", m_stop);
211
216
m_connectAll = new KAction(this);
212
m_connectAll->setText(i18n("&Connect All Inputs"));
217
m_connectAll->setText(i18n("Connect All Inputs"));
213
218
m_connectAll->setWhatsThis(i18n("Connect all readable MIDI ports"));
214
219
connect(m_connectAll, SIGNAL(triggered()), SLOT(connectAll()));
215
220
actionCollection()->addAction("connect_all", m_connectAll);
217
222
m_disconnectAll = new KAction(this);
218
m_disconnectAll->setText(i18n("&Disconnect All Inputs"));
223
m_disconnectAll->setText(i18n("Disconnect All Inputs"));
219
224
m_disconnectAll->setWhatsThis(i18n("Disconnect all input MIDI ports"));
220
225
connect(m_disconnectAll, SIGNAL(triggered()), SLOT(disconnectAll()));
221
226
actionCollection()->addAction( "disconnect_all", m_disconnectAll );
223
228
m_configConns = new KAction(this);
224
m_configConns->setText(i18n("Con&figure Connections"));
229
m_configConns->setText(i18n("Configure Connections"));
225
230
m_configConns->setWhatsThis(i18n("Open the Connections dialog"));
226
231
connect(m_configConns, SIGNAL(triggered()), SLOT(configConnections()));
227
232
actionCollection()->addAction("connections_dialog", m_configConns );
229
234
m_createTrack = new KAction(this);
230
m_createTrack->setText(i18n("&Add Track View"));
235
m_createTrack->setText(i18n("Add Track View"));
231
236
m_createTrack->setWhatsThis(i18n("Create a new tab/track view"));
232
237
connect(m_createTrack, SIGNAL(triggered()), SLOT(addTrack()));
233
238
actionCollection()->addAction("add_track", m_createTrack );
235
240
m_changeTrack = new KAction(this);
236
m_changeTrack->setText(i18n("&Change Track View"));
241
m_changeTrack->setText(i18n("Change Track View"));
237
242
m_changeTrack->setWhatsThis(i18n("Change the track number of the view"));
238
243
connect(m_changeTrack, SIGNAL(triggered()), SLOT(changeCurrentTrack()));
239
244
actionCollection()->addAction("change_track", m_changeTrack );
241
246
m_deleteTrack = new KAction(this);
242
m_deleteTrack->setText(i18n("&Delete Track View"));
247
m_deleteTrack->setText(i18n("Delete Track View"));
243
248
m_deleteTrack->setWhatsThis(i18n("Delete the tab/track view"));
244
249
connect(m_deleteTrack, SIGNAL(triggered()), SLOT(deleteCurrentTrack()));
245
250
actionCollection()->addAction("delete_track", m_deleteTrack );
247
for(int i = 0; i < COLUMN_COUNT; ++i ) {
252
for ( int i = 0; i < COLUMN_COUNT; ++i ) {
248
253
m_popupAction[i] = new KToggleAction(columnName[i], this);
249
254
m_popupAction[i]->setWhatsThis(i18n("Toggle the %1 column",columnName[i]));
250
255
connect(m_popupAction[i], SIGNAL(triggered()), m_mapper, SLOT(map()));
254
259
connect(m_mapper, SIGNAL(mapped(int)), SLOT(toggleColumn(int)));
261
m_resizeColumns = new KAction(this);
262
m_resizeColumns->setText(i18n("Resize columns"));
263
m_resizeColumns->setWhatsThis(i18n("Resize the columns width to fit it's contents"));
264
connect(m_resizeColumns, SIGNAL(triggered()), SLOT(resizeAllColumns()));
265
actionCollection()->addAction("resize_columns", m_resizeColumns);
267
m_fileInfo = new KAction(this);
268
m_fileInfo->setText(i18n("Sequence Info"));
269
m_fileInfo->setWhatsThis(i18n("Display information about the loaded sequence"));
270
m_fileInfo->setIcon(KIcon("dialog-information"));
271
connect(m_fileInfo, SIGNAL(triggered()), SLOT(songFileInfo()));
272
actionCollection()->addAction("file_info", m_fileInfo);
274
m_tempoSlider = new KPlayerPopupSliderAction( this, SLOT(tempoSlider(int)), this );
275
m_tempoSlider->setText(i18n("Scale Tempo"));
276
m_tempoSlider->setWhatsThis(i18n("Display a slider to scale the tempo between 50% and 200%"));
277
m_tempoSlider->setIcon(KIcon("chronometer"));
278
actionCollection()->addAction("tempo_slider", m_tempoSlider);
280
m_tempo100 = new KAction(this);
281
m_tempo100->setText(i18n("Reset Tempo"));
282
m_tempo100->setWhatsThis(i18n("Reset the tempo scale to 100%"));
283
m_tempo100->setIcon(KIcon("player-time"));
284
connect(m_tempo100, SIGNAL(triggered()), this, SLOT(tempoReset()));
285
actionCollection()->addAction("tempo100", m_tempo100);
256
287
setStandardToolBarMenuEnabled(true);
259
290
m_popup = static_cast <QMenu*>(guiFactory()->container("popup", this));
260
291
Q_CHECK_PTR( m_popup );
293
m_filter = new EventFilter(this);
294
QMenu* filtersMenu = m_filter->buildMenu(this);
295
m_popup->addMenu( filtersMenu );
296
m_model->setFilter(m_filter);
297
m_proxy->setFilter(m_filter);
298
connect(m_filter, SIGNAL(filterChanged()), m_proxy, SLOT(invalidate()));
299
menuBar()->insertMenu( menuBar()->actions().last(), filtersMenu );
263
302
void KMidimon::fileNew()
265
305
m_model->clear();
266
306
for (int i = m_tabBar->count() - 1; i >= 0; i--) {
267
307
m_tabBar->removeTab(i);
373
416
config.writeEntry("smf", m_proxy->showSmfMsg());
374
417
config.writeEntry("client_names", m_model->showClientNames());
375
418
config.writeEntry("translate_sysex", m_model->translateSysex());
419
config.writeEntry("translate_notes", m_model->translateNotes());
420
config.writeEntry("translate_ctrls", m_model->translateCtrls());
421
config.writeEntry("instrument", m_model->getInstrumentName());
376
422
config.writeEntry("fixed_font", getFixedFont());
377
423
for (i = 0; i < COLUMN_COUNT; ++i) {
378
424
config.writeEntry(QString("show_column_%1").arg(i),
399
447
m_proxy->setFilterSmfMsg(config.readEntry("smf", true));
400
448
m_model->setShowClientNames(config.readEntry("client_names", false));
401
449
m_model->setTranslateSysex(config.readEntry("translate_sysex", false));
402
m_adaptor->setResolution(m_defaultResolution = config.readEntry("resolution", RESOLUTION));
403
m_adaptor->setTempo(m_defaultTempo = config.readEntry("tempo", TEMPO_BPM));
450
m_model->setTranslateNotes(config.readEntry("translate_notes", false));
451
m_model->setTranslateCtrls(config.readEntry("translate_ctrls", false));
452
m_model->setInstrumentName(config.readEntry("instrument", QString()));
453
m_defaultResolution = config.readEntry("resolution", RESOLUTION);
454
m_defaultTempo = config.readEntry("tempo", TEMPO_BPM);
455
m_adaptor->setResolution(m_defaultResolution);
456
m_adaptor->setTempo(m_defaultTempo);
404
457
m_adaptor->queue_set_tempo();
405
458
setFixedFont(config.readEntry("fixed_font", false));
406
459
for (i = 0; i < COLUMN_COUNT; ++i) {
430
485
dlg.setRegSmfMsg(m_proxy->showSmfMsg());
431
486
dlg.setShowClientNames(m_model->showClientNames());
432
487
dlg.setTranslateSysex(m_model->translateSysex());
488
dlg.setTranslateNotes(m_model->translateNotes());
489
dlg.setTranslateCtrls(m_model->translateCtrls());
490
dlg.setInstruments(m_model->getInstruments());
491
dlg.setInstrumentName(m_model->getInstrumentName());
433
492
dlg.setUseFixedFont(getFixedFont());
434
493
for (i = 0; i < COLUMN_COUNT; ++i) {
435
494
dlg.setShowColumn(i, m_popupAction[i]->isChecked());
445
504
m_proxy->setFilterSmfMsg(dlg.isRegSmfMsg());
446
505
m_model->setShowClientNames(dlg.showClientNames());
447
506
m_model->setTranslateSysex(dlg.translateSysex());
448
m_adaptor->setTempo(m_defaultTempo = dlg.getTempo());
449
m_adaptor->setResolution(m_defaultResolution = dlg.getResolution());
450
m_adaptor->queue_set_tempo();
507
m_model->setTranslateNotes(dlg.translateNotes());
508
m_model->setTranslateCtrls(dlg.translateCtrls());
509
m_model->setInstrumentName(dlg.getInstrumentName());
510
m_defaultTempo = dlg.getTempo();
511
m_defaultResolution = dlg.getResolution();
451
512
setFixedFont(dlg.useFixedFont());
452
513
for (i = 0; i < COLUMN_COUNT; ++i) {
453
514
setColumnStatus(i, dlg.showColumn(i));
585
646
void KMidimon::resizeColumns(const QModelIndex&, int, int)
649
m_view->scrollToBottom();
652
void KMidimon::resizeAllColumns()
587
654
for( int i = 0; i < COLUMN_COUNT; ++i)
588
655
m_view->resizeColumnToContents(i);
589
m_view->scrollToBottom();
592
658
void KMidimon::addNewTab(int data)
692
758
if (index.isValid())
693
759
m_view->setCurrentIndex(m_proxy->mapFromSource(index));
763
KMidimon::songFileInfo()
766
if (m_file.isEmpty())
767
infostr = i18n("No file loaded");
769
infostr = i18n("File: <b>%1</b><br>"
770
"SMF Format: <b>%2</b><br>"
771
"Number of tracks: <b>%3</b><br>"
772
"Number of events: <b>%4</b><br>"
773
"Division: <b>%5 ppq</b><br>"
774
"Initial tempo: <b>%6 bpm</b><br>"
775
"Duration: <b>%7</b>",
777
m_model->getSMFFormat(),
778
m_model->getSMFTracks(),
779
m_model->getSong()->size(),
780
m_model->getSMFDivision(),
781
m_model->getInitialTempo(),
782
m_model->getDuration()
784
KMessageBox::information(this, infostr, i18n("Sequence Information"));
787
void KMidimon::tempoReset()
789
m_adaptor->setTempoFactor(1.0);
790
m_tempoSlider->slider()->setValue(100);
791
m_tempoSlider->slider()->setToolTip("100%");
794
void KMidimon::tempoSlider(int value)
796
double tempoFactor = (value*value + 100.0*value + 2e4) / 4e4;
797
m_adaptor->setTempoFactor(tempoFactor);
799
QString tip = QString("%1\%").arg(tempoFactor*100.0, 0, 'f', 0);
800
m_tempoSlider->slider()->setToolTip(tip);
801
QToolTip::showText(QCursor::pos(), tip, this);