Skip to content

Commit e51aa2e

Browse files
committed
Add GUID display format
Add a display format to convert binary GUIDs to their text representation. See issue #2342.
1 parent 4c4e55f commit e51aa2e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/ColumnDisplayFormatDialog.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ ColumnDisplayFormatDialog::ColumnDisplayFormatDialog(DBBrowserDB& db, const sqlb
3434
ui->comboDisplayFormat->addItem(tr("Lower case"), "lower");
3535
ui->comboDisplayFormat->addItem(tr("Upper case"), "upper");
3636
ui->comboDisplayFormat->insertSeparator(ui->comboDisplayFormat->count());
37+
ui->comboDisplayFormat->addItem(tr("Binary GUID to text"), "guid");
38+
ui->comboDisplayFormat->insertSeparator(ui->comboDisplayFormat->count());
3739
ui->comboDisplayFormat->addItem(tr("Custom"), "custom");
3840

3941
ui->labelDisplayFormat->setText(ui->labelDisplayFormat->text().arg(column_name));
@@ -54,6 +56,16 @@ ColumnDisplayFormatDialog::ColumnDisplayFormatDialog(DBBrowserDB& db, const sqlb
5456
formatFunctions["ddmmyyyyDate"] = "strftime('%d/%m/%Y', " + sqlb::escapeIdentifier(column_name) + ")";
5557
formatFunctions["lower"] = "lower(" + sqlb::escapeIdentifier(column_name) + ")";
5658
formatFunctions["upper"] = "upper(" + sqlb::escapeIdentifier(column_name) + ")";
59+
formatFunctions["guid"] = "substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 7, 2) || " +
60+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 5, 2) || " +
61+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 3, 2) || " +
62+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 1, 2) || '-' || " +
63+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 11, 2) || " +
64+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 9, 2) || '-' || " +
65+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 15, 2) || " +
66+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 13, 2) || '-' || " +
67+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 17, 4) || '-' || " +
68+
"substr(hex(" + sqlb::escapeIdentifier(column_name) + "), 21, 12)";
5769

5870
// Set the current format, if it's empty set the default format
5971
if(current_format.isEmpty())

0 commit comments

Comments
 (0)