Merge branch 'fix/valideBtn' into 'dev'
fix of validate crash and validate dialogues and personnages See merge request p2406187/sae201!28
This commit is contained in:
commit
1a53e15095
@ -137,7 +137,7 @@ void MainWindow::loadPath(Path* p) {
|
|||||||
ui->longitudeSpin->setValue(firstStep.getLongitude());
|
ui->longitudeSpin->setValue(firstStep.getLongitude());
|
||||||
|
|
||||||
for(int i = 0; i < firstStep.getTexte().length(); i++) {
|
for(int i = 0; i < firstStep.getTexte().length(); i++) {
|
||||||
QString q = firstStep.getPersonnage().at(i) + ": " + firstStep.getTexte().at(i);
|
QString q = "[" + firstStep.getPersonnage().at(i) + "] : " + firstStep.getTexte().at(i);
|
||||||
ui->dialogEdit->appendPlainText(q);
|
ui->dialogEdit->appendPlainText(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,8 +626,51 @@ void MainWindow::on_validateBtn_clicked()
|
|||||||
this->currentPath->setDuration(ui->durationSpin->value());
|
this->currentPath->setDuration(ui->durationSpin->value());
|
||||||
this->currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text());
|
this->currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text());
|
||||||
this->currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value());
|
this->currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value());
|
||||||
|
this->currentPath->getStep()[ui->stepNumber->value()-1].clearPersonnages();
|
||||||
|
this->currentPath->getStep()[ui->stepNumber->value()-1].clearTextes();
|
||||||
|
extractDialogue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::extractDialogue() {
|
||||||
|
std::string texte = ui->dialogEdit->toPlainText().toStdString();
|
||||||
|
size_t currentPosition = 0;
|
||||||
|
|
||||||
|
while (currentPosition < texte.length()) {
|
||||||
|
size_t startPersonnage = texte.find('[', currentPosition);
|
||||||
|
if (startPersonnage == std::string::npos) break;
|
||||||
|
size_t endPersonnage = texte.find(']', startPersonnage);
|
||||||
|
if (endPersonnage == std::string::npos) break;
|
||||||
|
std::string nomPersonnage = texte.substr(startPersonnage + 1, endPersonnage - startPersonnage - 1);
|
||||||
|
|
||||||
|
size_t startDialogue = texte.find(':', endPersonnage);
|
||||||
|
if (startDialogue == std::string::npos) break;
|
||||||
|
startDialogue += 2;
|
||||||
|
size_t endDialogue = startDialogue;
|
||||||
|
while (endDialogue < texte.length()) {
|
||||||
|
size_t nextNewLine = texte.find('\n', endDialogue);
|
||||||
|
if (nextNewLine == std::string::npos) {
|
||||||
|
endDialogue = texte.length();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
size_t nextPersonnageStart = texte.find('[', nextNewLine);
|
||||||
|
if (nextPersonnageStart != std::string::npos && nextPersonnageStart < nextNewLine + nomPersonnage.length() + 3) {
|
||||||
|
endDialogue = nextNewLine;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
endDialogue = nextNewLine + 1;
|
||||||
|
}
|
||||||
|
std::string dialogue = texte.substr(startDialogue, endDialogue - startDialogue);
|
||||||
|
|
||||||
|
currentPath->getStep()[ui->stepNumber->value()-1].addPersonnage(QString::fromStdString(nomPersonnage));
|
||||||
|
currentPath->getStep()[ui->stepNumber->value()-1].addTexte(QString::fromStdString(dialogue));
|
||||||
|
currentPosition = endDialogue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::loadAndExportPaths(QStringList fichiers) {
|
void MainWindow::loadAndExportPaths(QStringList fichiers) {
|
||||||
|
|
||||||
|
|
||||||
@ -921,6 +964,7 @@ void MainWindow::newPath(){
|
|||||||
currentPath = p;
|
currentPath = p;
|
||||||
path.append(p);
|
path.append(p);
|
||||||
loadPath(p);
|
loadPath(p);
|
||||||
|
p->addStep();
|
||||||
|
|
||||||
int pathCount = path.length();
|
int pathCount = path.length();
|
||||||
ui->pathNumber->setMaximum(pathCount);
|
ui->pathNumber->setMaximum(pathCount);
|
||||||
@ -944,6 +988,3 @@ void MainWindow::on_actionFont_color_triggered()
|
|||||||
{
|
{
|
||||||
this->setColor();
|
this->setColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,7 @@ public:
|
|||||||
void setFont();
|
void setFont();
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void newPath();
|
void newPath();
|
||||||
|
void extractDialogue();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
|
|||||||
16
step.cpp
16
step.cpp
@ -37,6 +37,22 @@ QList<QString> Step::getTexte() const
|
|||||||
return texte;
|
return texte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Step::addPersonnage(const QString& pers) {
|
||||||
|
personnage.append(pers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Step::addTexte(const QString& txt) {
|
||||||
|
texte.append(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Step::clearPersonnages() {
|
||||||
|
personnage.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Step::clearTextes() {
|
||||||
|
texte.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void Step::setTitle(const QString &newTitle)
|
void Step::setTitle(const QString &newTitle)
|
||||||
{
|
{
|
||||||
title = newTitle;
|
title = newTitle;
|
||||||
|
|||||||
4
step.h
4
step.h
@ -33,6 +33,10 @@ public:
|
|||||||
void setPersonnage(const QList<QString> &newPersonnage);
|
void setPersonnage(const QList<QString> &newPersonnage);
|
||||||
void setTexte(const QList<QString> &newTexte);
|
void setTexte(const QList<QString> &newTexte);
|
||||||
QString toGPSFormat();
|
QString toGPSFormat();
|
||||||
|
void addPersonnage(const QString& pers) ;
|
||||||
|
void addTexte(const QString& txt);
|
||||||
|
void clearPersonnages();
|
||||||
|
void clearTextes();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STEP_H
|
#endif // STEP_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user