Commit 89bc8f2f authored by Dmitry Kazakov's avatar Dmitry Kazakov

Remove KisModelIndexConverterAnimatedLayers

It is not used since the new implementation of the timeline docker
parent af1e0ef9
......@@ -111,7 +111,6 @@ set(kritaui_LIB_SRCS
kis_model_index_converter_base.cpp
kis_model_index_converter.cpp
kis_model_index_converter_show_all.cpp
kis_model_index_converter_animated_layers.cpp
kis_painting_assistant.cc
kis_painting_assistants_decoration.cpp
kis_painting_assistants_manager.cpp
......
/*
* Copyright (c) 2015 Jouni Pentikäinen <joupent@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_model_index_converter_animated_layers.h"
#include "kis_node_dummies_graph.h"
#include "kis_dummies_facade.h"
#include "kis_node_model.h"
KisModelIndexConverterAnimatedLayers::KisModelIndexConverterAnimatedLayers(KisDummiesFacadeBase *dummiesFacade, KisNodeModel *model)
: m_dummiesFacade(dummiesFacade),
m_model(model)
{}
KisNodeDummy *KisModelIndexConverterAnimatedLayers::dummyFromRow(int row, QModelIndex parent)
{
KisNodeDummy *parentDummy = parent.isValid() ?
dummyFromIndex(parent) : m_dummiesFacade->rootDummy();
if(!parentDummy) return 0;
KisNodeDummy *resultDummy = 0;
KisNodeDummy *currentDummy = parentDummy->lastChild();
while (currentDummy) {
if (currentDummy->node()->isAnimated()) {
if (!row) {
resultDummy = currentDummy;
break;
}
row--;
}
currentDummy = currentDummy->prevSibling();
}
return resultDummy;
}
KisNodeDummy *KisModelIndexConverterAnimatedLayers::dummyFromIndex(QModelIndex index)
{
Q_ASSERT(index.isValid());
Q_ASSERT(index.internalPointer());
return static_cast<KisNodeDummy*>(index.internalPointer());
}
QModelIndex KisModelIndexConverterAnimatedLayers::indexFromDummy(KisNodeDummy *dummy)
{
Q_ASSERT(dummy);
KisNodeDummy *parentDummy = dummy->parent();
// a root node
if (!parentDummy) return QModelIndex();
if (!dummy->node()->isAnimated()) return QModelIndex();
int row = 0;
KisNodeDummy *currentDummy = parentDummy->lastChild();
while (currentDummy && currentDummy != dummy) {
if(currentDummy->node()->isAnimated()) {
row++;
}
currentDummy = currentDummy->prevSibling();
}
return m_model->createIndex(row, 0, (void*)dummy);
}
bool KisModelIndexConverterAnimatedLayers::indexFromAddedDummy(KisNodeDummy *parentDummy, int index, const QString &newNodeMetaObjectType, bool isAnimated, QModelIndex &parentIndex, int &row)
{
Q_UNUSED(newNodeMetaObjectType);
// adding a root node
if (!parentDummy) {
Q_ASSERT(!index);
return false;
}
if (!isAnimated) {
return false;
}
row = 0;
parentIndex = indexFromDummy(parentDummy);
KisNodeDummy *dummy = parentDummy->lastChild();
int toScan = parentDummy->childCount() - index;
while (dummy && toScan > 0) {
if(dummy->node()->isAnimated()) {
row++;
}
dummy = dummy->prevSibling();
toScan--;
}
return true;
}
int KisModelIndexConverterAnimatedLayers::rowCount(QModelIndex parent)
{
KisNodeDummy *dummy = parent.isValid() ?
dummyFromIndex(parent) : m_dummiesFacade->rootDummy();
// a root node (hidden)
if(!dummy) return 0;
int numChildren = 0;
KisNodeDummy *currentDummy = dummy->lastChild();
while(currentDummy) {
if(currentDummy->node()->isAnimated()) {
numChildren++;
}
currentDummy = currentDummy->prevSibling();
}
return numChildren;
}
/*
* Copyright (c) 2015 Jouni Pentikäinen <joupent@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_MODEL_INDEX_CONVERTER_ANIMATER_LAYERS_H_
#define _KIS_MODEL_INDEX_CONVERTER_ANIMATER_LAYERS_H_
#include "kis_model_index_converter_base.h"
class KisDummiesFacadeBase;
class KisNodeModel;
class KRITAUI_EXPORT KisModelIndexConverterAnimatedLayers : public KisModelIndexConverterBase
{
public:
KisModelIndexConverterAnimatedLayers(KisDummiesFacadeBase *dummiesFacade,
KisNodeModel *model);
KisNodeDummy *dummyFromRow(int row, QModelIndex parent);
KisNodeDummy *dummyFromIndex(QModelIndex index);
QModelIndex indexFromDummy(KisNodeDummy *dummy);
bool indexFromAddedDummy(KisNodeDummy *parentDummy, int index, const QString &newNodeMetaObjectType, bool isAnimated, QModelIndex &parentIndex, int &row);
int rowCount(QModelIndex parent);
private:
KisDummiesFacadeBase *m_dummiesFacade;
KisNodeModel *m_model;
};
#endif
......@@ -113,7 +113,6 @@ protected:
private:
friend class KisModelIndexConverter;
friend class KisModelIndexConverterShowAll;
friend class KisModelIndexConverterAnimatedLayers;
void connectDummy(KisNodeDummy *dummy, bool needConnect);
void connectDummies(KisNodeDummy *dummy, bool needConnect);
......
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