Load data
This commit is contained in:
parent
8fd2dc0df7
commit
37000d8281
@ -1,5 +1,6 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -56,13 +57,10 @@ void MainWindow::exportHTMLMap()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_pushButton_clicked()
|
void MainWindow::loadImage(QString fileName) {
|
||||||
{
|
|
||||||
|
|
||||||
QString ext[] = {"png", "jpeg", "jpg"};
|
QString ext[] = {"png", "jpeg", "jpg"};
|
||||||
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
|
|
||||||
if (fileName.isEmpty()) return;
|
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (!file.open(QIODevice::ReadOnly | QFile::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QFile::Text)) {
|
||||||
QMessageBox::warning(this, "Warning", "Cannot open file: " +
|
QMessageBox::warning(this, "Warning", "Cannot open file: " +
|
||||||
@ -91,7 +89,13 @@ void MainWindow::on_pushButton_clicked()
|
|||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_pushButton_clicked()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
|
||||||
|
if (fileName.isEmpty()) return;
|
||||||
|
this->loadImage(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -106,6 +110,25 @@ void MainWindow::on_actionOpen_triggered()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
Path* p = new Path(&file);
|
||||||
|
currentPath = p;
|
||||||
|
path.append(p);
|
||||||
|
|
||||||
|
ui->titleEdit->setText(p->getName());
|
||||||
|
ui->locEdit->setText(p->getCity());
|
||||||
|
ui->diffSpin->setValue(p->getDifficulty());
|
||||||
|
ui->lengthSpin->setValue(p->getLength());
|
||||||
|
ui->durationSpin->setValue(p->getDuration());
|
||||||
|
ui->imagePath->setText(p->getImage());
|
||||||
|
|
||||||
|
loadImage(p->getImage());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_toolButton_clicked()
|
||||||
|
{
|
||||||
|
QString fileName = ui->imagePath->text();
|
||||||
|
if(fileName.isEmpty()) return;
|
||||||
|
loadImage(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,11 +31,14 @@ private slots:
|
|||||||
|
|
||||||
void on_actionOpen_triggered();
|
void on_actionOpen_triggered();
|
||||||
|
|
||||||
|
void on_toolButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QString currentFile;
|
QString currentFile;
|
||||||
bool textChanged;
|
bool textChanged;
|
||||||
QList<Path*> path;
|
QList<Path*> path;
|
||||||
Path* currentPath;
|
Path* currentPath;
|
||||||
|
void loadImage(QString fileName);
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
<widget class="QLineEdit" name="titleEdit">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>60</x>
|
<x>60</x>
|
||||||
@ -101,7 +101,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
<widget class="QLineEdit" name="locEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="spinBox_2"/>
|
<widget class="QSpinBox" name="spinBox_2"/>
|
||||||
@ -148,7 +148,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="spinBox_3">
|
<widget class="QSpinBox" name="diffSpin">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string>/5</string>
|
<string>/5</string>
|
||||||
</property>
|
</property>
|
||||||
@ -171,7 +171,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
<widget class="QDoubleSpinBox" name="durationSpin">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string>h</string>
|
<string>h</string>
|
||||||
</property>
|
</property>
|
||||||
@ -197,7 +197,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_2">
|
<widget class="QDoubleSpinBox" name="lengthSpin">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string>Km</string>
|
<string>Km</string>
|
||||||
</property>
|
</property>
|
||||||
@ -243,6 +243,16 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="imagePath"/>
|
<widget class="QLineEdit" name="imagePath"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="toolButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::ListAdd"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="pushButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user