return QString();
}
+const QString Row::class_name() const
+{
+ if (row_ && row_->desc)
+ return QString::fromUtf8(row_->desc);
+ return QString();
+}
+
int Row::index() const
{
return index_;
const srd_decoder_annotation_row* row() const;
const QString title() const;
+ const QString class_name() const;
int index() const;
bool operator<(const Row &other) const;
return form;
}
-QWidget *Settings::get_decoder_settings_form(QWidget *parent) const
+QWidget *Settings::get_decoder_settings_form(QWidget *parent)
{
#ifdef ENABLE_DECODE
+ GlobalSettings settings;
QCheckBox *cb;
QWidget *form = new QWidget(parent);
SLOT(on_dec_initialStateConfigurable_changed(int)));
decoder_layout->addRow(tr("Allow configuration of &initial signal state"), cb);
+ // Annotation export settings
+ ann_export_format_ = new QLineEdit();
+ ann_export_format_->setText(
+ settings.value(GlobalSettings::Key_Dec_ExportFormat).toString());
+ connect(ann_export_format_, SIGNAL(textChanged(const QString&)),
+ this, SLOT(on_dec_exportFormat_changed(const QString&)));
+ decoder_layout->addRow(tr("Annotation export format"), ann_export_format_);
+ QLabel *description_1 = new QLabel(tr("%s = sample range; %d: decoder name; %c: row name; %q: use quotes for ann text"));
+ description_1->setAlignment(Qt::AlignRight);
+ decoder_layout->addRow(description_1);
+ QLabel *description_2 = new QLabel(tr("%1: longest annotation text; %a: all annotation texts"));
+ description_2->setAlignment(Qt::AlignRight);
+ decoder_layout->addRow(description_2);
+
return form;
#else
(void)parent;
settings.setValue(GlobalSettings::Key_View_DefaultLogicHeight, value);
}
+#ifdef ENABLE_DECODE
void Settings::on_dec_initialStateConfigurable_changed(int state)
{
GlobalSettings settings;
settings.setValue(GlobalSettings::Key_Dec_InitialStateConfigurable, state ? true : false);
}
+void Settings::on_dec_exportFormat_changed(const QString &text)
+{
+ GlobalSettings settings;
+ settings.setValue(GlobalSettings::Key_Dec_ExportFormat, text);
+}
+#endif
+
void Settings::on_log_logLevel_changed(int value)
{
logging.set_log_level(value);
#include <QListWidget>
#include <QPlainTextEdit>
#include <QStackedWidget>
+#include <QLineEdit>
namespace pv {
QPlainTextEdit *create_log_view() const;
QWidget *get_view_settings_form(QWidget *parent) const;
- QWidget *get_decoder_settings_form(QWidget *parent) const;
+ QWidget *get_decoder_settings_form(QWidget *parent);
QWidget *get_about_page(QWidget *parent) const;
QWidget *get_logging_page(QWidget *parent) const;
void on_view_conversionThresholdDispMode_changed(int state);
void on_view_defaultDivHeight_changed(int value);
void on_view_defaultLogicHeight_changed(int value);
+#ifdef ENABLE_DECODE
void on_dec_initialStateConfigurable_changed(int state);
+ void on_dec_exportFormat_changed(const QString &text);
+#endif
void on_log_logLevel_changed(int value);
void on_log_bufferSize_changed(int value);
void on_log_saveToFile_clicked(bool checked);
PageListWidget *page_list;
QStackedWidget *pages;
+#ifdef ENABLE_DECODE
+ QLineEdit *ann_export_format_;
+#endif
+
QPlainTextEdit *log_view_;
};
const QString GlobalSettings::Key_View_DefaultLogicHeight = "View_DefaultLogicHeight";
const QString GlobalSettings::Key_View_ShowHoverMarker = "View_ShowHoverMarker";
const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable";
+const QString GlobalSettings::Key_Dec_ExportFormat = "Dec_ExportFormat";
const QString GlobalSettings::Key_Log_BufferSize = "Log_BufferSize";
const QString GlobalSettings::Key_Log_NotifyOfStacktrace = "Log_NotifyOfStacktrace";
setValue(Key_View_DefaultLogicHeight,
2 * QFontMetrics(QApplication::font()).height());
+ if (!contains(Key_Dec_ExportFormat))
+ setValue(Key_Dec_ExportFormat, "%s %d: %c: %1");
+
// Default to 500 lines of backlog
if (!contains(Key_Log_BufferSize))
setValue(Key_Log_BufferSize, 500);
static const QString Key_View_DefaultLogicHeight;
static const QString Key_View_ShowHoverMarker;
static const QString Key_Dec_InitialStateConfigurable;
+ static const QString Key_Dec_ExportFormat;
static const QString Key_Log_BufferSize;
static const QString Key_Log_NotifyOfStacktrace;
if (annotations.empty())
return;
- QSettings settings;
- const QString dir = settings.value(SettingSaveDirectory).toString();
+ GlobalSettings settings;
+ const QString dir = settings.value("MainWindow/SaveDirectory").toString();
const QString file_name = QFileDialog::getSaveFileName(
owner_->view(), tr("Export annotations"), dir, tr("Text Files (*.txt);;All Files (*)"));
if (file_name.isEmpty())
return;
+ const QString format = settings.value(GlobalSettings::Key_Dec_ExportFormat).toString();
+ const QString quote = format.contains("%q") ? "\"" : "";
+ const QString class_name = selected_row_->class_name();
+
QFile file(file_name);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
QTextStream out_stream(&file);
- for (Annotation &ann : annotations)
- out_stream << ann.annotations().front() << '\n';
+ for (Annotation &ann : annotations) {
+ const QString sample_range = QString("%1-%2").arg(ann.start_sample()).arg(
+ ann.end_sample());
+
+ QString all_ann_text;
+ for (const QString &s : ann.annotations())
+ all_ann_text = all_ann_text + quote + s + quote + ",";
+ all_ann_text.chop(1);
+
+ const QString first_ann_text = quote + ann.annotations().front() + quote;
+
+ QString out_text = format;
+ out_text = out_text.replace("%s", sample_range);
+ out_text = out_text.replace("%d", decode_signal_->name());
+ out_text = out_text.replace("%c", class_name);
+ out_text = out_text.replace("%1", first_ann_text);
+ out_text = out_text.replace("%a", all_ann_text);
+ out_stream << out_text << '\n';
+ }
if (out_stream.status() == QTextStream::Ok)
return;