Skip to content

Commit

Permalink
Move CSV export code from ld-analyse/library into ld-export-metadata.
Browse files Browse the repository at this point in the history
Simon suggested that it'd be better to have this in the export tool.
  • Loading branch information
atsampson authored and Simon Inns committed Jan 6, 2020
1 parent 917c0f0 commit b6dc841
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 281 deletions.
13 changes: 0 additions & 13 deletions tools/ld-analyse/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void Configuration::writeConfiguration(void)
configuration->beginGroup("directories");
configuration->setValue("sourceDirectory", settings.directories.sourceDirectory);
configuration->setValue("pngDirectory", settings.directories.pngDirectory);
configuration->setValue("csvDirectory", settings.directories.csvDirectory);
configuration->endGroup();

// Windows
Expand Down Expand Up @@ -95,7 +94,6 @@ void Configuration::readConfiguration(void)
configuration->beginGroup("directories");
settings.directories.sourceDirectory = configuration->value("sourceDirectory").toString();
settings.directories.pngDirectory = configuration->value("pngDirectory").toString();
settings.directories.csvDirectory = configuration->value("csvDirectory").toString();
configuration->endGroup();

// Windows
Expand All @@ -119,7 +117,6 @@ void Configuration::setDefault(void)
// Directories
settings.directories.sourceDirectory = QDir::homePath();
settings.directories.pngDirectory = QDir::homePath();
settings.directories.csvDirectory = QDir::homePath();

// Windows
settings.windows.mainWindowGeometry = QByteArray();
Expand Down Expand Up @@ -158,16 +155,6 @@ QString Configuration::getPngDirectory(void)
return settings.directories.pngDirectory;
}

void Configuration::setCsvDirectory(QString csvDirectory)
{
settings.directories.csvDirectory = csvDirectory;
}

QString Configuration::getCsvDirectory(void)
{
return settings.directories.csvDirectory;
}

// Windows
void Configuration::setMainWindowGeometry(QByteArray mainWindowGeometry)
{
Expand Down
3 changes: 0 additions & 3 deletions tools/ld-analyse/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class Configuration : public QObject
QString getSourceDirectory(void);
void setPngDirectory(QString pngDirectory);
QString getPngDirectory(void);
void setCsvDirectory(QString csvDirectory);
QString getCsvDirectory(void);

// Get and set methods - windows
void setMainWindowGeometry(QByteArray mainWindowGeometry);
Expand Down Expand Up @@ -80,7 +78,6 @@ public slots:
struct Directories {
QString sourceDirectory; // Last used directory for .tbc files
QString pngDirectory; // Last used directory for .png files
QString csvDirectory; // Last used directory for .csv files
};

// Window geometry and settings
Expand Down
76 changes: 0 additions & 76 deletions tools/ld-analyse/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ void MainWindow::updateGuiLoaded()
ui->actionDropout_analysis->setEnabled(true);
ui->actionSNR_analysis->setEnabled(true);
ui->actionSave_frame_as_PNG->setEnabled(true);
ui->actionSave_metadata_as_CSV->setEnabled(true);
ui->actionSave_VBI_as_CSV->setEnabled(true);
ui->actionClosed_Captions->setEnabled(true);
if (tbcSource.getIsSourcePal()) ui->actionPAL_Chroma_decoder->setEnabled(true);
else ui->actionPAL_Chroma_decoder->setEnabled(false);
Expand Down Expand Up @@ -233,8 +231,6 @@ void MainWindow::updateGuiUnloaded()
ui->actionDropout_analysis->setEnabled(false);
ui->actionSNR_analysis->setEnabled(false);
ui->actionSave_frame_as_PNG->setEnabled(false);
ui->actionSave_metadata_as_CSV->setEnabled(false);
ui->actionSave_VBI_as_CSV->setEnabled(false);
ui->actionClosed_Captions->setEnabled(false);
ui->actionPAL_Chroma_decoder->setEnabled(false);

Expand Down Expand Up @@ -463,78 +459,6 @@ void MainWindow::on_actionSave_frame_as_PNG_triggered()
}
}

// Save the VITS metadata as a CSV file
void MainWindow::on_actionSave_metadata_as_CSV_triggered()
{
qDebug() << "MainWindow::on_actionSave_metadata_as_CSV_triggered(): Called";

// Create a suggestion for the filename
QString filenameSuggestion = configuration.getCsvDirectory() + tr("/");
filenameSuggestion += tbcSource.getCurrentSourceFilename() + tr("_vits.csv");

QString csvFilename = QFileDialog::getSaveFileName(this,
tr("Save CSV file"),
filenameSuggestion,
tr("CSV file (*.csv);;All Files (*)"));

// Was a filename specified?
if (!csvFilename.isEmpty() && !csvFilename.isNull()) {
// Save the metadata as CSV
qDebug() << "MainWindow::on_actionSave_metadata_as_CSV_triggered(): Saving VITS metadata as" << csvFilename;

if (tbcSource.saveVitsAsCsv(csvFilename)) {
// Update the configuration for the CSV directory
QFileInfo csvFileInfo(csvFilename);
configuration.setCsvDirectory(csvFileInfo.absolutePath());
qDebug() << "MainWindow::on_actionSave_metadata_as_CSV_triggered(): Setting CSV directory to:" << csvFileInfo.absolutePath();
configuration.writeConfiguration();
} else {
// Save as CSV failed
qDebug() << "MainWindow::on_actionSave_metadata_as_CSV_triggered(): Failed to save file as" << csvFilename;

QMessageBox messageBox;
messageBox.warning(this, "Warning", "Could not save VITS CSV file using the specified filename!");
messageBox.setFixedSize(500, 200);
}
}
}

