OSDN Git Service

fix compile problem
[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 <q3dict.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     QString getHierarchLevel() const;
60
61     Project* getProject() const { return project; }
62
63     void setName(const QString& n) { name = n; }
64     const QString& getName() const { return name; }
65     void getFullName(QString& fullName) const;
66
67     CoreAttributes* getParent() const { return parent; }
68
69     uint treeLevel() const;
70
71     CoreAttributesList getSubList() const;
72     CoreAttributesListIterator getSubListIterator() const;
73
74     bool hasSubs() 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; }
80
81     bool hasSameAncestor(const CoreAttributes* c) const;
82     bool isDescendantOf(const CoreAttributes* c) const;
83     bool isParentOf(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 Q3Dict<CustomAttribute>& getCustomAttributeDict() const
91     {
92         return customAttributes;
93     }
94     void inheritCustomAttributes
95         (const Q3Dict<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     Q3Dict<CustomAttribute> customAttributes;
150 } ;
151
152 #endif