From 3e89eb7279c60cbc21dd15c87b7a8d8a7c4909af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 16 Dec 2012 09:49:51 +0100 Subject: [PATCH] Sort categories with translated names --- lib/libkdchart/src/KDChartBackgroundAttributes.cpp | 10 +++++----- src/controller/KissCount.cpp | 4 ++++ src/model/Category.hpp | 4 +++- src/model/User.cpp | 7 +++++++ src/view/wxUI.cpp | 8 ++++++++ 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/libkdchart/src/KDChartBackgroundAttributes.cpp b/lib/libkdchart/src/KDChartBackgroundAttributes.cpp index f9f1520..91d8b81 100644 --- a/lib/libkdchart/src/KDChartBackgroundAttributes.cpp +++ b/lib/libkdchart/src/KDChartBackgroundAttributes.cpp @@ -147,11 +147,11 @@ QPixmap BackgroundAttributes::pixmap() const QDebug operator<<(QDebug dbg, const KDChart::BackgroundAttributes& ba) { dbg << "KDChart::BackgroundAttributes(" - << "visible="<LoadUser(user) ; + if (_user) _wxUI->LoadUser(); } @@ -504,6 +505,9 @@ QFont KissCount::ExtractFont(QString strFont) weight = list[3].toInt(); faceName = list[4]; + (void) family; + (void) style; + return QFont(faceName, pointSize, weight); } diff --git a/src/model/Category.hpp b/src/model/Category.hpp index ead5511..6ed6099 100644 --- a/src/model/Category.hpp +++ b/src/model/Category.hpp @@ -23,6 +23,8 @@ #include #include +#include + struct Category { int id; @@ -38,7 +40,7 @@ struct Category if (cat1.fix_cost) return true; if (cat2.fix_cost) return false; - return cat1.name < cat2.name; + return QApplication::translate("", cat1.name.toStdString().c_str()) < QApplication::translate("", cat2.name.toStdString().c_str()); } bool operator == (int catId) diff --git a/src/model/User.cpp b/src/model/User.cpp index 76468f4..40f6792 100644 --- a/src/model/User.cpp +++ b/src/model/User.cpp @@ -35,6 +35,8 @@ User::~User() void User::InvalidateOperations() { std::map >* >::iterator it; + std::vector::iterator it2; + int i; for (it = _operations.begin(); it != _operations.end(); it++) { @@ -48,6 +50,11 @@ void User::InvalidateOperations() std::sort(_accounts.begin(), _accounts.end(), Account()); std::sort(_categories.begin(), _categories.end(), Category()); + + for (i=0, it2=_categories.begin(); it2 !=_categories.end(); it2++, i++) + { + _categoriesFonts[i] = KissCount::ExtractFont(it2->font); + } } Category User::GetCategory(int catId) diff --git a/src/view/wxUI.cpp b/src/view/wxUI.cpp index 41ff229..d9aee22 100644 --- a/src/view/wxUI.cpp +++ b/src/view/wxUI.cpp @@ -238,12 +238,20 @@ void wxUI::LoadPanels() void wxUI::LoadUser() { User* user = _kiss->GetUser(); + int i; if (user->_preferences["language"].size()) SetLanguage(user->GetLanguage()); else SetLanguage(SupportedLanguages::languages[0].name); + // Sort with translated names + std::sort(user->_categories.begin(), user->_categories.end(), Category()); + for (i=0; i < (int)user->_categories.size(); i++) + { + user->_categoriesFonts[i] = KissCount::ExtractFont(user->_categories[i].font); + } + LoadPanels(); if (_panels.size())