1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 09:49:19 +02:00

fixed toc items order

This commit is contained in:
Nikolay Pultsin 2015-10-24 02:38:44 +01:00
parent b3790dfcad
commit 1378c40a2c

View file

@ -237,8 +237,13 @@ static jobject createTextModel(JNIEnv *env, jobject javaModel, ZLTextModel &mode
return env->PopLocalFrame(textModel); return env->PopLocalFrame(textModel);
} }
static bool ct_compare(const shared_ptr<ContentsTree> &first, const shared_ptr<ContentsTree> &second) {
return first->reference() < second->reference();
}
static void initTOC(JNIEnv *env, jobject javaModel, const ContentsTree &tree) { static void initTOC(JNIEnv *env, jobject javaModel, const ContentsTree &tree) {
const std::vector<shared_ptr<ContentsTree> > &children = tree.children(); std::vector<shared_ptr<ContentsTree> > children = tree.children();
std::sort(children.begin(), children.end(), ct_compare);
for (std::vector<shared_ptr<ContentsTree> >::const_iterator it = children.begin(); it != children.end(); ++it) { for (std::vector<shared_ptr<ContentsTree> >::const_iterator it = children.begin(); it != children.end(); ++it) {
const ContentsTree &child = **it; const ContentsTree &child = **it;
JString text(env, child.text()); JString text(env, child.text());