1 /***************************************************************************
2 effecstackview.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
20 #include "effectstackedit.h"
21 #include <QVBoxLayout>
25 #include "ui_constval_ui.h"
26 #include "ui_listval_ui.h"
27 #include "ui_boolval_ui.h"
29 EffectStackEdit::EffectStackEdit(QGroupBox* gbox,QWidget *parent): QWidget(parent)
33 gbox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
34 QVBoxLayout *tmpvbox=new QVBoxLayout;
35 tmpvbox->addLayout(vbox);
36 tmpvbox->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Expanding));
37 gbox->setLayout(tmpvbox);
40 void EffectStackEdit::transferParamDesc(const QDomElement& d,int ,int){
43 QDomNodeList namenode = params.elementsByTagName("parameter");
47 QTextStream str(&outstr);
50 for (int i=0;i< namenode.count() ;i++){
51 kDebug() << "in form";
52 QDomNode pa=namenode.item(i);
53 QDomNode na=pa.firstChildElement("name");
54 QDomNamedNodeMap nodeAtts=pa.attributes();
55 QString type=nodeAtts.namedItem("type").nodeValue();
56 QWidget * toFillin=NULL,*labelToFillIn=NULL;
57 //TODO constant, list, bool, complex , color, geometry, position
58 if (type=="double" || type=="constant"){
60 Ui::Constval_UI *ctval=new Ui::Constval_UI;
61 ctval->setupUi(toFillin);
63 ctval->horizontalSlider->setMinimum(nodeAtts.namedItem("min").nodeValue().toInt());
64 ctval->horizontalSlider->setMaximum(nodeAtts.namedItem("max").nodeValue().toInt());
65 ctval->spinBox->setMinimum(ctval->horizontalSlider->minimum());
66 ctval->spinBox->setMaximum(ctval->horizontalSlider->maximum());
67 if (nodeAtts.namedItem("value").isNull())
68 ctval->horizontalSlider->setValue(nodeAtts.namedItem("default").nodeValue().toInt());
70 ctval->horizontalSlider->setValue(nodeAtts.namedItem("value").nodeValue().toInt());
71 ctval->title->setTitle(na.toElement().text() );
72 valueItems[na.toElement().text()]=ctval;
73 connect (ctval->horizontalSlider, SIGNAL(valueChanged(int)) , this, SLOT (slotSliderMoved(int)));
77 Ui::Listval_UI *lsval=new Ui::Listval_UI;
78 lsval->setupUi(toFillin);
79 nodeAtts.namedItem("paramlist");
81 lsval->list->addItems(nodeAtts.namedItem("paramlist").nodeValue().split(","));
82 /*if (nodeAtts.namedItem("value").isNull())
83 lsval->list->setCurrentText(nodeAtts.namedItem("default").nodeValue());
85 lsval->list->setCurrentText(nodeAtts.namedItem("value").nodeValue());
87 connect (lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT (slotSliderMoved(int)));
88 lsval->title->setTitle(na.toElement().text() );
89 valueItems[na.toElement().text()]=lsval;
93 Ui::Boolval_UI *bval=new Ui::Boolval_UI;
94 bval->setupUi(toFillin);
95 if (nodeAtts.namedItem("value").isNull())
96 bval->checkBox->setCheckState(nodeAtts.namedItem("default").nodeValue()=="0" ? Qt::Unchecked : Qt::Checked);
98 bval->checkBox->setCheckState(nodeAtts.namedItem("value").nodeValue()=="0" ? Qt::Unchecked : Qt::Checked);
100 connect (bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT (slotSliderMoved(int)));
101 bval->title->setTitle(na.toElement().text() );
102 valueItems[na.toElement().text()]=bval;
106 items.append(toFillin);
107 vbox->addWidget(toFillin);
111 void EffectStackEdit::collectAllParameters(){
112 QDomNodeList namenode = params.elementsByTagName("parameter");
114 for (int i=0;i< namenode.count() ;i++){
115 QDomNode pa=namenode.item(i);
116 QDomNode na=pa.firstChildElement("name");
117 QString type=pa.attributes().namedItem("type").nodeValue();
118 if (type=="double" || type=="constant"){
119 QSlider* slider=((Ui::Constval_UI*)valueItems[na.toElement().text()])->horizontalSlider;
120 pa.attributes().namedItem("value").setNodeValue(QString::number(slider->value()));
123 KComboBox *box=((Ui::Listval_UI*)valueItems[na.toElement().text()])->list;
124 pa.attributes().namedItem("value").setNodeValue(box->currentText());
127 QCheckBox *box=((Ui::Boolval_UI*)valueItems[na.toElement().text()])->checkBox;
128 pa.attributes().namedItem("value").setNodeValue(box->checkState() == Qt::Checked ? "1" :"0" );
131 emit parameterChanged(params);
133 void EffectStackEdit::slotSliderMoved(int){
134 collectAllParameters();
137 void EffectStackEdit::clearAllItems(){
138 foreach (QWidget* w,items){
139 kDebug() << "delete" << w;
140 vbox->removeWidget(w);