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

preferencesAboutTextFull
Claudio Valerio 12 years ago
commit a390738e34
  1. 4
      resources/library/interactivities/Contraste.wgt/css/basic.css
  2. 139
      resources/library/interactivities/Contraste.wgt/locales/fr/scripts/blackYellow.js
  3. 137
      resources/library/interactivities/Contraste.wgt/locales/ru/scripts/blackYellow.js
  4. 128
      resources/library/interactivities/Contraste.wgt/scripts/blackYellow.js
  5. 46
      src/board/UBBoardController.cpp
  6. 1
      src/board/UBBoardController.h
  7. 59
      src/board/UBBoardView.cpp
  8. 7
      src/board/UBBoardView.h
  9. 1
      src/core/UB.h
  10. 2
      src/desktop/UBDesktopPalette.cpp
  11. 3
      src/domain/UBAbstractUndoCommand.h
  12. 96
      src/domain/UBGraphicsDelegateFrame.cpp
  13. 6
      src/domain/UBGraphicsDelegateFrame.h
  14. 10
      src/domain/UBGraphicsGroupContainerItem.cpp
  15. 1
      src/domain/UBGraphicsGroupContainerItem.h
  16. 1
      src/domain/UBGraphicsGroupContainerItemDelegate.cpp
  17. 20
      src/domain/UBGraphicsItemDelegate.cpp
  18. 1
      src/domain/UBGraphicsItemDelegate.h
  19. 58
      src/domain/UBGraphicsItemGroupUndoCommand.cpp
  20. 30
      src/domain/UBGraphicsItemGroupUndoCommand.h
  21. 2
      src/domain/UBGraphicsItemTransformUndoCommand.h
  22. 9
      src/domain/UBGraphicsItemUndoCommand.cpp
  23. 6
      src/domain/UBGraphicsItemUndoCommand.h
  24. 7
      src/domain/UBGraphicsPolygonItem.cpp
  25. 1
      src/domain/UBGraphicsPolygonItem.h
  26. 9
      src/domain/UBGraphicsScene.cpp
  27. 20
      src/domain/UBGraphicsStrokesGroup.cpp
  28. 3
      src/domain/UBGraphicsStrokesGroup.h
  29. 17
      src/domain/domain.pri
  30. 6
      src/gui/UBFeaturesWidget.cpp
  31. 18
      src/gui/UBTeacherGuideWidget.cpp