// Save the VBI as a CSV file
void MainWindow::on_actionSave_VBI_as_CSV_triggered()
{
qDebug() << "MainWindow::on_actionSave_VBI_as_CSV_triggered(): Called";

// Create a suggestion for the filename
QString filenameSuggestion = configuration.getCsvDirectory() + tr("/");
filenameSuggestion += tbcSource.getCurrentSourceFilename() + tr("_vbi.csv");

QString csvFilename = QFileDialog::getSaveFileName(this,
tr("Save CSV file"),
filenameSuggestion,
tr("CSV file (*.csv);;All Files (*)"));

// Was a filename specified?
if (!csvFilename.isEmpty() && !csvFilename.isNull()) {
// Save the metadata as CSV
qDebug() << "MainWindow::on_actionSave_VBI_as_CSV_triggered(): Saving VBI as" << csvFilename;

if (tbcSource.saveVbiAsCsv(csvFilename)) {
// Update the configuration for the CSV directory
QFileInfo csvFileInfo(csvFilename);
configuration.setCsvDirectory(csvFileInfo.absolutePath());
qDebug() << "MainWindow::on_actionSave_VBI_as_CSV_triggered(): Setting CSV directory to:" << csvFileInfo.absolutePath();
configuration.writeConfiguration();
} else {
// Save as CSV failed
qDebug() << "MainWindow::on_actionSave_VBI_as_CSV_triggered(): Failed to save file as" << csvFilename;

QMessageBox messageBox;
messageBox.warning(this, "Warning","Could not save VBI CSV file using the specified filename!");
messageBox.setFixedSize(500, 200);
}
}
}

// Zoom in menu option
void MainWindow::on_actionZoom_In_triggered()
{
Expand Down
2 changes: 0 additions & 2 deletions tools/ld-analyse/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ private slots:
void on_actionDropout_analysis_triggered();
void on_actionSNR_analysis_triggered();
void on_actionSave_frame_as_PNG_triggered();
void on_actionSave_metadata_as_CSV_triggered();
void on_actionSave_VBI_as_CSV_triggered();
void on_actionZoom_In_triggered();
void on_actionZoom_Out_triggered();
void on_actionZoom_1x_triggered();
Expand Down
12 changes: 0 additions & 12 deletions tools/ld-analyse/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@
<addaction name="actionOpen_TBC_file"/>
<addaction name="separator"/>
<addaction name="actionSave_frame_as_PNG"/>
<addaction name="actionSave_metadata_as_CSV"/>
<addaction name="actionSave_VBI_as_CSV"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
Expand Down Expand Up @@ -537,11 +535,6 @@
<string>Ctrl+R</string>
</property>
</action>
<action name="actionSave_metadata_as_CSV">
<property name="text">
<string>Save VITS as CSV...</string>
</property>
</action>
<action name="actionZoom_In">
<property name="text">
<string>Zoom In</string>
Expand All @@ -568,11 +561,6 @@
<string>PAL Chroma decoder...</string>
</property>
</action>
<action name="actionSave_VBI_as_CSV">
<property name="text">
<string>Save VBI as CSV...</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
Expand Down
16 changes: 0 additions & 16 deletions tools/ld-analyse/tbcsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,22 +449,6 @@ qint32 TbcSource::getSecondFieldNumber(qint32 frameNumber)
return ldDecodeMetaData.getSecondFieldNumber(frameNumber);
}

// Save the VITS metadata as a CSV file
bool TbcSource::saveVitsAsCsv(QString filename)
{
if (!sourceReady) return 0;

return ldDecodeMetaData.writeVitsCsv(filename);
}

// Save the VBI as a CSV file
bool TbcSource::saveVbiAsCsv(QString filename)
{
if (!sourceReady) return 0;

return ldDecodeMetaData.writeVbiCsv(filename);
}

qint32 TbcSource::getCcData0(qint32 frameNumber)
{
if (!sourceReady) return false;
Expand Down
3 changes: 0 additions & 3 deletions tools/ld-analyse/tbcsource.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ class TbcSource : public QObject
qint32 getFirstFieldNumber(qint32 frameNumber);
qint32 getSecondFieldNumber(qint32 frameNumber);

bool saveVitsAsCsv(QString filename);
bool saveVbiAsCsv(QString filename);

qint32 getCcData0(qint32 frameNumber);
qint32 getCcData1(qint32 frameNumber);

Expand Down
Loading

0 comments on commit b6dc841

Please sign in to comment.