2009-01-28 20:55:45 +00:00
|
|
|
/* 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__
|
|
|
|
|
2009-02-01 00:08:08 +00:00
|
|
|
#include <QObject>
|
2009-01-28 20:55:45 +00:00
|
|
|
#include "dictionary.hh"
|
|
|
|
#include "instances.hh"
|
|
|
|
|
|
|
|
/// This class generates the article's body for the given lookup request
|
2009-02-01 00:08:08 +00:00
|
|
|
class ArticleMaker: public QObject
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
2009-02-01 00:08:08 +00:00
|
|
|
Q_OBJECT // We make it QObject to use tr() conveniently
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
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;
|
2009-02-01 00:08:08 +00:00
|
|
|
|
|
|
|
/// 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 );
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|