33 LDObjectList objs = selectedObjects(); |
33 LDObjectList objs = selectedObjects(); |
34 if (objs.isEmpty()) |
34 if (objs.isEmpty()) |
35 return; |
35 return; |
36 |
36 |
37 // If we move down, we need to iterate the array in reverse order. |
37 // If we move down, we need to iterate the array in reverse order. |
38 int start = up ? 0 : (objs.size() - 1); |
38 int start = up ? 0 : (length(objs) - 1); |
39 int end = up ? objs.size() : -1; |
39 int end = up ? length(objs) : -1; |
40 int increment = up ? 1 : -1; |
40 int increment = up ? 1 : -1; |
41 QSet<LDObject*> objsToCompile; |
41 QSet<LDObject*> objsToCompile; |
42 LDDocument* file = objs[0]->document(); |
42 LDDocument* file = objs[0]->document(); |
43 |
43 |
44 for (int i = start; i != end; i += increment) |
44 for (int i = start; i != end; i += increment) |
46 LDObject* obj = objs[i]; |
46 LDObject* obj = objs[i]; |
47 |
47 |
48 int idx = obj->lineNumber(); |
48 int idx = obj->lineNumber(); |
49 int target = idx + (up ? -1 : 1); |
49 int target = idx + (up ? -1 : 1); |
50 |
50 |
51 if ((up and idx == 0) or (not up and idx == file->objects().size() - 1)) |
51 if ((up and idx == 0) or (not up and idx == length(file->objects()) - 1)) |
52 { |
52 { |
53 // One of the objects hit the extrema. If this happens, this should be the first |
53 // One of the objects hit the extrema. If this happens, this should be the first |
54 // object to be iterated on. Thus, nothing has changed yet and it's safe to just |
54 // object to be iterated on. Thus, nothing has changed yet and it's safe to just |
55 // abort the entire operation. |
55 // abort the entire operation. |
56 return; |
56 return; |