src/file.cpp

changeset 522
afa691788bdb
parent 519
63135a8abd41
child 527
47c068f2e7e3
--- a/src/file.cpp	Sat Oct 19 02:33:08 2013 +0300
+++ b/src/file.cpp	Tue Oct 22 13:40:16 2013 +0300
@@ -364,7 +364,7 @@
 		*numWarnings = 0;
 
 	// Calculate the amount of lines
-for (str line : *f)
+	for (str line : *f)
 		lines << line;
 
 	f->rewind();
@@ -1107,7 +1107,6 @@
 
 	if (g_win && f)
 	{	// A ton of stuff needs to be updated
-		g_win->clearSelection();
 		g_win->updateFileListItem (f);
 		g_win->buildObjList();
 		g_win->updateTitle();
@@ -1124,7 +1123,7 @@
 int LDFile::countExplicitFiles()
 {	int count = 0;
 
-for (LDFile * f : g_loadedFiles)
+	for (LDFile* f : g_loadedFiles)
 		if (f->implicit() == false)
 			count++;
 
@@ -1155,3 +1154,40 @@
 	g_logoedStud = openDATFile ("stud-logo.dat", true);
 	g_logoedStud2 = openDATFile ("stud2-logo.dat", true);
 }
+
+// =============================================================================
+// -----------------------------------------------------------------------------
+void LDFile::addToSelection (LDObject* obj) // [protected]
+{	if (obj->selected())
+		return;
+
+	assert (obj->file() == this);
+	m_sel << obj;
+	obj->setSelected (true);
+}
+
+// =============================================================================
+// -----------------------------------------------------------------------------
+void LDFile::removeFromSelection (LDObject* obj) // [protected]
+{	if (!obj->selected())
+		return;
+
+	assert (obj->file() == this);
+	m_sel.removeOne (obj);
+	obj->setSelected (false);
+}
+
+// =============================================================================
+// -----------------------------------------------------------------------------
+void LDFile::clearSelection()
+{	for (LDObject* obj : m_sel)
+		removeFromSelection (obj);
+
+	assert (m_sel.isEmpty());
+}
+
+// =============================================================================
+// -----------------------------------------------------------------------------
+const QList<LDObject*>& LDFile::selection() const
+{	return m_sel;
+}
\ No newline at end of file

mercurial