tools/linguist/shared/translatormessage.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   141         || needs8BitHelper(m_comment)
   141         || needs8BitHelper(m_comment)
   142         || needs8BitHelper(m_context);
   142         || needs8BitHelper(m_context);
   143 }
   143 }
   144 
   144 
   145 
   145 
   146 bool TranslatorMessage::operator==(const TranslatorMessage& m) const
       
   147 {
       
   148     static QString msgIdPlural = QLatin1String("po-msgid_plural");
       
   149 
       
   150     // Special treatment for context comments (empty source).
       
   151     return (m_context == m.m_context)
       
   152         && m_sourcetext == m.m_sourcetext
       
   153         && m_extra[msgIdPlural] == m.m_extra[msgIdPlural]
       
   154         && m_id == m.m_id
       
   155         && (m_sourcetext.isEmpty() || m_comment == m.m_comment);
       
   156 }
       
   157 
       
   158 
       
   159 bool TranslatorMessage::operator<(const TranslatorMessage& m) const
       
   160 {
       
   161     if (m_context != m.m_context)
       
   162         return m_context < m.m_context;
       
   163     if (m_sourcetext != m.m_sourcetext)
       
   164         return m_sourcetext < m.m_sourcetext;
       
   165     if (m_comment != m.m_comment)
       
   166         return m_comment < m.m_comment;
       
   167     return m_id < m.m_id;
       
   168 }
       
   169 
       
   170 int qHash(const TranslatorMessage &msg)
       
   171 {
       
   172     return
       
   173         qHash(msg.context()) ^
       
   174         qHash(msg.sourceText()) ^
       
   175         qHash(msg.extra(QLatin1String("po-msgid_plural"))) ^
       
   176         qHash(msg.comment()) ^
       
   177         qHash(msg.id());
       
   178 }
       
   179 
       
   180 bool TranslatorMessage::hasExtra(const QString &key) const
   146 bool TranslatorMessage::hasExtra(const QString &key) const
   181 {
   147 {
   182     return m_extra.contains(key);
   148     return m_extra.contains(key);
   183 }
   149 }
   184 
   150