From 53f5ef1980c2ef010f9cf5085aa00e4cb3efd930 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 3 May 2015 19:22:47 +0200 Subject: [PATCH 1/3] Solves issue #2028 (Slow MIDI import due to repeated message) AutomationPattern::addObject now returns a boolean which indicates whether the object was added or not. This change enables the removal of the error message that is shown in the case that a model is already connected from AutomationPattern::addObject. Instead all interactive callers now check for the return value and show the message in case it is needed. This change set improves the import of MIDI files significantly. These have been slowed down quite a lot due to the message being shown repeatedly during the MIDI import. --- include/AutomationPattern.h | 2 +- src/core/AutomationPattern.cpp | 10 ++++------ src/gui/AutomationPatternView.cpp | 11 ++++++++++- src/gui/editors/AutomationEditor.cpp | 10 +++++++++- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index 5257cecab..b6d0e6f2e 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -56,7 +56,7 @@ public: AutomationPattern( const AutomationPattern & _pat_to_copy ); virtual ~AutomationPattern(); - void addObject( AutomatableModel * _obj, bool _search_dup = true ); + bool addObject( AutomatableModel * _obj, bool _search_dup = true ); const AutomatableModel * firstObject() const; diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index f14e6cb70..2e7570957 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -31,7 +31,6 @@ #include "ProjectJournal.h" #include "BBTrackContainer.h" #include "Song.h" -#include "TextFloat.h" #include "embed.h" int AutomationPattern::s_quantization = 1; @@ -107,7 +106,7 @@ AutomationPattern::~AutomationPattern() -void AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) +bool AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) { if( _search_dup ) { @@ -115,10 +114,8 @@ void AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) it != m_objects.end(); ++it ) { if( *it == _obj ) - { - TextFloat::displayMessage( _obj->displayName(), tr( "Model is already connected " - "to this pattern." ), embed::getIconPixmap( "automation" ), 2000 ); - return; + { + return false; } } } @@ -138,6 +135,7 @@ void AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) emit dataChanged(); + return true; } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 166552a39..09574a2de 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -35,6 +35,7 @@ #include "ProjectJournal.h" #include "RenameDialog.h" #include "StringPairDrag.h" +#include "TextFloat.h" #include "ToolTip.h" @@ -420,7 +421,15 @@ void AutomationPatternView::dropEvent( QDropEvent * _de ) journallingObject( val.toInt() ) ); if( mod != NULL ) { - m_pat->addObject( mod ); + bool added = m_pat->addObject( mod ); + if ( !added ) + { + TextFloat::displayMessage( mod->displayName(), + tr( "Model is already connected " + "to this pattern." ), + embed::getIconPixmap( "automation" ), + 2000 ); + } } update(); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 16431faa7..4b2eb6175 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -2299,7 +2299,15 @@ void AutomationEditorWindow::dropEvent( QDropEvent *_de ) journallingObject( val.toInt() ) ); if( mod != NULL ) { - m_editor->m_pattern->addObject( mod ); + bool added = m_editor->m_pattern->addObject( mod ); + if ( !added ) + { + TextFloat::displayMessage( mod->displayName(), + tr( "Model is already connected " + "to this pattern." ), + embed::getIconPixmap( "automation" ), + 2000 ); + } setCurrentPattern( m_editor->m_pattern ); } } From 3e72793465d2d2a4faf853d9f6e4dd12608b1075 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 3 May 2015 22:19:42 +0200 Subject: [PATCH 2/3] Fixes the wrong tab spacing for #2028 --- include/AutomationPattern.h | 2 +- src/core/AutomationPattern.cpp | 4 ++-- src/gui/AutomationPatternView.cpp | 18 +++++++++--------- src/gui/editors/AutomationEditor.cpp | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index b6d0e6f2e..58127d02c 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -56,7 +56,7 @@ public: AutomationPattern( const AutomationPattern & _pat_to_copy ); virtual ~AutomationPattern(); - bool addObject( AutomatableModel * _obj, bool _search_dup = true ); + bool addObject( AutomatableModel * _obj, bool _search_dup = true ); const AutomatableModel * firstObject() const; diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 2e7570957..93934c2a2 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -115,7 +115,7 @@ bool AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) { if( *it == _obj ) { - return false; + return false; } } } @@ -135,7 +135,7 @@ bool AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) emit dataChanged(); - return true; + return true; } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 09574a2de..955461c21 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -421,15 +421,15 @@ void AutomationPatternView::dropEvent( QDropEvent * _de ) journallingObject( val.toInt() ) ); if( mod != NULL ) { - bool added = m_pat->addObject( mod ); - if ( !added ) - { - TextFloat::displayMessage( mod->displayName(), - tr( "Model is already connected " - "to this pattern." ), - embed::getIconPixmap( "automation" ), - 2000 ); - } + bool added = m_pat->addObject( mod ); + if ( !added ) + { + TextFloat::displayMessage( mod->displayName(), + tr( "Model is already connected " + "to this pattern." ), + embed::getIconPixmap( "automation" ), + 2000 ); + } } update(); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 4b2eb6175..8a3e47ab0 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -2299,15 +2299,15 @@ void AutomationEditorWindow::dropEvent( QDropEvent *_de ) journallingObject( val.toInt() ) ); if( mod != NULL ) { - bool added = m_editor->m_pattern->addObject( mod ); - if ( !added ) - { - TextFloat::displayMessage( mod->displayName(), - tr( "Model is already connected " - "to this pattern." ), - embed::getIconPixmap( "automation" ), - 2000 ); - } + bool added = m_editor->m_pattern->addObject( mod ); + if ( !added ) + { + TextFloat::displayMessage( mod->displayName(), + tr( "Model is already connected " + "to this pattern." ), + embed::getIconPixmap( "automation" ), + 2000 ); + } setCurrentPattern( m_editor->m_pattern ); } } From cbf4e59691dbb4180f7ea4f31bc85c44a0fc5326 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Mon, 4 May 2015 19:37:54 +0200 Subject: [PATCH 3/3] Yet another tab correction The wrong settings concerning tabs in QtCreator lead to bad display of the code in other editors. --- src/gui/AutomationPatternView.cpp | 8 ++++---- src/gui/editors/AutomationEditor.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 955461c21..e92b5eb71 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -425,10 +425,10 @@ void AutomationPatternView::dropEvent( QDropEvent * _de ) if ( !added ) { TextFloat::displayMessage( mod->displayName(), - tr( "Model is already connected " - "to this pattern." ), - embed::getIconPixmap( "automation" ), - 2000 ); + tr( "Model is already connected " + "to this pattern." ), + embed::getIconPixmap( "automation" ), + 2000 ); } } update(); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 8a3e47ab0..f51e7bce9 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -2303,10 +2303,10 @@ void AutomationEditorWindow::dropEvent( QDropEvent *_de ) if ( !added ) { TextFloat::displayMessage( mod->displayName(), - tr( "Model is already connected " - "to this pattern." ), - embed::getIconPixmap( "automation" ), - 2000 ); + tr( "Model is already connected " + "to this pattern." ), + embed::getIconPixmap( "automation" ), + 2000 ); } setCurrentPattern( m_editor->m_pattern ); }