src/hbcore/inputfw/hbinputextrauserdictionary.cpp
changeset 28 b7da29130b0e
parent 6 c3690ec91ef8
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    34 
    34 
    35 #include "hbinputsettingproxy.h"
    35 #include "hbinputsettingproxy.h"
    36 
    36 
    37 const int HbExtraDictMaxFrequency = 255;
    37 const int HbExtraDictMaxFrequency = 255;
    38 
    38 
       
    39 const QString RomanHundreds[10] = {"C","CC","CCC","CD","D","DC","DCC","DCCC","CM","M"};
       
    40 const QString RomanTens[9] = {"X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
       
    41 const QString RomanOnes[9] = {"I","II","III","IV","V","VI","VII","VIII","IX"};
       
    42 
    39 /*!
    43 /*!
    40 @proto
    44 @proto
    41 @hbcore
    45 @hbcore
    42 \class HbExtraUserDictionary
    46 \class HbExtraUserDictionary
    43 \brief A generic implementation of HbUserDictionary class.
    47 \brief A generic implementation of HbUserDictionary class.
    97     return true;
   101     return true;
    98 }
   102 }
    99 
   103 
   100 QString HbExtraUserDictionaryPrivate::name() const
   104 QString HbExtraUserDictionaryPrivate::name() const
   101 {
   105 {
   102     QString num;
   106     
   103     num.setNum(id);
   107     QString num(convertToRomanNumerals(id));
   104 
       
   105     return QString(KExtraUserDictKeyBase) + num;
   108     return QString(KExtraUserDictKeyBase) + num;
   106 }
   109 }
   107 
   110 
   108 QString HbExtraUserDictionaryPrivate::fileName() const
   111 QString HbExtraUserDictionaryPrivate::fileName() const
   109 {
   112 {
   110     return HbInputSettingProxy::extraDictionaryPath() + QDir::separator() + name() + QString(KExtraFileExt);
   113     return HbInputSettingProxy::extraDictionaryPath() + QDir::separator() + name() + QString(KExtraFileExt);
       
   114 }
       
   115 
       
   116 QString HbExtraUserDictionaryPrivate::convertToRomanNumerals(int id) const
       
   117 {
       
   118     int numId = id; 
       
   119     QString retNum;
       
   120     
       
   121     // Append Roman Thousand's to the string
       
   122     int index = 10;
       
   123     int count = numId/1000;
       
   124     for (int i = 0; i < count; i++) {
       
   125         retNum.append(RomanHundreds[index-1]);
       
   126     }
       
   127 
       
   128     // Append Roman Hundred's to the string
       
   129     numId = numId % 1000;
       
   130     index = numId / 100;
       
   131     if (index) {
       
   132         retNum.append(RomanHundreds[index - 1]);
       
   133     }
       
   134 
       
   135     // Append Roman Ten's to the string
       
   136     numId = numId % 100;
       
   137     index = numId / 10;
       
   138     if (index) {
       
   139         retNum.append(RomanTens[index - 1]);
       
   140     }
       
   141     // Append Roman single digit numerals to the string
       
   142     numId = numId % 10;
       
   143     index = numId / 1;
       
   144     if (index) {
       
   145         retNum.append(RomanOnes[index - 1]);
       
   146     }
       
   147     return retNum;
   111 }
   148 }
   112 
   149 
   113 bool HbExtraUserDictionaryPrivate::save(QString fileName)
   150 bool HbExtraUserDictionaryPrivate::save(QString fileName)
   114 {
   151 {
   115     QFile file(fileName);
   152     QFile file(fileName);