开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 142

撸码小分队/DS

forked from Vanishi/DS
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
标签 (4)
master
V1.0
DS.v1.7.x64.2023年04月16日
DS.v1.6.x64.2023年04月13日
DS.v1.5.x64.2023年04月08日
DS.v1.0.x64.2023年03月18日
master
分支 (2)
标签 (4)
master
V1.0
DS.v1.7.x64.2023年04月16日
DS.v1.6.x64.2023年04月13日
DS.v1.5.x64.2023年04月08日
DS.v1.0.x64.2023年03月18日
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
标签 (4)
master
V1.0
DS.v1.7.x64.2023年04月16日
DS.v1.6.x64.2023年04月13日
DS.v1.5.x64.2023年04月08日
DS.v1.0.x64.2023年03月18日
DS
/
TaskFlow
/
mFcHelper.cpp
DS
/
TaskFlow
/
mFcHelper.cpp
mFcHelper.cpp 13.33 KB
一键复制 编辑 原始数据 按行查看 历史
sun-th 提交于 2023年04月08日 18:39 +08:00 . V1.5 新增图片下载功能&优化代码结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
#include "mFcHelper.h"
#include "Utils/models.h"
#include "mFcModels.h"
#include "mTaskSerialize.h"
#include "mTaskDeserialize.h"
#include "TaskFlow/pageCustomtaskFlowControl.h"
#include "flowleftwidget/mFlowButtonWidget.h"
#include "flowleftwidget/mFlowIfWidget.h"
#include "flowleftwidget/mFlowLoopWidget.h"
#include "flowleftwidget/mDownArrow.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QTimer>
#include <QDebug>
MFcHelper::MFcHelper(PageCustomTaskFlowControl *parent) : QObject(parent) {
m_fc = parent;
}
MFcHelper::~MFcHelper(){
}
void MFcHelper::serialize(){
MTaskSerialize taskser(m_fc);
}
void MFcHelper::deserialize(){
MTaskDeserialize taskdeser(m_fc->task->program,this);
for (int i = 0; i < taskdeser.steps.length(); ++i) {
MFlowStepParams *params = taskdeser.steps[i];
bool bgnormal = true;
if(0==i){
bgnormal = false;
}
if(MCONSTANT_FLOW_MENU_TYPE_LoopBtn==params->menuType){
addLoopWidget(params,bgnormal);
}else if(MCONSTANT_FLOW_MENU_TYPE_JudgeBtn==params->menuType){
addIfWidget(params,bgnormal);
}else{
addButtonWidget(params,bgnormal);
}
}
updateFixedSize();
m_currentData->notificationType = MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT;
emit m_fc->notificationToFlow(m_currentData);
// emit m_fc->notificationToSmartAlertWidget(this->m_currentData);
}
MFcHelper::Location MFcHelper::getLocation(MFlowStepParams *params){
Location location;
QWidget *widget = m_fc;
QVBoxLayout *layout = m_fc->boxLayout;
int target =layout->count() - 2; // 默认位置在主窗口的顶部
if(params->carryParent!=nullptr){
for (int i = this->allstepwidgets.count()-1; i >=0 ; --i) {
QWidget *stepwidget = this->allstepwidgets.at(i);
QString stepwidgetname = stepwidget->metaObject()->className();
if ("MFlowLoopWidget"==stepwidgetname) {
MFlowLoopWidget *step = qobject_cast<MFlowLoopWidget *>(stepwidget);
if(step->data->stepparams==params->carryParent){
widget = step;
layout = step->boxLayout;
target = step->boxLayout->count() - 1;
break;
}
}else if ("MFlowIfWidget"==stepwidgetname) {
MFlowIfWidget *step = qobject_cast<MFlowIfWidget *>(stepwidget);
if(step->data->stepparams==params->carryParent){
widget = step;
layout = step->boxLayout;
target = step->boxLayout->count() - 1;
break;
}
}
}
}
location.widget = widget;
location.layout = layout;
location.target = target;
return location;
}
void MFcHelper::addButtonWidget(MFlowStepParams *params,bool bgnormal){
Location location = getLocation(params);
MFlowButtonWidget *stepwidget = new MFlowButtonWidget(m_fc,
m_fc->controls.value(params->menuType),
new MDownArrow(m_fc),params,bgnormal);
stepwidget->currentParentWidget = location.widget;
connect(stepwidget,&MFlowButtonWidget::notificationToParentWidget,m_fc,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
this->arrows.append(stepwidget->arrow);
this->allstepwidgets.append(stepwidget);
stepwidget->title->setText(params->name);
location.layout->insertWidget(location.target,stepwidget,0,Qt::AlignCenter);
location.layout->insertWidget(location.target,stepwidget->arrow,0,Qt::AlignCenter);
if(!bgnormal){
m_currentData = stepwidget->data;
}
}
void MFcHelper::addIfWidget(MFlowStepParams *params,bool bgnormal){
Location location = getLocation(params);
MFlowIfWidget *stepwidget = new MFlowIfWidget(m_fc, m_fc->controls.value(params->menuType),
new MDownArrow(m_fc),new MDownArrow(m_fc),
params,bgnormal);
this->arrows.append(stepwidget->arrow);
this->arrows.append(stepwidget->innerDefaultArrow);
this->allstepwidgets.append(stepwidget);
stepwidget->title->setText(params->name);
connect(stepwidget,&MFlowIfWidget::notificationToParentWidget,m_fc,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
location.layout->insertWidget(location.target,stepwidget,0,Qt::AlignCenter);
location.layout->insertWidget(location.target,stepwidget->arrow,0,Qt::AlignCenter);
if(!bgnormal){
m_currentData = stepwidget->data;
}
}
void MFcHelper::addLoopWidget(MFlowStepParams *params,bool bgnormal){
Location location = getLocation(params);
MFlowLoopWidget *stepwidget = new MFlowLoopWidget(m_fc, m_fc->controls.value(params->menuType),
new MDownArrow(m_fc),new MDownArrow(m_fc),
params,bgnormal);
this->arrows.append(stepwidget->arrow);
this->arrows.append(stepwidget->innerDefaultArrow);
this->allstepwidgets.append(stepwidget);
stepwidget->title->setText(params->name);
connect(stepwidget,&MFlowLoopWidget::notificationToParentWidget,m_fc,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
location.layout->insertWidget(location.target,stepwidget,0,Qt::AlignCenter);
location.layout->insertWidget(location.target,stepwidget->arrow,0,Qt::AlignCenter);
if(!bgnormal){
m_currentData = stepwidget->data;
}
}
void MFcHelper::removeStep(QWidget *stepwidget){
//获取被删除的widget及其内部所有的widget,以及箭头,并清理出去
QTimer::singleShot(10,this,[this,stepwidget](){
m_removeWidgets.clear();
updateDelWidgets(stepwidget);
for (int i = 0; i < m_removeWidgets.count(); ++i) {
//判断被删除的widget是否存在与 m_currentPressedData一致,如果存在,则需要置空
QWidget *delWidget = m_removeWidgets.at(i);
if(delWidget==m_currentData->widget){
m_currentData->widgetIsDelete = true;
}
delWidget->deleteLater();
}
});
updateFixedSize();
}
void MFcHelper::updateFixedSize(){
QTimer::singleShot(50,this,[this](){
m_tempLoopTypeWidgetMaxDeep = 0;
m_tempLoopTypeWidgets.clear();//清空所有层级中的窗体
getLoopTypeWidgets(0,this->m_fc);
for (int i=m_tempLoopTypeWidgetMaxDeep;i>=1;--i) {
QList<QWidget *> values= m_tempLoopTypeWidgets.values(i);
for (int j=0;j<values.count();++j) {
QWidget *widget = values[j];
QString widgetName = widget->metaObject()->className();
if ("MFlowLoopWidget"==widgetName) {
MFlowLoopWidget *loopWidget= qobject_cast<MFlowLoopWidget *>(widget);
loopWidget->updateFixedSize();
}else if ("MFlowIfWidget"==widgetName) {
MFlowIfWidget * ifWidget = qobject_cast<MFlowIfWidget *>(widget);
ifWidget->updateFixedSize();
}
}
}
});
}
void MFcHelper::updateDelWidgets(QWidget *widget){
QBoxLayout *dataLayout = nullptr;
QString widgetName = widget->metaObject()->className();
// step 自身widget涉及节点的新增和移除
if ("MFlowLoopWidget"==widgetName) {
MFlowLoopWidget *loopWidget = static_cast<MFlowLoopWidget *>(widget);
m_removeWidgets.append(loopWidget);
m_removeWidgets.append(loopWidget->arrow);
m_removeWidgets.append(loopWidget->innerDefaultArrow);
this->arrows.removeOne(loopWidget->arrow);
this->arrows.removeOne(loopWidget->innerDefaultArrow);
this->allstepwidgets.removeOne(loopWidget);
dataLayout = loopWidget->boxLayout;
}else if ("MFlowIfWidget"==widgetName) {
MFlowIfWidget *ifWidget = static_cast<MFlowIfWidget *>(widget);
m_removeWidgets.append(ifWidget);
m_removeWidgets.append(ifWidget->arrow);
m_removeWidgets.append(ifWidget->innerDefaultArrow);
this->arrows.removeOne(ifWidget->arrow);
this->arrows.removeOne(ifWidget->innerDefaultArrow);
this->allstepwidgets.removeOne(ifWidget);
dataLayout = ifWidget->boxLayout;
}else if ("MFlowButtonWidget"==widgetName) {
MFlowButtonWidget *btnWidget = static_cast<MFlowButtonWidget *>(widget);
m_removeWidgets.append(btnWidget);
m_removeWidgets.append(btnWidget->arrow);
this->arrows.removeOne(btnWidget->arrow);
this->allstepwidgets.removeOne(btnWidget);
}
if(dataLayout!=nullptr){
for (int i=0;i<dataLayout->count();++i) {
QWidget *widget2 = dataLayout->itemAt(i)->widget();
QString widget2Name=widget2->metaObject()->className();
if ("MFlowLoopWidget"==widget2Name) {
MFlowLoopWidget *widget2C = static_cast<MFlowLoopWidget *>(widget2);
dataLayout->removeWidget(widget2C);
m_removeWidgets.append(widget2C);
m_removeWidgets.append(widget2C->arrow);
m_removeWidgets.append(widget2C->innerDefaultArrow);
this->arrows.removeOne(widget2C->arrow);
this->arrows.removeOne(widget2C->innerDefaultArrow);
this->allstepwidgets.removeOne(widget2C);
updateDelWidgets(widget2C);
}else if ("MFlowIfWidget"==widget2Name) {
MFlowIfWidget *widget2C = static_cast<MFlowIfWidget *>(widget2);
dataLayout->removeWidget(widget2C);
m_removeWidgets.append(widget2C);
m_removeWidgets.append(widget2C->arrow);
m_removeWidgets.append(widget2C->innerDefaultArrow);
this->arrows.removeOne(widget2C->arrow);
this->arrows.removeOne(widget2C->innerDefaultArrow);
this->allstepwidgets.removeOne(widget2C);
updateDelWidgets(widget2C);
}else if ("MFlowButtonWidget"==widget2Name) {
MFlowButtonWidget *widget2C = static_cast<MFlowButtonWidget *>(widget2);
dataLayout->removeWidget(widget2C);
m_removeWidgets.append(widget2C);
m_removeWidgets.append(widget2C->arrow);
this->arrows.removeOne(widget2C->arrow);
this->allstepwidgets.removeOne(widget2C);
}
}
}
}
void MFcHelper::setarrowsPress(){
for (int i=0;i<arrows.count();++i) {
arrows.at(i)->setIconPress();
}
}
void MFcHelper::setarrowsNormal(){
for (int i=0;i<arrows.count();++i) {
arrows.at(i)->setIconNormal();
}
}
void MFcHelper::updateBackground(){
for (int i = 0; i < allstepwidgets.count(); ++i) {
QWidget *widget = allstepwidgets.at(i);
if(m_currentData!=nullptr && m_currentData->widget==widget){
widget->setStyleSheet(m_stylesheet_QWidget_flowleftwidget_blue_press);
}else{
widget->setStyleSheet(m_stylesheet_QWidget_flowleftwidget_blue_normal);
}
}
}
void MFcHelper::getLoopTypeWidgets(int deep, QWidget *widget){
deep+=1;
if(m_tempLoopTypeWidgetMaxDeep < deep){
m_tempLoopTypeWidgetMaxDeep = deep;
}
QString widgetName = widget->metaObject()->className();
QBoxLayout *dataLayout = nullptr;
if ("MFlowLoopWidget"==widgetName) {
MFlowLoopWidget *current = static_cast<MFlowLoopWidget *>(widget);
dataLayout = current->boxLayout;
}else if ("MFlowIfWidget"==widgetName) {
MFlowIfWidget *current = static_cast<MFlowIfWidget *>(widget);
dataLayout = current->boxLayout;
}else if ("PageCustomTaskFlowControl"==widgetName) {
PageCustomTaskFlowControl *current = static_cast<PageCustomTaskFlowControl *>(widget);
dataLayout = current->boxLayout;
}
if(dataLayout!=nullptr){
for (int i=0;i<dataLayout->count();++i) {
QWidget *nextWidget = dataLayout->itemAt(i)->widget();
// 下一个widget只有符合循环类型的控件才可以继续迭代
if("MFlowLoopWidget"==QString(nextWidget->metaObject()->className())){
m_tempLoopTypeWidgets.insert(deep,nextWidget);
getLoopTypeWidgets(deep,nextWidget);
}else if("MFlowIfWidget"==QString(nextWidget->metaObject()->className())){
m_tempLoopTypeWidgets.insert(deep,nextWidget);
getLoopTypeWidgets(deep,nextWidget);
}
}
}
}
void MFcHelper::setCurrentStepData(MFlowStepData *data){
// 在设置当前stepData时,如果是由侧边栏直接拖拽过来的data,则忽略
// 因为侧边栏拖拽过来的data在dropEvent时,已经提前设置过。
if ("MFlowMenuToolButton"!=QString(data->widget->metaObject()->className())) {
this->m_currentData = data;
}
}
MFlowStepData * MFcHelper::getCurrentStepData(){
return this->m_currentData;
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

一个Qt开发的可以替代爬虫的网页数据采集软件,它最重要的特点就是,降低了采集网页数据的门槛,由至少必须掌握一门编程语言降低到只要会操作电脑即可。
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/coderanks/DS.git
git@gitee.com:coderanks/DS.git
coderanks
DS
DS
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /