Added --export-csv command line option.

This commit is contained in:
Leonardo Zide
2022-10-30 14:12:34 -07:00
parent 37dd02ee08
commit 3abe683d2b
5 changed files with 61 additions and 40 deletions
+7 -5
View File
@@ -1428,7 +1428,7 @@ bool Project::ExportCOLLADA(const QString& FileName)
return true;
}
void Project::ExportCSV()
bool Project::ExportCSV(const QString& FileName)
{
lcPartsList PartsList;
@@ -1438,13 +1438,13 @@ void Project::ExportCSV()
if (PartsList.empty())
{
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to export."));
return;
return false;
}
QString SaveFileName = GetExportFileName(QString(), "csv", tr("Export CSV"), tr("CSV Files (*.csv);;All Files (*.*)"));
QString SaveFileName = GetExportFileName(FileName, "csv", tr("Export CSV"), tr("CSV Files (*.csv);;All Files (*.*)"));
if (SaveFileName.isEmpty())
return;
return false;
lcDiskFile CSVFile(SaveFileName);
char Line[1024];
@@ -1452,7 +1452,7 @@ void Project::ExportCSV()
if (!CSVFile.Open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Could not open file '%1' for writing.").arg(SaveFileName));
return;
return false;
}
CSVFile.WriteLine("Part Name,Color,Quantity,Part ID,Color Code\n");
@@ -1467,6 +1467,8 @@ void Project::ExportCSV()
CSVFile.WriteLine(Line);
}
}
return true;
}
lcInstructions* Project::GetInstructions()