2018-07-30 09:50:54 +02:00
|
|
|
#include "reportdialog.h"
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2018-07-31 10:28:07 +02:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QSettings>
|
|
|
|
|
2018-07-30 09:50:54 +02:00
|
|
|
ReportDialog::ReportDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
|
|
|
|
{
|
|
|
|
ui_.setupUi(this);
|
|
|
|
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
|
|
|
model_ = std::make_unique<ReportModel>(market_, ui_.reportView);
|
|
|
|
ui_.reportView->setModel(model_.get());
|
|
|
|
ui_.reportView->hideColumn(0);
|
2018-07-31 10:28:07 +02:00
|
|
|
|
|
|
|
connect(ui_.exportCsvButton, &QPushButton::clicked, this, &ReportDialog::onExportCsvButtonClicked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDialog::onExportCsvButtonClicked()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
int feeInPercent = settings.value("global/feeInPercent").toInt();
|
|
|
|
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
|
|
|
|
|
|
|
QFileDialog fileDialog(this);
|
|
|
|
fileDialog.setFileMode(QFileDialog::AnyFile);
|
|
|
|
fileDialog.setNameFilter("CSV Files (*.csv)");
|
|
|
|
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
if (fileDialog.exec()) {
|
|
|
|
market_->exportReportToCSV(fileDialog.selectedFiles().at(0).toStdString(), feeInPercent, maxFeeInEuro);
|
|
|
|
}
|
2018-07-30 09:50:54 +02:00
|
|
|
}
|