PDA

View Full Version : How to display flash video on QHelp documentation



sebboh
21st June 2010, 16:29
Hi all,

I'm trying to devellop my own "widget assistant" using QtHelp to manage some software documentation. To be able to show the ressources (png, css & co) of the html pages I overloaded some QNetworkAccessManager Method and QNetworkRequest Method :


QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
const QNetworkRequest &request, QIODevice* /*outgoingData*/)
{
qDebug("dbt");
const QUrl& url = request.url();
QString mimeType = url.toString();
if (mimeType.endsWith(QLatin1String(".svg"))
|| mimeType.endsWith(QLatin1String(".svgz"))) {
mimeType = QLatin1String("image/svg+xml");
} else if (mimeType.endsWith(QLatin1String(".css"))) {
mimeType = QLatin1String("text/css");
} else if (mimeType.endsWith(QLatin1String(".js"))) {
mimeType = QLatin1String("text/javascript");
} else if (mimeType.endsWith(QLatin1String(".txt"))) {
mimeType = QLatin1String("text/plain");
} else if (mimeType.endsWith(QLatin1String(".swf"))) {
mimeType = QLatin1String("application/x-shockwave-flash");
} else {
mimeType = QLatin1String("text/html");
}

const QByteArray &data = helpEngine->findFile(url).isValid()
? helpEngine->fileData(url) : QByteArray("File not found!");
qDebug(url.toString());
qDebug("fin");
return new HelpNetworkReply(request, data, mimeType);
}


HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request,
const QByteArray &fileData, const QString& mimeType)
: data(fileData), origLen(fileData.length())
{
qDebug("DBT NETWORK REPLY");
setRequest(request);
setOpenMode(QIODevice::ReadOnly);

setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen));
QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
QTimer::singleShot(0, this, SIGNAL(readyRead()));
qDebug("FIN NETWORK REPLY");
}


qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
{
qDebug("DBT READ DATA");
qint64 len = qMin(qint64(data.length()), maxlen);
if (len) {
qMemCopy(buffer, data.constData(), len);
data.remove(0, len);
}
if (!data.length())
QTimer::singleShot(0, this, SIGNAL(finished()));

qDebug("FIN READ DATA");
return len;
}

It works well and now I can display all my qhc documentation with pictures and other ressources. Nevertheless I'm not able to display well swf video. On my page, instead of the flash video there is a white box. The plugin seems not be able to load the .swf file but I dont understand why.
Is there someone who could help me to understand ?

Thanks in advance for you response,

Sebboh.

PS : i'm not a native english speaker, sorry if there are any mistakes