Merge remote-tracking branch 'origin/develop' into claudio-dev

preferencesAboutTextFull
Claudio Valerio 12 years ago
commit dabc747b4d
  1. 2
      resources/library/applications/Nuancier.wgt/css/layout.css
  2. 2
      resources/library/applications/Nuancier.wgt/index.html
  3. 76
      resources/library/applications/Nuancier.wgt/js/colorpicker.js
  4. 2
      resources/library/applications/Nuancier.wgt/js/jquery-1.8.1.min.js
  5. 4
      resources/library/interactivities/Balance.wgt/config.xml
  6. BIN
      resources/library/interactivities/Balance.wgt/css/images/delete.png
  7. BIN
      resources/library/interactivities/Balance.wgt/css/images/graduations.png
  8. BIN
      resources/library/interactivities/Balance.wgt/css/images/pivot.png
  9. BIN
      resources/library/interactivities/Balance.wgt/css/images/scale.png
  10. BIN
      resources/library/interactivities/Balance.wgt/css/images/scales.png
  11. BIN
      resources/library/interactivities/Balance.wgt/css/images/weight-add.png
  12. BIN
      resources/library/interactivities/Balance.wgt/css/images/weight.png
  13. 81
      resources/library/interactivities/Balance.wgt/css/main.css
  14. 88
      resources/library/interactivities/Balance.wgt/js/main.js
  15. 4
      resources/library/interactivities/Balance.wgt/js/templates.js
  16. 3
      resources/library/interactivities/Morpion.wgt/js/main.js
  17. 2
      resources/library/interactivities/Ordre lettres.wgt/locales/fr/js/script.js
  18. 25
      resources/library/interactivities/Train.wgt/js/main.js
  19. 1
      resources/library/interactivities/Train.wgt/js/templates.js
  20. 1
      resources/library/interactivities/Transformation.wgt/css/main.css
  21. 2
      src/api/UBWidgetMessageAPI.cpp
  22. 26
      src/board/UBBoardController.cpp
  23. 30
      src/domain/UBGraphicsGroupContainerItem.cpp
  24. 3
      src/domain/UBGraphicsGroupContainerItem.h
  25. 2
      src/domain/UBGraphicsItemDelegate.cpp
  26. 23
      src/domain/UBGraphicsMediaItem.cpp
  27. 1
      src/domain/UBGraphicsMediaItem.h
  28. 24
      src/domain/UBGraphicsPDFItem.cpp
  29. 4
      src/domain/UBGraphicsPDFItem.h
  30. 29
      src/domain/UBGraphicsPixmapItem.cpp
  31. 3
      src/domain/UBGraphicsPixmapItem.h
  32. 1
      src/domain/UBGraphicsPolygonItem.cpp
  33. 37
      src/domain/UBGraphicsProxyWidget.cpp
  34. 8
      src/domain/UBGraphicsProxyWidget.h
  35. 4
      src/domain/UBGraphicsScene.cpp
  36. 63
      src/domain/UBGraphicsStrokesGroup.cpp
  37. 2
      src/domain/UBGraphicsStrokesGroup.h
  38. 25
      src/domain/UBGraphicsSvgItem.cpp
  39. 3
      src/domain/UBGraphicsSvgItem.h
  40. 49
      src/domain/UBGraphicsTextItem.cpp
  41. 3
      src/domain/UBGraphicsTextItem.h
  42. 152
      src/domain/UBGraphicsWebView.cpp
  43. 61
      src/domain/UBGraphicsWebView.h
  44. 157
      src/domain/UBGraphicsWidgetItem.cpp
  45. 19
      src/domain/UBGraphicsWidgetItem.h
  46. 19
      src/domain/UBItem.cpp
  47. 22
      src/domain/UBItem.h
  48. 6
      src/domain/domain.pri
  49. 11
      src/pdf-merger/Utils.cpp
  50. 23
      src/tools/UBGraphicsCurtainItem.cpp
  51. 3
      src/tools/UBGraphicsCurtainItem.h
  52. 5
      src/tools/UBGraphicsCurtainItemDelegate.h

@ -34,6 +34,8 @@ html, body {
font-size: 12px;
line-height: 18px;
color: #52697E;
width: 100%;
height: 100%;
}
body {
text-align: center;

@ -4,7 +4,7 @@
<link rel="stylesheet" href="css/colorpicker.css" type="text/css" />
<link rel="stylesheet" media="screen" type="text/css" href="css/layout.css" />
<title>ColorPicker - jQuery plugin</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="js/colorpicker.js"></script>
<script type="text/javascript" src="js/eye.js"></script>
<script type="text/javascript" src="js/utils.js"></script>

@ -5,12 +5,16 @@
*
* Dual licensed under the MIT and GPL licenses
*
*/
*/
(function ($) {
var ColorPicker = function () {
var
ids = {},
penFlag = true,
tmpColor = {
a:"",
b:""
},
inAction,
charMin = 65,
visible,
@ -108,7 +112,10 @@
}
setSelector(col, cal.get(0));
setHue(col, cal.get(0));
setNewColor(col, cal.get(0));
//setNewColor(col, cal.get(0));
$(cal.get(0)).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(col));
tmpColor.a = cal.get(0);
tmpColor.b = col;
cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
},
blur = function (ev) {
@ -174,14 +181,25 @@
$(document).unbind('mousemove', moveHue);
return false;
},
downSelector = function (ev) {
downSelector = function (ev) {
var current = {
cal: $(this).parent(),
pos: $(this).offset()
};
current.preview = current.cal.data('colorpicker').livePreview;
current.preview = current.cal.data('colorpicker').livePreview;
$(document).bind('mouseup', current, upSelector);
$(document).bind('mousemove', current, moveSelector);
change.apply(
current.cal.data('colorpicker')
.fields
.eq(6)
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - current.pos.top))))/150, 10))
.end()
.eq(5)
.val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - current.pos.left))))/150, 10))
.get(0),
[current.preview]
);
},
moveSelector = function (ev) {
change.apply(
@ -202,6 +220,18 @@
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
$(document).unbind('mouseup', upSelector);
$(document).unbind('mousemove', moveSelector);
if(penFlag){
$("div.tools_change").removeClass("tools_compass");
window.sankore.setTool('pen');
window.sankore.setPenColor('#' + HSBToHex(tmpColor.b));
sankore.returnStatus("PEN installed", penFlag);
} else {
$("div.tools_change").addClass("tools_compass");
window.sankore.setTool('compass');
window.sankore.setPenColor('#' + HSBToHex(tmpColor.b));
sankore.returnStatus("Compass installed", penFlag);
}
//$(tmpColor.a).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(tmpColor.b));
return false;
},
enterSubmit = function (ev) {
@ -249,7 +279,7 @@
cal.css({
left: left + 'px',
top: top + 'px'
});
});
if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
cal.show();
}
@ -325,7 +355,7 @@
r: hex >> 16,
g: (hex & 0x00FF00) >> 8,
b: (hex & 0x0000FF)
};
};
},
HexToHSB = function (hex) {
return RGBToHSB(HexToRGB(hex));
@ -379,43 +409,43 @@
rgb.r=t1;
rgb.b=t2;
rgb.g=t2+t3
}
}
else if(h<120) {
rgb.g=t1;
rgb.b=t2;
rgb.r=t1-t3
}
}
else if(h<180) {
rgb.g=t1;
rgb.r=t2;
rgb.b=t2+t3
}
}
else if(h<240) {
rgb.b=t1;
rgb.r=t2;
rgb.g=t1-t3
}
}
else if(h<300) {
rgb.b=t1;
rgb.g=t2;
rgb.r=t2+t3
}
}
else if(h<360) {
rgb.r=t1;
rgb.g=t2;
rgb.b=t1-t3
}
}
else {
rgb.r=0;
rgb.g=0;
rgb.b=0
}
}
}
return {
r:Math.round(rgb.r),
g:Math.round(rgb.g),
b:Math.round(rgb.b)
};
};
},
RGBToHex = function (rgb) {
var hex = [
@ -433,6 +463,9 @@
HSBToHex = function (hsb) {
return RGBToHex(HSBToRGB(hsb));
},
// changeCursor = function (flag) {
// alert(flag)
// },
restoreOriginal = function () {
var cal = $(this).parent();
var col = cal.data('colorpicker').origColor;
@ -446,6 +479,15 @@
};
return {
init: function (opt) {
if(window.sankore)
sankore.setTool("arrow");
// $(document).mouseout(function(event){
// if(event.target.tagName == "DIV" && event.target.className == "colorpicker")
// changeCursor(true)
// })
// $("body").mouseleave(function(){
// changeCursor(true)
// })
opt = $.extend({}, defaults, opt||{});
if (typeof opt.color == 'string') {
opt.color = HexToHSB(opt.color);
@ -465,9 +507,13 @@
var cal = $(tpl).attr('id', id);
if (options.flat) {
cal.appendTo(this).show();
} else {
}
else {
cal.appendTo(document.body);
}
// cal.bind("mouseover", function(){
// window.sankore.setTool('arrow');
// })
options.fields = cal
.find('input')
.bind('keyup', keyDown)

File diff suppressed because one or more lines are too long

@ -3,8 +3,8 @@
xmlns:ub="http://uniboard.mnemis.com/widgets"
id="http://www.njin.fr/sankore/apps/balance"
version="1.0"
width="1025"
height="880"
width="540"
height="450"
ub:resizable="true">
<name>La Balance</name>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -15,7 +15,7 @@
}
#scalesWrapper {
padding: 0px 100px 200px;
padding: 0px 100px 100px;
position: relative;
}
@ -29,10 +29,10 @@
.scale {
position: absolute;
width: 250px;
width: 125px;
height: 0;
padding: 200px 45px 50px;
top: 145px;
padding: 90px 20px 35px;
top: 72px;
background: url(images/scale.png) no-repeat center bottom;
}
@ -45,12 +45,12 @@
#leftScale {
left: 0;
margin-left: -150px;
margin-left: -75px;
}
#rightScale {
right: 0;
margin-right: -150px;
margin-right: -75px;
}
#tray {
@ -58,27 +58,27 @@
background-color: red;
top: 50%;
margin-top: -1px;
width: 550px;
height: 288px;
width: 225px;
height: 144px;
background: url("images/scales.png") no-repeat center;
}
#graduations {
width: 100px;
height: 30px;
width: 50px;
height: 15px;
position: absolute;
top: 0;
left: 50%;
margin-left: -50px;
margin-left: -25px;
background: url(images/graduations.png) center no-repeat;
}
#pivot {
position: absolute;
width: 80px;
height: 80px;
left: 235px;
top: 106px;
width: 40px;
height: 40px;
left: 93px;
top: 52px;
background: url(images/pivot.png) center no-repeat;
}
@ -101,14 +101,14 @@
text-indent: -100px;
width: 68px;
height: 70px;
width: 34px;
height: 34px;
margin-left: 10px;
cursor: pointer;
border-radius: 4px;
border-radius: 2px;
border: 1px solid rgba(255,255,255, 0.15);
background: rgba(0,0,0, 0.15) url(images/weight-add.png) center no-repeat;
}
@ -124,15 +124,15 @@
.object input {
border: none;
width: 40px;
padding: none;
margin: 0 2px 0 0;
width: 100%;
padding: 0;
margin: 0;
text-align: center;
font-size: 16px;
font-size: 12px;
color: #000;
border-radius: 3px;
border-radius: 2px;
background-color: #FFF;
box-shadow: 0 1px 2px rgba(0,0,0, 0.4);
}
@ -140,7 +140,7 @@
.object .tools {
display: none;
position: absolute;
top: -23px;
top: -13px;
width: 100%;
text-align: center;
}
@ -150,8 +150,8 @@
position: relative;
overflow: hidden;
cursor: pointer;
width: 22px;
height: 22px;
width: 11px;
height: 11px;
text-indent: -100px;
border: none;
margin: 0;
@ -180,7 +180,7 @@
position: absolute;
width: 100%;
height: 20px;
top: 72px;
top: 36px;
border-radius: 4px;
box-shadow: 0 3px 0 #999, 0 1px 2px rgba(0,0,0, .65);
background-color: #CCC;
@ -198,9 +198,9 @@
#weights {
display: none;
position: absolute;
top: 40px;
right: 40px;
width: 230px;
top: 20px;
right: 0px;
width: 160px;
}
.onEdit #weights {
@ -213,21 +213,26 @@
.weight {
position: relative;
width: 64px;
height: 70px;
width: 32px;
height: 35px;
margin-left: 10px;
margin-bottom: 30px;
font-size: 16px;
font-size: 12px;
text-align: center;
color: #CCC;
text-shadow: 0 -1px 0 #000;
}
.weight .unit {
font-size: 10px;
}
.weight .amount {
height: 100%;
padding: 4px 4px 0;
padding: 4px 2px 0;
border-radius: 4px;
border: 1px solid rgba(255,255,255, 0.15);
background-color: rgba(0,0,0, 0.15);
@ -235,10 +240,10 @@
.weight > div.bg {
position: absolute;
left: -3px;
left: -2px;
bottom: -18px;
width: 70px;
height: 64px;
width: 35px;
height: 32px;
background: url(images/weight.png) no-repeat center bottom;
}

@ -1,14 +1,47 @@
var weighValues = [500,200,100,50,20,10];
function onTemplateLoadedCallback(app) {
$("#weights").append($(Mustache.render(weightTemplate, {weight: 500})));
$("#weights").append($(Mustache.render(weightTemplate, {weight: 200})));
$("#weights").append($(Mustache.render(weightTemplate, {weight: 100})));
$("#weights").append($(Mustache.render(weightTemplate, {weight: 50})));
$("#weights").append($(Mustache.render(weightTemplate, {weight: 20})));
$("#weights").append($(Mustache.render(weightTemplate, {weight: 10})));
$.each(weighValues, function(){
$("#weights").append($(Mustache.render(weightTemplate, {weight: this})));
});
$("#weights > .weight").draggable({helper: "clone"});
$("#leftScale").droppable({
accept: ".object",
drop: function(event, ui) {
if($(ui.draggable).hasClass("inScale"))
return;
var object = $(ui.draggable).clone();
object.data("weight", $(ui.draggable).data("weight"));
object.addClass("inScale");
$("#leftScale").append(object);
placeObject($("#leftScale"), object);
refreshScales();
object.draggable({
stop: function(event, ui) {
if($(ui.helper).hasClass("onOut")) {
$(ui.helper).remove();
refreshScales();
}
}
});
},
out: function(event, ui) {
$(ui.draggable).addClass("onOut");
},
over: function(event, ui) {
$(ui.draggable).removeClass("onOut");
}
});
$("#rightScale").droppable({
accept: ".weight",
accept: ".weight.right",
drop: function(event, ui) {
if($(ui.draggable).hasClass("inScale"))
return;
@ -72,6 +105,10 @@ function objectForGUID(app, guid) {
window.object = guid;
var objectUi = $(Mustache.render(objectTemplate, window));
var weight = getWeightFor(app.parameters, guid);
if(!app.onEdit && (weight == undefined || $.trim(weight) == ""))
weight = weighValues[Math.floor(Math.random()*weighValues.length)];
if(weight !== undefined) {
objectUi.data("weight", weight);
objectUi.find("input[name=weight]").val(weight);
@ -137,8 +174,8 @@ function placeObject($container, $object) {
var count = $container.children().size() - 1;
var left = width * (count % 4) + 25;
var bottom = height * (Math.floor(count / 4)) + 40;
var left = width * (count % 4) + 5;
var bottom = height * (Math.floor(count / 4)) + 12;
log("Place at ["+left+" , "+bottom+"]");
$object.css("left", left+"px").css("bottom", bottom+"px");
@ -215,39 +252,6 @@ function reloadApp(app) {
}
refreshScales();
$("#leftScale").droppable({
accept: ".object",
drop: function(event, ui) {
if($(ui.draggable).hasClass("inScale"))
return;
var object = $(ui.draggable).clone();
object.data("weight", $(ui.draggable).data("weight"));
object.addClass("inScale");
$("#leftScale").append(object);
placeObject($("#leftScale"), object);
refreshScales();
object.draggable({
stop: function(event, ui) {
if($(ui.helper).hasClass("onOut")) {
$(ui.helper).remove();
refreshScales();
}
}
});
},
out: function(event, ui) {
$(ui.draggable).addClass("onOut");
},
over: function(event, ui) {
$(ui.draggable).removeClass("onOut");
}
});
if(app.onEdit) {

@ -23,8 +23,8 @@ var objectTemplate =
'<div class="tools">'+
'<button role="remove">{{fr.njin.i18n.balance.parameters.label.remove}}</button>'+
'</div>'+
'<div class="amount"><input type="text" name="weight">g</div><div class="bg"></div>'+
'<div class="amount"><input type="text" name="weight"></div><div class="bg"></div>'+
'</div>';
var weightTemplate =
'<div id="{{object}}" class="weight w{{weight}}" data-weight="{{weight}}"><div class="amount">{{weight}}g</div><div class="bg"></div></div>';
'<div id="{{object}}" class="weight right w{{weight}}" data-weight="{{weight}}"><div class="amount">{{weight}}</div><div class="bg"></div></div>';

@ -148,7 +148,8 @@ function isGameEnd(i, j) {
}
function isCellsWin(cells) {
if((player == cells.eq(0).data("player") == cells.eq(1).data("player") == cells.eq(2).data("player")))
var n = ((3*player) - (parseInt(cells.eq(0).data("player")) + parseInt(cells.eq(1).data("player")) + parseInt(cells.eq(2).data("player"))));
if( n == 0 )
return cells;
return null;
}

@ -1,7 +1,7 @@
var sankoreLang = {
display: "Afficher",
edit: "Modifier",
short_desc: "Ecoutez le son et replacer les lettres dans l'ordre.",
short_desc: "Ecoutez le son et replacez les lettres dans l'ordre.",
add: "Nouveau bloc",
enter: "Saisir la consigne ici ...",
example: "exemple",

@ -8,9 +8,18 @@ function revert($e) {
elmt.className = elmt.className.replace(/(d(\d+))/, "");
}
function getN(range) {
if(range > 1)
return Math.floor(Math.random()*range);
else if(range == 1)
return Math.round(Math.random()*10)/10;
else if(range == 0.1)
return Math.round(Math.random()*0.1*100)/100;
}
function reloadApp(app) {
var operator = app.parameters.value("operator");
var range = parseInt(app.parameters.value("range"));
var range = parseFloat(app.parameters.value("range"));
var count = parseInt(app.parameters.value("count"));
$scene = $("#scene");
@ -25,16 +34,12 @@ function reloadApp(app) {
var meeted = [];
for (var i = 0; i < count; i++) {
var n = Math.floor(Math.random()*range);
while($.inArray(n, meeted) != -1) {
if(range > 1)
n = Math.floor(Math.random()*range);
else
n = Math.round(Math.random()*range*100)/100;
}
var n = getN(range);
while($.inArray(n, meeted) != -1)
n = getN(range);
meeted.push(n);
$label = $("<div id='l"+i+"' class='label'>"+n+"</div>");

@ -31,6 +31,7 @@ var parametersTemplate =
'<div class="inline">'+
'<label>{{fr.njin.i18n.train.parameters.label.range}}'+
'<select name="range" role="parameter">'+
'<option value="0.1">< 0.1</option>'+
'<option value="1">< 1</option>'+
'<option value="10">< 10</option>'+
'<option value="100">< 100</option>'+

@ -136,6 +136,7 @@
}
.card .picture > div img {
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}

@ -17,8 +17,6 @@
#include "core/UBApplication.h"
#include "domain/UBGraphicsWebView.h"
#include "core/memcheck.h"
UBWidgetMessageAPI::UBWidgetMessageAPI(UBGraphicsWidgetItem *graphicsWidgetItem, QObject *parent)

@ -611,18 +611,28 @@ void UBBoardController::duplicateItem(UBItem *item)
{
UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if(groupItem){
QTransform groupTransform = groupItem->transform();
groupItem->resetTransform();
QList<QGraphicsItem*> children = groupItem->childItems();
foreach(QGraphicsItem* pIt, children){
UBItem* pItem = dynamic_cast<UBItem*>(pIt);
if(NULL != pItem){
duplicateItem(pItem); // The duplication already copies the item parameters
if(NULL != mLastCreatedItem){
mLastCreatedItem->setSelected(true);
}
duplicateItem(pItem);
}
}
groupItem->setTransform(groupTransform);
groupItem->setSelected(false);
UBApplication::mainWindow->actionGroupItems->trigger();
QList<QGraphicsItem*> selItems = mActiveScene->selectedItems();
if(!selItems.empty()){
// I don't like this solution but for now this is the only way I found.
// Normally, at this state, only the duplicated group should be selected
UBGraphicsGroupContainerItem* duplicatedGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(selItems.at(0));
if(NULL != duplicatedGroup){
duplicatedGroup->setTransform(groupTransform);
}
}
}
return;
break;
@ -635,7 +645,7 @@ void UBBoardController::duplicateItem(UBItem *item)
{
mActiveScene->addItem(gitem);
gitem->setPos(itemPos);
mLastCreatedItem = gitem;
mLastCreatedItem = gitem;
gitem->setSelected(true);
}
return;
@ -652,6 +662,7 @@ void UBBoardController::duplicateItem(UBItem *item)
if (createdGitem)
createdGitem->setPos(itemPos);
mLastCreatedItem = dynamic_cast<QGraphicsItem*>(createdItem);
mLastCreatedItem->setSelected(true);
}
}
@ -2176,7 +2187,10 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
{
foreach(UBItem* item, mimeData->items())
{
duplicateItem(item);
QGraphicsItem* pItem = dynamic_cast<QGraphicsItem*>(item);
if(NULL != pItem){
duplicateItem(item);
}
}
return;

@ -16,8 +16,8 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsGroupContainerItemDelegate(this, 0);
mDelegate->init();
setDelegate(new UBGraphicsGroupContainerItemDelegate(this, 0));
Delegate()->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -32,8 +32,6 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem()
{
if (mDelegate)
delete mDelegate;
}
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
@ -50,14 +48,14 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
//Check if group is allready rotatable or flippable
if (childItems().count()) {
if (UBGraphicsItem::isFlippable(this) && !UBGraphicsItem::isFlippable(item)) {
mDelegate->setFlippable(false);
Delegate()->setFlippable(false);
}
if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) {
mDelegate->setRotatable(false);
Delegate()->setRotatable(false);
}
} else {
mDelegate->setFlippable(UBGraphicsItem::isFlippable(item));
mDelegate->setRotatable(UBGraphicsItem::isRotatable(item));
Delegate()->setFlippable(UBGraphicsItem::isFlippable(item));
Delegate()->setRotatable(UBGraphicsItem::isRotatable(item));
}
// COMBINE
@ -207,12 +205,6 @@ void UBGraphicsGroupContainerItem::copyItemParameters(UBItem *copy) const
}
}
void UBGraphicsGroupContainerItem::remove()
{
if (mDelegate)
mDelegate->remove();
}
void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
@ -244,7 +236,7 @@ void UBGraphicsGroupContainerItem::clearSource()
void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event)) {
if (Delegate()->mousePressEvent(event)) {
//NOOP
} else {
@ -257,7 +249,7 @@ void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *eve
void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mouseMoveEvent(event)) {
if (Delegate()->mouseMoveEvent(event)) {
// NOOP;
} else {
QGraphicsItem::mouseMoveEvent(event);
@ -273,7 +265,7 @@ void UBGraphicsGroupContainerItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e
QVariant UBGraphicsGroupContainerItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
QVariant newValue = mDelegate->itemChange(change, value);
QVariant newValue = Delegate()->itemChange(change, value);
foreach(QGraphicsItem *child, children())
{
@ -317,8 +309,8 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
break;
}
}
mDelegate->setFlippable(flippableNow);
mDelegate->setRotatable(rotatableNow);
Delegate()->setFlippable(flippableNow);
Delegate()->setRotatable(rotatableNow);
}
}

@ -22,13 +22,10 @@ public:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual UBCoreGraphicsScene *corescene();
virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
enum { Type = UBGraphicsItemType::groupContainerType };
virtual int type() const

@ -406,7 +406,7 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
scene->removeItem(mFrame);
/* this is performed because when removing delegated from scene while it contains flash content, segfault happens because of QGraphicsScene::removeItem() */
UBGraphicsWebView *mDelegated_casted = dynamic_cast<UBGraphicsWebView*>(mDelegated);
UBGraphicsWidgetItem *mDelegated_casted = dynamic_cast<UBGraphicsWidgetItem*>(mDelegated);
if (mDelegated_casted)
mDelegated_casted->setHtml(QString());

@ -72,6 +72,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
update();
mMediaObject = new Phonon::MediaObject(this);
setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaObject));
Delegate()->init();
if (pMediaFileUrl.toLocalFile().contains("videos"))
{
mMediaType = mediaType_Video;
@ -116,18 +120,14 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mSource = Phonon::MediaSource(pMediaFileUrl);
mMediaObject->setCurrentSource(mSource);
UBGraphicsMediaItemDelegate* itemDelegate = new UBGraphicsMediaItemDelegate(this, mMediaObject);
itemDelegate->init();
setDelegate(itemDelegate);
if (mediaType_Audio == mMediaType)
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
else
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
connect(mDelegate, SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool)));
connect(Delegate(), SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool)));
connect(mMediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasMediaChanged(bool)));
}
@ -220,7 +220,7 @@ void UBGraphicsMediaItem::hasMediaChanged(bool hasMedia)
{
Q_UNUSED(hasMedia);
mMediaObject->seek(mInitialPos);
UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(mDelegate);
UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(Delegate());
if (med)
med->updateTicker(initialPos());
}
@ -289,9 +289,9 @@ void UBGraphicsMediaItem::copyItemParameters(UBItem *copy) const
void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate)
if (Delegate())
{
mDelegate->mousePressEvent(event);
Delegate()->mousePressEvent(event);
if (parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type())
{
UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem());
@ -304,7 +304,7 @@ void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
group->setCurrentItem(this);
this->setSelected(true);
mDelegate->positionHandles();
Delegate()->positionHandles();
}
}
@ -351,3 +351,4 @@ void UBGraphicsMediaItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->accept();
}

