# HG changeset patch
# User Santeri Piippo
# Date 1520089009 -7200
# Node ID 0384b1d49786c4692ac2fb60f8707e2ce7d3fbe5
# Parent  f5921a474d57176e495aaecb6d93a9abae28a116
moved LDObject::next to the algorithm toolset

diff -r f5921a474d57 -r 0384b1d49786 src/linetypes/modelobject.cpp
--- a/src/linetypes/modelobject.cpp	Sat Mar 03 16:53:56 2018 +0200
+++ b/src/linetypes/modelobject.cpp	Sat Mar 03 16:56:49 2018 +0200
@@ -271,15 +271,6 @@
 
 // =============================================================================
 //
-// Object after this in the current file
-//
-LDObject* LDObject::next()
-{
-	return model()->getObject(model()->indexOf(this).row() + 1);
-}
-
-// =============================================================================
-//
 // Moves this object using the given vertex as a movement List
 //
 void LDObject::move (Vertex vect)
diff -r f5921a474d57 -r 0384b1d49786 src/linetypes/modelobject.h
--- a/src/linetypes/modelobject.h	Sat Mar 03 16:53:56 2018 +0200
+++ b/src/linetypes/modelobject.h	Sat Mar 03 16:56:49 2018 +0200
@@ -73,7 +73,6 @@
 	virtual bool isScemantic() const; // Does this object have meaning in the part model?
 	bool isSelected() const;
 	void move (Vertex vect);
-	LDObject* next();
 	virtual int numVertices() const;
 	virtual int numPolygonVertices() const;
 	virtual QString objectListText() const;
diff -r f5921a474d57 -r 0384b1d49786 src/toolsets/algorithmtoolset.cpp
--- a/src/toolsets/algorithmtoolset.cpp	Sat Mar 03 16:53:56 2018 +0200
+++ b/src/toolsets/algorithmtoolset.cpp	Sat Mar 03 16:56:49 2018 +0200
@@ -306,6 +306,16 @@
 	return false;
 }
 
+LDObject* AlgorithmToolset::next(LDObject* object)
+{
+	QModelIndex index = currentDocument()->indexOf(object);
+
+	if (index.isValid())
+		return currentDocument()->getObject(index.row() + 1);
+	else
+		return nullptr;
+}
+
 void AlgorithmToolset::autocolor()
 {
 	LDColor color;
@@ -351,8 +361,8 @@
 
 	// Find a spot to place the new comment
 	for (obj = currentDocument()->getObject (0);
-		obj and obj->next() and not obj->next()->isScemantic();
-		obj = obj->next())
+		obj and next(obj) and not next(obj)->isScemantic();
+		obj = next(obj))
 	{
 		LDComment* comment = dynamic_cast<LDComment*> (obj);
 
@@ -375,7 +385,7 @@
 
 	// If we're adding a history line right before a scemantic object, pad it
 	// an empty line
-	if (obj and obj->next() and obj->next()->isScemantic())
+	if (obj and next(obj) and next(obj)->isScemantic())
 		currentDocument()->emplaceAt<LDEmpty>(idx);
 }
 
diff -r f5921a474d57 -r 0384b1d49786 src/toolsets/algorithmtoolset.h
--- a/src/toolsets/algorithmtoolset.h	Sat Mar 03 16:53:56 2018 +0200
+++ b/src/toolsets/algorithmtoolset.h	Sat Mar 03 16:56:49 2018 +0200
@@ -39,4 +39,5 @@
 
 private:
 	bool isColorUsed (class LDColor color);
-};
\ No newline at end of file
+	LDObject* next(LDObject* object);
+};