2 * CoreAttributes.h - TaskJuggler
4 * Copyright (c) 2001, 2002, 2003, 2004, 2005 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.
13 #ifndef _CoreAttributes_h_
14 #define _CoreAttributes_h_
20 #include "CustomAttribute.h"
24 class CoreAttributesList;
25 class CoreAttributesListIterator;
26 class CustomAttributeDefinition;
29 * @short This class is the base class for all attribute classes.
30 * @author Chris Schlaeger <cs@kde.org>
35 CoreAttributes(Project* p, const QString& i, const QString& n,
36 CoreAttributes* parent_, const QString& df = QString::null,
38 virtual ~CoreAttributes();
40 virtual CAType getType() const { return CA_Undefined; }
42 const QString& getId() const { return id; }
43 QString getFullId() const;
45 const QString& getDefinitionFile() const { return definitionFile; }
46 uint getDefinitionLine() const { return definitionLine; }
48 void setIndex(int idx) { index = idx; }
49 int getIndex() const { return index; }
51 void setSequenceNo(uint no) { sequenceNo = no; }
52 uint getSequenceNo() const { return sequenceNo; }
54 void setHierarchNo(uint no);
55 QString getHierarchNo() const;
57 void setHierarchIndex(uint no);
58 QString getHierarchIndex() const;
59 QString getHierarchLevel() const;
61 Project* getProject() const { return project; }
63 void setName(const QString& n) { name = n; }
64 const QString& getName() const { return name; }
65 void getFullName(QString& fullName) const;
67 CoreAttributes* getParent() const { return parent; }
69 uint treeLevel() const;
71 CoreAttributesList getSubList() const;
72 CoreAttributesListIterator getSubListIterator() const;
75 void addFlag(QString flag) { flags.addFlag(flag); }
76 void purgeFlags() { flags.clear(); }
77 void clearFlag(const QString& flag) { flags.clearFlag(flag); }
78 bool hasFlag(const QString& flag) { return flags.hasFlag(flag); }
79 FlagList getFlagList() const { return flags; }
81 bool hasSameAncestor(const CoreAttributes* c) const;
82 bool isDescendantOf(const CoreAttributes* c) const;
83 bool isParentOf(const CoreAttributes* c) const;
85 bool isRoot() const { return parent == 0; }
88 void addCustomAttribute(const QString& id, CustomAttribute* ca);
89 const CustomAttribute* getCustomAttribute(const QString& id) const;
90 const Q3Dict<CustomAttribute>& getCustomAttributeDict() const
92 return customAttributes;
94 void inheritCustomAttributes
95 (const Q3Dict<CustomAttributeDefinition>& dict);
98 /// A pointer to access information that are global to the project.
101 /// An ID that must be unique within the attribute class.
104 /// A short description of the attribute.
107 /// Pointer to parent. If there is no parent the pointer is 0.
108 CoreAttributes* parent;
110 /* Name of the tjp file that caused the creation of this CoreAttribute. It
111 * may be empty if it was not created from a .tjp file. */
112 const QString definitionFile;
114 /* Line in the .tjp file that caused the createtion of this Core
115 * Attribute. It may be 0 if it was not created from a .tjp file. */
119 * The index of the attribute declaration within the project files. Each
120 * attribute lists has it's own indices.
125 * The index of the attribute declaration within it's parents childs.
129 * The index of the attributes in a logical order that takes the tree
130 * structure and the start and end date into account. Each attribute list
131 * has it's own indices.
136 * The index of the attributes of the same parent in a logical order that
137 * takes the tree structure and the start and end date into account. Each
138 * attribute list has it's own indices.
142 /// List of child attributes.
143 CoreAttributesList* sub;
145 /// List of flags set for this attribute.
148 /// User defined, optional attributes.
149 Q3Dict<CustomAttribute> customAttributes;