| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2014-01-07 13:27:11 +01:00
										 |  |  | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | ** Contact: http://www.qt-project.org/legal
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** 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 | 
					
						
							|  |  |  | ** a written agreement between you and Digia.  For licensing terms and | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** conditions see http://www.qt.io/licensing.  For further information
 | 
					
						
							|  |  |  | ** use the contact form at http://www.qt.io/contact-us.
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** General Public License version 2.1 or version 3 as published by the Free | 
					
						
							|  |  |  | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | 
					
						
							|  |  |  | ** LICENSE.LGPLv3 included in the packaging of this file.  Please review the | 
					
						
							|  |  |  | ** following information to ensure the GNU Lesser General Public License | 
					
						
							|  |  |  | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
 | 
					
						
							|  |  |  | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** In addition, as a special exception, Digia gives you certain additional | 
					
						
							|  |  |  | ** rights.  These rights are described in the Digia Qt LGPL Exception | 
					
						
							|  |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "timelinemodelaggregator.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "qmlprofilertimelinemodelproxy.h"
 | 
					
						
							|  |  |  | #include "qmlprofilerpainteventsmodelproxy.h"
 | 
					
						
							|  |  |  | #include "qmlprofilerplugin.h"
 | 
					
						
							| 
									
										
										
										
											2014-09-26 15:49:49 +02:00
										 |  |  | #include "notesmodel.h"
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QStringList>
 | 
					
						
							|  |  |  | #include <QVariant>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace QmlProfiler { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TimelineModelAggregator::TimelineModelAggregatorPrivate { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     TimelineModelAggregatorPrivate(TimelineModelAggregator *qq):q(qq) {} | 
					
						
							|  |  |  |     ~TimelineModelAggregatorPrivate() {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     TimelineModelAggregator *q; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-26 15:49:49 +02:00
										 |  |  |     // mapping of modelId assigned by manager to index in our list
 | 
					
						
							|  |  |  |     QList <int> modelManagerIndexMapping; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     QList <AbstractTimelineModel *> modelList; | 
					
						
							|  |  |  |     QmlProfilerModelManager *modelManager; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TimelineModelAggregator::TimelineModelAggregator(QObject *parent) | 
					
						
							|  |  |  |     : QObject(parent), d(new TimelineModelAggregatorPrivate(this)) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-02 12:45:18 +02:00
										 |  |  |     connect(this,SIGNAL(modelsChanged(int,int)),this,SIGNAL(heightChanged())); | 
					
						
							|  |  |  |     connect(this,SIGNAL(stateChanged()),this,SIGNAL(heightChanged())); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TimelineModelAggregator::~TimelineModelAggregator() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete d; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-02 12:45:18 +02:00
										 |  |  | int TimelineModelAggregator::height() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-29 16:49:31 +02:00
										 |  |  |     return modelOffset(d->modelList.length()); | 
					
						
							| 
									
										
										
										
											2014-09-02 12:45:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | void TimelineModelAggregator::setModelManager(QmlProfilerModelManager *modelManager) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d->modelManager = modelManager; | 
					
						
							|  |  |  |     connect(modelManager,SIGNAL(stateChanged()),this,SLOT(dataChanged())); | 
					
						
							|  |  |  |     connect(modelManager,SIGNAL(dataAvailable()),this,SIGNAL(dataAvailable())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // external models pushed on top
 | 
					
						
							|  |  |  |     foreach (AbstractTimelineModel *timelineModel, QmlProfilerPlugin::instance->getModels()) { | 
					
						
							|  |  |  |         timelineModel->setModelManager(modelManager); | 
					
						
							|  |  |  |         addModel(timelineModel); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     PaintEventsModelProxy *paintEventsModelProxy = new PaintEventsModelProxy(this); | 
					
						
							|  |  |  |     paintEventsModelProxy->setModelManager(modelManager); | 
					
						
							|  |  |  |     addModel(paintEventsModelProxy); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-06 17:36:11 +02:00
										 |  |  |     for (int i = 0; i < QmlDebug::MaximumRangeType; ++i) { | 
					
						
							|  |  |  |         RangeTimelineModel *rangeModel = new RangeTimelineModel((QmlDebug::RangeType)i, this); | 
					
						
							|  |  |  |         rangeModel->setModelManager(modelManager); | 
					
						
							|  |  |  |         addModel(rangeModel); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-06-13 19:14:12 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Connect this last so that it's executed after the models have updated their data.
 | 
					
						
							|  |  |  |     connect(modelManager->qmlModel(),SIGNAL(changed()),this,SIGNAL(stateChanged())); | 
					
						
							| 
									
										
										
										
											2014-09-26 15:49:49 +02:00
										 |  |  |     connect(modelManager->notesModel(), SIGNAL(changed(int,int,int)), | 
					
						
							|  |  |  |             this, SIGNAL(notesChanged(int,int,int))); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void TimelineModelAggregator::addModel(AbstractTimelineModel *m) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-26 15:49:49 +02:00
										 |  |  |     while (d->modelManagerIndexMapping.size() <= m->modelId()) | 
					
						
							|  |  |  |         d->modelManagerIndexMapping.append(-1); | 
					
						
							|  |  |  |     d->modelManagerIndexMapping[m->modelId()] = d->modelList.size(); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     d->modelList << m; | 
					
						
							|  |  |  |     connect(m,SIGNAL(expandedChanged()),this,SIGNAL(expandedChanged())); | 
					
						
							| 
									
										
										
										
											2014-09-11 11:20:52 +02:00
										 |  |  |     connect(m,SIGNAL(hiddenChanged()),this,SIGNAL(hiddenChanged())); | 
					
						
							| 
									
										
										
										
											2014-06-18 11:20:41 +02:00
										 |  |  |     connect(m,SIGNAL(rowHeightChanged()),this,SIGNAL(rowHeightChanged())); | 
					
						
							| 
									
										
										
										
											2014-09-02 12:45:18 +02:00
										 |  |  |     connect(m,SIGNAL(heightChanged()),this,SIGNAL(heightChanged())); | 
					
						
							| 
									
										
										
										
											2014-09-26 15:49:49 +02:00
										 |  |  |     d->modelManager->notesModel()->addTimelineModel(m); | 
					
						
							| 
									
										
										
										
											2014-08-27 12:11:26 +02:00
										 |  |  |     emit modelsChanged(d->modelList.length(), d->modelList.length()); | 
					
						
							| 
									
										
										
										
											2014-08-27 13:48:25 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-02 12:45:18 +02:00
										 |  |  | const AbstractTimelineModel *TimelineModelAggregator::model(int modelIndex) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList[modelIndex]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-27 13:48:25 +02:00
										 |  |  | QVariantList TimelineModelAggregator::models() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QVariantList ret; | 
					
						
							|  |  |  |     foreach (AbstractTimelineModel *model, d->modelList) | 
					
						
							|  |  |  |         ret << QVariant::fromValue(model); | 
					
						
							|  |  |  |     return ret; | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-26 15:49:49 +02:00
										 |  |  | int TimelineModelAggregator::modelIndexFromManagerIndex(int modelManagerIndex) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelManagerIndexMapping[modelManagerIndex]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | NotesModel *TimelineModelAggregator::notes() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelManager->notesModel(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | int TimelineModelAggregator::count(int modelIndex) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-29 12:36:29 +02:00
										 |  |  |     return d->modelList[modelIndex]->count(); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool TimelineModelAggregator::isEmpty() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     foreach (const AbstractTimelineModel *modelProxy, d->modelList) | 
					
						
							|  |  |  |         if (!modelProxy->isEmpty()) | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-29 16:49:31 +02:00
										 |  |  | int TimelineModelAggregator::modelOffset(int modelIndex) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int ret = 0; | 
					
						
							|  |  |  |     for (int i = 0; i < modelIndex; ++i) | 
					
						
							|  |  |  |         ret += d->modelList[i]->height(); | 
					
						
							|  |  |  |     return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 11:20:41 +02:00
										 |  |  | int TimelineModelAggregator::rowHeight(int modelIndex, int row) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList[modelIndex]->rowHeight(row); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int TimelineModelAggregator::rowOffset(int modelIndex, int row) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList[modelIndex]->rowOffset(row); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void TimelineModelAggregator::setRowHeight(int modelIndex, int row, int height) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d->modelList[modelIndex]->setRowHeight(row, height); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-06 17:36:11 +02:00
										 |  |  | bool TimelineModelAggregator::expanded(int modelIndex) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-06-06 17:36:11 +02:00
										 |  |  |     return d->modelList[modelIndex]->expanded(); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-06 17:36:11 +02:00
										 |  |  | void TimelineModelAggregator::setExpanded(int modelIndex, bool expanded) | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-06-06 17:36:11 +02:00
										 |  |  |     d->modelList[modelIndex]->setExpanded(expanded); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-11 11:20:52 +02:00
										 |  |  | bool TimelineModelAggregator::hidden(int modelIndex) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList[modelIndex]->hidden(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void TimelineModelAggregator::setHidden(int modelIndex, bool hidden) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d->modelList[modelIndex]->setHidden(hidden); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | int TimelineModelAggregator::rowCount(int modelIndex) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList[modelIndex]->rowCount(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 13:40:35 +02:00
										 |  |  | QString TimelineModelAggregator::displayName(int modelIndex) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 13:40:35 +02:00
										 |  |  |     return d->modelList[modelIndex]->displayName(); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-23 12:34:37 +02:00
										 |  |  | int TimelineModelAggregator::rowMinValue(int modelIndex, int row) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList[modelIndex]->rowMinValue(row); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int TimelineModelAggregator::rowMaxValue(int modelIndex, int row) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList[modelIndex]->rowMaxValue(row); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | int TimelineModelAggregator::firstIndex(int modelIndex, qint64 startTime) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->firstIndex(startTime); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | int TimelineModelAggregator::firstIndexNoParents(int modelIndex, qint64 startTime) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->firstIndexNoParents(startTime); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | int TimelineModelAggregator::lastIndex(int modelIndex, qint64 endTime) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->lastIndex(endTime); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | int TimelineModelAggregator::row(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->row(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | qint64 TimelineModelAggregator::duration(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->duration(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | qint64 TimelineModelAggregator::startTime(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->startTime(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | qint64 TimelineModelAggregator::endTime(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->endTime(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-29 16:32:42 +02:00
										 |  |  | int TimelineModelAggregator::selectionId(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-08-29 16:32:42 +02:00
										 |  |  |     return d->modelList[modelIndex]->selectionId(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-29 16:24:34 +02:00
										 |  |  | int TimelineModelAggregator::typeId(int modelIndex, int index) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList[modelIndex]->typeId(index); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | int TimelineModelAggregator::bindingLoopDest(int modelIndex,int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->bindingLoopDest(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | QColor TimelineModelAggregator::color(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->color(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-02 12:19:33 +02:00
										 |  |  | float TimelineModelAggregator::relativeHeight(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-02 12:19:33 +02:00
										 |  |  |     return d->modelList[modelIndex]->relativeHeight(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | QVariantList TimelineModelAggregator::labels(int modelIndex) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->labels(); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-07 14:02:29 +02:00
										 |  |  | QVariantMap TimelineModelAggregator::details(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->details(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  | QVariantMap TimelineModelAggregator::location(int modelIndex, int index) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-08 14:43:15 +02:00
										 |  |  |     return d->modelList[modelIndex]->location(index); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-29 16:32:42 +02:00
										 |  |  | bool TimelineModelAggregator::isSelectionIdValid(int modelIndex, int typeIndex) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-08-29 16:32:42 +02:00
										 |  |  |     return d->modelList[modelIndex]->isSelectionIdValid(typeIndex); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-29 16:32:42 +02:00
										 |  |  | int TimelineModelAggregator::selectionIdForLocation(int modelIndex, const QString &filename, | 
					
						
							| 
									
										
										
										
											2014-06-12 13:08:08 +02:00
										 |  |  |                                                    int line, int column) const | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-08-29 16:32:42 +02:00
										 |  |  |     return d->modelList[modelIndex]->selectionIdForLocation(filename, line, column); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-27 12:11:26 +02:00
										 |  |  | void TimelineModelAggregator::swapModels(int modelIndex1, int modelIndex2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-26 15:49:49 +02:00
										 |  |  |     AbstractTimelineModel *&model1 = d->modelList[modelIndex1]; | 
					
						
							|  |  |  |     AbstractTimelineModel *&model2 = d->modelList[modelIndex2]; | 
					
						
							|  |  |  |     std::swap(d->modelManagerIndexMapping[model1->modelId()], | 
					
						
							|  |  |  |               d->modelManagerIndexMapping[model2->modelId()]); | 
					
						
							|  |  |  |     std::swap(model1, model2); | 
					
						
							| 
									
										
										
										
											2014-08-27 12:11:26 +02:00
										 |  |  |     emit modelsChanged(modelIndex1, modelIndex2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-26 15:49:49 +02:00
										 |  |  | QString TimelineModelAggregator::noteText(int noteId) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelManager->notesModel()->text(noteId); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString TimelineModelAggregator::noteText(int modelIndex, int index) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int managerId = d->modelList[modelIndex]->modelId(); | 
					
						
							|  |  |  |     int noteId = d->modelManager->notesModel()->get(managerId, index); | 
					
						
							|  |  |  |     return noteId != -1 ? noteText(noteId) : QString(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void TimelineModelAggregator::setNoteText(int noteId, const QString &text) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (text.length() > 0) { | 
					
						
							|  |  |  |         notes()->update(noteId, text); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         notes()->remove(noteId); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void TimelineModelAggregator::setNoteText(int modelIndex, int index, const QString &text) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int managerId = d->modelList[modelIndex]->modelId(); | 
					
						
							|  |  |  |     NotesModel *notesModel = notes(); | 
					
						
							|  |  |  |     int noteId = notesModel->get(managerId, index); | 
					
						
							|  |  |  |     if (noteId == -1) { | 
					
						
							|  |  |  |         if (text.length() > 0) | 
					
						
							|  |  |  |             notesModel->add(managerId, index, text); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         setNoteText(noteId, text); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int TimelineModelAggregator::noteTimelineModel(int noteIndex) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelManagerIndexMapping[notes()->timelineModel(noteIndex)]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int TimelineModelAggregator::noteTimelineIndex(int noteIndex) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return notes()->timelineIndex(noteIndex); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QVariantList TimelineModelAggregator::notesByTimelineModel(int modelIndex) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int managerId = d->modelList[modelIndex]->modelId(); | 
					
						
							|  |  |  |     return notes()->byTimelineModel(managerId); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QVariantList TimelineModelAggregator::notesByTypeId(int typeId) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return notes()->byTypeId(typeId); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int TimelineModelAggregator::noteCount() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return notes()->count(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | void TimelineModelAggregator::dataChanged() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // this is a slot connected for every modelproxy
 | 
					
						
							|  |  |  |     // nothing to do here, each model will take care of itself
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int TimelineModelAggregator::modelCount() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->modelList.count(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace QmlProfiler
 |