Commit 8e695fb8 authored by Anatoly Mihalchenko's avatar Anatoly Mihalchenko

Merge branch 'master' of github.com:Sankore/Sankore-3.1

parents a4908414 2f485a87
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:ub="http://uniboard.mnemis.com/widgets"
id="http://uniboard.mnemis.com/widgets/notes"
version="1.2"
width="900"
height="450"
ub:resizable="true">
<name>Notes</name>
<author href="http://www.getuniboard.com"
email="info@mnemis.com">Mnemis SA</author>
<description>Associer images</description>
<content src="index.html"/>
</widget>
html, body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background-color: white;
}
.toggle_mode{
width: 100%;
height: 25px;
border-bottom: 1px solid black;
background-color: #ccc;
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
#display_img, #edit_img{
width: 15px;
height: 15px;
margin: 5px 10px;
}
.green_point{
background-image: url(../img/green_point.png);
}
.red_point{
background-image: url(../img/red_point.png);
}
#display_text, #edit_text{
height: 19px;
padding: 3px 0 0 0;
}
.selected{
background-color: #666;
}
#display:hover, #edit:hover{
background-color: #999;
}
.cont{
width: 100%;
border-bottom: 1px solid black;
margin: 0;
padding: 0;
position: relative;
}
.sub_cont{
width: 100%;
padding: 0;
margin: 20px 0 0 0;
min-height: 60px;
}
.imgs_cont{
width: 100%;
min-height: 142px;
margin: 0;
}
.imgs_answers{
width: 162px;
margin: 0 auto;
margin-bottom: 10px;
min-height: 142px;
border: 2px dashed #ccc;
text-align: center;
}
.imgs_answers_gray{
background-color: #f4f2f2;
}
.imgs_answers_green{
background-color: #9f9;
}
.imgs_answers_red{
background-color: #f99;
}
.number_cont{
width: 40px;
height: 33px;
margin-left: 40px;
margin-right: 10px;
background-image: url(../img/circle.png);
background-repeat: no-repeat;
text-align: center;
float: left;
font-size: 130%;
padding-top: 7px;
font-weight: bold;
}
.text_cont{
width: 80%;
min-height: 40px;
float: right;
background-color: #ccc;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
padding-left: 10px;
}
.close_cont{
width: 20px;
height: 20px;
background-image: url(../img/close_cont.png);
cursor: pointer;
position: absolute;
top: -15px;
left: 5px;
}
.add_img{
width: 120px;
height: 120px;
margin: 10px 20px;
background-image: url(../img/add_img.png);
background-position: center;
background-repeat: no-repeat;
cursor: pointer;
display: inline-block;
}
.img_block{
width: 120px;
height: 120px;
margin: 10px 20px;
cursor: pointer;
display: inline-block;
position: relative;
background-color: white;
}
.img_gray{
border: 1px solid #ccc;
-moz-box-shadow: #ccc -1px 0 4px;
-webkit-box-shadow: #ccc -1px 0 4px;
box-shadow: #ccc -1px 0 4px;
}
.close_img, .clear_img, .true_img, .false_img{
width: 30px;
height: 30px;
background-repeat: no-repeat;
position: absolute;
right: -15px;
cursor: pointer;
}
.close_img{
background-image: url(../img/close_img.png);
top: -15px;
}
.clear_img{
background-image: url(../img/clear_img.png);
top: 15px;
}
.true_img{
background-image: url(../img/false.png);
top: 45px;
}
.false_img{
background-image: url(../img/true.png);
top: 45px;
}
.add_block{
margin: 20px 0 0 20px;
width: 110px;
height: 25px;
background-image: url(../img/add_block.png);
background-repeat: no-repeat;
padding-left: 40px;
padding-top: 5px;
cursor: pointer;
background-color: #ccc;
-webkit-border-radius: 15px;
border-radius: 15px;
}
.dropHere{
background-color: #ccc;
}
.dropBack{
background-color: #F4F2F2;
}
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content {
display: none;
position:fixed;
top: 50%;
left: 50%;
width: 340px;
height: 480px;
padding: 16px;
background-color: white;
z-index:1002;
overflow: auto;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>D'n'd</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="css/basic.css"/>
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var lang = ""; //locale language
if(window.sankore){
lang = sankore.locale().substr(0,2);
} else
lang = "en";
if(lang == "en")
start();
else{
returnStatus(lang);
}
function returnStatus(lang){
$.ajax({
type: 'POST',
url:'locales/' + lang + '/index.html',
statusCode: {
404: function() {
start();
},
200: function(){
window.location.href = 'locales/' + lang + '/index.html';
}
}
});
}
//here you can put your code
if(window.sankore)
sankore.enableDropOnWidget();
});
</script>
</head>
<body>
<!--<div class="dnd_container">
<div class="dnd_1" id="dnd_1" ondragenter="return false;" ondragleave="$(this).css('border-color','#ccc'); return false;" ondragover="$(this).css('border-color','orange'); return false;" ondrop="$(this).css('border-color','#ccc'); return onDropTarget1(event);">Drop the item here ...</div>
<div class="dnd_2" id="dnd_2" ondragenter="return false;" ondragleave="$(this).css('border-color','#ccc'); return false;" ondragover="$(this).css('border-color','orange'); return false;" ondrop="$(this).css('border-color','#ccc'); return onDropTarget2(event);">Drop the item here ...</div>
</div>
<div class='black_overlay' id='fade'></div>
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">открыть</a></p>
<div id="light" class="white_content">
Содержание<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">закрыть</a></div>-->
<div class="toggle_mode">
<div style="width: 50%; height: 100%; float: left;">
<div id="display" style="float: right; width: 90px; cursor: pointer;" class="selected">
<div id="display_img" style="float: right;" class="green_point"></div>
<div id="display_text" style="float: right;">Display</div>
</div>
</div>
<div style="width: 50%; height: 100%; float: right;">
<div id="edit" style="float: left; width: 90px; cursor: pointer;">
<div id="edit_img" style="float: left;" class="red_point"></div>
<div id="edit_text" style="float: left;">Edit</div>
</div>
</div>
</div>
<div style="width: 100%; height: 25px;"></div>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html>
<head>
<title>D'n'd</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="../../css/basic.css"/>
<script type="text/javascript" src="../../js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../../js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
$(document).ready(function(){
start();
//here you can put your code
if(window.sankore)
sankore.enableDropOnWidget();
});
</script>
</head>
<body>
<div class="toggle_mode">
<div style="width: 50%; height: 100%; float: left;">
<div id="display" style="float: right; width: 120px; cursor: pointer;" class="selected">
<div id="display_img" style="float: right;" class="green_point"></div>
<div id="display_text" style="float: right;"></div>
</div>
</div>
<div style="width: 50%; height: 100%; float: right;">
<div id="edit" style="float: left; width: 120px; cursor: pointer;">
<div id="edit_img" style="float: left;" class="red_point"></div>
<div id="edit_text" style="float: left;"></div>
</div>
</div>
</div>
<div style="width: 100%; height: 25px;"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>D'n'd</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="../../css/basic.css"/>
<script type="text/javascript" src="../../js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../../js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
$(document).ready(function(){
start();
//here you can put your code
if(window.sankore)
sankore.enableDropOnWidget();
});
</script>
</head>
<body>
<div class="toggle_mode">
<div style="width: 50%; height: 100%; float: left;">
<div id="display" style="float: right; width: 120px; cursor: pointer;" class="selected">
<div id="display_img" style="float: right;" class="green_point"></div>
<div id="display_text" style="float: right;"></div>
</div>
</div>
<div style="width: 50%; height: 100%; float: right;">
<div id="edit" style="float: left; width: 120px; cursor: pointer;">
<div id="edit_img" style="float: left;" class="red_point"></div>
<div id="edit_text" style="float: left;"></div>
</div>
</div>
</div>
<div style="width: 100%; height: 25px;"></div>
</body>
</html>
......@@ -16,6 +16,7 @@
#include <QWebView>
#include <QDomDocument>
#include <QtGui>
#include "core/UB.h"
#include "core/UBApplication.h"
......@@ -35,9 +36,35 @@
#include "UBWidgetMessageAPI.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/UBDownloadManager.h"
#include "core/memcheck.h"
//Known extentions for files, add if you know more supported
const QString audioExtentions = ".mp3.wma.ogg";
const QString videoExtentions = ".avi.flv";
const QString imageExtentions = ".png.jpg.tif.bmp.tga";
const QString htmlExtentions = ".htm.html.xhtml";
//Allways use aliases instead of const char* itself
const QString imageAlias = "image";
const QString imageAliasCap = "Image";
const QString videoAlias = "video";
const QString videoAliasCap = "Video";
const QString audioAlias = "audio";
const QString audioAliasCap = "Audio";
//Xml tag names
const QString tMainSection = "mimedata";
const QString tType = "type";
const QString tPath = "path";
const QString tMessage = "message";
const QString tReady = "ready";
const QString tMimeText = "text/plain";
//Name of path inside widget to store objects
const QString objectsPath = "objects";
UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidgetItem *widget)
......@@ -47,7 +74,7 @@ UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidg
, mIsVisible(false)
, mMessagesAPI(0)
, mDatastoreAPI(0)
{
{
UBGraphicsW3CWidgetItem* w3CGraphicsWidget = dynamic_cast<UBGraphicsW3CWidgetItem*>(widget);
if (w3CGraphicsWidget)
......@@ -55,6 +82,8 @@ UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidg
mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget->w3cWidget());
mDatastoreAPI = new UBDatastoreAPI(w3CGraphicsWidget);
}
connect(UBDownloadManager::downloadManager(), SIGNAL(downloadFinished(bool,sDownloadFileDesc,QByteArray)), this, SLOT(onDownloadFinished(bool,sDownloadFileDesc,QByteArray)));
}
......@@ -297,6 +326,11 @@ int UBWidgetUniboardAPI::currentPageNumber()
return UBApplication::boardController->activeSceneIndex() + 1;
}
QString UBWidgetUniboardAPI::getObjDir()
{
return mGraphicsWidget->getOwnFolder().toLocalFile() + "/" + objectsPath + "/";
}
void UBWidgetUniboardAPI::showMessage(const QString& message)
{
UBApplication::boardController->showMessage(message, false);
......@@ -451,6 +485,196 @@ QString UBWidgetUniboardAPI::downloadUrl(const QString &objectUrl, const QString
return result;
}
QString UBWidgetUniboardAPI::downloadWeb(const QString &objectUrl)
{
// When we fall there, it means that we are dropping something from the web to the board
sDownloadFileDesc desc;
desc.dest = sDownloadFileDesc::graphicsWidget;
desc.modal = true;
desc.url = objectUrl;
desc.currentSize = 0;
desc.name = QFileInfo(objectUrl).fileName();
desc.totalSize = 0; // The total size will be retrieved during the download
registerIDWidget(UBDownloadManager::downloadManager()->addFileToDownload(desc));
return QString();
}
void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
{
const QMimeData *pMimeData = event->mimeData();
QString destFileName;
QString contentType;
bool downloaded = false;
QGraphicsView *tmpView = mGraphicsWidget->scene()->views().at(0);
QPoint dropPoint(mGraphicsWidget->mapFromScene(tmpView->mapToScene(event->pos())).toPoint());
Qt::DropActions dropActions = event->dropAction();
Qt::MouseButtons dropMouseButtons = event->mouseButtons();
Qt::KeyboardModifiers dropModifiers = event->keyboardModifiers();
QMimeData dropMimeData;
if (pMimeData->hasHtml()) { //Dropping element from web browser
QString qsHtml = pMimeData->html();
QString url = UBApplication::urlFromHtml(qsHtml);
if(!url.isEmpty()) {
QString str = "test string";
QMimeData mimeData;
mimeData.setData(tMimeText, str.toAscii());
sDownloadFileDesc desc;
desc.dest = sDownloadFileDesc::graphicsWidget;
desc.modal = true;
desc.url = url;
desc.currentSize = 0;
desc.name = QFileInfo(url).fileName();
desc.totalSize = 0; // The total size will be retrieved during the download
desc.dropPoint = event->pos(); //Passing pure event point. No modifications
desc.dropActions = dropActions;
desc.dropMouseButtons = dropMouseButtons;
desc.dropModifiers = dropModifiers;
registerIDWidget(UBDownloadManager::downloadManager()->addFileToDownload(desc));
// return;
}
} else if (pMimeData->hasUrls()) { //Local file processing
QUrl curUrl = pMimeData->urls().first();
QString sUrl = curUrl.toString();
if (sUrl.startsWith("file://") || sUrl.startsWith("/")) {
QString fileName = curUrl.toLocalFile();
QString extention = UBFileSystemUtils::extension(fileName);
contentType = UBFileSystemUtils::mimeTypeFromFileName(fileName);
if (supportedTypeHeader(contentType)) {
destFileName = getObjDir() + QUuid::createUuid().toString() + extention;
if (!UBFileSystemUtils::copyFile(fileName, destFileName)) {
qDebug() << "can't copy from" << fileName << "to" << destFileName;
return;
}
downloaded = true;
}
}
}
QString mimeText = createMimeText(downloaded, contentType, destFileName);
dropMimeData.setData(tMimeText, mimeText.toAscii());
QDropEvent readyEvent(dropPoint, dropActions, &dropMimeData, dropMouseButtons, dropModifiers);
//sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&readyEvent);
// readyEvent.acceptProposedAction();
}
void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc desc, QByteArray pData)
{
//if widget recieves is waiting for this id then process
if (!takeIDWidget(desc.id))
return;
if (!pSuccess) {
qDebug() << "can't download the whole data. An error occured";
return;
}
QString contentType = desc.contentTypeHeader;
QString extention = UBFileSystemUtils::fileExtensionFromMimeType(contentType);
if (!supportedTypeHeader(contentType)) {
qDebug() << "actions for mime type" << contentType << "are not supported";
return;
}
QString objDir = getObjDir();
if (!QDir().exists(objDir)) {
if (!QDir().mkpath(objDir)) {
qDebug() << "can't create objects directory path. Check the permissions";
return;
}
}
QString destFileName = objDir + QUuid::createUuid() + "." + extention;
QFile destFile(destFileName);
if (!destFile.open(QIODevice::WriteOnly)) {
qDebug() << "can't open" << destFileName << "for wrighting";
return;
}
if (destFile.write(pData) == -1) {
qDebug() << "can't implement data writing";
return;
}
QGraphicsView *tmpView = mGraphicsWidget->scene()->views().at(0);
QPoint dropPoint(mGraphicsWidget->mapFromScene(tmpView->mapToScene(desc.dropPoint)).toPoint());
QMimeData dropMimeData;
QString mimeText = createMimeText(true, contentType, destFileName);
dropMimeData.setData(tMimeText, mimeText.toAscii());
destFile.close();
QDropEvent readyEvent(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers);
//sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&readyEvent);
readyEvent.acceptProposedAction();
}
QString UBWidgetUniboardAPI::createMimeText(bool downloaded, const QString &mimeType, const QString &fileName)
{
QString mimeXml;
QXmlStreamWriter writer(&mimeXml);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement(tMainSection);
writer.writeTextElement(tReady, boolToStr(downloaded));
if (downloaded) {
if (!mimeType.isEmpty()) {
writer.writeTextElement(tType, mimeType); //writing type of element
}
if (!QFile::exists(fileName)) {
qDebug() << "file" << fileName << "doesn't exist";
return QString();
}
QString relatedFileName = fileName;
relatedFileName = relatedFileName.remove(mGraphicsWidget->getOwnFolder().toLocalFile());
writer.writeTextElement(tPath, relatedFileName); //writing path to created object
}
writer.writeEndElement();
writer.writeEndDocument();
return mimeXml;
}
bool UBWidgetUniboardAPI::supportedTypeHeader(const QString &typeHeader) const
{
return typeHeader.startsWith(imageAlias) || typeHeader.startsWith(imageAliasCap)
|| typeHeader.startsWith(audioAlias) || typeHeader.startsWith(audioAliasCap)
|| typeHeader.startsWith(videoAlias) || typeHeader.startsWith(videoAliasCap);
}
bool UBWidgetUniboardAPI::takeIDWidget(int id)
{
if (webDownloadIds.contains(id)) {
webDownloadIds.removeAll(id);
return true;
}
return false;
}
UBDocumentDatastoreAPI::UBDocumentDatastoreAPI(UBGraphicsW3CWidgetItem *graphicsWidget)
......
......@@ -16,8 +16,10 @@
#define UBWIDGETAPI_H
#include <QtCore>
#include <QDropEvent>
#include "UBW3CWidgetAPI.h"
#include "core/UBDownloadManager.h"
class UBGraphicsScene;
class UBGraphicsWidgetItem;
......@@ -245,6 +247,15 @@ class UBWidgetUniboardAPI : public QObject
* this method download the object on the widget directory and return the path of the downloaded object
*/
QString downloadUrl(const QString &objectUrl, const QString &extention = "");
QString downloadWeb(const QString &objectUrl);
void ProcessDropEvent(QDropEvent *);
private slots:
void onDownloadFinished(bool pSuccess, sDownloadFileDesc desc, QByteArray pData);
private:
inline void registerIDWidget(int id){webDownloadIds.append(id);}
inline bool takeIDWidget(int id);
private:
......@@ -255,6 +266,10 @@ class UBWidgetUniboardAPI : public QObject
int pageCount();
int currentPageNumber();
QString getObjDir();
QString createMimeText(bool downloaded, const QString &mimeType, const QString &fileName);
bool supportedTypeHeader(const QString &) const;
QString boolToStr(bool value) const {return value ? "true" : "false";}
UBGraphicsScene* mScene;
......@@ -265,7 +280,7 @@ class UBWidgetUniboardAPI : public QObject
UBWidgetMessageAPI* mMessagesAPI;
UBDatastoreAPI* mDatastoreAPI;
QList<int> webDownloadIds;
};
......
......@@ -52,7 +52,6 @@
#include "core/memcheck.h"
//Known extentions for files, add if you know more supported
const QString audioExtentions = ".mp3.wma.ogg";
const QString videoExtentions = ".avi.flv";
......@@ -65,11 +64,6 @@ const QString videoAlias = "video";
const QString audioAlias = "audio";
const QString htmlAlias = "html";
//Xml tag names
const QString tMainSection = "mimedata";
const QString tType = "type";
const QString tPath = "path";
UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
: QGraphicsView (pParent)
, mController (pController)
......@@ -643,7 +637,6 @@ UBBoardView::forcedTabletRelease ()
mMouseButtonIsPressed = false;
mTabletStylusIsPressed = false;
mPendingStylusReleaseEvent = false;
}
}
......@@ -766,50 +759,7 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
}
}
QString UBBoardView::processMimeData(const QMimeData *pMimeData, UBGraphicsWidgetItem *widget)
{
QString mimeXml;
QXmlStreamWriter writer(&mimeXml);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement(tMainSection);
if (pMimeData->hasUrls()) {
QList<QUrl> urls = pMimeData->urls();
QString ext = fileExtention(urls.at(0).toLocalFile());
if (ext.isNull()) {
qDebug() << "unknown file type";
return QString();
}
QString fileType = typeForExtention(ext);
if (fileType.isNull()) {
qDebug() << "unknown extention";
return QString();
}
//writing type of element
writer.writeTextElement(tType, fileType);
QString fileName = urls.at(0).toLocalFile();
QString destName = widget->downloadUrl(fileName, ext);
if (destName.isNull()) {
qDebug() << "error at creating destination folder";
return QString();
}
//writing path to created object
writer.writeTextElement(tPath, destName);
}
writer.writeEndElement();
writer.writeEndDocument();
return mimeXml;
}
QString UBBoardView::fileExtention(const QString &filename)
QString UBBoardView::fileExtention(const QString &filename) const
{
int pos = filename.lastIndexOf(".");
if (pos != -1)
......@@ -817,7 +767,7 @@ QString UBBoardView::fileExtention(const QString &filename)
else
return QString();
}
QString UBBoardView::typeForExtention(const QString &extention)
QString UBBoardView::typeForExtention(const QString &extention) const
{
if (extention.isEmpty())
return QString();
......@@ -836,8 +786,12 @@ QString UBBoardView::typeForExtention(const QString &extention)
return result;
}
bool UBBoardView::isDropableData(const QMimeData *pMimeData)
bool UBBoardView::isDropableData(const QMimeData *pMimeData) const
{
if (pMimeData->hasHtml()) {
return true;
}
if (pMimeData->hasUrls()) {
if (!typeForExtention(fileExtention(pMimeData->urls().at(0).toLocalFile())).isNull()) {
return true;
......@@ -853,25 +807,17 @@ void UBBoardView::dropEvent (QDropEvent *event)
QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y());
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
if (graphicsWidget && graphicsWidget->acceptDrops()){
// A new event is build to avoid problem related to different way to pass the mime type
// A parsing is done to try to provide a mimeType with only urls.
QMimeData mimeData;
QString str = processMimeData(event->mimeData(), graphicsWidget);
mimeData.setData("text/plain", str.toAscii());
QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint());
QDropEvent cleanedEvent(newPoint, event->dropAction(), &mimeData, event->mouseButtons(), event->keyboardModifiers());
QApplication::sendEvent(graphicsWidget->widgetWebView(),&cleanedEvent);
cleanedEvent.acceptProposedAction();
if (graphicsWidget && graphicsWidget->acceptDrops()) {
graphicsWidget->processDropEvent(event);
event->acceptProposedAction();
return;
}
qDebug() << event->source();
if(!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBDraggableMediaPlayer *>(event->source()) || dynamic_cast<UBDraggableLabel *>(event->source()) || dynamic_cast<UBDraggableMedia *>(event->source()))
{
} else if (!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source())
|| dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBDraggableMediaPlayer *>(event->source())
|| dynamic_cast<UBDraggableLabel *>(event->source()) || dynamic_cast<UBDraggableMedia *>(event->source())) {
mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction ();
event->acceptProposedAction();
}
}
......
......@@ -89,7 +89,7 @@ class UBBoardView : public QGraphicsView
QList<QUrl> processMimeData(const QMimeData* pMimeData);
QString processMimeData(const QMimeData *pMimeData, UBGraphicsWidgetItem *widget);
bool isDropableData(const QMimeData *pMimeData);
bool isDropableData(const QMimeData *pMimeData) const;
UBBoardController* mController;
......@@ -118,8 +118,8 @@ class UBBoardView : public QGraphicsView
bool mVirtualKeyboardActive;
bool mOkOnWidget;
QString typeForExtention(const QString &extention);
QString fileExtention(const QString &filename);
QString typeForExtention(const QString &extention) const;
QString fileExtention(const QString &filename) const;
private slots:
......
......@@ -70,7 +70,7 @@ void UBDownloadManager::destroy()
* \brief Add a file to the download list
* @param desc as the given file description
*/
void UBDownloadManager::addFileToDownload(sDownloadFileDesc desc)
int UBDownloadManager::addFileToDownload(sDownloadFileDesc desc)
{
// Set the ID for this download
desc.id = mLastID;
......@@ -89,6 +89,8 @@ void UBDownloadManager::addFileToDownload(sDownloadFileDesc desc)
UBApplication::boardController->paletteManager()->startDownloads();
emit fileAddedToDownload();
return desc.id;
}
/**
......@@ -144,8 +146,7 @@ void UBDownloadManager::onUpdateDownloadLists()
// If we fall here that means that there is no pending download
break;
}
if(-1 == mDLAvailability.at(i))
{
if(-1 == mDLAvailability.at(i)) {
// Pending downloads exist and a download 'slot' is available
// Let's move the first pending download to the current download
// list and fill the slot
......@@ -194,13 +195,21 @@ void UBDownloadManager::onDownloadProgress(int id, qint64 received, qint64 total
*/
void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{
// Temporary data for dnd do not delete it please
Q_UNUSED(pPos)
Q_UNUSED(pSize)
Q_UNUSED(isBackground)
for(int i=0; i<mCrntDL.size(); i++)
{
sDownloadFileDesc desc = mCrntDL.at(i);
if(id == desc.id)
{
if(desc.modal)
{
if (desc.dest == sDownloadFileDesc::graphicsWidget) {
desc.contentTypeHeader = pContentTypeHeader;
emit downloadFinished(pSuccess, desc, pData);
} else if(desc.modal) {
// The downloaded file is modal so we must put it on the board
emit addDownloadedFileToBoard(pSuccess, sourceUrl, pContentTypeHeader, pData, pPos, pSize, isBackground);
}
......@@ -208,6 +217,7 @@ void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl
{
emit addDownloadedFileToLibrary(pSuccess, sourceUrl, pContentTypeHeader, pData);
}
break;
}
}
......
......@@ -19,6 +19,7 @@
#include <QString>
#include <QVector>
#include <QMutex>
#include <QDropEvent>
#include "UBDownloadThread.h"
......@@ -26,18 +27,44 @@
#define SIMULTANEOUS_DOWNLOAD 2 // Maximum 5 because of QNetworkAccessManager limitation!!!
typedef struct
struct sDownloadFileDesc
{
enum eDestinations {
board //default for sDownloadFileDesc
, library
, graphicsWidget
};
//creating constructor to make sure to have default values
sDownloadFileDesc() :
dest(board)
, id(0)
, totalSize(0)
, currentSize(0)
, modal(false)
, isBackground(false)
, dropActions(Qt::IgnoreAction)
, dropMouseButtons(Qt::NoButton)
, dropModifiers(Qt::NoModifier)
{;}
eDestinations dest;
QString name;
int id;
int totalSize;
int currentSize;
QString url;
QString contentTypeHeader;
bool modal;
QPointF pos; // For board drop only
QSize size; // For board drop only
bool isBackground; // For board drop only
}sDownloadFileDesc;
QPoint dropPoint; //For widget's Drop event
Qt::DropActions dropActions; //For widget's Drop event
Qt::MouseButtons dropMouseButtons; //For widget's Drop event
Qt::KeyboardModifiers dropModifiers; //For widget's Drop event
};
class UBDownloadHttpFile : public UBHttpGet
{
......@@ -66,7 +93,7 @@ public:
UBDownloadManager(QObject* parent=0, const char* name="UBDownloadManager");
~UBDownloadManager();
static UBDownloadManager* downloadManager();
void addFileToDownload(sDownloadFileDesc desc);
int addFileToDownload(sDownloadFileDesc desc);
QVector<sDownloadFileDesc> currentDownloads();
QVector<sDownloadFileDesc> pendingDownloads();
void cancelDownloads();
......@@ -78,6 +105,8 @@ signals:
void fileAddedToDownload();
void downloadUpdated(int id, qint64 crnt, qint64 total);
void downloadFinished(int id);
void downloadFinished(bool pSuccess, int id, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData);
void downloadFinished(bool pSuccess, sDownloadFileDesc desc, QByteArray pData);
void downloadModalFinished();
void addDownloadedFileToBoard(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void addDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData);
......
......@@ -8,6 +8,10 @@ UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidge
{
setObjectName(name);
mActions.clear();
mCloseButtons.setIcon(QIcon(QPixmap(":images/close.svg")));
mCloseButtons.setGeometry(0, 0, 2*ACTIONSIZE, ACTIONSIZE);
mCloseButtons.setVisible(false);
connect(&mCloseButtons, SIGNAL(clicked()), this, SLOT(onCloseClicked()));
}
UBActionableWidget::~UBActionableWidget()
......@@ -36,36 +40,26 @@ void UBActionableWidget::removeAllActions()
void UBActionableWidget::setActionsVisible(bool bVisible)
{
mShowActions = bVisible;
if(!mActions.empty() && mActions.contains(eAction_Close)){
mCloseButtons.setVisible(bVisible);
}
}
bool UBActionableWidget::shouldClose(QPoint p)
void UBActionableWidget::onCloseClicked()
{
qDebug() << "Should close: " << p.x() << "," << p.y();
bool close = false;
emit close(this);
}
if(mShowActions &&
p.x() >= 0 &&
p.x() <= ACTIONSIZE &&
p.y() >= 0 &&
p.y() <= ACTIONSIZE){
close = true;
void UBActionableWidget::setActionsParent(QWidget *parent)
{
if(mActions.contains(eAction_Close)){
mCloseButtons.setParent(parent);
}
return close;
}
void UBActionableWidget::paintEvent(QPaintEvent* ev)
void UBActionableWidget::unsetActionsParent()
{
Q_UNUSED(ev);
if(mShowActions){
QPainter p(this);
if(mActions.contains(eAction_Close)){
p.drawPixmap(0, 0, 16, 16, QPixmap(":images/close.svg"));
}else if(mActions.contains(eAction_MoveUp)){
// Implement me later
}else if(mActions.contains(eAction_MoveDown)){
// Implement me later
}
mCloseButtons.setParent(this);
}
}
......@@ -3,6 +3,8 @@
#include <QWidget>
#include <QPaintEvent>
#include <QToolButton>
#include <QPushButton>
#define ACTIONSIZE 16
......@@ -22,14 +24,22 @@ public:
void removeAction(eAction act);
void removeAllActions();
void setActionsVisible(bool bVisible);
bool shouldClose(QPoint p);
signals:
void close(QWidget* w);
protected:
void paintEvent(QPaintEvent* ev);
void setActionsParent(QWidget* parent);
void unsetActionsParent();
QVector<eAction> mActions;
QPushButton mCloseButtons;
private slots:
void onCloseClicked();
private:
bool mShowActions;
};
#endif // UBACTIONABLEWIDGET_H
......@@ -5,7 +5,7 @@
UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name)
{
removeAllActions();
}
UBDraggableMedia::~UBDraggableMedia()
......
......@@ -67,6 +67,7 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name)
*/
UBMediaWidget::~UBMediaWidget()
{
unsetActionsParent();
DELETEPTR(mpSlider);
DELETEPTR(mpPauseButton);
DELETEPTR(mpPlayStopButton);
......@@ -152,6 +153,7 @@ void UBMediaWidget::createMediaPlayer()
}
mLayout.addWidget(mpMediaContainer, 1);
mLayout.addLayout(&mSeekerLayout, 0);
setActionsParent(mpMediaContainer);
}
/**
......
......@@ -69,6 +69,8 @@ public:
eMediaType mediaType();
int border();
void setAudioCover(const QString& coverPath);
void setUrl(const QString& url){mUrl = url;}
QString url(){return mUrl;}
protected:
void resizeEvent(QResizeEvent* ev);
......@@ -118,6 +120,8 @@ private:
QHBoxLayout mMediaLayout;
/** The audio cover */
QLabel* mpCover;
/** The media url */
QString mUrl;
};
#endif // UBMEDIAWIDGET_H
......@@ -10,7 +10,7 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation,
, mCanRemove(true)
, mpLayout(NULL)
, mpContainer(NULL)
, mMargin(5)
, mMargin(10)
, mListElementsSpacing(10)
, mpEmptyLabel(NULL)
, mpCurrentWidget(NULL)
......@@ -69,6 +69,9 @@ void UBWidgetList::removeWidget(QWidget *widget)
if(0 == mpLayout->count()){
mpEmptyLabel->setVisible(true);
}
if(mpCurrentWidget == widget){
mpCurrentWidget = NULL;
}
}
}
......@@ -140,22 +143,15 @@ void UBWidgetList::mousePressEvent(QMouseEvent *ev)
if(mCanRemove){
QWidget* pWAt = widgetAt(ev->pos());
if(NULL != mpCurrentWidget){
if(pWAt == mpCurrentWidget){
QPoint p;
p.setX(ev->x());
p.setY(ev->y());
if(mpCurrentWidget->shouldClose(p)){
emit closeWidget(mpCurrentWidget);
return;
}
}else{
if(pWAt != mpCurrentWidget){
mpCurrentWidget->setActionsVisible(false);
update();
}
}
mpCurrentWidget = dynamic_cast<UBActionableWidget*>(pWAt);
if(NULL != mpCurrentWidget){
mpCurrentWidget->setActionsVisible(true);
update();
}
}
update();
......@@ -231,6 +227,3 @@ bool UBWidgetList::empty()
{
return mWidgetInfo.empty();
}
// TODO : - add onHover 'delete' button
......@@ -428,7 +428,10 @@ void UBAbstractWidget::paintEvent(QPaintEvent * event)
p.drawText(rect(), Qt::AlignCenter, message);
}
}
void UBAbstractWidget::dropEvent(QDropEvent *event)
{
QWebView::dropEvent(event);
}
QPixmap UBAbstractWidget::takeSnapshot()
{
......
......@@ -131,6 +131,7 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
virtual void injectInlineJavaScript();
virtual void paintEvent(QPaintEvent * event);
virtual void dropEvent(QDropEvent *);
protected slots:
......
......@@ -258,6 +258,14 @@ QString UBGraphicsWidgetItem::downloadUrl(const QString &fileUrl, const QString
{
return mUniboardAPI->downloadUrl(fileUrl, extention);
}
QString UBGraphicsWidgetItem::downloadWeb(const QString &fileUrl)
{
return mUniboardAPI->downloadWeb(fileUrl);
}
void UBGraphicsWidgetItem::processDropEvent(QDropEvent *event)
{
return mUniboardAPI->ProcessDropEvent(event);
}
UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent)
: UBGraphicsWidgetItem(parent)
......
......@@ -62,11 +62,13 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
QMap<QString, QString> datastoreEntries() const;
void removeDatastoreEntry(const QString& key);
void removeAllDatastoreEntries();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate; }
virtual void remove();
void removeScript();
QString downloadUrl(const QString &fileUrl, const QString &extention);
QString downloadWeb(const QString &fileUrl);
void processDropEvent(QDropEvent *event);
virtual void setOwnFolder(const QUrl &newFolder) {ownFolder = newFolder;}
virtual QUrl getOwnFolder() const {return ownFolder;}
......
......@@ -142,6 +142,7 @@ void UBTBPageEditWidget::onActionButton()
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this);
mActions << pAction;
mpActions->addWidget(pAction);
connectActions(pAction);
emit valueChanged();
}
......@@ -150,6 +151,7 @@ void UBTBPageEditWidget::onLinkButton()
UBUrlWidget* pUrl = new UBUrlWidget(this);
mUrls << pUrl;
mpLinks->addWidget(pUrl);
connectActions(pUrl);
emit valueChanged();
}
......@@ -163,11 +165,20 @@ void UBTBPageEditWidget::onMediaDropped(const QString &url)
//mpDataMgr->medias()->append(pMedia);
//mpDataMgr->addMediaUrl(url);
mpMediaContainer->addWidget(pMedia);
connectActions(pMedia);
emit valueChanged();
}
}
}
void UBTBPageEditWidget::connectActions(QWidget* w)
{
UBActionableWidget* pActionable = dynamic_cast<UBActionableWidget*>(w);
if(NULL != pActionable){
connect(pActionable, SIGNAL(close(QWidget*)), this, SLOT(onCloseWidget(QWidget*)));
}
}
void UBTBPageEditWidget::onDocumentEditClicked()
{
emit changeTBState(eTeacherBarState_DocumentEdit);
......@@ -217,6 +228,7 @@ void UBTBPageEditWidget::updateFields()
pAction->setText(action.content);
mActions << pAction;
mpActions->addWidget(pAction);
connectActions(pAction);
}
// Medias
foreach(QString url, *mpDataMgr->mediaUrls()){
......@@ -226,6 +238,7 @@ void UBTBPageEditWidget::updateFields()
if(pWidget != NULL){
mMedias << pWidget;
mpMediaContainer->addWidget(pWidget);
connectActions(pWidget);
}
}
}
......@@ -237,6 +250,7 @@ void UBTBPageEditWidget::updateFields()
urlWidget->setUrl(link.link);
mUrls << urlWidget;
mpLinks->addWidget(urlWidget);
connectActions(urlWidget);
}
// Comments
mpComments->document()->setPlainText(mpDataMgr->comments());
......@@ -287,7 +301,15 @@ void UBTBPageEditWidget::onCloseWidget(QWidget *w)
mpLinks->removeWidget(pW);
mUrls.remove(mUrls.indexOf(pW));
DELETEPTR(w);
}else if("UBTBMediaPicture" == w->objectName() || "UBMediaWidget" == w->objectName()){
}else if("UBTBMediaPicture" == w->objectName()){
UBPictureWidget* pW = dynamic_cast<UBPictureWidget*>(w);
mMediaUrls.removeOne(pW->url());
mpMediaContainer->removeWidget(w);
mMedias.remove(mMedias.indexOf(w));
DELETEPTR(w);
}else if("UBMediaWidget" == w->objectName()){
UBMediaWidget* pW = dynamic_cast<UBMediaWidget*>(w);
mMediaUrls.removeOne(pW->url());
mpMediaContainer->removeWidget(w);
mMedias.remove(mMedias.indexOf(w));
DELETEPTR(w);
......@@ -326,10 +348,12 @@ UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):UBActionableWidget(p
mpLayout->addLayout(mpTitleLayout);
mpLayout->addLayout(mpLabelLayout);
setActionsParent(this);
}
UBUrlWidget::~UBUrlWidget()
{
unsetActionsParent();
DELETEPTR(mpTitle);
DELETEPTR(mpTitleLabel);
DELETEPTR(mpUrlLabel);
......@@ -460,6 +484,7 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url)
if(mimeType.contains("image")){
QPixmap pix = QPixmap(url);
UBPictureWidget* pic = new UBPictureWidget();
pic->setUrl(url);
pix.scaledToWidth(pic->label()->width());
pic->label()->resize(pix.width(), pix.height());
pic->label()->setPixmap(pix);
......@@ -470,6 +495,7 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url)
else if(mimeType.contains("video") || mimeType.contains("audio")){
UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);
mediaPlayer->setFile(url);
mediaPlayer->setUrl(url);
pW = mediaPlayer;
}
else{
......@@ -511,11 +537,12 @@ UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name
mpText->setStyleSheet("background:white;");
mpLayout->addWidget(mpText, 1);
setActionsParent(this);
}
UBTeacherStudentAction::~UBTeacherStudentAction()
{
unsetActionsParent();
DELETEPTR(mpCombo);
DELETEPTR(mpText);
DELETEPTR(mpComboLayout);
......@@ -568,10 +595,12 @@ UBPictureWidget::UBPictureWidget(QWidget *parent, const char *name):UBActionable
mpLabel = new QLabel(this);
mpLayout->addWidget(mpLabel);
mpLabel->setGeometry( 10, 10, width()-2*10, height());
setActionsParent(mpLabel);
}
UBPictureWidget::~UBPictureWidget()
{
unsetActionsParent();
DELETEPTR(mpLabel);
DELETEPTR(mpLayout);
}
......
......@@ -64,6 +64,8 @@ public:
~UBPictureWidget();
QLabel* label(){return mpLabel;}
void setUrl(const QString& url){mUrl = url;}
QString url(){return mUrl;}
protected:
void resizeEvent(QResizeEvent* ev);
......@@ -71,6 +73,7 @@ protected:
private:
QVBoxLayout* mpLayout;
QLabel* mpLabel;
QString mUrl;
};
class UBTBMediaContainer : public UBWidgetList
......@@ -124,6 +127,7 @@ private slots:
void onCloseWidget(QWidget* w);
private:
void connectActions(QWidget* w);
QVBoxLayout mLayout;
QHBoxLayout mTitleLayout;
QVBoxLayout mContainerLayout;
......
......@@ -18,9 +18,12 @@
#include <QtNetwork>
#include "network/UBNetworkAccessManager.h"
#include "core/UBDownloadManager.h"
#include "core/memcheck.h"
sDownloadFileDesc desc;
UBHttpGet::UBHttpGet(QObject* parent)
: QObject(parent)
, mReply(0)
......@@ -42,7 +45,6 @@ UBHttpGet::~UBHttpGet()
}
}
QNetworkReply* UBHttpGet::get(QUrl pUrl, QPointF pPos, QSize pSize, bool isBackground)
{
mPos = pPos;
......@@ -63,7 +65,26 @@ QNetworkReply* UBHttpGet::get(QUrl pUrl, QPointF pPos, QSize pSize, bool isBackg
return mReply;
}
//QNetworkReply* UBHttpGet::get(const sDownloadFileDesc &downlinfo)
//{
// mDownloadInfo.size = downlinfo.size;
// mDownloadInfo.isBackground = downlinfo.isBackground;
// mDownloadInfo.pos = downlinfo.pos;
// if (mReply)
// delete mReply;
// UBNetworkAccessManager * nam = UBNetworkAccessManager::defaultAccessManager();
// mReply = nam->get(QNetworkRequest(QUrl(downlinfo.url))); //mReply deleted by this destructor
// mDownloadedBytes.clear();
// connect(mReply, SIGNAL(finished()), this, SLOT(requestFinished()));
// connect(mReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
// connect(mReply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgressed(qint64, qint64)));
// return mReply;
//}
void UBHttpGet::readyRead()
{
......
......@@ -18,24 +18,27 @@
#include <QtCore>
#include <QtNetwork>
#include <QDropEvent>
class UBHttpGet : public QObject
{
Q_OBJECT;
Q_OBJECT
public:
UBHttpGet(QObject* parent = 0);
virtual ~UBHttpGet();
QNetworkReply* get(QUrl pUrl, QPointF pPoint = QPointF(0, 0), QSize pSize = QSize(0, 0), bool isBackground = false);
// QNetworkReply* get(const sDownloadFileDesc &downlinfo);
signals:
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader
, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
// void downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData
// , sDownloadFileDesc downlInfo);
private slots:
......@@ -54,6 +57,7 @@ class UBHttpGet : public QObject
int mRequestID;
int mRedirectionCount;
bool mIsSelfAborting;
// sDownloadFileDesc mDownloadInfo;
};
#endif /* UBHTTPGET_H_ */
......
......@@ -57,7 +57,7 @@ bool ASCIIHexDecode::decode(std::string & encoded)
for(int i = 0;i<len;i++)
{
unsigned char ch = encoded[i];
if( WHITESPACES.find(ch) != -1 )
if((int) WHITESPACES.find(ch) != -1 )
{
continue;
}
......
......@@ -42,7 +42,7 @@ namespace merge_lib
{
unsigned int startOfParent = content.find("/Parent");
unsigned int endOfParent = content.find(" R", startOfParent);
if(startOfParent == -1)
if((int)startOfParent == -1)
break;
std::vector <Object *> parents = parent->getChildrenByBounds(startOfParent, endOfParent);
if(parents.size() != 1)
......@@ -50,7 +50,7 @@ namespace merge_lib
parent = parents[0];
std::string parentContent = parent->getObjectContent();
unsigned int startOfMediaBox = parentContent.find(_handlerName);
if(startOfMediaBox == -1)
if((int)startOfMediaBox == -1)
{
content = parentContent;
continue;
......
......@@ -36,8 +36,8 @@ void AnnotsHandler::_processObjectContent(unsigned int startOfPageElement)
{
Object * child = _annotations[0];
std::string childContent = child->getObjectContent();
if( Parser::findToken(childContent,"/Rect") == -1 &&
Parser::findToken(childContent,"/Subtype") == -1 )
if((int) Parser::findToken(childContent,"/Rect") == -1 &&
(int)Parser::findToken(childContent,"/Subtype") == -1 )
{
// this was not Annotation but reference to array
// of annotations
......
......@@ -63,12 +63,12 @@ std::vector <Decoder * > Filter::_getDecoders()
while(1)
{
startOfDecoder = streamHeader.find("/", startOfDecoder);
if(startOfDecoder == -1)
if((int)startOfDecoder == -1)
break;
else
++startOfDecoder;
unsigned int endOfDecoder = streamHeader.find_first_of(whitespacesAndDelimeters, startOfDecoder);
if(endOfDecoder == -1)
if((int)endOfDecoder == -1)
break;
std::map<std::string, Decoder *>::iterator foundDecoder =
_allDecoders.find(streamHeader.substr(startOfDecoder, endOfDecoder - startOfDecoder));
......
......@@ -59,14 +59,14 @@ FilterPredictor::~FilterPredictor()
std::string FilterPredictor::getDictionaryContentStr(std::string & in, size_t &pos )
{
size_t beg = in.find(DICT_START_TOKEN,pos);
if( beg == -1 )
if((int) beg == -1 )
{
return "";
}
beg += DICT_START_TOKEN.size();
size_t end = in.find(DICT_END_TOKEN,beg);
if( end == -1 )
if((int) end == -1 )
{
return "";
}
......@@ -92,7 +92,7 @@ void FilterPredictor::obtainDecodeParams(Object *objectWithStream, std::string &
for(; it != params.end();it++)
{
size_t pos = dictStr.find((*it).first);
if( pos != -1 )
if((int) pos != -1 )
{
pos += (*it).first.size();
......@@ -123,7 +123,7 @@ void FilterPredictor::initialize(Object *objectWithStream)
objectWithStream->getHeader(content);
// we need to parse the header of file to obtain the decoder parameter
size_t position = content.find(DECODE_PARAM_TOKEN);
if( position != -1)
if((int) position != -1)
{
position += DECODE_PARAM_TOKEN.size();
std::string dictStr = getDictionaryContentStr(content,position);
......
......@@ -47,7 +47,7 @@ void FlateDecode::initialize(Object * objectWithStream)
std::string head;
objectWithStream->getHeader(head);
if( head.find(FilterPredictor::DECODE_PARAM_TOKEN) != -1 )
if((int) head.find(FilterPredictor::DECODE_PARAM_TOKEN) != -1 )
{
_predict = new FilterPredictor();
_predict->initialize(objectWithStream);
......
......@@ -59,7 +59,7 @@ void LZWDecode::initialize(Object * objectWithStream)
std::string head;
objectWithStream->getHeader(head);
if( head.find(FilterPredictor::DECODE_PARAM_TOKEN) != -1 )
if((int) head.find(FilterPredictor::DECODE_PARAM_TOKEN) != -1 )
{
_predict = new FilterPredictor();
_predict->initialize(objectWithStream);
......
......@@ -59,7 +59,7 @@ namespace merge_lib
}
bool _wasCropBoxHandlerCalled()
{
return (_page->getObjectContent().find("/BBox") != -1) ? true : false;
return ((int)_page->getObjectContent().find("/BBox") != -1) ? true : false;
}
};
}
......
......@@ -369,7 +369,7 @@ bool Object::_findObject(const std::string & token, Object* & foundObject, unsig
{
_isPassed = true;
tokenPositionInContent = Parser::findToken(_content,token);
if(tokenPositionInContent != -1)
if((int)tokenPositionInContent != -1)
{
foundObject = this;
return true;
......@@ -456,12 +456,12 @@ bool Object::getStream(std::string & stream)
bool Object::_getStreamFromContent(std::string & stream)
{
size_t stream_begin = _content.find("stream");
if( stream_begin == -1 )
if((int) stream_begin == -1 )
{
return false;
}
size_t stream_end = _content.find("endstream",stream_begin);
if( stream_end == -1 )
if((int) stream_end == -1 )
{
return false;
}
......@@ -558,7 +558,7 @@ std::string Object::getNameSimpleValue(const std::string &content, const std::st
Object* Object::findPatternInObjOrParents(const std::string &pattern)
{
std::string content=getObjectContent();
if( Parser::findToken(content,pattern,0) != -1 )
if((int) Parser::findToken(content,pattern,0) != -1 )
{
return this;
}
......@@ -569,7 +569,7 @@ Object* Object::findPatternInObjOrParents(const std::string &pattern)
{
unsigned int startOfParent = content.find("/Parent");
unsigned int endOfParent = content.find(" R", startOfParent);
if(startOfParent == -1)
if((int)startOfParent == -1)
{
break;
}
......@@ -581,7 +581,7 @@ Object* Object::findPatternInObjOrParents(const std::string &pattern)
parent = parents[0];
std::string parentContent = parent->getObjectContent();
unsigned int startOfPattern = parentContent.find(pattern);
if(startOfPattern == -1)
if((int)startOfPattern == -1)
{
content = parentContent;
continue;
......
......@@ -167,6 +167,8 @@ void _recalculateAnnotsCoordinates(Object * annotation,
const Rectangle & outputPagesRectangle,
const MergePageDescription & description)
{
Q_UNUSED(outputPagesRectangle);
Q_UNUSED(basePagesRectangle);
std::string annotsRectangleName("/Rect");
Object * objectWithRectangle;
unsigned int fake;
......@@ -193,7 +195,7 @@ static void _updateAnnotParentPage(Object *annotation,Object *newParentPage)
std::string &annotContent = annotation->getObjectContent();
size_t startOfP = Parser::findTokenName(annotContent,strP);
if( startOfP == -1 )
if((int) startOfP == -1 )
{
return;
}
......@@ -229,12 +231,12 @@ static void _updateAnnotParentPage(Object *annotation,Object *newParentPage)
static void _updateAnnotFormColor(Object *annotation )
{
std::string &objectContent = annotation->getObjectContent();
if( objectContent.find("/Widget") == -1 )
if((int) objectContent.find("/Widget") == -1 )
{
return;
}
size_t startOfAP = Parser::findTokenName(objectContent,"/AP");
if( startOfAP == -1 )
if((int) startOfAP == -1 )
{
return;
}
......@@ -262,7 +264,7 @@ static void _updateAnnotFormColor(Object *annotation )
{
if( token == "f" || token == "F" )
{
if( found != -1 )
if((int) found != -1 )
{
decodedStream[found] = ' ';
}
......@@ -272,7 +274,7 @@ static void _updateAnnotFormColor(Object *annotation )
// Then we need to update Filter section (if any)
std::string filterStr = "/Filter";
size_t startOfFlate = Parser::findTokenName(content,filterStr);
if( startOfFlate != -1 )
if((int) startOfFlate != -1 )
{
size_t endOfFlate = Parser::findEndOfElementContent(content,startOfFlate+filterStr.size());
childWithAP->eraseContent(startOfFlate,endOfFlate-startOfFlate);
......@@ -285,7 +287,7 @@ static void _updateAnnotFormColor(Object *annotation )
// update the length field
std::string lengthStr = "/Length";
size_t startOfLength = Parser::findTokenName(content,lengthStr,0);
if( startOfLength != -1 )
if((int) startOfLength != -1 )
{
size_t endOfLength = Parser::findEndOfElementContent(content,startOfLength + lengthStr.size());
childWithAP->eraseContent(startOfLength,endOfLength-startOfLength);
......@@ -296,10 +298,10 @@ static void _updateAnnotFormColor(Object *annotation )
// update the stream of object with new content
std::string stream("stream");
size_t leftBoundOfContentStream = content.find(stream);
if( leftBoundOfContentStream != -1 )
if((int) leftBoundOfContentStream != -1 )
{
size_t rightBoundOfContentStream = content.find("endstream", leftBoundOfContentStream);
if( rightBoundOfContentStream == -1 )
if((int) rightBoundOfContentStream == -1 )
{
rightBoundOfContentStream = content.size() - 1;
}
......@@ -323,7 +325,7 @@ static void processBasePageResources(Object *basePage)
return;
}
std::string resourceToken = "/Resources";
if( Parser::findTokenName(basePage->getObjectContent(),resourceToken) == -1 )
if((int) Parser::findTokenName(basePage->getObjectContent(),resourceToken) == -1 )
{
// it seems base page does not have resources, they can be located in parent!
Object *resource = basePage->findPatternInObjOrParents(resourceToken);
......@@ -331,20 +333,20 @@ static void processBasePageResources(Object *basePage)
{
std::string &resContStr = resource->getObjectContent();
size_t startOfRes = Parser::findTokenName(resContStr,resourceToken);
if( startOfRes == -1 )
if((int) startOfRes == -1 )
{
// no resources at all
return;
}
size_t endOfRes = Parser::findEndOfElementContent(resContStr,startOfRes + resourceToken.size());
if( endOfRes == -1 )
if((int) endOfRes == -1 )
{
return; // broken resources
}
std::string resourceContent = resContStr.substr(startOfRes,endOfRes-startOfRes);
size_t positionToInsert = basePage->getObjectContent().find("<<");
if( positionToInsert == -1 )
if((int) positionToInsert == -1 )
{
positionToInsert = 0;
resourceContent.insert(0,"<<");
......@@ -479,7 +481,7 @@ void Page::merge(Page * sourcePage, Document * parentDocument, MergePageDescript
rotationHandler.processObjectContent();
description.basePageTransformation.addRotation(_rotation);
if( sourcePage->_root->getObjectContent().find("/Annots") != -1 )
if((int) sourcePage->_root->getObjectContent().find("/Annots") != -1 )
{
Object *crop = sourcePage->_root->findPatternInObjOrParents("/CropBox");
if( crop )
......
......@@ -73,10 +73,10 @@ unsigned int PageElementHandler::_findEndOfElementContent(unsigned int startOfPa
static std::string whitespacesAndDelimeters(" \t\f\v\n\r<<[/");
unsigned int foundSlash = _pageContent.find("/", startOfPageElement + 1);
std::string fieldType;
while(foundSlash != -1)
while((int)foundSlash != -1)
{
unsigned int foundWhitespace = _pageContent.find_first_of(whitespacesAndDelimeters, foundSlash + 1);
if(foundWhitespace != -1)
if((int)foundWhitespace != -1)
fieldType = _pageContent.substr(foundSlash + 1, foundWhitespace - foundSlash - 1);
else
break;
......
......@@ -46,7 +46,7 @@ namespace merge_lib
void processObjectContent()
{
unsigned int startOfPageElement = _findStartOfPageElement();
if(startOfPageElement != -1)
if((int)startOfPageElement != -1)
_processObjectContent(startOfPageElement);
if(_nextHandler)
_nextHandler->processObjectContent();
......@@ -55,7 +55,7 @@ namespace merge_lib
void changeObjectContent()
{
unsigned int startOfPageElement = _findStartOfPageElement();
if(startOfPageElement != -1)
if((int)startOfPageElement != -1)
_changeObjectContent(startOfPageElement);
else
_pageElementNotFound();
......
This diff is collapsed.
......@@ -42,14 +42,14 @@ _rectangleName(rectangleName)
{
unsigned int rectanglePosition = Parser::findToken(content,rectangleName);
if( rectanglePosition == -1 )
if((int) rectanglePosition == -1 )
{
std::cerr<<"Unable to find rectangle name "<<rectangleName<<" in content\n";
}
size_t beg = content.find("[",rectanglePosition);
size_t end = content.find("]",rectanglePosition);
if( beg != -1 && end != -1 )
if((int) beg != -1 && (int) end != -1 )
{
std::string arr = content.substr(beg+1,end-beg-1);
std::stringstream in;
......@@ -119,7 +119,7 @@ void Rectangle::updateRectangle(Object * objectWithRectangle, const char * delim
std::string objectContent = objectWithMatrix->getObjectContent();
unsigned int matrixPosition = Parser::findToken(objectContent,"/Matrix");
if(matrixPosition == -1)
if((int)matrixPosition == -1)
continue;
unsigned int matrixValueLeftBound = objectContent.find("[", matrixPosition);
unsigned int matrixValueRightBound = objectContent.find("]", matrixValueLeftBound) + 1;
......
......@@ -61,7 +61,6 @@ SOURCES += \
macx {
LIBS += -lz
}
......
......@@ -93,3 +93,8 @@ void UBRoutedMouseEventWebView::wheelEvent(QWheelEvent* ev)
p->event(ev);
}
}
//void UBRoutedMouseEventWebView::dropEvent(QDropEvent *event)
//{
//// QWebView::dropEvent(event);
// event->accept();
//}
......@@ -39,6 +39,7 @@ class UBRoutedMouseEventWebView : public QWebView
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void contextMenuEvent(QContextMenuEvent* ev);
virtual void wheelEvent(QWheelEvent* ev);
// virtual void dropEvent(QDropEvent *);
};
#endif /* UBROUTEDMOUSEEVENTWEBVIEW_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment