add diagram wizard bay setting ui
This commit is contained in:
parent
5b2273f021
commit
04dd9af60e
|
|
@ -397,6 +397,7 @@ struct DiagramEditorWizardBusInfo //组态编辑母线信息
|
|||
int nNum1 = 0; //1母
|
||||
int nNum2 = 0; //2母
|
||||
int connectType = 0; //接线方式,1为分段连接
|
||||
bool bChanged = false; //是否改变
|
||||
};
|
||||
|
||||
enum class BayType //间隔类型
|
||||
|
|
@ -411,7 +412,6 @@ enum class BayType //间隔类型
|
|||
mainTransformerBay //主变
|
||||
};
|
||||
|
||||
|
||||
struct DiagramEditorWizardBayInfo //组态间隔信息
|
||||
{
|
||||
QString sName;
|
||||
|
|
@ -445,6 +445,14 @@ struct DiagramEditorBriefConnect //组态编辑时连接信息
|
|||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
QString getOppositeName(const QString& s){ //获取另一端名称
|
||||
if(con1.sName == s)
|
||||
return con2.sName;
|
||||
else if(con2.sName == s)
|
||||
return con1.sName;
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
//==================组态图使用=====================
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ set(DIAGRAMCAVAS_HEADER_FILES
|
|||
include/diagramEditor/wizardBayContentDlg.h
|
||||
include/diagramEditor/diagramEditorBaseBlock.h
|
||||
include/diagramEditor/diagramEditorStructContainer.h
|
||||
include/diagramEditor/diagramEditorBaySettingDlg.h
|
||||
include/graphicsDataModel/baseModel.h
|
||||
include/graphicsDataModel/fixedPortsModel.h
|
||||
include/graphicsItem/electricConnectLineItem.h
|
||||
|
|
@ -111,6 +112,7 @@ set(DIAGRAMCAVAS_SOURCE_FILES
|
|||
source/diagramEditor/wizardBayContentDlg.cpp
|
||||
source/diagramEditor/diagramEditorBaseBlock.cpp
|
||||
source/diagramEditor/diagramEditorStructContainer.cpp
|
||||
source/diagramEditor/diagramEditorBaySettingDlg.cpp
|
||||
source/graphicsDataModel/baseModel.cpp
|
||||
source/graphicsDataModel/fixedPortsModel.cpp
|
||||
source/graphicsItem/electricConnectLineItem.cpp
|
||||
|
|
@ -160,6 +162,7 @@ set(UI_FILES
|
|||
ui/measureSettingDlg.ui
|
||||
ui/bayManagerDlg.ui
|
||||
ui/bayManagerContentDlg.ui
|
||||
ui/diagramEditorBaySettingDlg.ui
|
||||
)
|
||||
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
virtual QString getName() {return sName;}
|
||||
virtual void setType(int n) {nType = n;}
|
||||
virtual int getType() {return nType;}
|
||||
virtual void addConnect(const QString&,int nType); //与目标建立连接
|
||||
virtual void addConnect(const QString&,int nType,bool bCover = false); //与目标建立连接
|
||||
virtual void addConnect(DiagramEditorBriefConnect); //直接添加连接
|
||||
virtual void removeConnect(const QString&);
|
||||
virtual void removeConnect(DiagramEditorBriefConnect);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef DIAGRAMEDITORBAYSETTINGDLG_H
|
||||
#define DIAGRAMEDITORBAYSETTINGDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class diagramEditorBaySettingDlg; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class DiagramEditorWizard;
|
||||
class DiagramEditorBayBlock;
|
||||
|
||||
class DiagramEditorBaySettingDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiagramEditorBaySettingDlg(QWidget *parent = nullptr);
|
||||
~DiagramEditorBaySettingDlg();
|
||||
|
||||
void initial();
|
||||
void showDlg(int nLevel);
|
||||
void showDlg(int nLevel,DiagramEditorBayBlock*);
|
||||
void setParent(DiagramEditorWizard* p) {_pWizard = p;}
|
||||
void addNewBay();
|
||||
public slots:
|
||||
void onAddClicked();
|
||||
void onDeleteClicked();
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
void onConnectLevelChanged(const QString&); //连接层级改变信号
|
||||
private:
|
||||
Ui::diagramEditorBaySettingDlg *ui;
|
||||
DiagramEditorWizard* _pWizard;
|
||||
int _curModel; //0新增,1修改
|
||||
DiagramEditorBayBlock* _curOperateBlock; //当前修改对象
|
||||
int _curLevel; //当前层级
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -11,6 +11,8 @@ QT_END_NAMESPACE
|
|||
class WizardBayContentDlg;
|
||||
class DiagramEditorBaseBlock;
|
||||
class DiagramEditorStructContainer;
|
||||
class QListWidgetItem;
|
||||
class DiagramEditorBaySettingDlg;
|
||||
|
||||
class DiagramEditorWizard : public QDialog
|
||||
{
|
||||
|
|
@ -20,7 +22,7 @@ public:
|
|||
~DiagramEditorWizard();
|
||||
signals:
|
||||
void wizardFinish(DiagramEditorWizardInfo);
|
||||
protected:
|
||||
public slots:
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
void onLastClicked();
|
||||
|
|
@ -29,20 +31,33 @@ protected:
|
|||
void onAddBusClicked(); //添加母线
|
||||
void onAddBayClicked(); //添加间隔
|
||||
void onAddTransClicked(); //添加变压器
|
||||
void onAddBayFinished(DiagramEditorWizardBayInfo); //添加间隔完毕
|
||||
|
||||
void onDelegateFinishEdit(const QModelIndex &index, const QString &value); //代理edit完成事件
|
||||
void onBusDeleteClicked();
|
||||
void onBusIndexRbtnClicked(const QPoint &pos); //bus列表右键菜单
|
||||
|
||||
void onBayListSelected(QListWidgetItem* pItem); //baylist选择事件
|
||||
public:
|
||||
QMap<int,DiagramEditorWizardBusInfo> getMapBusInfo() {return _mapBus;}
|
||||
QMap<int,QMap<int,DiagramEditorStructContainer*>> getCointainerStruct(){return _mapSturctContainer;}
|
||||
QList<DiagramEditorBaseBlock*> getTargetLevelBlocks(int nLevel,int nType); //返回指定层数的对应block,type:1母线,2间隔
|
||||
DiagramEditorStructContainer* getContainerByBlock(int nLevel,int nType,QString sName); //根据block名称返回container
|
||||
DiagramEditorBaseBlock* getBlockByName(int nLevel,int nType,QString sName); //根据名称返回block
|
||||
bool removeBlockByName(int nLevel,int nType,const QString& sName); //依据名称删除block
|
||||
WizardBayContentDlg* getContentDlg() {return _bayContentDlg;}
|
||||
DiagramEditorBaySettingDlg* getBaySettingDlg() {return _baySettingDlg;}
|
||||
private:
|
||||
void initial();
|
||||
void reOrderBus(); //重置bus次序
|
||||
|
||||
void generateBayPage(); //根据bus设置生成bay页
|
||||
void generateBayStruct(); //根据bus设置生成bay结构
|
||||
void showSelectedBayPage(int); //显示选中的bay页面
|
||||
template <typename T> void reindexQMap(QMap<int, T> &map); //重新排序函数
|
||||
private:
|
||||
Ui::diagramEditorWizard *ui;
|
||||
BiDirectionalMap<int,QString> _divideType; //划分段数名对照
|
||||
WizardBayContentDlg* _bayContentDlg;
|
||||
DiagramEditorBaySettingDlg* _baySettingDlg;
|
||||
QMap<int,DiagramEditorWizardBusInfo> _mapBus; //母线信息
|
||||
|
||||
QMap<int,QMap<int,DiagramEditorStructContainer*>> _mapSturctContainer; //划分后的区块
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include <QTableWidget>
|
||||
#include "global.h"
|
||||
|
||||
class DiagramEditorWizard;
|
||||
|
||||
class WizardBayContentDlg: public QTableWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -15,8 +17,15 @@ public:
|
|||
void initial();
|
||||
void addBay(DiagramEditorWizardBayInfo);
|
||||
void clearData();
|
||||
void flushData(int nLevel); //使用选中层级数据刷新界面
|
||||
void setParent(DiagramEditorWizard* p) {_pWizard = p;}
|
||||
public slots:
|
||||
void onDeleteClicked();
|
||||
void onModifyClicked();
|
||||
void onIndexRbtnClicked(const QPoint &pos); //索引列表右键菜单
|
||||
private:
|
||||
int _curPageIndex;
|
||||
int _curLevel;
|
||||
DiagramEditorWizard* _pWizard;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,10 +11,13 @@ DiagramEditorBaseBlock::~DiagramEditorBaseBlock()
|
|||
|
||||
}
|
||||
|
||||
void DiagramEditorBaseBlock::addConnect(const QString& str,int n)
|
||||
void DiagramEditorBaseBlock::addConnect(const QString& str,int n,bool bCover)
|
||||
{
|
||||
if(!bCover){
|
||||
if(str == sName)
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto& con:lstCon){
|
||||
if(con.con1.sName == str || con.con2.sName == str){ //已存在不插入
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,174 @@
|
|||
#include <QMessageBox>
|
||||
#include "diagramEditor/diagramEditorBaySettingDlg.h"
|
||||
#include "diagramEditor/diagramEditorWizard.h"
|
||||
#include "diagramEditor/diagramEditorBaseBlock.h"
|
||||
#include "ui_diagramEditorBaySettingDlg.h"
|
||||
#include "diagramEditor/diagramEditorStructContainer.h"
|
||||
#include "diagramEditor/wizardBayContentDlg.h"
|
||||
|
||||
DiagramEditorBaySettingDlg::DiagramEditorBaySettingDlg(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::diagramEditorBaySettingDlg)
|
||||
,_curOperateBlock(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||
initial();
|
||||
}
|
||||
|
||||
DiagramEditorBaySettingDlg::~DiagramEditorBaySettingDlg()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::showDlg(int nLevel)
|
||||
{
|
||||
_curModel = 0;
|
||||
show();
|
||||
addNewBay();
|
||||
if(_pWizard){
|
||||
auto mapBus = _pWizard->getMapBusInfo();
|
||||
double d = mapBus.value(nLevel).dVoltage;
|
||||
ui->le_name->setText(QString::number(d)+"kV");
|
||||
ui->cb_level->setCurrentIndex(nLevel);
|
||||
}
|
||||
_curLevel = nLevel;
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::showDlg(int nLevel,DiagramEditorBayBlock* p)
|
||||
{
|
||||
_curModel = 1;
|
||||
if(_curOperateBlock == nullptr)
|
||||
_curOperateBlock = p;
|
||||
show();
|
||||
addNewBay();
|
||||
if(_pWizard){
|
||||
ui->le_name->setText(p->getName());
|
||||
ui->cb_level->setCurrentIndex(nLevel);
|
||||
if(p){
|
||||
auto lstCon = p->getConnect();
|
||||
QStringList lst;
|
||||
for(auto& con:lstCon){
|
||||
QString sOppo = con.getOppositeName(p->getName());
|
||||
lst.append(sOppo);
|
||||
}
|
||||
ui->listWidget->addItems(lst);
|
||||
}
|
||||
}
|
||||
_curLevel = nLevel;
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::addNewBay()
|
||||
{
|
||||
ui->cb_type->setCurrentIndex(0);
|
||||
ui->cb_level->clear();
|
||||
ui->cb_target->clear();
|
||||
ui->listWidget->clear();
|
||||
if(_pWizard){
|
||||
auto mapAllCon = _pWizard->getCointainerStruct();
|
||||
for(auto iter = mapAllCon.begin();iter != mapAllCon.end();++iter){
|
||||
ui->cb_level->addItem("第"+QString::number(iter.key()+1)+"层",iter.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::initial()
|
||||
{
|
||||
_curModel = 0;
|
||||
_curLevel = 0;
|
||||
connect(ui->btn_add,&QPushButton::clicked,this,&DiagramEditorBaySettingDlg::onAddClicked);
|
||||
connect(ui->btn_delete,&QPushButton::clicked,this,&DiagramEditorBaySettingDlg::onDeleteClicked);
|
||||
connect(ui->btn_ok,&QPushButton::clicked,this,&DiagramEditorBaySettingDlg::onOkClicked);
|
||||
connect(ui->btn_cancel,&QPushButton::clicked,this,&DiagramEditorBaySettingDlg::onCancelClicked);
|
||||
connect(ui->cb_level,&QComboBox::currentTextChanged,this,&DiagramEditorBaySettingDlg::onConnectLevelChanged);
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::onAddClicked()
|
||||
{
|
||||
//auto pItem = ui->listWidget->currentItem();
|
||||
QString str = ui->cb_target->currentText();
|
||||
auto lst = ui->listWidget->findItems(str,Qt::MatchExactly);
|
||||
if(lst.size() == 0){ //为空才添加
|
||||
ui->listWidget->addItem(str);
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::onDeleteClicked()
|
||||
{
|
||||
int n = ui->listWidget->currentRow();
|
||||
if(n){
|
||||
auto pItem = ui->listWidget->takeItem(n);
|
||||
delete pItem;
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::onOkClicked()
|
||||
{
|
||||
QString sName = ui->le_name->text();
|
||||
BayType nType = BayType(ui->cb_type->currentIndex());
|
||||
if(_curModel == 0){
|
||||
if(_pWizard){
|
||||
auto map = _pWizard->getMapBusInfo();
|
||||
for(auto iter = map.begin();iter != map.end();++iter){
|
||||
auto lstBlock = _pWizard->getTargetLevelBlocks(iter.key(),2);
|
||||
for(auto bay:lstBlock)
|
||||
{
|
||||
if(bay->getName() == sName){ //判断间隔存在
|
||||
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"间隔名已存在"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList lst;
|
||||
for(int i = 0;i < ui->listWidget->count();++i){
|
||||
lst.append(ui->listWidget->item(i)->text());
|
||||
}
|
||||
|
||||
DiagramEditorWizardBayInfo info;
|
||||
info.sName = sName;
|
||||
info.nType = nType;
|
||||
info.lstBindObj = lst;
|
||||
|
||||
_pWizard->onAddBayFinished(info);
|
||||
}
|
||||
}
|
||||
else if(_curModel == 1){
|
||||
if(_curOperateBlock){
|
||||
_curOperateBlock->setName(sName);
|
||||
_curOperateBlock->setBayType(nType);
|
||||
_curOperateBlock->clearConnect();
|
||||
|
||||
for(int i = 0;i < ui->listWidget->count();++i){
|
||||
_curOperateBlock->addConnect(ui->listWidget->item(i)->text(),1,true);
|
||||
}
|
||||
|
||||
auto pContent = _pWizard->getContentDlg();
|
||||
pContent->flushData(_curLevel);
|
||||
_curOperateBlock = nullptr;
|
||||
}
|
||||
}
|
||||
hide();
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::onCancelClicked()
|
||||
{
|
||||
hide();
|
||||
if(_curOperateBlock)
|
||||
_curOperateBlock = nullptr;
|
||||
}
|
||||
|
||||
void DiagramEditorBaySettingDlg::onConnectLevelChanged(const QString& str)
|
||||
{
|
||||
if(_pWizard){
|
||||
int n = ui->cb_level->findText(str);
|
||||
if(n != -1){
|
||||
ui->cb_target->clear();
|
||||
int nIndex = ui->cb_level->itemData(n).toInt();
|
||||
auto lstBlock = _pWizard->getTargetLevelBlocks(nIndex,1);
|
||||
for(auto& block:lstBlock){
|
||||
ui->cb_target->addItem(block->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,10 +6,12 @@
|
|||
#include "diagramEditor/wizardBayContentDlg.h"
|
||||
#include "diagramEditor/diagramEditorBaseBlock.h"
|
||||
#include "diagramEditor/diagramEditorStructContainer.h"
|
||||
#include "diagramEditor/diagramEditorBaySettingDlg.h"
|
||||
|
||||
DiagramEditorWizard::DiagramEditorWizard(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::diagramEditorWizard)
|
||||
,_baySettingDlg(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
_busPageChanged = false;
|
||||
|
|
@ -25,6 +27,7 @@ DiagramEditorWizard::~DiagramEditorWizard()
|
|||
void DiagramEditorWizard::initial()
|
||||
{
|
||||
_bayContentDlg = new WizardBayContentDlg(this);
|
||||
_bayContentDlg->setParent(this);
|
||||
ui->stackedWidget->addWidget(_bayContentDlg);
|
||||
ui->tabWidget->tabBar()->setEnabled(false);
|
||||
connect(ui->btn_ok,&QPushButton::clicked,this,&DiagramEditorWizard::onOkClicked);
|
||||
|
|
@ -50,6 +53,8 @@ void DiagramEditorWizard::initial()
|
|||
connect(delegate,&WizardBusTableDelegate::editingFinished,this,&DiagramEditorWizard::onDelegateFinishEdit);
|
||||
connect(ui->tableWidget_bus, &QTableWidget::customContextMenuRequested, this, &DiagramEditorWizard::onBusIndexRbtnClicked);
|
||||
|
||||
connect(ui->listWidget_bay,&QListWidget::itemClicked,this,&DiagramEditorWizard::onBayListSelected);
|
||||
|
||||
_divideType.insert(1,"A段");
|
||||
_divideType.insert(2,"B段");
|
||||
_divideType.insert(3,"C段");
|
||||
|
|
@ -72,10 +77,13 @@ void DiagramEditorWizard::reOrderBus()
|
|||
}
|
||||
}
|
||||
|
||||
void DiagramEditorWizard::generateBayPage()
|
||||
void DiagramEditorWizard::generateBayStruct()
|
||||
{
|
||||
for(auto iter = _mapBus.begin();iter != _mapBus.end();++iter)
|
||||
{
|
||||
if(!iter->bChanged) //只生成修改过的程序
|
||||
continue;
|
||||
iter->bChanged = false;
|
||||
QListWidgetItem* item = new QListWidgetItem("第"+QString::number(iter->nIndex+1)+"层");
|
||||
item->setData(Qt::UserRole,iter->nIndex);
|
||||
ui->listWidget_bay->addItem(item);
|
||||
|
|
@ -185,6 +193,11 @@ void DiagramEditorWizard::generateBayPage()
|
|||
}
|
||||
}
|
||||
|
||||
void DiagramEditorWizard::showSelectedBayPage(int nIdx)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template <typename T> void DiagramEditorWizard::reindexQMap(QMap<int, T> &map) {
|
||||
if (map.isEmpty())
|
||||
return;
|
||||
|
|
@ -237,7 +250,17 @@ void DiagramEditorWizard::onNextClicked()
|
|||
ui->stackedWidget_last->setCurrentIndex(1);
|
||||
ui->stackedWidget_next->setCurrentIndex(0);
|
||||
|
||||
|
||||
generateBayStruct();
|
||||
if(ui->listWidget_bay->count()){
|
||||
QListWidgetItem* targetItem = ui->listWidget_bay->item(0);
|
||||
// 确保项有效
|
||||
if (targetItem) {
|
||||
// 手动发射itemClicked信号
|
||||
emit ui->listWidget_bay->itemClicked(targetItem);
|
||||
// 如果需要同时选中该项
|
||||
ui->listWidget_bay->setCurrentItem(targetItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(ui->tabWidget->currentIndex() == 1){
|
||||
ui->tabWidget->setCurrentIndex(2);
|
||||
|
|
@ -274,12 +297,17 @@ void DiagramEditorWizard::onAddBusClicked()
|
|||
|
||||
DiagramEditorWizardBusInfo info;
|
||||
info.nIndex = row;
|
||||
info.bChanged = true;
|
||||
_mapBus.insert(row,info);
|
||||
}
|
||||
|
||||
void DiagramEditorWizard::onAddBayClicked()
|
||||
{
|
||||
|
||||
if(_baySettingDlg == nullptr){
|
||||
_baySettingDlg = new DiagramEditorBaySettingDlg(this);
|
||||
_baySettingDlg->setParent(this);
|
||||
}
|
||||
_baySettingDlg->showDlg(ui->listWidget_bay->currentItem()->data(Qt::UserRole).toInt());
|
||||
}
|
||||
|
||||
void DiagramEditorWizard::onAddTransClicked()
|
||||
|
|
@ -287,6 +315,28 @@ void DiagramEditorWizard::onAddTransClicked()
|
|||
|
||||
}
|
||||
|
||||
void DiagramEditorWizard::onAddBayFinished(DiagramEditorWizardBayInfo info)
|
||||
{
|
||||
int curIndex = ui->listWidget_bay->currentItem()->data(Qt::UserRole).toInt(); //当前层级
|
||||
|
||||
if(!info.lstBindObj.isEmpty()){
|
||||
auto pContainer = getContainerByBlock(curIndex,1,info.lstBindObj.first());
|
||||
|
||||
DiagramEditorBayBlock* pBlock = new DiagramEditorBayBlock(this);
|
||||
pBlock->setName(info.sName);
|
||||
pBlock->setType(2);
|
||||
pBlock->setBayType(info.nType);
|
||||
|
||||
for(auto& sName:info.lstBindObj){
|
||||
pBlock->addConnect(sName,1);
|
||||
}
|
||||
|
||||
pContainer->insertBlock(3,pBlock);
|
||||
|
||||
_bayContentDlg->flushData(curIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramEditorWizard::onDelegateFinishEdit(const QModelIndex &index, const QString &value)
|
||||
{
|
||||
int row = index.row();
|
||||
|
|
@ -385,3 +435,77 @@ void DiagramEditorWizard::onBusIndexRbtnClicked(const QPoint &pos)
|
|||
// 在点击位置显示菜单
|
||||
menu.exec(ui->tableWidget_bus->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void DiagramEditorWizard::onBayListSelected(QListWidgetItem* pItem)
|
||||
{
|
||||
int nIndex = pItem->data(Qt::UserRole).toInt();
|
||||
ui->label_level->setText("第"+QString::number(nIndex+1)+"层");
|
||||
_bayContentDlg->flushData(nIndex);
|
||||
}
|
||||
|
||||
QList<DiagramEditorBaseBlock*> DiagramEditorWizard::getTargetLevelBlocks(int nLevel,int nType)
|
||||
{
|
||||
QList<DiagramEditorBaseBlock*> lstBlock;
|
||||
for(auto iter = _mapSturctContainer.begin();iter != _mapSturctContainer.end();++iter){
|
||||
if(iter.key() == nLevel){
|
||||
for(auto& container:iter.value())
|
||||
{
|
||||
auto mapBlock = container->getBlockMap();
|
||||
for(auto& lst:mapBlock)
|
||||
{
|
||||
for(auto& block:lst)
|
||||
{
|
||||
if(block->getType() == nType){ //返回对应type
|
||||
lstBlock.append(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return lstBlock;
|
||||
}
|
||||
|
||||
DiagramEditorStructContainer* DiagramEditorWizard::getContainerByBlock(int nLevel,int nType,QString sName)
|
||||
{
|
||||
DiagramEditorStructContainer* pContainer = nullptr;
|
||||
auto lstBlock = getTargetLevelBlocks(nLevel,nType);
|
||||
for(auto& block:lstBlock){
|
||||
if(block->getName() == sName){
|
||||
pContainer = block->getCurContainer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pContainer;
|
||||
}
|
||||
|
||||
DiagramEditorBaseBlock* DiagramEditorWizard::getBlockByName(int nLevel,int nType,QString sName)
|
||||
{
|
||||
DiagramEditorBaseBlock* pBlock = nullptr;
|
||||
auto lstBlock = getTargetLevelBlocks(nLevel,nType);
|
||||
for(auto& block:lstBlock){
|
||||
if(block->getName() == sName){
|
||||
return block;
|
||||
}
|
||||
}
|
||||
return pBlock;
|
||||
}
|
||||
|
||||
bool DiagramEditorWizard::removeBlockByName(int nLevel,int nType,const QString& sName)
|
||||
{
|
||||
DiagramEditorStructContainer* pCon = getContainerByBlock(nLevel,nType,sName);
|
||||
if(pCon){
|
||||
auto& mapBlock = pCon->getBlockMap();
|
||||
for(auto& lst:mapBlock){
|
||||
|
||||
for(int i = 0;i< lst.size();++i){
|
||||
if(lst[i]->getName() == sName){
|
||||
delete lst[i];
|
||||
lst.removeAt(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
#include "diagramEditor/wizardBayContentDlg.h"
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include "diagramEditor/wizardBayContentDlg.h"
|
||||
#include "diagramEditor/diagramEditorWizard.h"
|
||||
#include "diagramEditor/diagramEditorBaseBlock.h"
|
||||
#include "diagramEditor/diagramEditorStructContainer.h"
|
||||
#include "diagramEditor/diagramEditorBaySettingDlg.h"
|
||||
|
||||
WizardBayContentDlg::WizardBayContentDlg(QWidget *parent)
|
||||
: QTableWidget(parent)
|
||||
,_pWizard(nullptr)
|
||||
{
|
||||
initial();
|
||||
}
|
||||
|
|
@ -13,7 +19,7 @@ WizardBayContentDlg::~WizardBayContentDlg()
|
|||
|
||||
void WizardBayContentDlg::initial()
|
||||
{
|
||||
_curPageIndex = 0;
|
||||
_curLevel = 0;
|
||||
QStringList headerText;
|
||||
headerText<<"间隔名称"<<"间隔类型"<<"连接对象";
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
|
@ -22,6 +28,8 @@ void WizardBayContentDlg::initial()
|
|||
setColumnCount(headerText.count());
|
||||
setHorizontalHeaderLabels(headerText);
|
||||
horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
verticalHeader()->setVisible(false);
|
||||
connect(this, &QTableWidget::customContextMenuRequested, this, &WizardBayContentDlg::onIndexRbtnClicked);
|
||||
}
|
||||
|
||||
void WizardBayContentDlg::addBay(DiagramEditorWizardBayInfo obj)
|
||||
|
|
@ -70,5 +78,113 @@ void WizardBayContentDlg::addBay(DiagramEditorWizardBayInfo obj)
|
|||
|
||||
void WizardBayContentDlg::clearData()
|
||||
{
|
||||
clear();
|
||||
clearContents();
|
||||
setRowCount(0);
|
||||
}
|
||||
|
||||
void WizardBayContentDlg::flushData(int nLevel)
|
||||
{
|
||||
clearData();
|
||||
if(_pWizard){
|
||||
QList<DiagramEditorBaseBlock*> lst = _pWizard->getTargetLevelBlocks(nLevel,2);
|
||||
for(auto& block:lst){
|
||||
auto pItem = dynamic_cast<DiagramEditorBayBlock*>(block);
|
||||
if(pItem){
|
||||
DiagramEditorWizardBayInfo info;
|
||||
info.sName = pItem->getName();
|
||||
info.nType = pItem->getBayType();
|
||||
auto lstCon = pItem->getConnect(); //获取间隔所连对象的名称
|
||||
for(auto& con:lstCon){
|
||||
QString sOpposite = con.getOppositeName(pItem->getName());
|
||||
info.lstBindObj.append(sOpposite);
|
||||
}
|
||||
|
||||
addBay(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
_curLevel = nLevel;
|
||||
}
|
||||
|
||||
void WizardBayContentDlg::onDeleteClicked()
|
||||
{
|
||||
// 获取当前选中的索引
|
||||
QModelIndexList selectedIndexes = this->selectionModel()->selectedRows();
|
||||
if (selectedIndexes.isEmpty()) {
|
||||
return; // 没有选中任何行
|
||||
}
|
||||
|
||||
// 获取当前选中的第一项索引
|
||||
QModelIndex index = selectedIndexes.first();
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex indexName = index.sibling(index.row(),0);
|
||||
QString sName = indexName.data().toString();
|
||||
if(_pWizard){
|
||||
bool res = _pWizard->removeBlockByName(_curLevel,2,sName);
|
||||
if(res){
|
||||
flushData(_curLevel);
|
||||
}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int currentRow = this->currentRow();
|
||||
if (currentRow == -1) {
|
||||
return; // 没有选中行
|
||||
}
|
||||
|
||||
this->removeRow(currentRow);
|
||||
}
|
||||
|
||||
void WizardBayContentDlg::onModifyClicked()
|
||||
{
|
||||
// 获取当前选中的索引
|
||||
QModelIndexList selectedIndexes = this->selectionModel()->selectedRows();
|
||||
if (selectedIndexes.isEmpty()) {
|
||||
return; // 没有选中任何行
|
||||
}
|
||||
|
||||
// 获取当前选中的第一项索引
|
||||
QModelIndex index = selectedIndexes.first();
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex indexName = index.sibling(index.row(),0);
|
||||
QString sName = indexName.data().toString();
|
||||
|
||||
if(_pWizard){
|
||||
DiagramEditorBaseBlock* pBlock = _pWizard->getBlockByName(_curLevel,2,sName);
|
||||
if(pBlock){
|
||||
auto pBay = dynamic_cast<DiagramEditorBayBlock*>(pBlock);
|
||||
if(pBay)
|
||||
_pWizard->getBaySettingDlg()->showDlg(_curLevel,pBay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WizardBayContentDlg::onIndexRbtnClicked(const QPoint &pos)
|
||||
{
|
||||
// 获取当前点击的位置对应的索引
|
||||
QModelIndex index = this->indexAt(pos);
|
||||
if (!index.isValid()) {
|
||||
return; // 如果点击的是空白区域,直接返回
|
||||
}
|
||||
|
||||
QMenu menu;
|
||||
QAction *deleteAction = new QAction("移除间隔", this);
|
||||
QAction *modifyAction = new QAction("修改间隔", this);
|
||||
menu.addAction(deleteAction);
|
||||
menu.addAction(modifyAction);
|
||||
|
||||
// 连接删除菜单项的触发信号与槽函数
|
||||
connect(deleteAction, &QAction::triggered, this, &WizardBayContentDlg::onDeleteClicked);
|
||||
connect(modifyAction, &QAction::triggered, this, &WizardBayContentDlg::onModifyClicked);
|
||||
|
||||
// 在点击位置显示菜单
|
||||
menu.exec(this->mapToGlobal(pos));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,293 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>diagramEditorBaySettingDlg</class>
|
||||
<widget class="QDialog" name="diagramEditorBaySettingDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<height>425</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(196, 196, 196);</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(0, 0, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置间隔</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>460</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>基本信息</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0,1">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>间隔名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_name"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>间隔类型</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_type">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>分段间隔</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>母联间隔</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>PT间隔</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>进线间隔</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>出线间隔</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>无功补偿间隔</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>旁路间隔</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>主变间隔</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>连接信息</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,1">
|
||||
<property name="horizontalSpacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="1,2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>连接位置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cb_level"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>连接对象</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cb_target"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_add">
|
||||
<property name="text">
|
||||
<string>添加</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_delete">
|
||||
<property name="text">
|
||||
<string>删除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>连接列表</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>155</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_ok">
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_cancel">
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Reference in New Issue