[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [rocs] RocsCore/DataStructures/LinkedList: Simplify code.
From: Andreas Cord-Landwehr <cordlandwehr () kde ! org>
Date: 2013-05-21 19:26:12
Message-ID: 20130521192612.73AF9A6071 () git ! kde ! org
[Download RAW message or body]
Git commit ac677931db6c0c44bfbd2007f4b1f38373c8e4cc by Andreas Cord-Landwehr.
Committed on 20/05/2013 at 23:00.
Pushed by cordlandwehr into branch 'master'.
Simplify code.
The arrangeNodes method is typical use case for signals/slots.
M +2 -8 RocsCore/DataStructures/LinkedList/ListStructure.cpp
M +3 -1 RocsCore/DataStructures/LinkedList/ListStructure.h
http://commits.kde.org/rocs/ac677931db6c0c44bfbd2007f4b1f38373c8e4cc
diff --git a/RocsCore/DataStructures/LinkedList/ListStructure.cpp \
b/RocsCore/DataStructures/LinkedList/ListStructure.cpp index e962236..4079358 100644
--- a/RocsCore/DataStructures/LinkedList/ListStructure.cpp
+++ b/RocsCore/DataStructures/LinkedList/ListStructure.cpp
@@ -83,11 +83,12 @@ void Rocs::ListStructure::importStructure(DataStructurePtr other)
void Rocs::ListStructure::init()
{
+ connect(this, SIGNAL(changed()), this, SLOT(arrangeNodes()));
+
m_animationGroup = new QParallelAnimationGroup(parent());
//FIXME only default data type considered
if (!dataList(0).isEmpty()) {
m_begin = boost::static_pointer_cast<ListNode>(dataList(0).first());
- arrangeNodes();
} else {
m_begin = boost::shared_ptr<ListNode>();
}
@@ -108,7 +109,6 @@ PointerPtr Rocs::ListStructure::createPointer(DataPtr from, \
DataPtr to, int poin }
PointerPtr e = DataStructure::createPointer(from, to, pointerType);
- arrangeNodes();
return e;
}
@@ -135,7 +135,6 @@ DataPtr Rocs::ListStructure::createData(const QString& name, int \
dataType) } else {
m_begin = n;
}
- arrangeNodes();
return n;
}
@@ -148,10 +147,8 @@ void Rocs::ListStructure::remove(DataPtr n)
p->remove();
}
DataStructure::remove(n);
- arrangeNodes();
}
-
QScriptValue Rocs::ListStructure::head()
{
return m_begin->scriptValue();
@@ -164,7 +161,6 @@ void Rocs::ListStructure::setHead(Data *headNode)
return;
}
m_begin = boost::static_pointer_cast<ListNode>(headNode->getData());
- arrangeNodes();
}
QScriptValue Rocs::ListStructure::begin()
@@ -186,7 +182,6 @@ void Rocs::ListStructure::setBegin(Data* node)
void Rocs::ListStructure::remove(PointerPtr ptr)
{
DataStructure::remove(ptr);
- arrangeNodes();
}
QScriptValue Rocs::ListStructure::createNode()
@@ -200,7 +195,6 @@ QScriptValue Rocs::ListStructure::createNode(int type)
\
DataStructure::addData(ListNode::create(getDataStructure(), \
generateUniqueIdentifier(), type), type) );
n->setEngine(engine());
- arrangeNodes();
return n->scriptValue();
}
diff --git a/RocsCore/DataStructures/LinkedList/ListStructure.h \
b/RocsCore/DataStructures/LinkedList/ListStructure.h index 372d1e0..b102913 100644
--- a/RocsCore/DataStructures/LinkedList/ListStructure.h
+++ b/RocsCore/DataStructures/LinkedList/ListStructure.h
@@ -104,9 +104,11 @@ public:
*/
Q_INVOKABLE void setBegin(Data* node);
+private slots:
+ void arrangeNodes();
+
private:
void init();
- void arrangeNodes();
boost::shared_ptr<ListNode> m_begin;
QParallelAnimationGroup* m_animationGroup;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic