Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit ba38dba4 authored by Nicolas Carion's avatar Nicolas Carion

[Timeline2] Attempt to use Loader on the same track repeaters

parent 77de1090
......@@ -93,6 +93,11 @@ QModelIndex TimelineItemModel::index(int row, int column, const QModelIndex &par
int clipId = getTrackById_const(trackId)->getClipByRow(row);
if (clipId != -1) {
result = createIndex(row, 0, quintptr(clipId));
} else {
int transId = getTrackById_const(trackId)->getTransitionByRow(row);
if (transId != -1) {
result = createIndex(row, 1, quintptr(transId));
}
}
} else if (row < getTracksCount() && row >= 0) {
auto it = m_allTracks.cbegin();
......@@ -119,7 +124,7 @@ QModelIndex TimelineItemModel::makeTransitionIndexFromID(int tid) const
{
Q_ASSERT(m_allTransitions.count(tid) > 0);
int trid = m_allTransitions.at(tid)->getCurrentTrackId();
return index(getTrackById_const(trid)->getRowfromTransition(tid), 1, makeTrackIndexFromID(trid, true) );
return index(getTrackById_const(trid)->getRowfromTransition(tid), 0, makeTrackIndexFromID(trid, true) );
}
QModelIndex TimelineItemModel::makeTrackIndexFromID(int tid, bool transition) const
......@@ -166,7 +171,8 @@ int TimelineItemModel::rowCount(const QModelIndex &parent) const
return 0;
}
// return number of clip in a specific track
return parent.column() == 0 ? getTrackClipsCount(id) : getTrackTransitionsCount(id);
//return parent.column() == 0 ? getTrackClipsCount(id) : getTrackTransitionsCount(id);
return getTrackClipsCount(id) + getTrackTransitionsCount(id);
}
return getTracksCount();
}
......@@ -219,6 +225,7 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
if (role == ItemIdRole) {
return id;
}
//qDebug() << "REQUESTING DATA "<<roleNames()[role]<<index;
if (isClip(id)) {
std::shared_ptr<ClipModel>clip = m_allClips.at(id);
// Get data for a clip
......
......@@ -376,7 +376,7 @@ int TrackModel::getRowfromClip(int cid) const
int TrackModel::getRowfromTransition(int tid) const
{
Q_ASSERT(m_allTransitions.count(tid) > 0);
return (int)std::distance(m_allTransitions.begin(), m_allTransitions.find(tid));
return (int)m_allClips.size() + (int)std::distance(m_allTransitions.begin(), m_allTransitions.find(tid));
}
QVariant TrackModel::getProperty(const QString &name)
......@@ -575,7 +575,7 @@ int TrackModel::getTransitionByRow(int row) const
return -1;
}
auto it = m_allTransitions.cbegin();
std::advance(it, row);
std::advance(it, row - m_allClips.size());
return (*it).first;
}
......
......@@ -310,7 +310,7 @@ Rectangle {
visible: true // !isBlank && !isTransition
text: i18n('Cut')
onTriggered: {
if (!transitionTrackRoot.isLocked) {
if (!trackRoot.isLocked) {
timeline.copyClip(trackIndex, index)
timeline.remove(trackIndex, index)
} else {
......@@ -319,7 +319,7 @@ Rectangle {
}
}
MenuItem {
visible: !grouped && transitionTrackRoot.selection.length > 1
visible: !grouped && trackRoot.selection.length > 1
text: i18n('Group')
onTriggered: timeline.groupSelection()
}
......
......@@ -37,6 +37,7 @@ Column{
signal clipDragged(var clip, int x, int y)
signal clipDropped(var clip)
signal clipDraggedToTrack(var clip, int pos)
signal transitionDraggedToTrack(var transition, int pos)
function redrawWaveforms() {
for (var i = 0; i < repeater.count; i++)
......@@ -51,35 +52,87 @@ Column{
DelegateModel {
id: trackModel
Clip {
timeScale: timeline.scaleFactor
clipName: model.name
clipResource: model.resource
clipDuration: model.duration
mltService: model.mlt_service
inPoint: model.in
outPoint: model.out
isBlank: model.blank
clipId: model.item
binId: model.binId
isAudio: false //model.audio
isTransition: model.isTransition
audioLevels: model.audioLevels
markers: model.markers
width: model.duration * timeScale
height: parent.height
modelStart: model.start
x: modelStart * timeScale
grouped: model.grouped
borderColor: (model.grouped ? 'yellow' : 'black')
trackIndex: trackRoot.DelegateModel.itemsIndex
trackId: trackRoot.trackId
fadeIn: 0 //model.fadeIn
fadeOut: 0 //model.fadeOut
//hash: model.hash
speed: 1 //model.speed
selected: trackRoot.selection.indexOf(clipId) !== -1
delegate: Item{
property var itemModel : model
Loader {
/* property var model : parent.itemModel
property var model.name : modelName
property var model.resource : modelResource
property var model.duration : modelDuration
property var modelMlt_service : model.mlt_service
property var modelIn : model.in
property var modelOut : model.out
property var modelBlank : model.blank
property var modelItem : model.item
property var modelBinId : model.binId
isAudio: false //model.audio
property var modelIsTransition : model.isTransition
property var modelAudioLevels : model.audioLevels
property var modelMarkers : model.markers
width: model.duration * timeScale
height: parent.height
modelStart: model.start
x: modelStart * timeScale
grouped: model.grouped
borderColor: (model.grouped ? 'yellow' : 'black')
trackIndex: trackRoot.DelegateModel.itemsIndex
*/
sourceComponent: {
if (model.isTransition) {
console.log("========================= CREATING TRANSITION")
return transitionDelegate
} else {
console.log(model.item)
console.log(model.start)
return clipDelegate
}
}
onLoaded: {
item.timeScale= timeline.scaleFactor
item.clipName= model.name
item.clipResource= model.resource
item.clipDuration= model.duration
item.mltService= model.mlt_service
item.inPoint= model.in
item.outPoint= model.out
item.isBlank= model.blank
item.clipId= model.item
item.binId= model.binId
item.isAudio= false //model.audio
item.isTransition= model.isTransition
if (!model.isTransition) {
item.audioLevels= model.audioLevels
item.markers= model.markers
item.fadeIn= 0 //model.fadeIn
item.fadeOut= 0 //model.fadeOut
}
item.width= model.duration * timeScale
item.height= trackRoot.height
item.modelStart= model.start
item.x= model.start * timeScale
item.grouped= model.grouped
item.borderColor= (model.grouped ? 'yellow' : 'black')
item.trackIndex= trackRoot.DelegateModel.itemsIndex
item.trackId= trackRoot.trackId
//hash= model.hash
item.speed= 1 //model.speed
item.selected= trackRoot.selection.indexOf(clipId) !== -1
console.log(width, height);
}
}
}
}
Item {
id: clipRow
height: trackRoot.height
Repeater { id: repeater; model: trackModel }
}
Component {
id: clipDelegate
Clip {
onGroupedChanged: {
console.log('Clip ', clipId, ' is grouped : ', grouped)
flashclip.start()
......@@ -171,10 +224,102 @@ Column{
}
}
}
Component {
id: transitionDelegate
MltTransition {
opacity: 0.6
selected: trackRoot.selection.indexOf(clipId) !== -1
Item {
id: clipRow
height: trackRoot.height
Repeater { id: repeater; model: trackModel }
onGroupedChanged: {
console.log('Transition ', clipId, ' is grouped : ', grouped)
flashclip.start()
}
SequentialAnimation on color {
id: flashclip
loops: 2
running: false
ColorAnimation { from: Qt.darker(getColor()); to: "#ff3300"; duration: 100 }
ColorAnimation { from: "#ff3300"; to: Qt.darker(getColor()); duration: 100 }
}
onClicked: {
console.log("Transition clicked",clip.clipId)
trackRoot.clipClicked(clip, trackRoot, shiftClick);
clip.draggedX = clip.x
}
onMoved: { //called when the movement is finished
console.log("Transition released",clip.clipId)
var toTrack = clip.trackId
var cIndex = clip.clipId
var frame = Math.round(clip.x / timeScale)
var origFrame = Math.round(clip.originalX / timeScale)
console.log("Asking move ",toTrack, cIndex, frame)
controller.requestTransitionMove(cIndex, clip.originalTrackId, origFrame, false, false)
var val = controller.requestTransitionMove(cIndex, toTrack, frame, true, true)
console.log("RESULT", val)
}
onDragged: { //called when the move is in process
var toTrack = clip.trackId
var cIndex = clip.clipId
clip.x = Math.max(0, clip.x)
var frame = Math.round(clip.x / timeScale)
frame = controller.suggestTransitionMove(cIndex, toTrack, frame);
if (!controller.requestTransitionMove(cIndex, toTrack, frame, false, false)) {
// Abort move
clip.x = clip.draggedX
} else {
clip.x = frame * timeScale
}
var mapped = trackRoot.mapFromItem(clip, mouse.x, mouse.y)
trackRoot.clipDragged(clip, mapped.x, mapped.y)
clip.draggedX = clip.x
}
onTrimmingIn: {
if (controller.requestClipResize(clip.clipId, newDuration, false, false, true)) {
clip.lastValidDuration = newDuration
clip.originalX = clip.draggedX
// Show amount trimmed as a time in a "bubble" help.
var delta = newDuration - clip.originalDuration
var s = timeline.timecode(Math.abs(delta))
s = '%1%2 = %3'.arg((delta < 0)? '+' : (delta > 0)? '-' : '')
.arg(s.substring(3))
.arg(timeline.timecode(clipDuration))
bubbleHelp.show(clip.x + clip.width, trackRoot.y + trackRoot.height, s)
}
}
onTrimmedIn: {
bubbleHelp.hide()
controller.requestClipResize(clip.clipId, clip.originalDuration, false, false, true)
controller.requestClipResize(clip.clipId, clip.lastValidDuration, false, true, true)
}
onTrimmingOut: {
if (controller.requestClipResize(clip.clipId, newDuration, true, false, true)) {
clip.lastValidDuration = newDuration
// Show amount trimmed as a time in a "bubble" help.
var delta = newDuration - clip.originalDuration
var s = timeline.timecode(Math.abs(delta))
s = '%1%2 = %3'.arg((delta < 0)? '+' : (delta > 0)? '-' : '')
.arg(s.substring(3))
.arg(timeline.timecode(clipDuration))
bubbleHelp.show(clip.x + clip.width, trackRoot.y + trackRoot.height, s)
}
}
onTrimmedOut: {
bubbleHelp.hide()
controller.requestClipResize(clip.clipId, clip.originalDuration, true, false, true)
controller.requestClipResize(clip.clipId, clip.lastValidDuration, true, true, true)
}
Component.onCompleted: {
moved.connect(trackRoot.clipDropped)
dropped.connect(trackRoot.clipDropped)
draggedToTrack.connect(trackRoot.transitionDraggedToTrack)
//console.log('Showing item ', model.item, 'name', model.name, ' service: ',mltService)
}
}
}
}
......@@ -489,6 +489,20 @@ Rectangle {
}
}
}
onTransitionDraggedToTrack: {
console.log('Transition Dragged to Track')
var y = pos - ruler.height
currentTrack = Logic.getTrackIndexFromPos(y)
var frame = Math.round(transition.x / timeScale)
if (currentTrack >= 0 && currentTrack < tracksRepeater.count) {
var track = tracksRepeater.itemAt(currentTrack)
if (controller.requestTransitionMove(transition.transitionId, track.trackId, frame, false, false)) {
transition.reparent(track)
transition.trackIndex = track.DelegateModel.itemsIndex
transition.trackId = track.trackId
}
}
}
Image {
anchors.right: parent.right
anchors.left: parent.left
......@@ -509,7 +523,7 @@ Rectangle {
}
}
DelegateModel {
/*DelegateModel {
id: transitionDelegateModel
model: transitionmodel
TransitionTrack {
......@@ -538,7 +552,7 @@ Rectangle {
}
}
}
}
}*/
Connections {
......
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