Commit c0eabf80 authored by Till Theato's avatar Till Theato
Browse files

Try to fix rebuild of group during resize not cared of in undo history (does not work always yet)

svn path=/trunk/kdenlive/; revision=4590
parent 103261c8
......@@ -195,6 +195,7 @@ set(kdenlive_SRCS
vectorscope.cpp
colorplaneexport.cpp
colortools.cpp
rebuildgroupcommand.cpp
)
add_definitions( ${KDE4_DEFINITIONS} )
......
......@@ -21,7 +21,6 @@
#include "configtrackscommand.h"
#include "customtrackview.h"
#include <KLocale>
ConfigTracksCommand::ConfigTracksCommand(CustomTrackView* view, QList< TrackInfo > oldInfos, QList< TrackInfo > newInfos, QUndoCommand* parent) :
QUndoCommand(parent),
......
......@@ -24,7 +24,6 @@
#include <QGraphicsView>
#include <QPointF>
#include <KDebug>
#include "definitions.h"
class CustomTrackView;
......
......@@ -58,6 +58,7 @@
#include "trackdialog.h"
#include "tracksconfigdialog.h"
#include "configtrackscommand.h"
#include "rebuildgroupcommand.h"
#include <KDebug>
#include <KLocale>
......@@ -1009,8 +1010,18 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
QGraphicsView::mousePressEvent(event);
}
void CustomTrackView::rebuildGroup(AbstractGroupItem* group)
void CustomTrackView::rebuildGroup(int childTrack, GenTime childPos)
{
const QPointF p((int)childPos.frames(m_document->fps()), childTrack * m_tracksHeight + m_tracksHeight / 2);
QList<QGraphicsItem *> list = scene()->items(p);
AbstractGroupItem *group = NULL;
for (int i = 0; i < list.size(); i++) {
if (!list.at(i)->isEnabled()) continue;
if (list.at(i)->type() == GROUPWIDGET) {
group = static_cast <AbstractGroupItem *>(list.at(i));
break;
}
}
if (group) {
QList <QGraphicsItem *> children = group->childItems();
m_document->clipManager()->removeGroup(group);
......@@ -4121,7 +4132,7 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
}
if (item->parentItem() && item->parentItem() != m_selectionGroup)
rebuildGroup(static_cast <AbstractGroupItem *>(item->parentItem()));
new RebuildGroupCommand(this, item->info().track, item->info().startPos, command);
}
void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldInfo, int pos, bool check, QUndoCommand *command)
......@@ -4233,7 +4244,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
}
}
if (item->parentItem() && item->parentItem() != m_selectionGroup)
rebuildGroup(static_cast <AbstractGroupItem *>(item->parentItem()));
new RebuildGroupCommand(this, item->info().track, item->info().startPos, command);
}
void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
......
......@@ -219,6 +219,11 @@ public slots:
void slotSelectTrack(int ix);
void insertZoneOverwrite(QStringList data, int in);
/** @brief Rebuilds a group to fit changes to it's childen.
* @param childTrack the track of one of the groups children
* @param childPos The position of the same child */
void rebuildGroup(int childTrack, GenTime childPos);
protected:
virtual void drawBackground(QPainter * painter, const QRectF & rect);
//virtual void drawForeground ( QPainter * painter, const QRectF & rect );
......@@ -307,8 +312,6 @@ private:
bool canBeMoved(QList<AbstractClipItem *> items, GenTime offset, int trackOffset) const;
ClipItem *getClipUnderCursor() const;
AbstractClipItem *getMainActiveClip() const;
/** @brief Rebuilds @param group to fit changes to it's childen. */
void rebuildGroup(AbstractGroupItem *group);
void resetSelectionGroup(bool selectItems = true);
void groupSelectedItems(bool force = false, bool createNewGroup = false);
/** Get available space for clip move (min and max free positions) */
......
/***************************************************************************
* Copyright (C) 2010 by Till Theato (root@ttill.de) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "rebuildgroupcommand.h"
#include "customtrackview.h"
RebuildGroupCommand::RebuildGroupCommand(CustomTrackView* view, int childTrack, GenTime childPos, QUndoCommand* parent) :
QUndoCommand(parent),
m_view(view),
m_childTrack(childTrack),
m_childPos(childPos)
{
setText(i18n("Rebuild Group"));
}
// virtual
void RebuildGroupCommand::undo()
{
m_view->rebuildGroup(m_childTrack, m_childPos);
}
// virtual
void RebuildGroupCommand::redo()
{
m_view->rebuildGroup(m_childTrack, m_childPos);
}
/***************************************************************************
* Copyright (C) 2010 by Till Theato (root@ttill.de) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef REBUILDGROUPCOMMAND_H
#define REBUILDGROUPCOMMAND_H
#include <QUndoCommand>
#include "abstractgroupitem.h"
class CustomTrackView;
class RebuildGroupCommand : public QUndoCommand
{
public:
RebuildGroupCommand(CustomTrackView *view, int childTrack, GenTime childPos, QUndoCommand* parent = 0);
virtual void undo();
virtual void redo();
private:
CustomTrackView *m_view;
int m_childTrack;
GenTime m_childPos;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment