| 1 |
/* |
| 2 |
* Project.h - TaskJuggler |
| 3 |
* |
| 4 |
* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 |
| 5 |
* by Chris Schlaeger <[email protected]> |
| 6 |
* SPDX-FileCopyrightText: 2011 Dag Andersen <[email protected]> |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of version 2 of the GNU General Public License as |
| 10 |
* published by the Free Software Foundation. |
| 11 |
* |
| 12 |
* $Id$ |
| 13 |
*/ |
| 14 |
|
| 15 |
#ifndef _Project_h_ |
| 16 |
#define _Project_h_ |
| 17 |
|
| 18 |
#include "plantj_export.h" |
| 19 |
|
| 20 |
#include <QObject> |
| 21 |
#include <QMap> |
| 22 |
|
| 23 |
#include "VacationList.h" |
| 24 |
#include "ScenarioList.h" |
| 25 |
#include "TaskList.h" |
| 26 |
#include "ShiftList.h" |
| 27 |
#include "ResourceList.h" |
| 28 |
// #include "AccountList.h" |
| 29 |
// #include "QtReport.h" |
| 30 |
// #include "Journal.h" |
| 31 |
|
| 32 |
|
| 33 |
namespace TJ |
| 34 |
{ |
| 35 |
|
| 36 |
// class ReportXML; |
| 37 |
// class Report; |
| 38 |
class CustomAttributeDefinition; |
| 39 |
class VacationInterval; |
| 40 |
class UsageLimits; |
| 41 |
|
| 42 |
|
| 43 |
/** |
| 44 |
* The Project class is the root of the data tree of the application. |
| 45 |
* Applications can use multiple Project objects. This is e. g. needed when |
| 46 |
* the application needs to preserve the state prior to a scheduler run. The |
| 47 |
* scheduler calculates the data in place, adding the calculated values to the |
| 48 |
* existing data structures. Since the original data cannot be identified |
| 49 |
* anymore the applications needs to make a copy of the project before calling |
| 50 |
* the scheduler. For that purpose Project and all related sub-classes provide |
| 51 |
* a copy constructor. |
| 52 |
* |
| 53 |
* @short The root class of all project related information. |
| 54 |
* @author Chris Schlaeger <[email protected]> |
| 55 |
*/ |
| 56 |
class PLANTJ_EXPORT Project : public QObject |
| 57 |
{ |
| 58 |
Q_OBJECT |
| 59 |
public: |
| 60 |
Project(); |
| 61 |
~Project() override; |
| 62 |
|
| 63 |
/* void addSourceFile(const QString& f); |
| 64 |
QStringList getSourceFiles() const;*/ |
| 65 |
// Called to Q_EMIT a signal with the currently processed file. |
| 66 |
void setProgressInfo(const QString& i); |
| 67 |
// Called to Q_EMIT a signal with the current process of the scheduler. |
| 68 |
void setProgressBar(int i, int of); |
| 69 |
/** |
| 70 |
* Projects have at least one ID, but can have multiple IDs. This usually |
| 71 |
* happens when projects are composed of several sub-projects. Each sub |
| 72 |
* projects brings its own unique ID. Each ID must be registered with the |
| 73 |
* project by calling addId(). The most recently added ID is also the |
| 74 |
* current ID. All subsequently added tasks are associated with this |
| 75 |
* project ID. So, you have to add at least one ID before you add any |
| 76 |
* tasks. |
| 77 |
*/ |
| 78 |
bool addId(const QString& i, bool changeCurrentId = true); |
| 79 |
|
| 80 |
/** |
| 81 |
* Returns the first (default) ID of the project. |
| 82 |
*/ |
| 83 |
QString getId() const |
| 84 |
{ |
| 85 |
return projectIDs.isEmpty() ? QString() : projectIDs.first(); |
| 86 |
} |
| 87 |
/** |
| 88 |
* Returns the current project ID. If the project ID list is empty |
| 89 |
* an empty QString is returned. |
| 90 |
*/ |
| 91 |
QString getCurrentId() const |
| 92 |
{ |
| 93 |
return currentId; |
| 94 |
} |
| 95 |
/** |
| 96 |
* Returns a list of all registered project IDs. |
| 97 |
*/ |
| 98 |
QStringList getProjectIdList() const { return projectIDs; } |
| 99 |
/** |
| 100 |
* Returns true if the passed ID is a registered project ID. |
| 101 |
*/ |
| 102 |
bool isValidId(const QString& i) const |
| 103 |
{ |
| 104 |
return projectIDs.indexOf(i) != -1; |
| 105 |
} |
| 106 |
/** |
| 107 |
* Returns a string ID of the index of the passed ID in the project ID. |
| 108 |
* The first ID in the list is returned as "A", the second as "B". The |
| 109 |
* 27th is "AA" and so on. |
| 110 |
*/ |
| 111 |
QString getIdIndex(const QString& i) const; |
| 112 |
|
| 113 |
/** |
| 114 |
* Returns the number of supported scenarios. |
| 115 |
*/ |
| 116 |
int getMaxScenarios() const { return scenarioList.count(); } |
| 117 |
/** |
| 118 |
* Returns a pointer to the scenario. |
| 119 |
* @param sc Index of the scenario in the project scenario list. |
| 120 |
*/ |
| 121 |
Scenario* getScenario(int sc) const; |
| 122 |
/** |
| 123 |
* Returns a pointer to the scenario with index sc. |
| 124 |
* @param sc Index of the scenario in the project scenario list. |
| 125 |
*/ |
| 126 |
QString getScenarioId(int sc) const; |
| 127 |
/** |
| 128 |
* Returns the name of a scenario. |
| 129 |
* @param sc Index of the scenario in the project scenario list. |
| 130 |
*/ |
| 131 |
QString getScenarioName(int sc) const; |
| 132 |
/** |
| 133 |
* Returns the index of the scenario. The index of the first item in the |
| 134 |
* list is 1, not 0! If the scenario is unknown -1 is returned. |
| 135 |
* @param id the ID of the scenario. |
| 136 |
*/ |
| 137 |
int getScenarioIndex(const QString& id) const; |
| 138 |
/** |
| 139 |
* Returns an iterator for the list of defined scenarios. |
| 140 |
*/ |
| 141 |
ScenarioListIterator getScenarioIterator() const |
| 142 |
{ |
| 143 |
return ScenarioListIterator(scenarioList); |
| 144 |
} |
| 145 |
|
| 146 |
/** |
| 147 |
* Set the name of the project. The project name is mainly used for the |
| 148 |
* reports. |
| 149 |
*/ |
| 150 |
void setName(const QString& n) { name = n; } |
| 151 |
/** |
| 152 |
* Returns the name of the project. |
| 153 |
*/ |
| 154 |
const QString& getName() const { return name; } |
| 155 |
|
| 156 |
/** |
| 157 |
* Set the version number of the project. This version is mainly used for |
| 158 |
* reports. |
| 159 |
*/ |
| 160 |
void setVersion(const QString& v) { version = v; } |
| 161 |
/** |
| 162 |
* Returns the version number of the project. |
| 163 |
*/ |
| 164 |
const QString& getVersion() const { return version; } |
| 165 |
|
| 166 |
/** |
| 167 |
* Set the copyright information. This is a default text used for all |
| 168 |
* reports. |
| 169 |
*/ |
| 170 |
void setCopyright(const QString& c) { copyright = c; } |
| 171 |
/** |
| 172 |
* Returns the copyright information of the project. |
| 173 |
*/ |
| 174 |
const QString& getCopyright() const { return copyright; } |
| 175 |
|
| 176 |
/** |
| 177 |
* Set the customer information for this project. |
| 178 |
*/ |
| 179 |
void setCustomer(const QString& c) { customer = c; } |
| 180 |
/** |
| 181 |
* Returns the customer information of the project. |
| 182 |
*/ |
| 183 |
const QString& getCustomer() const { return customer; } |
| 184 |
|
| 185 |
/** |
| 186 |
* Set the default priority for all top-level tasks. Normally this value |
| 187 |
* is 500. |
| 188 |
*/ |
| 189 |
void setPriority(int p) { priority = p; } |
| 190 |
/** |
| 191 |
* Returns the default priority for all top-level tasks. |
| 192 |
*/ |
| 193 |
int getPriority() const { return priority; } |
| 194 |
|
| 195 |
/** |
| 196 |
* Set the start time of the project. |
| 197 |
*/ |
| 198 |
void setStart(time_t s) { start = s; } |
| 199 |
/** |
| 200 |
* Get the start time of the project. |
| 201 |
*/ |
| 202 |
time_t getStart() const { return start; } |
| 203 |
|
| 204 |
/** |
| 205 |
* Set the end time of the project. The specified second is still |
| 206 |
* considered as within the project time frame. |
| 207 |
*/ |
| 208 |
void setEnd(time_t e) { end = e; } |
| 209 |
/** |
| 210 |
* Get the end time of the project. |
| 211 |
*/ |
| 212 |
time_t getEnd() const { return end; } |
| 213 |
|
| 214 |
/** |
| 215 |
* Set the date that TaskJuggler uses as current date for all |
| 216 |
* computations. This mainly affects status reporting and the computation |
| 217 |
* of the completion degree of tasks. */ |
| 218 |
void setNow(time_t n); |
| 219 |
/** |
| 220 |
* Get the date that TaskJuggler uses as current date. |
| 221 |
*/ |
| 222 |
time_t getNow() const { return now; } |
| 223 |
|
| 224 |
/** |
| 225 |
* Specifies whether TaskJuggler uses Sunday or Monday as first day of the |
| 226 |
* week. Besides the calendar views this mainly affects the numbering of |
| 227 |
* weeks. ISO 8601:1988 requires the week to start on Monday as most |
| 228 |
* European countries use, but other Countries like the US use Sunday as |
| 229 |
* first day of the week. |
| 230 |
*/ |
| 231 |
void setWeekStartsMonday(bool wsm) { weekStartsMonday = wsm; } |
| 232 |
/** |
| 233 |
* Get the setting for the first day of the week. |
| 234 |
* @return true of weeks should start on Monday. |
| 235 |
*/ |
| 236 |
bool getWeekStartsMonday() const { return weekStartsMonday; } |
| 237 |
/** |
| 238 |
* Decides if containers which subtasks are all hidden should be |
| 239 |
* drawn as normal tasks or not. |
| 240 |
*/ |
| 241 |
void setDrawEmptyContainersAsTasks(bool decat) |
| 242 |
{ |
| 243 |
drawEmptyContainerAsTasks = decat; |
| 244 |
} |
| 245 |
/** |
| 246 |
* @return true if containers which subtasks are all hidden should be |
| 247 |
* drawn as normal tasks |
| 248 |
*/ |
| 249 |
bool getDrawEmptyContainersAsTasks() const |
| 250 |
{ |
| 251 |
return drawEmptyContainerAsTasks; |
| 252 |
} |
| 253 |
/** |
| 254 |
* Set the working hours of the specified weekday. |
| 255 |
* @param day The day of the week. Independently of the weekStartsMonday |
| 256 |
* setting TaskJuggler uses 0 for Sunday, 1 for Monday and so on. |
| 257 |
* @param l The list of working intervals. The interval use seconds since |
| 258 |
* midnight. As with all TaskJuggler intervals, the specified end value is |
| 259 |
* not part of the interval. The interval ends one seconds earlier. |
| 260 |
*/ |
| 261 |
void setWorkingHours(int day, const QList<Interval*>& l); |
| 262 |
/** |
| 263 |
* Returns a constant list of working intervals for all week days. |
| 264 |
*/ |
| 265 |
const QList<Interval*>* const * getWorkingHours() const |
| 266 |
{ |
| 267 |
return static_cast<const QList<Interval*>* const*> |
| 268 |
(workingHours); |
| 269 |
} |
| 270 |
/** |
| 271 |
* Returns the list of working intervals for the specified weekday. |
| 272 |
* @param day Day of the week. 0 for Sunday, 1 for Monday and so on. |
| 273 |
*/ |
| 274 |
QList<Interval*>* getWorkingHours(int day) const |
| 275 |
{ |
| 276 |
if (day < 0 || day > 6) |
| 277 |
qFatal("day out of range"); |
| 278 |
return workingHours[day]; |
| 279 |
} |
| 280 |
/** |
| 281 |
* Returns an iterator for the list of working intervals for the |
| 282 |
* specified weekday. |
| 283 |
* @param day Day of the week. 0 for Sunday, 1 for Monday and so on. |
| 284 |
*/ |
| 285 |
QListIterator<Interval*> getWorkingHoursIterator(int day) const |
| 286 |
{ |
| 287 |
return QListIterator<Interval*>(*workingHours[day]); |
| 288 |
} |
| 289 |
/** |
| 290 |
* If there is a working interval defined for this weekday and the |
| 291 |
* day is not registered as a vacation day then it is a workday. |
| 292 |
*/ |
| 293 |
bool isWorkingDay(time_t d) const; |
| 294 |
|
| 295 |
/** |
| 296 |
* If date is contained in a vacation day or the date is outside |
| 297 |
* of the defined working hours, false is returned. Otherwise true. |
| 298 |
*/ |
| 299 |
bool isWorkingTime(time_t d) const; |
| 300 |
|
| 301 |
/** |
| 302 |
* If the interval overlaps with a vacation day or the interval is outside |
| 303 |
* of the defined working hours, false is returned. Otherwise true. |
| 304 |
*/ |
| 305 |
bool isWorkingTime(const Interval& iv) const; |
| 306 |
|
| 307 |
/** |
| 308 |
* Returns the number of working days that overlap with the specified |
| 309 |
* interval. |
| 310 |
*/ |
| 311 |
int calcWorkingDays(const Interval& iv) const; |
| 312 |
|
| 313 |
/** |
| 314 |
* The daily working hours value is used to convert working hours into |
| 315 |
* working days. It should be an average value of the specified |
| 316 |
* workingHours for each week day. With this function you can set the |
| 317 |
* value for the project. |
| 318 |
*/ |
| 319 |
void setDailyWorkingHours(double h) { dailyWorkingHours = h; } |
| 320 |
/** |
| 321 |
* Returns the specified daily working hours. |
| 322 |
*/ |
| 323 |
double getDailyWorkingHours() const { return dailyWorkingHours; } |
| 324 |
|
| 325 |
/** |
| 326 |
* The weekly working days value is used to convert working days into |
| 327 |
* working weeks. It should match the number of working days specified |
| 328 |
* with the workingHours. The value is derived from the yearlyWorkingDays |
| 329 |
* setting. This function returns the value. |
| 330 |
*/ |
| 331 |
double getWeeklyWorkingDays() const |
| 332 |
{ |
| 333 |
return yearlyWorkingDays / 52.1429; |
| 334 |
} |
| 335 |
|
| 336 |
/** |
| 337 |
* The monthly working days value is used to convert working days into |
| 338 |
* working month. It should reflect the workingHours settings and the |
| 339 |
* vacation settings. The value is derived from the yearlyWorkingDays |
| 340 |
* setting. This function returns the value. |
| 341 |
*/ |
| 342 |
double getMonthlyWorkingDays() const |
| 343 |
{ |
| 344 |
return yearlyWorkingDays / 12; |
| 345 |
} |
| 346 |
|
| 347 |
/** |
| 348 |
* The yearly working days value is used to convert working days into |
| 349 |
* working years. The value should reflect the workingHours settings and |
| 350 |
* the vacation settings. This function sets the value which also affects |
| 351 |
* the monthly working days and the weekly working days. |
| 352 |
*/ |
| 353 |
void setYearlyWorkingDays(double wd) { yearlyWorkingDays = wd; } |
| 354 |
/** |
| 355 |
* Returns the specified number of working days per year. |
| 356 |
*/ |
| 357 |
double getYearlyWorkingDays() const { return yearlyWorkingDays; } |
| 358 |
|
| 359 |
void setScheduleGranularity(ulong s) { scheduleGranularity = s; } |
| 360 |
ulong getScheduleGranularity() const { return scheduleGranularity; } |
| 361 |
|
| 362 |
void setAllowRedefinitions(bool ar) { allowRedefinitions = ar; } |
| 363 |
bool getAllowRedefinitions() const { return allowRedefinitions; } |
| 364 |
|
| 365 |
/** |
| 366 |
* Add a vacation interval to the vacation list. These global vacations |
| 367 |
* are meant for events like Christmas, Eastern or corporate holidays. |
| 368 |
* A day that overlaps any of the intervals in the list is considered to |
| 369 |
* not be a working day. Vacation intervals may not overlap. |
| 370 |
* @param n Name of the vacation. |
| 371 |
* @param i The time interval the vacation lasts. |
| 372 |
*/ |
| 373 |
void addVacation(const QString& n, const Interval& i) |
| 374 |
{ |
| 375 |
vacationList.add(n, i); |
| 376 |
} |
| 377 |
void addVacation(VacationInterval* vi) |
| 378 |
{ |
| 379 |
vacationList.add(vi); |
| 380 |
} |
| 381 |
/** |
| 382 |
* Returns true if the passed moment falls within any of the vacation |
| 383 |
* intervals. |
| 384 |
*/ |
| 385 |
bool isVacation(time_t vd) const { return vacationList.isVacation(vd); } |
| 386 |
|
| 387 |
/** |
| 388 |
* Returns the name of the first vacation that the given date falls into. |
| 389 |
* If no vacation is found QString::Null is returned. |
| 390 |
*/ |
| 391 |
QString vacationName(time_t vd) const |
| 392 |
{ |
| 393 |
return vacationList.vacationName(vd); |
| 394 |
} |
| 395 |
|
| 396 |
/** |
| 397 |
* Returns an iterator for the vacation list. |
| 398 |
*/ |
| 399 |
VacationList::Iterator getVacationListIterator() const |
| 400 |
{ |
| 401 |
return VacationList::Iterator(vacationList); |
| 402 |
} |
| 403 |
|
| 404 |
/** |
| 405 |
* This function is for library internal use only. Creating a Scenario |
| 406 |
* object with the project as parameter will automatically add it to the |
| 407 |
* scenario list of the project. |
| 408 |
*/ |
| 409 |
void addScenario(Scenario* r); |
| 410 |
/** |
| 411 |
* This function is for library internal use only. Deleting a Scenario |
| 412 |
* will automatically delete it from the respective list of the |
| 413 |
* project. |
| 414 |
*/ |
| 415 |
void deleteScenario(Scenario* s); |
| 416 |
|
| 417 |
/** |
| 418 |
* This function is for library internal use only. Creating a Task object |
| 419 |
* with the project as parameter will automatically add it to the Task |
| 420 |
* list of the project. |
| 421 |
*/ |
| 422 |
void addTask(Task* t); |
| 423 |
/** |
| 424 |
* This function is for library internal use only. Deleting a Task |
| 425 |
* will automatically delete it from the respective list of the |
| 426 |
* project. |
| 427 |
*/ |
| 428 |
void deleteTask(Task* t); |
| 429 |
/** |
| 430 |
* Returns a pointer to the Task with the specified ID. The ID must be an |
| 431 |
* absolute ID of the form "foo.bar". If no Task with the ID exists 0 is |
| 432 |
* returned. |
| 433 |
*/ |
| 434 |
Task* getTask(const QString& id) const |
| 435 |
{ |
| 436 |
return taskList.getTask(id); |
| 437 |
} |
| 438 |
/** |
| 439 |
* Returns the number of tasks of the project. |
| 440 |
*/ |
| 441 |
uint taskCount() const { return taskList.count(); } |
| 442 |
/** |
| 443 |
* Returns a copy of the Task list of the project. |
| 444 |
*/ |
| 445 |
TaskList getTaskList() const { return taskList; } |
| 446 |
/** |
| 447 |
* Returns an iterator that can be used to traverse the Task list. The |
| 448 |
* Task list is a flat list of all tasks. |
| 449 |
*/ |
| 450 |
TaskListIterator getTaskListIterator() const |
| 451 |
{ |
| 452 |
return TaskListIterator(taskList); |
| 453 |
} |
| 454 |
/** |
| 455 |
* This function adds a new, user-defined attribute to the Task |
| 456 |
* attributes. The @param id must be unique within the Task attributes |
| 457 |
* namespace. @param cad is a pointer to the CustomAttributeDefinition |
| 458 |
* object. |
| 459 |
*/ |
| 460 |
bool addTaskAttribute(const QString& id, CustomAttributeDefinition* cad); |
| 461 |
/** |
| 462 |
* Returns a pointer to the custom attribute object identified by @p id. |
| 463 |
* If no attributes with the id exists, 0 is returned. |
| 464 |
* @param id the identifier |
| 465 |
*/ |
| 466 |
const CustomAttributeDefinition* getTaskAttribute(const QString& id) const; |
| 467 |
/** |
| 468 |
* Returns a read-only pointer to the dictionary that holds the pointers |
| 469 |
* to user-defined attributes of Tasks. |
| 470 |
*/ |
| 471 |
const QMap<QString, CustomAttributeDefinition*>& |
| 472 |
getTaskAttributeDict() const |
| 473 |
{ |
| 474 |
return taskAttributes; |
| 475 |
} |
| 476 |
|
| 477 |
/** |
| 478 |
* This function is for library internal use only. Creating a Resource |
| 479 |
* object with the project as parameter will automatically add it to the |
| 480 |
* resource list of the project. |
| 481 |
*/ |
| 482 |
void addResource(Resource* r); |
| 483 |
/** |
| 484 |
* This function is for library internal use only. Deleting a Resource |
| 485 |
* will automatically delete it from the respective list of the |
| 486 |
* project. |
| 487 |
*/ |
| 488 |
void deleteResource(Resource* r); |
| 489 |
/** |
| 490 |
* Returns a pointer to the Resource with the specified ID. The ID must |
| 491 |
* not be an absolute ID since the Resource list has a flat namespace. If |
| 492 |
* no Resource with the ID exists 0 is returned. |
| 493 |
*/ |
| 494 |
Resource* getResource(const QString& id) const |
| 495 |
{ |
| 496 |
return resourceList.getResource(id); |
| 497 |
} |
| 498 |
/** |
| 499 |
* Returns the number of resources in the Resource list. |
| 500 |
*/ |
| 501 |
uint resourceCount() const { return resourceList.count(); } |
| 502 |
/** |
| 503 |
* Returns a copy of the Resource list. |
| 504 |
*/ |
| 505 |
ResourceList getResourceList() const { return resourceList; } |
| 506 |
/** |
| 507 |
* Returns an iterator that can be used to traverse the Resource list. The |
| 508 |
* Resource list is a flat list of all resources. |
| 509 |
*/ |
| 510 |
ResourceListIterator getResourceListIterator() const |
| 511 |
{ |
| 512 |
return ResourceListIterator(resourceList); |
| 513 |
} |
| 514 |
/** |
| 515 |
* This function adds a new, user-defined attribute to the Resource |
| 516 |
* attributes. The @p name must be unique within the Resource attributes |
| 517 |
* namespace. @p cad is a pointer to the CustomAttributeDefinition |
| 518 |
* object. |
| 519 |
* @param name the name of the attribute |
| 520 |
* @param cad the pointer to the CustomAttributeDefinition object |
| 521 |
*/ |
| 522 |
bool addResourceAttribute(const QString& name, |
| 523 |
CustomAttributeDefinition* cad); |
| 524 |
/** |
| 525 |
* Returns a pointer to the custom attribute object identified by @p id. |
| 526 |
* If no attributes with the id exists, 0 is returned. |
| 527 |
* @param id the identifier |
| 528 |
*/ |
| 529 |
const CustomAttributeDefinition* getResourceAttribute(const QString& id) |
| 530 |
const; |
| 531 |
/** |
| 532 |
* Returns a read-only pointer to the dictionary that holds the pointers |
| 533 |
* to user-defined attributes of Resources. |
| 534 |
*/ |
| 535 |
const QMap<QString, CustomAttributeDefinition*>& |
| 536 |
getResourceAttributeDict() const |
| 537 |
{ |
| 538 |
return resourceAttributes; |
| 539 |
} |
| 540 |
|
| 541 |
/** |
| 542 |
* This function is for library internal use only. Creating an Account |
| 543 |
* object with the project as parameter will automatically add it to the |
| 544 |
* Account list of the project. |
| 545 |
*/ |
| 546 |
// void addAccount(Account* a); |
| 547 |
/** |
| 548 |
* This function is for library internal use only. Deleting a Account |
| 549 |
* will automatically delete it from the respective list of the |
| 550 |
* project. |
| 551 |
*/ |
| 552 |
// void deleteAccount(Account* a); |
| 553 |
/** |
| 554 |
* Returns a pointer to the Account with the specified ID. The ID may |
| 555 |
* not be an absolute ID since the account list has a flat namespace. If |
| 556 |
* no Account with the ID exists 0 is returned. |
| 557 |
*/ |
| 558 |
/* Account* getAccount(const QString& id) const |
| 559 |
{ |
| 560 |
return accountList.getAccount(id); |
| 561 |
}*/ |
| 562 |
/** |
| 563 |
* Returns the number of accounts in the Account list. |
| 564 |
*/ |
| 565 |
// uint accountCount() const { return accountList.count(); } |
| 566 |
/** |
| 567 |
* Returns a copy of the Account list. |
| 568 |
*/ |
| 569 |
// AccountList getAccountList() const { return accountList; } |
| 570 |
/** |
| 571 |
* Returns an iterator that can be used to traverse the Account list. The |
| 572 |
* Account list is a flat list of all accounts. |
| 573 |
*/ |
| 574 |
/* AccountListIterator getAccountListIterator() const |
| 575 |
{ |
| 576 |
return AccountListIterator(accountList); |
| 577 |
}*/ |
| 578 |
/** |
| 579 |
* This function adds a new, user-defined attribute to the Account |
| 580 |
* attributes. The @param id must be unique within the Account attributes |
| 581 |
* namespace. @param cad is a pointer to the CustomAttributeDefinition |
| 582 |
* object. |
| 583 |
*/ |
| 584 |
/* bool addAccountAttribute(const QString& name, |
| 585 |
CustomAttributeDefinition* cad);*/ |
| 586 |
/** |
| 587 |
* Returns a pointer to the custom attribute object identified by @p id. |
| 588 |
* If no attributes with the id exists, 0 is returned. |
| 589 |
*/ |
| 590 |
/* const CustomAttributeDefinition* getAccountAttribute(const QString& id) |
| 591 |
const;*/ |
| 592 |
/** |
| 593 |
* Returns a read-only pointer to the dictionary that holds the pointers |
| 594 |
* to user-defined attributes of Accounts. |
| 595 |
*/ |
| 596 |
// const QList<CustomAttributeDefinition*>& |
| 597 |
// getAccountAttributeDict() const |
| 598 |
// { |
| 599 |
// return accountAttributes; |
| 600 |
// } |
| 601 |
|
| 602 |
/** |
| 603 |
* This function is for library internal use only. Creating a Shift |
| 604 |
* object with the project as parameter will automatically add it to the |
| 605 |
* Shift list of the project. |
| 606 |
*/ |
| 607 |
void addShift(Shift* s); |
| 608 |
/** |
| 609 |
* This function is for library internal use only. Deleting a Shift |
| 610 |
* will automatically delete it from the respective list of the |
| 611 |
* project. |
| 612 |
*/ |
| 613 |
void deleteShift(Shift* s); |
| 614 |
/** |
| 615 |
* Returns a pointer to the Shift with the specified ID. The ID may |
| 616 |
* not be an absolute ID since the Shift list has a flat namespace. If |
| 617 |
* no Shift with the ID exists 0 is returned. |
| 618 |
*/ |
| 619 |
Shift* getShift(const QString& id) const |
| 620 |
{ |
| 621 |
return shiftList.getShift(id); |
| 622 |
} |
| 623 |
/** |
| 624 |
* Returns the number of shifts in the shift list. |
| 625 |
*/ |
| 626 |
uint shiftCount() const { return shiftList.count(); } |
| 627 |
/** |
| 628 |
* Returns a copy of the Shift list. |
| 629 |
*/ |
| 630 |
ShiftList getShiftList() const { return shiftList; } |
| 631 |
/** |
| 632 |
* Returns an iterator that can be used to traverse the Shift list. The |
| 633 |
* Shift list is a flat list of all accounts. |
| 634 |
*/ |
| 635 |
ShiftListIterator getShiftListIterator() const |
| 636 |
{ |
| 637 |
return ShiftListIterator(shiftList); |
| 638 |
} |
| 639 |
|
| 640 |
/** |
| 641 |
* Set the minimum daily effort for resources. This value is not used for |
| 642 |
* resource allocation. It is currently not used at all. In future |
| 643 |
* versions TaskJuggler might spit out warnings for all resources that are |
| 644 |
* not loaded to at least this value each day. The value is inherited by |
| 645 |
* all resources that are created subsequent to this function call. |
| 646 |
*/ |
| 647 |
void setMinEffort(double m) { minEffort = m; } |
| 648 |
/** |
| 649 |
* Returns the default minimum effort value. |
| 650 |
*/ |
| 651 |
double getMinEffort() const { return minEffort; } |
| 652 |
|
| 653 |
/** |
| 654 |
* Set the maximum efforts for resources. This is the default value |
| 655 |
* inherited by all resources created subsequent to this function call. A |
| 656 |
* resource is never loaded more each day, week, month etc. than the |
| 657 |
* maximum effort value specified for the resource. |
| 658 |
*/ |
| 659 |
void setResourceLimits(UsageLimits* l); |
| 660 |
|
| 661 |
/** |
| 662 |
* Returns the default effort limits for resources. |
| 663 |
*/ |
| 664 |
const UsageLimits* getResourceLimits() const { return resourceLimits; } |
| 665 |
|
| 666 |
/** |
| 667 |
* Set the default daily cost rate for resources. This value is inherited |
| 668 |
* by all resources created subsequent to this function call. |
| 669 |
*/ |
| 670 |
// void setRate(double r) { rate = r; } |
| 671 |
/** |
| 672 |
* Return the default daily cost rate for resources. |
| 673 |
*/ |
| 674 |
// double getRate() const { return rate; } |
| 675 |
|
| 676 |
/** |
| 677 |
* Set the currency unit for the project. |
| 678 |
*/ |
| 679 |
// void setCurrency(const QString& s) { currency = s; } |
| 680 |
/** |
| 681 |
* Returns the currency unit setting. |
| 682 |
*/ |
| 683 |
// const QString& getCurrency() const { return currency; } |
| 684 |
|
| 685 |
/** |
| 686 |
* Sets the number of decimal digits used for all currency values of the |
| 687 |
* project. |
| 688 |
*/ |
| 689 |
// void setCurrencyDigits(uint cd) { currencyFormat.setFracDigits(cd); } |
| 690 |
|
| 691 |
/** |
| 692 |
* Sets the default number format for load and other values. |
| 693 |
*/ |
| 694 |
// void setNumberFormat(const RealFormat& rf) { numberFormat = rf; } |
| 695 |
/** |
| 696 |
* Returns the current default number format. |
| 697 |
*/ |
| 698 |
// const RealFormat& getNumberFormat() const { return numberFormat; } |
| 699 |
|
| 700 |
/** |
| 701 |
* Sets the default currency format. |
| 702 |
*/ |
| 703 |
// void setCurrencyFormat(const RealFormat& rf) { currencyFormat = rf; } |
| 704 |
/** |
| 705 |
* Returns the default currency format. |
| 706 |
*/ |
| 707 |
// const RealFormat& getCurrencyFormat() const { return currencyFormat; } |
| 708 |
|
| 709 |
/** |
| 710 |
* Set the default time zone for the project. |
| 711 |
*/ |
| 712 |
bool setTimeZone(const QString& tz); |
| 713 |
/** |
| 714 |
* Returns the default time zone of the project; |
| 715 |
*/ |
| 716 |
const QString& getTimeZone() const { return timeZone; } |
| 717 |
|
| 718 |
/** |
| 719 |
* Sets the format used for timestamps in reports. It will be used as |
| 720 |
* default for all subsequent report definitions. See the TaskJuggler |
| 721 |
* manual for the format details. |
| 722 |
*/ |
| 723 |
void setShortTimeFormat(const QString& tf) { shortTimeFormat = tf; } |
| 724 |
/** |
| 725 |
* Returns the format for timestamps in reports. |
| 726 |
*/ |
| 727 |
const QString& getShortTimeFormat() const { return shortTimeFormat; } |
| 728 |
|
| 729 |
/** |
| 730 |
* Sets the format used for date stamps in reports. It will be used as |
| 731 |
* default for all subsequent report definitions. See the TaskJuggler |
| 732 |
* manual for the format details. |
| 733 |
*/ |
| 734 |
void setTimeFormat(const QString& tf) { timeFormat = tf; } |
| 735 |
/** |
| 736 |
* Returns the format for date stamps in reports. |
| 737 |
*/ |
| 738 |
const QString& getTimeFormat() const { return timeFormat; } |
| 739 |
|
| 740 |
// void addXMLReport(ReportXML *r) { xmlreport = r; } |
| 741 |
// |
| 742 |
// void addReport(Report* r) |
| 743 |
// { |
| 744 |
// reports.append(r); |
| 745 |
// } |
| 746 |
// Report* getReport(uint idx) const; |
| 747 |
// QPtrListIterator<Report> getReportListIterator() const; |
| 748 |
|
| 749 |
void addAllowedFlag(QString flag) |
| 750 |
{ |
| 751 |
if (!isAllowedFlag(flag)) |
| 752 |
allowedFlags.append(flag); |
| 753 |
} |
| 754 |
bool isAllowedFlag(const QString& flag) const |
| 755 |
{ |
| 756 |
return allowedFlags.contains(flag) > 0; |
| 757 |
} |
| 758 |
|
| 759 |
const QStringList getAllowedFlags() const |
| 760 |
{ |
| 761 |
return allowedFlags; |
| 762 |
} |
| 763 |
|
| 764 |
/** |
| 765 |
* Converts working seconds to working days. |
| 766 |
*/ |
| 767 |
double convertToDailyLoad(long secs) const; |
| 768 |
|
| 769 |
void setMaxErrors(int me) { maxErrors = me; } |
| 770 |
|
| 771 |
// void addJournalEntry(JournalEntry* entry); |
| 772 |
// |
| 773 |
// bool hasJournal() const { return !journal.isEmpty(); } |
| 774 |
// |
| 775 |
// Journal::Iterator getJournalIterator() const; |
| 776 |
|
| 777 |
/** |
| 778 |
* Generate cross references between all data structures and run a |
| 779 |
* consistency check. This function must be called after the project data |
| 780 |
* tree has been constructed. |
| 781 |
* @return Only if all tests were successful true is returned. |
| 782 |
*/ |
| 783 |
bool pass2(bool noDepCheck); |
| 784 |
|
| 785 |
bool scheduleScenario(Scenario* sc); |
| 786 |
void breakScheduling(); |
| 787 |
void completeBuffersAndIndices(); |
| 788 |
bool scheduleAllScenarios(); |
| 789 |
// bool generateReports() const; |
| 790 |
|
| 791 |
// bool generateXMLReport() const; |
| 792 |
/// Call this to abort the scheduling. |
| 793 |
void cancelScheduling(); |
| 794 |
|
| 795 |
Q_SIGNALS: |
| 796 |
void updateProgressInfo(const QString& i); |
| 797 |
void updateProgressBar(int i, int of); |
| 798 |
|
| 799 |
private: |
| 800 |
void overlayScenario(int base, int sc); |
| 801 |
void prepareScenario(int sc); |
| 802 |
void finishScenario(int sc); |
| 803 |
|
| 804 |
TaskList tasksReadyToBeScheduled(int sc, const TaskList &leafTasks); |
| 805 |
bool schedule(int sc); |
| 806 |
|
| 807 |
bool checkSchedule(int sc) const; |
| 808 |
|
| 809 |
/// The start date of the project |
| 810 |
time_t start; |
| 811 |
/// The end date of the project |
| 812 |
time_t end; |
| 813 |
/// The current date used in status calculations and reports. |
| 814 |
time_t now; |
| 815 |
|
| 816 |
bool allowRedefinitions; |
| 817 |
|
| 818 |
/// True if week based calculations use Monday as first day of week. |
| 819 |
bool weekStartsMonday; |
| 820 |
|
| 821 |
/// True if containers w/o visible subtask should be drawn as normal tasks |
| 822 |
bool drawEmptyContainerAsTasks; |
| 823 |
|
| 824 |
/// The name of the Project |
| 825 |
QString name; |
| 826 |
/// The revision of the project description. |
| 827 |
QString version; |
| 828 |
/// Some legal words to please the boss. |
| 829 |
QString copyright; |
| 830 |
|
| 831 |
/// Some information about the customer of this project. |
| 832 |
QString customer; |
| 833 |
|
| 834 |
/// The default timezone of the project. |
| 835 |
QString timeZone; |
| 836 |
/** |
| 837 |
* A format string in strftime(3) format that specifies the default time |
| 838 |
* format for all time values TaskJuggler generates. |
| 839 |
*/ |
| 840 |
QString timeFormat; |
| 841 |
/** |
| 842 |
* A format string in strftime(3) format that specifies the time format |
| 843 |
* for all daytime values (e. g. HH:MM). |
| 844 |
*/ |
| 845 |
QString shortTimeFormat; |
| 846 |
|
| 847 |
/// The currency of used for all money values. |
| 848 |
QString currency; |
| 849 |
/// The number of fraction digits of all money values. |
| 850 |
int currencyDigits; |
| 851 |
|
| 852 |
// The default format used for printing load values and the like. |
| 853 |
// RealFormat numberFormat; |
| 854 |
// The default format used for printing currency values. |
| 855 |
// RealFormat currencyFormat; |
| 856 |
|
| 857 |
/** |
| 858 |
* The default priority that will be inherited by all tasks. Sub tasks |
| 859 |
* will inherit the priority of its parent task. */ |
| 860 |
int priority; |
| 861 |
|
| 862 |
/// Default values for Resource variables (TODO: should be obsoleted!) |
| 863 |
double minEffort; |
| 864 |
|
| 865 |
/** |
| 866 |
* The default resource usage limits. |
| 867 |
*/ |
| 868 |
UsageLimits* resourceLimits; |
| 869 |
|
| 870 |
/** |
| 871 |
* The default daily cost of a resource. The value is inherited to all |
| 872 |
* resources but can be overridden. |
| 873 |
*/ |
| 874 |
double rate; |
| 875 |
|
| 876 |
/* The average number of working hours per day. This factor is used |
| 877 |
* when converting hours in working days. It should match the workingHours |
| 878 |
* closely. */ |
| 879 |
double dailyWorkingHours; |
| 880 |
|
| 881 |
/* The average number of working days per year. This factor is used when |
| 882 |
* converting working days into years. It should match the defined working |
| 883 |
* hours and vacation days. */ |
| 884 |
double yearlyWorkingDays; |
| 885 |
|
| 886 |
/* The list of standard working or opening hours. These values will be |
| 887 |
* inherited by the resources as default working hours. */ |
| 888 |
QList<Interval*>* workingHours[7]; |
| 889 |
|
| 890 |
/** |
| 891 |
* The granularity of the scheduler in seconds. No intervals |
| 892 |
* shorter than this time will be scheduled. */ |
| 893 |
ulong scheduleGranularity; |
| 894 |
|
| 895 |
/** |
| 896 |
* To avoid difficult to find typos in flag names all flags must |
| 897 |
* be registered before they can be used. This variable contains |
| 898 |
* the list of all registered flags. It is legal to declare a flag |
| 899 |
* twice, so we can merge projects to a larger project. */ |
| 900 |
QStringList allowedFlags; |
| 901 |
|
| 902 |
/** |
| 903 |
* Each project has a unique ID but can have multiple other IDs as |
| 904 |
* well. This happens usually when small projects are merged to a |
| 905 |
* create a big project. Each task can be assigned to a different |
| 906 |
* project ID but all IDs must be declared before they can be |
| 907 |
* used. */ |
| 908 |
QStringList projectIDs; |
| 909 |
|
| 910 |
QString currentId; |
| 911 |
|
| 912 |
int maxErrors; |
| 913 |
|
| 914 |
// Journal journal; |
| 915 |
|
| 916 |
VacationList vacationList; |
| 917 |
|
| 918 |
ScenarioList scenarioList; |
| 919 |
TaskList taskList; |
| 920 |
ResourceList resourceList; |
| 921 |
// AccountList accountList; |
| 922 |
ShiftList shiftList; |
| 923 |
|
| 924 |
/** |
| 925 |
* The following lists contain a deep copy of their unscheduled |
| 926 |
* counterpart. They will be used to initialize the working lists before |
| 927 |
* an optimizer run. |
| 928 |
*/ |
| 929 |
TaskList originalTaskList; |
| 930 |
ResourceList originalResourceList; |
| 931 |
// AccountList originalAccountList; |
| 932 |
|
| 933 |
QMap<QString, CustomAttributeDefinition*> taskAttributes; |
| 934 |
QMap<QString, CustomAttributeDefinition*> resourceAttributes; |
| 935 |
// QList<CustomAttributeDefinition*> accountAttributes; |
| 936 |
|
| 937 |
/* This is for version 1.0 XML reports and should be removed before the |
| 938 |
* next major release. */ |
| 939 |
/* ReportXML* xmlreport; |
| 940 |
|
| 941 |
QPtrList<Report> reports; |
| 942 |
QPtrList<QtReport> interactiveReports;*/ |
| 943 |
QStringList sourceFiles; |
| 944 |
|
| 945 |
// This flag is raised to abort the scheduling. |
| 946 |
bool breakFlag; |
| 947 |
// This flag is raised to abort the scheduling. |
| 948 |
bool cancelSchedulingFlag; |
| 949 |
} ; |
| 950 |
|
| 951 |
} // namespace TJ |
| 952 |
|
| 953 |
#endif |