]> git.sesse.net Git - kdenlive/blob - src/effectslistview.cpp
Drag and drop from effects list
[kdenlive] / src / effectslistview.cpp
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #include <KDebug>
22 #include <KLocale>
23
24 #include "effectslistview.h"
25
26 EffectsListView::EffectsListView(EffectsList *audioEffectList, EffectsList *videoEffectList, EffectsList *customEffectList, QWidget *parent)
27     : QWidget(parent)
28 {
29   m_effectsList = new EffectsListWidget(audioEffectList, videoEffectList, customEffectList);
30
31   ui.setupUi(this);
32   QVBoxLayout *lyr = new QVBoxLayout(ui.effectlistframe);
33   lyr->addWidget(m_effectsList);
34   ui.search_effect->setListWidget(m_effectsList);
35   ui.buttonInfo->setIcon(KIcon("help-about"));
36   ui.infopanel->hide();
37
38   connect(ui.type_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(filterList(int)));
39   connect (ui.buttonInfo, SIGNAL (clicked()), this, SLOT (showInfoPanel()));
40   connect(m_effectsList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateInfo()));
41   connect(m_effectsList, SIGNAL(doubleClicked(QListWidgetItem *,const QPoint &)), this, SLOT(slotEffectSelected()));
42
43   m_effectsList->setCurrentRow(0); 
44 }
45
46
47 void EffectsListView::filterList(int pos)
48 {
49   QListWidgetItem *item;
50   for (int i = 0; i < m_effectsList->count(); i++)
51   {
52     item = m_effectsList->item(i);
53     if (pos == 0) item->setHidden(false);
54     else if (item->data(Qt::UserRole).toInt() == pos) item->setHidden(false);
55     else item->setHidden(true);
56   }
57   item = m_effectsList->currentItem();
58   if (item) {
59     if (item->isHidden()) {
60       int i;
61       for (i = 0; i < m_effectsList->count() && m_effectsList->item(i)->isHidden(); i++);
62       m_effectsList->setCurrentRow(i);
63     }
64     else m_effectsList->scrollToItem(item);
65   }
66 }
67
68 void EffectsListView::showInfoPanel()
69 {
70   if (ui.infopanel->isVisible()) {
71     ui.infopanel->hide();
72     ui.buttonInfo->setDown(false);
73   }
74   else {
75     ui.infopanel->show();
76     ui.buttonInfo->setDown(true);
77   }
78 }
79
80 void EffectsListView::slotEffectSelected()
81 {
82   QDomElement effect = m_effectsList->currentEffect();
83   if (!effect.isNull()) emit addEffect(effect);
84 }
85
86 void EffectsListView::slotUpdateInfo()
87 {
88   QString info = m_effectsList->currentInfo(); 
89   if (!info.isEmpty()) ui.infopanel->setText(info);
90 }
91
92 KListWidget *EffectsListView::listView()
93 {
94   return m_effectsList;
95 }
96
97 #include "effectslistview.moc"