214 lines
6.0 KiB
C++
214 lines
6.0 KiB
C++
#include <QPushButton>
|
|
#include "WellLogDialog.h"
|
|
#include <QDir>
|
|
#include "LogIO.h"
|
|
#include "geometryutils.h"
|
|
|
|
int SetWellRoundWellName(QString filename, QString strNewName)
|
|
{
|
|
bool ret=false;
|
|
if(filename!="")
|
|
{
|
|
CLogIO a_cslfio;
|
|
if(a_cslfio.Open(filename.toStdString().c_str(),CSlfIO::modeReadWrite))
|
|
{
|
|
Slf_FILE_MESSAGE mssage;
|
|
a_cslfio.GetFileMessage(mssage);
|
|
int len=strlen(strNewName.toStdString().c_str());
|
|
if(len>sizeof(mssage.WellName)) len=sizeof(mssage.WellName);
|
|
strncpy(mssage.WellName,strNewName.toStdString().c_str(),len);
|
|
mssage.WellName[len]=0;
|
|
a_cslfio.SetFileMessage(mssage);
|
|
ret=true;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
//bool RenameWellName(CObjWell *pWell,QString strNewName)
|
|
//{
|
|
// if(!pWell) return false;
|
|
// QList<PaiObject*> wellroundchildren;
|
|
// int count=pWell->GetAllWellRound(wellroundchildren);
|
|
// QString filename=pWell->GetWellMessageFileName();
|
|
// QString path,wellname;
|
|
// GetWellNameAndPath(filename,wellname,path);
|
|
// QFileInfo f(filename);
|
|
// QDir ss;
|
|
// QString newname=path;
|
|
// newname+="/"+strNewName+"."+f.suffix();
|
|
// if(ss.rename(filename,newname)) {//.WELL文件改名
|
|
// pWell->SetWellFileName(newname);
|
|
// }
|
|
// QString dirn=path;
|
|
// int index=dirn.lastIndexOf("\\");
|
|
// int index1=dirn.lastIndexOf("/");
|
|
// if(index1>index) index=index1;
|
|
// QString odir=dirn.mid(index+1);
|
|
// QString ndir="#"+strNewName;
|
|
// QString ndirpath=dirn.left(index+1)+ndir;
|
|
// if(ss.rename(dirn,ndirpath))//改目录名
|
|
// {
|
|
// for(int i=0;i<count;i++) {
|
|
// CObjWelllogRound *pWellR=dynamic_cast<CObjWelllogRound *>(wellroundchildren.at(i));
|
|
// QString fi=pWellR->GetSlfFileName();
|
|
// fi.replace(odir,ndir);
|
|
// if(count==1) {
|
|
// QString path,wellname,ofilename;
|
|
// GetWellNameAndPath(fi,wellname,path);
|
|
// ofilename=fi;
|
|
// //ofilename.replace(wellname,strNewName);
|
|
// //whp2020.7.19 解决井名中有连续重复字符时replace会把路径名重复替换问题
|
|
// QFileInfo ff(fi);
|
|
// QString newname=strNewName+"."+ff.suffix();
|
|
// QString oldname=wellname+"."+ff.suffix();
|
|
// ofilename.replace(oldname,newname);
|
|
// //whp2020.7.19
|
|
// if(ss.rename(fi,ofilename)) {
|
|
// pWellR->SetSlfFileName(ofilename);
|
|
// pWellR->SetName(strNewName);
|
|
// }
|
|
// else {
|
|
// pWellR->SetSlfFileName(fi);
|
|
// AfxMessageBox("改井次不成功:\n"+fi+"\n 到 \n"+ofilename);
|
|
// }
|
|
// }
|
|
// else pWellR->SetSlfFileName(fi);
|
|
// }
|
|
// QString fi=pWell->GetWellMessageFileName();
|
|
// fi.replace(odir,ndir);
|
|
// pWell->SetWellFileName(fi);
|
|
// return true;
|
|
// }
|
|
// else {
|
|
// AfxMessageBox("改目录名不成功:\n"+dirn+"\n 到 \n"+ndirpath);
|
|
// return false;
|
|
// }
|
|
//}
|
|
|
|
//void RenameWellName(CObjWell *pDestWell,CObjWell *pWell,bool isMount)
|
|
//{
|
|
// QString wellfile=pDestWell->GetWellMessageFileName();
|
|
// int index=wellfile.lastIndexOf("#");
|
|
// int index1=wellfile.lastIndexOf("\\");
|
|
// int index2=wellfile.lastIndexOf("/");
|
|
// if(index2>index1) index1=index2;
|
|
// QString newdir=wellfile.mid(index,index1-index);
|
|
// QString newname=pWell->GetWellMessageFileName();
|
|
// index=newname.lastIndexOf("#");
|
|
// index1=newname.lastIndexOf("\\");
|
|
// index2=newname.lastIndexOf("/");
|
|
// if(index2>index1) index1=index2;
|
|
// QString dirname;
|
|
// dirname=newname.mid(index,index1-index);
|
|
// QString budir=GetLogdataPath();
|
|
// budir+="temp/"+dirname;
|
|
// newname=GetLogdataPath()+GetProject()->GetName()+"/"+dirname;
|
|
// QDir dir;
|
|
// int flag=1;
|
|
// int v=0;
|
|
// char buf[MAX_PATH];
|
|
// strcpy(buf,budir.toStdString().c_str());
|
|
// while(1) {
|
|
// if(dir.exists(buf)) {
|
|
// sprintf(buf,"%s%d",budir.toStdString().c_str(),v);
|
|
// v+=1;
|
|
// }
|
|
// else {
|
|
// break;
|
|
// }
|
|
// }
|
|
// budir=buf;
|
|
// if(newdir != dirname){
|
|
// if(!dir.rename(newname,budir)) {
|
|
// flag=0;
|
|
// dir.remove(pWell->GetWellMessageFileName());
|
|
// }
|
|
// }
|
|
// QList<PaiObject*> wellroundchildren;
|
|
// int count=pWell->GetAllWellRound(wellroundchildren);
|
|
// for(int i=0;i<count;i++) {
|
|
// CObjWelllogRound *pWellR=dynamic_cast<CObjWelllogRound *>(wellroundchildren.at(i));
|
|
// if(pWellR) {
|
|
// pWell->RemoveChild(pWellR);
|
|
// pWellR->SetWell(pDestWell);
|
|
// pDestWell->AddChild(pWellR,isMount);
|
|
// if(flag) {
|
|
// newname=pWellR->GetSlfFileName();
|
|
// newname.replace(dirname,newdir);
|
|
// pWellR->SetSlfFileName(newname);
|
|
// }
|
|
// }
|
|
// }
|
|
// if(flag) {
|
|
// QDir dir(budir);
|
|
// dir.setFilter(QDir::Files | QDir::NoSymLinks);
|
|
// QFileInfoList list = dir.entryInfoList();
|
|
// QStringList string_list;
|
|
// for(int i=0; i<list.size();i++)
|
|
// {
|
|
// QFileInfo file_info = list.at(i);
|
|
// if(!file_info.isDir()) {
|
|
// QString absolute_file_path = file_info.absoluteFilePath();
|
|
// if(absolute_file_path.lastIndexOf(".well",-1,Qt::CaseInsensitive)>-1) continue;
|
|
// QString newfile=absolute_file_path;
|
|
// newfile.replace("temp/"+dirname,GetProject()->GetName()+"/"+newdir);
|
|
// QFile::copy(absolute_file_path,newfile);
|
|
// }
|
|
// }
|
|
// QFile::copy(wellfile,newname);
|
|
// }
|
|
//}
|
|
|
|
|
|
WellLogDialog::WellLogDialog(QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags)
|
|
{
|
|
setAttribute( Qt::WA_DeleteOnClose ,true );
|
|
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint);
|
|
m_DialogType=0;
|
|
}
|
|
|
|
void WellLogDialog::GetOKAndCancel(QPushButton* &okBtn,QPushButton* &cancelBtn)
|
|
{
|
|
}
|
|
|
|
void WellLogDialog::DataToView(){}
|
|
void WellLogDialog::ViewToData(){}
|
|
|
|
void WellLogDialog::Init()
|
|
{
|
|
QPushButton* okBtn;
|
|
QPushButton* cancelBtn;
|
|
GetOKAndCancel(okBtn,cancelBtn);
|
|
okBtn->setIcon(QIcon( ::GetImagePath() + "icon/OK.png"));
|
|
cancelBtn->setIcon(QIcon( ::GetImagePath() + "icon/Cancel.png"));
|
|
QObject::connect(okBtn, SIGNAL(clicked()), this, SLOT(slotSave()));
|
|
QObject::connect(cancelBtn, SIGNAL(clicked()), this, SLOT(slotCancel()));
|
|
|
|
DataToView();
|
|
}
|
|
int WellLogDialog::Validate()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
WellLogDialog::~WellLogDialog()
|
|
{
|
|
}
|
|
void WellLogDialog::slotSave()
|
|
{
|
|
if(Validate())
|
|
{
|
|
ViewToData();
|
|
accept();
|
|
// CObjWell*pWell=dynamic_cast<CObjWell*>(m_pObject);
|
|
// if(pWell) pWell->LoadXYZ();
|
|
// GetObjectEvent().OnRefreshWellMessage(wellLR.GetFileName());
|
|
}
|
|
}
|
|
void WellLogDialog::slotCancel()
|
|
{
|
|
reject();
|
|
}
|
|
|