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 ***************************************************************************/
21 #include "effectstackview.h"
22 #include "effectslist.h"
24 #include <QHeaderView>
27 EffectStackView::EffectStackView(EffectsList *audioEffectList, EffectsList *videoEffectList, EffectsList *customEffectList, QWidget *parent)
31 //ui.effectlist->horizontalHeader()->setVisible(false);
32 //ui.effectlist->verticalHeader()->setVisible(false);
36 ui.buttonNew->setIcon(KIcon("document-new"));
37 ui.buttonUp->setIcon(KIcon("go-up"));
38 ui.buttonDown->setIcon(KIcon("go-down"));
39 ui.buttonDel->setIcon(KIcon("trash-empty"));
41 ui.buttonLeftRight->setIcon(KIcon("go-next"));//better icons needed
42 ui.buttonUpDown->setIcon(KIcon("go-up"));
43 ui.buttonShowInTimeline->setIcon(KIcon("kmplayer"));
44 ui.buttonHelp->setIcon(KIcon("help-about"));
45 ui.buttonNewPoints->setIcon(KIcon("xedit"));
47 ui.effectlist->setDragDropMode(QAbstractItemView::NoDragDrop);//use internal if dropis recognised right
49 connect (ui.effectlist, SIGNAL ( itemSelectionChanged()), this , SLOT( slotItemSelectionChanged() ));
50 connect (ui.buttonNew, SIGNAL (clicked()), this, SLOT (slotNewEffect()) );
51 connect (ui.buttonUp, SIGNAL (clicked()), this, SLOT (slotItemUp()) );
52 connect (ui.buttonDown, SIGNAL (clicked()), this, SLOT (slotItemDown()) );
53 connect (ui.buttonDel, SIGNAL (clicked()), this, SLOT (slotItemDel()) );
54 connect (ui.buttonLeftRight, SIGNAL (clicked()), this , SLOT ( slotSetMoveX() ) );
55 connect (ui.buttonUpDown, SIGNAL (clicked()), this , SLOT ( slotSetMoveY() ) );
56 connect (ui.buttonShowInTimeline, SIGNAL (clicked()), this , SLOT ( slotShowInTimeline() ) );
57 connect (ui.buttonNewPoints, SIGNAL (clicked()), this , SLOT ( slotSetNew() ) );
58 connect (ui.buttonHelp, SIGNAL (clicked()), this , SLOT ( slotSetHelp() ) );
59 connect (ui.parameterList, SIGNAL (currentIndexChanged ( const QString & ) ), this, SLOT( slotParameterChanged(const QString&) ) );
60 connect (ui.effectlist, SIGNAL (itemSelectionChanged() ) , this, SLOT ( itemSelectionChanged()));
62 effectLists["audio"]=audioEffectList;
63 effectLists["video"]=videoEffectList;
64 effectLists["custom"]=customEffectList;
70 QList< QPair<QString, QMap<int,QVariant> > > points;
71 QMap<int,QVariant> data;
76 QPair<QString,QMap<int,QVariant> > testpair("gray",data);
77 points.append(testpair);
79 QMap<int,QVariant> data1;
84 QPair<QString,QMap<int,QVariant> > testpair1("dx",data1);
85 points.append(testpair1);
86 ui.parameterList->addItem("all");
87 ui.parameterList->addItem("gray");
88 ui.parameterList->addItem("dx");
90 ui.kplotwidget->setPointLists(points,0,305);
94 void EffectStackView::slotClipItemSelected(ClipItem* c)
99 effects=clipref->effectNames();
100 setupListView(effects);
104 void EffectStackView::setupListView(const QStringList& effects_list){
106 ui.effectlist->clear();
107 ui.effectlist->addItems(effects);
108 for (int i=0;i< ui.effectlist->count();i++){
109 QListWidgetItem* item=ui.effectlist->item(i);
110 item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
111 item->setCheckState(Qt::Checked);
113 item->setSelected(true);
114 ui.effectlist->setCurrentRow(activeRow);
120 void EffectStackView::slotItemSelectionChanged(){
122 if (ui.effectlist->currentItem() && ui.effectlist->currentItem()->isSelected() ){
123 activeRow=ui.effectlist->row( ui.effectlist->currentItem() );
127 ui.buttonDel->setEnabled( activeRow!=-1);
128 ui.buttonUp->setEnabled( activeRow >0 );
129 ui.buttonDown->setEnabled( (activeRow<ui.effectlist->count()-1) && activeRow>=0 );
132 void EffectStackView::slotItemUp(){
133 if (activeRow>0 && activeRow <effects.size() ){
134 effects.swap(activeRow, activeRow-1);
137 setupListView(effects);
141 void EffectStackView::slotItemDown(){
142 if (activeRow<effects.size()-1 ){
143 effects.swap(activeRow, activeRow+1);
146 setupListView(effects);
150 void EffectStackView::slotItemDel(){
151 if (activeRow<effects.size() && activeRow>=0 ){
152 effects.removeAt(activeRow);
154 if (effects.size()>0 && activeRow>0)
156 setupListView(effects);
160 void EffectStackView::slotSetMoveX(){
161 ui.kplotwidget->setMoveX(!ui.kplotwidget->isMoveX());
162 updateButtonStatus();
165 void EffectStackView::slotSetMoveY(){
166 ui.kplotwidget->setMoveY(!ui.kplotwidget->isMoveY());
167 updateButtonStatus();
170 void EffectStackView::slotSetNew(){
171 ui.kplotwidget->setNewPoints(!ui.kplotwidget->isNewPoints());
172 updateButtonStatus();
175 void EffectStackView::slotSetHelp(){
176 ui.infoBox->setVisible(!ui.infoBox->isVisible());
177 ui.buttonHelp->setDown(ui.infoBox->isVisible());
180 void EffectStackView::slotShowInTimeline(){
182 ui.kplotwidget->setMoveTimeLine(!ui.kplotwidget->isMoveTimeline());
183 updateButtonStatus();
187 void EffectStackView::updateButtonStatus(){
188 ui.buttonLeftRight->setDown(ui.kplotwidget->isMoveX());
189 ui.buttonUpDown->setDown(ui.kplotwidget->isMoveY());
191 ui.buttonShowInTimeline->setEnabled( ui.kplotwidget->isMoveX() || ui.kplotwidget->isMoveY () );
192 ui.buttonShowInTimeline->setDown(ui.kplotwidget->isMoveTimeline());
194 ui.buttonNewPoints->setEnabled(ui.parameterList->currentText()!="all");
195 ui.buttonNewPoints->setDown(ui.kplotwidget->isNewPoints());
198 void EffectStackView::slotParameterChanged(const QString& text){
200 //ui.buttonNewPoints->setEnabled(text!="all");
201 updateButtonStatus();
204 void EffectStackView::slotNewEffect(){
207 QMenu *displayMenu=new QMenu (this);
208 foreach (QString type, effectLists.keys() ){
209 QAction *a=new QAction(type,displayMenu);
210 EffectsList *list=effectLists[type];
212 QMenu *parts=new QMenu(type,displayMenu);
213 foreach (QString name, list->effectNames()){
214 QAction *entry=new QAction(name,parts);
215 parts->addAction(entry);
218 displayMenu->addMenu(parts);
222 QAction *result=displayMenu->exec(mapToGlobal(ui.buttonNew->pos()+ui.buttonNew->rect().bottomRight()));
225 kDebug()<< result->text();
227 kDebug() << "kein re4sult";
232 void EffectStackView::itemSelectionChanged (){
235 #include "effectstackview.moc"