2 * CoreAttributesList.h - TaskJuggler
4 * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
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.
12 #ifndef _CoreAttributesList_h_
13 #define _CoreAttributesList_h_
17 #include "CoreAttributes.h"
22 * @short The class stores a list of CoreAttributes.
24 * @author Chris Schlaeger <cs@kde.org>
26 class CoreAttributesList : public QPtrList<CoreAttributes>
31 for (int i = 0; i < maxSortingLevel; i++)
32 sorting[i] = SequenceUp;
34 CoreAttributesList(const CoreAttributesList& l) :
35 QPtrList<CoreAttributes>(l)
37 for (int i = 0; i < maxSortingLevel; i++)
38 sorting[i] = l.sorting[i];
41 virtual ~CoreAttributesList();
43 void deleteContents();
46 SequenceUp = 0, SequenceDown,
47 TreeMode, NameUp, NameDown, FullNameUp,
48 FullNameDown, IdUp, IdDown, IndexUp, IndexDown,
49 StatusUp, StatusDown, CompletedUp, CompletedDown,
51 ResponsibleUp, ResponsibleDown,
52 MinEffortUp, MinEffortDown,
53 MaxEffortUp, MaxEffortDown,
55 StartUp, StartDown, EndUp, EndDown,
56 CriticalnessUp, CriticalnessDown,
57 PathCriticalnessUp, PathCriticalnessDown
60 static const int maxSortingLevel = 3;
61 void setSorting(int s, int level);
62 void createIndex(bool initial = false);
63 int getIndex(const QString& id) const;
64 uint maxDepth() const;
66 static bool isSupportedSortingCriteria(int sc);
68 virtual int compareItemsLevel(CoreAttributes* c1, CoreAttributes* c2,
72 virtual int compareItems(QCollection::Item i1, QCollection::Item i2);
74 int sorting[maxSortingLevel];
78 * @short Iterator for CoreAttributesList objects.
79 * @author Chris Schlaeger <cs@kde.org>
81 class CoreAttributesListIterator : public QPtrListIterator<CoreAttributes>
84 CoreAttributesListIterator(const CoreAttributesList& l) :
85 QPtrListIterator<CoreAttributes>(l) { }
86 virtual ~CoreAttributesListIterator() { }
89 template<class TL, class T> int compareTreeItemsT(TL* list, T* c1, T* c2)
101 c1 = c1->getParent();
108 c2 = c2->getParent();
114 QPtrListIterator<T> cal1(cl1);
115 QPtrListIterator<T> cal2(cl2);
116 for ( ; *cal1 != 0 && *cal2 != 0; ++cal1, ++cal2)
119 for (int j = 1; j < CoreAttributesList::maxSortingLevel; ++j)
121 if ((res = list->compareItemsLevel(*cal1, *cal2, j)) != 0)
124 if ((res = (*cal1)->getSequenceNo() - (*cal2)->getSequenceNo()) != 0)
125 return res < 0 ? -1 : 1;