Project

class Project

Public Functions

void parse_project_xml(rapidxml::xml_document<> &pDoc)

Parse the xml file of project.

Parameters:

pDoc

void process_xml(QFile &pPath)

This function proecesses the xml file and creates a tree model.

Give XML file path and the content will be stored inside the class and processed by rapidxml

Parameters:

pFile

void addFile(Filter &f, QFile &pFile)

This function will add file to our project.

The function first traverses the tree and when the appropriate branch is reached the node is added to the parent

Parameters:
  • f

  • pFile

void getFile(const QString &pFileName)

Gets the file with filename.

Parameters:

pFileName

void save_xml()

This function when called saves the xml changes to disk.

We used standard c++ functions to achieve this.

QDir GetDir()

returns the directory of the project when called.

void removeFile(QModelIndex &idx, Filter &pFilter, QFile &pFile)

Removes the file name from project.xml and the hierarchial project tree view in ui window.

Parameters:
  • idx

  • pFilter

  • pFile

pugi::xml_node FindFile(QFile &file, pugi::xml_node &n)

This function searches for the passed file name and returns the filename and its next consecutive file name from project.xml.

This is a recursive function wherein We keep traversing the child notes of the directory tree until we find the file. If the key(i.e the name of the child node file) matches the filename the search is over and we return, if there are not child node files/directories then also we return.

At some point once the function gets to the end of the tree in case the file is not found till yet then there will be no children and thus it will return.

Parameters:
  • file

  • QFile – & file,pugi::xml_node & n

Returns:

FindFile(file, next)

TreeModel *getModel()

returns the whole tree model whenever the function is called

Returns:

TreeModel *model

void open_git_repo()

Opens the git repo under the hood in a git_repository variable.

void lg2_add()

It adds the “workingFolder” to current git index so that they can be tracked and later pushed.

It adds everything in the current directory to the current git index.

Parameters:

workingFolder

bool commit(std::string message)

This function commits the changes done to the local repository.

Parameters:

message

Returns:

bool

bool push(QString branchName)

This function is responsible for pushing the code to the remote github repository.

It uses libgit2 library for pushing the code.

  1. First store remote info from the remote repository.

  2. Then fetch remote objects.

  3. Merge fetched objects with local ones.

  4. Now, push the merged objects to the github repo.

Parameters:

branchName

Returns:

bool

bool add_config()

It takes the system level config from the git if git is installed and stores them into variables.

Returns:

bool

bool add_git_config()

It adds the git config to the variables.

Returns:

bool

int fetch()

This function fetches the remote objects from the remote repository.

It uses the credentials to perform the fetch.

If the local repository is not up to date with the remote one, then reset the local one to the latest commit.

Returns:

int

bool enable_push(bool increment)

Increments the version value by one if passed value is true and sets stage value as corrector in xml file.

We call this function to update the version of the project in the xml file.

See also

save_xml()

Parameters:

boolean

Returns:

bool

void AddTemp(Filter *f, QFile &pFile, QString prefix)

Adds only text files and html files to the project tree view whenever project is opened.

Parameters:
  • filter

  • file

  • prefix

int LevenshteinWithGraphemes(QList<Diff> diffs)

Returns the Levenshtein distance between the diffs.

Parameters:

diffs

Returns:

int

int GetGraphemesCount(QString string)

Returns the number of graphemes in a string.

Parameters:

string

Returns:

int

int GetPageNumber(std::string localFilename, std::string *no, size_t *loc, QString *ext)

Returns the page number from a given filename.

Parameters:
  • localFilename

  • no

  • loc

  • ext

Returns:

int

void add_and_commit()

Adds and commits the file.

void set_stage_verifier()

Updates the stage value in xml file to ‘Verifier’.

See also

save_xml()

void set_stage(QString mRole)

According to the pipeline once the project has been corrected it goes to verifier for further verification.

As such we update the XML of the project (project.xml file) and set the stage of the project to indicate that it is in verification mode.

Parameters:

mRole

void set_verifier()

Sets the project stage as verifier.

void set_corrector()

Sets the project stage as corrector.

QString get_stage()

Returns the stage from the project.xml.

Returns:

QString

QString get_version()

Returns the version of the set.

Returns:

QString

QString get_configuration()

Returns the configuration from project.xml.

Returns:

QString

void set_version(int)

This function is to set version as passed in the parameters.

Parameters:

int – ver

void set_configuration(QString val)

We set the configuration of the project by passing the whole string of the configuration as a string We match the xml tags with that of the configuration and change the InnerXML accordingly.

Parameters:

QString – val

QString get_pmEmail()

Returns the project manager email.

Returns:

QString

QString get_bookId()

Returns the book id.

Returns:

QString

QString get_setId()

Returns the set id.

Returns:

QString

QString get_repo()

Returns the repository link of the set.

Returns:

QString

Filter *getFilter(QString name)

Returns the pointer to the Filter whose name matches to the string passed otherwise returns nullptr.

Parameters:

str

Returns:

Filter*

Public Static Functions

static int clone(QString url_, QString path)

It clones the git repository from the “url_” and stores the repository in the path “path” passes.

Returns the success code

Parameters:
  • url_

  • path

Returns:

int