/*
* CoreAttributes.h - TaskJuggler
*
- * Copyright (c) 2001, 2002 by Chris Schlaeger <cs@suse.de>
+ * Copyright (c) 2001, 2002, 2003, 2004, 2005 by Chris Schlaeger <cs@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
#define _CoreAttributes_h_
#include <qstring.h>
+#include <q3dict.h>
#include "FlagList.h"
+#include "CustomAttribute.h"
class Project;
class CoreAttributes;
+class CoreAttributesList;
+class CoreAttributesListIterator;
+class CustomAttributeDefinition;
-class CoreAttributesList : public QPtrList<CoreAttributes>
-{
-public:
- CoreAttributesList() { sorting = Sequence; }
- virtual ~CoreAttributesList();
-
- enum SortCriteria { Sequence, TreeMode, NameUp, NameDown, FullNameUp,
- FullNameDown, IdUp, IdDown, IndexUp, IndexDown,
- StartUp, StartDown, EndUp, EndDown,
- PrioUp, PrioDown,
- ResponsibleUp, ResponsibleDown,
- MinEffortUp, MinEffortDown,
- MaxEffortUp, MaxEffortDown,
- RateUp, RateDown,
- KotrusIdUp, KotrusIdDown
- };
-
- void setSorting(SortCriteria s);
- void createIndex();
-
-protected:
- virtual int compareItems(QCollection::Item i1, QCollection::Item i2);
-
- SortCriteria sorting;
-} ;
-
+/**
+ * @short This class is the base class for all attribute classes.
+ * @author Chris Schlaeger <cs@kde.org>
+ */
class CoreAttributes
{
public:
- CoreAttributes(Project* p, const QString& i, const QString& n,
- CoreAttributes* parent_) :
- project(p), id(i), name(n), parent(parent_) { }
- virtual ~CoreAttributes() { }
+ CoreAttributes(Project* p, const QString& i, const QString& n,
+ CoreAttributes* parent_, const QString& df = QString::null,
+ uint dl = 0);
+ virtual ~CoreAttributes();
- virtual const char* getType() { return "CoreAttributes"; }
+ virtual CAType getType() const { return CA_Undefined; }
- const QString& getId() const { return id; }
- QString getFullId() const;
-
- void setIndex(uint idx) { index = idx; }
- uint getIndex() const { return index; }
+ const QString& getId() const { return id; }
+ QString getFullId() const;
- void setSequenceNo(uint no) { sequenceNo = no; }
- uint getSequenceNo() const { return sequenceNo; }
-
- Project* getProject() { return project; }
+ const QString& getDefinitionFile() const { return definitionFile; }
+ uint getDefinitionLine() const { return definitionLine; }
- void setName(const QString& n) { name = n; }
- const QString& getName() const { return name; }
- void getFullName(QString& fullName) const;
+ void setIndex(int idx) { index = idx; }
+ int getIndex() const { return index; }
- CoreAttributes* getParent() const { return parent; }
+ void setSequenceNo(uint no) { sequenceNo = no; }
+ uint getSequenceNo() const { return sequenceNo; }
- void addSub(CoreAttributes* c) { sub.append(c); }
- virtual CoreAttributesList getSubList() const { return sub; }
+ void setHierarchNo(uint no);
+ QString getHierarchNo() const;
- void addFlag(QString flag) { flags.addFlag(flag); }
- void clearFlag(const QString& flag) { flags.clearFlag(flag); }
- bool hasFlag(const QString& flag) { return flags.hasFlag(flag); }
- FlagList getFlagList() const { return flags; }
+ void setHierarchIndex(uint no);
+ QString getHierarchIndex() const;
+ QString getHierarchLevel() const;
-protected:
- /// A pointer to access information that are global to the project.
- Project* project;
+ Project* getProject() const { return project; }
- /// An ID that must be unique within the attribute class.
- QString id;
+ void setName(const QString& n) { name = n; }
+ const QString& getName() const { return name; }
+ void getFullName(QString& fullName) const;
- /// An index number that must be unique within the attribute class.
- uint index;
+ CoreAttributes* getParent() const { return parent; }
- /// The index of the task declaration.
- uint sequenceNo;
+ uint treeLevel() const;
- /// A short description of the attribute.
- QString name;
+ CoreAttributesList getSubList() const;
+ CoreAttributesListIterator getSubListIterator() const;
- /// Pointer to parent. If there is no parent the pointer is 0.
- CoreAttributes* parent;
+ bool hasSubs() const;
+ void addFlag(QString flag) { flags.addFlag(flag); }
+ void purgeFlags() { flags.clear(); }
+ void clearFlag(const QString& flag) { flags.clearFlag(flag); }
+ bool hasFlag(const QString& flag) { return flags.hasFlag(flag); }
+ FlagList getFlagList() const { return flags; }
- /// List of child attributes.
- CoreAttributesList sub;
+ bool hasSameAncestor(const CoreAttributes* c) const;
+ bool isDescendantOf(const CoreAttributes* c) const;
+ bool isParentOf(const CoreAttributes* c) const;
- /// List of flags set for this attribute.
- FlagList flags;
+ bool isRoot() const { return parent == 0; }
+ bool isLeaf() const;
- CoreAttributes() { } // Don't use this!
+ void addCustomAttribute(const QString& id, CustomAttribute* ca);
+ const CustomAttribute* getCustomAttribute(const QString& id) const;
+ const Q3Dict<CustomAttribute>& getCustomAttributeDict() const
+ {
+ return customAttributes;
+ }
+ void inheritCustomAttributes
+ (const Q3Dict<CustomAttributeDefinition>& dict);
+
+protected:
+ /// A pointer to access information that are global to the project.
+ Project* project;
+
+ /// An ID that must be unique within the attribute class.
+ QString id;
+
+ /// A short description of the attribute.
+ QString name;
+
+ /// Pointer to parent. If there is no parent the pointer is 0.
+ CoreAttributes* parent;
+
+ /* Name of the tjp file that caused the creation of this CoreAttribute. It
+ * may be empty if it was not created from a .tjp file. */
+ const QString definitionFile;
+
+ /* Line in the .tjp file that caused the createtion of this Core
+ * Attribute. It may be 0 if it was not created from a .tjp file. */
+ uint definitionLine;
+
+ /**
+ * The index of the attribute declaration within the project files. Each
+ * attribute lists has it's own indices.
+ */
+ uint sequenceNo;
+
+ /**
+ * The index of the attribute declaration within it's parents childs.
+ */
+ uint hierarchNo;
+ /**
+ * The index of the attributes in a logical order that takes the tree
+ * structure and the start and end date into account. Each attribute list
+ * has it's own indices.
+ */
+ int index;
+
+ /**
+ * The index of the attributes of the same parent in a logical order that
+ * takes the tree structure and the start and end date into account. Each
+ * attribute list has it's own indices.
+ */
+ uint hierarchIndex;
+
+ /// List of child attributes.
+ CoreAttributesList* sub;
+
+ /// List of flags set for this attribute.
+ FlagList flags;
+
+ /// User defined, optional attributes.
+ Q3Dict<CustomAttribute> customAttributes;
} ;
#endif