@ -112,7 +112,6 @@ protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void clearSource();
Phonon::MediaObject *mMediaObject;

@ -28,21 +28,20 @@ UBGraphicsPDFItem::UBGraphicsPDFItem(PDFRenderer *renderer, int pageNumber, QGra
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::BackgroundItem)); //Necessary to set if we want z value to be assigned correctly
mDelegate = new UBGraphicsItemDelegate(this,0, true, false, false);
mDelegate->init();
setDelegate(new UBGraphicsItemDelegate(this,0, true, false, false));
Delegate()->init();
}
UBGraphicsPDFItem::~UBGraphicsPDFItem()
{
if (mDelegate)
delete mDelegate;
}
QVariant UBGraphicsPDFItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
QVariant newValue = mDelegate->itemChange(change, value);
QVariant newValue = Delegate()->itemChange(change, value);
return GraphicsPDFItem::itemChange(change, newValue);
}
@ -54,7 +53,7 @@ void UBGraphicsPDFItem::setUuid(const QUuid &pUuid)
void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event))
if (Delegate()->mousePressEvent(event))
{
// NOOP
}
@ -67,7 +66,7 @@ void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPDFItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mouseMoveEvent(event))
if (Delegate()->mouseMoveEvent(event))
{
// NOOP
}
@ -80,7 +79,7 @@ void UBGraphicsPDFItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPDFItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
Delegate()->mouseReleaseEvent(event);
GraphicsPDFItem::mouseReleaseEvent(event);
}
@ -131,13 +130,6 @@ UBGraphicsScene* UBGraphicsPDFItem::scene()
}
void UBGraphicsPDFItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const
{
QPixmap pixmap(mRenderer->pageSizeF(mPageNumber).toSize());
@ -155,3 +147,5 @@ UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const
return pixmapItem;
}

