2025-10-29 17:23:30 +08:00
|
|
|
|
#include "preqtablewidget.h"
|
|
|
|
|
|
#include <QMouseEvent>
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
#include <QMimeData>
|
|
|
|
|
|
#include <QDrag>
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
|
|
|
|
#include "CallManage.h"
|
|
|
|
|
|
#include "PropertyWidget.h"
|
|
|
|
|
|
|
|
|
|
|
|
//针对曲线
|
|
|
|
|
|
PreQTableWidget::PreQTableWidget(QWidget *parent) :
|
|
|
|
|
|
QTableWidget(parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(ChangedItem()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreQTableWidget::mousePressEvent(QMouseEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"PreQTableWidget mousePressEvent";
|
|
|
|
|
|
|
|
|
|
|
|
if (event->button() == Qt::LeftButton)
|
|
|
|
|
|
{
|
|
|
|
|
|
startPos = event->pos();
|
|
|
|
|
|
m_press = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
QTableWidget::mousePressEvent(event);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreQTableWidget::ChangedItem()
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"PreQTableWidget itemSelectionChanged!";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreQTableWidget::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"PreQTableWidget mouseMoveEvent";
|
|
|
|
|
|
|
|
|
|
|
|
if (event->buttons() & Qt::LeftButton)
|
|
|
|
|
|
{
|
|
|
|
|
|
int distance = (event->pos() - startPos).manhattanLength();
|
|
|
|
|
|
if (distance >= QApplication::startDragDistance())
|
|
|
|
|
|
{
|
|
|
|
|
|
performDrag();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
QTableWidget::mouseMoveEvent(event);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreQTableWidget::dragEnterEvent(QDragEnterEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"PreQTableWidget dragEnterEvent";
|
|
|
|
|
|
|
|
|
|
|
|
PreQTableWidget *source = qobject_cast<PreQTableWidget *>(event->source());
|
|
|
|
|
|
if (source && source != this) {
|
|
|
|
|
|
event->setDropAction(Qt::MoveAction);
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
QMyTreeWidget *sourceTree = qobject_cast<QMyTreeWidget *>(event->source());
|
|
|
|
|
|
if (sourceTree) {
|
|
|
|
|
|
event->setDropAction(Qt::MoveAction);
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreQTableWidget::dragMoveEvent(QDragMoveEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"PreQTableWidget dragMoveEvent";
|
|
|
|
|
|
|
|
|
|
|
|
PreQTableWidget *source = qobject_cast<PreQTableWidget *>(event->source());
|
|
|
|
|
|
if (source && source != this) {
|
|
|
|
|
|
event->setDropAction(Qt::MoveAction);
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
QMyTreeWidget *sourceTree = qobject_cast<QMyTreeWidget *>(event->source());
|
|
|
|
|
|
if (sourceTree) {
|
|
|
|
|
|
event->setDropAction(Qt::MoveAction);
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreQTableWidget::dropEvent(QDropEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"PreQTableWidget dropEvent";
|
|
|
|
|
|
|
|
|
|
|
|
PreQTableWidget *source = qobject_cast<PreQTableWidget *>(event->source());
|
|
|
|
|
|
if (source && source != this) {
|
|
|
|
|
|
|
|
|
|
|
|
QString strExtern = event->mimeData()->text();
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
|
2025-11-21 10:14:28 +08:00
|
|
|
|
if (list.size() > 3)
|
2025-10-29 17:23:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
QString strSlfName = list[0];
|
|
|
|
|
|
QString strWellName = list[1];
|
|
|
|
|
|
QString strLineName = list[2];
|
2025-11-21 10:14:28 +08:00
|
|
|
|
QString strType = list[3];
|
2025-10-29 17:23:30 +08:00
|
|
|
|
|
2025-11-21 10:14:28 +08:00
|
|
|
|
qDebug() << "source strSlfName:" << strSlfName<< " strWellName:" << strWellName << " strLineName:" << strLineName << " strType:" << strType;
|
2025-10-29 17:23:30 +08:00
|
|
|
|
if(m_strWellName == strWellName)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_AddSuc = true;
|
2025-11-21 10:14:28 +08:00
|
|
|
|
|
|
|
|
|
|
if(strType=="curveObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//新建曲线
|
|
|
|
|
|
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(strType=="waveObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//新建波列
|
|
|
|
|
|
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
|
|
|
|
|
}
|
2025-11-25 17:56:20 +08:00
|
|
|
|
else if(strType=="tableObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//新建表格曲线
|
|
|
|
|
|
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
|
|
|
|
|
}
|
2025-10-29 17:23:30 +08:00
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
//m_listLineName.push_back(strLineName);
|
|
|
|
|
|
|
|
|
|
|
|
// 接受拖拽事件
|
|
|
|
|
|
event->setDropAction(Qt::MoveAction);
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// 如果井名不正确,不接受拖拽事件
|
|
|
|
|
|
event->ignore();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-11-21 10:14:28 +08:00
|
|
|
|
int rownum = rowCount();
|
|
|
|
|
|
setRowCount(rownum+1);
|
2025-10-29 17:23:30 +08:00
|
|
|
|
//
|
2025-11-21 10:14:28 +08:00
|
|
|
|
QTableWidgetItem* item = new QTableWidgetItem(strExtern);
|
|
|
|
|
|
item->setFlags(item->flags() & (~Qt::ItemIsEditable));
|
|
|
|
|
|
item->setTextAlignment(Qt::AlignCenter); //设置文本居中
|
|
|
|
|
|
//
|
|
|
|
|
|
setItem(rownum, 0, item);
|
2025-10-29 17:23:30 +08:00
|
|
|
|
|
2025-11-21 10:14:28 +08:00
|
|
|
|
//
|
|
|
|
|
|
event->setDropAction(Qt::MoveAction);
|
|
|
|
|
|
event->accept();
|
2025-10-29 17:23:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
QMyTreeWidget *sourceTree = qobject_cast<QMyTreeWidget *>(event->source());
|
|
|
|
|
|
if (sourceTree) {
|
|
|
|
|
|
|
|
|
|
|
|
QString strExtern = event->mimeData()->text();
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
|
2025-11-21 10:14:28 +08:00
|
|
|
|
if (list.size() > 3)
|
2025-10-29 17:23:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
QString strSlfName = list[0];
|
|
|
|
|
|
QString strWellName = list[1];
|
|
|
|
|
|
QString strLineName = list[2];
|
2025-11-21 10:14:28 +08:00
|
|
|
|
QString strType = list[3];
|
2025-10-29 17:23:30 +08:00
|
|
|
|
|
2025-11-21 10:14:28 +08:00
|
|
|
|
qDebug() << "sourceTree strSlfName:" << strSlfName<< " strWellName:" << strWellName << " strLineName:" << strLineName << " strType:" << strType;
|
2025-10-29 17:23:30 +08:00
|
|
|
|
if(m_strWellName == strWellName)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_AddSuc = true;
|
2025-11-21 10:14:28 +08:00
|
|
|
|
if(strType=="curveObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//新建曲线
|
|
|
|
|
|
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(strType=="waveObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//新建波列
|
|
|
|
|
|
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
|
|
|
|
|
}
|
2025-11-25 17:56:20 +08:00
|
|
|
|
else if(strType=="tableObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//新建表格曲线
|
|
|
|
|
|
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
|
|
|
|
|
}
|
2025-10-29 17:23:30 +08:00
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
//m_listLineName.push_back(strLineName);
|
|
|
|
|
|
|
|
|
|
|
|
// 接受拖拽事件
|
|
|
|
|
|
event->setDropAction(Qt::MoveAction);
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-11-18 11:40:42 +08:00
|
|
|
|
// 如果井名不正确,不接受拖拽事件
|
|
|
|
|
|
event->ignore();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-29 17:23:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreQTableWidget::performDrag()
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"PreQTableWidget performDrag!";
|
|
|
|
|
|
|
|
|
|
|
|
int iCurrentRow = currentRow();
|
|
|
|
|
|
if( cellWidget(iCurrentRow, 0) != nullptr )
|
|
|
|
|
|
{
|
|
|
|
|
|
auto myWidget = cellWidget(currentRow(), 0);
|
|
|
|
|
|
|
|
|
|
|
|
FormInfo *formInfo = (FormInfo*)myWidget;//获得widget
|
|
|
|
|
|
|
2025-11-21 10:14:28 +08:00
|
|
|
|
QString strType = formInfo->m_strType;
|
|
|
|
|
|
//if(strType == "curveObject" || strType == "waveObject")
|
2025-11-20 09:32:51 +08:00
|
|
|
|
{
|
|
|
|
|
|
//曲线对象(AC、BS...)
|
|
|
|
|
|
QMimeData *mimeData = new QMimeData;
|
|
|
|
|
|
// 这里需要根据你的item数据来设置mimeData,例如:
|
2025-11-21 10:14:28 +08:00
|
|
|
|
mimeData->setText(formInfo->m_strSlfName + "#@@#"+ formInfo->m_strWellName + "#@@#" +formInfo->m_strLineName + "#@@#" + strType);
|
2025-11-20 09:32:51 +08:00
|
|
|
|
// 创建QDrag对象
|
|
|
|
|
|
QDrag *drag = new QDrag(this);
|
|
|
|
|
|
drag->setMimeData(mimeData);
|
|
|
|
|
|
// 可以设置拖拽时的光标图标
|
|
|
|
|
|
QRect itemRect = visualItemRect(currentItem()); // 获取项的矩形区域
|
|
|
|
|
|
QPixmap itemPixmap = QWidget::grab(itemRect);//QPixmap::grabWidget(this, itemRect); // 获取项的屏幕截图
|
|
|
|
|
|
// 调整拖拽光标的热点,使其位于截图的中心
|
|
|
|
|
|
drag->setPixmap(itemPixmap);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行拖拽操作
|
|
|
|
|
|
m_AddSuc = false;
|
|
|
|
|
|
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
|
|
|
|
|
|
if (dropAction == Qt::MoveAction) { //&& m_AddSuc
|
|
|
|
|
|
// 处理拖拽结束的逻辑,例如从界面上移除拖拽的项
|
|
|
|
|
|
removeRow(iCurrentRow);
|
2025-11-21 10:14:28 +08:00
|
|
|
|
if(strType=="curveObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//删除曲线
|
|
|
|
|
|
emit CallManage::getInstance()->sig_delLine(m_strUuid, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(strType=="waveObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//删除波列
|
|
|
|
|
|
emit CallManage::getInstance()->sig_delWave(m_strUuid, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName);
|
|
|
|
|
|
}
|
2025-11-25 17:56:20 +08:00
|
|
|
|
else if(strType=="tableObject")
|
|
|
|
|
|
{
|
|
|
|
|
|
//删除波列
|
|
|
|
|
|
emit CallManage::getInstance()->sig_delTableLine(m_strUuid, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName);
|
|
|
|
|
|
}
|
2025-11-20 09:32:51 +08:00
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
//m_listLineName.removeOne(formInfo->m_strLineName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-29 17:23:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if(!currentItem())
|
|
|
|
|
|
// {
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// QString strExtern = currentItem()->text();
|
|
|
|
|
|
|
|
|
|
|
|
// QMimeData *mimeData = new QMimeData;
|
|
|
|
|
|
// mimeData->setText(strExtern);
|
|
|
|
|
|
|
|
|
|
|
|
// QDrag *drag = new QDrag(this);
|
|
|
|
|
|
// drag->setMimeData(mimeData);
|
|
|
|
|
|
// if (drag->exec(Qt::MoveAction) == Qt::MoveAction){
|
|
|
|
|
|
// qDebug()<<"Success!";
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PreQTableWidget::mouseReleaseEvent(QMouseEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_press)//如果鼠标左键被释放
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"PreQTableWidget mouseReleaseEvent";
|
|
|
|
|
|
|
|
|
|
|
|
m_press = false;//按下标志置fasle,形成互斥
|
|
|
|
|
|
|
|
|
|
|
|
int iCurrentRow = currentRow();
|
|
|
|
|
|
qDebug()<<"PreQTableWidget mouseReleaseEvent, iCurrentRow=" << QString::number(iCurrentRow);
|
|
|
|
|
|
if( cellWidget(iCurrentRow, 0) != nullptr )
|
|
|
|
|
|
{
|
|
|
|
|
|
auto myWidget = cellWidget(currentRow(), 0);
|
|
|
|
|
|
|
|
|
|
|
|
FormInfo *formInfo = (FormInfo*)myWidget;//获得widget
|
|
|
|
|
|
//
|
|
|
|
|
|
QList<float> listMin;
|
|
|
|
|
|
QList<float> listMax;
|
2025-11-05 18:15:33 +08:00
|
|
|
|
QStringList strListOtherScaleType;
|
|
|
|
|
|
QStringList strListOtherLine = getListLineName(formInfo->m_strLineName, listMin, listMax, strListOtherScaleType);
|
2025-10-29 17:23:30 +08:00
|
|
|
|
//PropertyService()->initCurveProperty(formInfo->m_strSlfName, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName, formInfo->m_lineColor, formInfo->m_dWidth, strListOtherLine);
|
|
|
|
|
|
|
2025-12-12 20:10:30 +08:00
|
|
|
|
if(formInfo->m_strType == "depthObject")
|
|
|
|
|
|
PropertyService()->initDepthProperty(formInfo);
|
|
|
|
|
|
else
|
|
|
|
|
|
PropertyService()->initCurveProperty(formInfo, strListOtherLine, listMin, listMax, strListOtherScaleType);
|
2025-10-29 17:23:30 +08:00
|
|
|
|
|
|
|
|
|
|
//曲线置顶显示,激活可选
|
2025-11-04 14:44:14 +08:00
|
|
|
|
emit CallManage::getInstance()->sig_Raise(m_strUuid, formInfo->m_strSlfName, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName);
|
2025-10-29 17:23:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 18:15:33 +08:00
|
|
|
|
QStringList PreQTableWidget::getListLineName(QString strLineName, QList<float> &listMin, QList<float> &listMax, QStringList &strListOtherScaleType)
|
2025-10-29 17:23:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
QStringList strListOtherLine;
|
|
|
|
|
|
for(int i=0; i<rowCount(); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( cellWidget(i, 0) != nullptr )
|
|
|
|
|
|
{
|
|
|
|
|
|
auto myWidget = cellWidget(i, 0);
|
|
|
|
|
|
|
|
|
|
|
|
FormInfo *formInfo = (FormInfo*)myWidget;//获得widget
|
|
|
|
|
|
QString strTmp = formInfo->m_strLineName;
|
|
|
|
|
|
if(strTmp!=strLineName)
|
|
|
|
|
|
{
|
|
|
|
|
|
strListOtherLine.push_back(strTmp);
|
|
|
|
|
|
listMin.push_back(formInfo->m_vmin);
|
|
|
|
|
|
listMax.push_back(formInfo->m_vmax);
|
2025-11-05 18:15:33 +08:00
|
|
|
|
strListOtherScaleType.push_back(formInfo->m_strScaleType);
|
2025-10-29 17:23:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return strListOtherLine;
|
|
|
|
|
|
}
|