OSDN Git Service

Replace uppercase bool constant with proper lower case names.
[tjqt4port/tj2qt4.git] / taskjuggler / CoreAttributes.h
1 /*
2  * CoreAttributes.h - TaskJuggler
3  *
4  * Copyright (c) 2001, 2002, 2003, 2004, 2005 by Chris Schlaeger <cs@kde.org>
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 #ifndef _CoreAttributes_h_
14 #define _CoreAttributes_h_
15
16 #include <qstring.h>
17 #include <qdict.h>
18
19 #include "FlagList.h"
20 #include "CustomAttribute.h"
21
22 class Project;
23 class CoreAttributes;
24 class CoreAttributesList;
25 class CoreAttributesListIterator;
26 class CustomAttributeDefinition;
27
28 /**
29  * @short This class is the base class for all attribute classes.
30  * @author Chris Schlaeger <cs@kde.org>
31  */
32 class CoreAttributes
33 {
34 public:
35     CoreAttributes(Project* p, const QString& i, const QString& n,
36                    CoreAttributes* parent_, const QString& df = QString::null,
37                    uint dl = 0);
38     virtual ~CoreAttributes();
39
40     virtual CAType getType() const { return CA_Undefined; }
41
42     const QString& getId() const { return id; }
43     QString getFullId() const;
44
45     const QString& getDefinitionFile() const { return definitionFile; }
46     uint getDefinitionLine() const { return definitionLine; }
47
48     void setIndex(int idx) { index = idx; }
49     int getIndex() const { return index; }
50
51     void setSequenceNo(uint no) { sequenceNo = no; }
52     uint getSequenceNo() const { return sequenceNo; }
53
54     void setHierarchNo(uint no);
55     QString getHierarchNo() const;
56
57     void setHierarchIndex(uint no);
58     QString getHierarchIndex() const;
59
60     Project* getProject() const { return project; }
61
62     void setName(const QString& n) { name = n; }
63     const QString& getName() const { return name; }
64     void getFullName(QString& fullName) const;
65
66     CoreAttributes* getParent() const { return parent; }
67
68     uint treeLevel() const;
69
70     CoreAttributesList getSubList() const;
71     CoreAttributesListIterator getSubListIterator() const;
72
73     bool hasSubs() const;
74     void addFlag(QString flag) { flags.addFlag(flag); }
75     void purgeFlags() { flags.clear(); }
76     void clearFlag(const QString& flag) { flags.clearFlag(flag); }
77     bool hasFlag(const QString& flag) { return flags.hasFlag(flag); }
78     FlagList getFlagList() const { return flags; }
79
80     bool hasSameAncestor(const CoreAttributes* c) const;
81     bool isDescendentOf(const CoreAttributes* c) const;
82     bool isParentOf(const CoreAttributes* c) const;
83     bool isChildOf(const CoreAttributes* c) const;
84
85     bool isRoot() const { return parent == 0; }
86     bool isLeaf() const;
87
88     void addCustomAttribute(const QString& id, CustomAttribute* ca);
89     const CustomAttribute* getCustomAttribute(const QString& id) const;
90     const QDict<CustomAttribute>& getCustomAttributeDict() const
91     {
92         return customAttributes;
93     }
94     void inheritCustomAttributes
95         (const QDict<CustomAttributeDefinition>& dict);
96
97 protected:
98     /// A pointer to access information that are global to the project.
99     Project* project;
100
101     /// An ID that must be unique within the attribute class.
102     QString id;
103
104     /// A short description of the attribute.
105     QString name;
106
107     /// Pointer to parent. If there is no parent the pointer is 0.
108     CoreAttributes* parent;
109
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;
113
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. */
116     uint definitionLine;
117
118     /**
119      * The index of the attribute declaration within the project files. Each
120      * attribute lists has it's own indices.
121      */
122     uint sequenceNo;
123
124     /**
125      * The index of the attribute declaration within it's parents childs.
126      */
127     uint hierarchNo;
128     /**
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.
132      */
133     int index;
134
135     /**
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.
139      */
140     uint hierarchIndex;
141
142     /// List of child attributes.
143     CoreAttributesList* sub;
144
145     /// List of flags set for this attribute.
146     FlagList flags;
147
148     /// User defined, optional attributes.
149     QDict<CustomAttribute> customAttributes;
150 } ;
151
152 #endif