]> git.sesse.net Git - kdenlive/blob - src/effectslistview.cpp
Reindent all source files
[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     m_effectsList = new EffectsListWidget(audioEffectList, videoEffectList, customEffectList);
29
30     ui.setupUi(this);
31     QVBoxLayout *lyr = new QVBoxLayout(ui.effectlistframe);
32     lyr->addWidget(m_effectsList);
33     ui.search_effect->setListWidget(m_effectsList);
34     ui.buttonInfo->setIcon(KIcon("help-about"));
35     ui.infopanel->hide();
36
37     connect(ui.type_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(filterList(int)));
38     connect(ui.buttonInfo, SIGNAL(clicked()), this, SLOT(showInfoPanel()));
39     connect(m_effectsList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateInfo()));
40     connect(m_effectsList, SIGNAL(doubleClicked(QListWidgetItem *, const QPoint &)), this, SLOT(slotEffectSelected()));
41
42     m_effectsList->setCurrentRow(0);
43 }
44
45
46 void EffectsListView::filterList(int pos) {
47     QListWidgetItem *item;
48     for (int i = 0; i < m_effectsList->count(); i++) {
49         item = m_effectsList->item(i);
50         if (pos == 0) item->setHidden(false);
51         else if (item->data(Qt::UserRole).toInt() == pos) item->setHidden(false);
52         else item->setHidden(true);
53     }
54     item = m_effectsList->currentItem();
55     if (item) {
56         if (item->isHidden()) {
57             int i;
58             for (i = 0; i < m_effectsList->count() && m_effectsList->item(i)->isHidden(); i++);
59             m_effectsList->setCurrentRow(i);
60         } else m_effectsList->scrollToItem(item);
61     }
62 }
63
64 void EffectsListView::showInfoPanel() {
65     if (ui.infopanel->isVisible()) {
66         ui.infopanel->hide();
67         ui.buttonInfo->setDown(false);
68     } else {
69         ui.infopanel->show();
70         ui.buttonInfo->setDown(true);
71     }
72 }
73
74 void EffectsListView::slotEffectSelected() {
75     QDomElement effect = m_effectsList->currentEffect();
76     if (!effect.isNull()) emit addEffect(effect);
77 }
78
79 void EffectsListView::slotUpdateInfo() {
80     QString info = m_effectsList->currentInfo();
81     if (!info.isEmpty()) ui.infopanel->setText(info);
82 }
83
84 KListWidget *EffectsListView::listView() {
85     return m_effectsList;
86 }
87
88 #include "effectslistview.moc"