}
bool collision = false;
for (int i = 0; i < collidingItems.count(); i++) {
- if (!collidingItems.at(i)->isEnabled()) continue;
+ if (!collidingItems.at(i)->isEnabled()) continue;
if (collidingItems.at(i)->type() == AVWIDGET) {
collision = true;
break;
if (event->modifiers() == Qt::ControlModifier) {
// Ctrl + click, select all items on track after click position
int track = (int)(mapToScene(m_clickEvent).y() / m_tracksHeight);
- if (m_document->trackInfoAt(m_document->tracksCount() - track - 1).isLocked) {
+ if (m_document->trackInfoAt(m_document->tracksCount() - track - 1).isLocked) {
// Cannot use spacer on locked track
emit displayMessage(i18n("Cannot use spacer in a locked track"), ErrorMessage);
- return;
- }
-
+ return;
+ }
+
QRectF rect(mapToScene(m_clickEvent).x(), track * m_tracksHeight + m_tracksHeight / 2, sceneRect().width() - mapToScene(m_clickEvent).x(), m_tracksHeight / 2 - 2);
bool isOk;
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->parentItem() == 0 && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET)) {
AbstractClipItem *item = static_cast<AbstractClipItem *>(selection.at(i));
- if (item->isItemLocked()) continue;
+ if (item->isItemLocked()) continue;
offsetList.append(item->startPos());
offsetList.append(item->endPos());
m_selectionGroup->addToGroup(selection.at(i));
selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
} else if (selection.at(i)->parentItem() == 0 && selection.at(i)->type() == GROUPWIDGET) {
- if (static_cast<AbstractGroupItem *>(selection.at(i))->isItemLocked()) continue;
+ if (static_cast<AbstractGroupItem *>(selection.at(i))->isItemLocked()) continue;
QList<QGraphicsItem *> children = selection.at(i)->childItems();
for (int j = 0; j < children.count(); j++) {
AbstractClipItem *item = static_cast<AbstractClipItem *>(children.at(j));
m_selectionGroup->addToGroup(selection.at(i));
selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
} else if (selection.at(i)->parentItem()) {
- if (static_cast<AbstractGroupItem *>(selection.at(i)->parentItem())->isItemLocked()) continue;
+ if (static_cast<AbstractGroupItem *>(selection.at(i)->parentItem())->isItemLocked()) continue;
m_selectionGroup->addToGroup(selection.at(i)->parentItem());
selection.at(i)->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
}
QVBoxLayout *lyr = new QVBoxLayout(effectlistframe);
lyr->addWidget(m_effectsList);
lyr->setContentsMargins(0, 0, 0, 0);
- search_effect->setListWidget(m_effectsList);
+ search_effect->setTreeWidget(m_effectsList);
buttonInfo->setIcon(KIcon("help-about"));
setFocusPolicy(Qt::StrongFocus);
connect(type_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(filterList(int)));
connect(buttonInfo, SIGNAL(clicked()), this, SLOT(showInfoPanel()));
connect(m_effectsList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateInfo()));
- connect(m_effectsList, SIGNAL(doubleClicked(QListWidgetItem *, const QPoint &)), this, SLOT(slotEffectSelected()));
+ connect(m_effectsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotEffectSelected()));
- m_effectsList->setCurrentRow(0);
+ //m_effectsList->setCurrentRow(0);
}
void EffectsListView::filterList(int pos)
{
- QListWidgetItem *item;
- for (int i = 0; i < m_effectsList->count(); i++) {
- item = m_effectsList->item(i);
- if (pos == 0) item->setHidden(false);
- else if (item->data(Qt::UserRole).toInt() == pos) item->setHidden(false);
- else item->setHidden(true);
+ QTreeWidgetItem *item;
+ QTreeWidgetItem *folder;
+ for (int i = 0; i < m_effectsList->topLevelItemCount(); i++) {
+ folder = m_effectsList->topLevelItem(i);
+ for (int j = 0; j < folder->childCount(); j++) {
+ item = folder->child(j);
+ if (pos == 0) item->setHidden(false);
+ else if (item->data(0, Qt::UserRole).toInt() == pos) item->setHidden(false);
+ else item->setHidden(true);
+ }
}
item = m_effectsList->currentItem();
- if (item) {
+ /*if (item) {
if (item->isHidden()) {
int i;
- for (i = 0; i < m_effectsList->count() && m_effectsList->item(i)->isHidden(); i++) /*do nothing*/;
+ for (i = 0; i < m_effectsList->count() && m_effectsList->item(i)->isHidden(); i++); //do nothing
m_effectsList->setCurrentRow(i);
} else m_effectsList->scrollToItem(item);
- }
+ }*/
}
void EffectsListView::showInfoPanel()
infopanel->setText(m_effectsList->currentInfo());
}
-KListWidget *EffectsListView::listView()
-{
- return m_effectsList;
-}
-
void EffectsListView::reloadEffectList()
{
m_effectsList->initList();
void EffectsListView::slotRemoveEffect()
{
- QListWidgetItem *item = m_effectsList->currentItem();
- QString effectId = item->text();
+ QTreeWidgetItem *item = m_effectsList->currentItem();
+ QString effectId = item->text(0);
QString path = KStandardDirs::locateLocal("appdata", "effects/", true);
QDir directory = QDir(path);
static const int EFFECT_VIDEO = 1;
static const int EFFECT_AUDIO = 2;
static const int EFFECT_CUSTOM = 3;
+static const int EFFECT_FOLDER = 4;
const int TypeRole = Qt::UserRole;
const int IdRole = TypeRole + 1;
EffectsListWidget::EffectsListWidget(QMenu *menu, QWidget *parent) :
- KListWidget(parent),
+ QTreeWidget(parent),
m_menu(menu)
{
//setSelectionMode(QAbstractItemView::ExtendedSelection);
//setDragDropMode(QAbstractItemView::DragDrop);
+ setColumnCount(1);
setDropIndicatorShown(true);
setAlternatingRowColors(true);
- setSortingEnabled(true);
setDragEnabled(true);
setAcceptDrops(true);
+ setHeaderHidden(true);
initList();
}
void EffectsListWidget::initList()
{
clear();
- QListWidgetItem *item;
+ QTreeWidgetItem *item;
+ QTreeWidgetItem *parentItem;
QString effectName;
QStringList effectInfo;
KIcon videoIcon("kdenlive-show-video");
KIcon audioIcon("kdenlive-show-audio");
KIcon customIcon("kdenlive-custom-effect");
+ KIcon folderIcon("folder");
+
+ KSharedConfigPtr config = KSharedConfig::openConfig("kdenliveeffectscategoryrc");
+ KConfigGroup transConfig(config, "Category");
+ // read the entries
+ QMap< QString, QString > profiles = transConfig.entryMap();
+ QMapIterator<QString, QString> i(profiles);
+ QList <QTreeWidgetItem *> folders;
+ while (i.hasNext()) {
+ i.next();
+ item = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n(i.key().toUtf8().data())));
+ item->setIcon(0, folderIcon);
+ item->setData(0, TypeRole, QString::number((int) EFFECT_FOLDER));
+ item->setData(0, IdRole, i.value());
+ folders.append(item);
+ }
+ QTreeWidgetItem *misc = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Misc")));
+ misc->setIcon(0, folderIcon);
+ misc->setData(0, TypeRole, QString::number((int) EFFECT_FOLDER));
+
+ QTreeWidgetItem *audio = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Audio")));
+ audio->setIcon(0, folderIcon);
+ audio->setData(0, TypeRole, QString::number((int) EFFECT_FOLDER));
+
+ QTreeWidgetItem *custom = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Custom")));
+ custom->setIcon(0, folderIcon);
+ custom->setData(0, TypeRole, QString::number((int) EFFECT_FOLDER));
+
+ insertTopLevelItem(0, custom);
+ insertTopLevelItem(0, misc);
+ insertTopLevelItem(0, audio);
+ insertTopLevelItems(0, folders);
+
+
int ct = MainWindow::videoEffects.count();
for (int ix = 0; ix < ct; ix ++) {
effectInfo = MainWindow::videoEffects.effectIdInfo(ix);
+ parentItem = NULL;
+ for (int i = 0; i < folders.count(); i++) {
+ QStringList l = folders.at(i)->data(0, IdRole).toString().split(',', QString::SkipEmptyParts);
+ if (l.contains(effectInfo.at(2))) {
+ parentItem = folders.at(i);
+ break;
+ }
+ }
+ if (parentItem == NULL) parentItem = misc;
if (!effectInfo.isEmpty()) {
- item = new QListWidgetItem(videoIcon, effectInfo.takeFirst(), this);
- item->setData(TypeRole, QString::number((int) EFFECT_VIDEO));
- item->setData(IdRole, effectInfo);
+ item = new QTreeWidgetItem(parentItem, QStringList(effectInfo.takeFirst()));
+ item->setIcon(0, videoIcon);
+ item->setData(0, TypeRole, QString::number((int) EFFECT_VIDEO));
+ item->setData(0, IdRole, effectInfo);
}
}
ct = MainWindow::audioEffects.count();
for (int ix = 0; ix < ct; ix ++) {
effectInfo = MainWindow::audioEffects.effectIdInfo(ix);
+ parentItem = NULL;
+ for (int i = 0; i < folders.count(); i++) {
+ QStringList l = folders.at(i)->data(0, IdRole).toString().split(',', QString::SkipEmptyParts);
+ if (l.contains(effectInfo.at(2))) {
+ parentItem = folders.at(i);
+ break;
+ }
+ }
+ if (parentItem == NULL) parentItem = audio;
if (!effectInfo.isEmpty()) {
- item = new QListWidgetItem(audioIcon, effectInfo.takeFirst(), this);
- item->setData(TypeRole, QString::number((int) EFFECT_AUDIO));
- item->setData(IdRole, effectInfo);
+ item = new QTreeWidgetItem(parentItem, QStringList(effectInfo.takeFirst()));
+ item->setIcon(0, audioIcon);
+ item->setData(0, TypeRole, QString::number((int) EFFECT_AUDIO));
+ item->setData(0, IdRole, effectInfo);
}
}
for (int ix = 0; ix < ct; ix ++) {
effectInfo = MainWindow::customEffects.effectIdInfo(ix);
if (!effectInfo.isEmpty()) {
- item = new QListWidgetItem(customIcon, effectInfo.takeFirst(), this);
- item->setData(TypeRole, QString::number((int) EFFECT_CUSTOM));
- item->setData(IdRole, effectInfo);
+ item = new QTreeWidgetItem(custom, QStringList(effectInfo.takeFirst()));
+ item->setIcon(0, customIcon);
+ item->setData(0, TypeRole, QString::number((int) EFFECT_CUSTOM));
+ item->setData(0, IdRole, effectInfo);
}
}
+ setSortingEnabled(true);
+ sortByColumn(0, Qt::AscendingOrder);
}
const QDomElement EffectsListWidget::currentEffect() const
return itemEffect(currentItem());
}
-const QDomElement EffectsListWidget::itemEffect(QListWidgetItem *item) const
+const QDomElement EffectsListWidget::itemEffect(QTreeWidgetItem *item) const
{
QDomElement effect;
- if (!item) return effect;
- QStringList effectInfo = item->data(IdRole).toStringList();
+ if (!item || item->data(0, TypeRole).toInt() == (int)EFFECT_FOLDER) return effect;
+ QStringList effectInfo = item->data(0, IdRole).toStringList();
kDebug() << "// EFFECT SELECTED: " << effectInfo;
- switch (item->data(TypeRole).toInt()) {
+ switch (item->data(0, TypeRole).toInt()) {
case 1:
effect = MainWindow::videoEffects.getEffectByTag(effectInfo.at(0), effectInfo.at(1)).cloneNode().toElement();
break;
QString EffectsListWidget::currentInfo()
{
- QListWidgetItem *item = currentItem();
- if (!item) return QString();
+ QTreeWidgetItem *item = currentItem();
+ if (!item || item->data(0, TypeRole).toInt() == (int)EFFECT_FOLDER) return QString();
QString info;
- QStringList effectInfo = item->data(IdRole).toStringList();
- switch (item->data(TypeRole).toInt()) {
+ QStringList effectInfo = item->data(0, IdRole).toStringList();
+ switch (item->data(0, TypeRole).toInt()) {
case 1:
info = MainWindow::videoEffects.getInfo(effectInfo.at(0), effectInfo.at(1));
break;
m_DragStartPosition = event->pos();
m_dragStarted = true;
}
- KListWidget::mousePressEvent(event);
+ QTreeWidget::mousePressEvent(event);
}
// virtual
return;
{
- QListWidgetItem *clickItem = itemAt(event->pos());
- if (clickItem) {
+ QTreeWidgetItem *clickItem = itemAt(event->pos());
+ if (clickItem && clickItem->data(0, TypeRole).toInt() != (int)EFFECT_FOLDER) {
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
- const QList <QListWidgetItem *>list = selectedItems();
+ const QList <QTreeWidgetItem *>list = selectedItems();
QDomDocument doc;
- foreach(QListWidgetItem *item, list) {
+ foreach(QTreeWidgetItem *item, list) {
const QDomElement e = itemEffect(item);
if (!e.isNull()) doc.appendChild(doc.importNode(e, true));
}
//virtual
void EffectsListWidget::contextMenuEvent(QContextMenuEvent * event)
{
- QListWidgetItem *item = itemAt(event->pos());
- if (item && item->data(TypeRole).toInt() == EFFECT_CUSTOM) m_menu->popup(event->globalPos());
+ QTreeWidgetItem *item = itemAt(event->pos());
+ if (item && item->data(0, TypeRole).toInt() == EFFECT_CUSTOM) m_menu->popup(event->globalPos());
}
#include "effectslistwidget.moc"
QWidget * toFillin = new QWidget(m_baseWidget);
QString value = pa.attribute("value").isNull() ?
pa.attribute("default") : pa.attribute("value");
-
- /** Currently supported parameter types are:
- * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
- * list: a combobox containing a list of values to choose
- * bool: a checkbox
- * complex: designed for keyframe parameters, but old and not finished, do not use
- * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
- * keyframe: a list widget with a list of entries (position and value)
- * color: a color chooser button
- * position: a slider representing the position of a frame in the current clip
- * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
- */
+
+ /** Currently supported parameter types are:
+ * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
+ * list: a combobox containing a list of values to choose
+ * bool: a checkbox
+ * complex: designed for keyframe parameters, but old and not finished, do not use
+ * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
+ * keyframe: a list widget with a list of entries (position and value)
+ * color: a color chooser button
+ * position: a slider representing the position of a frame in the current clip
+ * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
+ */
if (type == "double" || type == "constant") {
int min;