From ff010da5eeeed6a974365e34bbf9dd63ae2f225e Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 5 Apr 2009 23:54:28 +0200 Subject: [PATCH] SongEditor: fixed horizontal scrollbar with Qt 4.5 Due to optimizations in the graphics subsystem of Qt 4.5 songEditor::paintEvent() didn't get called regularly anymore and thus the range of the horizontal scrollbar didn't get updated at all. This commit makes the GUI track all changes related to the length of the song. --- include/song.h | 1 + include/song_editor.h | 8 +++----- src/core/song.cpp | 2 ++ src/core/track.cpp | 6 ++---- src/gui/song_editor.cpp | 19 ++++++++++--------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/song.h b/include/song.h index 7cd09112a..3544c5fde 100644 --- a/include/song.h +++ b/include/song.h @@ -312,6 +312,7 @@ private: friend class controllerRackView; signals: + void lengthChanged( int _tacts ); void tempoChanged( bpm_t _new_bpm ); void timeSignatureChanged( int _old_ticks_per_tact, int _ticks_per_tact ); diff --git a/include/song_editor.h b/include/song_editor.h index 80239c0cb..1156f81cc 100644 --- a/include/song_editor.h +++ b/include/song_editor.h @@ -2,7 +2,7 @@ * song_editor.h - declaration of class songEditor, a window where you can * setup your songs * - * Copyright (c) 2004-2008 Tobias Doerffel + * Copyright (c) 2004-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -66,15 +66,13 @@ public slots: private slots: - - void updatePosition( const midiTime & _t ); - + void updateScrollBar( int ); + void updatePosition( const midiTime & _t ); void zoomingChanged( void ); private: virtual void keyPressEvent( QKeyEvent * _ke ); - virtual void paintEvent( QPaintEvent * _pe ); virtual void wheelEvent( QWheelEvent * _we ); virtual bool allowRubberband( void ) const; diff --git a/src/core/song.cpp b/src/core/song.cpp index 42c3fe2dc..82fbbcda3 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -575,6 +575,8 @@ void song::updateLength( void ) } } m_tracksMutex.unlock(); + + emit lengthChanged( m_length ); } diff --git a/src/core/track.cpp b/src/core/track.cpp index d053b23fc..ed6503adb 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -913,7 +913,6 @@ void trackContentWidget::addTCOView( trackContentObjectView * _tcov ) tco->saveJournallingState( false ); changePosition(); tco->restoreJournallingState(); - } @@ -1753,11 +1752,9 @@ trackContentObject * track::addTCO( trackContentObject * _tco ) { m_trackContentObjects.push_back( _tco ); -// emit dataChanged(); emit trackContentObjectAdded( _tco ); - //engine::getSongEditor()->setModified(); - return( _tco ); // just for convenience + return _tco; // just for convenience } @@ -1776,6 +1773,7 @@ void track::removeTCO( trackContentObject * _tco ) { m_trackContentObjects.erase( it ); emit trackContentObjectRemoved( _tco ); + engine::getSong()->updateLength(); engine::getSong()->setModified(); } } diff --git a/src/gui/song_editor.cpp b/src/gui/song_editor.cpp index 2caaf880c..db2c80c0c 100644 --- a/src/gui/song_editor.cpp +++ b/src/gui/song_editor.cpp @@ -249,6 +249,8 @@ songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) : static_cast( layout() )->addWidget( m_leftRightScroll ); connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), this, SLOT( scrolled( int ) ) ); + connect( m_s, SIGNAL( lengthChanged( int ) ), + this, SLOT( updateScrollBar( int ) ) ); engine::getMainWindow()->workspace()->addSubWindow( this ); @@ -377,15 +379,6 @@ void songEditor::keyPressEvent( QKeyEvent * _ke ) -void songEditor::paintEvent( QPaintEvent * _pe ) -{ - m_leftRightScroll->setMaximum( m_s->length() ); - trackContainerView::paintEvent( _pe ); -} - - - - void songEditor::wheelEvent( QWheelEvent * _we ) { if( _we->modifiers() & Qt::ControlModifier ) @@ -428,6 +421,14 @@ void songEditor::wheelEvent( QWheelEvent * _we ) +void songEditor::updateScrollBar( int _len ) +{ + m_leftRightScroll->setMaximum( _len ); +} + + + + void songEditor::updatePosition( const midiTime & _t ) { if( ( m_s->isPlaying() && m_s->m_playMode == song::Mode_PlaySong