@ -47,10 +47,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
@ -63,7 +60,6 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
// UBGraphicsItemDelegate* mDelegate;
};
#endif /* UBGRAPHICSPDFITEM_H_ */

@ -28,10 +28,10 @@
UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
: QGraphicsPixmapItem(parent)
{
mDelegate = new UBGraphicsItemDelegate(this, 0, true);
mDelegate->init();
mDelegate->setFlippable(true);
mDelegate->setRotatable(true);
setDelegate(new UBGraphicsItemDelegate(this, 0, true));
Delegate()->init();
Delegate()->setFlippable(true);
Delegate()->setRotatable(true);
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setTransformationMode(Qt::SmoothTransformation);
@ -44,13 +44,11 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
UBGraphicsPixmapItem::~UBGraphicsPixmapItem()
{
if (mDelegate)
delete mDelegate;
}
QVariant UBGraphicsPixmapItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
QVariant newValue = mDelegate->itemChange(change, value);
QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsPixmapItem::itemChange(change, newValue);
}
@ -64,14 +62,14 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QMimeData* pMime = new QMimeData();
pMime->setImageData(pixmap().toImage());
mDelegate->setMimeData(pMime);
Delegate()->setMimeData(pMime);
qreal k = (qreal)pixmap().width() / 100.0;
QSize newSize((int)(pixmap().width() / k), (int)(pixmap().height() / k));
mDelegate->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
Delegate()->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
if (mDelegate->mousePressEvent(event))
if (Delegate()->mousePressEvent(event))
{
//NOOP
}
@ -83,7 +81,7 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mouseMoveEvent(event))
if (Delegate()->mouseMoveEvent(event))
{
// NOOP;
}
@ -95,7 +93,7 @@ void UBGraphicsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
Delegate()->mouseReleaseEvent(event);
QGraphicsPixmapItem::mouseReleaseEvent(event);
}
@ -145,13 +143,6 @@ UBGraphicsScene* UBGraphicsPixmapItem::scene()
}
void UBGraphicsPixmapItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsPixmapItem::setOpacity(qreal op)
{
QGraphicsPixmapItem::setOpacity(op);

@ -44,14 +44,11 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
virtual UBGraphicsScene* scene();
virtual void remove();
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
void setOpacity(qreal op);
qreal opacity() const;
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);

