-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved Hanyu pinyin appending functions from GUI code (MainWindow) to …
…a separate class (GPinyinAppender) Changed GDateEstimator to only insert PLACE nodes if the defaultPlace value is non-null and non-empty Updated to version 1.6.0 *** Major bug fixes *** Fixed GIndiEntry and GFamily so that new PLACE nodes are properly appended to the GNode tree (now PACE data will be saved) Fixed GIndiEntry::parseDeath() to parse PLACE nodes git-svn-id: http://svn.phoenixteam.org/repos/GedTools@46 9dab71d7-c464-4d9a-89bf-b85db2a2fdf8
- Loading branch information
Showing
9 changed files
with
165 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef V_G_PINYIN_APPENDER_H | ||
#define V_G_PINYIN_APPENDER_H | ||
|
||
#include "GIndiMap.h" | ||
#include "PinyinMap.h" | ||
|
||
/* GPinyinAppender: Adds pinyin data to all entries | ||
* in a GIndiMap based on the data contained in the | ||
* PinyinMap.dat file (accessed through PinyinMap). | ||
*/ | ||
class GPinyinAppender { | ||
|
||
public: | ||
|
||
//=== Constructor/Destructor ===// | ||
|
||
/* Constructor */ | ||
GPinyinAppender(); | ||
|
||
/* Destructor */ | ||
~GPinyinAppender(); | ||
|
||
//=== Methods ===// | ||
|
||
/* Appends pinyin data to the specified | ||
* GIndiMap's individual entries | ||
* @return incomplete ("?") entry count | ||
*/ | ||
int appendTo(GIndiMap & indiMap); | ||
|
||
private: | ||
|
||
//=== Constants ===// | ||
|
||
// First unicode point for Chinese characters | ||
static const int CJK_CODEPOINT; | ||
|
||
//=== Private Data Members ===// | ||
|
||
// Map containing pinyin data from PinyinMap.dat | ||
PinyinMap * _pinyinMap; | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
#include "GPinyinAppender.h" | ||
|
||
//=== Constants ===// | ||
|
||
// First unicode point for Chinese characters | ||
const int GPinyinAppender::CJK_CODEPOINT = 0x3400; | ||
|
||
//=== Constructor/Destructor ===// | ||
|
||
/* Constructor */ | ||
GPinyinAppender::GPinyinAppender() { | ||
_pinyinMap = new PinyinMap(); | ||
} | ||
|
||
/* Destructor */ | ||
GPinyinAppender::~GPinyinAppender() { | ||
delete _pinyinMap; | ||
} | ||
|
||
//=== Methods ===// | ||
|
||
/* Appends pinyin data to the specified | ||
* GIndiMap's individual entries | ||
* @return incomplete ("?") entry count | ||
*/ | ||
int GPinyinAppender::appendTo(GIndiMap & indiMap) { | ||
// Define loop variables | ||
QString name; // Chinese name of individual | ||
QString romanName; // Romanized name of individual | ||
QString pinyin; // Hanyu pinyin for an individual character in the name | ||
bool needSpace; // Don't append spaces between hanzi | ||
bool hasHanzi; // If there are no hanzi then we don't need a romanized name | ||
bool incomplete; // If this romanization has a "?" then it's incomplete | ||
int incompleteCount = 0; // Total number of incomplete ("?") entries | ||
GIndiMap::Iterator i, end = indiMap.end(); | ||
// Loop through every GIndiEntry in the GIndiMap | ||
for (i=indiMap.begin();i!=end;++i) { | ||
// Reset variables for this name entry | ||
name = i.value()->name(); | ||
romanName = ""; | ||
hasHanzi = false; | ||
needSpace = false; | ||
incomplete = false; | ||
// Loop through each character in their name to append Pinyin | ||
for (int j=0;j<name.length();++j) { | ||
// If it's a Hanzi then try to append pinyin for it | ||
if (name[j] >= CJK_CODEPOINT) { | ||
// Append space if needed | ||
if (needSpace) romanName.append(' '); | ||
hasHanzi = true; | ||
// Find the pinyin entry for this hanzi | ||
pinyin = _pinyinMap->lookup(name[j]); | ||
// If pinyin data is found then append it | ||
if (!pinyin.isNull()) { | ||
romanName.append(pinyin); | ||
needSpace = true; | ||
} | ||
// If there is no pinyin found then append "?" | ||
else { | ||
romanName.append('?'); | ||
needSpace = true; | ||
incomplete = true; | ||
} | ||
} | ||
// Otherwise append whatever the character is | ||
else { | ||
romanName.append(name[j]); | ||
needSpace = false; | ||
} | ||
} | ||
// Update the romanized name entry if needed | ||
if (hasHanzi) i.value()->setRomanizedName(romanName); | ||
// If this entry was incomplete then increment the count | ||
if (incomplete) ++incompleteCount; | ||
} | ||
return incompleteCount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters