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

junyanglong/DS

forked from Vanishi/DS
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
标签 (3)
master
DS.v1.7.x64.2023年04月16日
DS.v1.6.x64.2023年04月13日
DS.v1.5.x64.2023年04月08日
master
分支 (1)
标签 (3)
master
DS.v1.7.x64.2023年04月16日
DS.v1.6.x64.2023年04月13日
DS.v1.5.x64.2023年04月08日
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 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
分支 (1)
标签 (3)
master
DS.v1.7.x64.2023年04月16日
DS.v1.6.x64.2023年04月13日
DS.v1.5.x64.2023年04月08日
DS
/
TaskFlow
/
pageCustomtaskFlowControl.cpp
DS
/
TaskFlow
/
pageCustomtaskFlowControl.cpp
pageCustomtaskFlowControl.cpp 33.43 KB
一键复制 编辑 原始数据 按行查看 历史
sun-th 提交于 2023年03月26日 13:05 +08:00 . V1.3 兼容Qt6.4.3&预计提升性能20%&升级execl库
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 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
#include "pageCustomtaskFlowControl.h"
#include "flowleftwidget/mFlowButtonWidget.h"
#include "flowleftwidget/mFlowLoopWidget.h"
#include "flowleftwidget/mFlowIfWidget.h"
#include "flowleftwidget/mFlowMenuToolbutton.h"
#include "flowleftwidget/mDownArrow.h"
#include "mFcHelper.h"
#include "mFcModels.h"
#include "Utils/models.h"
#include "Utils/database.h"
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
#include <QMimeData>
#include <QDrag>
#include <QMouseEvent>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonObject>
#include <QTimer>
#include <QDebug>
PageCustomTaskFlowControl::PageCustomTaskFlowControl(MTask *task,QWidget *parent) : QWidget(parent),
m_fcHelper(new MFcHelper(this)){
this->task = task;
setAttribute(Qt::WA_StyledBackground,true);
setStyleSheet(".PageCustomTaskFlowControl {background-color:rgb(255,255,255);}");
setAcceptDrops(true);
boxLayout = new QVBoxLayout(this);
boxLayout->setContentsMargins(0,5,0,200);
boxLayout->setSpacing(1);
// 初始化控件
QJsonParseError json_error;
QJsonDocument jsonDoc(QJsonDocument::fromJson(Database::getInstance()->read_file(":/res/images/control/controls.json").toUtf8(), &json_error));
if(json_error.error == QJsonParseError::NoError){
QJsonObject rootObj = jsonDoc.object();
QStringList keys = rootObj.keys();
for(int i = 0; i < keys.size(); i++){
QString menuType = keys.at(i);
QJsonObject obj = rootObj.value(menuType).toObject();
controls.insert(menuType,new MControl(menuType,obj.value("tip").toString(),obj.value("icon").toString(),obj.value("flowWidgetName").toString()));
}
}
//添加开始控件
QPushButton *start = new QPushButton(this);
start->setIcon(QIcon(":/res/images/icon/flow/start.png"));
start->setStyleSheet("QPushButton{border:0px;}");
start->setIconSize(QSize(30,30));
boxLayout->addWidget(start,0,Qt::AlignCenter);
// 添加默认箭头
MDownArrow *arrow = new MDownArrow(this);
boxLayout->addWidget(arrow,0,Qt::AlignCenter);
m_fcHelper->arrows.append(arrow);
//添加结束控件
QPushButton *end = new QPushButton(this);
end->setIcon(QIcon(":/res/images/icon/flow/pause.png"));
end->setStyleSheet("QPushButton{border:0px;}");
end->setIconSize(QSize(22,22));
boxLayout->addWidget(end,0,Qt::AlignCenter);
}
PageCustomTaskFlowControl::~PageCustomTaskFlowControl(){
QHash<QString,MControl*>::const_iterator it;
for (it=controls.constBegin();it!=controls.constEnd();++it) {
delete it.value();
}
}
void PageCustomTaskFlowControl::serialize(){
m_fcHelper->serialize();
}
void PageCustomTaskFlowControl::deserialize(){
m_fcHelper->deserialize();
}
void PageCustomTaskFlowControl::setFlowAddressList(const QStringList &addressList, bool isFirst){
// 流程第一步
if(isFirst){
bool isLoop = false;
if(addressList.length()>1){
isLoop = true;
NextStepLocation nslocation = getNextStepLocation();
MFlowLoopWidget *loopWidget = new MFlowLoopWidget(this,this->controls[MCONSTANT_FLOW_MENU_TYPE_LoopBtn],
new MDownArrow(this),
new MDownArrow(this),nullptr,true);
m_fcHelper->arrows.append(loopWidget->arrow);
m_fcHelper->arrows.append(loopWidget->innerDefaultArrow);
m_fcHelper->allstepwidgets.append(loopWidget);
connect(loopWidget,&MFlowLoopWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
nslocation.layout->insertWidget(nslocation.target,loopWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,loopWidget->arrow,0,Qt::AlignCenter);
MFlowStepParamsLoop *params = static_cast<MFlowStepParamsLoop*>(loopWidget->data->stepparams);
params->loopTypeName = MCONSTANT_RADIO_SITEADDRESS;
params->loopTypeValue = addressList.join(",");
params->loopTextList = addressList;
m_fcHelper->setCurrentStepData(loopWidget->data);
}
// 首次添加该步骤,才会新建openweb窗体
QTimer::singleShot(50,this,[=](){
this->addFlowOpenWebStep(addressList[0],isLoop);
});
}else {
qDebug()<<"addFlowAddressListStep isFirst == false 暂无处理";
}
}
void PageCustomTaskFlowControl::addFlowOpenWebStep(const QString &url,bool isLoop){
// 添加打开网页步骤窗体
NextStepLocation nslocation = getNextStepLocation();
MFlowButtonWidget *openWebWidget = new MFlowButtonWidget(this,
this->controls.value(MCONSTANT_FLOW_MENU_TYPE_OpenWebBtn),
new MDownArrow(this));
openWebWidget->currentParentWidget = nslocation.widget;
connect(openWebWidget,&MFlowButtonWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
m_fcHelper->arrows.append(openWebWidget->arrow);
m_fcHelper->allstepwidgets.append(openWebWidget);
MFlowStepParamsOpenWeb *params = static_cast<MFlowStepParamsOpenWeb*>(openWebWidget->data->stepparams);
params->stepURL = url;
params->url = url;
params->isLoop = isLoop;
nslocation.layout->insertWidget(nslocation.target,openWebWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,openWebWidget->arrow,0,Qt::AlignCenter);
openWebWidget->data->notificationType = MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT;
m_fcHelper->setCurrentStepData(openWebWidget->data);
emit this->notificationToFlow(m_fcHelper->getCurrentStepData());
}
void PageCustomTaskFlowControl::addFlowLoopAndExtractStep(MParamsField *field,
const QString &loopTypeName,
const QString &loopTypeValue,
const QStringList &textList){
// 新增(循环+提取数据)步骤
NextStepLocation nslocation = getNextStepLocation();
MFlowLoopWidget *loopWidget = new MFlowLoopWidget(this,this->controls[MCONSTANT_FLOW_MENU_TYPE_LoopBtn],
new MDownArrow(this),
new MDownArrow(this),nullptr,true);
m_fcHelper->arrows.append(loopWidget->arrow);
m_fcHelper->arrows.append(loopWidget->innerDefaultArrow);
m_fcHelper->allstepwidgets.append(loopWidget);
connect(loopWidget,&MFlowLoopWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
nslocation.layout->insertWidget(nslocation.target,loopWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,loopWidget->arrow,0,Qt::AlignCenter);
MFlowStepParamsLoop *params = static_cast<MFlowStepParamsLoop*>(loopWidget->data->stepparams);
params->stepURL = nslocation.ruleUrlNewStep;
params->loopTypeName = loopTypeName;
params->loopTypeValue = loopTypeValue;
params->loopTextList = textList;
m_fcHelper->setCurrentStepData(loopWidget->data);
// 新增循环窗口中的提取字段窗口
QTimer::singleShot(50,this,[=](){
this->addFlowExtractStep(field,true);
});
}
void PageCustomTaskFlowControl::addFlowLoopAndRollClickStep(){
// 新增(循环+下拉刷新)步骤
NextStepLocation nslocation = getNextStepLocation();
MFlowLoopWidget *loopWidget = new MFlowLoopWidget(this,this->controls[MCONSTANT_FLOW_MENU_TYPE_LoopBtn],
new MDownArrow(this),
new MDownArrow(this),nullptr,true);
m_fcHelper->arrows.append(loopWidget->arrow);
m_fcHelper->arrows.append(loopWidget->innerDefaultArrow);
m_fcHelper->allstepwidgets.append(loopWidget);
connect(loopWidget,&MFlowLoopWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
nslocation.layout->insertWidget(nslocation.target,loopWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,loopWidget->arrow,0,Qt::AlignCenter);
MFlowStepParamsLoop *params = static_cast<MFlowStepParamsLoop*>(loopWidget->data->stepparams);
params->stepURL = nslocation.ruleUrlNewStep;
params->loopTypeName = MCONSTANT_RADIO_SINGLE;
params->loopTypeValue = "下拉刷新";
params->loopTextList = QStringList()<<"下拉刷新";
m_fcHelper->setCurrentStepData(loopWidget->data);
QTimer::singleShot(50,this,[=](){
addFlowClickStep(params->stepURL,"nodeXpath","nodeText","下拉刷新",true,false,true);
});
}
void PageCustomTaskFlowControl::addFlowLoopAndClickStep(const QString &nodeRuleUrl,
const QString &nodeXpath,
const QString &nodeText,
const QString &loopTypeName,
const QString &loopTypeValue,
const QStringList &textList,
const QString &clickName,
bool isNewTab,bool isTurnPage){
// 新增(循环+点击)步骤
NextStepLocation nslocation = getNextStepLocation();
MFlowLoopWidget *loopWidget = new MFlowLoopWidget(this,this->controls[MCONSTANT_FLOW_MENU_TYPE_LoopBtn],
new MDownArrow(this),
new MDownArrow(this),nullptr,true);
m_fcHelper->arrows.append(loopWidget->arrow);
m_fcHelper->arrows.append(loopWidget->innerDefaultArrow);
m_fcHelper->allstepwidgets.append(loopWidget);
connect(loopWidget,&MFlowLoopWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
nslocation.layout->insertWidget(nslocation.target,loopWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,loopWidget->arrow,0,Qt::AlignCenter);
MFlowStepParamsLoop *params = static_cast<MFlowStepParamsLoop*>(loopWidget->data->stepparams);
params->stepURL = nslocation.ruleUrlNewStep;
params->loopTypeName = loopTypeName;
params->loopTypeValue = loopTypeValue;
params->loopTextList = textList;
m_fcHelper->setCurrentStepData(loopWidget->data);
QTimer::singleShot(50,this,[=](){
addFlowClickStep(nodeRuleUrl,nodeXpath,nodeText,clickName,true,isNewTab,false,isTurnPage);
});
}
void PageCustomTaskFlowControl::addFlowClickStep(const QString &ruleUrl,const QString &nodeXpath,const QString &nodeText,const QString &name,bool isLoop,bool isNewTab,bool isRoll,bool isTurnPage){
NextStepLocation nslocation = getNextStepLocation();
if(isLoop==false){
if(nslocation.ruleUrlParentInnerLastStep==nslocation.ruleUrlParent){
// 上一步ruleUrl 和 所属循环ruleUrl相等,则表示该click 也处于所属循环之中
isLoop = true;
isNewTab = true;
}
}
// 新增提取数据的步骤
MFlowButtonWidget *clickWidget = new MFlowButtonWidget(this,this->controls.value(MCONSTANT_FLOW_MENU_TYPE_ClickEleBtn),new MDownArrow(this));
m_fcHelper->arrows.append(clickWidget->arrow);
m_fcHelper->allstepwidgets.append(clickWidget);
clickWidget->currentParentWidget = nslocation.widget;
connect(clickWidget,&MFlowButtonWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
nslocation.layout->insertWidget(nslocation.target,clickWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,clickWidget->arrow,0,Qt::AlignCenter);
MFlowStepParamsClickEle *params =static_cast<MFlowStepParamsClickEle*>(clickWidget->data->stepparams);
if(name!=""){
clickWidget->title->setText(name);
params->name = name;
}
params->stepURL = ruleUrl;
params->eleXpath = nodeXpath;
params->eleText = nodeText;
params->isLoop = isLoop;
params->isNewTab = isNewTab;
params->isRoll = isRoll;
params->isTurnPage = isTurnPage;
clickWidget->data->notificationType = MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT;
m_fcHelper->setCurrentStepData(clickWidget->data);
emit this->notificationToFlow(m_fcHelper->getCurrentStepData());
m_fcHelper->updateBackground();
if(!nslocation.noUpdateSize){
m_fcHelper->updateFixedSize();
}
}
void PageCustomTaskFlowControl::addFlowExtractStep(MParamsField *field,bool isLoop){
NextStepLocation nslocation = getNextStepLocation();
bool isMergeExtract = false;
if(m_fcHelper->getCurrentStepData()->control->menuType == MCONSTANT_FLOW_MENU_TYPE_ExtractBtn){
// 如果当前按钮窗体为提取字段,则考虑合并
isMergeExtract = true;
}
if(isMergeExtract){
// CompareXpathResult res= MFlowTools::compareXpath(field->fieldXpath,
// m_fcHelper->getCurrentStepData()->m_xpath);
MFlowStepParamsExtract *params = static_cast<MFlowStepParamsExtract*>(m_fcHelper->getCurrentStepData()->stepparams);
params->pfs.append(field);
// params->isLoop = isLoop// 合并进来的字段,不需要设置该参数
m_fcHelper->getCurrentStepData()->notificationType = MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT;
emit this->notificationToFlow(m_fcHelper->getCurrentStepData());
}else{
// 新增提取数据的步骤
MFlowButtonWidget *extractWidget = new MFlowButtonWidget(this,
this->controls.value(MCONSTANT_FLOW_MENU_TYPE_ExtractBtn),
new MDownArrow(this));
m_fcHelper->arrows.append(extractWidget->arrow);
m_fcHelper->allstepwidgets.append(extractWidget);
extractWidget->currentParentWidget = nslocation.widget;
connect(extractWidget,&MFlowButtonWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
nslocation.layout->insertWidget(nslocation.target,extractWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,extractWidget->arrow,0,Qt::AlignCenter);
MFlowStepParamsExtract *params = static_cast<MFlowStepParamsExtract*>(extractWidget->data->stepparams);
params->stepURL = nslocation.ruleUrlNewStep;
params->pfs.append(field);
params->isLoop = isLoop;
extractWidget->data->notificationType = MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT;
// 将新增窗体步骤设置为当前窗体步骤
m_fcHelper->setCurrentStepData(extractWidget->data);
emit this->notificationToFlow(m_fcHelper->getCurrentStepData());
m_fcHelper->updateBackground();
if(!nslocation.noUpdateSize){
m_fcHelper->updateFixedSize();
}
}
}
void PageCustomTaskFlowControl::addFlowInputStep(const QString &nodeXpath, const QString &nodeText, const QString text, bool isLoop){
NextStepLocation nslocation = getNextStepLocation();
// if(isLoop==false){
// if(nslocation.ruleUrlParentInnerLastStep==nslocation.ruleUrlParent){
// // 上一步ruleUrl 和 所属循环ruleUrl相等,则表示该click 也处于所属循环之中
// isLoop = true;
// }
// }
MFlowButtonWidget *inputWidget = new MFlowButtonWidget(this,this->controls.value(MCONSTANT_FLOW_MENU_TYPE_InputBtn),new MDownArrow(this));
m_fcHelper->arrows.append(inputWidget->arrow);
m_fcHelper->allstepwidgets.append(inputWidget);
inputWidget->currentParentWidget = nslocation.widget;
connect(inputWidget,&MFlowButtonWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
nslocation.layout->insertWidget(nslocation.target,inputWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,inputWidget->arrow,0,Qt::AlignCenter);
MFlowStepParamsInput *params =static_cast<MFlowStepParamsInput*>(inputWidget->data->stepparams);
params->stepURL = nslocation.ruleUrlNewStep;
params->eleXpath = nodeXpath;
params->eleText = nodeText;
params->isLoop = isLoop;
params->inputText = text;
inputWidget->data->notificationType = MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT;
m_fcHelper->setCurrentStepData(inputWidget->data);
emit this->notificationToFlow(m_fcHelper->getCurrentStepData());
m_fcHelper->updateBackground();
if(!nslocation.noUpdateSize){
m_fcHelper->updateFixedSize();
}
}
void PageCustomTaskFlowControl::addFlowMouseStep(const QString &nodeXpath, const QString &nodeText, bool isLoop){
NextStepLocation nslocation = getNextStepLocation();
// if(isLoop==false){
// if(nslocation.ruleUrlParentInnerLastStep==nslocation.ruleUrlParent){
// // 上一步ruleUrl 和 所属循环ruleUrl相等,则表示该click 也处于所属循环之中
// isLoop = true;
// }
// }
MFlowButtonWidget *mouseWidget = new MFlowButtonWidget(this,this->controls.value(MCONSTANT_FLOW_MENU_TYPE_MouseBtn),new MDownArrow(this));
m_fcHelper->arrows.append(mouseWidget->arrow);
m_fcHelper->allstepwidgets.append(mouseWidget);
mouseWidget->currentParentWidget = nslocation.widget;
connect(mouseWidget,&MFlowButtonWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
nslocation.layout->insertWidget(nslocation.target,mouseWidget,0,Qt::AlignCenter);
nslocation.layout->insertWidget(nslocation.target,mouseWidget->arrow,0,Qt::AlignCenter);
MFlowStepParamsMouse *params =static_cast<MFlowStepParamsMouse*>(mouseWidget->data->stepparams);
params->stepURL = nslocation.ruleUrlNewStep;
params->eleXpath = nodeXpath;
params->eleText = nodeText;
params->isLoop = isLoop;
mouseWidget->data->notificationType = MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT;
m_fcHelper->setCurrentStepData(mouseWidget->data);
emit this->notificationToFlow(m_fcHelper->getCurrentStepData());
m_fcHelper->updateBackground();
if(!nslocation.noUpdateSize){
m_fcHelper->updateFixedSize();
}
}
QString PageCustomTaskFlowControl::getStepURL(QWidget *widget) const{
QString ruleUrl;
QString widgetName = widget->metaObject()->className();
if("MFlowButtonWidget"==widgetName){
MFlowButtonWidget *buttonWidget = static_cast<MFlowButtonWidget *>(widget);
ruleUrl = buttonWidget->data->stepparams->stepURL;
}else if ("MFlowLoopWidget"==widgetName) {
MFlowLoopWidget *loopWidget = static_cast<MFlowLoopWidget *>(widget);
ruleUrl = loopWidget->data->stepparams->stepURL;
}else if ("MFlowIfWidget"==widgetName) {
MFlowIfWidget *ifWidget = static_cast<MFlowIfWidget *>(widget);
ruleUrl = ifWidget->data->stepparams->stepURL;
}
return ruleUrl;
}
PageCustomTaskFlowControl::NextStepLocation PageCustomTaskFlowControl::getNextStepLocation(){
int parentTypeMain = 11;
int parentTypeLoop = 12;
int parentTypeIf = 13;
QWidget *parentWidget = this;
QVBoxLayout *parentLayout = this->boxLayout;
int parentType = parentTypeMain;
int target =parentLayout->count() - 2; // 默认位置在主窗口的顶部
NextStepLocation nslocation;
// 如果当前按下的窗体存在 && 未被删除
if(m_fcHelper->getCurrentStepData() && !m_fcHelper->getCurrentStepData()->widgetIsDelete){
if(m_fcHelper->getCurrentStepData()->control->menuType == MCONSTANT_FLOW_MENU_TYPE_LoopBtn){
// 如果 当前按下的窗体菜单类型为loop框,需要判断loop的类型,再决定添加的位置
MFlowLoopWidget *currentLoop = static_cast<MFlowLoopWidget *>(m_fcHelper->getCurrentStepData()->widget);
parentWidget =currentLoop;
parentLayout = currentLoop->boxLayout;
parentType = parentTypeLoop;
MFlowStepParamsLoop *loopParams = static_cast<MFlowStepParamsLoop*>(currentLoop->data->stepparams);
nslocation.ruleUrlParent = loopParams->stepURL;
int innerCount = parentLayout->count();
if(innerCount==1){// 空循环窗体
target = innerCount - 1;
}else{
if(loopParams->loopTypeName==MCONSTANT_RADIO_SINGLE){// 单个元素类型的循环,翻页点击需要放在最后一步
target = innerCount - 1 - 2;
}else{
target = innerCount - 1;
}
}
}else if(m_fcHelper->getCurrentStepData()->control->menuType == MCONSTANT_FLOW_MENU_TYPE_JudgeBtn){
// 如果 当前按下的窗体菜单类型为if框,直接在if框内顶部添加
MFlowIfWidget *currentIf = static_cast<MFlowIfWidget *>(m_fcHelper->getCurrentStepData()->widget);
parentWidget = currentIf;
parentLayout = currentIf->boxLayout;
parentType = parentTypeIf;
nslocation.ruleUrlParent = currentIf->data->stepparams->stepURL;
target = parentLayout->count() - 1;
}else{
// 如果 当前按下的窗体为按钮窗体,首先为当前的按钮窗体找到父窗体
QWidget *currentParentWindow=static_cast<MFlowButtonWidget *>(m_fcHelper->getCurrentStepData()->widget)->currentParentWidget;
QString currentParentWindowName = currentParentWindow->metaObject()->className();
if("MFlowLoopWidget"==currentParentWindowName){
MFlowLoopWidget *currentLoop = static_cast<MFlowLoopWidget *>(currentParentWindow);
parentWidget =currentLoop;
parentLayout = currentLoop->boxLayout;
parentType = parentTypeLoop;
MFlowStepParamsLoop *loopParams = static_cast<MFlowStepParamsLoop*>(currentLoop->data->stepparams);
nslocation.ruleUrlParent = loopParams->stepURL;
int innerCount = parentLayout->count();
if(innerCount==1){// 空循环窗体
target = innerCount - 1;
}else{
if(loopParams->loopTypeName==MCONSTANT_RADIO_SINGLE){// 单个元素类型的循环
target = innerCount - 1 - 2;
}else{
target = innerCount - 1;
}
}
}else if ("MFlowIfWidget"==currentParentWindowName) {
MFlowIfWidget *currentIf = static_cast<MFlowIfWidget *>(currentParentWindow);
parentWidget = currentIf;
parentLayout = currentIf->boxLayout;
parentType = parentTypeLoop;
nslocation.ruleUrlParent = currentIf->data->stepparams->stepURL;
target = parentLayout->count() - 1;
}
}
}
if(parentTypeMain==parentType){
// 如果在主窗口,则起始步骤的 target = 1
if(target>1){
// 不在起始位置,存在上一步widget
nslocation.ruleUrlParentInnerLastStep = getStepURL(parentLayout->itemAt(target-1)->widget());
}
}else{
// 如果是非主窗口,则起始步骤的target = 0
if(target>0){
// 不在起始位置,存在上一步widget
nslocation.ruleUrlParentInnerLastStep = getStepURL(parentLayout->itemAt(target-1)->widget());
}
}
nslocation.widget = parentWidget;
nslocation.layout = parentLayout;
nslocation.target = target;
nslocation.noUpdateSize = parentType == parentTypeMain ? true:false;
if(nslocation.ruleUrlParentInnerLastStep!=""){// 如果本循环内上一步ruleUrl存在
nslocation.ruleUrlNewStep = nslocation.ruleUrlParentInnerLastStep;//(场景:非循环内第一步)
}else{
nslocation.ruleUrlNewStep = nslocation.ruleUrlParent;// (场景:循环内第一步)
}
return nslocation;
}
void PageCustomTaskFlowControl::onNotificationFromChildWidget(MFlowStepData *data){
if (MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT==data->notificationType){
// 拖拽以成功的方式结束,需要更新布局
m_fcHelper->updateFixedSize();
m_fcHelper->setarrowsNormal();
m_fcHelper->setCurrentStepData(data);
m_fcHelper->updateBackground();
}else if (MCONNSTANT_NOTIFICATION_TYPE_START==data->notificationType) {
// 整个拖拽系统首次出现拖拽行为
m_fcHelper->setarrowsPress();
}else if (MCONNSTANT_NOTIFICATION_TYPE_OTHER_END==data->notificationType||
MCONNSTANT_NOTIFICATION_TYPE_OTHER_END_SHOWCONTENT==data->notificationType) {
// 所有拖拽行为结束,但是以取消的方式结束
m_fcHelper->setarrowsNormal();
m_fcHelper->setCurrentStepData(data);
m_fcHelper->updateBackground();
}else if (MCONNSTANT_NOTIFICATION_TYPE_DELETE_CURRENT_WIDGET) {
// TODO 如果删除的widget是curentStepWidge。则需要重新寻找一个widget替代currentStepWidget
m_fcHelper->removeStep(data->widget);
}
if(m_fcHelper->getCurrentStepData()->widgetIsDelete){
qDebug()<<"stepwidget被删除";
}else {
if(MCONNSTANT_NOTIFICATION_TYPE_OTHER_END_SHOWCONTENT==data->notificationType ||
MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT==data->notificationType){
// 如果通知类型都包含显示右侧内容,则需要矫正stepData的状态类型
m_fcHelper->getCurrentStepData()->notificationType = data->notificationType;
emit this->notificationToFlow(m_fcHelper->getCurrentStepData());
emit this->notificationToSmartAlertWidget(m_fcHelper->getCurrentStepData());
}
}
}
void PageCustomTaskFlowControl::dragEnterEvent(QDragEnterEvent *event)
{
dragEnterEvery(event);
}
void PageCustomTaskFlowControl::dragEnterEvery(QDragEnterEvent *event){
// qDebug()<<QString(m_this->metaObject()->className())<<"dragEnterEvent()";
if (event->mimeData()->hasFormat("application/MFlowButtonWidget")) {
event->acceptProposedAction();
} else if (event->mimeData()->hasFormat("application/MFlowLoopWidget")) {
event->acceptProposedAction();
} else if (event->mimeData()->hasFormat("application/MFlowIfWidget")) {
event->acceptProposedAction();
} else if (event->mimeData()->hasFormat("application/MFlowMenuToolButton")) {
event->acceptProposedAction();
} else {
event->ignore();
return;
}
}
void PageCustomTaskFlowControl::dropEvery(QWidget *parentWidget,QVBoxLayout *boxLayout, QDropEvent *event){
// qDebug()<<QString(m_this->metaObject()->className())<<"dropEvent()";
QObject *tw = qobject_cast<QObject*>(parentWidget->childAt(event->pos()));
if(!tw){
return ;
}
if("MDownArrow"==QString(tw->metaObject()->className())){
// 只有箭头区域才是合法的接收区域
MDownArrow *targetArrow = qobject_cast<MDownArrow *>(tw);
int targetIndex = boxLayout->indexOf(targetArrow);
if (event->mimeData()->hasFormat("application/MFlowMenuToolButton")) {
MControl *menu = qobject_cast<MFlowMenuToolButton *>(event->source())->data->control;
if("MFlowButtonWidget"==menu->menuFlowWidgetName){
MFlowButtonWidget *widget = new MFlowButtonWidget(this,
menu,
new MDownArrow(this));
//如果是从侧边栏拖拽过来的新窗体,需要在这里重新覆盖掉
m_fcHelper->setCurrentStepData(widget->data);
m_fcHelper->arrows.append(widget->arrow);
m_fcHelper->allstepwidgets.append(widget);
widget->currentParentWidget = parentWidget;
connect(widget,&MFlowButtonWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
boxLayout->insertWidget(targetIndex,widget,0,Qt::AlignCenter);
boxLayout->insertWidget(targetIndex,widget->arrow,0,Qt::AlignCenter);
event->setDropAction(Qt::MoveAction);
event->accept();
}else if ("MFlowLoopWidget"==menu->menuFlowWidgetName) {
MFlowLoopWidget *widget = new MFlowLoopWidget(this,menu,
new MDownArrow(this),
new MDownArrow(this));
//如果是从侧边栏拖拽过来的新窗体,需要在这里重新覆盖掉
m_fcHelper->setCurrentStepData(widget->data);
m_fcHelper->arrows.append(widget->arrow);
m_fcHelper->arrows.append(widget->innerDefaultArrow);
m_fcHelper->allstepwidgets.append(widget);
widget->currentParentWidget = parentWidget;
connect(widget,&MFlowLoopWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
boxLayout->insertWidget(targetIndex,widget,0,Qt::AlignCenter);
boxLayout->insertWidget(targetIndex,widget->arrow,0,Qt::AlignCenter);
event->setDropAction(Qt::MoveAction);
event->accept();
}else if ("MFlowIfWidget"==menu->menuFlowWidgetName) {
MFlowIfWidget *widget = new MFlowIfWidget(this,menu,
new MDownArrow(this),
new MDownArrow(this));
//如果是从侧边栏拖拽过来的新窗体,需要在这里重新覆盖掉
m_fcHelper->setCurrentStepData(widget->data);
m_fcHelper->arrows.append(widget->arrow);
m_fcHelper->arrows.append(widget->innerDefaultArrow);
m_fcHelper->allstepwidgets.append(widget);
widget->currentParentWidget = parentWidget;
connect(widget,&MFlowIfWidget::notificationToParentWidget,this,&PageCustomTaskFlowControl::onNotificationFromChildWidget);
boxLayout->insertWidget(targetIndex,widget,0,Qt::AlignCenter);
boxLayout->insertWidget(targetIndex,widget->arrow,0,Qt::AlignCenter);
event->setDropAction(Qt::MoveAction);
event->accept();
}else {
event->ignore();
}
}else if (event->mimeData()->hasFormat("application/MFlowButtonWidget")) {
QByteArray itemData = event->mimeData()->data("application/MFlowButtonWidget");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QPoint offset;
dataStream >>offset;
MFlowButtonWidget *widget= static_cast<MFlowButtonWidget *>(event->source());
boxLayout->insertWidget(targetIndex,widget,0,Qt::AlignCenter);
boxLayout->insertWidget(targetIndex,widget->arrow,0,Qt::AlignCenter);
widget->currentParentWidget = parentWidget;
event->setDropAction(Qt::MoveAction);
event->accept();
}else if(event->mimeData()->hasFormat("application/MFlowLoopWidget")) {
QByteArray itemData = event->mimeData()->data("application/MFlowLoopWidget");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QPoint offset;
dataStream >>offset;
MFlowLoopWidget *widget = static_cast<MFlowLoopWidget *>(event->source());
boxLayout->insertWidget(targetIndex,widget,0,Qt::AlignCenter);
boxLayout->insertWidget(targetIndex,widget->arrow,0,Qt::AlignCenter);
widget->currentParentWidget = parentWidget;
event->setDropAction(Qt::MoveAction);
event->accept();
}else if(event->mimeData()->hasFormat("application/MFlowIfWidget")) {
QByteArray itemData = event->mimeData()->data("application/MFlowIfWidget");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QPoint offset;
dataStream >>offset;
MFlowIfWidget *widget = static_cast<MFlowIfWidget *>(event->source());
boxLayout->insertWidget(targetIndex,widget,0,Qt::AlignCenter);
boxLayout->insertWidget(targetIndex,widget->arrow,0,Qt::AlignCenter);
widget->currentParentWidget = parentWidget;
event->setDropAction(Qt::MoveAction);
event->accept();
}else {
event->ignore();
}
}
}
void PageCustomTaskFlowControl::dropEvent(QDropEvent *event){
this->dropEvery(this,boxLayout,event);
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

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

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

取消
提交

简介

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

发行版

暂无发行版

贡献者

全部

近期动态

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

搜索帮助

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

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