| 1 |
/* |
| 2 |
* ShiftList.cpp - TaskJuggler |
| 3 |
* |
| 4 |
* SPDX-FileCopyrightText: 2001, 2002, 2003, 2004 Chris Schlaeger <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of version 2 of the GNU General Public License as |
| 8 |
* published by the Free Software Foundation. |
| 9 |
* |
| 10 |
* $Id$ |
| 11 |
*/ |
| 12 |
|
| 13 |
// clazy:excludeall=qstring-arg |
| 14 |
#include "ShiftList.h" |
| 15 |
#include "Shift.h" |
| 16 |
#include "Project.h" |
| 17 |
|
| 18 |
namespace TJ |
| 19 |
{ |
| 20 |
|
| 21 |
Shift* |
| 22 |
ShiftList::getShift(const QString& id) const |
| 23 |
{ |
| 24 |
for (ShiftListIterator sli(*this); *sli != nullptr; ++sli) |
| 25 |
if ((*sli)->getId() == id) |
| 26 |
return *sli; |
| 27 |
|
| 28 |
return nullptr; |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
ShiftList::compareItemsLevel(CoreAttributes* c1, CoreAttributes* c2, |
| 33 |
int level) |
| 34 |
{ |
| 35 |
Shift* s1 = static_cast<Shift*>(c1); |
| 36 |
Shift* s2 = static_cast<Shift*>(c2); |
| 37 |
|
| 38 |
if (level < 0 || level >= maxSortingLevel) |
| 39 |
return -1; |
| 40 |
|
| 41 |
switch (sorting[level]) |
| 42 |
{ |
| 43 |
case TreeMode: |
| 44 |
if (level == 0) |
| 45 |
return compareTreeItemsT(this, s1, s2); |
| 46 |
else |
| 47 |
return s1->getSequenceNo() == s2->getSequenceNo() ? 0 : |
| 48 |
s1->getSequenceNo() < s2->getSequenceNo() ? -1 : 1; |
| 49 |
default: |
| 50 |
return CoreAttributesList::compareItemsLevel(s1, s2, level); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
Shift* ShiftListIterator::operator*() |
| 55 |
{ |
| 56 |
return static_cast<Shift*>(CoreAttributesListIterator::operator*()); |
| 57 |
} |
| 58 |
|
| 59 |
} // namespace TJ |