Skip to content

Commit

Permalink
updated column handling
Browse files Browse the repository at this point in the history
  • Loading branch information
r3yc0n1c committed Mar 28, 2024
1 parent d8fc874 commit abb43ca
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
77 changes: 39 additions & 38 deletions src/dialogs/VersionInfoDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ VersionInfoDialog::~VersionInfoDialog() {}

void VersionInfoDialog::CopyTreeWidgetSelection(QTreeWidget *t)
{
const int keyColumnIndex = 0, valueColumnIndex = 1;
QString vinfo, row;

QTreeWidgetItemIterator it(t);

while (*it) {
if ((*it)->isSelected()) {
row = (*it)->text(keyColumnIndex) + " = " + (*it)->text(valueColumnIndex) + "\n";
row = (*it)->text(KeyColumn) + " " + (*it)->text(ValueColumn) + "\n";
vinfo.append(row);
}
it++;
Expand Down Expand Up @@ -104,17 +103,17 @@ void VersionInfoDialog::fillVersionInfo()

// Left tree
QTreeWidgetItem *addrItemL = new QTreeWidgetItem();
addrItemL->setText(0, "Address:");
addrItemL->setText(1, RzAddressString(sdb_num_get(sdb, "addr", 0)));
addrItemL->setText(KeyColumn, "Address:");
addrItemL->setText(ValueColumn, RzAddressString(sdb_num_get(sdb, "addr", 0)));
ui->leftTreeWidget->addTopLevelItem(addrItemL);

QTreeWidgetItem *offItemL = new QTreeWidgetItem();
offItemL->setText(0, "Offset:");
offItemL->setText(1, RzAddressString(sdb_num_get(sdb, "offset", 0)));
offItemL->setText(KeyColumn, "Offset:");
offItemL->setText(ValueColumn, RzAddressString(sdb_num_get(sdb, "offset", 0)));
ui->leftTreeWidget->addTopLevelItem(offItemL);

QTreeWidgetItem *entriesItemL = new QTreeWidgetItem();
entriesItemL->setText(0, "Entries:");
entriesItemL->setText(KeyColumn, "Entries:");
const ut64 num_entries = sdb_num_get(sdb, "num_entries", 0);
for (size_t i = 0; i < num_entries; ++i) {
auto key = QString("entry%0").arg(i);
Expand All @@ -123,8 +122,8 @@ void VersionInfoDialog::fillVersionInfo()
continue;
}
auto item = new QTreeWidgetItem();
item->setText(0, RzAddressString(i));
item->setText(1, value);
item->setText(KeyColumn, RzAddressString(i));
item->setText(ValueColumn, value);
entriesItemL->addChild(item);
}
ui->leftTreeWidget->addTopLevelItem(entriesItemL);
Expand All @@ -135,17 +134,17 @@ void VersionInfoDialog::fillVersionInfo()

// Right tree
QTreeWidgetItem *addrItemR = new QTreeWidgetItem();
addrItemR->setText(0, "Address:");
addrItemR->setText(1, RzAddressString(sdb_num_get(sdb, "addr", 0)));
addrItemR->setText(KeyColumn, "Address:");
addrItemR->setText(ValueColumn, RzAddressString(sdb_num_get(sdb, "addr", 0)));
ui->rightTreeWidget->addTopLevelItem(addrItemR);

QTreeWidgetItem *offItemR = new QTreeWidgetItem();
offItemR->setText(0, "Offset:");
offItemR->setText(1, RzAddressString(sdb_num_get(sdb, "offset", 0)));
offItemR->setText(KeyColumn, "Offset:");
offItemR->setText(ValueColumn, RzAddressString(sdb_num_get(sdb, "offset", 0)));
ui->rightTreeWidget->addTopLevelItem(offItemR);

QTreeWidgetItem *entriesItemR = new QTreeWidgetItem();
entriesItemR->setText(0, "Entries:");
entriesItemR->setText(KeyColumn, "Entries:");
for (size_t num_version = 0;; num_version++) {
auto path_version =
QString("bin/cur/info/versioninfo/verneed/version%0").arg(num_version);
Expand All @@ -155,8 +154,8 @@ void VersionInfoDialog::fillVersionInfo()
}
const char *filename = sdb_const_get(sdb, "file_name", 0);
auto *parentItem = new QTreeWidgetItem();
parentItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx", 0)));
parentItem->setText(1,
parentItem->setText(KeyColumn, RzAddressString(sdb_num_get(sdb, "idx", 0)));
parentItem->setText(ValueColumn,
QString("Version: %0\t"
"File: %1")
.arg(QString::number(sdb_num_get(sdb, "vn_version", 0)),
Expand All @@ -172,14 +171,14 @@ void VersionInfoDialog::fillVersionInfo()
}

auto *childItem = new QTreeWidgetItem();
childItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx", 0)));
childItem->setText(KeyColumn, RzAddressString(sdb_num_get(sdb, "idx", 0)));
QString childString =
QString("Name: %0\t"
"Flags: %1\t"
"Version: %2\t")
.arg(sdb_const_get(sdb, "name", 0), sdb_const_get(sdb, "flags", 0),
QString::number(sdb_num_get(sdb, "version", 0)));
childItem->setText(1, childString);
childItem->setText(ValueColumn, childString);
parentItem->addChild(childItem);
}
entriesItemR->addChild(parentItem);
Expand Down Expand Up @@ -219,48 +218,48 @@ void VersionInfoDialog::fillVersionInfo()
.arg(product_version_ls & 0xFFFF);

auto item = new QTreeWidgetItem();
item->setText(0, "Signature");
item->setText(1, RzHexString(sdb_num_get(sdb, "Signature", 0)));
item->setText(KeyColumn, "Signature");
item->setText(ValueColumn, RzHexString(sdb_num_get(sdb, "Signature", 0)));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "StrucVersion");
item->setText(1, RzHexString(sdb_num_get(sdb, "StrucVersion", 0)));
item->setText(KeyColumn, "StrucVersion");
item->setText(ValueColumn, RzHexString(sdb_num_get(sdb, "StrucVersion", 0)));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileVersion");
item->setText(1, file_version);
item->setText(KeyColumn, "FileVersion");
item->setText(ValueColumn, file_version);
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "ProductVersion");
item->setText(1, product_version);
item->setText(KeyColumn, "ProductVersion");
item->setText(ValueColumn, product_version);
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileFlagsMask");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlagsMask", 0)));
item->setText(KeyColumn, "FileFlagsMask");
item->setText(ValueColumn, RzHexString(sdb_num_get(sdb, "FileFlagsMask", 0)));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileFlags");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlags", 0)));
item->setText(KeyColumn, "FileFlags");
item->setText(ValueColumn, RzHexString(sdb_num_get(sdb, "FileFlags", 0)));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileOS");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileOS", 0)));
item->setText(KeyColumn, "FileOS");
item->setText(ValueColumn, RzHexString(sdb_num_get(sdb, "FileOS", 0)));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileType");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileType", 0)));
item->setText(KeyColumn, "FileType");
item->setText(ValueColumn, RzHexString(sdb_num_get(sdb, "FileType", 0)));
ui->leftTreeWidget->addTopLevelItem(item);

