comparison 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
comparison
equal deleted inserted replaced
57:4f3e6a09239a 58:b3c3a5fa185f
14 */ 14 */
15 15
16 #include "ItemLayerList.h" 16 #include "ItemLayerList.h"
17 17
18 #include "data/model/LayerItemModel.h" 18 #include "data/model/LayerItemModel.h"
19 #include "layer/Layer.h"
20 #include "base/PlayParameters.h"
19 21
20 #include <QWidget> 22 #include <QWidget>
21 23
22 #include <QApplication> 24 #include <QApplication>
23 #include <QLabel> 25 #include <QLabel>
24 26
27
25 ItemLayerList::ItemLayerList(QWidget *parent) : GenericItemList(parent){ 28 ItemLayerList::ItemLayerList(QWidget *parent) : GenericItemList(parent){
26 setAcceptDrops(true); 29 setAcceptDrops(true);
27 30
28 /* Init all variables*/ 31 /* Init all variables*/
29 labelIcon = new QLabel; 32 m_labelIcon = new QLabel;
30 labelName = new QLabel; 33 m_labelName = new QLabel;
31 checkBox1 = new QCheckBox; 34 m_checkBoxShow = new QCheckBox;
32 checkBox2 = new QCheckBox; 35 m_checkBoxPlay = new QCheckBox;
33 layoutMain = new QHBoxLayout; 36 m_layoutMain = new QHBoxLayout;
34 37
35 /* set the correct widget parameters*/ 38 /* set the correct widget parameters*/
36 labelIcon->setMaximumSize(25,25); 39 m_labelIcon->setMaximumSize(25,25);
37 //labelIcon->setPixmap(QIcon(":icons/layerViewer_btn_config.png").pixmap(20)); 40 //labelIcon->setPixmap(QIcon(":icons/layerViewer_btn_config.png").pixmap(20));
38 41
39 labelName->setMaximumHeight(25); 42 m_labelName->setMaximumHeight(25);
40 //labelName->setText("ljdh lksdf hl"); 43 //labelName->setText("ljdh lksdf hl");
41 44
42 checkBox1->setLayoutDirection(Qt::RightToLeft); 45 m_checkBoxShow->setLayoutDirection(Qt::RightToLeft);
43 checkBox1->setMaximumSize(30,30); 46 m_checkBoxShow->setMaximumSize(30,30);
44 //checkBox1->setText(""); 47 //checkBox1->setText("");
45 checkBox1->setAutoFillBackground(true); 48 m_checkBoxShow->setAutoFillBackground(true);
46 //QPalette palette; 49 //QPalette palette;
47 //palette.setColor(QPalette::Button,QColor ( 100, 60, 20)); 50 //palette.setColor(QPalette::Button,QColor ( 100, 60, 20));
48 //checkBox1->setPalette(palette); 51 //checkBox1->setPalette(palette);
49 52
50 checkBox2->setMaximumSize(20,30); 53 m_checkBoxPlay->setMaximumSize(20,30);
51 54
52 layoutMain->setSpacing(5); 55 m_layoutMain->setSpacing(5);
53 layoutMain->setMargin(0); 56 m_layoutMain->setMargin(0);
54 57
55 this->setMaximumHeight(30); 58 this->setMaximumHeight(30);
56 this->setMinimumHeight(30); 59 this->setMinimumHeight(30);
57 this->setFrameStyle(QFrame::Panel | QFrame::Raised); 60 this->setFrameStyle(QFrame::Panel | QFrame::Raised);
58 this->setLineWidth(1); 61 this->setLineWidth(1);
59 62
60 /* build the interface*/ 63 /* build the interface*/
61 layoutMain->addWidget(checkBox1); 64 m_layoutMain->addWidget(m_checkBoxShow);
62 layoutMain->addWidget(checkBox2); 65 m_layoutMain->addWidget(m_checkBoxPlay);
63 layoutMain->addWidget(labelIcon); 66 m_layoutMain->addWidget(m_labelIcon);
64 layoutMain->addWidget(labelName); 67 m_layoutMain->addWidget(m_labelName);
65 68
66 /*add the main layout in this widget*/ 69 /*add the main layout in this widget*/
67 this->setLayout(layoutMain); 70 this->setLayout(m_layoutMain);
68 71
69 connect(this, SIGNAL(doubleClicked()), this, SLOT(openPropertyBox())); 72 connect(this, SIGNAL(doubleClicked()), this, SLOT(openPropertyBox()));
70 } 73 }
71 74
72 void ItemLayerList::setIcon(QString &icon){ 75 void ItemLayerList::setIcon(QString &icon){
73 labelIcon->setPixmap(QIcon(icon).pixmap(25)); 76 m_labelIcon->setPixmap(QIcon(icon).pixmap(25));
74 } 77 }
75 78
76 void ItemLayerList::setName(QString &name){ 79 void ItemLayerList::setName(QString &name){
77 labelName->setText(name); 80 m_labelName->setText(name);
78 } 81 }
79 82
80 void ItemLayerList::setColor(QColor &color){ 83 void ItemLayerList::setColor(QColor &color){
81 QPalette palette; 84 QPalette palette;
82 palette.setColor(QPalette::Button,color); 85 palette.setColor(QPalette::Button,color);
83 checkBox1->setPalette(palette); 86 m_checkBoxShow->setPalette(palette);
84 } 87 }
85 88
86 void ItemLayerList::changeCheckBox1State(bool state){ 89 void ItemLayerList::changeCheckBoxShowState(bool state){
87 checkBox1->setChecked(state); 90 m_checkBoxShow->setChecked(state);
88 } 91 }
89 92
90 void ItemLayerList::changeCheckBox2State(bool state){ 93 void ItemLayerList::changeCheckBoxPlayState(bool state){
91 checkBox2->setChecked(state); 94 m_checkBoxPlay->setChecked(state);
92 } 95 }
93 96
94 void ItemLayerList::setPropertyBox(PropertyBox *box){ 97 void ItemLayerList::setPropertyBox(PropertyBox *box){
95 m_propertyBox = box; 98 m_propertyBox = box;
96 if(m_propertyBox!=0){ 99 if(m_propertyBox!=0){
97 connect(checkBox1,SIGNAL(stateChanged(int)),m_propertyBox,SLOT(layerVisibilityChanged(int))); 100
101 m_container = m_propertyBox->container();
102
103
104 updateCheckboxs();
105 connect(m_checkBoxShow,SIGNAL(stateChanged(int)),m_propertyBox,SLOT(layerVisibilityChanged(int)));
98 connect(m_propertyBox, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool))); 106 connect(m_propertyBox, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool)));
99 if(m_propertyBox->showButton() == 0){
100 checkBox1->setEnabled(false);
101 }
102 if(m_propertyBox->playButton() ==0 ){
103 checkBox2->setEnabled(false);
104 }
105 } 107 }
106 108
107 //connect(); 109 //connect();
108 } 110 }
109 111
119 void ItemLayerList::openPropertyBox(){ 121 void ItemLayerList::openPropertyBox(){
120 ItemLayerList::configAction(); 122 ItemLayerList::configAction();
121 } 123 }
122 124
123 void ItemLayerList::showLayer(bool value){ 125 void ItemLayerList::showLayer(bool value){
124 changeCheckBox1State(value); 126 changeCheckBoxShowState(value);
125 127
128 }
129
130 void ItemLayerList::updateCheckboxs(){
131
132
133 Layer *layer = dynamic_cast<Layer *>(m_container);
134 if (layer) {
135 m_checkBoxShow->setEnabled(true);
136 m_checkBoxShow->setChecked(true);
137
138 disconnect(layer, SIGNAL(modelReplaced()),
139 this, SLOT(updateCheckboxs()));
140 connect(layer, SIGNAL(modelReplaced()),
141 this, SLOT(updateCheckboxs()));
142 }else{
143 m_checkBoxShow->setEnabled(false);
144 }
145
146 PlayParameters *params = m_container->getPlayParameters();
147
148 if(params){
149 m_checkBoxPlay->setEnabled(true);
150 m_checkBoxPlay->setChecked(!params->isPlayMuted());
151
152 connect(params, SIGNAL(playAudibleChanged(bool)),m_checkBoxPlay, SLOT(setState(bool)));
153 connect(m_checkBoxPlay, SIGNAL(stateChanged(int)),params, SLOT(setPlayAudible(int)));
154 }else{
155 m_checkBoxPlay->setEnabled(false);
156 }
157
158
126 } 159 }
127 160
128 161
129 162
130 163