view widgets/ItemAudioFilterList.cpp @ 282:d9319859a4cf tip

(none)
author benoitrigolleau
date Fri, 31 Oct 2008 11:00:24 +0000
parents 3200ed3fc957
children
line wrap: on
line source

/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */

/*   
	Sound Access
		EASAIER client application.
		Silogic 2007. Benoit Rigolleau.

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License as
	published by the Free Software Foundation; either version 2 of the
	License, or (at your option) any later version.  See the file
	COPYING included with this distribution for more information.
*/

#include "ItemAudioFilterList.h"

#include "data/model/LayerItemModel.h"

#include <QWidget>

#include <QApplication>
#include <QLabel>


ItemAudioFilterList::ItemAudioFilterList(QWidget *parent) : GenericItemList(parent),
	m_propertyBox(0),
	m_container(0)
{
	setAcceptDrops(true);

	/* Init all variables*/
	m_labelIcon = new QLabel;
	m_labelName = new QLabel;
	m_checkBoxPlay = new QCheckBox;
	m_layoutMain = new QHBoxLayout;

	/* set the correct widget parameters*/
	m_labelIcon->setMaximumSize(25,25);
	//labelIcon->setPixmap(QIcon(":icons/layerViewer_btn_config.png").pixmap(20));

	m_labelName->setMaximumHeight(25);
	//labelName->setText("ljdh lksdf hl");

	m_checkBoxPlay->setLayoutDirection(Qt::RightToLeft);
	m_checkBoxPlay->setMaximumSize(30,30);	

	m_layoutMain->setSpacing(5);
	m_layoutMain->setMargin(0);

	this->setMaximumHeight(30);
	this->setMinimumHeight(30);
	this->setFrameStyle(QFrame::Panel | QFrame::Raised);
	this->setLineWidth(1);
	
	/* build the interface*/
	m_layoutMain->addWidget(m_checkBoxPlay);
	m_layoutMain->addWidget(m_labelIcon);
	m_layoutMain->addWidget(m_labelName);

	/*add the main layout in this widget*/
	this->setLayout(m_layoutMain);

	connect(this, SIGNAL(doubleClicked()), this, SLOT(openPropertyBox()));

}

ItemAudioFilterList::~ItemAudioFilterList(){
	if(m_propertyBox){
		m_propertyBox->close();
		delete m_propertyBox;
	}
	
}

void ItemAudioFilterList::setIcon(QString &icon){
	m_labelIcon->setPixmap(QIcon(icon).pixmap(25));
}

void ItemAudioFilterList::setName(QString &name){
	m_labelName->setText(name);
}


void ItemAudioFilterList::changeCheckBoxPlayState(bool state){
	m_checkBoxPlay->setChecked(state);
}

void ItemAudioFilterList::setPropertyBox(PropertyBox *box){
	m_propertyBox = box;
	if(m_propertyBox!=0){
		m_container = m_propertyBox->container();
		updateCheckboxs("Enable");
		connect(m_propertyBox, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool)));
		connect(m_checkBoxPlay, SIGNAL(stateChanged(int)),m_container, SLOT(setFilterEnabled(int)));
		connect(m_container, SIGNAL(propertyChanged(PropertyContainer::PropertyName)),this, SLOT(updateCheckboxs(PropertyContainer::PropertyName)));
	}
}

void ItemAudioFilterList::configAction(){
	if(m_propertyBox!=0){
		m_propertyBox->showNormal();
	}
}


/*********SLOTS ************/
void ItemAudioFilterList::openPropertyBox(){
	ItemAudioFilterList::configAction();
}

void ItemAudioFilterList::updateCheckboxs(PropertyContainer::PropertyName name){

	if (name == "Enable")
	{
		int enable = m_container->getPropertyRangeAndValue(name,0,0,0);
		m_checkBoxPlay->setChecked(enable);
	}
}