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>
24 #include "ui_constval_ui.h"
26 EffectStackEdit::EffectStackEdit(QGroupBox* gbox,QWidget *parent): QWidget(parent)
30 gbox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
31 QVBoxLayout *tmpvbox=new QVBoxLayout;
32 tmpvbox->addLayout(vbox);
33 tmpvbox->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Expanding));
34 gbox->setLayout(tmpvbox);
37 void EffectStackEdit::transferParamDesc(const QDomElement& d,int ,int){
39 QDomNodeList namenode = params.elementsByTagName("parameter");
43 QTextStream str(&outstr);
46 for (int i=0;i< namenode.count() ;i++){
47 QDomNode pa=namenode.item(i);
48 QDomNode na=pa.firstChildElement("name");
49 QString type=pa.attributes().namedItem("type").nodeValue();
50 QWidget * toFillin=NULL,*labelToFillIn=NULL;
51 if (type=="double" || type=="constant"){
53 Ui::Constval_UI *ctval=new Ui::Constval_UI;
54 ctval->setupUi(toFillin);
56 ctval->horizontalSlider->setMinimum(pa.attributes().namedItem("min").nodeValue().toInt());
57 ctval->horizontalSlider->setMaximum(pa.attributes().namedItem("max").nodeValue().toInt());
58 ctval->spinBox->setMinimum(ctval->horizontalSlider->minimum());
59 ctval->spinBox->setMaximum(ctval->horizontalSlider->maximum());
60 ctval->horizontalSlider->setValue(pa.attributes().namedItem("default").nodeValue().toInt());
61 ctval->title->setText(na.toElement().text() );
62 valueItems[na.toElement().text()]=ctval;
63 connect (ctval->horizontalSlider, SIGNAL(valueChanged(int)) , this, SLOT (slotSliderMoved(int)));
69 items.append(toFillin);
70 vbox->addWidget(toFillin);
74 void EffectStackEdit::collectAllParameters(){
75 QDomNodeList namenode = params.elementsByTagName("parameter");
77 for (int i=0;i< namenode.count() ;i++){
78 QDomNode pa=namenode.item(i);
79 QDomNode na=pa.firstChildElement("name");
80 QString type=pa.attributes().namedItem("type").nodeValue();
81 if (type=="double" || type=="constant"){
82 QSlider* slider=((Ui::Constval_UI*)valueItems[na.toElement().text()])->horizontalSlider;
83 pa.attributes().namedItem("value").setNodeValue(QString::number(slider->value()));
86 emit parameterChanged(params);
88 void EffectStackEdit::slotSliderMoved(int){
89 collectAllParameters();
92 void EffectStackEdit::clearAllItems(){
93 foreach (QWidget* w,items){
94 kDebug() << "delete" << w;
95 vbox->removeWidget(w);