00001 00002 /**************************************************************************\ 00003 * REQUIRED HEADERS * 00004 \**************************************************************************/ 00005 00006 #include "CEditorProc.h" 00007 #include "CShaderEditor.h" 00008 00009 /**************************************************************************\ 00010 * PRIVATE DEFINITIONS * 00011 \**************************************************************************/ 00012 00013 /**************************************************************************\ 00014 * PUBLIC CLASS FUNCTIONS * 00015 \**************************************************************************/ 00016 00017 //CONSTRUCTOR 00018 CEditorProc::CEditorProc(QString & fileName,QObject * parent) 00019 :QProcess(parent) 00020 { 00021 pTmpFile = new QFile("edit_" +fileName); 00022 } 00023 00024 //DESTRUCTOR 00025 CEditorProc::~CEditorProc() 00026 { 00027 pTmpFile->remove(); 00028 SAFE_DELETE(pTmpFile); 00029 } 00030 00031 //STERT EDIT 00032 bool CEditorProc::StartEdit(QString & editorPath,QStringList & editorArgs,QString & shaderText,QString & shaderFileName){ 00033 00034 currentEditorPath = editorPath; 00035 currentEditorArgs = editorArgs; 00036 00037 pTmpFile->open(QIODevice::WriteOnly); 00038 pTmpFile->resize(0); 00039 pTmpFile->write(shaderText.toAscii()); 00040 00041 tmpFileName = QFileInfo(pTmpFile->fileName()).absoluteFilePath(); 00042 00043 pTmpFile->close(); 00044 00045 start(editorPath,editorArgs << tmpFileName); 00046 return true; 00047 } 00048 00049 //STOP EDIT 00050 QString & CEditorProc::StopEdit(){ 00051 00052 pTmpFile->open(QIODevice::ReadOnly); 00053 textReceived = pTmpFile->readAll(); 00054 pTmpFile->close(); 00055 if(state() == QProcess::NotRunning){ 00056 start(currentEditorPath,currentEditorArgs << tmpFileName); 00057 } 00058 return textReceived; 00059 }