view widgets/AudioFilterViewerWidget.cpp @ 79:afcf540ae3a2

add the real time filter stack to manage real time filters and their attributes
author lbajardsilogic
date Tue, 19 Jun 2007 15:15:12 +0000
parents a5d941805d45
children bb04d9df8b41
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 "data/model/LayerItemModel.h"
#include "AudioFilterViewerWidget.h"
#include <iostream>

AudioFilterViewerWidget::AudioFilterViewerWidget(QWidget *parent) : QFrame(parent){
	/* Init all variables*/
	m_pushButtonCONFIG = new QPushButton;
	m_pushButtonUP = new QPushButton;
	m_pushButtonDOWN = new QPushButton;
	m_pushButtonREMOVE = new QPushButton;
	m_pushButtonNEW = new QPushButton;

	m_layoutACTION = new QHBoxLayout;
	m_layoutMAIN = new QVBoxLayout;
	
	m_widgetLIST = new ItemContainer();
	
	/* set the correct widget parameters*/
	m_pushButtonCONFIG->setMaximumSize(20,20);
	m_pushButtonCONFIG->setIcon(QIcon(":icons/layerViewer_btn_config.png"));
	m_pushButtonUP->setMaximumSize(20,20);
	m_pushButtonUP->setIcon(QIcon(":icons/layerViewer_btn_up.png"));
	m_pushButtonDOWN->setMaximumSize(20,20);
	m_pushButtonDOWN->setIcon(QIcon(":icons/layerViewer_btn_down.png"));
	m_pushButtonREMOVE->setMaximumSize(20,20);
	m_pushButtonREMOVE->setIcon(QIcon(":icons/layerViewer_btn_remove.png"));
	m_pushButtonNEW->setMaximumSize(20,20);
	m_pushButtonNEW->setIcon(QIcon(":icons/layerViewer_btn_new.png"));
	
	//the action one:
	m_layoutACTION->addWidget(m_pushButtonCONFIG);
	m_layoutACTION->addStretch();
	m_layoutACTION->addWidget(m_pushButtonUP);
	m_layoutACTION->addWidget(m_pushButtonDOWN);
	m_layoutACTION->addWidget(m_pushButtonNEW);
	m_layoutACTION->addSpacing(10);
	m_layoutACTION->addWidget(m_pushButtonREMOVE);

	//the main one:
	m_layoutMAIN->addWidget(m_widgetLIST);
	m_layoutMAIN->addLayout(m_layoutACTION);

	/* connect pushButtons*/
	connect(m_pushButtonUP,SIGNAL(clicked()),m_widgetLIST,SLOT(upCurrentItem()));
	connect(m_pushButtonDOWN,SIGNAL(clicked()),m_widgetLIST,SLOT(downCurrentItem()));
	connect(m_pushButtonCONFIG,SIGNAL(clicked()),m_widgetLIST,SLOT(openConfigBoxForCurrentItem()));
	//connect(m_pushButtonREMOVE,SIGNAL(clicked()),this,SLOT(removeSelectedItemRequested()));
	connect(m_pushButtonREMOVE,SIGNAL(clicked()),this,SLOT(removeFilterRequested()));
		
	/*connect the list of items */
	connect(m_widgetLIST,SIGNAL(currentChanged(int)),this,SLOT(newItemSelected(int)));


	/*add the main layout in this widget*/
	this->setLayout(m_layoutMAIN);
	this->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
	this->setLineWidth(2);
}

void AudioFilterViewerWidget::addItem(ItemAudioFilterList *item){
	if (m_widgetLIST)
		m_widgetLIST->addItem(item);
}

void AudioFilterViewerWidget::removeAllItems(){
	if (m_widgetLIST)
		m_widgetLIST->removeAllItems();
}

void AudioFilterViewerWidget::setCurrentIndex(int i){

}

/************** SLOTS ********/
void AudioFilterViewerWidget::newItemSelected(int i){
	emit currentChanged(i);
}

void AudioFilterViewerWidget::removeSelectedItemRequested(){
	m_widgetLIST->removeSelectedItem();
}

void AudioFilterViewerWidget::removeFilterRequested()
{
	QString filterName = m_widgetLIST->getCurrentFilterName();
	emit removeFilter(filterName);
}

QString AudioFilterViewerWidget::getCurrentFilterName()
{
	return m_widgetLIST->getCurrentFilterName();
}

void AudioFilterViewerWidget::removeItem(QString name)
{
	m_widgetLIST->removeItem(name);
}