moved LDObject::next to the algorithm toolset

Sat, 03 Mar 2018 16:56:49 +0200

author
Santeri Piippo
date
Sat, 03 Mar 2018 16:56:49 +0200
changeset 1259
0384b1d49786
parent 1258
f5921a474d57
child 1260
0347e9bc883e

moved LDObject::next to the algorithm toolset

src/linetypes/modelobject.cpp file | annotate | diff | comparison | revisions
src/linetypes/modelobject.h file | annotate | diff | comparison | revisions
src/toolsets/algorithmtoolset.cpp file | annotate | diff | comparison | revisions
src/toolsets/algorithmtoolset.h file | annotate | diff | comparison | revisions
--- 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)
--- 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;
--- 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);
 }
 
--- 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);
+};

mercurial