added fast and leightweight timer-framework - widgets requiring periodic updates can simply connect their update-slots to songEditor::periodicUpdate()

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@929 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-04-21 08:38:35 +00:00
parent 9ccc0e3a59
commit da2472b9ad
2 changed files with 30 additions and 10 deletions

View File

@@ -27,6 +27,8 @@
#ifndef _SONG_EDITOR_H
#define _SONG_EDITOR_H
#include <QtCore/QBasicTimer>
#include "track_container_view.h"
#include "lcd_spinbox.h"
#include "automatable_slider.h"
@@ -46,10 +48,14 @@ class songEditor : public trackContainerView
{
Q_OBJECT
public:
songEditor( song * _song );
songEditor( song * _song, songEditor * & _engine_ptr );
virtual ~songEditor();
signals:
void periodicUpdate( void );
private slots:
void scrolled( int _new_pos );
void updateTimeLinePosition( void );
@@ -70,8 +76,9 @@ private slots:
private:
virtual void keyPressEvent( QKeyEvent * _ke );
virtual void wheelEvent( QWheelEvent * _we );
virtual void paintEvent( QPaintEvent * _pe );
virtual void timerEvent( QTimerEvent * _ev );
virtual void wheelEvent( QWheelEvent * _we );
virtual bool allowRubberband( void ) const;
@@ -80,6 +87,9 @@ private:
song * m_s;
QBasicTimer m_updateTimer;
QScrollBar * m_leftRightScroll;
QWidget * m_toolBar;

View File

@@ -80,11 +80,13 @@
songEditor::songEditor( song * _song ) :
songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) :
trackContainerView( _song ),
m_s( _song ),
m_scrollBack( FALSE )
{
_engine_ptr = this;
setWindowTitle( tr( "Song-Editor" ) );
setWindowIcon( embed::getIconPixmap( "songeditor" ) );
@@ -371,6 +373,7 @@ songEditor::songEditor( song * _song ) :
w->show();
m_updateTimer.start( 1000 / 20, this ); // 20 fps
}
@@ -383,10 +386,10 @@ songEditor::~songEditor()
void songEditor::paintEvent( QPaintEvent * _pe )
void songEditor::scrolled( int _new_pos )
{
m_leftRightScroll->setMaximum( m_s->length() );
trackContainerView::paintEvent( _pe );
update();
emit positionChanged( m_currentPosition = midiTime( _new_pos, 0 ) );
}
@@ -448,11 +451,18 @@ void songEditor::keyPressEvent( QKeyEvent * _ke )
void songEditor::scrolled( int _new_pos )
void songEditor::paintEvent( QPaintEvent * _pe )
{
update();
emit positionChanged( m_currentPosition = midiTime( _new_pos, 0 ) );
m_leftRightScroll->setMaximum( m_s->length() );
trackContainerView::paintEvent( _pe );
}
void songEditor::timerEvent( QTimerEvent * )
{
emit periodicUpdate();
}