mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-17 15:21:30 +02:00
MainWindow: improve tx history export error handling
This commit is contained in:
+19
-6
@@ -1711,13 +1711,26 @@ void MainWindow::onTxPoolBacklog(const QVector<quint64> &backlog, quint64 origin
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onExportHistoryCSV() {
|
void MainWindow::onExportHistoryCSV() {
|
||||||
QString fn = QFileDialog::getSaveFileName(this, "Save CSV file", QDir::homePath(), "CSV (*.csv)");
|
QString filePath = QFileDialog::getSaveFileName(this, "Save CSV file", QDir::homePath(), "CSV (*.csv)");
|
||||||
if (fn.isEmpty())
|
if (filePath.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (!fn.endsWith(".csv"))
|
if (!filePath.endsWith(".csv"))
|
||||||
fn += ".csv";
|
filePath += ".csv";
|
||||||
m_wallet->history()->writeCSV(fn);
|
QFileInfo fileInfo(filePath);
|
||||||
Utils::showInfo(this, "CSV export", QString("Transaction history exported to %1").arg(fn));
|
QDir dir = fileInfo.absoluteDir();
|
||||||
|
|
||||||
|
if (!dir.exists()) {
|
||||||
|
Utils::showError(this, "Unable to export transaction history", QString("Path does not exist: %1").arg(dir.absolutePath()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool success = m_wallet->history()->writeCSV(filePath);
|
||||||
|
if (!success) {
|
||||||
|
Utils::showError(this, "Unable to export transaction history", QString("No permission to write to: %1").arg(filePath));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::showInfo(this, "CSV export", QString("Transaction history exported to %1").arg(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onImportHistoryDescriptionsCSV() {
|
void MainWindow::onImportHistoryDescriptionsCSV() {
|
||||||
|
|||||||
@@ -400,9 +400,6 @@ bool TransactionHistory::writeCSV(const QString &path) {
|
|||||||
data += line;
|
data += line;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
data = QString("blockHeight,timestamp,date,accountIndex,direction,balanceDelta,amount,fee,txid,description,paymentId,fiatAmount,fiatCurrency%1").arg(data);
|
data = QString("blockHeight,timestamp,date,accountIndex,direction,balanceDelta,amount,fee,txid,description,paymentId,fiatAmount,fiatCurrency%1").arg(data);
|
||||||
return Utils::fileWrite(path, data);
|
return Utils::fileWrite(path, data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user