From 0e9e40f5e438b27ebfa1d5931a6bc9250557b57e Mon Sep 17 00:00:00 2001
From: Ryan Inch <mythologylover75@gmail.com>
Date: Thu, 25 Jun 2020 00:56:08 -0400
Subject: [PATCH] Collection Manager: Depth first renumber. Task: T69577

Add a depth first option to the Renumber QCD Slots operator.
---
 object_collection_manager/__init__.py      | 2 +-
 object_collection_manager/internals.py     | 8 ++++++--
 object_collection_manager/qcd_operators.py | 6 +++++-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index 6a1a9f22d..91901c6f7 100644
--- a/object_collection_manager/__init__.py
+++ b/object_collection_manager/__init__.py
@@ -22,7 +22,7 @@ bl_info = {
     "name": "Collection Manager",
     "description": "Manage collections and their objects",
     "author": "Ryan Inch",
-    "version": (2, 8, 0),
+    "version": (2, 9, 0),
     "blender": (2, 80, 0),
     "location": "View3D - Object Mode (Shortcut - M)",
     "warning": '',  # used for warning icon and text in addons panel
diff --git a/object_collection_manager/internals.py b/object_collection_manager/internals.py
index f3bcf37f8..8e0c5b90b 100644
--- a/object_collection_manager/internals.py
+++ b/object_collection_manager/internals.py
@@ -210,7 +210,7 @@ class QCDSlots():
                 if self.length() > 20:
                     break
 
-    def renumerate(self, *, beginning=False):
+    def renumerate(self, *, depth_first=False, beginning=False):
         if beginning:
             self.clear_slots()
             self.overrides.clear()
@@ -242,7 +242,11 @@ class QCDSlots():
                         self.add_slot(f"{x+1}", layer_collection.name)
 
 
-            laycol_iter_list.extend(list(layer_collection.children))
+            if depth_first:
+                laycol_iter_list[0:0] = list(layer_collection.children)
+
+            else:
+                laycol_iter_list.extend(list(layer_collection.children))
 
             if self.length() > 20:
                 break
diff --git a/object_collection_manager/qcd_operators.py b/object_collection_manager/qcd_operators.py
index 53212920f..7330dd0fd 100644
--- a/object_collection_manager/qcd_operators.py
+++ b/object_collection_manager/qcd_operators.py
@@ -287,7 +287,8 @@ class RenumerateQCDSlots(Operator):
     bl_label = "Renumber QCD Slots"
     bl_description = (
         "Renumber QCD slots.\n"
-        "  * LMB - Renumber starting from the slot designated 1.\n"
+        "  * LMB - Renumber (breadth first) starting from the slot designated 1.\n"
+        "  * Ctrl+LMB - Renumber (depth first) starting from the slot designated 1.\n"
         "  * Alt+LMB - Renumber from the beginning"
         )
     bl_idname = "view3d.renumerate_qcd_slots"
@@ -301,6 +302,9 @@ class RenumerateQCDSlots(Operator):
         if modifiers == {'alt'}:
             qcd_slots.renumerate(beginning=True)
 
+        elif modifiers == {'ctrl'}:
+            qcd_slots.renumerate(depth_first=True)
+
         else:
             qcd_slots.renumerate()
 
-- 
GitLab