@ -171,6 +171,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground());
//cp->setTransform(transform());
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
}

@ -29,8 +29,9 @@ UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent)
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this,0, true, false, false);
mDelegate->init();
//UBGraphicsItemDelegate* delegate = new UBGraphicsItemDelegate(this,0, true, false, false);
//delegate->init();
//setDelegate(delegate);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -40,8 +41,6 @@ UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent)
UBGraphicsProxyWidget::~UBGraphicsProxyWidget()
{
if (mDelegate)
delete mDelegate;
}
@ -67,7 +66,7 @@ QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVar
}
}
QVariant newValue = mDelegate->itemChange(change, value);
QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsProxyWidget::itemChange(change, newValue);
}
@ -79,7 +78,7 @@ void UBGraphicsProxyWidget::setUuid(const QUuid &pUuid)
void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event))
if (Delegate()->mousePressEvent(event))
{
//NOOP
}
@ -95,7 +94,7 @@ void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mouseMoveEvent(event))
if (Delegate()->mouseMoveEvent(event))
{
// NOOP;
}
@ -108,13 +107,13 @@ void UBGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
Delegate()->mouseReleaseEvent(event);
QGraphicsProxyWidget::mouseReleaseEvent(event);
}
void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if( mDelegate->weelEvent(event) )
if( Delegate()->weelEvent(event) )
{
QGraphicsProxyWidget::wheelEvent(event);
event->accept();
@ -132,17 +131,6 @@ void UBGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
// NOOP
}
void UBGraphicsProxyWidget::setDelegate(UBGraphicsItemDelegate* pDelegate)
{
if (mDelegate)
{
delete mDelegate;
}
mDelegate = pDelegate;
}
void UBGraphicsProxyWidget::resize(qreal w, qreal h)
{
UBGraphicsProxyWidget::resize(QSizeF(w, h));
@ -177,8 +165,8 @@ void UBGraphicsProxyWidget::resize(const QSizeF & pSize)
QGraphicsProxyWidget::resize(size.width(), size.height());
if (widget())
widget()->resize(size.width(), size.height());
if (mDelegate)
mDelegate->positionHandles();
if (Delegate())
Delegate()->positionHandles();
if (scene())
scene()->setModified(true);
}
@ -197,8 +185,3 @@ UBGraphicsScene* UBGraphicsProxyWidget::scene()
}
void UBGraphicsProxyWidget::remove()
{
if (mDelegate)
mDelegate->remove(true);
}

@ -27,7 +27,6 @@ class UBGraphicsItemDelegate;
class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{
public:
UBGraphicsProxyWidget(QGraphicsItem* parent = 0);
virtual ~UBGraphicsProxyWidget();
virtual void resize(qreal w, qreal h);
@ -35,18 +34,13 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual QSizeF size() const;
void setDelegate(UBGraphicsItemDelegate* pDelegate);
virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
protected:
UBGraphicsProxyWidget(QGraphicsItem* parent = 0);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

@ -2041,8 +2041,8 @@ void UBGraphicsScene::drawItems (QPainter * painter, int numItems,
{
if (!mTools.contains(rootItem(items[i])))
{
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (items[i]);
if(!pdfItem || mRenderingContext == NonScreen)
bool isPdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (items[i]) != NULL;
if(!isPdfItem || mRenderingContext == NonScreen)
{
itemsFiltered[count] = items[i];
optionsFiltered[count] = options[i];

@ -4,12 +4,14 @@
#include "core/memcheck.h"
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsItemGroup(parent)
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
:UBGraphicsItem(), QGraphicsItemGroup(parent)
{
mDelegate = new UBGraphicsItemDelegate(this, 0, true, true, false);
mDelegate->init();
mDelegate->setFlippable(true);
mDelegate->setRotatable(true);
setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false));
Delegate()->init();
Delegate()->setFlippable(true);
Delegate()->setRotatable(true);
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
@ -22,9 +24,6 @@ UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsI
UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()
{
if(mDelegate){
delete mDelegate;
}
}
void UBGraphicsStrokesGroup::setUuid(const QUuid &pUuid)
@ -83,7 +82,7 @@ QColor UBGraphicsStrokesGroup::color(colorType pColorType) const
void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event))
if (Delegate()->mousePressEvent(event))
{
//NOOP
}
@ -95,7 +94,7 @@ void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsStrokesGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mouseMoveEvent(event))
if (Delegate()->mouseMoveEvent(event))
{
// NOOP;
}
@ -107,33 +106,39 @@ void UBGraphicsStrokesGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
Delegate()->mouseReleaseEvent(event);
QGraphicsItemGroup::mouseReleaseEvent(event);
}
UBItem* UBGraphicsStrokesGroup::deepCopy() const
{
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
QList<QGraphicsItem*> chl = childItems();
QTransform groupTransform = transform();
const_cast<UBGraphicsStrokesGroup*>(this)->resetTransform();
foreach(QGraphicsItem *child, chl)
{
UBGraphicsPolygonItem *polygon = dynamic_cast<UBGraphicsPolygonItem*>(child);
if (polygon)
{
copy->addToGroup(dynamic_cast<QGraphicsItem*>(polygon->deepCopy()));
polygon->setStrokesGroup(copy);
}
}
copyItemParameters(copy);
QList<QGraphicsItem*> chl = childItems();
return copy;
foreach(QGraphicsItem *child, chl)
{
UBGraphicsPolygonItem *polygon = dynamic_cast<UBGraphicsPolygonItem*>(child);
if (polygon){
QGraphicsItem* pItem = dynamic_cast<QGraphicsItem*>(polygon->deepCopy());
copy->addToGroup(pItem);
}
}
const_cast<UBGraphicsStrokesGroup*>(this)->setTransform(groupTransform);
copyItemParameters(copy);
return copy;
}
void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
{
UBGraphicsStrokesGroup *cp = dynamic_cast<UBGraphicsStrokesGroup*>(copy);
QGraphicsItem *cp = dynamic_cast<QGraphicsItem*>(copy);
if(NULL != cp)
{
cp->setTransform(transform());
@ -144,12 +149,6 @@ void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
}
}
void UBGraphicsStrokesGroup::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
// Never draw the rubber band, we draw our custom selection with the DelegateFrame
@ -161,7 +160,7 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value)
{
QVariant newValue = mDelegate->itemChange(change, value);
QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsItemGroup::itemChange(change, newValue);
}

