- added a type alias LDObjectList

Fri, 10 Jan 2014 15:48:40 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 10 Jan 2014 15:48:40 +0200
changeset 617
f5059d144438
parent 616
92170185dbb6
child 618
de0d51349f6c

- added a type alias LDObjectList

src/document.cc file | annotate | diff | comparison | revisions
src/document.h file | annotate | diff | comparison | revisions
src/extprogs.cc file | annotate | diff | comparison | revisions
src/gldraw.cc file | annotate | diff | comparison | revisions
src/gui.cc file | annotate | diff | comparison | revisions
src/gui.h file | annotate | diff | comparison | revisions
src/gui_actions.cc file | annotate | diff | comparison | revisions
src/gui_editactions.cc file | annotate | diff | comparison | revisions
src/ldtypes.cc file | annotate | diff | comparison | revisions
src/ldtypes.h file | annotate | diff | comparison | revisions
src/misc.cc file | annotate | diff | comparison | revisions
src/misc.h file | annotate | diff | comparison | revisions
src/primitives.cc file | annotate | diff | comparison | revisions
src/types.cc file | annotate | diff | comparison | revisions
src/types.h file | annotate | diff | comparison | revisions
--- a/src/document.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/document.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -434,10 +434,10 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-QList<LDObject*> loadFileContents (QFile* fp, int* numWarnings, bool* ok)
+LDObjectList loadFileContents (QFile* fp, int* numWarnings, bool* ok)
 {
 	QStringList lines;
-	QList<LDObject*> objs;
+	LDObjectList objs;
 
 	if (numWarnings)
 		*numWarnings = 0;
@@ -505,7 +505,7 @@
 
 	int numWarnings;
 	bool ok;
-	QList<LDObject*> objs = loadFileContents (fp, &numWarnings, &ok);
+	LDObjectList objs = loadFileContents (fp, &numWarnings, &ok);
 	fp->close();
 	fp->deleteLater();
 
@@ -1074,7 +1074,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void LDDocument::addObjects (const QList<LDObject*> objs)
+void LDDocument::addObjects (const LDObjectList objs)
 {
 	for (LDObject* obj : objs)
 		if (obj)
@@ -1190,7 +1190,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-QList<LDObject*> LDDocument::inlineContents (LDSubfile::InlineFlags flags)
+LDObjectList LDDocument::inlineContents (LDSubfile::InlineFlags flags)
 {
 	// Possibly substitute with logoed studs:
 	// stud.dat -> stud-logo.dat
@@ -1206,7 +1206,7 @@
 			return g_logoedStud2->inlineContents (flags);
 	}
 
-	QList<LDObject*> objs, objcache;
+	LDObjectList objs, objcache;
 
 	bool deep = flags & LDSubfile::DeepInline,
 		 doCache = flags & LDSubfile::CacheInline;
@@ -1243,7 +1243,7 @@
 
 				// We only want to cache immediate subfiles, so shed the caching
 				// flag when recursing deeper in hierarchy.
-				QList<LDObject*> otherobjs = ref->inlineContents (flags & ~ (LDSubfile::CacheInline));
+				LDObjectList otherobjs = ref->inlineContents (flags & ~ (LDSubfile::CacheInline));
 
 				for (LDObject* otherobj : otherobjs)
 				{
@@ -1385,7 +1385,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-const QList<LDObject*>& LDDocument::getSelection() const
+const LDObjectList& LDDocument::getSelection() const
 {
 	return m_sel;
 }
--- a/src/document.h	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/document.h	Fri Jan 10 15:48:40 2014 +0200
@@ -56,15 +56,15 @@
 {
 	properties:
 		Q_OBJECT
-		PROPERTY (private,	QList<LDObject*>,			Objects, 		LIST_OPS,	STOCK_WRITE)
+		PROPERTY (private,	LDObjectList,			Objects, 		LIST_OPS,	STOCK_WRITE)
 		PROPERTY (private,	History*,					History,		NO_OPS,		STOCK_WRITE)
-		PROPERTY (private,	QList<LDObject*>,			Vertices,		LIST_OPS,	STOCK_WRITE)
+		PROPERTY (private,	LDObjectList,			Vertices,		LIST_OPS,	STOCK_WRITE)
 		PROPERTY (private,	QList<LDDocumentPointer*>,	References,		LIST_OPS,	STOCK_WRITE)
 		PROPERTY (public,	QString,					Name,			STR_OPS,	STOCK_WRITE)
 		PROPERTY (public,	QString,					FullPath,		STR_OPS,	STOCK_WRITE)
 		PROPERTY (public,	QString,					DefaultName,	STR_OPS,	STOCK_WRITE)
 		PROPERTY (public,	bool,						Implicit,		BOOL_OPS,	STOCK_WRITE)
-		PROPERTY (public,	QList<LDObject*>,			Cache,			LIST_OPS,	STOCK_WRITE)
+		PROPERTY (public,	LDObjectList,			Cache,			LIST_OPS,	STOCK_WRITE)
 		PROPERTY (public,	long,						SavePosition,	NUM_OPS,	STOCK_WRITE)
 		PROPERTY (public,	QListWidgetItem*,			ListItem,		NO_OPS,		STOCK_WRITE)
 
@@ -73,13 +73,13 @@
 		~LDDocument();
 
 		int addObject (LDObject* obj); // Adds an object to this file at the end of the file.
-		void addObjects (const QList<LDObject*> objs);
+		void addObjects (const LDObjectList objs);
 		void clearSelection();
 		void forgetObject (LDObject* obj); // Deletes the given object from the object chain.
 		QString getDisplayName();
-		const QList<LDObject*>& getSelection() const;
+		const LDObjectList& getSelection() const;
 		bool hasUnsavedChanges() const; // Does this document.have unsaved changes?
-		QList<LDObject*> inlineContents (LDSubfile::InlineFlags flags);
+		LDObjectList inlineContents (LDSubfile::InlineFlags flags);
 		void insertObj (int pos, LDObject* obj);
 		int getObjectCount() const;
 		LDObject* getObject (int pos) const;
@@ -136,7 +136,7 @@
 		friend class LDObject;
 
 	private:
-		QList<LDObject*>			m_sel;
+		LDObjectList			m_sel;
 
 		// If set to true, next inline of this document discards the cache and
 		// re-builds it.
@@ -182,11 +182,11 @@
 // Is it safe to close all files?
 bool safeToCloseAll();
 
-QList<LDObject*> loadFileContents (QFile* f, int* numWarnings, bool* ok = null);
+LDObjectList loadFileContents (QFile* f, int* numWarnings, bool* ok = null);
 
 extern QList<LDDocument*> g_loadedFiles;
 
-inline const QList<LDObject*>& selection()
+inline const LDObjectList& selection()
 {
 	return getCurrentDocument()->getSelection();
 }
@@ -210,7 +210,7 @@
 class LDFileLoader : public QObject
 {
 	Q_OBJECT
-	PROPERTY (private,	QList<LDObject*>,	Objects,			NO_OPS,		STOCK_WRITE)
+	PROPERTY (private,	LDObjectList,	Objects,			NO_OPS,		STOCK_WRITE)
 	PROPERTY (private,	bool,					Done,				BOOL_OPS,	STOCK_WRITE)
 	PROPERTY (private,	int,					Progress,		NUM_OPS,		STOCK_WRITE)
 	PROPERTY (private,	bool,					Aborted,			BOOL_OPS,	STOCK_WRITE)
--- a/src/extprogs.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/extprogs.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -166,14 +166,14 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-static void writeObjects (const QList<LDObject*>& objects, QFile& f)
+static void writeObjects (const LDObjectList& objects, QFile& f)
 {
 	for (LDObject* obj : objects)
 	{
 		if (obj->getType() == LDObject::ESubfile)
 		{
 			LDSubfile* ref = static_cast<LDSubfile*> (obj);
-			QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepInline);
+			LDObjectList objs = ref->inlineContents (LDSubfile::DeepInline);
 
 			writeObjects (objs, f);
 
@@ -187,7 +187,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-static void writeObjects (const QList<LDObject*>& objects, QString fname)
+static void writeObjects (const LDObjectList& objects, QString fname)
 {
 	// Write the input file
 	QFile f (fname);
@@ -217,7 +217,7 @@
 // -----------------------------------------------------------------------------
 void writeColorGroup (const int colnum, QString fname)
 {
-	QList<LDObject*> objects;
+	LDObjectList objects;
 
 	for (LDObject* obj : getCurrentDocument()->getObjects())
 	{
@@ -303,7 +303,7 @@
 		return;
 	}
 
-	QList<LDObject*> objs = loadFileContents (&f, null);
+	LDObjectList objs = loadFileContents (&f, null);
 
 	// If we replace the objects, delete the selection now.
 	if (replace)
--- a/src/gldraw.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/gldraw.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -995,7 +995,7 @@
 		case LDObject::ESubfile:
 		{
 			LDSubfile* ref = static_cast<LDSubfile*> (obj);
-			QList<LDObject*> objs;
+			LDObjectList objs;
 
 			objs = ref->inlineContents (LDSubfile::DeepCacheInline | LDSubfile::RendererInline);
 			bool oldinvert = g_glInvert;
@@ -1324,7 +1324,7 @@
 	// Clear the selection if we do not wish to add to it.
 	if (!m_addpick)
 	{
-		QList<LDObject*> oldsel = selection();
+		LDObjectList oldsel = selection();
 		getCurrentDocument()->clearSelection();
 
 		for (LDObject* obj : oldsel)
@@ -1462,7 +1462,7 @@
 			setCursor (Qt::CrossCursor);
 
 			// Clear the selection when beginning to draw.
-			QList<LDObject*> priorsel = selection();
+			LDObjectList priorsel = selection();
 			getCurrentDocument()->clearSelection();
 
 			for (LDObject* obj : priorsel)
@@ -1510,7 +1510,7 @@
 
 	// Clean the selection and create the object
 	QList<Vertex>& verts = m_drawedVerts;
-	QList<LDObject*> objs;
+	LDObjectList objs;
 
 	switch (getEditMode())
 	{
@@ -1729,7 +1729,7 @@
 	} elif (obj->getType() == LDObject::ESubfile)
 	{
 		LDSubfile* ref = static_cast<LDSubfile*> (obj);
-		QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline);
+		LDObjectList objs = ref->inlineContents (LDSubfile::DeepCacheInline);
 
 		for (LDObject* obj : objs)
 		{
--- a/src/gui.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/gui.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -299,7 +299,7 @@
 	if (selection().isEmpty())
 		return 0;
 
-	QList<LDObject*> selCopy = selection();
+	LDObjectList selCopy = selection();
 
 	// Delete the objects that were being selected
 	for (LDObject* obj : selCopy)
@@ -460,7 +460,7 @@
 	if (m_renderer->isPicking())
 		return;
 
-	QList<LDObject*> priorSelection = selection();
+	LDObjectList priorSelection = selection();
 
 	// Get the objects from the object list selection
 	getCurrentDocument()->clearSelection();
@@ -479,7 +479,7 @@
 	}
 
 	// Update the GL renderer
-	QList<LDObject*> compound = priorSelection + selection();
+	LDObjectList compound = priorSelection + selection();
 	removeDuplicates (compound);
 
 	for (LDObject* obj : compound)
@@ -689,7 +689,7 @@
 // =============================================================================
 // TODO: what the heh?
 // -----------------------------------------------------------------------------
-void ForgeWindow::deleteObjects (QList<LDObject*> objs)
+void ForgeWindow::deleteObjects (LDObjectList objs)
 {
 	for (LDObject* obj : objs)
 		obj->deleteSelf();
@@ -699,7 +699,7 @@
 // -----------------------------------------------------------------------------
 void ForgeWindow::deleteByColor (const int colnum)
 {
-	QList<LDObject*> objs;
+	LDObjectList objs;
 
 	for (LDObject* obj : getCurrentDocument()->getObjects())
 	{
--- a/src/gui.h	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/gui.h	Fri Jan 10 15:48:40 2014 +0200
@@ -111,7 +111,7 @@
 		LDObject::Type getUniformSelectedType();
 		void scrollToSelection();
 		void spawnContextMenu (const QPoint pos);
-		void deleteObjects (QList<LDObject*> objs);
+		void deleteObjects (LDObjectList objs);
 		int deleteSelection();
 		void deleteByColor (const int colnum);
 		bool save (LDDocument* f, bool saveAs);
@@ -236,7 +236,7 @@
 
 	private:
 		GLRenderer* m_renderer;
-		QList<LDObject*> m_sel;
+		LDObjectList m_sel;
 		QList<LDQuickColor> m_quickColors;
 		QList<QToolButton*> m_colorButtons;
 		QList<QAction*> m_recentFiles;
--- a/src/gui_actions.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/gui_actions.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -396,7 +396,7 @@
 		return;
 	}
 
-	QList<LDObject*> objs = loadFileContents (&f, null);
+	LDObjectList objs = loadFileContents (&f, null);
 
 	getCurrentDocument()->clearSelection();
 
--- a/src/gui_editactions.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/gui_editactions.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -42,7 +42,7 @@
 // -----------------------------------------------------------------------------
 static int copyToClipboard()
 {
-	QList<LDObject*> objs = selection();
+	LDObjectList objs = selection();
 	int num = 0;
 
 	// Clear the clipboard first.
@@ -116,7 +116,7 @@
 // -----------------------------------------------------------------------------
 static void doInline (bool deep)
 {
-	QList<LDObject*> sel = selection();
+	LDObjectList sel = selection();
 
 	for (LDObject* obj : sel)
 	{
@@ -127,7 +127,7 @@
 		if (idx == -1)
 			continue;
 
-		QList<LDObject*> objs;
+		LDObjectList objs;
 
 		if (obj->getType() == LDObject::ESubfile)
 			objs = static_cast<LDSubfile*> (obj)->inlineContents (
@@ -170,7 +170,7 @@
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (SplitQuads, 0)
 {
-	QList<LDObject*> objs = selection();
+	LDObjectList objs = selection();
 	int num = 0;
 
 	for (LDObject* obj : objs)
@@ -250,7 +250,7 @@
 	int colnum;
 	int defcol = -1;
 
-	QList<LDObject*> objs = selection();
+	LDObjectList objs = selection();
 
 	// If all selected objects have the same color, said color is our default
 	// value to the color selection dialog.
@@ -276,7 +276,7 @@
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (Borders, CTRL_SHIFT (B))
 {
-	QList<LDObject*> objs = selection();
+	LDObjectList objs = selection();
 	int num = 0;
 
 	for (LDObject* obj : objs)
@@ -357,7 +357,7 @@
 // -----------------------------------------------------------------------------
 static void doMoveSelection (const bool up)
 {
-	QList<LDObject*> objs = selection();
+	LDObjectList objs = selection();
 	LDObject::moveObjects (objs, up);
 	g_win->buildObjList();
 }
@@ -440,7 +440,7 @@
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (Invert, CTRL_SHIFT (W))
 {
-	QList<LDObject*> sel = selection();
+	LDObjectList sel = selection();
 
 	for (LDObject* obj : sel)
 	{
@@ -464,7 +464,7 @@
 // -----------------------------------------------------------------------------
 static void doRotate (const int l, const int m, const int n)
 {
-	QList<LDObject*> sel = selection();
+	LDObjectList sel = selection();
 	QList<Vertex*> queue;
 	const Vertex rotpoint = rotPoint (sel);
 	const double angle = (pi * *currentGrid().confs[Grid::Angle]) / 180,
@@ -721,7 +721,7 @@
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (Demote, 0)
 {
-	QList<LDObject*> sel = selection();
+	LDObjectList sel = selection();
 	int num = 0;
 
 	for (LDObject* obj : sel)
--- a/src/ldtypes.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/ldtypes.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -30,7 +30,7 @@
 cfg (Int, ld_defaultlicense, 0);
 
 // List of all LDObjects
-static QList<LDObject*> g_LDObjects;
+static LDObjectList g_LDObjects;
 
 // =============================================================================
 // LDObject constructors
@@ -354,9 +354,9 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-QList<LDObject*> LDSubfile::inlineContents (InlineFlags flags)
+LDObjectList LDSubfile::inlineContents (InlineFlags flags)
 {
-	QList<LDObject*> objs = getFileInfo()->inlineContents (flags);
+	LDObjectList objs = getFileInfo()->inlineContents (flags);
 
 	// Transform the objects
 	for (LDObject* obj : objs)
@@ -384,7 +384,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void LDObject::moveObjects (QList<LDObject*> objs, const bool up)
+void LDObject::moveObjects (LDObjectList objs, const bool up)
 {
 	if (objs.isEmpty())
 		return;
@@ -393,7 +393,7 @@
 	const long start = up ? 0 : (objs.size() - 1);
 	const long end = up ? objs.size() : -1;
 	const long incr = up ? 1 : -1;
-	QList<LDObject*> objsToCompile;
+	LDObjectList objsToCompile;
 	LDDocument* file = objs[0]->getFile();
 
 	for (long i = start; i != end; i += incr)
@@ -438,7 +438,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-QString LDObject::describeObjects (const QList<LDObject*>& objs)
+QString LDObject::describeObjects (const LDObjectList& objs)
 {
 	bool firstDetails = true;
 	QString text = "";
--- a/src/ldtypes.h	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/ldtypes.h	Fri Jan 10 15:48:40 2014 +0200
@@ -169,10 +169,10 @@
 		static LDObject* getDefault (const LDObject::Type type);
 
 		// TODO: move this to LDDocument?
-		static void moveObjects (QList<LDObject*> objs, const bool up);
+		static void moveObjects (LDObjectList objs, const bool up);
 
 		// Get a description of a list of LDObjects
-		static QString describeObjects (const QList<LDObject*>& objs);
+		static QString describeObjects (const LDObjectList& objs);
 		static LDObject* fromID (int id);
 
 		// TODO: make these private!
@@ -224,7 +224,7 @@
 		LDSharedVertex (const Vertex& a) : m_data (a) {}
 
 	private:
-		QList<LDObject*> m_refs;
+		LDObjectList m_refs;
 		Vertex m_data;
 };
 
@@ -415,7 +415,7 @@
 
 		// Inlines this subfile. Note that return type is an array of heap-allocated
 		// LDObject copies, they must be deleted manually.
-		QList<LDObject*> inlineContents (InlineFlags flags);
+		LDObjectList inlineContents (InlineFlags flags);
 
 	protected:
 		~LDSubfile();
--- a/src/misc.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/misc.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -209,7 +209,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-Vertex rotPoint (const QList<LDObject*>& objs)
+Vertex rotPoint (const LDObjectList& objs)
 {
 	switch (edit_rotpoint)
 	{
--- a/src/misc.h	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/misc.h	Fri Jan 10 15:48:40 2014 +0200
@@ -67,7 +67,7 @@
 	CustomPoint
 };
 
-Vertex rotPoint (const QList<LDObject*>& objs);
+Vertex rotPoint (const LDObjectList& objs);
 void configRotationPoint();
 
 // =============================================================================
--- a/src/primitives.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/primitives.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -385,9 +385,9 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-QList<LDObject*> makePrimitive (PrimitiveType type, int segs, int divs, int num)
+LDObjectList makePrimitive (PrimitiveType type, int segs, int divs, int num)
 {
-	QList<LDObject*> objs;
+	LDObjectList objs;
 	QList<int> condLineSegs;
 	QList<QLineF> circle;
 
--- a/src/types.cc	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/types.cc	Fri Jan 10 15:48:40 2014 +0200
@@ -351,7 +351,7 @@
 		case LDObject::ESubfile:
 		{
 			LDSubfile* ref = static_cast<LDSubfile*> (obj);
-			QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline);
+			LDObjectList objs = ref->inlineContents (LDSubfile::DeepCacheInline);
 
 			for (LDObject * obj : objs)
 			{
--- a/src/types.h	Fri Jan 10 15:41:57 2014 +0200
+++ b/src/types.h	Fri Jan 10 15:48:40 2014 +0200
@@ -52,6 +52,11 @@
 };
 
 // =============================================================================
+//
+class LDObject;
+using LDObjectList = QList<LDObject*>;
+
+// =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 // matrix

mercurial