eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot dic/header.cpp dic/header.h dic/tile.cpp ...


From: Olivier Teulière
Subject: [Eliot-dev] eliot dic/header.cpp dic/header.h dic/tile.cpp ...
Date: Sun, 28 Jun 2009 11:48:17 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Olivier Teulière <ipkiss>       09/06/28 11:48:17

Modified files:
        dic            : header.cpp header.h tile.cpp tile.h 
        qt             : dic_tools_widget.cpp 

Log message:
        Display the alternative inputs in the dictionary information tab

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/header.cpp?cvsroot=eliot&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/header.h?cvsroot=eliot&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/tile.cpp?cvsroot=eliot&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/tile.h?cvsroot=eliot&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/dic_tools_widget.cpp?cvsroot=eliot&r1=1.9&r2=1.10

Patches:
Index: dic/header.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/header.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- dic/header.cpp      28 Jun 2009 10:55:24 -0000      1.11
+++ dic/header.cpp      28 Jun 2009 11:48:17 -0000      1.12
@@ -336,7 +336,7 @@
 const wdstring & Header::getDisplayStr(unsigned int iCode) const
 {
     // Safety check
-    if (iCode == 0 || iCode > m_displayCache.size())
+    if (iCode == 0 || iCode > m_letters.size())
     {
         ostringstream oss;
         oss << iCode;
@@ -346,6 +346,28 @@
 }
 
 
+vector<wistring> Header::getInputStr(unsigned int iCode) const
+{
+    // Safety check
+    if (iCode == 0 || iCode > m_letters.size())
+    {
+        ostringstream oss;
+        oss << iCode;
+        throw DicException("Header::getInputStr: No code for letter '" + 
oss.str());
+    }
+    map<wchar_t, vector<wstring> >::const_iterator it =
+        m_displayAndInputData.find(m_letters[iCode - 1]);
+    if (it == m_displayAndInputData.end())
+    {
+        vector<wistring> vect;
+        vect.push_back(m_displayCache[iCode]);
+        return vect;
+    }
+    else
+        return it->second;
+}
+
+
 wdstring Header::convertToDisplay(const wstring &iWord) const
 {
     // Optimization for dictionaries without display nor input chars,

Index: dic/header.h
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/header.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- dic/header.h        28 Jun 2009 10:55:24 -0000      1.9
+++ dic/header.h        28 Jun 2009 11:48:17 -0000      1.10
@@ -133,6 +133,11 @@
     const wdstring & getDisplayStr(unsigned int iCode) const;
 
     /**
+     * Return all the accepted input strings corresponding to the given code
+     */
+    vector<wistring> getInputStr(unsigned int iCode) const;
+
+    /**
      * Convert the given string (made of internal characters)
      * into a string suitable for display
      */

Index: dic/tile.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/tile.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- dic/tile.cpp        23 Jun 2009 12:41:53 -0000      1.4
+++ dic/tile.cpp        28 Jun 2009 11:48:17 -0000      1.5
@@ -110,6 +110,15 @@
 }
 
 
+vector<wistring> Tile::getInputStr() const
+{
+    if (m_code == 0)
+        throw DicException("Tile::getInputStr: Invalid tile");
+    // We always return uppercase strings
+    return m_header->getInputStr(m_code);
+}
+
+
 wchar_t Tile::toChar() const
 {
     if (m_joker)

Index: dic/tile.h
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/tile.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- dic/tile.h  23 Jun 2009 12:41:53 -0000      1.5
+++ dic/tile.h  28 Jun 2009 11:48:17 -0000      1.6
@@ -59,6 +59,7 @@
     wchar_t toChar() const;
     unsigned int toCode() const;
     wstring getDisplayStr() const;
+    vector<wstring> getInputStr() const;
 
     static const Tile &Joker()  { return m_TheJoker; }
 

Index: qt/dic_tools_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/dic_tools_widget.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- qt/dic_tools_widget.cpp     27 Jun 2009 18:09:44 -0000      1.9
+++ qt/dic_tools_widget.cpp     28 Jun 2009 11:48:17 -0000      1.10
@@ -99,12 +99,13 @@
 
     m_dicInfoModel = new QStandardItemModel(this);
     treeViewDicLetters->setModel(m_dicInfoModel);
-    m_dicInfoModel->setColumnCount(5);
+    m_dicInfoModel->setColumnCount(6);
     m_dicInfoModel->setHeaderData(0, Qt::Horizontal, _q("Letter"), 
Qt::DisplayRole);
     m_dicInfoModel->setHeaderData(1, Qt::Horizontal, _q("Points"), 
Qt::DisplayRole);
     m_dicInfoModel->setHeaderData(2, Qt::Horizontal, _q("Frequency"), 
Qt::DisplayRole);
     m_dicInfoModel->setHeaderData(3, Qt::Horizontal, _q("Vowel?"), 
Qt::DisplayRole);
     m_dicInfoModel->setHeaderData(4, Qt::Horizontal, _q("Consonant?"), 
Qt::DisplayRole);
+    m_dicInfoModel->setHeaderData(5, Qt::Horizontal, _q("Alternative input"), 
Qt::DisplayRole);
 }
 
 
@@ -320,6 +321,13 @@
                            it->isVowel() ? _q("Yes") : _q("No"));
             model->setData(model->index(rowNum, 4),
                            it->isConsonant() ? _q("Yes") : _q("No"));
+            const vector<wistring> &inputVect = it->getInputStr();
+            wstring tmp;
+            for (unsigned int i = 1; i < inputVect.size(); ++i)
+            {
+                tmp += inputVect[i] + L"  ";
+            }
+            model->setData(model->index(rowNum, 5), qfw(tmp));
             ++rowNum;
         }
         treeViewDicLetters->resizeColumnToContents(0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]