@ -21,8 +21,6 @@ public:
~UBGraphicsStrokesGroup();
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
enum { Type = UBGraphicsItemType::StrokeItemType };
virtual int type() const
{

@ -53,10 +53,11 @@ void UBGraphicsSvgItem::init()
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this, 0, true, true, false);
mDelegate->init();
mDelegate->setFlippable(true);
mDelegate->setRotatable(true);
setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false));
Delegate()->init();
Delegate()->setFlippable(true);
Delegate()->setRotatable(true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -71,8 +72,6 @@ void UBGraphicsSvgItem::init()
UBGraphicsSvgItem::~UBGraphicsSvgItem()
{
if (mDelegate)
delete mDelegate;
}
@ -84,14 +83,14 @@ QByteArray UBGraphicsSvgItem::fileData() const
QVariant UBGraphicsSvgItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
QVariant newValue = mDelegate->itemChange(change, value);
QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsSvgItem::itemChange(change, newValue);
}
void UBGraphicsSvgItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event))
if (Delegate()->mousePressEvent(event))
{
//NOOP
}
@ -104,7 +103,7 @@ void UBGraphicsSvgItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsSvgItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mouseMoveEvent(event))
if (Delegate()->mouseMoveEvent(event))
{
// NOOP;
}
@ -117,7 +116,7 @@ void UBGraphicsSvgItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsSvgItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
Delegate()->mouseReleaseEvent(event);
QGraphicsSvgItem::mouseReleaseEvent(event);
}
@ -182,12 +181,6 @@ UBGraphicsScene* UBGraphicsSvgItem::scene()
}
void UBGraphicsSvgItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const
{

@ -58,10 +58,7 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi
virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void setUuid(const QUuid &pUuid);

@ -31,16 +31,17 @@
QColor UBGraphicsTextItem::lastUsedTextColor;
UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
: QGraphicsTextItem(parent)
: UBGraphicsItem()
, QGraphicsTextItem(parent)
, mMultiClickState(0)
, mLastMousePressTime(QTime::currentTime())
{
mDelegate = new UBGraphicsTextItemDelegate(this, 0);
mDelegate->init();
setDelegate(new UBGraphicsTextItemDelegate(this, 0));
Delegate()->init();
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
mDelegate->setFlippable(false);
mDelegate->setRotatable(true);
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
Delegate()->setFlippable(false);
Delegate()->setRotatable(true);
mTypeTextHereLabel = tr("<Type Text Here>");
@ -58,7 +59,7 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
setUuid(QUuid::createUuid());
connect(document(), SIGNAL(contentsChanged()), mDelegate, SLOT(contentsChanged()));
connect(document(), SIGNAL(contentsChanged()), Delegate(), SLOT(contentsChanged()));
connect(document(), SIGNAL(undoCommandAdded()), this, SLOT(undoCommandAdded()));
connect(document()->documentLayout(), SIGNAL(documentSizeChanged(const QSizeF &)),
@ -68,18 +69,14 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
UBGraphicsTextItem::~UBGraphicsTextItem()
{
if (mDelegate)
{
delete mDelegate;
}
}
QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
QVariant newValue = value;
if(mDelegate)
newValue = mDelegate->itemChange(change, value);
if(Delegate())
newValue = Delegate()->itemChange(change, value);
return QGraphicsTextItem::itemChange(change, newValue);
}
@ -95,10 +92,10 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
return;
}
if (mDelegate)
if (Delegate())
{
mDelegate->mousePressEvent(event);
if (mDelegate && parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type())
Delegate()->mousePressEvent(event);
if (Delegate() && parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type())
{
UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem());
if (group)
@ -110,13 +107,13 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
group->setCurrentItem(this);
this->setSelected(true);
mDelegate->positionHandles();
Delegate()->positionHandles();
}
}
else
{
mDelegate->getToolBarItem()->show();
Delegate()->getToolBarItem()->show();
}
}
@ -165,7 +162,7 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (!mDelegate || !mDelegate->mouseMoveEvent(event))
if (!Delegate() || !Delegate()->mouseMoveEvent(event))
{
QGraphicsTextItem::mouseMoveEvent(event);
}
@ -184,8 +181,8 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (mMultiClickState == 1)
{
if (mDelegate)
mDelegate->mouseReleaseEvent(event);
if (Delegate())
Delegate()->mouseReleaseEvent(event);
QGraphicsTextItem::mouseReleaseEvent(event);
}
@ -324,8 +321,8 @@ void UBGraphicsTextItem::resize(qreal w, qreal h)
setTextWidth(w);
setTextHeight(h);
if (mDelegate)
mDelegate->positionHandles();
if (Delegate())
Delegate()->positionHandles();
}
@ -347,12 +344,6 @@ void UBGraphicsTextItem::undoCommandAdded()
}
void UBGraphicsTextItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsTextItem::documentSizeChanged(const QSizeF & newSize)
{
resize(newSize.width(), newSize.height());

@ -58,8 +58,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual QSizeF size() const;
virtual void remove();
static QColor lastUsedTextColor;
QColor colorOnDarkBackground() const
@ -81,7 +79,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
{
mColorOnLightBackground = pColorOnLightBackground;
}
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);

@ -1,152 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include <QtWebKit>
#include "UBGraphicsWebView.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "core/memcheck.h"
UBGraphicsWebView::UBGraphicsWebView(QGraphicsItem* parent)
: QGraphicsWebView(parent)
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this, 0, true);
mDelegate->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true);
}
UBGraphicsWebView::~UBGraphicsWebView()
{
if (mDelegate)
delete mDelegate;
}
QVariant UBGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant &value)
{
if ((change == QGraphicsItem::ItemSelectedHasChanged) && scene()) {
if (isSelected())
scene()->setActiveWindow(this);
else
if(scene()->activeWindow() == this)
scene()->setActiveWindow(0);
}
QVariant newValue = mDelegate->itemChange(change, value);
return QGraphicsWebView::itemChange(change, newValue);
}
void UBGraphicsWebView::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void UBGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (!mDelegate->mousePressEvent(event))
setSelected(true); /* forcing selection */
QGraphicsWebView::mousePressEvent(event);
}
void UBGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (!mDelegate->mouseMoveEvent(event))
QGraphicsWebView::mouseMoveEvent(event);
}
void UBGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
QGraphicsWebView::mouseReleaseEvent(event);
}
void UBGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if (mDelegate->weelEvent(event))
{
QGraphicsWebView::wheelEvent(event);
event->accept();
}
}
void UBGraphicsWebView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
/* NOOP */
}
void UBGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
/* NOOP */
}
void UBGraphicsWebView::setDelegate(UBGraphicsItemDelegate* pDelegate)
{
if (mDelegate)
delete mDelegate;
mDelegate = pDelegate;
}
void UBGraphicsWebView::resize(qreal w, qreal h)
{
UBGraphicsWebView::resize(QSizeF(w, h));
}
void UBGraphicsWebView::resize(const QSizeF & pSize)
{
if (pSize != size()) {
QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height());
QGraphicsWebView::resize(pSize.width(), pSize.height());
if (mDelegate)
mDelegate->positionHandles();
if (scene())
scene()->setModified(true);
}
}
QSizeF UBGraphicsWebView::size() const
{
return QGraphicsWebView::size();
}
UBGraphicsScene* UBGraphicsWebView::scene()
{
return static_cast<UBGraphicsScene*>(QGraphicsItem::scene());
}
void UBGraphicsWebView::remove()
{
if (mDelegate)
mDelegate->remove(true);
}

@ -1,61 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSWEBVIEW_H_
#define UBGRAPHICSWEBVIEW_H_
#include <QtGui>
#include <QtWebKit>
#include "UBItem.h"
#include "UBResizableGraphicsItem.h"
class UBGraphicsItemDelegate;
class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{
public:
UBGraphicsWebView(QGraphicsItem* parent = 0);
virtual ~UBGraphicsWebView();
virtual void resize(qreal w, qreal h);
virtual void resize(const QSizeF & size);
virtual QSizeF size() const;
void setDelegate(UBGraphicsItemDelegate* pDelegate);
virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
};
#endif /* UBGRAPHICSWEBVIEW_H_ */