@ -144,9 +144,13 @@ body{
font-family: Verdana,Arial,Helvetica,sans-serif; font-family: Verdana,Arial,Helvetica,sans-serif;
font-weight: bold; font-weight: bold;
font-size:24px; font-size:24px;
word-wrap: break-word;
} }
.editContainer{ .editContainer{
min-width: 200px;
max-width: 240px;
height: auto;
position: absolute; position: absolute;
border: 5px solid #c7c7c7; border: 5px solid #c7c7c7;
-webkit-border-radius: 5px; -webkit-border-radius: 5px;

@ -82,17 +82,20 @@ function init(){
.css("left",importArray[i].left); .css("left",importArray[i].left);
tmpReadyTask.appendTo("#data"); tmpReadyTask.appendTo("#data");
} }
$(document).disableTextSelect();
} }
$(document).disableTextSelect();
} }
/* ------------- BUTTONS -------------*/ /* ------------- BUTTONS -------------*/
if(window.sankore){
if(sankore.preference("by_style","")){ if(sankore.preference("by_style","")){
changeStyle(sankore.preference("by_style","")); changeStyle(sankore.preference("by_style",""));
$(".style_select").val(sankore.preference("by_style","")); $(".style_select").val(sankore.preference("by_style",""));
} else } else
changeStyle("3") changeStyle("3")
} else
changeStyle("3")
$("#wgt_display, #wgt_edit").click(function(event){ $("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){ if(this.id == "wgt_display"){
@ -106,7 +109,7 @@ function init(){
mode = false; mode = false;
$(".leftDiv, .rightDiv").animate({ $(".leftDiv, .rightDiv").animate({
"opacity":"1" "opacity":"1"
},"slow",function(){ },"fast",function(){
if(opacityChanged){ if(opacityChanged){
if($(".editContainer").size() != 0){ if($(".editContainer").size() != 0){
$(".editContainer").each(function(index, domElem){ $(".editContainer").each(function(index, domElem){
@ -139,14 +142,17 @@ function init(){
$(document).enableTextSelect(); $(document).enableTextSelect();
$(".leftDiv, .rightDiv").animate({ $(".leftDiv, .rightDiv").animate({
"opacity":"0.4" "opacity":"0.4"
},"slow",function(){ },"fast",function(){
if(!opacityChanged){ if(!opacityChanged){
if($(".readyTask").size() != 0){ if($(".readyTask").size() != 0){
var tmp_arr = [];
$(".readyTask").each(function(){
tmp_arr.push($(this));
})
orderItems(tmp_arr);
$(".readyTask").each(function(index, domElem){ $(".readyTask").each(function(index, domElem){
var editContent = $("<div class='editContainer'>").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("#data"); var editContent = $("<div class='editContainer'>").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("#data");
var closeItem = $("<div class='closeItem'>").appendTo(editContent); var closeItem = $("<div class='closeItem'>").appendTo(editContent);
var rightResize = $("<div class='rightResize'>").appendTo(editContent);
var bottomResize = $("<div class='bottomResize'>").appendTo(editContent);
editContent.css("top", $(domElem).position().top).css("left", $(domElem).position().left); editContent.css("top", $(domElem).position().top).css("left", $(domElem).position().left);
$(domElem).css("position","static") $(domElem).css("position","static")
.width("100%") .width("100%")
@ -178,7 +184,7 @@ function init(){
}); });
$("#wgt_reload").click(function(){ $("#wgt_reload").click(function(){
window.location.reload(); reloadItems();
}); });
$("#wgt_add").click(function(){ $("#wgt_add").click(function(){
@ -188,10 +194,9 @@ function init(){
$("#data").show(); $("#data").show();
}); });
} }
shadowDiv.show() shadowDiv.show();
shadowOver = true; shadowOver = true;
popupBack.show("slow"); popupBack.show("slow");
$(document).disableTextSelect(); $(document).disableTextSelect();
}); });
@ -241,7 +246,6 @@ function init(){
shadowOver = false; shadowOver = false;
$(document).enableTextSelect(); $(document).enableTextSelect();
}); });
}); });
okButton.click(function(){ okButton.click(function(){
@ -256,7 +260,6 @@ function init(){
$(document).enableTextSelect(); $(document).enableTextSelect();
}) })
} }
}); });
/* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ /* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/
@ -271,6 +274,7 @@ function init(){
}); });
$(".readyTask, .editContainer").live("mousedown",function(event){ $(".readyTask, .editContainer").live("mousedown",function(event){
if($("#wgt_display").hasClass("selected")){
if(!shadowOver){ if(!shadowOver){
dragElement = $(this); dragElement = $(this);
coords.left = event.pageX - $(this).position().left; coords.left = event.pageX - $(this).position().left;
@ -278,23 +282,12 @@ function init(){
resizeObj.width = $(this).width(); resizeObj.width = $(this).width();
resizeObj.height = $(this).height(); resizeObj.height = $(this).height();
} }
if($("#wgt_display").hasClass("selected"))
$(document).disableTextSelect(); $(document).disableTextSelect();
});
$(".rightResize").live("mousedown",function(event){
if(!shadowOver){
resizeObj.x = true;
}
});
$(".bottomResize").live("mousedown",function(event){
if(!shadowOver){
resizeObj.y = true;
} }
}); });
$("body").mouseup(function(event){ $("body").mouseup(function(event){
if($("#wgt_display").hasClass("selected")){
if(!shadowOver){ if(!shadowOver){
if (dragElement) { if (dragElement) {
exportToSankore(); exportToSankore();
@ -303,10 +296,11 @@ function init(){
resizeObj.x = false; resizeObj.x = false;
resizeObj.y = false; resizeObj.y = false;
} }
}
}); });
$("body").mousemove(function(event){ $("body").mousemove(function(event){
if(dragElement && !shadowOver){ if(dragElement && !shadowOver && $("#wgt_display").hasClass("selected")){
var top = event.pageY - coords.top; var top = event.pageY - coords.top;
var left = event.pageX - coords.left; var left = event.pageX - coords.left;
var bottom = top + dragElement.height(); var bottom = top + dragElement.height();
@ -335,6 +329,36 @@ function init(){
} }
}); });
$(".taskContainer").live("keyup", function(){
if($(".editContainer").size() > 1){
var prev = $(".editContainer:first"),
prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
recursionCall(prevBottom, prevLeft, prev.next());
}
})
function recursionCall(prevBottom, prevLeft, curr){
var curTop = curr.position().top,
curHeight = curr.height(),
curLeft = curr.position().left;
if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px");
else
curr.css("top", "60px").css("left", prevLeft + 255 + "px");
} else {
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else
curr.css("top", "60px");
}
prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left;
if(curr.next().length)
recursionCall(prevBottom, prevLeft, curr.next());
}
//$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); //$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height());
popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%");
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
@ -347,7 +371,7 @@ function init(){
if (window.widget) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
//exportToSankore(); exportToSankore();
sankore.setPreference("by_style", $(".style_select").find("option:selected").val()); sankore.setPreference("by_style", $(".style_select").find("option:selected").val());
} }
} }
@ -397,6 +421,7 @@ function init(){
}); });
} }
} }
if(window.sankore)
sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport)); sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport));
} }
} }
@ -412,18 +437,70 @@ function checkEmptyFields(field){
} }
} }
//reload
function reloadItems(){
if($("#wgt_edit").hasClass("selected"))
$("#wgt_display").trigger("click");
else{
var tmp_array = [];
$(".readyTask").each(function(){
tmp_array.push($(this));
});
tmp_array = shuffle(tmp_array);
orderItems(tmp_array);
}
}
//order items
function orderItems(items){
var bottom = 45,
lastItemLeft = 54;
for (var i in items){
if((bottom + items[i].height()) < ($(window).height() - 54)){
items[i].css("top", bottom + 15 + "px").css("left", lastItemLeft + "px").appendTo("#data");
bottom += items[i].height() + 15;
} else {
bottom = 60;
lastItemLeft += 255;
items[i].css("top", bottom + "px").css("left", lastItemLeft + "px").appendTo("#data");
bottom += items[i].height();
}
}
}
//shuffles an array
function shuffle( arr )
{
var pos, tmp;
for( var i = 0; i < arr.length; i++ )
{
pos = Math.round( Math.random() * ( arr.length - 1 ) );
tmp = arr[pos];
arr[pos] = arr[i];
arr[i] = tmp;
}
return arr;
}
//adding a new task to the page //adding a new task to the page
function addTask(expression, result){ function addTask(expression, result){
var lastItem = $(".editContainer:last"), var lastItem = $(".editContainer:last"),
lastItemPos = lastItem.length ? lastItem.position().top : 45, lastItemPos = lastItem.length ? lastItem.position().top : 45,
lastItemHeight = lastItem.length ? lastItem.height() : 0; lastItemHeight = lastItem.length ? lastItem.height() : 0,
var editContent = $("<div class='editContainer'>").width(240).height(70).css("top", lastItemPos + lastItemHeight + 15 + "px").appendTo("#data"); lastItemLeft = lastItem.length ? lastItem.position().left : 54;
var closeItem = $("<div class='closeItem'>").appendTo(editContent); var bottom = lastItemPos + lastItemHeight + 85;
var rightResize = $("<div class='rightResize'>").appendTo(editContent); var editContent = $("<div class='editContainer'>");
var bottomResize = $("<div class='bottomResize'>").appendTo(editContent); $("<div class='closeItem'>").appendTo(editContent);
var main = $("<div class='readyTask'>"); var main = $("<div class='readyTask'>");
var exprContainer = $("<div class='taskContainer' style='color: yellow;' contenteditable='true'>" + expression + "</div>").appendTo(main); $("<div class='taskContainer' style='color: yellow;' contenteditable='true'>" + expression + "</div>").appendTo(main);
var resContainer = $("<div class='taskContainer' style='color: black;' contenteditable='true'>"+ result + "</div>").appendTo(main); $("<div class='taskContainer' style='color: black;' contenteditable='true'>"+ result + "</div>").appendTo(main);
if(bottom < ($(window).height() - 54)){
editContent.css("top", lastItemPos + lastItemHeight + 15 + "px").css("left", lastItemLeft + "px").appendTo("#data");
} else {
lastItemPos = 45;
editContent.css("top", lastItemPos + 15 + "px").css("left", lastItemLeft + 255 + "px").appendTo("#data");
}
main.appendTo(editContent); main.appendTo(editContent);
} }

@ -88,11 +88,14 @@ function init(){
/* ------------- BUTTONS -------------*/ /* ------------- BUTTONS -------------*/
if(window.sankore){
if(sankore.preference("by_style","")){ if(sankore.preference("by_style","")){
changeStyle(sankore.preference("by_style","")); changeStyle(sankore.preference("by_style",""));
$(".style_select").val(sankore.preference("by_style","")); $(".style_select").val(sankore.preference("by_style",""));
} else } else
changeStyle("3") changeStyle("3")
} else
changeStyle("3")
$("#wgt_display, #wgt_edit").click(function(event){ $("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){ if(this.id == "wgt_display"){
@ -106,7 +109,7 @@ function init(){
mode = false; mode = false;
$(".leftDiv, .rightDiv").animate({ $(".leftDiv, .rightDiv").animate({
"opacity":"1" "opacity":"1"
},"slow",function(){ },"fast",function(){
if(opacityChanged){ if(opacityChanged){
if($(".editContainer").size() != 0){ if($(".editContainer").size() != 0){
$(".editContainer").each(function(index, domElem){ $(".editContainer").each(function(index, domElem){
@ -139,14 +142,17 @@ function init(){
$(document).enableTextSelect(); $(document).enableTextSelect();
$(".leftDiv, .rightDiv").animate({ $(".leftDiv, .rightDiv").animate({
"opacity":"0.4" "opacity":"0.4"
},"slow",function(){ },"fast",function(){
if(!opacityChanged){ if(!opacityChanged){
if($(".readyTask").size() != 0){ if($(".readyTask").size() != 0){
var tmp_arr = [];
$(".readyTask").each(function(){
tmp_arr.push($(this));
})
orderItems(tmp_arr);
$(".readyTask").each(function(index, domElem){ $(".readyTask").each(function(index, domElem){
var editContent = $("<div class='editContainer'>").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("#data"); var editContent = $("<div class='editContainer'>").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("#data");
var closeItem = $("<div class='closeItem'>").appendTo(editContent); var closeItem = $("<div class='closeItem'>").appendTo(editContent);
var rightResize = $("<div class='rightResize'>").appendTo(editContent);
var bottomResize = $("<div class='bottomResize'>").appendTo(editContent);
editContent.css("top", $(domElem).position().top).css("left", $(domElem).position().left); editContent.css("top", $(domElem).position().top).css("left", $(domElem).position().left);
$(domElem).css("position","static") $(domElem).css("position","static")
.width("100%") .width("100%")
@ -178,7 +184,7 @@ function init(){
}); });
$("#wgt_reload").click(function(){ $("#wgt_reload").click(function(){
window.location.reload(); reloadItems();
}); });
$("#wgt_add").click(function(){ $("#wgt_add").click(function(){
@ -188,10 +194,9 @@ function init(){
$("#data").show(); $("#data").show();
}); });
} }
shadowDiv.show() shadowDiv.show();
shadowOver = true; shadowOver = true;
popupBack.show("slow"); popupBack.show("slow");
$(document).disableTextSelect(); $(document).disableTextSelect();
}); });
@ -241,7 +246,6 @@ function init(){
shadowOver = false; shadowOver = false;
$(document).enableTextSelect(); $(document).enableTextSelect();
}); });
}); });
okButton.click(function(){ okButton.click(function(){
@ -256,7 +260,6 @@ function init(){
$(document).enableTextSelect(); $(document).enableTextSelect();
}) })
} }
}); });
/* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ /* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/
@ -271,6 +274,7 @@ function init(){
}); });
$(".readyTask, .editContainer").live("mousedown",function(event){ $(".readyTask, .editContainer").live("mousedown",function(event){
if($("#wgt_display").hasClass("selected")){
if(!shadowOver){ if(!shadowOver){
dragElement = $(this); dragElement = $(this);
coords.left = event.pageX - $(this).position().left; coords.left = event.pageX - $(this).position().left;
@ -278,23 +282,12 @@ function init(){
resizeObj.width = $(this).width(); resizeObj.width = $(this).width();
resizeObj.height = $(this).height(); resizeObj.height = $(this).height();
} }
if($("#wgt_display").hasClass("selected"))
$(document).disableTextSelect(); $(document).disableTextSelect();
});
$(".rightResize").live("mousedown",function(event){
if(!shadowOver){
resizeObj.x = true;
}
});
$(".bottomResize").live("mousedown",function(event){
if(!shadowOver){
resizeObj.y = true;
} }
}); });
$("body").mouseup(function(event){ $("body").mouseup(function(event){
if($("#wgt_display").hasClass("selected")){
if(!shadowOver){ if(!shadowOver){
if (dragElement) { if (dragElement) {
exportToSankore(); exportToSankore();
@ -303,10 +296,11 @@ function init(){
resizeObj.x = false; resizeObj.x = false;
resizeObj.y = false; resizeObj.y = false;
} }
}
}); });
$("body").mousemove(function(event){ $("body").mousemove(function(event){
if(dragElement && !shadowOver){ if(dragElement && !shadowOver && $("#wgt_display").hasClass("selected")){
var top = event.pageY - coords.top; var top = event.pageY - coords.top;
var left = event.pageX - coords.left; var left = event.pageX - coords.left;
var bottom = top + dragElement.height(); var bottom = top + dragElement.height();
@ -335,6 +329,36 @@ function init(){
} }
}); });
$(".taskContainer").live("keyup", function(){
if($(".editContainer").size() > 1){
var prev = $(".editContainer:first"),
prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
recursionCall(prevBottom, prevLeft, prev.next());
}
})
function recursionCall(prevBottom, prevLeft, curr){
var curTop = curr.position().top,
curHeight = curr.height(),
curLeft = curr.position().left;
if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px");
else
curr.css("top", "60px").css("left", prevLeft + 255 + "px");
} else {
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else
curr.css("top", "60px");
}
prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left;
if(curr.next().length)
recursionCall(prevBottom, prevLeft, curr.next());
}
//$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); //$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height());
popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%");
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
@ -347,7 +371,7 @@ function init(){
if (window.widget) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
//exportToSankore(); exportToSankore();
sankore.setPreference("by_style", $(".style_select").find("option:selected").val()); sankore.setPreference("by_style", $(".style_select").find("option:selected").val());
} }
} }
@ -397,6 +421,7 @@ function init(){
}); });
} }
} }
if(window.sankore)
sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport)); sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport));
} }
} }
@ -412,18 +437,70 @@ function checkEmptyFields(field){
} }
} }
//reload
function reloadItems(){
if($("#wgt_edit").hasClass("selected"))
$("#wgt_display").trigger("click");
else{
var tmp_array = [];
$(".readyTask").each(function(){
tmp_array.push($(this));
});
tmp_array = shuffle(tmp_array);
orderItems(tmp_array);
}
}
//order items
function orderItems(items){
var bottom = 45,
lastItemLeft = 54;
for (var i in items){
if((bottom + items[i].height()) < ($(window).height() - 54)){
items[i].css("top", bottom + 15 + "px").css("left", lastItemLeft + "px").appendTo("#data");
bottom += items[i].height() + 15;
} else {
bottom = 60;
lastItemLeft += 255;
items[i].css("top", bottom + "px").css("left", lastItemLeft + "px").appendTo("#data");
bottom += items[i].height();
}
}
}
//shuffles an array
function shuffle( arr )
{
var pos, tmp;
for( var i = 0; i < arr.length; i++ )
{
pos = Math.round( Math.random() * ( arr.length - 1 ) );
tmp = arr[pos];
arr[pos] = arr[i];
arr[i] = tmp;
}
return arr;
}
//adding a new task to the page //adding a new task to the page
function addTask(expression, result){ function addTask(expression, result){
var lastItem = $(".editContainer:last"), var lastItem = $(".editContainer:last"),
lastItemPos = lastItem.length ? lastItem.position().top : 45, lastItemPos = lastItem.length ? lastItem.position().top : 45,
lastItemHeight = lastItem.length ? lastItem.height() : 0; lastItemHeight = lastItem.length ? lastItem.height() : 0,
var editContent = $("<div class='editContainer'>").width(240).height(70).css("top", lastItemPos + lastItemHeight + 15 + "px").appendTo("#data"); lastItemLeft = lastItem.length ? lastItem.position().left : 54;
var closeItem = $("<div class='closeItem'>").appendTo(editContent); var bottom = lastItemPos + lastItemHeight + 85;
var rightResize = $("<div class='rightResize'>").appendTo(editContent); var editContent = $("<div class='editContainer'>");
var bottomResize = $("<div class='bottomResize'>").appendTo(editContent); $("<div class='closeItem'>").appendTo(editContent);
var main = $("<div class='readyTask'>"); var main = $("<div class='readyTask'>");
var exprContainer = $("<div class='taskContainer' style='color: yellow;' contenteditable='true'>" + expression + "</div>").appendTo(main); $("<div class='taskContainer' style='color: yellow;' contenteditable='true'>" + expression + "</div>").appendTo(main);
var resContainer = $("<div class='taskContainer' style='color: black;' contenteditable='true'>"+ result + "</div>").appendTo(main); $("<div class='taskContainer' style='color: black;' contenteditable='true'>"+ result + "</div>").appendTo(main);
if(bottom < ($(window).height() - 54)){
editContent.css("top", lastItemPos + lastItemHeight + 15 + "px").css("left", lastItemLeft + "px").appendTo("#data");
} else {
lastItemPos = 45;
editContent.css("top", lastItemPos + 15 + "px").css("left", lastItemLeft + 255 + "px").appendTo("#data");
}
main.appendTo(editContent); main.appendTo(editContent);
} }

@ -109,7 +109,7 @@ function init(){
mode = false; mode = false;
$(".leftDiv, .rightDiv").animate({ $(".leftDiv, .rightDiv").animate({
"opacity":"1" "opacity":"1"
},"slow",function(){ },"fast",function(){
if(opacityChanged){ if(opacityChanged){
if($(".editContainer").size() != 0){ if($(".editContainer").size() != 0){
$(".editContainer").each(function(index, domElem){ $(".editContainer").each(function(index, domElem){
@ -142,14 +142,17 @@ function init(){
$(document).enableTextSelect(); $(document).enableTextSelect();
$(".leftDiv, .rightDiv").animate({ $(".leftDiv, .rightDiv").animate({
"opacity":"0.4" "opacity":"0.4"
},"slow",function(){ },"fast",function(){
if(!opacityChanged){ if(!opacityChanged){
if($(".readyTask").size() != 0){ if($(".readyTask").size() != 0){
var tmp_arr = [];
$(".readyTask").each(function(){
tmp_arr.push($(this));
})
orderItems(tmp_arr);
$(".readyTask").each(function(index, domElem){ $(".readyTask").each(function(index, domElem){
var editContent = $("<div class='editContainer'>").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("#data"); var editContent = $("<div class='editContainer'>").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("#data");
var closeItem = $("<div class='closeItem'>").appendTo(editContent); var closeItem = $("<div class='closeItem'>").appendTo(editContent);
var rightResize = $("<div class='rightResize'>").appendTo(editContent);
var bottomResize = $("<div class='bottomResize'>").appendTo(editContent);
editContent.css("top", $(domElem).position().top).css("left", $(domElem).position().left); editContent.css("top", $(domElem).position().top).css("left", $(domElem).position().left);
$(domElem).css("position","static") $(domElem).css("position","static")
.width("100%") .width("100%")
@ -181,7 +184,7 @@ function init(){
}); });
$("#wgt_reload").click(function(){ $("#wgt_reload").click(function(){
window.location.reload(); reloadItems();
}); });
$("#wgt_add").click(function(){ $("#wgt_add").click(function(){
@ -271,6 +274,7 @@ function init(){
}); });
$(".readyTask, .editContainer").live("mousedown",function(event){ $(".readyTask, .editContainer").live("mousedown",function(event){
if($("#wgt_display").hasClass("selected")){
if(!shadowOver){ if(!shadowOver){
dragElement = $(this); dragElement = $(this);
coords.left = event.pageX - $(this).position().left; coords.left = event.pageX - $(this).position().left;
@ -278,23 +282,12 @@ function init(){
resizeObj.width = $(this).width(); resizeObj.width = $(this).width();
resizeObj.height = $(this).height(); resizeObj.height = $(this).height();
} }
if($("#wgt_display").hasClass("selected"))
$(document).disableTextSelect(); $(document).disableTextSelect();
});
$(".rightResize").live("mousedown",function(event){
if(!shadowOver){
resizeObj.x = true;
}
});
$(".bottomResize").live("mousedown",function(event){
if(!shadowOver){
resizeObj.y = true;
} }
}); });
$("body").mouseup(function(event){ $("body").mouseup(function(event){
if($("#wgt_display").hasClass("selected")){
if(!shadowOver){ if(!shadowOver){
if (dragElement) { if (dragElement) {
exportToSankore(); exportToSankore();
@ -303,10 +296,11 @@ function init(){
resizeObj.x = false; resizeObj.x = false;
resizeObj.y = false; resizeObj.y = false;
} }
}
}); });
$("body").mousemove(function(event){ $("body").mousemove(function(event){
if(dragElement && !shadowOver){ if(dragElement && !shadowOver && $("#wgt_display").hasClass("selected")){
var top = event.pageY - coords.top; var top = event.pageY - coords.top;
var left = event.pageX - coords.left; var left = event.pageX - coords.left;
var bottom = top + dragElement.height(); var bottom = top + dragElement.height();
@ -335,6 +329,36 @@ function init(){
} }
}); });
$(".taskContainer").live("keyup", function(){
if($(".editContainer").size() > 1){
var prev = $(".editContainer:first"),
prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
recursionCall(prevBottom, prevLeft, prev.next());
}
})
function recursionCall(prevBottom, prevLeft, curr){
var curTop = curr.position().top,
curHeight = curr.height(),
curLeft = curr.position().left;
if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px");
else
curr.css("top", "60px").css("left", prevLeft + 255 + "px");
} else {
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else
curr.css("top", "60px");
}
prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left;
if(curr.next().length)
recursionCall(prevBottom, prevLeft, curr.next());
}
//$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); //$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height());
popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%");
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
@ -347,7 +371,7 @@ function init(){
if (window.widget) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
//exportToSankore(); exportToSankore();
sankore.setPreference("by_style", $(".style_select").find("option:selected").val()); sankore.setPreference("by_style", $(".style_select").find("option:selected").val());
} }
} }
@ -413,18 +437,70 @@ function checkEmptyFields(field){
} }
} }
//reload
function reloadItems(){
if($("#wgt_edit").hasClass("selected"))
$("#wgt_display").trigger("click");
else{
var tmp_array = [];
$(".readyTask").each(function(){
tmp_array.push($(this));
});
tmp_array = shuffle(tmp_array);
orderItems(tmp_array);
}
}
//order items
function orderItems(items){
var bottom = 45,
lastItemLeft = 54;
for (var i in items){
if((bottom + items[i].height()) < ($(window).height() - 54)){
items[i].css("top", bottom + 15 + "px").css("left", lastItemLeft + "px").appendTo("#data");
bottom += items[i].height() + 15;
} else {
bottom = 60;
lastItemLeft += 255;
items[i].css("top", bottom + "px").css("left", lastItemLeft + "px").appendTo("#data");
bottom += items[i].height();
}
}
}
//shuffles an array
function shuffle( arr )
{
var pos, tmp;
for( var i = 0; i < arr.length; i++ )
{
pos = Math.round( Math.random() * ( arr.length - 1 ) );
tmp = arr[pos];
arr[pos] = arr[i];
arr[i] = tmp;
}
return arr;
}
//adding a new task to the page //adding a new task to the page
function addTask(expression, result){ function addTask(expression, result){
var lastItem = $(".editContainer:last"), var lastItem = $(".editContainer:last"),
lastItemPos = lastItem.length ? lastItem.position().top : 45, lastItemPos = lastItem.length ? lastItem.position().top : 45,
lastItemHeight = lastItem.length ? lastItem.height() : 0; lastItemHeight = lastItem.length ? lastItem.height() : 0,
var editContent = $("<div class='editContainer'>").width(240).height(70).css("top", lastItemPos + lastItemHeight + 15 + "px").appendTo("#data"); lastItemLeft = lastItem.length ? lastItem.position().left : 54;
var closeItem = $("<div class='closeItem'>").appendTo(editContent); var bottom = lastItemPos + lastItemHeight + 85;
var rightResize = $("<div class='rightResize'>").appendTo(editContent); var editContent = $("<div class='editContainer'>");
var bottomResize = $("<div class='bottomResize'>").appendTo(editContent); $("<div class='closeItem'>").appendTo(editContent);
var main = $("<div class='readyTask'>"); var main = $("<div class='readyTask'>");
var exprContainer = $("<div class='taskContainer' style='color: yellow;' contenteditable='true'>" + expression + "</div>").appendTo(main); $("<div class='taskContainer' style='color: yellow;' contenteditable='true'>" + expression + "</div>").appendTo(main);
var resContainer = $("<div class='taskContainer' style='color: black;' contenteditable='true'>"+ result + "</div>").appendTo(main); $("<div class='taskContainer' style='color: black;' contenteditable='true'>"+ result + "</div>").appendTo(main);
if(bottom < ($(window).height() - 54)){
editContent.css("top", lastItemPos + lastItemHeight + 15 + "px").css("left", lastItemLeft + "px").appendTo("#data");
} else {
lastItemPos = 45;
editContent.css("top", lastItemPos + 15 + "px").css("left", lastItemLeft + 255 + "px").appendTo("#data");
}
main.appendTo(editContent); main.appendTo(editContent);
} }

@ -54,6 +54,8 @@
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "board/UBFeaturesController.h" #include "board/UBFeaturesController.h"
#include "domain/UBGraphicsStrokesGroup.h"
#include "gui/UBFeaturesWidget.h" #include "gui/UBFeaturesWidget.h"
#include "tools/UBToolsManager.h" #include "tools/UBToolsManager.h"
@ -158,7 +160,7 @@ void UBBoardController::setupViews()
mControlLayout = new QHBoxLayout(mControlContainer); mControlLayout = new QHBoxLayout(mControlContainer);
mControlLayout->setContentsMargins(0, 0, 0, 0); mControlLayout->setContentsMargins(0, 0, 0, 0);
mControlView = new UBBoardView(this, mControlContainer); mControlView = new UBBoardView(this, mControlContainer, true);
mControlView->setInteractive(true); mControlView->setInteractive(true);
mControlView->setMouseTracking(true); mControlView->setMouseTracking(true);
@ -536,6 +538,8 @@ void UBBoardController::duplicateItem(UBItem *item)
if (!item) if (!item)
return; return;
mLastCreatedItem = NULL;
QUrl sourceUrl; QUrl sourceUrl;
QByteArray pData; QByteArray pData;
@ -551,9 +555,13 @@ void UBBoardController::duplicateItem(UBItem *item)
itemSize = commonItem->boundingRect().size(); itemSize = commonItem->boundingRect().size();
} }
UBMimeType::Enum itemMimeType;
QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile()); QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile());
if(NULL != qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(commonItem)){
UBMimeType::Enum itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader); itemMimeType = UBMimeType::Group;
}else{
itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader);
}
switch(static_cast<int>(itemMimeType)) switch(static_cast<int>(itemMimeType))
{ {
@ -598,13 +606,37 @@ void UBBoardController::duplicateItem(UBItem *item)
pixitem->pixmap().save(&buffer, format.toLatin1()); pixitem->pixmap().save(&buffer, format.toLatin1());
} }
}break; }break;
case UBMimeType::Group:
{
UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if(groupItem){
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);
}
}
}
groupItem->setSelected(false);
UBApplication::mainWindow->actionGroupItems->trigger();
}
return;
break;
}
case UBMimeType::UNKNOWN: case UBMimeType::UNKNOWN:
{ {
QGraphicsItem *gitem = dynamic_cast<QGraphicsItem*>(item->deepCopy()); QGraphicsItem *gitem = dynamic_cast<QGraphicsItem*>(item->deepCopy());
if (gitem) if (gitem)
{ {
qDebug() << "Adding a stroke: " << gitem;
mActiveScene->addItem(gitem); mActiveScene->addItem(gitem);
gitem->setPos(itemPos); gitem->setPos(itemPos);
mLastCreatedItem = gitem;
} }
return; return;
}break; }break;
@ -619,12 +651,13 @@ void UBBoardController::duplicateItem(UBItem *item)
QGraphicsItem *createdGitem = dynamic_cast<QGraphicsItem*>(createdItem); QGraphicsItem *createdGitem = dynamic_cast<QGraphicsItem*>(createdItem);
if (createdGitem) if (createdGitem)
createdGitem->setPos(itemPos); createdGitem->setPos(itemPos);
mLastCreatedItem = dynamic_cast<QGraphicsItem*>(createdItem);
} }
} }
void UBBoardController::deleteScene(int nIndex) void UBBoardController::deleteScene(int nIndex)
{ {
if (selectedDocument()->pageCount()>2) if (selectedDocument()->pageCount()>=2)
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene(); persistCurrentScene();
@ -1466,14 +1499,15 @@ void UBBoardController::ClearUndoStack()
while (itUniq.hasNext()) while (itUniq.hasNext())
{ {
QGraphicsItem* item = itUniq.next(); QGraphicsItem* item = itUniq.next();
UBGraphicsScene *scene = NULL;
if (item->scene()) { if (item->scene()) {
UBGraphicsScene *scene = dynamic_cast<UBGraphicsScene*>(item->scene()); scene = dynamic_cast<UBGraphicsScene*>(item->scene());
}
if(!scene) if(!scene)
{ {
mActiveScene->deleteItem(item); mActiveScene->deleteItem(item);
} }
} }
}
} }

@ -279,6 +279,7 @@ class UBBoardController : public UBDocumentContainer
bool mCleanupDone; bool mCleanupDone;
QMap<QAction*, QPair<QString, QString> > mActionTexts; QMap<QAction*, QPair<QString, QString> > mActionTexts;
bool mCacheWidgetIsEnabled; bool mCacheWidgetIsEnabled;
QGraphicsItem* mLastCreatedItem;
private slots: private slots:
void stylusToolDoubleClicked(int tool); void stylusToolDoubleClicked(int tool);

@ -62,7 +62,7 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent) UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent, bool pIsControl)
: QGraphicsView (pParent) : QGraphicsView (pParent)
, mController (pController) , mController (pController)
, mIsCreatingTextZone (false) , mIsCreatingTextZone (false)
@ -72,6 +72,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
, mLongPressInterval(1000) , mLongPressInterval(1000)
, mIsDragInProgress(false) , mIsDragInProgress(false)
, mMultipleSelectionIsEnabled(false) , mMultipleSelectionIsEnabled(false)
, isControl(pIsControl)
{ {
init (); init ();
@ -81,13 +82,14 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
mLongPressTimer.setSingleShot(true); mLongPressTimer.setSingleShot(true);
} }
UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent) UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent, bool pIscontrol)
: QGraphicsView (pParent) : QGraphicsView (pParent)
, mController (pController) , mController (pController)
, suspendedMousePressEvent(NULL) , suspendedMousePressEvent(NULL)
, mLongPressInterval(1000) , mLongPressInterval(1000)
, mIsDragInProgress(false) , mIsDragInProgress(false)
, mMultipleSelectionIsEnabled(false) , mMultipleSelectionIsEnabled(false)
, isControl(pIscontrol)
{ {
init (); init ();
@ -124,6 +126,8 @@ void UBBoardView::init ()
setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
setAcceptDrops (true); setAcceptDrops (true);
setOptimizationFlag (QGraphicsView::IndirectPainting); // enable UBBoardView::drawItems filter
mTabletStylusIsPressed = false; mTabletStylusIsPressed = false;
mMouseButtonIsPressed = false; mMouseButtonIsPressed = false;
mPendingStylusReleaseEvent = false; mPendingStylusReleaseEvent = false;
@ -532,11 +536,11 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
if (movingItem->data(UBGraphicsItemData::ItemLocked).toBool()) if (movingItem->data(UBGraphicsItemData::ItemLocked).toBool())
return false; return false;
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); if (movingItem->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type() && !movingItem->isSelected() && movingItem->parentItem()->isSelected())
if (movingItem->parentItem() && !movingItem->isSelected() && movingItem->parentItem()->isSelected())
return false; return false;
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
switch(item->type()) switch(item->type())
{ {
case UBGraphicsGroupContainerItem::Type: case UBGraphicsGroupContainerItem::Type:
@ -557,6 +561,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
case UBGraphicsTextItem::Type: case UBGraphicsTextItem::Type:
return !item->isSelected(); return !item->isSelected();
} }
return false; return false;
} }
@ -566,24 +571,33 @@ QGraphicsItem* UBBoardView::determineItemToMove(QGraphicsItem *item)
if(item) if(item)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
//W3C widgets should take mouse move events from play tool.
if ((UBStylusTool::Play == currentTool) && (UBGraphicsW3CWidgetItem::Type == item->type())) if ((UBStylusTool::Play == currentTool) && (UBGraphicsW3CWidgetItem::Type == item->type()))
return item; return item;
// if item is in group
if(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()) if(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())
{ {
// play tool should move groups by any element
if (UBStylusTool::Play == currentTool && item->parentItem()->isSelected()) if (UBStylusTool::Play == currentTool && item->parentItem()->isSelected())
return item->parentItem(); return item->parentItem();
// groups should should be moved instead of strokes groups
if (UBGraphicsStrokesGroup::Type == item->type())
return item->parentItem();
// selected groups should be moved by moving any element
if (item->parentItem()->isSelected()) if (item->parentItem()->isSelected())
return item; return item;
if (item->isSelected()) if (item->isSelected())
return NULL; return NULL;
return item->parentItem(); return item->parentItem();
} }
// items like polygons placed in two groups nested, so we need to recursive call.
if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type()) if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type())
return determineItemToMove(item->parentItem()); return determineItemToMove(item->parentItem());
} }
@ -595,14 +609,20 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
{ {
mLastPressedMousePos = mapToScene(event->pos()); mLastPressedMousePos = mapToScene(event->pos());
// Determining item who will take mouse press event
//all other items will be deselected and if all item will be deselected, then
// wrong item can catch mouse press. because selected items placed on the top
QGraphicsItem *pressedItem = determineItemToMove(movingItem);
if (movingItem && QGraphicsSvgItem::Type != movingItem->type() if (movingItem
&& !(movingItem->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type())
&& QGraphicsSvgItem::Type != movingItem->type()
&& UBGraphicsDelegateFrame::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type()
&& !mMultipleSelectionIsEnabled) && !mMultipleSelectionIsEnabled)
{ {
foreach(QGraphicsItem *item, scene()->selectedItems()) foreach(QGraphicsItem *item, scene()->selectedItems())
{ {
if (item != movingItem) if (item != pressedItem)
{ {
item->setSelected(false); item->setSelected(false);
} }
@ -634,9 +654,10 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
void UBBoardView::handleItemMouseMove(QMouseEvent *event) void UBBoardView::handleItemMouseMove(QMouseEvent *event)
{ {
if (movingItem) // determine item to move (maybee we need to move group of item or his parent.
movingItem = determineItemToMove(movingItem); movingItem = determineItemToMove(movingItem);
// items should be moved not every mouse move.
if (movingItem && itemShouldBeMoved(movingItem) && (mMouseButtonIsPressed || mTabletStylusIsPressed)) if (movingItem && itemShouldBeMoved(movingItem) && (mMouseButtonIsPressed || mTabletStylusIsPressed))
{ {
QPointF scenePos = mapToScene(event->pos()); QPointF scenePos = mapToScene(event->pos());
@ -662,6 +683,8 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event)
mWidgetMoved = ((posAfterMove-posBeforeMove).manhattanLength() != 0); mWidgetMoved = ((posAfterMove-posBeforeMove).manhattanLength() != 0);
// a cludge for terminate moving of w3c widgets. // a cludge for terminate moving of w3c widgets.
// in some cases w3c widgets catches mouse move and doesn't sends that events to web page,
// at simple - in google map widget - mouse move events doesn't comes to web page from rectangle of wearch bar on bottom right corner of widget.
if (mWidgetMoved && UBGraphicsW3CWidgetItem::Type == movingItem->type()) if (mWidgetMoved && UBGraphicsW3CWidgetItem::Type == movingItem->type())
movingItem->setPos(posBeforeMove); movingItem->setPos(posBeforeMove);
@ -729,6 +752,11 @@ void UBBoardView::longPressEvent()
void UBBoardView::mousePressEvent (QMouseEvent *event) void UBBoardView::mousePressEvent (QMouseEvent *event)
{ {
if (!isControl) {
event->ignore();
return;
}
mIsDragInProgress = false; mIsDragInProgress = false;
if (isAbsurdPoint (event->pos ())) if (isAbsurdPoint (event->pos ()))
@ -990,7 +1018,8 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
if (QGraphicsSvgItem::Type != movingItem->type() && if (QGraphicsSvgItem::Type != movingItem->type() &&
UBGraphicsDelegateFrame::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type() &&
UBToolWidget::Type != movingItem->type() && UBToolWidget::Type != movingItem->type() &&
QGraphicsWidget::Type != movingItem->type()) QGraphicsWidget::Type != movingItem->type() &&
!(movingItem->parentItem() && UBGraphicsW3CWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()))
{ {
bReleaseIsNeed = false; bReleaseIsNeed = false;
if (movingItem->isSelected() && mMultipleSelectionIsEnabled) if (movingItem->isSelected() && mMultipleSelectionIsEnabled)
@ -1405,3 +1434,13 @@ UBBoardView::setToolCursor (int tool)
controlViewport->setCursor (UBResources::resources ()->penCursor); controlViewport->setCursor (UBResources::resources ()->penCursor);
} }
} }
bool UBBoardView::hasSelectedParents(QGraphicsItem * item)
{
if (item->isSelected())
return true;
if (item->parentItem()==NULL)
return false;
return hasSelectedParents(item->parentItem());
}

@ -31,8 +31,8 @@ class UBBoardView : public QGraphicsView
public: public:
UBBoardView(UBBoardController* pController, QWidget* pParent = 0); UBBoardView(UBBoardController* pController, QWidget* pParent = 0, bool pIsControl = false);
UBBoardView(UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent = 0); UBBoardView(UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent = 0, bool pIscontrol = false);
virtual ~UBBoardView(); virtual ~UBBoardView();
UBGraphicsScene* scene(); UBGraphicsScene* scene();
@ -147,6 +147,9 @@ class UBBoardView : public QGraphicsView
bool mIsDragInProgress; bool mIsDragInProgress;
bool mMultipleSelectionIsEnabled; bool mMultipleSelectionIsEnabled;
bool isControl;
static bool hasSelectedParents(QGraphicsItem * item);
private slots: private slots:

@ -33,6 +33,7 @@ struct UBMimeType
Flash, Flash,
PDF, PDF,
UniboardTool, UniboardTool,
Group,
UNKNOWN UNKNOWN
}; };
}; };

@ -57,9 +57,7 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent)
mShowHideAction->setCheckable(true); mShowHideAction->setCheckable(true);
connect(mShowHideAction, SIGNAL(triggered(bool)), this, SLOT(showHideClick(bool))); connect(mShowHideAction, SIGNAL(triggered(bool)), this, SLOT(showHideClick(bool)));
#ifndef Q_WS_X11
actions << mShowHideAction; actions << mShowHideAction;
#endif
setActions(actions); setActions(actions);
setButtonIconSize(QSize(42, 42)); setButtonIconSize(QSize(42, 42));

@ -32,7 +32,8 @@ class UBAbstractUndoCommand : public QUndoCommand
undotype_GRAPHICITEMTRANSFORM = 2, undotype_GRAPHICITEMTRANSFORM = 2,
undotype_GRAPHICITEM = 3, undotype_GRAPHICITEM = 3,
undotype_GRAPHICTEXTITEM = 4, undotype_GRAPHICTEXTITEM = 4,
undotype_PAGESIZE = 5 undotype_PAGESIZE = 5,
undotype_GRAPHICSGROUPITEM = 6
}; };
virtual UndoType getType() { return undotype_UNKNOWN; } virtual UndoType getType() { return undotype_UNKNOWN; }

@ -228,6 +228,9 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mCurrentTool = toolFromPos(event->pos()); mCurrentTool = toolFromPos(event->pos());
setCursorFromAngle(QString("")); setCursorFromAngle(QString(""));
event->accept(); event->accept();
prepareFramesToMove(getLinkedFrames());
} }
void UBGraphicsDelegateFrame::setCursorFromAngle(QString angle) void UBGraphicsDelegateFrame::setCursorFromAngle(QString angle)
@ -469,33 +472,25 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
mTranslateX = move.dx(); mTranslateX = move.dx();
mTranslateY = move.dy(); mTranslateY = move.dy();
moveLinkedItems(move);
} }
QTransform tr = buildTransform(); QTransform tr = buildTransform();
//TODO UB 4.x: Could find a better solution ?
if (resizingRight() || resizingBottom() || resizingBottomRight()) if (resizingRight() || resizingBottom() || resizingBottomRight())
{ {
QPointF ref; QPointF ref;
if(!mMirrorX && !mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(mMirrorX && !mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(!mMirrorX && mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(mMirrorX && mMirrorY){
ref = delegated()->boundingRect().topRight();
}
// Map the item topleft point to the current mouse move transform // we just detects coordinates of corner before and after scaling and then moves object at diff between them.
QPointF topLeft = tr.map(ref); if (resizingBottomRight() && mMirrorX)
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x();
// Map the item topleft point to the mouse press transform else
QPointF fixedPoint = mInitialTransform.map(ref); mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x();
// Update the translation coordinates if (resizingBottomRight() && mMirrorY)
mTranslateX += fixedPoint.x() - topLeft.x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y();
mTranslateY += fixedPoint.y() - topLeft.y(); else
mTranslateY += mInitialTransform.map(delegated()->boundingRect().topLeft()).y() - tr.map(delegated()->boundingRect().topLeft()).y();
// Update the transform // Update the transform
tr = buildTransform(); tr = buildTransform();
@ -534,6 +529,71 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->accept(); event->accept();
} }
QList<UBGraphicsDelegateFrame *> UBGraphicsDelegateFrame::getLinkedFrames()
{
QList<UBGraphicsDelegateFrame*> linkedFrames;
QList<QGraphicsItem*> sItems = mDelegate->delegated()->scene()->selectedItems();
if (sItems.count())
{
sItems.removeAll(delegated());
foreach(QGraphicsItem *item, sItems)
{
UBGraphicsItem *gitem = dynamic_cast<UBGraphicsItem*>(item);
if (gitem)
linkedFrames << gitem->Delegate()->frame();
}
}
return linkedFrames;
}
void UBGraphicsDelegateFrame::prepareFramesToMove(QList<UBGraphicsDelegateFrame *> framesToMove)
{
mLinkedFrames = framesToMove;
foreach (UBGraphicsDelegateFrame *frame, mLinkedFrames)
{
frame->prepareLinkedFrameToMove();
}
}
void UBGraphicsDelegateFrame::prepareLinkedFrameToMove()
{
mDelegate->startUndoStep();
mStartingPoint = QPointF(0,0);
initializeTransform();
mScaleX = 1;
mScaleY = 1;
mTranslateX = 0;
mTranslateY = 0;
mAngleOffset = 0;
mInitialTransform = buildTransform();
mCurrentTool = Move;
}
void UBGraphicsDelegateFrame::moveLinkedItems(QLineF movingVector, bool bLinked)
{
if (bLinked)
{
mCurrentTool = Move;
mTranslateX = movingVector.dx();
mTranslateY = movingVector.dy();
delegated()->setTransform(buildTransform(), false);
}
else
{
foreach(UBGraphicsDelegateFrame* frame, mLinkedFrames)
{
frame->moveLinkedItems(movingVector, true);
}
}
}
QTransform UBGraphicsDelegateFrame::buildTransform() QTransform UBGraphicsDelegateFrame::buildTransform()
{ {

@ -48,6 +48,10 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
enum OperationMode {Scaling, Resizing, ResizingHorizontally}; enum OperationMode {Scaling, Resizing, ResizingHorizontally};
void setOperationMode(OperationMode pMode) {mOperationMode = pMode;} void setOperationMode(OperationMode pMode) {mOperationMode = pMode;}
bool isResizing(){return mResizing;} bool isResizing(){return mResizing;}
void moveLinkedItems(QLineF movingVector, bool bLinked = false);
void prepareFramesToMove(QList<UBGraphicsDelegateFrame *> framesToMove);
void prepareLinkedFrameToMove();
QList<UBGraphicsDelegateFrame *> getLinkedFrames();
private: private:
QRectF bottomRightResizeGripRect() const; QRectF bottomRightResizeGripRect() const;
@ -120,5 +124,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
bool mResizing; bool mResizing;
bool mMirroredXAtStart; bool mMirroredXAtStart;
bool mMirroredYAtStart; bool mMirroredYAtStart;
QList<UBGraphicsDelegateFrame *> mLinkedFrames;
}; };
#endif /* UBGRAPHICSDELEGATEFRAME_H_ */ #endif /* UBGRAPHICSDELEGATEFRAME_H_ */

@ -32,6 +32,16 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
} }
UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem()
{
foreach (QGraphicsItem *item, childItems())
{
removeFromGroup(item);
if (item && item->scene())
item->scene()->removeItem(item);
}
}
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
{ {
if (!item) { if (!item) {

@ -10,6 +10,7 @@ class UBGraphicsGroupContainerItem : public QGraphicsItem, public UBItem, public
public: public:
UBGraphicsGroupContainerItem (QGraphicsItem *parent = 0); UBGraphicsGroupContainerItem (QGraphicsItem *parent = 0);
virtual ~UBGraphicsGroupContainerItem();
void addToGroup(QGraphicsItem *item); void addToGroup(QGraphicsItem *item);
void removeFromGroup(QGraphicsItem *item); void removeFromGroup(QGraphicsItem *item);

@ -19,6 +19,7 @@ UBGraphicsGroupContainerItemDelegate::UBGraphicsGroupContainerItemDelegate(QGrap
//Wrapper function. Use it to set correct data() to QGraphicsItem as well //Wrapper function. Use it to set correct data() to QGraphicsItem as well
setFlippable(false); setFlippable(false);
setRotatable(false); setRotatable(false);
setCanDuplicate(true);
} }
UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItemDelegate::delegated() UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItemDelegate::delegated()

@ -195,10 +195,10 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
if ((change == QGraphicsItem::ItemSelectedHasChanged if ((change == QGraphicsItem::ItemSelectedHasChanged
|| change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemPositionHasChanged
|| change == QGraphicsItem::ItemTransformHasChanged) || change == QGraphicsItem::ItemTransformHasChanged)
&& mDelegated->scene()) && mDelegated->scene()
&& UBApplication::boardController)
{ {
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
positionHandles(); positionHandles();
} }
@ -471,18 +471,18 @@ void UBGraphicsItemDelegate::lock(bool locked)
mFrame->positionHandles(); mFrame->positionHandles();
} }
void UBGraphicsItemDelegate::showHideRecurs(const QVariant &pShow, QGraphicsItem *pItem)
void UBGraphicsItemDelegate::showHide(bool show)
{
if (show)
{ {
mDelegated->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Object)); pItem->setData(UBGraphicsItemData::ItemLayerType, pShow);
foreach (QGraphicsItem *insideItem, pItem->childItems()) {
showHideRecurs(pShow, insideItem);
} }
else
{
mDelegated->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
} }
void UBGraphicsItemDelegate::showHide(bool show)
{
QVariant showFlag = QVariant(show ? UBItemLayerType::Object : UBItemLayerType::Control);
showHideRecurs(showFlag, mDelegated);
mDelegated->update(); mDelegated->update();
emit showOnDisplayChanged(show); emit showOnDisplayChanged(show);

@ -297,6 +297,7 @@ protected slots:
private: private:
void updateFrame(); void updateFrame();
void updateButtons(bool showUpdated = false); void updateButtons(bool showUpdated = false);
inline void showHideRecurs(const QVariant &pShow, QGraphicsItem *pItem);
QPointF mOffset; QPointF mOffset;
QTransform mPreviousTransform; QTransform mPreviousTransform;

@ -0,0 +1,58 @@
#include "UBGraphicsItemGroupUndoCommand.h"
#include "UBGraphicsGroupContainerItem.h"
#include "UBGraphicsScene.h"
#include "core/memcheck.h"
UBGraphicsItemGroupUndoCommand::UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated) :
mScene (pScene), mGroup(pGroupCreated), mFirstRedo(true)
{
if (pGroupCreated->childItems().count()) {
foreach (QGraphicsItem *item, pGroupCreated->childItems()) {
mItems << item;
}
}
}
UBGraphicsItemGroupUndoCommand::~UBGraphicsItemGroupUndoCommand()
{
}
void UBGraphicsItemGroupUndoCommand::undo()
{
mGroup->destroy();
foreach(QGraphicsItem *item, mItems) {
item->setSelected(true);
}
}
void UBGraphicsItemGroupUndoCommand::redo()
{
if (mFirstRedo) {
//Work around. TODO determine why does Qt call the redo function on pushing to undo
mFirstRedo = false;
return;
}
foreach (QGraphicsItem *item, mItems) {
if (item->type() == UBGraphicsGroupContainerItem::Type) {
QList<QGraphicsItem*> childItems = item->childItems();
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if (currentGroup) {
currentGroup->destroy();
}
foreach (QGraphicsItem *chItem, childItems) {
mGroup->addToGroup(chItem);
}
} else {
mGroup->addToGroup(item);
}
}
mScene->addItem(mGroup);
mGroup->setVisible(true);
mGroup->setFocus();
mGroup->setSelected(true);
}

@ -0,0 +1,30 @@
#ifndef UBGRAPHICSITEMGROUPUNDOCOMMAND_H
#define UBGRAPHICSITEMGROUPUNDOCOMMAND_H
#include <QList>
#include "UBAbstractUndoCommand.h"
class UBGraphicsScene;
class UBGraphicsGroupContainerItem;
class UBGraphicsItemGroupUndoCommand : public UBAbstractUndoCommand
{
public:
UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated);
virtual ~UBGraphicsItemGroupUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICSGROUPITEM; }
protected:
virtual void undo();
virtual void redo();
private:
UBGraphicsScene *mScene;
UBGraphicsGroupContainerItem *mGroup;
QList<QGraphicsItem*> mItems;
bool mFirstRedo;
};
#endif // UBGRAPHICSITEMGROUPUNDOCOMMAND_H

@ -32,7 +32,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand
const QSizeF& prevSize = QSizeF()); const QSizeF& prevSize = QSizeF());
virtual ~UBGraphicsItemTransformUndoCommand(); virtual ~UBGraphicsItemTransformUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICITEMTRANSFORM; }; virtual UndoType getType() { return undotype_GRAPHICITEMTRANSFORM; }
protected: protected:
virtual void undo(); virtual void undo();

@ -24,6 +24,7 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
#include "domain/UBGraphicsGroupContainerItem.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems) const QSet<QGraphicsItem*>& pAddedItems)
@ -81,6 +82,14 @@ void UBGraphicsItemUndoCommand::undo()
{ {
QGraphicsItem* item = itAdded.next(); QGraphicsItem* item = itAdded.next();
//if removing group
if (item->type() == UBGraphicsGroupContainerItem::Type) {
UBGraphicsGroupContainerItem *curGroup = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item);
if (curGroup) {
curGroup->destroy();
}
}
UBApplication::boardController->freezeW3CWidget(item, true); UBApplication::boardController->freezeW3CWidget(item, true);
item->setSelected(false); item->setSelected(false);
mScene->removeItem(item); mScene->removeItem(item);

@ -34,10 +34,10 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
virtual ~UBGraphicsItemUndoCommand(); virtual ~UBGraphicsItemUndoCommand();
QSet<QGraphicsItem*> GetAddedList() { return mAddedItems; }; QSet<QGraphicsItem*> GetAddedList() { return mAddedItems; }
QSet<QGraphicsItem*> GetRemovedList() { return mRemovedItems; }; QSet<QGraphicsItem*> GetRemovedList() { return mRemovedItems; }
virtual UndoType getType() { return undotype_GRAPHICITEM; }; virtual UndoType getType() { return undotype_GRAPHICITEM; }
protected: protected:
virtual void undo(); virtual void undo();

@ -154,7 +154,12 @@ UBItem* UBGraphicsPolygonItem::deepCopy() const
UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) const UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) const
{ {
UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(pol); QPolygonF p(pol);
if (parentItem()!=NULL)
{
p = mapToItem(parentItem(), p);
}
UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(p, parentItem());
copyItemParameters(copy); copyItemParameters(copy);

@ -20,6 +20,7 @@
#include "core/UB.h" #include "core/UB.h"
#include "UBItem.h" #include "UBItem.h"
#include "UBGraphicsStrokesGroup.h" #include "UBGraphicsStrokesGroup.h"
#include "domain/UBGraphicsGroupContainerItem.h"
class UBItem; class UBItem;
class UBGraphicsScene; class UBGraphicsScene;

@ -47,6 +47,7 @@
#include "board/UBBoardView.h" #include "board/UBBoardView.h"
#include "UBGraphicsItemUndoCommand.h" #include "UBGraphicsItemUndoCommand.h"
#include "UBGraphicsItemGroupUndoCommand.h"
#include "UBGraphicsTextItemUndoCommand.h" #include "UBGraphicsTextItemUndoCommand.h"
#include "UBGraphicsProxyWidget.h" #include "UBGraphicsProxyWidget.h"
#include "UBGraphicsPixmapItem.h" #include "UBGraphicsPixmapItem.h"
@ -843,8 +844,11 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
// UBGraphicsPolygonItems and added to the scene // UBGraphicsPolygonItems and added to the scene
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons()) foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons())
{ {
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol); UBGraphicsPolygonItem* croppedPolygonItem;
#pragma omp critical #pragma omp critical
{
croppedPolygonItem = collidingPolygonItem->deepCopy(pol);
if(NULL != pGroup){ if(NULL != pGroup){
croppedPolygonItem->setStrokesGroup(pGroup); croppedPolygonItem->setStrokesGroup(pGroup);
//pGroup->addToGroup(croppedPolygonItem); //pGroup->addToGroup(croppedPolygonItem);
@ -852,6 +856,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
// Add this new polygon to the 'added' list // Add this new polygon to the 'added' list
toBeAddedItems << croppedPolygonItem; toBeAddedItems << croppedPolygonItem;
} }
}
#pragma omp critical #pragma omp critical
// Remove the original polygonitem because it has been replaced by many smaller polygons // Remove the original polygonitem because it has been replaced by many smaller polygons
toBeRemovedItems << collidingPolygonItem; toBeRemovedItems << collidingPolygonItem;
@ -1521,7 +1526,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
groupItem->setFocus(); groupItem->setFocus();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, groupItem); UBGraphicsItemGroupUndoCommand* uc = new UBGraphicsItemGroupUndoCommand(this, groupItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }

@ -115,3 +115,23 @@ QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVa
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = mDelegate->itemChange(change, value);
return QGraphicsItemGroup::itemChange(change, newValue); return QGraphicsItemGroup::itemChange(change, newValue);
} }
QPainterPath UBGraphicsStrokesGroup::shape () const
{
QPainterPath path;
if (isSelected())
{
path.addRect(boundingRect());
}
else
{
foreach(QGraphicsItem* item, childItems())
{
path.addPath(item->shape());
}
}
return path;
}

@ -25,6 +25,9 @@ public:
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
protected: protected:
virtual QPainterPath shape () const;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

@ -1,4 +1,3 @@
HEADERS += src/domain/UBGraphicsScene.h \ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsItemUndoCommand.h \ src/domain/UBGraphicsItemUndoCommand.h \
src/domain/UBGraphicsTextItemUndoCommand.h \ src/domain/UBGraphicsTextItemUndoCommand.h \
@ -20,15 +19,14 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBAbstractUndoCommand.h \ src/domain/UBAbstractUndoCommand.h \
src/domain/UBGraphicsGroupContainerItem.h \ src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \ src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsStrokesGroup.h src/domain/UBGraphicsStrokesGroup.h \
src/domain/UBGraphicsItemGroupUndoCommand.h \
HEADERS += src/domain/UBGraphicsItemDelegate.h \ src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \ src/domain/UBGraphicsTextItemDelegate.h \
src/domain/UBGraphicsDelegateFrame.h \ src/domain/UBGraphicsDelegateFrame.h \
src/domain/UBGraphicsWidgetItemDelegate.h \ src/domain/UBGraphicsWidgetItemDelegate.h \
src/domain/UBGraphicsMediaItemDelegate.h src/domain/UBGraphicsMediaItemDelegate.h
SOURCES += src/domain/UBGraphicsScene.cpp \ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsItemUndoCommand.cpp \ src/domain/UBGraphicsItemUndoCommand.cpp \
src/domain/UBGraphicsTextItemUndoCommand.cpp \ src/domain/UBGraphicsTextItemUndoCommand.cpp \
@ -51,11 +49,10 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBAbstractUndoCommand.cpp \ src/domain/UBAbstractUndoCommand.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \ src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp src/domain/UBGraphicsStrokesGroup.cpp \
src/domain/UBGraphicsItemGroupUndoCommand.cpp \
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \ src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsTextItemDelegate.cpp \ src/domain/UBGraphicsTextItemDelegate.cpp \
src/domain/UBGraphicsMediaItemDelegate.cpp \ src/domain/UBGraphicsMediaItemDelegate.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \ src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsWidgetItemDelegate.cpp \ src/domain/UBGraphicsWidgetItemDelegate.cpp

@ -379,6 +379,12 @@ void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event )
event->ignore(); event->ignore();
return; return;
} }
foreach (UBFeature curFeature, fMimeData->features()) {
if (curFeature == onFeature) {
event->ignore();
return;
}
}
} }
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() ) { if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() ) {

@ -879,17 +879,21 @@ void UBTeacherGuidePageZeroWidget::fillComboBoxes()
parametersFile.close(); parametersFile.close();
QStringList licences; QStringList licences;
licences << tr("Attribution CC BY") << tr("Attribution-NoDerivs CC BY-ND") licences << tr("Attribution CC BY")
<< tr("Attribution-NoDerivs CC BY-ND")
<< tr("Attribution-ShareAlike CC BY-SA") << tr("Attribution-ShareAlike CC BY-SA")
<< tr("Attribution-NonCommercial CC BY-NC") << tr("Attribution-NonCommercial CC BY-NC")
<< tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND") << tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND")
<< tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA") << tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA")
<< tr("Public domain") << tr("Copyright"); << tr("Public domain")
<< tr("Copyright");
mpLicenceBox->addItems(licences); mpLicenceBox->addItems(licences);
QStringList licenceIconList; QStringList licenceIconList;
licenceIconList << ":images/licenses/ccby.png" licenceIconList << ":images/licenses/ccby.png"
<< ":images/licenses/ccbynd.png" << ":images/licenses/ccbysa.png" << ":images/licenses/ccbynd.png"
<< ":images/licenses/ccbync.png" << ":images/licenses/ccbyncnd.png" << ":images/licenses/ccbysa.png"
<< ":images/licenses/ccbync.png"
<< ":images/licenses/ccbyncnd.png"
<< ":images/licenses/ccbyncsa.png"; << ":images/licenses/ccbyncsa.png";
for (int i = 0; i < licenceIconList.count(); i += 1) for (int i = 0; i < licenceIconList.count(); i += 1)
mpLicenceBox->setItemData(i, licenceIconList.at(i)); mpLicenceBox->setItemData(i, licenceIconList.at(i));
@ -945,7 +949,7 @@ void UBTeacherGuidePageZeroWidget::loadData()
currentIndex = mpSchoolTypeBox->findText(documentProxy->metaData(UBSettings::sessionType).toString()); currentIndex = mpSchoolTypeBox->findText(documentProxy->metaData(UBSettings::sessionType).toString());
mpSchoolTypeBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); mpSchoolTypeBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0);
currentIndex = mpLicenceBox->findText(documentProxy->metaData(UBSettings::sessionLicence).toString()); currentIndex = documentProxy->metaData(UBSettings::sessionLicence).toInt();
mpLicenceBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); mpLicenceBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0);
} }
@ -962,7 +966,7 @@ void UBTeacherGuidePageZeroWidget::persistData()
documentProxy->setMetaData(UBSettings::sessionGradeLevel, mpSchoolLevelBox->currentText()); documentProxy->setMetaData(UBSettings::sessionGradeLevel, mpSchoolLevelBox->currentText());
documentProxy->setMetaData(UBSettings::sessionSubjects, mpSchoolSubjectsBox->currentText()); documentProxy->setMetaData(UBSettings::sessionSubjects, mpSchoolSubjectsBox->currentText());
documentProxy->setMetaData(UBSettings::sessionType, mpSchoolTypeBox->currentText()); documentProxy->setMetaData(UBSettings::sessionType, mpSchoolTypeBox->currentText());
documentProxy->setMetaData(UBSettings::sessionLicence, mpLicenceBox->currentText()); documentProxy->setMetaData(UBSettings::sessionLicence, mpLicenceBox->currentIndex());
} }
} }
@ -1087,7 +1091,7 @@ QVector<tUBGEElementNode*> UBTeacherGuidePageZeroWidget::getData()
elementNode = new tUBGEElementNode(); elementNode = new tUBGEElementNode();
elementNode->name = "licence"; elementNode->name = "licence";
elementNode->attributes.insert("value", mpLicenceBox->currentText()); elementNode->attributes.insert("value", QString("%1").arg(mpLicenceBox->currentIndex()));
result << elementNode; result << elementNode;
return result; return result;
} }

Loading…
Cancel
Save