of save and load a path without image
This commit is contained in:
parent
8659ab81c3
commit
afd9997724
0
data/images/d.json
Normal file
0
data/images/d.json
Normal file
@ -22,7 +22,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
, Clipboard(QGuiApplication::clipboard())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
currentPath = new Path();
|
||||
|
||||
connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() {
|
||||
static QString previousText;
|
||||
@ -95,6 +95,7 @@ void MainWindow::loadNewPath()
|
||||
currentPath = p;
|
||||
path.append(p);
|
||||
loadPath(p);
|
||||
currentFile = fileName;
|
||||
|
||||
int pathCount = path.length();
|
||||
ui->pathNumber->setMaximum(pathCount);
|
||||
@ -116,6 +117,7 @@ void MainWindow::loadPath(Path* p) {
|
||||
ui->depSpin->setValue(p->getDepartement());
|
||||
loadImage(p->getImage());
|
||||
|
||||
|
||||
ui->dialogEdit->clear();
|
||||
|
||||
if(!steps.isEmpty()) {
|
||||
@ -162,36 +164,35 @@ void MainWindow::exportHTMLMap()
|
||||
}
|
||||
|
||||
void MainWindow::loadImage(QString fileName) {
|
||||
|
||||
QString ext[] = {"png", "jpeg", "jpg"};
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly | QFile::Text)) {
|
||||
QMessageBox::warning(this, "Warning", "Cannot open file: " +
|
||||
QMessageBox::warning(this, "Warning", "Cannot open image: " +
|
||||
file.errorString());
|
||||
return;
|
||||
}
|
||||
QString text = file.fileName();
|
||||
|
||||
bool acceptedExt = false;
|
||||
for(QString e : ext) {
|
||||
if(text.endsWith(e)) acceptedExt = true;
|
||||
}else{
|
||||
QString text = file.fileName();
|
||||
bool acceptedExt = false;
|
||||
for(QString e : ext) {
|
||||
if(text.endsWith(e)) acceptedExt = true;
|
||||
}
|
||||
if(!acceptedExt) {
|
||||
QMessageBox::warning(this, "Warning", "Format de fichier incorrect");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ui->imagePath->setText(text);
|
||||
|
||||
|
||||
QPixmap px(fileName);
|
||||
|
||||
ui->imageLbl->setPixmap(px);
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
if(!acceptedExt) {
|
||||
QMessageBox::warning(this, "Warning", "Format de fichier incorrect");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ui->imagePath->setText(text);
|
||||
|
||||
|
||||
QPixmap px(fileName);
|
||||
|
||||
ui->imageLbl->setPixmap(px);
|
||||
|
||||
file.close();
|
||||
|
||||
}
|
||||
|
||||
@ -259,7 +260,6 @@ void MainWindow::saveFile(){
|
||||
steps.append(stepObject);
|
||||
}
|
||||
json["steps"] = steps;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
file.write(doc.toJson());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user