goldendict-ng/src/article_maker.hh

44 lines
1.7 KiB
C++
Raw Normal View History

/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.sf.net>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __ARTICLE_MAKER_HH_INCLUDED__
#define __ARTICLE_MAKER_HH_INCLUDED__
#include <QObject>
#include "dictionary.hh"
#include "instances.hh"
/// This class generates the article's body for the given lookup request
class ArticleMaker: public QObject
{
Q_OBJECT // We make it QObject to use tr() conveniently
std::vector< sptr< Dictionary::Class > > const & dictionaries;
std::vector< Instances::Group > const & groups;
public:
/// On construction, a reference to all dictionaries and a reference all
/// groups' instances are to be passed. Those references are kept stored as
/// references, and as such, any changes to them would reflect on the results
/// of the inquiries, altthough those changes are perfectly legal.
ArticleMaker( std::vector< sptr< Dictionary::Class > > const & dictionaries,
std::vector< Instances::Group > const & groups );
/// Looks up the given word within the given group, and creates a full html
/// page text containing its definition.
std::string makeDefinitionFor( QString const & word, QString const & group ) const;
/// Makes up a text which states that no translation for the given word
/// was found. Sometimes it's better to call this directly when it's already
/// known that there's no translation.
std::string makeNotFoundTextFor( QString const & word, QString const & group ) const;
private:
/// Makes everything up to and including the opening body tag.
static std::string makeHtmlHeader( QString const & word, QString const & icon );
};
#endif