Logo Search packages:      
Sourcecode: taskjuggler version File versions  Download package

bool ProjectFile::parse (  ) 

Calling the parse function will start the processing of the opened project file. It will automatically read all include files as well. The collected data is stored into the Project object.

Definition at line 172 of file ProjectFile.cpp.

References Project::addAllowedFlag(), Project::addId(), Project::addVacation(), Project::getDailyWorkingHours(), Project::getEnd(), Project::getScheduleGranularity(), Project::isAllowedFlag(), Project::setCopyright(), UsageLimits::setDailyMax(), Project::setKotrus(), Project::setMinEffort(), Project::setPriority(), Project::setRate(), and Project::setResourceLimits().

{
    TokenType tt;
    QString token;

    for ( ; ; )
    {
        switch (tt = nextToken(token))
        {
        case EndOfFile:
            return TRUE;
        case ID:
            // Only macro and include are allowed prior to the project header.
            if (proj->getEnd() == 0 &&
                token != KW("project") && token != KW("macro") &&
                token != KW("include"))
            {
                errorMessage
                    (i18n("The project properties must be defined prior to any "
                          "account, shift, task or resource."));
                return FALSE;
            }

            if (token == KW("task"))
            {
                if (!readTask(0))
                    return FALSE;
                break;
            }
            else if (token == KW("account"))
            {
                if (!readAccount(0))
                    return FALSE;
                break;
            }
            else if (token == KW("resource"))
            {
                if (!readResource(0))
                    return FALSE;
                break;
            }
            else if (token == KW("shift"))
            {
                if (!readShift(0))
                    return FALSE;
                break;
            }
            else if (token == KW("vacation"))
            {
                time_t from, to;
                QString name;
                if (!readVacation(from, to, TRUE, &name))
                    return FALSE;
                proj->addVacation(name, Interval(from, to));
                break;
            }
            else if (token == KW("priority"))
            {
                int priority;
                if (!readPriority(priority))
                    return FALSE;
                proj->setPriority(priority);
                break;
            }
            else if (token == KW("mineffort"))
            {
                TokenType tt;
                if ((tt = nextToken(token)) != REAL && tt != INTEGER)
                {
                    errorMessage(i18n("Real value exptected"));
                    return FALSE;
                }
                proj->setMinEffort(token.toDouble());
                break;
            }
            else if (token == KW("maxeffort"))
            {
                TokenType tt;
                if ((tt = nextToken(token)) != REAL && tt != INTEGER)
                {
                    errorMessage(i18n("Real value exptected"));
                    return FALSE;
                }
                UsageLimits* limits = new UsageLimits;
                limits->setDailyMax
                    ((uint) ((token.toDouble() *
                              proj->getDailyWorkingHours() * 3600) /
                             proj->getScheduleGranularity()));
                proj->setResourceLimits(limits);
                break;
            }
            else if (token == KW("limits"))
            {
                UsageLimits* limits;
                if ((limits = readLimits()) == 0)
                    return FALSE;
                proj->setResourceLimits(limits);
                break;
            }
            else if (token == KW("rate"))
            {
                TokenType tt;
                if ((tt = nextToken(token)) != REAL && tt != INTEGER)
                {
                    errorMessage(i18n("Real value exptected"));
                    return FALSE;
                }
                proj->setRate(token.toDouble());
                break;
            }
            else if (token == KW("currency"))
            {
                errorMessage
                    (i18n("ERROR: 'currency' is no longer a property. It's "
                          "now an optional project attribute. Please fix "
                          "your project file."));
                return FALSE;
            }
            else if (token == KW("currencydigits"))
            {
                errorMessage
                    (i18n("ERROR: 'currencydigits' has been deprecated. "
                          "Please use 'currencyformat' instead."));
                return FALSE;
            }
            else if (token == "timingresolution")
            {
                errorMessage
                    (i18n("ERROR: 'timingresolution' is no longer a "
                          "property. It's now an optional project attribute. "
                          "Please fix your project file."));
                return FALSE;
            }
            else if (token == KW("workinghours"))
            {
                errorMessage
                    (i18n("ERROR: 'workinghours' is no longer a property. "
                          "It's now an optional project attribute. Please fix "
                          "your project file."));
                return FALSE;
            }
            else if (token == KW("copyright"))
            {
                if (nextToken(token) != STRING)
                {
                    errorMessage(i18n("String expected"));
                    return FALSE;
                }
                proj->setCopyright(token);
                break;
            }
            else if (token == KW("include"))
            {
                if (!readInclude())
                    return FALSE;
                break;
            }
            else if (token == KW("macro"))
            {
                QString id;
                if (nextToken(id) != ID)
                {
                    errorMessage(i18n("Macro ID expected"));
                    return FALSE;
                }
                QString file = openFiles.last()->getFile();
                uint line = openFiles.last()->getLine();
                if (nextToken(token) != MacroBody)
                {
                    errorMessage(i18n("Macro body expected"));
                    return FALSE;
                }
                Macro* macro = new Macro(id, token, file, line);
                if (!macros.addMacro(macro))
                {
                    errorMessage(i18n("Macro has been defined already"));
                    delete macro;
                    return FALSE;
                }
                break;
            }
            else if (token == KW("flags"))
            {
                for ( ; ; )
                {
                    QString flag;
                    if (nextToken(flag) != ID)
                    {
                        errorMessage(i18n("flag ID expected"));
                        return FALSE;
                    }

                    /* Flags can be declared multiple times, but we
                     * register a flag only once. */
                    if (!proj->isAllowedFlag(flag))
                        proj->addAllowedFlag(flag);

                    if ((tt = nextToken(token)) != COMMA)
                    {
                        returnToken(tt, token);
                        break;
                    }
                }
                break;
            }
            else if (token == KW("project"))
            {
                if (!readProject())
                    return FALSE;
                break;
            }
            else if (token == KW("projectid"))
            {
                for ( ; ; )
                {
                    QString id;
                    if (nextToken(id) != ID)
                    {
                        errorMessage(i18n("Project ID expected"));
                        return FALSE;
                    }

                    if (!proj->addId(id))
                    {
                        errorMessage
                            (i18n("Project ID %1 has already been registered")
                             .arg(id));
                        return FALSE;
                    }

                    if ((tt = nextToken(token)) != COMMA)
                    {
                        returnToken(tt, token);
                        break;
                    }
                }
                break;
            }
            else if (token == KW("projectids"))
            {
                for ( ; ; )
                {
                    QString id;
                    if (nextToken(id) != ID)
                    {
                        errorMessage(i18n("Project ID expected"));
                        return FALSE;
                    }

                    proj->addId(id, FALSE);

                    if ((tt = nextToken(token)) != COMMA)
                    {
                        returnToken(tt, token);
                        break;
                    }
                }
                break;
            }
            else if (token == "xmltaskreport")
            {
                errorMessage
                    (i18n("ERROR: The keyword 'xmltaskreport' is "
                          "deprecated. Please use the keyword 'xmlreport' "
                          "instead."));
                return FALSE;
            }
            else if (token == KW("xmlreport"))
            {
               if(!readXMLReport())
                  return FALSE;
               break;
            }
            else if (token == KW("icalreport"))
            {
               if( !readICalTaskReport())
                  return FALSE;
               break;
            }
            else if (token == KW("htmltaskreport") ||
                     token == KW("htmlresourcereport") ||
                     token == KW("htmlweeklycalendar") ||
                     token == KW("htmlaccountreport"))
            {
               if (!readHTMLReport(token))
                   return FALSE;
               break;
            }
            else if (token == KW("taskreport") ||
                     token == KW("resourcereport") ||
                     token == KW("accountreport"))
            {
                if (!readReport(token))
                    return FALSE;
                break;
            }
            else if (token == KW("htmlstatusreport"))
            {
                if (!readHTMLStatusReport())
                    return FALSE;
                break;
            }
            else if (token == KW("csvtaskreport") ||
                     token == KW("csvresourcereport") ||
                     token == KW("csvaccountreport"))
            {
                if (!readCSVReport(token))
                    return FALSE;
                break;
            }
            else if (token == KW("export"))
            {
                if (!readExportReport())
                    return FALSE;
                break;
            }
            else if (token == KW("kotrusmode"))
            {
                if (nextToken(token) != STRING ||
                    (token != KW("db") && token != KW("xml") &&
                     token != KW("nokotrus")))
                {
                    errorMessage(i18n("Unknown kotrus mode"));
                    return FALSE;
                }
                if (token != KW("nokotrus"))
                {
                    Kotrus* kotrus = new Kotrus();
                    kotrus->setKotrusMode(token);
                    proj->setKotrus(kotrus);
                }
                break;
            }
            else if (token == KW("supplement"))
            {
                if (nextToken(token) != ID ||
                    (token != KW("task") && (token != KW("resource"))))
                {
                    errorMessage(i18n("'task' or 'resource' expected"));
                    return FALSE;
                }
                if ((token == "task" && !readTaskSupplement("")) ||
                    (token == "resource" && !readResourceSupplement()))
                    return FALSE;
                break;
            }
            // break missing on purpose!
        default:
            errorMessage(i18n("Syntax Error at '%1'!").arg(token));
            return FALSE;
        }
        qApp->processEvents();
    }

    return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index