diff --git a/about.cc b/about.cc
index f11b3f8a..4aa03804 100644
--- a/about.cc
+++ b/about.cc
@@ -44,7 +44,7 @@ About::About( QWidget * parent ): QDialog( parent )
{
QStringList creditsList =
QString::fromUtf8(
- creditsFile.readAll() ).split( '\n', QString::SkipEmptyParts );
+ creditsFile.readAll() ).split( '\n', Qt::SkipEmptyParts );
QString html = "
";
diff --git a/article_maker.cc b/article_maker.cc
index 0cb85db7..159e169a 100644
--- a/article_maker.cc
+++ b/article_maker.cc
@@ -14,6 +14,7 @@
#include "langcoder.hh"
#include "gddebug.hh"
#include "utils.hh"
+#include "globalbroadcaster.h"
using std::vector;
using std::string;
@@ -55,6 +56,10 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word,
{
result += "";
+
+ //custom javascript
+ result += "";
}
// add qwebchannel
@@ -630,6 +635,7 @@ void ArticleRequest::bodyFinished()
bool wasUpdated = false;
+ QStringList dictIds;
while ( bodyRequests.size() )
{
// Since requests should go in order, check the first one first
@@ -649,7 +655,7 @@ void ArticleRequest::bodyFinished()
activeDicts[ activeDicts.size() - bodyRequests.size() ];
string dictId = activeDict->getId();
-
+ dictIds << QString::fromStdString(dictId);
string head;
string gdFrom = "gdfrom-" + Html::escape( dictId );
@@ -702,14 +708,6 @@ void ArticleRequest::bodyFinished()
}
string jsVal = Html::escapeForJavaScript( dictId );
- head += "";
head += string( "emitDictIds(ActiveDictIds{word, dictIds});
+ }
+ } else if (wasUpdated) {
update();
+ qDebug() << "send dicts(updated):" << dictIds;
+ emit GlobalBroadcaster::instance()->emitDictIds(ActiveDictIds{word, dictIds});
+ }
}
void ArticleRequest::stemmedSearchFinished()
diff --git a/article_netmgr.cc b/article_netmgr.cc
index f38a7c85..cc8b8f40 100644
--- a/article_netmgr.cc
+++ b/article_netmgr.cc
@@ -207,10 +207,10 @@ QNetworkReply * ArticleNetworkAccessManager::createRequest( Operation op,
return QNetworkAccessManager::createRequest( op, newReq, outgoingData );
}
-
- QString contentType;
-
QUrl url=req.url();
+ QMimeType mineType=db.mimeTypeForUrl (url);
+ QString contentType=mineType.name();
+
if(req.url().scheme()=="gdlookup"){
QString path=url.path();
if(!path.isEmpty()){
@@ -379,7 +379,6 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
{
if( url.scheme() == "gico" )
{
- contentType="image/png";
QByteArray bytes;
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
@@ -485,8 +484,6 @@ qint64 ArticleResourceReply::readData( char * out, qint64 maxSize )
if ( maxSize == 0 )
return 0;
- GD_DPRINTF( "====reading %d bytes\n", (int)maxSize );
-
bool finished = req->isFinished();
qint64 avail = req->dataSize();
@@ -497,6 +494,7 @@ qint64 ArticleResourceReply::readData( char * out, qint64 maxSize )
qint64 left = avail - alreadyRead;
qint64 toRead = maxSize < left ? maxSize : left;
+ GD_DPRINTF( "====reading %d bytes\n", (int)toRead );
try
{
@@ -517,13 +515,15 @@ qint64 ArticleResourceReply::readData( char * out, qint64 maxSize )
void ArticleResourceReply::readyReadSlot()
{
- readyRead();
+ emit readyRead();
}
void ArticleResourceReply::finishedSlot()
{
- if ( req->dataSize() < 0 )
- error( ContentNotFoundError );
+ if (req->dataSize() < 0) {
+ emit error(ContentNotFoundError);
+ setError(ContentNotFoundError, "content not found");
+ }
emit finished();
}
diff --git a/article_netmgr.hh b/article_netmgr.hh
index 61cdfc47..ea903b27 100644
--- a/article_netmgr.hh
+++ b/article_netmgr.hh
@@ -99,6 +99,7 @@ class ArticleNetworkAccessManager: public QNetworkAccessManager
ArticleMaker const & articleMaker;
bool const & disallowContentFromOtherSites;
bool const & hideGoldenDictHeader;
+ QMimeDatabase db;
public:
diff --git a/articleview.cc b/articleview.cc
index a6a8fa34..2541643b 100644
--- a/articleview.cc
+++ b/articleview.cc
@@ -28,7 +28,7 @@
#include
#include
#include