diff widgets/ItemLayerList.cpp @ 58:b3c3a5fa185f

frontend with easaier's look
author benoitrigolleau
date Fri, 25 May 2007 12:36:35 +0000
parents 4f3e6a09239a
children 32b4949086a5
line wrap: on
line diff
--- a/widgets/ItemLayerList.cpp	Wed May 23 15:11:52 2007 +0000
+++ b/widgets/ItemLayerList.cpp	Fri May 25 12:36:35 2007 +0000
@@ -16,41 +16,44 @@
 #include "ItemLayerList.h"
 
 #include "data/model/LayerItemModel.h"
+#include "layer/Layer.h"
+#include "base/PlayParameters.h"
 
 #include <QWidget>
 
 #include <QApplication>
 #include <QLabel>
 
+
 ItemLayerList::ItemLayerList(QWidget *parent) : GenericItemList(parent){
 	setAcceptDrops(true);
 
 	/* Init all variables*/
-	labelIcon = new QLabel;
-	labelName = new QLabel;
-	checkBox1 = new QCheckBox;
-	checkBox2 = new QCheckBox;
-	layoutMain = new QHBoxLayout;
+	m_labelIcon = new QLabel;
+	m_labelName = new QLabel;
+	m_checkBoxShow = new QCheckBox;
+	m_checkBoxPlay = new QCheckBox;
+	m_layoutMain = new QHBoxLayout;
 
 	/* set the correct widget parameters*/
-	labelIcon->setMaximumSize(25,25);
+	m_labelIcon->setMaximumSize(25,25);
 	//labelIcon->setPixmap(QIcon(":icons/layerViewer_btn_config.png").pixmap(20));
 
-	labelName->setMaximumHeight(25);
+	m_labelName->setMaximumHeight(25);
 	//labelName->setText("ljdh lksdf hl");
 
-	checkBox1->setLayoutDirection(Qt::RightToLeft);
-	checkBox1->setMaximumSize(30,30);
+	m_checkBoxShow->setLayoutDirection(Qt::RightToLeft);
+	m_checkBoxShow->setMaximumSize(30,30);
 	//checkBox1->setText("");
-	checkBox1->setAutoFillBackground(true);
+	m_checkBoxShow->setAutoFillBackground(true);
 	//QPalette palette;
 	//palette.setColor(QPalette::Button,QColor ( 100, 60, 20));
 	//checkBox1->setPalette(palette);
 
-	checkBox2->setMaximumSize(20,30);	
+	m_checkBoxPlay->setMaximumSize(20,30);	
 
-	layoutMain->setSpacing(5);
-	layoutMain->setMargin(0);
+	m_layoutMain->setSpacing(5);
+	m_layoutMain->setMargin(0);
 
 	this->setMaximumHeight(30);
 	this->setMinimumHeight(30);
@@ -58,50 +61,49 @@
 	this->setLineWidth(1);
 	
 	/* build the interface*/
-	layoutMain->addWidget(checkBox1);
-	layoutMain->addWidget(checkBox2);
-	layoutMain->addWidget(labelIcon);
-	layoutMain->addWidget(labelName);
+	m_layoutMain->addWidget(m_checkBoxShow);
+	m_layoutMain->addWidget(m_checkBoxPlay);
+	m_layoutMain->addWidget(m_labelIcon);
+	m_layoutMain->addWidget(m_labelName);
 
 	/*add the main layout in this widget*/
-	this->setLayout(layoutMain);
+	this->setLayout(m_layoutMain);
 
 	connect(this, SIGNAL(doubleClicked()), this, SLOT(openPropertyBox()));
 }
 
 void ItemLayerList::setIcon(QString &icon){
-	labelIcon->setPixmap(QIcon(icon).pixmap(25));
+	m_labelIcon->setPixmap(QIcon(icon).pixmap(25));
 }
 
 void ItemLayerList::setName(QString &name){
-	labelName->setText(name);
+	m_labelName->setText(name);
 }
 
 void ItemLayerList::setColor(QColor &color){
 	QPalette palette;
 	palette.setColor(QPalette::Button,color);
-	checkBox1->setPalette(palette);
+	m_checkBoxShow->setPalette(palette);
 }
 
-void ItemLayerList::changeCheckBox1State(bool state){
-	checkBox1->setChecked(state);
+void ItemLayerList::changeCheckBoxShowState(bool state){
+	m_checkBoxShow->setChecked(state);
 }
 
-void ItemLayerList::changeCheckBox2State(bool state){
-	checkBox2->setChecked(state);
+void ItemLayerList::changeCheckBoxPlayState(bool state){
+	m_checkBoxPlay->setChecked(state);
 }
 
 void ItemLayerList::setPropertyBox(PropertyBox *box){
 	m_propertyBox = box;
 	if(m_propertyBox!=0){
-		connect(checkBox1,SIGNAL(stateChanged(int)),m_propertyBox,SLOT(layerVisibilityChanged(int)));
+		
+		m_container = m_propertyBox->container();
+
+		
+		updateCheckboxs();
+		connect(m_checkBoxShow,SIGNAL(stateChanged(int)),m_propertyBox,SLOT(layerVisibilityChanged(int)));
 		connect(m_propertyBox, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool)));
-		if(m_propertyBox->showButton() == 0){
-			checkBox1->setEnabled(false);
-		}
-		if(m_propertyBox->playButton() ==0 ){
-			checkBox2->setEnabled(false);
-		}
 	}
 
 	//connect();
@@ -121,13 +123,44 @@
 }
 
 void ItemLayerList::showLayer(bool value){
-	changeCheckBox1State(value);
+	changeCheckBoxShowState(value);
 	
 }
 
+void ItemLayerList::updateCheckboxs(){
 
 
+	Layer *layer = dynamic_cast<Layer *>(m_container);
+	if (layer) {
+		m_checkBoxShow->setEnabled(true);
+		m_checkBoxShow->setChecked(true);
+
+		disconnect(layer, SIGNAL(modelReplaced()),
+			this, SLOT(updateCheckboxs()));
+		connect(layer, SIGNAL(modelReplaced()),
+			this, SLOT(updateCheckboxs()));
+	}else{
+		m_checkBoxShow->setEnabled(false);
+	}
 
+	PlayParameters *params = m_container->getPlayParameters();
 
+	if(params){
+		m_checkBoxPlay->setEnabled(true);
+        m_checkBoxPlay->setChecked(!params->isPlayMuted());
+
+		connect(params, SIGNAL(playAudibleChanged(bool)),m_checkBoxPlay, SLOT(setState(bool)));
+		connect(m_checkBoxPlay, SIGNAL(stateChanged(int)),params, SLOT(setPlayAudible(int)));
+	}else{
+		m_checkBoxPlay->setEnabled(false);
+	}
 
 
+}
+
+
+
+
+
+
+