Logo Search packages:      
Sourcecode: qstardict version File versions  Download package

QString QStarDict::DictCore::translate ( const QString &  word  ) 

Returns translation for word. If word not found, returns "Not found!"

Definition at line 62 of file dictcore.cpp.

References QStarDict::DictPlugin::Translation::dictName(), QStarDict::DictPlugin::isTranslatable(), plugin(), QStarDict::DictPlugin::Translation::title(), QStarDict::DictPlugin::translate(), and QStarDict::DictPlugin::Translation::translation().

Referenced by QStarDict::DBusAdaptor::translate(), and QStarDict::DBusAdaptor::translateHtml().

{
    QString simplifiedWord = word.simplified();
    QString result;
    for (QList<Dictionary>::const_iterator i = m_loadedDicts.begin(); i != m_loadedDicts.end(); ++i)
    {
        if (! m_plugins.contains(i->plugin()))
            continue;
        DictPlugin *plugin = qobject_cast<DictPlugin*>(m_plugins[i->plugin()]->instance());
        if (! plugin->isTranslatable(i->name(), simplifiedWord))
            continue;
        DictPlugin::Translation translation = plugin->translate(i->name(), simplifiedWord);
        result += "<p>\n"
            "<font class=\"dict_name\">" + translation.dictName() + "</font><br>\n"
            "<font class=\"title\">" + translation.title() + "</font><br>\n"
            + translation.translation() + "</p>\n";
    }
    return result;
}


Generated by  Doxygen 1.6.0   Back to index