playlist.cpp

来自「这是一个自己开发的键盘驱动代码」· C++ 代码 · 共 40 行

CPP
40
字号
#include "playlist.h"

PlayList::PlayList( QWidget * parent, const char * name )
    : QListView( parent, name ), timer( this )
{
	pwidget = (QWidget*)parentWidget();
	
	connect( this, SIGNAL( doubleClicked( QListViewItem * ) ),
	     this, SLOT( slotMp3Play() ) );
	  
	connect( &timer, SIGNAL( timeout() ), this, SLOT( slotRemoveSong() ) );
	
	connect( &( pwidget->dirList() ), SIGNAL( fileSelected( const QString &, const QString & ) ),
	     this, SLOT( slotAddSong( const QString &, const QString & ) ) );

}

void PlayList::slotRemoveSong()
{
	takeItem( playlist->currentItem() );
}

void PlayList::contentsMousePressEvent( QMouseEvent * e )
{
	QListView::contentsMousePressEvent( e );
	timer.start( 750, TRUE );
}

void PlayList::contentsMouseReleaseEvent( QMouseEvent * e )
{
	QListView::contentsMouseReleaseEvent( e );
	timer.stop();
}

void PlayList::slotAddSong( const QString &fn, const QString &fp )
{
	QListViewItem item = new QListViewItem( playlist, fn, fp );
	insertItem( &item );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?