fullScreenToolButton->sizeHint().height()*2);
#endif*/
- searchingProgressBar = new QProgressBar();
+ searchingProgressBar = new QProgressBar(this);
//progress bar has minimum and maximum values set to 0, which will effect
//with "I'm alive" bar
searchingProgressBar->setMinimum(0);
QTextDocument *document = textEdit->document();
document->addResource(QTextDocument::ImageResource, QUrl("mydata://image.png"), QVariant(image));
+
+ qDebug()<<trans;
+
trans=tr("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") + tr("\n <ar>") + trans + tr("\n </ar>");
trans=XslConversion(trans);
+
+
textEdit->insertHtml(trans);
// textEdit->setPlainText(trans);
</xsl:template>
<xsl:template match="info">
-<<<<<<< HEAD
<!-- <xsl:variable name="path" select="info/@path"/>-->
- <tr bgcolor="#99FF99">
- <th>
+ <tr>
+ <th class="info">
<xsl:if test="@bookmark = 'true'">
<img src="mydata://image.png"/>
</xsl:if>
<xsl:value-of select="."/> <!-- <img src="{$path}"/> -->
</th>
-=======
- <tr>
- <th class="info"><xsl:value-of select="."/></th>
->>>>>>> 3e7118bfec64f44b11205ca836cb1a82c725d123
</tr>
</xsl:template>
<xsl:template match="key">
-<<<<<<< HEAD
- <tr bgcolor="#99CCFF">
- <th><xsl:value-of select="."/></th>
- </tr>
-=======
<tr>
- <th class="key"><xsl:value-of select="."/></th>
- </tr>
->>>>>>> 3e7118bfec64f44b11205ca836cb1a82c725d123
+ <th class="key"><xsl:value-of select="."/></th>
+ </tr>
</xsl:template>
<xsl:template match="t">
[<p><xsl:apply-templates/></p>]
</xsl:template>
+<xsl:template match="pos">
+ (<p><xsl:apply-templates/></p>)
+</xsl:template>
+
<xsl:template match="pot">
,<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:variable name="atr" select="@c"/>
<font color="{$atr}"> <xsl:apply-templates/></font>
</xsl:template>
+<!--
+<xsl:template match="table">
+ <table>
+ <xsl:apply-templates/>
+ </table>
+</xsl:template>
+
+<xsl:template match="tr">
+ <tr>
+ <xsl:apply-templates/>
+ </tr>
+</xsl:template>
+
+<xsl:template match="td">
+ <td>
+ <xsl:apply-templates/>
+ </td>
+</xsl:template> -->
</xsl:stylesheet>
plugin->settings()->setValue(key, settings->value(key));
}
delete settings;
+ plugin->getDictionaryInfo();
return plugin;
}
QList<Translation*> GooglePlugin::searchWordList(QString word, int limit) {
QList<Translation*> translations;
- QString url = QString("/translate_a/t?client=t&sl=%1+&tl=%2").arg(_langFrom,_langTo);
- qDebug()<<url;
+ QString url = QString("/translate_a/t?client=t&sl=%1&tl=%2").arg(_langFrom,
+ _langTo);
QHttpRequestHeader head = QHttpRequestHeader("POST", url, 1,1);
head.setValue("Host", "www.google.pl");
head.setValue("User-Agent", "Mozilla/5.0");
while(wait);
QString text = QString::fromUtf8(http->readAll());
-
text=jsonParse(text);
- if(text!=""){
+
+ if(text!="") {
text=tr("<key>") + word + tr("</key>") + tr("<t>") + text + tr("</t>");
translations<<(new TranslationGoogle(word,text,_infoNote,this));
}
int pos=0,pos2=0;
int index=0;
int size=0;
-
QString returnLang;
QString translation;
QString original;
pos=result.indexOf("\"",pos+1);
pos=result.indexOf("\"",pos+1);
pos=result.indexOf("\"",pos+1);
+ QList<QString> *list=new QList<QString>;
while(pos2>pos && pos2!=-1 && pos!= -1) {
index++;
if(size==index)
return QString("");
- QList<QString> *list=new QList<QString>;
list->append(list1.at(index*2+1));
- words.append(list);
pos=result.indexOf("\"",pos+1);
pos=result.indexOf("\"",pos+1);
}
+ words.append(list);
index++;
if(size==index)
return QString("");
pos=pos2+2;
}
- returnLang=list1.at(index*2+1);
-
- if(returnLang!=_langFrom)
+ if(words.size()!=partOfSpeach.size()) {
+ qDebug()<<"Error in Google Plugin (JsonParse)";
return QString("");
-
- //result=translation;
-
+ }
+ returnLang=list1.at(index*2+1);
+ if(partOfSpeach.size()==0){
+ if(translation==original){
+ qDebug()<<"This word don't exist";
+ return QString("");
+ }
+ else
+ return "\""+translation+"\"";
+ }
+ result=translation;
+ for(int i=0; i<words.size();i++) {
+ result+="<pos>"+partOfSpeach.at(i)+"</pos>:";
+ for(int j=0; j<words.at(i)->size();j++)
+ result+=words.at(i)->at(j)+" ";
+ }
return result;
}
wait=false;
}
-void GooglePlugin::started(int a) {
- qDebug()<<"test";
-}
-
void GooglePlugin::stop() {
stopped=true;
}
languages["UNKNOWN"] = "";
}
+void GooglePlugin::getDictionaryInfo() {
+ QString fullLangFrom=languages.key(_langFrom);
+ QString fullLangTo=languages.key(_langTo);
+ _infoNote=" [" + fullLangFrom + "-";
+ _infoNote+= fullLangTo + "] (" + _type + ")";
+}
+
+
Q_EXPORT_PLUGIN2(google, GooglePlugin)
void stop();
void done();
- void started(int);
private:
void initLanguages();
QString jsonParse(QString result);
+ void getDictionaryInfo();
QMap<QString, QString> languages;
//! language from which we translate
QString TranslationGoogle::toHtml() const {
QString result("");
- if(googlePlugin) {
- result+="<dict> <info bookmark=\"false\">GOOGLE TRANSLATOR </info>";
- result+=_trans +"</dict>";
- }
- qDebug()<<"test"+result;
- return result;
+ if(!googlePlugin)
+ return result;
+ result="<dict> <info path=\"\" ";
+ if(isBookmark())
+ result+="bookmark=\"true\" >";
+ else
+ result+="bookmark=\"false\" >";
+ result+=_dictionaryInfo+ "</info>"+_trans +"</dict>";
}
void TranslationGoogle::setKey(QString) {
Settings *settings=new Settings;
settings->setValue("langFrom","pl");
settings->setValue("langTo","en");
-
-
-jsonParse(QString result)
-
-
-
- while(1)
- qDebug()<<signa.count();
}
QTEST_MAIN(GoogleTest)
// qDebug()<<QPixmap(test).save(initialPath,format.toAscii());
// qDebug()<<QPixmap("/home/jakub/star.jpg").save(initialPath,format.toAscii());
- _infoNote="path=\""+initialPath+"\">"+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")";
+ _infoNote="path=\""+initialPath+"\"> \n" + _name + " [" + _langFrom + "-" + _langTo + "] (" + _type + ")";
dictionaryFile.close();
}