item = new QTreeWidgetItem();
item->setText(0, "FileSubType");
item->setText(1, RzHexString(sdb_num_get(sdb, "FileSubType", 0)));
item->setText(KeyColumn, "FileSubType");
item->setText(ValueColumn, RzHexString(sdb_num_get(sdb, "FileSubType", 0)));
ui->leftTreeWidget->addTopLevelItem(item);

// Adjust columns to content
Expand All @@ -286,8 +285,10 @@ void VersionInfoDialog::fillVersionInfo()
ut8 *key_utf16 = sdb_decode(sdb_const_get(sdb, "key", 0), &lenkey);
ut8 *val_utf16 = sdb_decode(sdb_const_get(sdb, "value", 0), &lenval);
item = new QTreeWidgetItem();
item->setText(0, QString::fromUtf16(reinterpret_cast<const ushort *>(key_utf16)));
item->setText(1, QString::fromUtf16(reinterpret_cast<const ushort *>(val_utf16)));
item->setText(KeyColumn,
QString::fromUtf16(reinterpret_cast<const ushort *>(key_utf16)));
item->setText(ValueColumn,
QString::fromUtf16(reinterpret_cast<const ushort *>(val_utf16)));
ui->rightTreeWidget->addTopLevelItem(item);
free(key_utf16);
free(val_utf16);
Expand Down
2 changes: 2 additions & 0 deletions src/dialogs/VersionInfoDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class VersionInfoDialog : public QDialog
explicit VersionInfoDialog(QWidget *parent = nullptr);
~VersionInfoDialog();

enum Column { KeyColumn = 0, ValueColumn = 1 };

private slots:
void CopyTreeWidgetSelection(QTreeWidget *t);

Expand Down

0 comments on commit abb43ca

Please sign in to comment.