代码拉取完成,页面将自动刷新
同步操作将从 xiongqiumin/JZNodeEditor 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include <QTreeWidget>
#include <QComboBox>
#include "UiCommon.h"
#include "JZNodeObject.h"
bool UiHelper::treeFilter(QTreeWidgetItem *item, QString name)
{
bool show = false;
int count = item->childCount();
if (count == 0)
{
show = item->text(0).contains(name);
}
else
{
for (int i = 0; i < count; i++)
{
if (treeFilter(item->child(i), name))
show = true;
}
}
item->setHidden(!show);
return show;
}
void UiHelper::clearTreeItem(QTreeWidgetItem *root)
{
while (root->childCount() > 0)
delete root->takeChild(0);
}
void UiHelper::treeUpdate(QTreeWidgetItem *root, const QStringList &names, std::function<QTreeWidgetItem*(int)> func)
{
auto indexOfItem = [](QTreeWidgetItem *node,const QString &name)->int{
for (int i = 0; i < node->childCount(); i++)
{
auto sub = node->child(i);
if (sub->text(0) == name)
return i;
}
return -1;
};
for (int i = root->childCount() - 1; i >= 0; i--)
{
if (!names.contains(root->child(0)->text(0)))
delete root->takeChild(i);
}
for (int i = 0; i < names.count(); i++)
{
QTreeWidgetItem *item = nullptr;
int cur_index = indexOfItem(root, names[i]);
if (cur_index >= 0)
{
item = root->child(cur_index);
if (cur_index != i)
{
root->takeChild(cur_index);
root->insertChild(i, item);
}
}
else
{
item = func(i);
root->addChild(item);
}
}
}
void UiHelper::updateEnumBox(QComboBox *box, int dataType, int value)
{
box->blockSignals(true);
auto meta = JZNodeObjectManager::instance()->enumMeta(dataType);
for (int i = 0; i < meta->count(); i++)
box->addItem(meta->key(i), meta->value(i));
if (value != 0xfafa)
{
int index = box->findData(value);
box->setCurrentIndex(index);
}
box->blockSignals(false);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。