]> git.sesse.net Git - kdenlive/blob - src/effectslistview.cpp
nicer layout for 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), m_audioList(audioEffectList), m_videoList(videoEffectList), m_customList(customEffectList)
28 {
29   ui.setupUi(this);
30   initList(0);
31   connect(ui.type_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(initList(int)));
32   connect(ui.button_info, SIGNAL(stateChanged(int)), this, SLOT(showInfoPanel(int)));
33   connect(ui.effectlist, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateInfo()));
34 }
35
36 void EffectsListView::initList(int pos)
37 {
38   QStringList names;
39   switch (pos)
40   {
41     case 0:
42       names = m_videoList->effectNames();
43       break;
44     case 1:
45       names = m_audioList->effectNames();
46       break;
47     default:
48       names = m_customList->effectNames();
49       break;
50   }
51   ui.effectlist->clear();
52   ui.effectlist->addItems(names);
53 }
54
55 void EffectsListView::showInfoPanel(int state)
56 {
57   if (state == 0) ui.infopanel->hide();
58   else ui.infopanel->show();
59 }
60
61 void EffectsListView::slotUpdateInfo()
62 {
63   QString info; 
64   if (ui.type_combo->currentIndex() == 0) {
65     info = m_videoList->getInfo(ui.effectlist->currentItem()->text());
66   }
67   else if (ui.type_combo->currentIndex() == 1) {
68     info = m_audioList->getInfo(ui.effectlist->currentItem()->text());
69   }
70   if (ui.type_combo->currentIndex() == 2) {
71     info = m_customList->getInfo(ui.effectlist->currentItem()->text());
72   }
73   ui.infopanel->setText(info);
74 }
75
76 KListWidget *EffectsListView::listView()
77 {
78   return ui.effectlist;
79 }
80
81 #include "effectslistview.moc"