Skip to content

Commit

Permalink
Use QEFI function to parse name and path
Browse files Browse the repository at this point in the history
  • Loading branch information
Inokinoki committed Jul 4, 2021
1 parent 10649ab commit 26464f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
15 changes: 4 additions & 11 deletions qefientry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <QDebug>

#include <qefi.h>

QString QEFIEntry::name() const
{
return m_name;
Expand All @@ -25,17 +27,8 @@ QEFIEntry::QEFIEntry(quint16 id, QString name, QString devicePath)
QEFIEntry::QEFIEntry(quint16 id, QByteArray boot_data)
{
m_id = id;

QString entry_name;
if (boot_data.size() > 6) { // TODO: Explain the magic number
quint16 *c = (quint16 *)boot_data.data();
c = c + 6 / 2;
for (int index = 6; index < boot_data.size(); index += 2, c++) {
if (*c == 0) break;
entry_name.append(*c);
}
}
m_name = entry_name;
m_name = qefi_extract_name(boot_data);
m_devicePath = qefi_extract_path(boot_data);
}

QEFIEntry::QEFIEntry() {}
2 changes: 1 addition & 1 deletion qefientryrebootview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ QEFIEntryRebootView::QEFIEntryRebootView(QWidget *parent)
for (int i = 0; i < m_entryIds.size(); i++) {
QEFIEntry &entry = m_entryItems[m_entryIds[i]];
m_entries->addItem(QString::asprintf("[%04X] ", entry.id()) + entry.name()
+ (entry.devicePath().size() > 0 ? "\n" + entry.devicePath().size() : ""));
+ (entry.devicePath().size() > 0 ? "\n" + entry.devicePath() : ""));
}
QObject::connect(m_entries, &QListWidget::currentRowChanged,
this, &QEFIEntryRebootView::entryChanged);
Expand Down
5 changes: 3 additions & 2 deletions qefientryview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ QEFIEntryView::QEFIEntryView(QWidget *parent)
if (m_entryItems.contains(m_order[i])) {
QEFIEntry &entry = m_entryItems[m_order[i]];
m_entries->addItem(QString::asprintf("[%04X] ", entry.id()) + entry.name()
+ (entry.devicePath().size() > 0 ? "\n" + entry.devicePath().size() : ""));
+ (entry.devicePath().size() > 0 ? "\n" + entry.devicePath() : ""));
}
}
QObject::connect(m_entries, &QListWidget::currentRowChanged,
Expand Down Expand Up @@ -92,7 +92,8 @@ void QEFIEntryView::resetClicked(bool checked)
for (int i = 0; i < m_order.size(); i++) {
if (m_entryItems.contains(m_order[i])) {
QEFIEntry &entry = m_entryItems[m_order[i]];
m_entries->addItem(QString::asprintf("[%04X] ", entry.id()) + entry.name());
m_entries->addItem(QString::asprintf("[%04X] ", entry.id()) + entry.name()
+ (entry.devicePath().size() > 0 ? "\n" + entry.devicePath() : ""));
}
}
updateButtonState();
Expand Down

0 comments on commit 26464f7

Please sign in to comment.