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_
15 #include <q3ptrlist.h>
17 #include <Q3PtrCollection>
19 #include "CoreAttributes.h"
24 * @short The class stores a list of CoreAttributes.
26 * @author Chris Schlaeger <cs@kde.org>
28 class CoreAttributesList : public Q3PtrList<CoreAttributes>
33 for (int i = 0; i < maxSortingLevel; i++)
34 sorting[i] = SequenceUp;
36 CoreAttributesList(const CoreAttributesList& l) :
37 Q3PtrList<CoreAttributes>(l)
39 for (int i = 0; i < maxSortingLevel; i++)
40 sorting[i] = l.sorting[i];
43 virtual ~CoreAttributesList();
45 void deleteContents();
48 SequenceUp = 0, SequenceDown,
49 TreeMode, NameUp, NameDown, FullNameUp,
50 FullNameDown, IdUp, IdDown, IndexUp, IndexDown,
51 StatusUp, StatusDown, CompletedUp, CompletedDown,
53 ResponsibleUp, ResponsibleDown,
54 MinEffortUp, MinEffortDown,
55 MaxEffortUp, MaxEffortDown,
57 StartUp, StartDown, EndUp, EndDown,
58 CriticalnessUp, CriticalnessDown,
59 PathCriticalnessUp, PathCriticalnessDown
62 static const int maxSortingLevel = 3;
63 void setSorting(int s, int level);
64 void createIndex(bool initial = false);
65 int getIndex(const QString& id) const;
66 uint maxDepth() const;
68 static bool isSupportedSortingCriteria(int sc);
70 virtual int compareItemsLevel(CoreAttributes* c1, CoreAttributes* c2,
74 virtual int compareItems(Q3PtrCollection::Item i1, Q3PtrCollection::Item i2);
76 int sorting[maxSortingLevel];
80 * @short Iterator for CoreAttributesList objects.
81 * @author Chris Schlaeger <cs@kde.org>
83 class CoreAttributesListIterator : public Q3PtrListIterator<CoreAttributes>
86 CoreAttributesListIterator(const CoreAttributesList& l) :
87 Q3PtrListIterator<CoreAttributes>(l) { }
88 virtual ~CoreAttributesListIterator() { }
91 template<class TL, class T> int compareTreeItemsT(TL* list, T* c1, T* c2)
96 Q3PtrList<T> cl1, cl2;
103 c1 = c1->getParent();
110 c2 = c2->getParent();
116 Q3PtrListIterator<T> cal1(cl1);
117 Q3PtrListIterator<T> cal2(cl2);
118 for ( ; *cal1 != 0 && *cal2 != 0; ++cal1, ++cal2)
121 for (int j = 1; j < CoreAttributesList::maxSortingLevel; ++j)
123 if ((res = list->compareItemsLevel(*cal1, *cal2, j)) != 0)
126 if ((res = (*cal1)->getSequenceNo() - (*cal2)->getSequenceNo()) != 0)
127 return res < 0 ? -1 : 1;