[dasher] Restore CConversionHelper::BuildTree, and move Chinese version to
- From: Patrick Welche <pwelche src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dasher] Restore CConversionHelper::BuildTree, and move Chinese version to
- Date: Mon, 24 Aug 2009 18:00:05 +0000 (UTC)
commit bf7715060ab5a60945caa37bcb4698d249e4251c
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Sat Aug 22 23:17:09 2009 +0100
Restore CConversionHelper::BuildTree, and move Chinese version to
CPinYinConversionHelper.
ChangeLog | 2 +
Src/DasherCore/ConversionHelper.cpp | 37 +++++++++++++---------------
Src/DasherCore/PinYinConversionHelper.cpp | 28 ++++++++++++++++++++-
Src/DasherCore/PinYinConversionHelper.h | 2 +
4 files changed, 47 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fe56156..c7c2c8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
* AlphabetManager.cpp: Move node creation outside of if statement.
* Move searching for target in game mode from DasherModel to DasherNode
and AlphabetManager.
+ * Restore CConversionHelper::BuildTree, and move Chinese version to
+ CPinYinConversionHelper.
2009-08-21 Alan Lawrence <acl33 inf phy cam ac uk>
diff --git a/Src/DasherCore/ConversionHelper.cpp b/Src/DasherCore/ConversionHelper.cpp
index 18d22eb..e716f76 100644
--- a/Src/DasherCore/ConversionHelper.cpp
+++ b/Src/DasherCore/ConversionHelper.cpp
@@ -347,29 +347,26 @@ void CConversionHelper::PopulateChildren( CDasherNode *pNode ) {
}
void CConversionHelper::BuildTree(CDasherNode *pRoot) {
-
+ // Build the string to convert.
std::string strCurrentString;
+ // Search backwards but stop at any conversion node.
+ for (CDasherNode *pNode = pRoot->Parent();
+ pNode && pNode->m_pNodeManager->GetID() != 2;
+ pNode = pNode->Parent()) {
+
+ // TODO: Need to make this the edit text rather than the display text
+ CAlphabetManager::SAlphabetData *pAlphabetData = static_cast<CAlphabetManager::SAlphabetData *>(pNode->m_pUserData);
+
+ strCurrentString = m_pAlphabet->GetText(pAlphabetData->iSymbol) + strCurrentString;
+ }
+ // Handle/store the result.
+ SCENode *pStartTemp;
+ Convert(strCurrentString, &pStartTemp);
- //Find the pinyin (roman) text (stored in Display text) of the previous alphabet node
-
- CAlphabetManager::SAlphabetData *pRootAlphabetData = static_cast<CAlphabetManager::SAlphabetData *>(pRoot->m_pUserData);
-
- //Get pinyin string (to translate) from 'Display Text' in the alphabet file (refer to alphabet.spyDict.xml)
- strCurrentString = m_pAlphabet->GetDisplayText(pRootAlphabetData->iSymbol);
-
- SCENode *pStartTemp;
- Convert(strCurrentString, &pStartTemp);
-
- SConversionData *pRootConversionData = static_cast<CConversionHelper::SConversionData *>(pRoot->m_pUserData);
-
- if(!(pRootConversionData->bisRoot))
- std::cout<<"ERROR IN BUILD TREE"<<std::endl;
-
- //Store all conversion trees(SCENode trees) in the pUserData->pSCENode of each Conversion Root
+ // Store all conversion trees (SCENode trees) in the pUserData->pSCENode
+ // of each Conversion Root.
- else{
- pRootConversionData->pSCENode = pStartTemp;
- }
+ static_cast<SConversionData *>(pRoot->m_pUserData)->pSCENode = pStartTemp;
}
void CConversionHelper::SetFlag(CDasherNode *pNode, int iFlag, bool bValue) {
diff --git a/Src/DasherCore/PinYinConversionHelper.cpp b/Src/DasherCore/PinYinConversionHelper.cpp
index ffbe8e3..da159e8 100644
--- a/Src/DasherCore/PinYinConversionHelper.cpp
+++ b/Src/DasherCore/PinYinConversionHelper.cpp
@@ -49,11 +49,35 @@ CPinYinConversionHelper::CPinYinConversionHelper(CNodeCreationManager *pNCManage
pParser = new CPinyinParser(strCHAlphabetPath);
}
-
+
+void CPinYinConversionHelper::BuildTree(CDasherNode *pRoot) {
+ DASHER_ASSERT(pRoot->m_pNodeManager == this);
+
+ // Find the pinyin (roman) text (stored in Display text) of the
+ // previous alphabet node.
+
+ SConversionData *pRootData = static_cast<SConversionData *>(pRoot->m_pUserData);
+
+ DASHER_ASSERT(pRootData->bisRoot);
+
+ // Get pinyin string (to translate) from 'Display Text' in the
+ // alphabet file (refer to alphabet.spyDict.xml).
+
+ std::string strCurrentString(m_pAlphabet->GetDisplayText(pRootData->iSymbol));
+
+ SCENode *pStartTemp;
+ Convert(strCurrentString, &pStartTemp);
+
+ // Store all conversion trees (SCENode trees) in the pUserData->pSCENode
+ // of each Conversion Root.
+
+ pRootData->pSCENode = pStartTemp;
+}
+
bool CPinYinConversionHelper::Convert(const std::string &strSource, SCENode ** pRoot) {
*pRoot = 0;
-
+cout<<"Convert \"" << strSource << "\"\n";
return (pParser && pParser->Convert(strSource, pRoot));
}
diff --git a/Src/DasherCore/PinYinConversionHelper.h b/Src/DasherCore/PinYinConversionHelper.h
index 073d361..4608a22 100644
--- a/Src/DasherCore/PinYinConversionHelper.h
+++ b/Src/DasherCore/PinYinConversionHelper.h
@@ -19,6 +19,8 @@ class CPinYinConversionHelper : public CConversionHelper {
public:
CPinYinConversionHelper(CNodeCreationManager *pNCManager, Dasher::CEventHandler *pEventHandler, CSettingsStore *pSettingsStore, Dasher::CAlphIO *pAlphIO, const std::string strCHAlphabetPath, Dasher::CAlphabet * pAlphabet);
+
+ virtual void BuildTree(CDasherNode *pRoot);
virtual bool Convert(const std::string &strSource, SCENode ** pRoot);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]