You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
8 years ago
|
#include "importdialog.h"
|
||
|
#include "ui_importdialog.h"
|
||
|
|
||
|
#include <service.h>
|
||
|
#include <csvimporter.h>
|
||
|
#include <QDesktopWidget>
|
||
|
#include <QFileDialog>
|
||
|
|
||
|
#include "data/postdata.h"
|
||
|
#include "postregister-odb.hxx"
|
||
|
#include "importprogressform.h"
|
||
|
|
||
|
ImportDialog::ImportDialog(QWidget *parent) :
|
||
|
QDialog(parent),
|
||
|
ui(new Ui::ImportDialog)
|
||
|
{
|
||
|
ui->setupUi(this);
|
||
|
}
|
||
|
|
||
|
ImportDialog::~ImportDialog()
|
||
|
{
|
||
|
delete ui;
|
||
|
}
|
||
|
|
||
|
void ImportDialog::on_buttonBox_accepted()
|
||
|
{
|
||
|
QString fileName = ui->editFile->text();
|
||
|
Service<PostData> service;
|
||
|
PostData pd;
|
||
|
CsvImporter importer(pd.metaObject());
|
||
|
|
||
|
importer.setImportFile(fileName);
|
||
|
importer.setSeparator(ui->editSparator->text());
|
||
|
|
||
|
ImportProgressForm *progress = new ImportProgressForm();
|
||
|
progress->move(QApplication::desktop()->screen()->rect().center() - progress->rect().center());
|
||
|
progress->setWindowModality(Qt::ApplicationModal);
|
||
|
progress->show();
|
||
|
service.importData(&importer, progress);
|
||
|
}
|
||
|
|
||
|
void ImportDialog::on_btnFile_clicked()
|
||
|
{
|
||
|
QString file = QFileDialog::getOpenFileName(this, tr("Import file"), "", tr("All Files (*.*)"));
|
||
|
ui->editFile->setText(file);
|
||
|
}
|