goldendict-ng/forvo.hh
Konstantin Isakov a5a2b4d67e Make Forvo support translatable.
We achieve this by making ForvoArticleRequest a proper Q_OBJECT.
2010-11-23 02:50:30 +03:00

68 lines
1.6 KiB
C++

/* This file is (c) 2008-2011 Konstantin Isakov <ikm@users.berlios.de>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __FORVO_HH_INCLUDED__
#define __FORVO_HH_INCLUDED__
#include "dictionary.hh"
#include "config.hh"
#include <QNetworkAccessManager>
#include "wstring.hh"
#include <QNetworkReply>
/// Support for Forvo pronunciations, based on its API.
namespace Forvo {
using std::vector;
using std::string;
using gd::wstring;
vector< sptr< Dictionary::Class > > makeDictionaries(
Dictionary::Initializing &,
Config::Forvo const &,
QNetworkAccessManager & )
throw( std::exception );
/// Exposed here for moc
class ForvoArticleRequest: public Dictionary::DataRequest
{
Q_OBJECT
struct NetReply
{
sptr< QNetworkReply > reply;
string word;
bool finished;
NetReply( sptr< QNetworkReply > const & reply_, string const & word_ ):
reply( reply_ ), word( word_ ), finished( false )
{}
};
typedef std::list< NetReply > NetReplies;
NetReplies netReplies;
QString apiKey, languageCode;
string dictionaryId;
public:
ForvoArticleRequest( wstring const & word, vector< wstring > const & alts,
QString const & apiKey_,
QString const & languageCode_,
string const & dictionaryId_,
QNetworkAccessManager & mgr );
virtual void cancel();
private:
void addQuery( QNetworkAccessManager & mgr, wstring const & word );
private slots:
virtual void requestFinished( QNetworkReply * );
};
}
#endif