@ -45,7 +45,7 @@ bool UBGraphicsWidgetItem::sInlineJavaScriptLoaded = false;
QStringList UBGraphicsWidgetItem::sInlineJavaScripts;
UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem *parent)
: UBGraphicsWebView(parent)
: QGraphicsWebView(parent)
, mInitialLoadDone(false)
, mIsFreezable(true)
, mIsResizable(false)
@ -58,7 +58,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
, mShouldMoveWidget(false)
, mUniboardAPI(0)
{
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
setData(UBGraphicsItemData::ItemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
QGraphicsWebView::setPage(new UBWebPage(this));
QGraphicsWebView::settings()->setAttribute(QWebSettings::JavaEnabled, true);
@ -84,9 +84,11 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
viewPalette.setBrush(QPalette::Window, QBrush(Qt::transparent));
setPalette(viewPalette);
UBGraphicsWidgetItemDelegate* delegate = new UBGraphicsWidgetItemDelegate(this);
delegate->init();
setDelegate(delegate);
setDelegate(new UBGraphicsWidgetItemDelegate(this));
Delegate()->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true);
}
@ -97,11 +99,11 @@ UBGraphicsWidgetItem::~UBGraphicsWidgetItem()
void UBGraphicsWidgetItem::initialize()
{
UBGraphicsWebView::setMinimumSize(nominalSize());
setMinimumSize(nominalSize());
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); // Necessary to set if we want z value to be assigned correctly
if (mDelegate && mDelegate->frame() && resizable())
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
if (Delegate() && Delegate()->frame() && resizable())
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
QPalette palette = page()->palette();
palette.setBrush(QPalette::Base, QBrush(Qt::transparent));
@ -260,17 +262,6 @@ void UBGraphicsWidgetItem::removeAllDatastoreEntries()
mDatastore.clear();
}
UBGraphicsItemDelegate* UBGraphicsWidgetItem::Delegate() const
{
return mDelegate;
}
void UBGraphicsWidgetItem::remove()
{
if (mDelegate)
mDelegate->remove();
}
void UBGraphicsWidgetItem::removeScript()
{
if (page() && page()->mainFrame())
@ -360,6 +351,8 @@ QPixmap UBGraphicsWidgetItem::takeSnapshot()
mIsTakingSnapshot = false;
mSnapshot = pixmap;
return pixmap;
}
@ -502,7 +495,7 @@ bool UBGraphicsWidgetItem::event(QEvent *event)
else if (event->type() == QEvent::ShortcutOverride)
event->accept();
return UBGraphicsWebView::event(event);
return QGraphicsWebView::event(event);
}
void UBGraphicsWidgetItem::dropEvent(QGraphicsSceneDragDropEvent *event)
@ -513,7 +506,10 @@ void UBGraphicsWidgetItem::dropEvent(QGraphicsSceneDragDropEvent *event)
void UBGraphicsWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
UBGraphicsWebView::mousePressEvent(event);
if (!Delegate()->mousePressEvent(event))
setSelected(true); /* forcing selection */
QGraphicsWebView::mousePressEvent(event);
// did webkit consume the mouse press ?
mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton);
@ -527,24 +523,19 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mShouldMoveWidget = false;
UBGraphicsWebView::mouseReleaseEvent(event);
Delegate()->mouseReleaseEvent(event);
QGraphicsWebView::mouseReleaseEvent(event);
}
void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
sendJSEnterEvent();
mDelegate->hoverEnterEvent(event);
UBGraphicsWebView::hoverEnterEvent(event);
Delegate()->hoverEnterEvent(event);
}
void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
sendJSLeaveEvent();
mDelegate->hoverLeaveEvent(event);
UBGraphicsWebView::hoverLeaveEvent(event);
}
void UBGraphicsWidgetItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
UBGraphicsWebView::hoverMoveEvent(event);
Delegate()->hoverLeaveEvent(event);
}
void UBGraphicsWidgetItem::sendJSEnterEvent()
@ -572,33 +563,40 @@ void UBGraphicsWidgetItem::injectInlineJavaScript()
void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if (mIsFrozen)
painter->drawPixmap(0, 0, mSnapshot);
if (scene()->renderingContext() != UBGraphicsScene::Screen)
{
painter->drawPixmap(0, 0, snapshot());
}
else
UBGraphicsWebView::paint(painter, option, widget);
if (!mInitialLoadDone || mLoadIsErronous) {
QString message;
{
if (!mInitialLoadDone || mLoadIsErronous)
{
QString message;
if (mInitialLoadDone && mLoadIsErronous)
message = tr("Cannot load content");
else
message = tr("Loading ...");
if (mInitialLoadDone && mLoadIsErronous)
message = tr("Cannot load content");
else
message = tr("Loading ...");
painter->setFont(QFont("Arial", 12));
painter->setFont(QFont("Arial", 12));
QFontMetrics fm = painter->fontMetrics();
QRect txtBoundingRect = fm.boundingRect(message);
QFontMetrics fm = painter->fontMetrics();
QRect txtBoundingRect = fm.boundingRect(message);
txtBoundingRect.moveCenter(rect().center().toPoint());
txtBoundingRect.adjust(-10, -5, 10, 5);
txtBoundingRect.moveCenter(rect().center().toPoint());
txtBoundingRect.adjust(-10, -5, 10, 5);
painter->setPen(Qt::NoPen);
painter->setBrush(UBSettings::paletteColor);
painter->drawRoundedRect(txtBoundingRect, 3, 3);
painter->setPen(Qt::NoPen);
painter->setBrush(UBSettings::paletteColor);
painter->drawRoundedRect(txtBoundingRect, 3, 3);
painter->setPen(Qt::white);
painter->drawText(rect(), Qt::AlignCenter, message);
painter->setPen(Qt::white);
painter->drawText(rect(), Qt::AlignCenter, message);
}
else
QGraphicsWebView::paint(painter, option, widget);
}
}
void UBGraphicsWidgetItem::geometryChangeRequested(const QRect& geom)
@ -624,6 +622,52 @@ void UBGraphicsWidgetItem::mainFrameLoadFinished (bool ok)
update(boundingRect());
}
void UBGraphicsWidgetItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if (Delegate()->weelEvent(event))
{
QGraphicsWebView::wheelEvent(event);
event->accept();
}
}
QVariant UBGraphicsWidgetItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if ((change == QGraphicsItem::ItemSelectedHasChanged) && scene()) {
if (isSelected())
scene()->setActiveWindow(this);
else
if(scene()->activeWindow() == this)
scene()->setActiveWindow(0);
}
QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsWebView::itemChange(change, newValue);
}
void UBGraphicsWidgetItem::resize(qreal w, qreal h)
{
UBGraphicsWidgetItem::resize(QSizeF(w, h));
}
void UBGraphicsWidgetItem::resize(const QSizeF & pSize)
{
if (pSize != size()) {
QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height());
QGraphicsWebView::resize(pSize.width(), pSize.height());
if (Delegate())
Delegate()->positionHandles();
if (scene())
scene()->setModified(true);
}
}
QSizeF UBGraphicsWidgetItem::size() const
{
return QGraphicsWebView::size();
}
UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent)
@ -881,21 +925,6 @@ UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
return copy;
}
void UBGraphicsW3CWidgetItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
UBGraphicsScene::RenderingContext rc = UBGraphicsScene::Screen;
if (scene())
rc = scene()->renderingContext();
if (rc == UBGraphicsScene::NonScreen || rc == UBGraphicsScene::PdfExport) {
if (!snapshot().isNull())
painter->drawPixmap(0, 0, snapshot());
}
else
UBGraphicsWidgetItem::paint(painter, option, widget);
}
QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> UBGraphicsW3CWidgetItem::preferences()
{
return mPreferences;

@ -19,10 +19,11 @@
#include <QtWebKit>
#include <QDomElement>
#include "UBGraphicsWebView.h"
#include "core/UB.h"
#include "UBItem.h"
#include "UBResizableGraphicsItem.h"
class UBWidgetUniboardAPI;
class UBGraphicsScene;
class UBW3CWidgetAPI;
@ -38,7 +39,7 @@ struct UBWidgetType
};
};
class UBGraphicsWidgetItem : public UBGraphicsWebView
class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{
Q_OBJECT
@ -52,6 +53,10 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
virtual void initialize();
virtual void resize(qreal w, qreal h);
virtual void resize(const QSizeF & size);
virtual QSizeF size() const;
QUrl mainHtml();
void loadMainHtml();
QUrl widgetUrl();
@ -75,9 +80,6 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
void removeDatastoreEntry(const QString& key);
void removeAllDatastoreEntries();
virtual UBGraphicsItemDelegate* Delegate() const;
virtual void remove();
void removeScript();
void processDropEvent(QGraphicsSceneDragDropEvent *event);
@ -140,16 +142,18 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
QMap<QString, QString> mDatastore;
QMap<QString, QString> mPreferences;
virtual bool event(QEvent *event);
virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual void sendJSEnterEvent();
virtual void sendJSLeaveEvent();
virtual void injectInlineJavaScript();
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
protected slots:
@ -230,7 +234,6 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget );
QMap<QString, PreferenceValue> preferences();
Metadata metadatas() const;

