2014-09-26 15:49:49 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-09-26 15:49:49 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-09-26 15:49:49 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-09-26 15:49:49 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-10-27 17:41:22 +01:00
|
|
|
#include "qmlprofilernotesmodel.h"
|
2014-12-10 12:53:49 +01:00
|
|
|
#include "qmlprofilerdatamodel.h"
|
2014-09-26 15:49:49 +02:00
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
|
2014-12-08 16:14:52 +01:00
|
|
|
QmlProfilerNotesModel::QmlProfilerNotesModel(QObject *parent) : TimelineNotesModel(parent),
|
|
|
|
|
m_modelManager(0)
|
2014-09-26 15:49:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-27 17:41:22 +01:00
|
|
|
void QmlProfilerNotesModel::setModelManager(QmlProfilerModelManager *modelManager)
|
2014-09-26 15:49:49 +02:00
|
|
|
{
|
|
|
|
|
m_modelManager = modelManager;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-27 17:41:22 +01:00
|
|
|
int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const QString &text)
|
2014-09-26 15:49:49 +02:00
|
|
|
{
|
|
|
|
|
int timelineModel = -1;
|
|
|
|
|
int timelineIndex = -1;
|
2014-12-09 11:01:23 +01:00
|
|
|
foreach (const Timeline::TimelineModel *model, timelineModels()) {
|
2014-12-05 17:33:21 +01:00
|
|
|
if (model->handlesTypeId(typeId)) {
|
2014-09-26 15:49:49 +02:00
|
|
|
for (int i = model->firstIndex(start); i <= model->lastIndex(start + duration); ++i) {
|
|
|
|
|
if (i < 0)
|
|
|
|
|
continue;
|
2014-10-27 18:42:39 +01:00
|
|
|
if (model->typeId(i) == typeId && model->startTime(i) == start &&
|
|
|
|
|
model->duration(i) == duration) {
|
2014-09-26 15:49:49 +02:00
|
|
|
timelineModel = model->modelId();
|
|
|
|
|
timelineIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (timelineIndex != -1)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (timelineModel == -1 || timelineIndex == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2014-12-08 16:14:52 +01:00
|
|
|
return TimelineNotesModel::add(timelineModel, timelineIndex, text);
|
2014-11-04 12:32:25 +01:00
|
|
|
}
|
|
|
|
|
|
2014-09-26 15:49:49 +02:00
|
|
|
|
2014-10-27 17:41:22 +01:00
|
|
|
void QmlProfilerNotesModel::loadData()
|
2014-09-26 15:49:49 +02:00
|
|
|
{
|
2014-12-08 16:14:52 +01:00
|
|
|
blockSignals(true);
|
|
|
|
|
clear();
|
2016-04-26 11:50:59 +02:00
|
|
|
const QVector<QmlNote> ¬es = m_modelManager->qmlModel()->notes();
|
2014-09-26 15:49:49 +02:00
|
|
|
for (int i = 0; i != notes.size(); ++i) {
|
2016-04-26 11:50:59 +02:00
|
|
|
const QmlNote ¬e = notes[i];
|
2014-09-26 15:49:49 +02:00
|
|
|
add(note.typeIndex, note.startTime, note.duration, note.text);
|
|
|
|
|
}
|
2014-12-08 16:14:52 +01:00
|
|
|
resetModified();
|
|
|
|
|
blockSignals(false);
|
2014-09-26 15:49:49 +02:00
|
|
|
emit changed(-1, -1, -1);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-27 17:41:22 +01:00
|
|
|
void QmlProfilerNotesModel::saveData()
|
2014-09-26 15:49:49 +02:00
|
|
|
{
|
2016-04-26 11:50:59 +02:00
|
|
|
QVector<QmlNote> notes;
|
2014-09-26 15:49:49 +02:00
|
|
|
for (int i = 0; i < count(); ++i) {
|
2014-12-09 11:01:23 +01:00
|
|
|
const Timeline::TimelineModel *model = timelineModelByModelId(timelineModel(i));
|
2014-12-08 16:14:52 +01:00
|
|
|
if (!model)
|
2014-09-26 15:49:49 +02:00
|
|
|
continue;
|
|
|
|
|
|
2014-12-08 16:14:52 +01:00
|
|
|
int index = timelineIndex(i);
|
2016-04-26 11:50:59 +02:00
|
|
|
QmlNote save = {
|
2014-12-08 16:14:52 +01:00
|
|
|
model->typeId(index),
|
|
|
|
|
model->startTime(index),
|
|
|
|
|
model->duration(index),
|
|
|
|
|
text(i)
|
2014-09-26 15:49:49 +02:00
|
|
|
};
|
|
|
|
|
notes.append(save);
|
|
|
|
|
}
|
2016-04-26 11:50:59 +02:00
|
|
|
m_modelManager->qmlModel()->setNotes(notes);
|
2014-12-08 16:14:52 +01:00
|
|
|
resetModified();
|
2014-09-26 15:49:49 +02:00
|
|
|
}
|
|
|
|
|
}
|