forked from qt-creator/qt-creator
Timeline: make notes model optional
If you pass 0 as notes model to the aggregator then all the notes features are hidden. Change-Id: I432f2820812c472221a0330de5b8f5d8d0fcad13 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -196,23 +196,21 @@ Item {
|
||||
Connections {
|
||||
target: notesModel
|
||||
onChanged: {
|
||||
if (arguments[1] === -1 || arguments[1] === model.modelId)
|
||||
notesButton.updateNotes();
|
||||
}
|
||||
}
|
||||
// This will only be called if notesModel != null.
|
||||
if (arguments[1] === -1 || arguments[1] === model.modelId) {
|
||||
var notes = notesModel.byTimelineModel(model.modelId);
|
||||
var newTexts = [];
|
||||
var newEventIds = [];
|
||||
for (var i in notes) {
|
||||
newTexts.push(notesModel.text(notes[i]))
|
||||
newEventIds.push(notesModel.timelineIndex(notes[i]));
|
||||
}
|
||||
|
||||
function updateNotes() {
|
||||
var notes = notesModel.byTimelineModel(model.modelId);
|
||||
var newTexts = [];
|
||||
var newEventIds = [];
|
||||
for (var i in notes) {
|
||||
newTexts.push(notesModel.text(notes[i]))
|
||||
newEventIds.push(notesModel.timelineIndex(notes[i]));
|
||||
// Bindings are only triggered when assigning the whole array.
|
||||
notesButton.eventIds = newEventIds;
|
||||
notesButton.texts = newTexts;
|
||||
}
|
||||
}
|
||||
|
||||
// Bindings are only triggered when assigning the whole array.
|
||||
eventIds = newEventIds;
|
||||
texts = newTexts;
|
||||
}
|
||||
|
||||
visible: eventIds.length > 0
|
||||
|
||||
@@ -125,7 +125,7 @@ Rectangle {
|
||||
property color noteColor: "orange"
|
||||
readonly property double spacing: parent.width / zoomer.traceDuration
|
||||
|
||||
model: modelProxy.notes.count
|
||||
model: modelProxy.notes ? modelProxy.notes.count : 0
|
||||
Item {
|
||||
property int timelineIndex: modelProxy.notes.timelineIndex(index)
|
||||
property int timelineModel: modelProxy.notes.timelineModel(index)
|
||||
|
||||
@@ -112,7 +112,7 @@ Item {
|
||||
}
|
||||
|
||||
noteEdit.focus = false;
|
||||
var noteId = notes.get(timelineModel.modelId, selectedItem);
|
||||
var noteId = notes ? notes.get(timelineModel.modelId, selectedItem) : -1;
|
||||
noteEdit.text = (noteId !== -1) ? notes.text(noteId) : "";
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ Item {
|
||||
anchors.bottomMargin: 5
|
||||
anchors.top: col.bottom
|
||||
|
||||
visible: text.length > 0 || focus
|
||||
visible: notes && (text.length > 0 || focus)
|
||||
width: col.width
|
||||
wrapMode: Text.Wrap
|
||||
color: "orange"
|
||||
@@ -229,14 +229,15 @@ Item {
|
||||
onFocusChanged: {
|
||||
if (!focus && selectedModel != -1 && selectedItem != -1) {
|
||||
saveTimer.stop();
|
||||
notes.setText(models[selectedModel].modelId, selectedItem, text);
|
||||
if (notes)
|
||||
notes.setText(models[selectedModel].modelId, selectedItem, text);
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: saveTimer
|
||||
onTriggered: {
|
||||
if (selectedModel != -1 && selectedItem != -1)
|
||||
if (notes && selectedModel != -1 && selectedItem != -1)
|
||||
notes.setText(models[selectedModel].modelId, selectedItem, noteEdit.text);
|
||||
}
|
||||
interval: 1000
|
||||
@@ -260,6 +261,7 @@ Item {
|
||||
anchors.top: closeIcon.top
|
||||
anchors.right: lockIcon.left
|
||||
anchors.rightMargin: 4
|
||||
visible: notes
|
||||
width: 8
|
||||
height: 12
|
||||
MouseArea {
|
||||
|
||||
@@ -71,7 +71,8 @@ void TimelineModelAggregator::addModel(TimelineModel *m)
|
||||
{
|
||||
d->modelList << m;
|
||||
connect(m,SIGNAL(heightChanged()),this,SIGNAL(heightChanged()));
|
||||
d->notesModel->addTimelineModel(m);
|
||||
if (d->notesModel)
|
||||
d->notesModel->addTimelineModel(m);
|
||||
emit modelsChanged();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user