Small qml cleanup, fix warnings and reselecting item with shift-click

parent 373f2614
......@@ -105,7 +105,9 @@ enum ProducerType {
Playlist = 9,
WebVfx = 10,
TextTemplate = 11,
QText
QText = 12,
Composition = 13,
Track = 14
};
Q_ENUM_NS(ProducerType)
} // namespace ClipType
......
......@@ -201,7 +201,6 @@ QHash<int, QByteArray> TimelineItemModel::roleNames() const
roles[IsLockedRole] = "locked";
roles[FadeInRole] = "fadeIn";
roles[FadeOutRole] = "fadeOut";
roles[IsCompositionRole] = "isComposition";
roles[FileHashRole] = "hash";
roles[SpeedRole] = "speed";
roles[HeightRole] = "trackHeight";
......@@ -309,8 +308,6 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
return clip->getIn();
case OutPointRole:
return clip->getOut();
case IsCompositionRole:
return false;
case ShowKeyframesRole:
return clip->showKeyframes();
case FadeInRole:
......@@ -333,6 +330,8 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
case Qt::DisplayRole: {
return getTrackById_const(id)->getProperty("kdenlive:track_name").toString();
}
case TypeRole:
return QVariant::fromValue(ClipType::ProducerType::Track);
case DurationRole:
// qDebug() << "DATA yielding duration" << m_tractor->get_playtime();
return getTrackById_const(id)->trackDuration();
......@@ -365,9 +364,6 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
case EffectsEnabledRole: {
return getTrackById_const(id)->stackEnabled();
}
case IsCompositionRole: {
return false;
}
default:
break;
}
......@@ -380,8 +376,8 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
case ServiceRole:
return compo->displayName();
break;
case IsBlankRole: // probably useless
return false;
case TypeRole:
return QVariant::fromValue(ClipType::ProducerType::Composition);
case StartRole:
return compo->getPosition();
case TrackIdRole:
......@@ -407,8 +403,6 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
QVariantList markersList;
return markersList;
}
case IsCompositionRole:
return true;
case GrabbedRole:
return compo->isGrabbed();
default:
......
......@@ -120,7 +120,6 @@ public:
NameRole = Qt::UserRole + 1,
ResourceRole, /// clip only
ServiceRole, /// clip only
IsBlankRole, /// clip only
StartRole, /// clip only
BinIdRole, /// clip only
TrackIdRole,
......@@ -150,7 +149,6 @@ public:
TrackTagRole, /// track only
FadeInRole, /// clip only
FadeOutRole, /// clip only
IsCompositionRole, /// clip only
FileHashRole, /// clip only
SpeedRole, /// clip only
ReloadThumbRole, /// clip only
......
......@@ -40,7 +40,6 @@ Rectangle {
property int clipDuration: 0
property bool isAudio: false
property int audioChannels
property bool isComposition: false
property bool showKeyframes: false
property bool isGrabbed: false
property bool grouped: false
......@@ -48,7 +47,7 @@ Rectangle {
property var markers
property var keyframeModel
property var clipStatus: 0
property var clipType: 0
property var itemType: 0
property int fadeIn: 0
property int fadeOut: 0
property int binId: 0
......@@ -94,7 +93,7 @@ Rectangle {
}
onClipResourceChanged: {
if (clipType == ProducerType.Color) {
if (itemType == ProducerType.Color) {
color: Qt.darker(getColor())
}
}
......@@ -172,7 +171,7 @@ Rectangle {
if (clipStatus == ClipState.Disabled) {
return 'grey'
}
if (clipType == ProducerType.Color) {
if (itemType == ProducerType.Color) {
var color = clipResource.substring(clipResource.length - 9)
if (color[0] == '#') {
return color
......@@ -192,8 +191,8 @@ Rectangle {
//generateWaveform()
}
*/
property bool variableThumbs: (isAudio || clipType == ProducerType.Color || mltService === '')
property bool isImage: clipType == ProducerType.Image
property bool variableThumbs: (isAudio || itemType == ProducerType.Color || mltService === '')
property bool isImage: itemType == ProducerType.Image
property string baseThumbPath: variableThumbs ? '' : 'image://thumbnail/' + binId + '/' + (isImage ? '#0' : '#')
property string inThumbPath: (variableThumbs || isImage ) ? baseThumbPath : baseThumbPath + Math.floor(inPoint * speed)
property string outThumbPath: (variableThumbs || isImage ) ? baseThumbPath : baseThumbPath + Math.floor(outPoint * speed)
......@@ -286,7 +285,7 @@ Rectangle {
Loader {
id: thumbsLoader
anchors.fill: parent
source: parentTrack.isAudio ? "ClipAudioThumbs.qml" : clipType == ProducerType.Color ? "" : "ClipThumbs.qml"
source: parentTrack.isAudio ? "ClipAudioThumbs.qml" : itemType == ProducerType.Color ? "" : "ClipThumbs.qml"
}
Rectangle {
......
......@@ -39,8 +39,8 @@ Item {
property int outPoint: 0
property int clipDuration: 0
property bool isAudio: false
property bool isComposition: true
property bool showKeyframes: false
property var itemType: 0
property bool isGrabbed: false
property var keyframeModel
property bool grouped: false
......@@ -61,7 +61,6 @@ Item {
property color color: displayRect.color
property color borderColor: 'black'
signal clicked(var clip, int shiftClick)
signal moved(var clip)
signal dragged(var clip, var mouse)
signal dropped(var clip)
......
This diff is collapsed.
......@@ -955,6 +955,7 @@ Rectangle {
property bool shiftClick: false
cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor
onPressed: {
console.log('+++++++++++++++++++ DRAG CLICKED +++++++++++++')
if (mouse.modifiers & Qt.ControlModifier) {
mouse.accepted = false
return
......@@ -963,10 +964,12 @@ Rectangle {
timeline.activeTrack = dragProxy.sourceTrack
if (mouse.modifiers & Qt.ShiftModifier) {
if (timeline.selection.indexOf(dragProxy.draggedItem) == -1) {
console.log('ADD SELECTION: ', dragProxy.draggedItem)
timeline.addSelection(dragProxy.draggedItem)
} else {
console.log('REMOVE SELECTION: ', dragProxy.draggedItem)
timeline.removeSelection(dragProxy.draggedItem)
endDrag()
//endDrag()
shiftClick = true
return
}
......@@ -1018,9 +1021,6 @@ Rectangle {
dragProxy.masterObject.originalX = dragProxy.masterObject.x
dragProxy.masterObject.originalTrackId = dragProxy.masterObject.trackId
dragProxy.masterObject.forceActiveFocus();
if (!dragProxy.masterObject.selected) {
dragProxy.masterObject.clicked(dragProxy.masterObject, mouse.modifiers == Qt.ShiftModifier)
}
}
} else {
mouse.accepted = false
......@@ -1233,7 +1233,7 @@ Rectangle {
model: multitrack
delegate: Track {
trackModel: multitrack
trackRootIndex: trackDelegateModel.modelIndex(index)
rootIndex: trackDelegateModel.modelIndex(index)
height: trackHeight
timeScale: timeline.scaleFactor
width: tracksContainerArea.width
......@@ -1320,7 +1320,7 @@ Rectangle {
onFrameFormatChanged: ruler.adjustFormat()
onSelectionChanged: {
//cornerstone.selected = timeline.isMultitrackSelected()
if (dragProxy.draggedItem > -1 && timeline.selection.indexOf(dragProxy.draggedItem) == -1) {
if (dragProxy.draggedItem > -1 && !timeline.exists(dragProxy.draggedItem)) {
endDrag()
}
var selectedTrack = timeline.selectedTrack()
......
......@@ -2278,6 +2278,11 @@ bool TimelineController::isInSelection(int itemId)
return m_model->isInMultiSelection(itemId);
}
bool TimelineController::exists(int itemId)
{
return m_model->isClip(itemId) || m_model->isComposition(itemId);
}
void TimelineController::slotMultitrackView(bool enable)
{
TimelineFunctions::enableMultitrackView(m_model, enable);
......
......@@ -235,6 +235,7 @@ public:
Q_INVOKABLE void selectItems(QVariantList arg, int startFrame, int endFrame, bool addToSelect);
/* @brief Returns true is item is selected as well as other items */
Q_INVOKABLE bool isInSelection(int itemId);
Q_INVOKABLE bool exists(int itemId);
Q_INVOKABLE int headerWidth() const;
Q_INVOKABLE void setHeaderWidth(int width);
......
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