Git commit e52045e31479ab9cafcb4db4276a8549ae64008a by Paul Mendez. Committed on 01/08/2012 at 00:56. Pushed by mendez into branch 'stage-paulm-test3'. Remove node type method of KPrShapeAnimation class M +32 -26 stage/part/KPrShapeAnimations.cpp M +9 -1 stage/part/KPrShapeAnimations.h M +0 -14 stage/part/animations/KPrShapeAnimation.cpp M +0 -15 stage/part/animations/KPrShapeAnimation.h M +0 -1 stage/part/tools/animationtool/KPrPredefinedAnimationsLoader= .cpp M +3 -3 stage/part/tools/animationtool/KPrShapeAnimationDocker.cpp http://commits.kde.org/calligra/e52045e31479ab9cafcb4db4276a8549ae64008a diff --git a/stage/part/KPrShapeAnimations.cpp b/stage/part/KPrShapeAnimati= ons.cpp index 429a21a..92b08a1 100644 --- a/stage/part/KPrShapeAnimations.cpp +++ b/stage/part/KPrShapeAnimations.cpp @@ -87,19 +87,20 @@ QVariant KPrShapeAnimations::data(const QModelIndex &in= dex, int role) const } = // Read Data - int groupCount =3D -1; + AnimationTmpData currentData; + currentData.group =3D -1; int thisRow =3D index.row(); - KPrShapeAnimation *thisAnimation =3D animationByRow(thisRow, groupCoun= t); + KPrShapeAnimation *thisAnimation =3D animationByRow(thisRow, currentDa= ta); if (!thisAnimation) { return QVariant(); } = if (role =3D=3D Qt::DisplayRole || role =3D=3D Qt::EditRole) { switch (index.column()) { - case Group: return groupCount; + case Group: return currentData.group; case StepCount: - if (thisAnimation->nodeType() =3D=3D KPrShapeAnimation::On= Click) { - return groupCount; + if (currentData.nodeType =3D=3D KPrShapeAnimation::OnClick= ) { + return currentData.group; } else { return QVariant(); @@ -111,7 +112,7 @@ QVariant KPrShapeAnimations::data(const QModelIndex &in= dex, int role) const case StartTime: return thisAnimation->timeRange().first; case Duration: return thisAnimation->globalDuration(); case AnimationClass: return thisAnimation->presetClass(); - case NodeType: return thisAnimation->nodeType(); + case NodeType: return currentData.nodeType; default: Q_ASSERT(false); } } @@ -126,13 +127,13 @@ QVariant KPrShapeAnimations::data(const QModelIndex &= index, int role) const case Group: return QVariant(); case StepCount: return QVariant(); case TriggerEvent: - if (thisAnimation->nodeType() =3D=3D KPrShapeAnimation::On= Click) + if (currentData.nodeType =3D=3D KPrShapeAnimation::OnClick) return KIcon("onclick").pixmap(KIconLoader::SizeSmall, KIconLoader::SizeSmall); - if (thisAnimation->nodeType() =3D=3D KPrShapeAnimation::Af= terPrevious) + if (currentData.nodeType =3D=3D KPrShapeAnimation::AfterPr= evious) return KIcon("after_previous").pixmap(KIconLoader::Siz= eSmall, KIconLoader::Siz= eSmall); - if (thisAnimation->nodeType() =3D=3D KPrShapeAnimation::Wi= thPrevious) + if (currentData.nodeType =3D=3D KPrShapeAnimation::WithPre= vious) return KIcon("with_previous").pixmap(KIconLoader::Size= Small, KIconLoader::Size= Small); case Name: return QVariant(); @@ -165,11 +166,11 @@ QVariant KPrShapeAnimations::data(const QModelIndex &= index, int role) const case Group: case StepCount: return QVariant(); case TriggerEvent: - if (thisAnimation->nodeType() =3D=3D KPrShapeAnimation::On= Click) + if (currentData.nodeType =3D=3D KPrShapeAnimation::OnClick) return i18n("start on mouse click"); - if (thisAnimation->nodeType() =3D=3D KPrShapeAnimation::Af= terPrevious) + if (currentData.nodeType =3D=3D KPrShapeAnimation::AfterPr= evious) return i18n("start after previous animation"); - if (thisAnimation->nodeType() =3D=3D KPrShapeAnimation::Wi= thPrevious) + if (currentData.nodeType =3D=3D KPrShapeAnimation::WithPre= vious) return i18n("start with previous animation"); case Name: return QVariant(); case ShapeThumbnail: return thisAnimation->shape()->name(); @@ -238,8 +239,7 @@ bool KPrShapeAnimations::setData(const QModelIndex &ind= ex, const QVariant &value return false; } // Read Data - int groupCount =3D -1; - KPrShapeAnimation *thisAnimation =3D animationByRow(index.row(), group= Count); + KPrShapeAnimation *thisAnimation =3D animationByRow(index.row()); if (!thisAnimation) { return false; } @@ -396,11 +396,6 @@ void KPrShapeAnimations::swapAnimations(KPrShapeAnimat= ion *oldAnimation, KPrShap QModelIndex indexNew =3D indexByAnimation(newAnimation); emit dataChanged(this->index(indexOld.row(), 0), this->index(indexOld.= row(), COLUMN_COUNT)); emit dataChanged(this->index(indexNew.row(), 0), this->index(indexNew.= row(), COLUMN_COUNT)); - if ((newAnimation->nodeType() =3D=3D KPrShapeAnimation::OnClick) || - (oldAnimation->nodeType() =3D=3D KPrShapeAnimation::OnClick)) { - notifyOnClickEventChanged(); - } - } = void KPrShapeAnimations::replaceAnimation(KPrShapeAnimation *oldAnimation,= KPrShapeAnimation *newAnimation) @@ -866,10 +861,10 @@ void KPrShapeAnimations::notifyOnClickEventChanged() emit onClickEventChanged(); } = -KPrShapeAnimation *KPrShapeAnimations::animationByRow(const int row, int &= groupCount) const +KPrShapeAnimation *KPrShapeAnimations::animationByRow(const int row, Anima= tionTmpData ¤tData) const { int rowCount =3D 0; - groupCount =3D 0; + int groupCount =3D 0; foreach (KPrAnimationStep *step, m_shapeAnimations) { int stepChild =3D -1; for (int i=3D0; i < step->animationCount(); i++) { @@ -883,16 +878,17 @@ KPrShapeAnimation *KPrShapeAnimations::animationByRow= (const int row, int &groupC stepChild++; subStepChild++; if (stepChild =3D=3D 0) { - b->setNodeType(KPrShapeAnimation::OnClick); + currentData.nodeType =3D KPrShapeAnimation= ::OnClick; groupCount =3D groupCount + 1; } else if (subStepChild =3D=3D 0) { - b->setNodeType(KPrShapeAnimation::AfterPre= vious); + currentData.nodeType =3D KPrShapeAnimation= ::AfterPrevious; } else { - b->setNodeType(KPrShapeAnimation::WithPrev= ious); + currentData.nodeType =3D KPrShapeAnimation= ::WithPrevious; } if (rowCount =3D=3D row) { + currentData.group =3D groupCount; return b; } rowCount++; @@ -907,8 +903,8 @@ KPrShapeAnimation *KPrShapeAnimations::animationByRow(c= onst int row, int &groupC = KPrShapeAnimation *KPrShapeAnimations::animationByRow(const int row) const { - int groupCount =3D 0; - return animationByRow(row, groupCount); + AnimationTmpData tmpData; + return animationByRow(row, tmpData); } = void KPrShapeAnimations::insertNewAnimation(KPrShapeAnimation *newAnimatio= n, const QModelIndex &previousAnimation) @@ -1081,6 +1077,16 @@ void KPrShapeAnimations::resyncStepsWithAnimations() } } = +KPrShapeAnimation::NodeType KPrShapeAnimations::triggerEventByIndex(const = QModelIndex &index) +{ + Q_ASSERT(index.isValid()); + AnimationTmpData currentData; + currentData.group =3D -1; + int thisRow =3D index.row(); + animationByRow(thisRow, currentData); + return currentData.nodeType; +} + QList KPrShapeAnimations::getWithPreviousSiblings(KPr= ShapeAnimation *animation) { bool startAdding =3D false; diff --git a/stage/part/KPrShapeAnimations.h b/stage/part/KPrShapeAnimation= s.h index b1bbfe2..8faa3ee 100644 --- a/stage/part/KPrShapeAnimations.h +++ b/stage/part/KPrShapeAnimations.h @@ -31,6 +31,12 @@ = class KPrDocument; = +struct AnimationTmpData +{ + int group; + KPrShapeAnimation::NodeType nodeType; +}; + = /** * Model for Animations data of each KPrPage @@ -276,6 +282,8 @@ public: = void resyncStepsWithAnimations(); = + KPrShapeAnimation::NodeType triggerEventByIndex(const QModelIndex &ind= ex); + public slots: /// Notify a external edition of begin or end time void notifyAnimationEdited(); @@ -291,7 +299,7 @@ signals: void onClickEventChanged(); = private: - KPrShapeAnimation *animationByRow(const int row, int &groupCount) cons= t; + KPrShapeAnimation *animationByRow(const int row, AnimationTmpData &cur= rentData) const; QString getAnimationName(KPrShapeAnimation *animation, bool omitSubTyp= e =3D false) const; QPixmap getAnimationShapeThumbnail(KPrShapeAnimation *animation) const; QPixmap getAnimationIcon(KPrShapeAnimation *animation) const; diff --git a/stage/part/animations/KPrShapeAnimation.cpp b/stage/part/anima= tions/KPrShapeAnimation.cpp index 239e1fc..3fabbf6 100644 --- a/stage/part/animations/KPrShapeAnimation.cpp +++ b/stage/part/animations/KPrShapeAnimation.cpp @@ -212,15 +212,6 @@ void KPrShapeAnimation::deactivate() // onClick would create a new animation // when putting data in it could check if the shape is the correct one if = not create a parallel one (with previous) = - - -void KPrShapeAnimation::setNodeType(KPrShapeAnimation::NodeType type) -{ - if (type !=3D m_triggerEvent) { - m_triggerEvent =3D type; - } -} - void KPrShapeAnimation::setPresetClass(KPrShapeAnimation::PresetClass pres= etClass) { m_class =3D presetClass; @@ -236,11 +227,6 @@ void KPrShapeAnimation::setPresetSubType(QString subTy= pe) m_presetSubType =3D subType; } = -KPrShapeAnimation::NodeType KPrShapeAnimation::nodeType() const -{ - return m_triggerEvent; -} - KPrShapeAnimation::PresetClass KPrShapeAnimation::presetClass() const { return m_class; diff --git a/stage/part/animations/KPrShapeAnimation.h b/stage/part/animati= ons/KPrShapeAnimation.h index e53c2c2..1c79069 100644 --- a/stage/part/animations/KPrShapeAnimation.h +++ b/stage/part/animations/KPrShapeAnimation.h @@ -128,14 +128,6 @@ public: /// to different params of the animation /// Use set methods to mantain them in sync with the /// real animation data - /** - * @brief Set the node type of the animation - * used just like quick access, Node Type is actually - * determined using the step, substep structure - * - * @param type Node Type - */ - void setNodeType(NodeType type); = /** * @brief Set class of the animation @@ -154,13 +146,6 @@ public: void setPresetSubType(QString subType); = /** - * @brief Returns the stored node type for the animation - * - * @return Node_Type - */ - NodeType nodeType() const; - - /** * @brief Returns stored class of the animation * * @return Preset_Class diff --git a/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.c= pp b/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.cpp index 48beeee..48937b6 100644 --- a/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.cpp +++ b/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.cpp @@ -363,7 +363,6 @@ KPrShapeAnimation *KPrPredefinedAnimationsLoader::loadO= dfShapeAnimation(const Ko } = if (shapeAnimation) { - shapeAnimation->setNodeType(KPrShapeAnimation::OnClick); if (presetClass =3D=3D "custom") { shapeAnimation->setPresetClass(KPrShapeAnimation::Custom); } diff --git a/stage/part/tools/animationtool/KPrShapeAnimationDocker.cpp b/s= tage/part/tools/animationtool/KPrShapeAnimationDocker.cpp index eb89e67..60100ca 100644 --- a/stage/part/tools/animationtool/KPrShapeAnimationDocker.cpp +++ b/stage/part/tools/animationtool/KPrShapeAnimationDocker.cpp @@ -505,7 +505,6 @@ void KPrShapeAnimationDocker::showAnimationsCustomConte= xtMenu(const QPoint &pos) menu.addSeparator(); if ((m_animationsView->selectionModel()->selectedRows().count() =3D=3D= 1) && (m_animationsView->currentIndex().isValid())) { - KPrShapeAnimation *currentAnimation =3D m_animationsModel->animati= onByRow(m_animationsView->currentIndex().row()); QActionGroup *actionGroup =3D new QActionGroup(m_animationsView); actionGroup->setExclusive(true); KAction *onClickAction =3D new KAction(KIcon("onclick"), i18n("sta= rt on mouse click"), m_animationsView); @@ -523,10 +522,11 @@ void KPrShapeAnimationDocker::showAnimationsCustomCon= textMenu(const QPoint &pos) actionGroup->addAction(withAction); actionGroup->setExclusive(true); = - if (currentAnimation->nodeType() =3D=3D KPrShapeAnimation::OnClick= ) { + KPrShapeAnimation::NodeType currentNodeType =3D m_animationsModel-= >triggerEventByIndex(m_animationsView->currentIndex()); + if (currentNodeType =3D=3D KPrShapeAnimation::OnClick) { onClickAction->setChecked(true); } - else if (currentAnimation->nodeType() =3D=3D KPrShapeAnimation::Af= terPrevious) { + else if (currentNodeType =3D=3D KPrShapeAnimation::AfterPrevious) { afterAction->setChecked(true); } else {