1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
24 #include "effectslistview.h"
25 #include "effectslistwidget.h"
26 #include "effectslist.h"
28 EffectsListView::EffectsListView(QWidget *parent)
30 m_effectsList = new EffectsListWidget();
33 QVBoxLayout *lyr = new QVBoxLayout(ui.effectlistframe);
34 lyr->addWidget(m_effectsList);
35 ui.search_effect->setListWidget(m_effectsList);
36 ui.buttonInfo->setIcon(KIcon("help-about"));
39 connect(ui.type_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(filterList(int)));
40 connect(ui.buttonInfo, SIGNAL(clicked()), this, SLOT(showInfoPanel()));
41 connect(m_effectsList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateInfo()));
42 connect(m_effectsList, SIGNAL(doubleClicked(QListWidgetItem *, const QPoint &)), this, SLOT(slotEffectSelected()));
44 m_effectsList->setCurrentRow(0);
48 void EffectsListView::filterList(int pos) {
49 QListWidgetItem *item;
50 for (int i = 0; i < m_effectsList->count(); i++) {
51 item = m_effectsList->item(i);
52 if (pos == 0) item->setHidden(false);
53 else if (item->data(Qt::UserRole).toInt() == pos) item->setHidden(false);
54 else item->setHidden(true);
56 item = m_effectsList->currentItem();
58 if (item->isHidden()) {
60 for (i = 0; i < m_effectsList->count() && m_effectsList->item(i)->isHidden(); i++);
61 m_effectsList->setCurrentRow(i);
62 } else m_effectsList->scrollToItem(item);
66 void EffectsListView::showInfoPanel() {
67 if (ui.infopanel->isVisible()) {
68 ui.infopanel->setVisible(false);
69 ui.buttonInfo->setDown(false);
71 ui.infopanel->setVisible(true);
72 ui.buttonInfo->setDown(true);
76 void EffectsListView::slotEffectSelected() {
77 QDomElement effect = m_effectsList->currentEffect().cloneNode().toElement();
78 if (!effect.isNull()) emit addEffect(effect);
81 void EffectsListView::slotUpdateInfo() {
82 QString info = m_effectsList->currentInfo();
83 if (!info.isEmpty()) ui.infopanel->setText(info);
86 KListWidget *EffectsListView::listView() {
90 #include "effectslistview.moc"