@ -38,6 +38,18 @@ UBItem::~UBItem()
// NOOP
}
UBGraphicsItem::~UBGraphicsItem()
{
if (mDelegate!=NULL)
delete mDelegate;
}
void UBGraphicsItem::setDelegate(UBGraphicsItemDelegate* delegate)
{
Q_ASSERT(mDelegate==NULL);
mDelegate = delegate;
}
void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value)
{
item->setZValue(value);
@ -54,6 +66,13 @@ bool UBGraphicsItem::isRotatable(QGraphicsItem *item)
return item->data(UBGraphicsItemData::ItemRotatable).toBool();
}
void UBGraphicsItem::remove()
{
if (Delegate())
Delegate()->remove(this);
}
UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem)
{
UBGraphicsItemDelegate *result = 0;

@ -90,30 +90,30 @@ class UBItem
class UBGraphicsItem
{
protected:
UBGraphicsItem() : mDelegate(0)
{
// NOOP
}
UBGraphicsItemDelegate* mDelegate;
virtual ~UBGraphicsItem()
UBGraphicsItem() : mDelegate(NULL)
{
// NOOP
}
virtual ~UBGraphicsItem();
void setDelegate(UBGraphicsItemDelegate* mDelegate);
public:
inline UBGraphicsItemDelegate *Delegate() const { return mDelegate; }
static void assignZValue(QGraphicsItem*, qreal value);
static bool isRotatable(QGraphicsItem *item);
static bool isFlippable(QGraphicsItem *item);
static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem);
virtual UBGraphicsItemDelegate *Delegate() const = 0;
virtual void remove() = 0;
void remove();
virtual void clearSource(){;}
virtual void clearSource(){}
private:
UBGraphicsItemDelegate* mDelegate;
};
#endif // UBITEM_H

@ -6,7 +6,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBDocumentUndoCommand.h \
src/domain/UBPageSizeUndoCommand.h \
src/domain/UBGraphicsProxyWidget.h \
src/domain/UBGraphicsWebView.h \
src/domain/UBGraphicsSvgItem.h \
src/domain/UBGraphicsPolygonItem.h \
src/domain/UBItem.h \
@ -35,7 +34,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBDocumentUndoCommand.cpp \
src/domain/UBPageSizeUndoCommand.cpp \
src/domain/UBGraphicsProxyWidget.cpp \
src/domain/UBGraphicsWebView.cpp \
src/domain/UBGraphicsSvgItem.cpp \
src/domain/UBGraphicsPolygonItem.cpp \
src/domain/UBItem.cpp \
@ -47,8 +45,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/UBGraphicsGroupContainerItem.cpp \
src/domain/UBGraphicsGroupContainerItemDelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp \
src/domain/UBGraphicsItemGroupUndoCommand.cpp \
src/domain/UBGraphicsItemDelegate.cpp \

@ -14,6 +14,7 @@
*/
#include <QtGlobal>
#include <QString>
#include "Config.h"
#include "Utils.h"
#include "Exception.h"
@ -65,18 +66,12 @@ double Utils::stringToDouble(const std::string & s )
std::string Utils::uIntToStr(unsigned int integer)
{
char str[10];
snprintf(str, sizeof(str), "%u", integer);
return std::string(str);
return std::string(QString::number(integer).toAscii());
}
std::string Utils::doubleToStr(double doubleValue)
{
char str[16];
snprintf(str, sizeof(str), "%f", doubleValue);
return std::string(str);
return std::string(QString::number(doubleValue).toAscii());
}
int Utils::_stringToInt(const std::string & str) //throw ConvertException

@ -37,8 +37,9 @@ const QColor UBGraphicsCurtainItem::sDarkBackgroundOpaqueControlColor = QColor(6
UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
: QGraphicsRectItem(parent)
{
mDelegate = new UBGraphicsCurtainItemDelegate(this, 0);
mDelegate->init();
UBGraphicsCurtainItemDelegate* delegate = new UBGraphicsCurtainItemDelegate(this, 0);
delegate->init();
setDelegate(delegate);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -56,7 +57,6 @@ UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
UBGraphicsCurtainItem::~UBGraphicsCurtainItem()
{
delete mDelegate;
}
QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVariant &value)
@ -64,9 +64,9 @@ QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVar
QVariant newValue = value;
if (mDelegate)
if (Delegate())
{
newValue = mDelegate->itemChange(change, value);
newValue = Delegate()->itemChange(change, value);
}
return QGraphicsRectItem::itemChange(change, newValue);
@ -80,7 +80,7 @@ void UBGraphicsCurtainItem::setUuid(const QUuid &pUuid)
void UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event))
if (Delegate()->mousePressEvent(event))
{
//NOOP
}
@ -92,7 +92,7 @@ void UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCurtainItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mouseMoveEvent(event))
if (Delegate()->mouseMoveEvent(event))
{
// NOOP;
}
@ -104,7 +104,7 @@ void UBGraphicsCurtainItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCurtainItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
Delegate()->mouseReleaseEvent(event);
QGraphicsRectItem::mouseReleaseEvent(event);
}
@ -171,13 +171,6 @@ QColor UBGraphicsCurtainItem::opaqueControlColor() const
}
void UBGraphicsCurtainItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsCurtainItem::triggerRemovedSignal()
{
emit removed();

@ -44,11 +44,8 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
//TODO UB 4.x not nice ...
void triggerRemovedSignal();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);

@ -40,13 +40,12 @@ class UBGraphicsCurtainItemDelegate : public UBGraphicsItemDelegate
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
virtual void positionHandles();
virtual void init();
public slots:
virtual void remove(bool checked, bool canUndo = true);
protected:
virtual void init();
};
#endif /* UBGRAPHICSCURTAINITEMDELEGATE_H_ */

Loading…
Cancel
Save