Пример #1
0
DWORD CGUIItem::CheckMouseState(float mouseX, float mouseY, MOUSESTATE mouseState, 
							   float x, float y, float width, float height, DWORD dwLastState)
{ 
	DWORD btState;
	if (mouseState == MOUSE_OPEN)
	{
		m_pVisItem->MouseOver(mouseX, mouseY, x, y, width, height, &btState);
		return btState;
	}
	else if (mouseState == MOUSE_LEFTPRESSED)
	{
		m_pVisItem->MouseButton(mouseX, mouseY, true, false, x, y, width, height, &btState);
		return btState;
	}
	else if (mouseState == MOUSE_LEFTRELEASED)
	{
		if ( m_pVisItem->MouseButton(mouseX, mouseY, false, true, x, y, width, height, &btState) )
		{
			StdString eventName = _T("RELEASED_");
			eventName += GetName()->GetString();
			CHashString eName(eventName.c_str());
		
			GUIEVENT ge;
			ge.event = eName.GetUniqueID();
			ge.ar = NULL;
			static DWORD msgHash_QueueGUIStateEvent = CHashString(_T("QueueGUIStateEvent")).GetUniqueID();
			m_ToolBox->SendMessage(msgHash_QueueGUIStateEvent, sizeof(GUIEVENT), &ge);
		}
		return btState;
	}
	return 0; 
}
void COptionTreeWrapper::SerializeRadioItem(IArchive &ar, COptionTreeItem *item, bool read)
{
	StdString szVal;
	COptionTreeItemRadio *otiRadio;
	OT_RADIO_NODE *node;
	int index;

	otiRadio = dynamic_cast<COptionTreeItemRadio*>(item);
	if (item == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemRadio: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if (read)
	{
		ar.Read(szVal);
		node = otiRadio->Node_FindNode(szVal.c_str());
		if (node != NULL)
		{	
			otiRadio->Node_UnCheckAll();
			node->m_bChecked = true;
		}	
	}
	else
	{
		index = otiRadio->Node_GetChecked();
		node = otiRadio->Node_FindNode(index);
		ar.Write(node->m_strText);
	}
}
void COptionTreeWrapper::SerializeStaticItemString(IArchive &ar, COptionTreeItem *item, bool read)
{
	StdString szString;
	COptionTreeItemStatic *otiStatic = dynamic_cast<COptionTreeItemStatic*>(item);

	CString szItem;
	if(otiStatic == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemStatic: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if(read)
	{
		ar.Read(szString);
		otiStatic->SetStaticText(szString.c_str());
	}
	else
	{
		szItem = otiStatic->GetStaticText();
		ar.Write(szItem);
	}
}
Пример #4
0
void CDetailObject::Serialize( IArchive &ar )
{
	StdString temp;
	if(ar.IsReading())
	{
		ar.Read(temp, "LayerLink");
		m_LayerLink = temp.c_str();
		ar.Read(temp, "ModelName");
		m_ModelName = temp.c_str();
		ar.Read(m_XCoverage, "XCoverage");
		ar.Read(m_YCoverage, "YCoverage");
		ar.Read(m_XRandomness, "XRandomness");
		ar.Read(m_YRandomness, "YRandomness");
		ar.Read(m_MinScale, "MinScale");
		ar.Read(m_MinScale, "MaxScale");
		ar.Read(m_MinYaw, "MinYaw");
		ar.Read(m_MaxYaw, "MaxYaw");
	}
	else
	{
		ar.Write(m_LayerLink.GetString(), "LayerLink");
		ar.Write(m_ModelName.GetString(), "ModelName");
		ar.Write(m_XCoverage, "XCoverage");
		ar.Write(m_YCoverage, "YCoverage");
		ar.Write(m_XRandomness, "XRandomness");
		ar.Write(m_YRandomness, "YRandomness");
		ar.Write(m_MinScale, "MinScale");
		ar.Write(m_MinScale, "MaxScale");
		ar.Write(m_MinYaw, "MinYaw");
		ar.Write(m_MaxYaw, "MaxYaw");
	}
}
Пример #5
0
long Universe::getClassPathExt(vector<StdString>& tokens,
        const StdString& arg) const {
#define EXT_TOKENS 2
    long result = ERR_SUCCESS;
    long fpIndex = arg.find_last_of(fileSeparator);
    long ssepIndex = arg.find(".som");

    if (fpIndex == StdString::npos) { //no new path
        //different from CSOM (see also HandleArguments):
        //we still want to strip the suffix from the filename, so
        //we set the start to -1, in order to start the substring
        //from character 0. npos is -1 too, but this is to make sure
        fpIndex = -1;
        //instead of returning here directly, we have to remember that
        //there is no new class path and return it later
        result = ERR_FAIL;
    } else
        tokens[0] = arg.substr(0, fpIndex);

    //adding filename (minus ".som" if present) to second slot
    ssepIndex =
            ((ssepIndex != StdString::npos) && (ssepIndex > fpIndex)) ?
                    (ssepIndex - 1) : arg.length();
    tokens[1] = arg.substr(fpIndex + 1, ssepIndex - (fpIndex));
    return result;
}
Пример #6
0
StdChar CSVWriterConfigPanel::getSeparator(void)
{
	if(mGUI->mSeparatorSemicolonBtn->isChecked())
		return ';';

	if(mGUI->mSeparatorColonBtn->isChecked())
		return ':';

	if(mGUI->mSeparatorSpaceBtn->isChecked())
		return ' ';

	if(mGUI->mSeparatorTabBtn->isChecked())
		return '\t';

	if(mGUI->mSeparatorCommaBtn->isChecked())
		return ',';

	if(mGUI->mSeparatorCustomBtn->isChecked())
	{
		StdString s = spt::string::fromQt(mGUI->mSeparatorCustomTxt->text());
		if(s.length() > 0)
			return s[0];
	}

	return ';';
}
Пример #7
0
void Parser::keywordMessage(MethodGenerationContext* mgenc, bool super) {
    StdString kw = keyword();
    
    // special compilation for ifTrue and ifFalse
    if (!super && kw == "ifTrue:") {
        ifTrueMessage(mgenc);
        return;
    } else if (!super && kw == "ifFalse:") {
        ifFalseMessage(mgenc);
        return;
    }
    formula(mgenc);
    while (sym == Keyword) {
        kw.append(keyword());
        formula(mgenc);
    }

    VMSymbol* msg = GetUniverse()->SymbolFor(kw);

    mgenc->AddLiteralIfAbsent(msg);

    if (super)
        bcGen->EmitSUPERSEND(mgenc, msg);
    else
        bcGen->EmitSEND(mgenc, msg);

}
Пример #8
0
bool OracleWriter::prepareOpen(std::vector<DatabaseColumn *> const &oColumns)
{
    setSQLLog(createConfigPanel()->getPath(), createConfigPanel()->getExportSQL(), createConfigPanel()->getExportSQLOnly());
    if(!SociContainer::prepareOpen(oColumns))
        return false;

    OracleWriterPanel *wp = createConfigPanel();
    setAutocommit(wp->getAutoCommitCount());

    StdString table = getTablename();
    if(table.length() == 0)
    {
        ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, "No target table selected!");
        return false;
    }

    if(getSession() == NULL)
    {
        ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, "Database session not initialized!");
        return false;
    }

    if(mAllowTruncate)
    {
#warning TODO: Implement truncate
    }

    if(mAllowModifyColumns)
    {
#warning TODO: Implement modify columns
    }

    return true;
}
void COptionTreeWrapper::SerializeEditItemString(IArchive &ar, COptionTreeItem *item, bool read)
{	
	StdString szString;
	COptionTreeItemEdit *otiEdit;
	
	CString szItem;
	otiEdit = dynamic_cast<COptionTreeItemEdit*>(item);
	if(otiEdit == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemEdit: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}

	otiEdit->CreateEditItem(0, NULL);

	if (read)
	{
		ar.Read(szString);
		otiEdit->SetEditText(szString.c_str());
	}
	else
	{
		otiEdit->GetWindowText(szItem);
		ar.Write(szItem);
	}
}
Пример #10
0
//---------------------------------------------------------------------
// Function:	EditDocument
// Description:	Edit an GUIEditor Document retrieving initial data 
//					from a archive
// Parameters:	ar = archive to load into document
// Returns:		DWORD = possible error or 0 for no error
//---------------------------------------------------------------------
DWORD CGUIEditor::EditDocument()
{
	if (!m_bCreated)
	{
		SetupTabBar();
		m_bCreated = true;
	}
	if (!m_bDocOpen)
	{
		StdString res;
		ReadINIKey(_T("LastUsedResolution"), res, _T("GUIEditor"), _T("800x600"));
		StdString x, y;
		res.GetToken(_T("x"), x);
		res.GetToken(_T("x"), y);
		UINT iX, iY;
		iX = (UINT)atoi(x.c_str());
		iY = (UINT)atoi(y.c_str());
		CreateDocView(iX, iY);
	}
	else
	{
		MessageBox(NULL, _T("Can't have more than one GUI open at a time"), _T("Sorry, mac"), MB_OK);
	}
	return NO_ERROR;
}
Пример #11
0
void CSchemaItem::DBReadString( DATABASEDATA *value, IArchive *ar, const TCHAR *tag )
{
	value->type = DBTYPE_STRING;
	StdString szReadString;
	ar->Read( szReadString );

	value->AssignString( (TCHAR *)szReadString.c_str(), _tcslen(szReadString) );
}
Пример #12
0
DWORD CInputManager::OnLoadKeyBinding(DWORD msgSize, void *param)
{
	IHashString *szhFileName;
	VERIFY_MESSAGE_SIZE(msgSize, sizeof(IHashString*));
	szhFileName = (IHashString*)param;
	StdString szNodeName;
	
	IXMLArchive *Archive;
	CHashString streamType(_T("File"));
	CREATEARCHIVE ca;
	DWORD retVal = MSG_NOT_HANDLED;
	
	ca.streamData = (void*)szhFileName->GetString();
	ca.mode = STREAM_MODE_READ;
	ca.streamType = &streamType;

	// call the Archive factory to create an XML archive
	static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID();
	if (retVal = m_ToolBox->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
	{
		//log error
		m_ToolBox->SetErrorValue(WARN_INVALID_OPERATION);
		m_ToolBox->Log(LOGWARNING, _T("CInputManager: Could not create archive from: %s\n"), szhFileName->GetString());
		return MSG_NOT_HANDLED;
	}

	Archive = dynamic_cast<IXMLArchive *>(ca.archive);
	int num;
	CHashString curKeyBind(_T(""));
	StdString keybindName;
	StdString parentType;
	StdString childType;
	StdString msg;
	int		  key;
	bool	  hitOnce;

	Archive->GetNode(szNodeName);
	Archive->Read(keybindName, _T("name"));
	Archive->Read(num, _T("num"));
	
	curKeyBind = keybindName.c_str();
	
	while (num != 0)
	{
		Archive->Read( msg, _T("msg") );
		Archive->Read( key, _T("key") );
		Archive->Read( hitOnce, _T("hitOnce") );
        //Add Entry to page			
		CHashString szMessage(msg);
		KEYBINDINGMAP &curPage = m_KeyMap[ curKeyBind.GetUniqueID() ];
		curPage[ key ].msg = szMessage.GetUniqueID();
		curPage[ key ].hitOnce = hitOnce;
		num--;
	}

	Archive->Close();
	return MSG_HANDLED_STOP;
}
Пример #13
0
StdChar CSVWriterConfigPanel::getBracket(StdChar &oClose) const
{
	oClose = 0;

	if(mGUI->mQuoteBtn->isChecked())
	{
		oClose = '"';
		return '"';
	}

	if(mGUI->mParenthesisBtn->isChecked())
	{
		oClose = ')';
		return '(';
	}

	if(mGUI->mBracketBtn->isChecked())
	{
		oClose = ']';
		return '[';
	}

	if(mGUI->mCurlyBtn->isChecked())
	{
		oClose = '}';
		return '{';
	}

	if(mGUI->mSignBtn->isChecked())
	{
		oClose = '>';
		return '<';
	}

	if(mGUI->mCustomQuoteBtn->isChecked())
	{
		StdString s = spt::string::fromQt(mGUI->mSeparatorCustomTxt->text());
		if(s.length() > 0)
		{
			if(s.length() > 1)
				oClose = s[1];
			else
			{
				switch(s[0])
				{
					case '\'':
					case '"':
						oClose = s[0];
					break;
				}
			}

			return s[0];
		}
	}

	return 0;
}
void CWorldEventToolPal::UpdateWorldEventTrigger( void )
{
	static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
	static DWORD msgHash_GetComponentType = CHashString(_T("GetComponentType")).GetUniqueID();
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();

	static CHashString Hash_Type = CHashString(_T("CWorldEventTrigger"));

	CString buf;
	m_Name.GetLBText(m_Name.GetCurSel(), buf);
	CHashString hszName((TCHAR*)buf.GetBuffer());
	FINDOBJECTPARAMS param;
	param.hszName = &hszName;
	DWORD result = m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), &param);

	// object exists 
	if( param.bFound == true )
	{
		GETCOMPONENTTYPEPARAMS gctp;
		gctp.name = &hszName;
		m_ToolBox->SendMessage(msgHash_GetComponentType, sizeof(gctp), &gctp);

		// it is a world event, get values from it
		if ( (gctp.componenttype != NULL) && (gctp.componenttype->GetUniqueID() == Hash_Type.GetUniqueID()) )
		{
			CREATEARCHIVE ca;
			CHashString streamType(_T("Memory"));
			ca.streamData = NULL;
			ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ;
			ca.streamType = &streamType;
	 	
			m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca, NULL, NULL);
			IArchive *MemArchive = (ca.archive);

			MemArchive->SetIsWriting(true);
			MemArchive->SeekTo(0);

			SERIALIZEOBJECTPARAMS sop;
			sop.name = &hszName;
			sop.archive = MemArchive;
			m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);

			MemArchive->SetIsWriting(false);
			MemArchive->SeekTo(0);

			StdString tmp;
			MemArchive->Read( tmp );
			m_EntityName.SetWindowText( tmp.c_str() );
			MemArchive->Read( tmp );
			m_EntityType.SetWindowText( tmp.c_str() );
			MemArchive->Read( tmp );
			m_EventName.SetWindowText( tmp.c_str() );
			
			MemArchive->Close();
		}
	}
}
Пример #15
0
void Parser::keywordPattern(MethodGenerationContext* mgenc) {
    StdString kw;
    do {
        kw.append(keyword());
        mgenc->AddArgumentIfAbsent(argument());
    } while (sym == Keyword);

    mgenc->SetSignature(GetUniverse()->SymbolFor(kw));
}
Пример #16
0
bool SociContainer::isTable(void)
{
	StdString t = getSelector();
	if(t.length() == 0)
		return true;

	if(t[0] == '{')
		return true;

	return false;
}
/// \brief	message handler to create zipped memory stream
/// \param	size - size of LPCTSTR
/// \param	param - pointer to string with path
/// \return	EE message return code
DWORD CZLibStreamFactory::OnAddZipFile(DWORD size, void *param)
{
	VERIFY_MESSAGE_SIZE(size, sizeof(LPCTSTR));
	StdString sPath = static_cast<LPCTSTR>(param);
	sPath.MakeSafeFileName();
	//sPath.ConformSlashesForward();
	if (!CZipFileStream::AddSearchPath(sPath.c_str()))
	{
		return MSG_ERROR;
	}
	return MSG_HANDLED_STOP;
}
Пример #18
0
StdString SociContainer::selectorToQuery(void)
{
	StdString q = getSelector();
	if(q.length() == 0)
		return q;

	if(q[0] == '{' && q != "{}" && q.length() > 1)
		q = "select * from "+ q.substr(1, q.length()-2);
	else
		q = mQuery;

	return q;
}
Пример #19
0
StdString OracleWriter::getDateFormatString(StdString const &oValue, bool bTimestamp) const
{
    StdString pattern = "0000-00-00 00:00:00";

    if(oValue.length() == 10)
        return "YYYY.MM.DD";

    if(oValue.length() >= 19 || bTimestamp == false)
        return "YYYY.MM.DD HH24:MI:SS";

    pattern += ".";
    StdString format = "YYYY.MM.DD HH24:MI:SS.";

    StdString v = oValue.substr(pattern.length(), oValue.length());
    for(size_t i = 0; i < v.length(); i++)
    {
        if(v[i] >= '0' && v[i] <= '9')
        {
            format += 'F';
            continue;
        }
        break;
    }

    return format;
}
Пример #20
0
void SociContainer::setSelector(StdString const &oId)
{
	Progress prg("Loading from Table ...");

	if(oId.length() > 0 && oId[0] == '{') // If it is a table we select it
	{
		mTablename = oId.substr(1, oId.length()-2);
		selectTable(mTablename, false);
	}
	else
		mTablename = "";

	super::setSelector(oId);
	refreshPreview(selectorToQuery(), mPreviewLimit);
}
Пример #21
0
bool CEntityManager::CompareNames(StdString searchString, StdString compString)
{
	static StdString token(_T("\\"));
	size_t subLen;
	// if searchString is null, positive match w/ everything
	if(_tcscmp(searchString, _T("")) == 0)
	{
		return true;
	}
	// if compString is null, no match
	if(_tcscmp(compString, _T("")) == 0)
	{
		return false;
	}
	const TCHAR* searchStringArray = searchString.c_str();
	const TCHAR* compStringArray = compString.c_str();

	while( _tcscmp(searchStringArray, _T("")) != 0 )
	{
		subLen = _tcscspn(compStringArray, token); //length of substring to token

		if (subLen > 0)
		{
			// compare substrings up to token 
			if( _tcsncmp(searchStringArray, compStringArray, subLen) == 0 )
			{
				return true;
			}

			// now check if compString's substring's next char is == token 
			if( compStringArray[subLen] != token.c_str()[0] )
			{
				// did not return above, therefore does not match
				return false;			
			}		

			// continue...advance ptr
			compStringArray = _tcsninc(compStringArray, subLen+1);
		}
		else
		{
			// string out
			return false;
		}
	}
	// if exited while loop..then true
	return true;
}
Пример #22
0
StdString HashSHA1Impl::GetFileHash(StdString strFile)
{
	StdString strRet;

	HANDLE hFile = CreateFile(strFile.c_str(), GENERIC_READ, FILE_SHARE_READ,
		NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile != INVALID_HANDLE_VALUE)
	{
		HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL);
		if (hMapping != INVALID_HANDLE_VALUE)
		{
			PBYTE pByte = (PBYTE)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
			unsigned long dwSize = GetFileSize(hFile, NULL);			
			
			Reset();
			Input(pByte, dwSize);
			unsigned int digest[5] = {0};
			Result(digest);
			TCHAR szRes[48] = _T("");
			_sntprintf_s(szRes, 48, 48, _T("%x%x%x%x%x"),
				digest[0], digest[1], digest[2], digest[3], digest[4]);
			strRet = szRes;

			UnmapViewOfFile(pByte);
			CloseHandle(hMapping);
		}
		else
		{
			CloseHandle(hFile);
		}
	}
	return strRet;
}
Пример #23
0
FileStream::FileStream(StdString filename) {
    ipos = 0;

Console::WriteLine(StdString("Opening ")+filename);
 fpointer = fopen(filename.rstr(),"r+b");
    GetLen();
}
Пример #24
0
std::vector<DatabaseColumn *> SociContainer::readColumnsFromTable(StdString const &oTablename)
{
	if(oTablename.length() == 0)
		return std::vector<DatabaseColumn *>();

	return readColumnsFromQuery("select * from " +oTablename+" limit 1", false);
}
Пример #25
0
/*!
This function queries the full name of a group given its id.
\param [in] ncid Groupd id (or File Id)
\param [in/out] grpFullName the full name of the group
\return Status code
*/
int CNetCdfInterface::inqGrpFullName(int ncid, StdString& grpFullName)
{
  StdSize strlen = 0;
  std::vector<char> buff;
  int status = nc_inq_grpname_full(ncid, &strlen, NULL);
  if (NC_NOERR == status)
  {
    buff.resize(strlen + 1);
    status = nc_inq_grpname_full(ncid, NULL, &buff[0]);
  }

  if (NC_NOERR != status)
  {
    StdString errormsg(nc_strerror(status));
    StdStringStream sstr;

    sstr << "Error when calling function nc_inq_grpname_full(ncid, &strlen, &buff[0])" << std::endl
         << errormsg << std::endl
         << "Unable to get the full group name given its id: " << ncid << std::endl;
    StdString e = sstr.str();
    throw CNetCdfException(e);
  }

  grpFullName.assign(buff.begin(), buff.end());

  return status;
}
CQHStateMachine *CQHStateMachineManager::GetStateMachineByFile( IHashString *fileName )
{
	CQHStateMachine *areturn = NULL;

	StdString file = fileName->GetString();
	file.MakeSafeFileName();
	CHashString srcFileName(file);

	static CHashString cqhsmTypeName(_T("CQHStateMachine"));
	IDTOOBJECTMAP::iterator fnameToSM = m_FilenameToStateMachine.find(srcFileName.GetUniqueID());
	if (fnameToSM != m_FilenameToStateMachine.end())
	{
		areturn = (CQHStateMachine*)(fnameToSM->second);
	}
	return areturn;
}
Пример #27
0
IBaseTextureObject * CTextureManager::GetTexture(IHashString *name )
{
	if( name != NULL )
	{
		StdString szSafeName = name->GetString();
		szSafeName.MakeSafeFileName();
		CHashString hsSafeName(szSafeName);
		//do we have it in the mapping already?
		TEXTURENAMEMAP::iterator cur = m_TextureNameMap.find( hsSafeName.GetUniqueID() );
		if( cur != m_TextureNameMap.end() )
		{
			//found one already loaded
			return (cur->second);
		}
	}
	return NULL;
}
Пример #28
0
bool SociContainer::connect(StdString const &oConnectString)
{
	StdString con = getConnectString();

	if(oConnectString.length() > 0)
	{
		if(con != oConnectString)
		{
			disconnect();
			con = oConnectString;
		}
	}

	if(mSession != NULL) // Same connect string and session already exists.
		return true;

	if(con.length() == 0)
		return false;

	setConnectString(con);

	bool rc = true;
	Progress prg("Connecting to database");
	prg->setLabelText("Connecting to database ...");
	prg->setMaximum(prg->maximum()+1);

	QApplication::processEvents();
	StdString connectStr = sociConnectString(con);

	try
	{
		mSession = new soci::session(sociFactory(), connectStr);
		mSociConnectString = connectStr;
		refreshTables();
	}
	catch(std::runtime_error const &e)
	{
		mSociConnectString = "";
		ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, e.what());
		rc = false;
	}
	prg->setValue(prg->value()+1);

	return rc;
}
Пример #29
0
bool ColumnEditorModel::setData(QModelIndex const &oIndex, QVariant const &oValue, int nRole)
{
	if(!oIndex.isValid())
		return QStandardItemModel::setData(oIndex, oValue, nRole);

	StdString s = oValue.value<StdString>();
	bool rc;
	bool update = true;

	int n = rowCount()-1;
	int ir = oIndex.row();
	int ic = oIndex.column();
	if(ir == n)
	{
		// Add new empty line at the end if the last item has got some text
		if(ic == COL_NAME && s.size() > 0)
		{
			updateName(n, s);
			insertRow(n+1);
		}
	}
	else
	{
		if(ic == COL_NAME)
		{
			if(s.size() == 0)
			{
				n = oIndex.row();
				deleteRow(n);
				update = false;
			}
			else
				updateName(ir, s);
		}
		else
			updateType(ir, s);
	}

	if(update)
		rc = QStandardItemModel::setData(oIndex, oValue, nRole);
	else
		rc = false;

	return rc;
}
/// message handler to check if a file exists
/// \param size - size of a CHECKFILEEXISTS
/// \param param - pointer to a CHECKFILEEXISTS struct
/// \return MSG_XXX return value
DWORD CZLibStreamFactory::OnCheckFileExists(DWORD size, void *param)
{
	VERIFY_MESSAGE_SIZE(size, sizeof(CHECKFILEEXISTS));
	CHECKFILEEXISTS &cfe = *(CHECKFILEEXISTS*)param;

	StdString sPath = cfe.pFilePath;
	sPath.MakeSafeFileName();
	sPath.ConformSlashesForward();

	if( CZipFileStream::CheckFileExist( sPath.c_str() ) )
	{
		cfe.bExists = true;
		return MSG_HANDLED_STOP;
	}
	
	cfe.bExists = false;
	return MSG_HANDLED_PROCEED;
}