多选删除,删除井次删除井;重命名曲线,重命名表格,重命名参数卡,重命名波列
This commit is contained in:
parent
c97223e698
commit
af7dec1446
|
|
@ -187,6 +187,7 @@ QString toString(QString cs);
|
|||
QString toString(int value,char f='f',int dem=3,bool iscut=1,bool ise=true);
|
||||
QString toString(float value,char f='f',int dem=3,bool iscut=1,bool ise=true);
|
||||
QString toString(double value,char f='f',int dem=3,bool iscut=1,bool ise=true);
|
||||
bool IsValidNmae(QString wellname);
|
||||
QString setdec(QString text,int dec=2,bool all=false);
|
||||
QStringList GetSimilarCurves(QString curvename,char *INI=NULL,bool isEQU=true);
|
||||
QString GetImagePath();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "qmytreewidget.h"
|
||||
#include "ObjWellLog.h"
|
||||
#include<QMessageBox>
|
||||
|
||||
QMyTreeWidget::QMyTreeWidget(QWidget *parent)
|
||||
{
|
||||
|
|
@ -36,7 +38,44 @@ QString QMyTreeWidget::getCurrentItemString()
|
|||
}
|
||||
return sret;
|
||||
}
|
||||
|
||||
void QMyTreeWidget::closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint )
|
||||
{
|
||||
QTreeWidget::closeEditor(editor,hint);
|
||||
QTreeWidgetItem *item = this->currentItem();
|
||||
QString strSlfName = item->data(0, Qt::UserRole+1).toString();
|
||||
QString strOldName = item->data(0, Qt::UserRole + 3).toString();
|
||||
QString strNewName = item->text(0).toUpper();
|
||||
if(!IsValidNmae(strNewName))
|
||||
{
|
||||
QString value="A~Za~z0~9#_-*\nαβγδεζηθικλμνξοπρστυφχψ";
|
||||
QMessageBox::warning(NULL,"非法命名",strNewName+"不符合命名规则\r\n仅支持下列符号:\n"+value);
|
||||
this->currentItem()->setText(0,strOldName);
|
||||
// this->setItemSelected(item,true);
|
||||
return;
|
||||
}
|
||||
//whp 2020.7.19end
|
||||
if(strOldName==strNewName) {
|
||||
return;
|
||||
}
|
||||
QString strTreeTag = item->data(0, Qt::UserRole).toString();
|
||||
CObjWellLog* pcopyingwelllog= new CObjWellLog();
|
||||
pcopyingwelllog->SetSlfFileName(strSlfName);
|
||||
pcopyingwelllog->SetName(strOldName);
|
||||
if(!pcopyingwelllog->RenName(strNewName))
|
||||
{
|
||||
this->currentItem()->setText(0,strOldName);
|
||||
// pObj->SetName(strOldName);
|
||||
// AfxMessageBox("无法改名,可能因重名等问题所致!");
|
||||
QMessageBox::information(NULL, "提示", "无法改名,可能因重名等问题所致!");
|
||||
}
|
||||
//else {
|
||||
//::GetObjectEvent().OnDeAttchData(pObj->GetSlfFileName(),strOldName);
|
||||
//::GetObjectEvent().OnRefreshData(pObj->GetSlfFileName(),strNewName);
|
||||
//}
|
||||
delete pcopyingwelllog;
|
||||
item->setData(0, Qt::UserRole + 3, strNewName); // 存储额外数据,波列卡
|
||||
return;
|
||||
}
|
||||
void QMyTreeWidget::startDrag(Qt::DropActions supportedActions)
|
||||
{
|
||||
if(currentItem()->parent()==NULL)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public:
|
|||
QString getCurrentItemString();
|
||||
protected:
|
||||
virtual void startDrag(Qt::DropActions supportedActions);
|
||||
virtual void closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint );
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -505,6 +505,7 @@ void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, Q
|
|||
itemSheetChild->setData(0, Qt::UserRole, "tableObject"); // 存储额外数据,如ID
|
||||
itemSheetChild->setData(0, Qt::UserRole + 1, fileFull); // 存储额外数据,井次文件路径
|
||||
itemSheetChild->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||||
itemSheetChild->setData(0, Qt::UserRole + 3, strCurveName); // 存储额外数据,表格名
|
||||
//
|
||||
itemSheetChild->setIcon(0, iconSheet);
|
||||
//在创建的每个节点下,加上下面代码
|
||||
|
|
@ -583,6 +584,7 @@ void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, Q
|
|||
itemCurveLog->setData(0, Qt::UserRole, "curveObject"); // 存储额外数据,如ID
|
||||
itemCurveLog->setData(0, Qt::UserRole + 1, fileFull); // 存储额外数据,井次文件路径
|
||||
itemCurveLog->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||||
itemCurveLog->setData(0, Qt::UserRole + 3, strCurveName); // 存储额外数据,曲线名
|
||||
//
|
||||
//
|
||||
QIcon iconLog;
|
||||
|
|
@ -606,6 +608,7 @@ void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, Q
|
|||
itemCardChild->setData(0, Qt::UserRole, "cardObject"); // 存储额外数据,如ID
|
||||
itemCardChild->setData(0, Qt::UserRole + 1, fileFull); // 存储额外数据,井次文件路径
|
||||
itemCardChild->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||||
itemCardChild->setData(0, Qt::UserRole + 3, strCurveName); // 存储额外数据,参数卡
|
||||
itemCardChild->setIcon(0, iconParameterCard);
|
||||
if (0 == itemParameterCard->childCount())
|
||||
{
|
||||
|
|
@ -621,6 +624,7 @@ void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, Q
|
|||
itemWaveChild->setData(0, Qt::UserRole, "waveObject"); // 存储额外数据,如ID
|
||||
itemWaveChild->setData(0, Qt::UserRole + 1, fileFull); // 存储额外数据,井次文件路径
|
||||
itemWaveChild->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||||
itemWaveChild->setData(0, Qt::UserRole + 3, strCurveName); // 存储额外数据,波列卡
|
||||
itemWaveChild->setIcon(0, iconWave);
|
||||
if (0 == itemWave->childCount())
|
||||
{
|
||||
|
|
@ -748,6 +752,11 @@ void QtProjectWidgets::initParameterCardTreeMenu(QMenu *menu, QTreeWidget *treeW
|
|||
connect(action_CardObject, SIGNAL(triggered(bool)), this, SLOT(onShowParameterCard(bool)));
|
||||
menu->addAction(action_CardObject);
|
||||
|
||||
QAction* action_ReName = new QAction("重命名", treeWidget);
|
||||
action_ReName->setIcon(QIcon(GetImagePath() + "icon/Rename.png")); // 设置图标":/image/u174.png"
|
||||
connect(action_ReName, SIGNAL(triggered()), this, SLOT(onReNameObject()));
|
||||
menu->addAction(action_ReName);
|
||||
|
||||
QAction* action_Copy = new QAction("复制", treeWidget);
|
||||
action_Copy->setIcon(QIcon(GetImagePath() + "icon/Copy.png")); // 设置图标":/image/u174.png"
|
||||
connect(action_Copy, SIGNAL(triggered()), this, SLOT(onCopySelObject()));
|
||||
|
|
@ -766,7 +775,12 @@ void QtProjectWidgets::initCurveObjectTreeMenu(QMenu *menu, QTreeWidget *treeWid
|
|||
m_action_ShowCurve->setIcon(QIcon(GetImagePath() + "icon/Sheet.png")); // 设置图标":/image/u174.png"
|
||||
connect(m_action_ShowCurve, SIGNAL(triggered(bool)), this, SLOT(onShowCurve(bool)));
|
||||
menu->addAction(m_action_ShowCurve);
|
||||
//
|
||||
|
||||
QAction* action_ReName = new QAction("重命名", treeWidget);
|
||||
action_ReName->setIcon(QIcon(GetImagePath() + "icon/Rename.png")); // 设置图标":/image/u174.png"
|
||||
connect(action_ReName, SIGNAL(triggered()), this, SLOT(onReNameObject()));
|
||||
menu->addAction(action_ReName);
|
||||
|
||||
m_action_DepthShift = new QAction("深度移动", treeWidget);
|
||||
m_action_DepthShift->setIcon(QIcon(GetImagePath() + "icon/RigidDepthShifting.png")); // 设置图标
|
||||
connect(m_action_DepthShift, SIGNAL(triggered(bool)), this, SLOT(onDepthShift(bool)));
|
||||
|
|
@ -790,7 +804,12 @@ void QtProjectWidgets::initWaveObjectTreeMenu(QMenu *menu, QTreeWidget *treeWidg
|
|||
action_WaveObject->setIcon(QIcon(GetImagePath() + "icon/Sheet.png")); // 设置图标
|
||||
connect(action_WaveObject, SIGNAL(triggered(bool)), this, SLOT(onShowWave(bool)));
|
||||
menu->addAction(action_WaveObject);
|
||||
//
|
||||
|
||||
QAction* action_ReName = new QAction("重命名", treeWidget);
|
||||
action_ReName->setIcon(QIcon(GetImagePath() + "icon/Rename.png")); // 设置图标":/image/u174.png"
|
||||
connect(action_ReName, SIGNAL(triggered()), this, SLOT(onReNameObject()));
|
||||
menu->addAction(action_ReName);
|
||||
|
||||
QAction* action_DepthShift = new QAction("深度移动", treeWidget);
|
||||
action_DepthShift->setIcon(QIcon(GetImagePath() + "icon/RigidDepthShifting.png")); // 设置图标
|
||||
connect(action_DepthShift, SIGNAL(triggered(bool)), this, SLOT(onDepthShift(bool)));
|
||||
|
|
@ -814,7 +833,12 @@ void QtProjectWidgets::initTableObjectTreeMenu(QMenu *menu, QTreeWidget *treeWid
|
|||
action_TableObject->setIcon(QIcon(GetImagePath() + "icon/Sheet.png")); // 设置图标
|
||||
connect(action_TableObject, SIGNAL(triggered(bool)), this, SLOT(onShowTable(bool)));
|
||||
menu->addAction(action_TableObject);
|
||||
//
|
||||
|
||||
QAction* action_ReName = new QAction("重命名", treeWidget);
|
||||
action_ReName->setIcon(QIcon(GetImagePath() + "icon/Rename.png")); // 设置图标":/image/u174.png"
|
||||
connect(action_ReName, SIGNAL(triggered()), this, SLOT(onReNameObject()));
|
||||
menu->addAction(action_ReName);
|
||||
|
||||
QAction* action_DepthShift = new QAction("深度移动", treeWidget);
|
||||
action_DepthShift->setIcon(QIcon(GetImagePath() + "icon/RigidDepthShifting.png")); // 设置图标
|
||||
connect(action_DepthShift, SIGNAL(triggered(bool)), this, SLOT(onDepthShift(bool)));
|
||||
|
|
@ -855,6 +879,11 @@ void QtProjectWidgets::initWellNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget
|
|||
menu->addAction(action_New);
|
||||
|
||||
menu->addAction(m_action_WellPaste);
|
||||
|
||||
QAction* action_Delete = new QAction("删除", treeWidget);
|
||||
action_Delete->setIcon(QIcon(GetImagePath() + "icon/Delete.png")); // 设置图标":/image/u174.png"
|
||||
connect(action_Delete, SIGNAL(triggered()), this, SLOT(onDeleteObject()));
|
||||
menu->addAction(action_Delete);
|
||||
}
|
||||
|
||||
//初始化根节点(井次名称)-右键菜单
|
||||
|
|
@ -892,6 +921,11 @@ void QtProjectWidgets::initSlfNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
|
|||
action_DepthShift->setIcon(QIcon(GetImagePath() + "icon/RigidDepthShifting.png")); // 设置图标
|
||||
connect(action_DepthShift, SIGNAL(triggered(bool)), this, SLOT(onDepthShift_Well(bool)));
|
||||
menu->addAction(action_DepthShift);
|
||||
|
||||
QAction* action_Delete = new QAction("删除", treeWidget);
|
||||
action_Delete->setIcon(QIcon(GetImagePath() + "icon/Delete.png")); // 设置图标":/image/u174.png"
|
||||
connect(action_Delete, SIGNAL(triggered()), this, SLOT(onDeleteObject()));
|
||||
menu->addAction(action_Delete);
|
||||
}
|
||||
|
||||
//初始化根节点(表目录)-右键菜单
|
||||
|
|
@ -1274,13 +1308,79 @@ void QtProjectWidgets::onCreateNewTable()
|
|||
//删除(曲线、表格、波列、参数卡)
|
||||
void QtProjectWidgets::onDeleteObject()
|
||||
{
|
||||
CLogIO *logio=new CLogIO;
|
||||
if(!logio->Open(m_strSlfName.toStdString().c_str(),CLogIO::modeReadWrite)) {
|
||||
delete logio;
|
||||
return;
|
||||
QList<QString> listDeleteDir;
|
||||
QList<QString> listDeleteSlf;
|
||||
QList<QString> listwellname;
|
||||
QMap<QString,QList<QString>> mapDeleteObject;// 复制Slf文件里对象名
|
||||
|
||||
mapDeleteObject.clear();
|
||||
foreach(QTreeWidgetItem *pItem, ui->treeWidget->selectedItems())
|
||||
{
|
||||
QString strTreeTag = pItem->data(0, Qt::UserRole).toString();
|
||||
if (strTreeTag == "wellname") //井名
|
||||
{
|
||||
QString pathTmp=GetLogdataPath();
|
||||
pathTmp+=g_prjname+"/#"+pItem->text(0);
|
||||
listDeleteDir.append(pathTmp);
|
||||
|
||||
}
|
||||
logio->DeleteObject(m_strCurveObjectName.toLocal8Bit().data());
|
||||
else if (strTreeTag == "wellItem") //井次
|
||||
{
|
||||
QString strSlfName = pItem->data(0, Qt::UserRole+1).toString();
|
||||
listDeleteSlf.append(strSlfName);
|
||||
listwellname.append(pItem->parent()->text(0));
|
||||
}
|
||||
|
||||
QTreeWidgetItem *parentItem = pItem->parent()->parent(); // 上两层目录是井次
|
||||
if (parentItem)
|
||||
{
|
||||
QString strSlfName = parentItem->data(0, Qt::UserRole+1).toString();
|
||||
if (strSlfName.contains(".slf"))
|
||||
{
|
||||
QString strObjectName = pItem->text(0);
|
||||
if(!mapDeleteObject.contains(strSlfName))
|
||||
{
|
||||
QList<QString> selList;
|
||||
selList.clear();
|
||||
mapDeleteObject.insert(strSlfName,selList);
|
||||
}
|
||||
mapDeleteObject[strSlfName].append(strObjectName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<listDeleteSlf.size(); i++)
|
||||
{
|
||||
QString strSlfName = listDeleteSlf.at(i);
|
||||
QFile::remove(strSlfName);
|
||||
if(mapDeleteObject.contains(strSlfName))
|
||||
mapDeleteObject.remove(strSlfName);
|
||||
}
|
||||
|
||||
for (int i=0; i<listDeleteDir.size(); i++)
|
||||
{
|
||||
QDir dir(listDeleteDir.at(i));
|
||||
if (dir.exists())
|
||||
dir.removeRecursively();
|
||||
}
|
||||
|
||||
QList<QString> listSlfName = mapDeleteObject.keys();
|
||||
for (int i=0; i<listSlfName.size(); i++)
|
||||
{
|
||||
QString strSlfName = listSlfName.at(i);
|
||||
|
||||
CLogIO *logio=new CLogIO;
|
||||
if(!logio->Open(strSlfName.toStdString().c_str(),CLogIO::modeReadWrite)) {
|
||||
delete logio;
|
||||
continue;
|
||||
}
|
||||
|
||||
QList<QString> listDeleteObject = mapDeleteObject[strSlfName];
|
||||
for (int j=0; j<listDeleteObject.size(); j++)
|
||||
logio->DeleteObject(listDeleteObject.at(j).toLocal8Bit().data());
|
||||
logio->Close();
|
||||
delete logio;
|
||||
}
|
||||
|
||||
QString strProjectFolder = GetProjectFolder();
|
||||
QString strProjectFile = strProjectFolder + g_prjname;
|
||||
|
|
@ -1319,6 +1419,15 @@ void QtProjectWidgets::onDeleteObject()
|
|||
expandAll(wellItem->child(k));
|
||||
}
|
||||
}
|
||||
|
||||
for (int k=0; k<listwellname.size(); k++)
|
||||
{
|
||||
QString strwellname = listwellname.at(i);
|
||||
if(strwellname== wellItem->text(0))//井
|
||||
{
|
||||
wellItem->setExpanded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1337,6 +1446,7 @@ void QtProjectWidgets::onCopySelObject() // 复制
|
|||
if (strSlfName.contains(".slf"))
|
||||
{
|
||||
QString strObjectName = pItem->text(0);
|
||||
|
||||
if(!m_mapCopyObject.contains(strSlfName))
|
||||
{
|
||||
QList<QString> selList;
|
||||
|
|
@ -1490,6 +1600,19 @@ void QtProjectWidgets::onPasteSelObject() // 粘贴
|
|||
RefreshWellRoundTree(parentItem);
|
||||
break;
|
||||
}
|
||||
|
||||
m_mapCopyObject.clear();
|
||||
}
|
||||
|
||||
void QtProjectWidgets::onReNameObject()
|
||||
{
|
||||
foreach(QTreeWidgetItem *pItem, ui->treeWidget->selectedItems())
|
||||
{
|
||||
pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);
|
||||
ui->treeWidget->editItem(pItem);
|
||||
// ui->treeWidget->setCurrentItem(pItem); // 更常用的是这样设置当前项并触发编辑
|
||||
// ui->treeWidget->setFocus(); // 确保控件获得焦点
|
||||
}
|
||||
}
|
||||
|
||||
// 粘贴井次
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ public slots:
|
|||
void onDeleteObject(); // 删除
|
||||
void onCopySelObject(); // 复制
|
||||
void onPasteSelObject(); // 粘贴
|
||||
void onReNameObject(); // 重命名
|
||||
void onPasteWell(); // 粘贴井次
|
||||
void RefreshWellRoundTree(QTreeWidgetItem *parentItem); // 刷新井次树
|
||||
//向左侧树图,追加固井结论表格
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user