export report as csv file implemented
This commit is contained in:
parent
e13339a432
commit
46aab9a836
5 changed files with 75 additions and 2 deletions
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
|
||||
ReportDialog::ReportDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
|
||||
{
|
||||
ui_.setupUi(this);
|
||||
|
@ -9,4 +12,21 @@ ReportDialog::ReportDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
|
|||
model_ = std::make_unique<ReportModel>(market_, ui_.reportView);
|
||||
ui_.reportView->setModel(model_.get());
|
||||
ui_.reportView->hideColumn(0);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -17,7 +17,10 @@ class ReportDialog : public QDialog
|
|||
ReportDialog(QWidget* parent = nullptr,
|
||||
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
||||
|
||||
private:
|
||||
private slots:
|
||||
void onExportCsvButtonClicked();
|
||||
|
||||
private:
|
||||
Ui::ReportDialog ui_;
|
||||
Marketplace* market_;
|
||||
std::unique_ptr<ReportModel> model_;
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="exportCsvButton">
|
||||
<property name="text">
|
||||
<string>Exportieren (.csv)</string>
|
||||
</property>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue