update
This commit is contained in:
parent
29a4b4dad4
commit
b15d0bf643
|
@ -1,8 +1,13 @@
|
|||
#include "EntityDocks.h"
|
||||
#include <stdexcept>
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
|
||||
QMutex DeduceFramework::_static_mutex;
|
||||
QList<std::shared_ptr<WsMessage>> deduct_each(std::shared_ptr<WsEntity> item)
|
||||
{
|
||||
QMutexLocker loc(&DeduceFramework::_static_mutex);
|
||||
|
||||
QList<std::shared_ptr<WsMessage>> rets;
|
||||
auto immediate = std::make_shared<ImmediateKernel>(item);
|
||||
|
||||
|
@ -20,6 +25,7 @@ QList<std::shared_ptr<WsMessage>> deduct_each(std::shared_ptr<WsEntity> item)
|
|||
QList<std::shared_ptr<WsMessage>> DeduceFramework::_accept_stack;
|
||||
void DeduceFramework::accept(const QList<std::shared_ptr<WsMessage>>& set)
|
||||
{
|
||||
QMutexLocker loc(&DeduceFramework::_static_mutex);
|
||||
_accept_stack.append(set);
|
||||
}
|
||||
|
||||
|
@ -29,9 +35,13 @@ void DeduceFramework::deduceBegin(std::shared_ptr<const DeduceRequest> ins)
|
|||
{
|
||||
auto dt = QTime::currentTime();
|
||||
|
||||
auto ret_list_set = QtConcurrent::blockingMapped(
|
||||
_entity_map_over_0xffff.values(), deduct_each
|
||||
);
|
||||
DeduceFramework::_static_mutex.lock();
|
||||
auto items = _entity_map_over_0xffff.values();
|
||||
for(auto item : _templets_within_0x2ff_0xffff.values())
|
||||
items.append(item);
|
||||
DeduceFramework::_static_mutex.unlock();
|
||||
|
||||
auto ret_list_set = QtConcurrent::blockingMapped(items, deduct_each);
|
||||
|
||||
_accept_stack.clear();
|
||||
for (auto vlist : ret_list_set)
|
||||
|
@ -182,17 +192,17 @@ void DeduceFramework::execute(std::shared_ptr<Immediate> map,
|
|||
case EntityOperateType::NEW: {
|
||||
nins->_success_mark = true;
|
||||
auto ent_t = std::make_shared<RtWsEntity>();
|
||||
ent_t->resetID(0x2ff);
|
||||
ent_t->resetTemplet(in->_template_name);
|
||||
|
||||
auto desc_p = std::make_shared<ComponentsInfoPull>();
|
||||
ent_t->append(desc_p);
|
||||
|
||||
// 提取所有的模板id
|
||||
auto _tm_ins = _templets_within_0x2ff_0xffff.values();
|
||||
QList<uint64_t> allids;
|
||||
std::transform(_templets_within_0x2ff_0xffff.begin(),
|
||||
_templets_within_0x2ff_0xffff.end(),
|
||||
std::back_inserter(allids),
|
||||
[](std::shared_ptr<RtWsEntity> i) { return i->entityID(); });
|
||||
std::transform(_templets_within_0x2ff_0xffff.begin(), _templets_within_0x2ff_0xffff.end(),
|
||||
std::back_inserter(allids), [](std::shared_ptr<RtWsEntity> i) { return i->entityID(); });
|
||||
|
||||
// 重置模板id
|
||||
while (allids.contains(ent_t->entityID())) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "componentbasic.h"
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QMutex>
|
||||
|
||||
class COMPONENTBASIC_EXPORT ComponentFactory : public Serializable {
|
||||
private:
|
||||
|
@ -62,6 +63,7 @@ public slots:
|
|||
void deduceBegin(std::shared_ptr<const DeduceRequest> ins);
|
||||
|
||||
public:
|
||||
static QMutex _static_mutex;
|
||||
static QList<std::shared_ptr<WsMessage>> _accept_stack;
|
||||
|
||||
DeduceFramework();
|
||||
|
|
|
@ -31,6 +31,9 @@ void ComponentsInfoPull::execute(std::shared_ptr<Immediate> map,
|
|||
|
||||
auto array = QJsonArray();
|
||||
for (auto ins : comp_list) {
|
||||
if(ins->name() == this->name())
|
||||
continue;
|
||||
|
||||
auto info_comp = QJsonObject();
|
||||
info_comp["component_type"] = ins->name();
|
||||
ins->saveTo(info_comp);
|
||||
|
|
|
@ -5,14 +5,99 @@
|
|||
#include <QSplitter>
|
||||
#include <QLabel>
|
||||
#include <QGroupBox>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
void TempletAssemble::deduce_start()
|
||||
{
|
||||
auto request = std::make_shared<DeduceRequest>();
|
||||
request->reset(-1, RtEntityManager::const_id);
|
||||
emit this->backend_deduce_request(request);
|
||||
}
|
||||
|
||||
#include <QJsonArray>
|
||||
void TempletAssemble::reply_accept(const QList<std::shared_ptr<WsMessage>>& msg_set)
|
||||
{
|
||||
for (auto msg : msg_set) {
|
||||
if (msg->topicString() == TypesQueryResult().topicString()) {
|
||||
_templet_model->clear();
|
||||
_component_types->clear();
|
||||
_right_widget->setEnabled(false);
|
||||
|
||||
auto conv = std::static_pointer_cast<TypesQueryResult>(msg);
|
||||
this->_component_types->addItems(conv->_component_types);
|
||||
for (auto info : conv->_entity_templets.keys()) {
|
||||
auto templat_id = conv->_entity_templets[info];
|
||||
if ((QList<uint64_t>{RtEntityManager::const_id}).contains(templat_id))
|
||||
continue;
|
||||
|
||||
auto cell = new QStandardItem(info);
|
||||
cell->setData(templat_id);
|
||||
cell->setEditable(false);
|
||||
_templet_model->appendRow(cell);
|
||||
}
|
||||
}
|
||||
if (msg->topicString() == ComponentDatasQueryResult().topicString()) {
|
||||
this->_right_widget->setEnabled(true);
|
||||
auto conv = std::dynamic_pointer_cast<ComponentDatasQueryResult>(msg);
|
||||
|
||||
auto name = conv->_entity_json["entity_templet"].toString();
|
||||
_templet_name->setText(name);
|
||||
this->_component_model->clear();
|
||||
|
||||
auto json_array = conv->_entity_json["component_list"].toArray();
|
||||
for (auto idx = 0; idx < json_array.count(); ++idx) {
|
||||
auto obj = json_array.at(idx).toObject();
|
||||
auto comp_name = obj["component_type"].toString();
|
||||
|
||||
auto row = new QStandardItem(comp_name);
|
||||
this->_component_model->appendRow(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TempletAssemble::complete_accept(std::shared_ptr<RespondDefault> ins) {}
|
||||
|
||||
void TempletAssemble::show_templet_content(const QModelIndex& target)
|
||||
{
|
||||
if (!target.isValid())
|
||||
return;
|
||||
|
||||
auto item = this->_templet_model->itemFromIndex(target);
|
||||
auto template_id = item->data().toULongLong();
|
||||
auto req = std::make_shared<ComponentDatasQuery>();
|
||||
req->reset(-1, template_id);
|
||||
this->_bind_framework->accept(QList<std::shared_ptr<WsMessage>>{req});
|
||||
}
|
||||
|
||||
#include <QInputDialog>
|
||||
void TempletAssemble::append_templet()
|
||||
{
|
||||
auto value = QInputDialog::getText(this, u8"ÊäÈëÄ£°åÀàÐÍ", u8"Ãû³Æ");
|
||||
if (value.isEmpty())
|
||||
return;
|
||||
|
||||
auto app = std::make_shared<TempletOperate>();
|
||||
app->reset(-1, RtEntityManager::const_id);
|
||||
app->_operate_code = (int)EntityOperateType::NEW;
|
||||
app->_template_name = value;
|
||||
|
||||
auto query = std::make_shared<TypesQuery>();
|
||||
query->reset(-1, RtEntityManager::const_id);
|
||||
|
||||
_bind_framework->accept(QList<std::shared_ptr<WsMessage>>() << app << query);
|
||||
}
|
||||
|
||||
TempletAssemble::TempletAssemble(std::shared_ptr<DeduceFramework> fmk, QWidget* parent)
|
||||
:QDialog(parent),
|
||||
_bind_framework(fmk),
|
||||
_bind_timer(new QTimer(this)),
|
||||
_templet_present(new QListView(this)),
|
||||
_templet_model(new QStandardItemModel(this)),
|
||||
_t_add(new QPushButton(u8"添加模板", this)),
|
||||
_t_remove(new QPushButton(u8"移除模板", this)),
|
||||
_right_widget(new QWidget(this)),
|
||||
_templet_name(new QLineEdit(this)),
|
||||
_component_types(new QComboBox(this)),
|
||||
_comp_add(new QPushButton(u8"添加组件", this)),
|
||||
|
@ -21,6 +106,12 @@ TempletAssemble::TempletAssemble(std::shared_ptr<DeduceFramework> fmk, QWidget *
|
|||
_component_model(new QStandardItemModel(this)),
|
||||
_apply(new QPushButton(u8"应用", this))
|
||||
{
|
||||
connect(this, &TempletAssemble::backend_deduce_request, _bind_framework.get(), &DeduceFramework::deduceBegin);
|
||||
connect(_bind_framework.get(), &DeduceFramework::reply, this, &TempletAssemble::reply_accept);
|
||||
connect(_templet_present, &QListView::clicked, this, &TempletAssemble::show_templet_content);
|
||||
connect(_t_add, &QPushButton::clicked, this, &TempletAssemble::append_templet);
|
||||
|
||||
|
||||
setWindowTitle(u8"类型模板配置");
|
||||
this->setMinimumSize(800, 600);
|
||||
|
||||
|
@ -32,13 +123,13 @@ TempletAssemble::TempletAssemble(std::shared_ptr<DeduceFramework> fmk, QWidget *
|
|||
split->addWidget(left_widget);
|
||||
auto llayout = new QGridLayout(left_widget);
|
||||
llayout->addWidget(_templet_present, 0, 0, 3, 2);
|
||||
_templet_present->setModel(_templet_model);
|
||||
llayout->addWidget(_t_add, 3, 0);
|
||||
llayout->addWidget(_t_remove, 3, 1);
|
||||
|
||||
|
||||
auto right_widget = new QWidget(this);
|
||||
split->addWidget(right_widget);
|
||||
auto rlayout = new QGridLayout(right_widget);
|
||||
split->addWidget(_right_widget);
|
||||
auto rlayout = new QGridLayout(_right_widget);
|
||||
rlayout->addWidget(new QLabel(u8"模板名称", this), 0, 0);
|
||||
rlayout->addWidget(_templet_name, 0, 1, 1, 4);
|
||||
rlayout->addWidget(new QLabel(u8"组件类型", this), 1, 0);
|
||||
|
@ -46,8 +137,16 @@ TempletAssemble::TempletAssemble(std::shared_ptr<DeduceFramework> fmk, QWidget *
|
|||
rlayout->addWidget(_comp_add, 1, 3);
|
||||
rlayout->addWidget(_comp_remove, 1, 4);
|
||||
rlayout->addWidget(_component_present, 2, 0, 3, 5);
|
||||
_component_present->setModel(_component_model);
|
||||
rlayout->addWidget(_apply, 5, 0, 1, 5);
|
||||
|
||||
rlayout->setColumnStretch(1, 1);
|
||||
split->setStretchFactor(1, 1);
|
||||
|
||||
auto ins = std::make_shared<TypesQuery>();
|
||||
ins->reset(-1, RtEntityManager::const_id);
|
||||
_bind_framework->accept(QList<std::shared_ptr<WsMessage>>{ins});
|
||||
|
||||
connect(this->_bind_timer, &QTimer::timeout, this, &TempletAssemble::deduce_start);
|
||||
this->_bind_timer->start(100);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QStandardItemModel>
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#include <EntityDocks.h>
|
||||
|
||||
class TempletAssemble : public QDialog
|
||||
|
@ -11,11 +12,13 @@ class TempletAssemble : public QDialog
|
|||
Q_OBJECT
|
||||
private:
|
||||
std::shared_ptr<DeduceFramework> _bind_framework;
|
||||
QTimer *const _bind_timer;
|
||||
|
||||
QListView *const _templet_present;
|
||||
QStandardItemModel *const _templet_model;
|
||||
QPushButton *const _t_add, *const _t_remove;
|
||||
|
||||
QWidget *const _right_widget;
|
||||
QLineEdit *const _templet_name;
|
||||
QComboBox *const _component_types;
|
||||
QPushButton *const _comp_add, *const _comp_remove;
|
||||
|
@ -23,10 +26,19 @@ private:
|
|||
QStandardItemModel *const _component_model;
|
||||
QPushButton *const _apply;
|
||||
|
||||
void deduce_start();
|
||||
void reply_accept(const QList<std::shared_ptr<WsMessage>>& set);
|
||||
void complete_accept(std::shared_ptr<RespondDefault> ins);
|
||||
|
||||
void show_templet_content(const QModelIndex& target);
|
||||
|
||||
void append_templet();
|
||||
|
||||
public:
|
||||
TempletAssemble(std::shared_ptr<DeduceFramework> fmk, QWidget *p = nullptr);
|
||||
virtual ~TempletAssemble() = default;
|
||||
|
||||
|
||||
signals:
|
||||
void backend_deduce_request(std::shared_ptr<const DeduceRequest> ins);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue