mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 01:25:33 -07:00
Revert "Manager: Improve machine load times by caching details labels"
This reverts commit 9366ddd60d.
This commit is contained in:
@@ -263,8 +263,6 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig)
|
||||
// * First you clear it with VMManagerDetailSection::clear()
|
||||
// * Then you add each line with VMManagerDetailSection::addSection()
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
|
||||
// System
|
||||
systemSection->clear();
|
||||
systemSection->addSection("Machine", passed_sysconfig->getDisplayValue(VMManager::Display::Name::Machine));
|
||||
@@ -322,8 +320,6 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig)
|
||||
inputSection->setSections();
|
||||
portsSection->setSections();
|
||||
otherSection->setSections();
|
||||
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -39,10 +39,6 @@ VMManagerDetailSection::
|
||||
ui->setupUi(this);
|
||||
|
||||
frameGridLayout = new QGridLayout();
|
||||
frameGridLayout->setContentsMargins(getMargins(MarginSection::DisplayGrid));
|
||||
ui->detailFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
ui->detailFrame->setLayout(frameGridLayout);
|
||||
|
||||
// Create the collapse button, set the name and add it to the layout
|
||||
collapseButton = new CollapseButton();
|
||||
setSectionName(sectionName);
|
||||
@@ -132,8 +128,6 @@ VMManagerDetailSection::
|
||||
innerFrameLayout->addWidget(buttonWidget);
|
||||
innerFrameLayout->addWidget(frame);
|
||||
setLayout(outerFrameLayout);
|
||||
|
||||
usedRows = 0;
|
||||
}
|
||||
|
||||
VMManagerDetailSection::~VMManagerDetailSection()
|
||||
@@ -162,7 +156,6 @@ VMManagerDetailSection::setupMainLayout()
|
||||
delete mainLayout;
|
||||
mainLayout = new QVBoxLayout;
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetailSection::setSections()
|
||||
{
|
||||
@@ -179,71 +172,52 @@ VMManagerDetailSection::setSections()
|
||||
continue;
|
||||
}
|
||||
|
||||
auto item = frameGridLayout->itemAtPosition(row, 1);
|
||||
auto label = item ? ((QLabel *) item->widget()) : nullptr;
|
||||
if (label) {
|
||||
label->setVisible(true);
|
||||
} else {
|
||||
label = new QLabel();
|
||||
label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
label->setTextInteractionFlags(label->textInteractionFlags() | Qt::TextSelectableByMouse);
|
||||
frameGridLayout->addWidget(label, row, 1, Qt::AlignLeft);
|
||||
}
|
||||
label->setText(line);
|
||||
const auto labelValue = new QLabel();
|
||||
labelValue->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
labelValue->setTextInteractionFlags(labelValue->textInteractionFlags() | Qt::TextSelectableByMouse);
|
||||
labelValue->setText(line);
|
||||
frameGridLayout->addWidget(labelValue, row, 1, Qt::AlignLeft);
|
||||
|
||||
item = frameGridLayout->itemAtPosition(row, 0);
|
||||
if (!labelKey) {
|
||||
if (item)
|
||||
labelKey = (QLabel *) item->widget();
|
||||
if (labelKey) {
|
||||
labelKey->setVisible(true);
|
||||
} else {
|
||||
labelKey = new QLabel();
|
||||
labelKey->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
labelKey->setText(QCoreApplication::translate("", QString(section.name + ":").toUtf8().data()));
|
||||
frameGridLayout->addWidget(labelKey, row, 0, Qt::AlignLeft);
|
||||
}
|
||||
labelKey = new QLabel();
|
||||
labelKey->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
labelKey->setTextInteractionFlags(labelValue->textInteractionFlags());
|
||||
labelKey->setText(QCoreApplication::translate("", QString(section.name + ":").toUtf8().data()));
|
||||
} else if (item) {
|
||||
label = (QLabel *) item->widget();
|
||||
if (label)
|
||||
label->setVisible(false);
|
||||
}
|
||||
|
||||
item = frameGridLayout->itemAtPosition(row, 2);
|
||||
if (!item || !item->widget()) {
|
||||
const auto hSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
frameGridLayout->addItem(hSpacer, row, 2);
|
||||
frameGridLayout->addWidget(labelKey, row, 0, Qt::AlignLeft);
|
||||
}
|
||||
|
||||
const auto hSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
frameGridLayout->addItem(hSpacer, row, 2);
|
||||
empty = false;
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
||||
int prevUsedRows = usedRows;
|
||||
usedRows = row;
|
||||
for (; row < prevUsedRows; row++) {
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
auto item = frameGridLayout->itemAtPosition(row, i);
|
||||
if (item) {
|
||||
auto widget = item->widget();
|
||||
if (widget)
|
||||
widget->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
collapseButton->setContent(ui->detailFrame);
|
||||
if (!empty)
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetailSection::clear()
|
||||
{
|
||||
sections.clear();
|
||||
setVisible(false);
|
||||
|
||||
// Clear everything out
|
||||
if (frameGridLayout) {
|
||||
while (frameGridLayout->count()) {
|
||||
QLayoutItem *cur_item = frameGridLayout->takeAt(0);
|
||||
if (cur_item->widget())
|
||||
delete cur_item->widget();
|
||||
delete cur_item;
|
||||
}
|
||||
}
|
||||
|
||||
delete frameGridLayout;
|
||||
frameGridLayout = new QGridLayout();
|
||||
frameGridLayout->setContentsMargins(getMargins(MarginSection::DisplayGrid));
|
||||
ui->detailFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
ui->detailFrame->setLayout(frameGridLayout);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
||||
@@ -91,7 +91,6 @@ private:
|
||||
static QMargins getMargins(MarginSection section);
|
||||
|
||||
QString sectionName;
|
||||
int usedRows;
|
||||
|
||||
struct DetailSection {
|
||||
QString name;
|
||||
|
||||
Reference in New Issue
Block a user