diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index bdc7704c..e17a120a 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -35,6 +35,7 @@ QT += script QT += xmlpatterns INCLUDEPATH += src +INCLUDEPATH += globals include($$THIRD_PARTY_PATH/libs.pri) include(src/adaptors/adaptors.pri) @@ -83,6 +84,7 @@ UB_LIBRARY.files = resources/library UB_FONTS.files = resources/fonts UB_THIRDPARTY_INTERACTIVE.files = thirdparty/interactive +DEFINES += NO_THIRD_PARTY_WARNINGS DEFINES += UBVERSION=\"\\\"$${LONG_VERSION}\"\\\" \ UBVERSION_RC=$$VERSION_RC ALPHA_BETA_STR = $$find(VERSION, "[ab]") diff --git a/buildDebianPackage b/buildDebianPackage index 9eb6010e..7056a1d7 100755 --- a/buildDebianPackage +++ b/buildDebianPackage @@ -49,8 +49,8 @@ else LAST_COMMITED_VERSION="`git describe $(git rev-list --tags --max-count=1)`" if [ "v$VERSION" != "$LAST_COMMITED_VERSION" ]; then echo creating a tag with the version $VERSION - git tag -a "v$VERSION" -m "Generating setup for v$VERSION" - git push origin --tags +# git tag -a "v$VERSION" -m "Generating setup for v$VERSION" +# git push origin --tags fi fi @@ -191,7 +191,7 @@ CHANGE_LOG_FILE="$BASE_WORKING_DIR/DEBIAN/changelog-sankore-$VERSION.txt" CONTROL_FILE="$BASE_WORKING_DIR/DEBIAN/control" CHANGE_LOG_TEXT="changelog.txt" -ARCHITECTURE=`uname -i` +ARCHITECTURE=`uname -m` if [ "$ARCHITECTURE" == "x86_64" ]; then ARCHITECTURE="amd64" fi diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/css/basic.css b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/css/basic.css index 476eeb71..dc78a0d9 100644 --- a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/css/basic.css +++ b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/css/basic.css @@ -3,6 +3,7 @@ html, body{ height: 100%; margin: 0; padding: 0; + background-color: white; } .toggle_mode{ @@ -122,29 +123,35 @@ html, body{ background-color: white; } -.close_img{ +.close_img, .clear_img, .numb_img { width: 30px; - height: 30px; - background-image: url(../img/close_img.png); + height: 30px; background-repeat: no-repeat; - position: absolute; - top: -15px; + position: absolute; right: -15px; cursor: pointer; } +.close_img{ + background-image: url(../img/close_img.png); + top: -15px; +} + .clear_img{ - width: 30px; - height: 30px; background-image: url(../img/clear_img.png); - background-repeat: no-repeat; - position: absolute; top: 15px; - right: -15px; - cursor: pointer; } -.fill_img{ +.numb_img{ + background-image: url(../img/numb_img.png); + left: -15px; + top: -15px; + color: white; + font-weight: bold; + font-size: 130%; +} + +/*.fill_img{ width: 30px; height: 30px; background-image: url(../img/fill_hor.png); @@ -153,7 +160,9 @@ html, body{ top: -15px; right: 17px; cursor: pointer; -} +}*/ + + .add_block{ margin: 20px 0 0 20px; diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/1.jpg b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/1.jpg deleted file mode 100644 index d3807e82..00000000 Binary files a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/1.jpg and /dev/null differ diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/1.png b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/1.png deleted file mode 100644 index c50733dc..00000000 Binary files a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/1.png and /dev/null differ diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/2.png b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/2.png deleted file mode 100644 index 7ad83b87..00000000 Binary files a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/2.png and /dev/null differ diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/clear_img.png b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/clear_img.png index fbaefffb..b00fca9a 100644 Binary files a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/clear_img.png and b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/clear_img.png differ diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/drop_img.png b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/drop_img.png new file mode 100644 index 00000000..17024f03 Binary files /dev/null and b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/drop_img.png differ diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/numb_img.png b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/numb_img.png new file mode 100644 index 00000000..6a0284c4 Binary files /dev/null and b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/img/numb_img.png differ diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/index.html b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/index.html index 5525abd4..20aaf679 100644 --- a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/index.html +++ b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/index.html @@ -15,10 +15,26 @@ lang = sankore.locale().substr(0,2); } else lang = "en"; - $(" + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/fr/js/script.js b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/fr/js/script.js new file mode 100644 index 00000000..83d61c86 --- /dev/null +++ b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/fr/js/script.js @@ -0,0 +1,392 @@ + +var sankoreLang = {display: "D'affichage", edit: "Modifier", short_desc: "Placez les photos dans l'ordre croissant.", add: "Nouveau bloc"}; + +//main function +function start(){ + + $("#display_text").text(sankoreLang.display); + $("#edit_text").text(sankoreLang.edit); + + if(window.sankore){ + if(sankore.preference("odr_des_imgs","")){ + var data = jQuery.parseJSON(sankore.preference("odr_des_imgs","")); + importData(data); + } else { + showExample(); + } + } + else + showExample(); + + //events + $("body").live("mouseout",function(){ + if(event.target.tagName == "BODY") + if(window.sankore) + exportData(); + }) + + $("#display, #edit").click(function(event){ + if(this.id == "display"){ + if(!$(this).hasClass("selected")){ + $(this).addClass("selected"); + $("#display_img").removeClass("red_point").addClass("green_point"); + $("#edit_img").removeClass("green_point").addClass("red_point"); + $("#edit").removeClass("selected"); + $(".add_block").remove(); + $(".cont").each(function(){ + var container = $(this); + var tmp_i = 0; + var tmp_right = ""; + var tmp_array = []; + + container.find(".text_cont").removeAttr("contenteditable"); + container.find(".add_img").remove(); + container.find(".close_cont").remove(); + container.find(".img_block").each(function(){ + if($(this).find("img").attr("src") != "img/drop_img.png"){ + $(this).find(".close_img").remove(); + $(this).find(".clear_img").remove(); + $(this).find(".numb_img").remove(); + $(this).removeAttr("ondragenter") + .removeAttr("ondragleave") + .removeAttr("ondragover") + .removeAttr("ondrop"); + $(this).find("input").val(++tmp_i) + tmp_right += tmp_i + "*"; + } else + $(this).remove(); + }); + container.find(".imgs_cont>input").val(tmp_right); + + container.find(".img_block").each(function(){ + $(this).css("float",""); + tmp_array.push($(this)); + }); + tmp_array = shuffle(tmp_array); + for(var i = 0; i").appendTo(container); + container.find(".text_cont").attr("contenteditable","true"); + //container.find(".imgs_cont").sortable("destroy"); + container.find(".imgs_cont").css("background-color", "white"); + + var add_img = $("
"); + container.find(".img_block").each(function(){ + $(this).attr("ondragenter", "return false;") + .attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;") + .attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;") + .attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);") + //.css("float","left"); + $("
").appendTo($(this)); + $("
").appendTo($(this)); + $("
" + $(this).find("input").val() + "
").appendTo($(this)); + }); + rightOrder(container.find(".imgs_cont")); + container.find(".imgs_cont").append(add_img) + }); + + $("
" + sankoreLang.add + "
").appendTo("body"); + } + } + }); + + //add new block + $(".add_block").live("click", function(){ + addContainer(); + }); + + //adding new img + $(".add_img").live("click", function(){ + addImgBlock($(this)); + }); + + //deleting a block + $(".close_cont").live("click",function(){ + $(this).parent().remove(); + refreshBlockNumbers(); + }); + + //deleting the img block + $(".close_img").live("click", function(){ + var i = 0; + var tmp_obj = $(this).parent().parent(); + $(this).parent().remove(); + if(tmp_obj.find(".img_block").size() > 0){ + refreshImgNumbers(tmp_obj); + } + + }); + + //cleaning an image + $(".clear_img").live("click",function(){ + //$(this).parent().find(".fill_img").remove(); + $(this).parent().find("img").attr("src","img/drop_img.png"); + }); +} + +//export +function exportData(){ + var array_to_export = []; + if($("#edit").hasClass("selected")){ + $(".cont").each(function(){ + var container = $(this); + var tmp_right = ""; + var tmp_i = 0; + container.find(".img_block").each(function(){ + if($(this).html().match(/input").val(tmp_right); + }); + } + $(".cont").each(function(){ + var cont_obj = new Object(); + cont_obj.text = $(this).find(".text_cont").text(); + cont_obj.right = $(this).find(".imgs_cont>input").val(); + cont_obj.imgs = []; + $(this).find(".img_block").each(function(){ + var img_obj = new Object(); + img_obj.value = $(this).find("input").val(); + img_obj.link = $(this).find("img").attr("src").replace("../../",""); + img_obj.ht = $(this).find("img").height(); + img_obj.wd = $(this).find("img").width(); + cont_obj.imgs.push(img_obj); + }); + array_to_export.push(cont_obj); + }); + sankore.setPreference("odr_des_imgs", JSON.stringify(array_to_export)); +} + +//import +function importData(data){ + + var tmp = 0; + for(var i in data){ + var tmp_array = []; + var container = $("
"); + var sub_container = $("
").appendTo(container); + var imgs_container = $("
").appendTo(container); + + var number = $("
"+ (++tmp) +"
").appendTo(sub_container); + var text = $("
" + data[i].text + "
").appendTo(sub_container); + + $("").appendTo(imgs_container); + + for(var j in data[i].imgs){ + var img_block = $("
"); + var img = $(""); + img.height(data[i].imgs[j].ht).width(data[i].imgs[j].wd); + if((120 - data[i].imgs[j].ht) > 0) + img.css("margin",(120 - data[i].imgs[j].ht)/2 + "px 0"); + var hidden_input = $("").val(data[i].imgs[j].value); + img_block.append(hidden_input).append(img); + tmp_array.push(img_block); + } + tmp_array = shuffle(tmp_array); + for(j = 0; j"); + var sub_container = $("
").appendTo(container); + var imgs_container = $("
").appendTo(container); + + var number = $("
1
").appendTo(sub_container); + var text = $("
" + sankoreLang.short_desc + "
").appendTo(sub_container); + + $("").appendTo(imgs_container); + + var img1 = $("
"); + $("").appendTo(img1); + $("").appendTo(img1); + var img2 = $("
"); + $("").appendTo(img2); + $("").appendTo(img2); + var img3 = $("
"); + $("").appendTo(img3); + $("").appendTo(img3); + var img4 = $("
"); + $("").appendTo(img4); + $("").appendTo(img4); + var img5 = $("
"); + $("").appendTo(img5); + $("").appendTo(img5); + + tmp_array.push(img1, img2, img3, img4, img5); + tmp_array = shuffle(tmp_array); + for(var i = 0; i"); + var sub_container = $("
").appendTo(container); + var imgs_container = $("
").appendTo(container); + + var close = $("
").appendTo(container); + var number = $("
"+ ($(".cont").size() + 1) +"
").appendTo(sub_container); + var text = $("
Enter your text here ...
").appendTo(sub_container); + + $("").appendTo(imgs_container); + var add_img = $("
").appendTo(imgs_container); + container.insertBefore($(".add_block")); +} + +//add new img block +function addImgBlock(dest){ + var img_block = $("
").insertBefore(dest); + var tmp_counter = dest.parent().find(".img_block").size(); + $("
").appendTo(img_block); + $("
").appendTo(img_block); + $("
" + tmp_counter + "
").appendTo(img_block); + $("").appendTo(img_block); + $("").appendTo(img_block); +} + +function refreshBlockNumbers(){ + var i = 0; + $(".cont").each(function(){ + $(this).find(".number_cont").text(++i); + }) +} + +//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; +} + +//regulation the images in right order +function rightOrder(source){ + var tmp_arr = []; + var tmp_var; + source.find(".img_block").each(function(){ + tmp_arr.push($(this)); + $(this).remove(); + }); + for(var i = 0; i < tmp_arr.length; i++) + for(var j = 0; j < tmp_arr.length - 1; j++){ + if(tmp_arr[j].find("input").val() > tmp_arr[j+1].find("input").val()){ + tmp_var = tmp_arr[j]; + tmp_arr[j] = tmp_arr[j+1]; + tmp_arr[j+1] = tmp_var; + } + } + for(i in tmp_arr) + source.append(tmp_arr[i]); +} + +//refresh the numbers of the images +function refreshImgNumbers(source){ + var tmp = 1; + source.find(".img_block").each(function(){ + $(this).find("input").val(tmp); + $(this).find(".numb_img").text(tmp); + tmp++; + }); +} + +function stringToXML(text){ + if (window.ActiveXObject){ + var doc=new ActiveXObject('Microsoft.XMLDOM'); + doc.async='false'; + doc.loadXML(text); + } else { + var parser=new DOMParser(); + doc=parser.parseFromString(text,'text/xml'); + } + return doc; +} + +function onDropTarget(obj, event) { + $(obj).find("img").remove(); + if (event.dataTransfer) { + var format = "text/plain"; + var textData = event.dataTransfer.getData(format); + if (!textData) { + alert(":("); + } + textData = stringToXML(textData); + var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; + tmp = tmp.substr(1, tmp.length); + var tmp_img = $("").attr("src", "../../" + tmp); + $(obj).append(tmp_img); + setTimeout(function(){ + if(tmp_img.height() >= tmp_img.width()) + tmp_img.attr("height", "120"); + else{ + tmp_img.attr("width","120"); + tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0"); + } + }, 6) + } + else { + alert ("Your browser does not support the dataTransfer object."); + } + + if (event.stopPropagation) { + event.stopPropagation (); + } + else { + event.cancelBubble = true; + } + return false; +} + diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/img/drop_img.png b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/img/drop_img.png new file mode 100644 index 00000000..2796c020 Binary files /dev/null and b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/img/drop_img.png differ diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/index.html b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/index.html new file mode 100644 index 00000000..9388cd2f --- /dev/null +++ b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/index.html @@ -0,0 +1,45 @@ + + + + D'n'd + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + diff --git a/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/js/script.js b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/js/script.js new file mode 100644 index 00000000..ae10471c --- /dev/null +++ b/resources/library/sankoreInteractivities/ordonner_des_images.wgt/locales/ru/js/script.js @@ -0,0 +1,392 @@ + +var sankoreLang = {display: "Показать", edit: "Изменить", short_desc: "Расположите картинки в порядке возрастания цифр.", add: "Новый блок"}; + +//main function +function start(){ + + $("#display_text").text(sankoreLang.display); + $("#edit_text").text(sankoreLang.edit); + + if(window.sankore){ + if(sankore.preference("odr_des_imgs","")){ + var data = jQuery.parseJSON(sankore.preference("odr_des_imgs","")); + importData(data); + } else { + showExample(); + } + } + else + showExample(); + + //events + $("body").live("mouseout",function(){ + if(event.target.tagName == "BODY") + if(window.sankore) + exportData(); + }) + + $("#display, #edit").click(function(event){ + if(this.id == "display"){ + if(!$(this).hasClass("selected")){ + $(this).addClass("selected"); + $("#display_img").removeClass("red_point").addClass("green_point"); + $("#edit_img").removeClass("green_point").addClass("red_point"); + $("#edit").removeClass("selected"); + $(".add_block").remove(); + $(".cont").each(function(){ + var container = $(this); + var tmp_i = 0; + var tmp_right = ""; + var tmp_array = []; + + container.find(".text_cont").removeAttr("contenteditable"); + container.find(".add_img").remove(); + container.find(".close_cont").remove(); + container.find(".img_block").each(function(){ + if($(this).find("img").attr("src") != "img/drop_img.png"){ + $(this).find(".close_img").remove(); + $(this).find(".clear_img").remove(); + $(this).find(".numb_img").remove(); + $(this).removeAttr("ondragenter") + .removeAttr("ondragleave") + .removeAttr("ondragover") + .removeAttr("ondrop"); + $(this).find("input").val(++tmp_i) + tmp_right += tmp_i + "*"; + } else + $(this).remove(); + }); + container.find(".imgs_cont>input").val(tmp_right); + + container.find(".img_block").each(function(){ + $(this).css("float",""); + tmp_array.push($(this)); + }); + tmp_array = shuffle(tmp_array); + for(var i = 0; i").appendTo(container); + container.find(".text_cont").attr("contenteditable","true"); + //container.find(".imgs_cont").sortable("destroy"); + container.find(".imgs_cont").css("background-color", "white"); + + var add_img = $("
"); + container.find(".img_block").each(function(){ + $(this).attr("ondragenter", "return false;") + .attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;") + .attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;") + .attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);") + //.css("float","left"); + $("
").appendTo($(this)); + $("
").appendTo($(this)); + $("
" + $(this).find("input").val() + "
").appendTo($(this)); + }); + rightOrder(container.find(".imgs_cont")); + container.find(".imgs_cont").append(add_img) + }); + + $("
" + sankoreLang.add + "
").appendTo("body"); + } + } + }); + + //add new block + $(".add_block").live("click", function(){ + addContainer(); + }); + + //adding new img + $(".add_img").live("click", function(){ + addImgBlock($(this)); + }); + + //deleting a block + $(".close_cont").live("click",function(){ + $(this).parent().remove(); + refreshBlockNumbers(); + }); + + //deleting the img block + $(".close_img").live("click", function(){ + var i = 0; + var tmp_obj = $(this).parent().parent(); + $(this).parent().remove(); + if(tmp_obj.find(".img_block").size() > 0){ + refreshImgNumbers(tmp_obj); + } + + }); + + //cleaning an image + $(".clear_img").live("click",function(){ + //$(this).parent().find(".fill_img").remove(); + $(this).parent().find("img").attr("src","img/drop_img.png"); + }); +} + +//export +function exportData(){ + var array_to_export = []; + if($("#edit").hasClass("selected")){ + $(".cont").each(function(){ + var container = $(this); + var tmp_right = ""; + var tmp_i = 0; + container.find(".img_block").each(function(){ + if($(this).html().match(/input").val(tmp_right); + }); + } + $(".cont").each(function(){ + var cont_obj = new Object(); + cont_obj.text = $(this).find(".text_cont").text(); + cont_obj.right = $(this).find(".imgs_cont>input").val(); + cont_obj.imgs = []; + $(this).find(".img_block").each(function(){ + var img_obj = new Object(); + img_obj.value = $(this).find("input").val(); + img_obj.link = $(this).find("img").attr("src").replace("../../",""); + img_obj.ht = $(this).find("img").height(); + img_obj.wd = $(this).find("img").width(); + cont_obj.imgs.push(img_obj); + }); + array_to_export.push(cont_obj); + }); + sankore.setPreference("odr_des_imgs", JSON.stringify(array_to_export)); +} + +//import +function importData(data){ + + var tmp = 0; + for(var i in data){ + var tmp_array = []; + var container = $("
"); + var sub_container = $("
").appendTo(container); + var imgs_container = $("
").appendTo(container); + + var number = $("
"+ (++tmp) +"
").appendTo(sub_container); + var text = $("
" + data[i].text + "
").appendTo(sub_container); + + $("").appendTo(imgs_container); + + for(var j in data[i].imgs){ + var img_block = $("
"); + var img = $(""); + img.height(data[i].imgs[j].ht).width(data[i].imgs[j].wd); + if((120 - data[i].imgs[j].ht) > 0) + img.css("margin",(120 - data[i].imgs[j].ht)/2 + "px 0"); + var hidden_input = $("").val(data[i].imgs[j].value); + img_block.append(hidden_input).append(img); + tmp_array.push(img_block); + } + tmp_array = shuffle(tmp_array); + for(j = 0; j"); + var sub_container = $("
").appendTo(container); + var imgs_container = $("
").appendTo(container); + + var number = $("
1
").appendTo(sub_container); + var text = $("
" + sankoreLang.short_desc + "
").appendTo(sub_container); + + $("").appendTo(imgs_container); + + var img1 = $("
"); + $("").appendTo(img1); + $("").appendTo(img1); + var img2 = $("
"); + $("").appendTo(img2); + $("").appendTo(img2); + var img3 = $("
"); + $("").appendTo(img3); + $("").appendTo(img3); + var img4 = $("
"); + $("").appendTo(img4); + $("").appendTo(img4); + var img5 = $("
"); + $("").appendTo(img5); + $("").appendTo(img5); + + tmp_array.push(img1, img2, img3, img4, img5); + tmp_array = shuffle(tmp_array); + for(var i = 0; i"); + var sub_container = $("
").appendTo(container); + var imgs_container = $("
").appendTo(container); + + var close = $("
").appendTo(container); + var number = $("
"+ ($(".cont").size() + 1) +"
").appendTo(sub_container); + var text = $("
Enter your text here ...
").appendTo(sub_container); + + $("").appendTo(imgs_container); + var add_img = $("
").appendTo(imgs_container); + container.insertBefore($(".add_block")); +} + +//add new img block +function addImgBlock(dest){ + var img_block = $("
").insertBefore(dest); + var tmp_counter = dest.parent().find(".img_block").size(); + $("
").appendTo(img_block); + $("
").appendTo(img_block); + $("
" + tmp_counter + "
").appendTo(img_block); + $("").appendTo(img_block); + $("").appendTo(img_block); +} + +function refreshBlockNumbers(){ + var i = 0; + $(".cont").each(function(){ + $(this).find(".number_cont").text(++i); + }) +} + +//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; +} + +//regulation the images in right order +function rightOrder(source){ + var tmp_arr = []; + var tmp_var; + source.find(".img_block").each(function(){ + tmp_arr.push($(this)); + $(this).remove(); + }); + for(var i = 0; i < tmp_arr.length; i++) + for(var j = 0; j < tmp_arr.length - 1; j++){ + if(tmp_arr[j].find("input").val() > tmp_arr[j+1].find("input").val()){ + tmp_var = tmp_arr[j]; + tmp_arr[j] = tmp_arr[j+1]; + tmp_arr[j+1] = tmp_var; + } + } + for(i in tmp_arr) + source.append(tmp_arr[i]); +} + +//refresh the numbers of the images +function refreshImgNumbers(source){ + var tmp = 1; + source.find(".img_block").each(function(){ + $(this).find("input").val(tmp); + $(this).find(".numb_img").text(tmp); + tmp++; + }); +} + +function stringToXML(text){ + if (window.ActiveXObject){ + var doc=new ActiveXObject('Microsoft.XMLDOM'); + doc.async='false'; + doc.loadXML(text); + } else { + var parser=new DOMParser(); + doc=parser.parseFromString(text,'text/xml'); + } + return doc; +} + +function onDropTarget(obj, event) { + $(obj).find("img").remove(); + if (event.dataTransfer) { + var format = "text/plain"; + var textData = event.dataTransfer.getData(format); + if (!textData) { + alert(":("); + } + textData = stringToXML(textData); + var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; + tmp = tmp.substr(1, tmp.length); + var tmp_img = $("").attr("src", "../../" + tmp); + $(obj).append(tmp_img); + setTimeout(function(){ + if(tmp_img.height() >= tmp_img.width()) + tmp_img.attr("height", "120"); + else{ + tmp_img.attr("width","120"); + tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0"); + } + }, 6) + } + else { + alert ("Your browser does not support the dataTransfer object."); + } + + if (event.stopPropagation) { + event.stopPropagation (); + } + else { + event.cancelBubble = true; + } + return false; +} + diff --git a/resources/style.qss b/resources/style.qss index 8ce2d992..c542d934 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -27,7 +27,8 @@ QWidget#UBMediaVideoContainer border: 2px solid #999999; } -QWidget#UBTeacherBarPreviewWidget + +QWidget#UBTBPreviewWidget { background: #FFFFFF; border-radius: 10px; diff --git a/src/adaptors/UBExportDocument.cpp b/src/adaptors/UBExportDocument.cpp index 27ea87d7..95a8e4bc 100644 --- a/src/adaptors/UBExportDocument.cpp +++ b/src/adaptors/UBExportDocument.cpp @@ -22,8 +22,12 @@ #include "document/UBDocumentProxy.h" +#include "globals/UBGlobals.h" + +THIRD_PARTY_WARNINGS_DISABLE #include "quazip.h" #include "quazipfile.h" +THIRD_PARTY_WARNINGS_ENABLE #include "transition/UniboardSankoreTransition.h" diff --git a/src/adaptors/UBExportFullPDF.cpp b/src/adaptors/UBExportFullPDF.cpp index 402ef9cb..858809c6 100644 --- a/src/adaptors/UBExportFullPDF.cpp +++ b/src/adaptors/UBExportFullPDF.cpp @@ -179,9 +179,6 @@ void UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QS QString pdfName = UBPersistenceManager::objectDirectory + "/" + pdfItem->fileUuid().toString() + ".pdf"; QString backgroundPath = pDocumentProxy->persistencePath() + "/" + pdfName; - QPointF boudingRectBottomLeft = scene->itemsBoundingRect().bottomLeft(); - QPointF pdfItemBottomLeft = pdfItem->sceneBoundingRect().bottomLeft(); - qDebug() << "scene->itemsBoundingRect()" << scene->itemsBoundingRect(); qDebug() << "pdfItem->boundingRect()" << pdfItem->boundingRect(); qDebug() << "pdfItem->sceneBoundingRect()" << pdfItem->sceneBoundingRect(); diff --git a/src/adaptors/UBExportWeb.cpp b/src/adaptors/UBExportWeb.cpp index bfdedfe5..59a9c31b 100644 --- a/src/adaptors/UBExportWeb.cpp +++ b/src/adaptors/UBExportWeb.cpp @@ -23,8 +23,12 @@ #include "document/UBDocumentProxy.h" +#include "globals/UBGlobals.h" + +THIRD_PARTY_WARNINGS_DISABLE #include "quazip.h" #include "quazipfile.h" +THIRD_PARTY_WARNINGS_ENABLE #include "core/memcheck.h" diff --git a/src/adaptors/UBImportCFF.cpp b/src/adaptors/UBImportCFF.cpp index 448e2834..6b4fa318 100644 --- a/src/adaptors/UBImportCFF.cpp +++ b/src/adaptors/UBImportCFF.cpp @@ -27,9 +27,13 @@ #include "UBCFFSubsetAdaptor.h" #include "UBImportCFF.h" +#include "globals/UBGlobals.h" + +THIRD_PARTY_WARNINGS_DISABLE #include "quazip.h" #include "quazipfile.h" #include "quazipfileinfo.h" +THIRD_PARTY_WARNINGS_ENABLE #include "core/memcheck.h" diff --git a/src/adaptors/UBImportDocument.cpp b/src/adaptors/UBImportDocument.cpp index f441b980..3e7808cf 100644 --- a/src/adaptors/UBImportDocument.cpp +++ b/src/adaptors/UBImportDocument.cpp @@ -22,9 +22,13 @@ #include "core/UBSettings.h" #include "core/UBPersistenceManager.h" +#include "globals/UBGlobals.h" + +THIRD_PARTY_WARNINGS_DISABLE #include "quazip.h" #include "quazipfile.h" #include "quazipfileinfo.h" +THIRD_PARTY_WARNINGS_ENABLE #include "core/memcheck.h" diff --git a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp index 0dbdd5c5..10ee3cc4 100644 --- a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp +++ b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp @@ -276,7 +276,6 @@ QMap UBMetadataDcSubsetAdaptor::load(QString pPath) qWarning() << "Document size not found, using default view size" << docSize; metadata.insert(UBSettings::documentSize, QVariant(docSize)); - } if (!updatedAtFound) @@ -284,6 +283,8 @@ QMap UBMetadataDcSubsetAdaptor::load(QString pPath) metadata.insert(UBSettings::documentUpdatedAt, date + "T00:00:00Z"); } + metadata.insert(UBSettings::documentDate, QVariant(date)); + return metadata; } diff --git a/src/adaptors/publishing/UBDocumentPublisher.cpp b/src/adaptors/publishing/UBDocumentPublisher.cpp index d3ec39dd..686b9d94 100644 --- a/src/adaptors/publishing/UBDocumentPublisher.cpp +++ b/src/adaptors/publishing/UBDocumentPublisher.cpp @@ -34,8 +34,12 @@ #include "domain/UBGraphicsWidgetItem.h" +#include "globals/UBGlobals.h" + +THIRD_PARTY_WARNINGS_DISABLE #include "quazip.h" #include "quazipfile.h" +THIRD_PARTY_WARNINGS_ENABLE #include "adaptors/UBExportFullPDF.h" #include "adaptors/UBExportDocument.h" diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 1fefd94b..54fe2a33 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -92,43 +92,8 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll UBBoardPaletteManager::~UBBoardPaletteManager() { - if(NULL != mpDownloadWidget) - { - delete mpDownloadWidget; - mpDownloadWidget = NULL; - } - if(NULL != mpTeacherBarWidget) - { - delete mpTeacherBarWidget; - mpTeacherBarWidget = NULL; - } - if(NULL != mpPageNavigWidget) - { - delete mpPageNavigWidget; - mpPageNavigWidget = NULL; - } - if(NULL != mpLibWidget) - { - delete mpLibWidget; - mpLibWidget = NULL; - } - if(NULL != mpCachePropWidget) - { - delete mpCachePropWidget; - mpCachePropWidget = NULL; - } delete mAddItemPalette; - if(NULL != mLeftPalette) - { - delete mLeftPalette; - mLeftPalette = NULL; - } - if(NULL != mRightPalette) - { - delete mRightPalette; - mRightPalette = NULL; - } if(NULL != mStylusPalette) { diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index b9819d52..f218f22c 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -43,6 +43,7 @@ QString UBSettings::sessionKeywords = QString("sessionKeywords"); QString UBSettings::sessionLevel = QString("sessionLevel"); QString UBSettings::sessionTopic = QString("sessionTopic"); QString UBSettings::sessionAuthors = QString("sessionAuthors"); +QString UBSettings::documentDate = QString("date"); QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:"); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 21b4d4e1..fd25cd4b 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -160,6 +160,7 @@ class UBSettings : public QObject static QString sessionLevel; static QString sessionTopic; static QString sessionAuthors; + static QString documentDate; static QString trashedDocumentGroupNamePrefix; diff --git a/src/customWidgets/UBActionableWidget.cpp b/src/customWidgets/UBActionableWidget.cpp new file mode 100644 index 00000000..20ddaf69 --- /dev/null +++ b/src/customWidgets/UBActionableWidget.cpp @@ -0,0 +1,71 @@ +#include +#include + +#include "UBActionableWidget.h" + +UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent) + , mShowActions(false) +{ + setObjectName(name); + mActions.clear(); +} + +UBActionableWidget::~UBActionableWidget() +{ + +} + +void UBActionableWidget::addAction(eAction act) +{ + if(!mActions.contains(act)){ + mActions << act; + } +} + +void UBActionableWidget::removeAction(eAction act) +{ + if(mActions.contains(act)){ + mActions.remove(mActions.indexOf(act)); + } +} + +void UBActionableWidget::removeAllActions() +{ + mActions.clear(); +} + +void UBActionableWidget::setActionsVisible(bool bVisible) +{ + mShowActions = bVisible; +} + +bool UBActionableWidget::shouldClose(QPoint p) +{ + qDebug() << "Should close: " << p.x() << "," << p.y(); + bool close = false; + + if(mShowActions && + p.x() >= 0 && + p.x() <= ACTIONSIZE && + p.y() >= 0 && + p.y() <= ACTIONSIZE){ + close = true; + } + + return close; +} + +void UBActionableWidget::paintEvent(QPaintEvent* ev) +{ + Q_UNUSED(ev); + if(mShowActions){ + QPainter p(this); + if(mActions.contains(eAction_Close)){ + p.drawPixmap(0, 0, 16, 16, QPixmap(":images/close.svg")); + }else if(mActions.contains(eAction_MoveUp)){ + // Implement me later + }else if(mActions.contains(eAction_MoveDown)){ + // Implement me later + } + } +} diff --git a/src/customWidgets/UBActionableWidget.h b/src/customWidgets/UBActionableWidget.h new file mode 100644 index 00000000..12b2a2fb --- /dev/null +++ b/src/customWidgets/UBActionableWidget.h @@ -0,0 +1,35 @@ +#ifndef UBACTIONABLEWIDGET_H +#define UBACTIONABLEWIDGET_H + +#include +#include + +#define ACTIONSIZE 16 + +typedef enum{ + eAction_Close, + eAction_MoveUp, + eAction_MoveDown +}eAction; + +class UBActionableWidget : public QWidget +{ + Q_OBJECT +public: + UBActionableWidget(QWidget* parent=0, const char* name="UBActionableWidget"); + ~UBActionableWidget(); + void addAction(eAction act); + void removeAction(eAction act); + void removeAllActions(); + void setActionsVisible(bool bVisible); + bool shouldClose(QPoint p); + +protected: + void paintEvent(QPaintEvent* ev); + QVector mActions; + +private: + bool mShowActions; +}; + +#endif // UBACTIONABLEWIDGET_H diff --git a/src/customWidgets/UBDraggableMedia.cpp b/src/customWidgets/UBDraggableMedia.cpp index 6d2551f2..7b976707 100644 --- a/src/customWidgets/UBDraggableMedia.cpp +++ b/src/customWidgets/UBDraggableMedia.cpp @@ -38,5 +38,5 @@ void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev) drag->setMimeData(mimeData); - Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction); + drag->exec(Qt::CopyAction | Qt::MoveAction); } diff --git a/src/customWidgets/UBGlobals.h b/src/customWidgets/UBGlobals.h deleted file mode 100644 index 1707ceac..00000000 --- a/src/customWidgets/UBGlobals.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef UBGLOBALS_H -#define UBGLOBALS_H - -#define DELETEPTR(ptr) if(NULL != ptr){ \ - delete ptr; \ - ptr = NULL; \ - } - -#endif // UBGLOBALS_H diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index c1809d93..8fb69cc3 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -13,7 +13,7 @@ * along with this program. If not, see . */ #include "core/UBApplication.h" -#include "UBGlobals.h" +#include "globals/UBGlobals.h" #include "UBMediaWidget.h" /** @@ -22,7 +22,7 @@ * @param parent as the parent widget * @param name as the object name */ -UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):QWidget(parent) +UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):UBActionableWidget(parent, name) , mpMediaObject(NULL) , mpVideoWidget(NULL) , mpAudioOutput(NULL) @@ -35,11 +35,10 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name) , mpMediaContainer(NULL) , mpCover(NULL) { - setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); + addAction(eAction_Close); mType = type; setLayout(&mLayout); diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h index 5192c3c7..01b0a0b6 100644 --- a/src/customWidgets/UBMediaWidget.h +++ b/src/customWidgets/UBMediaWidget.h @@ -27,6 +27,7 @@ #include #include "interfaces/IResizeable.h" +#include "UBActionableWidget.h" #define UBMEDIABUTTON_SIZE 32 #define TICK_INTERVAL 1000 @@ -58,7 +59,7 @@ private: bool mPressed; }; -class UBMediaWidget : public QWidget +class UBMediaWidget : public UBActionableWidget { Q_OBJECT public: diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 6481acb4..bc0d89d4 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -1,15 +1,19 @@ #include #include +#include +#include -#include "UBGlobals.h" +#include "globals/UBGlobals.h" #include "UBWidgetList.h" UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent) + , mCanRemove(true) , mpLayout(NULL) , mpContainer(NULL) , mMargin(5) , mListElementsSpacing(10) , mpEmptyLabel(NULL) + , mpCurrentWidget(NULL) { setObjectName(name); mOrientation = orientation; @@ -130,6 +134,53 @@ void UBWidgetList::resizeEvent(QResizeEvent *ev) updateSizes(); } +void UBWidgetList::mousePressEvent(QMouseEvent *ev) +{ + Q_UNUSED(ev); + if(mCanRemove){ + QWidget* pWAt = widgetAt(ev->pos()); + if(NULL != mpCurrentWidget){ + if(pWAt == mpCurrentWidget){ + QPoint p; + p.setX(ev->x()); + p.setY(ev->y()); + if(mpCurrentWidget->shouldClose(p)){ + emit closeWidget(mpCurrentWidget); + return; + } + + }else{ + mpCurrentWidget->setActionsVisible(false); + } + } + mpCurrentWidget = dynamic_cast(pWAt); + if(NULL != mpCurrentWidget){ + mpCurrentWidget->setActionsVisible(true); + } + } + update(); +} + +QWidget* UBWidgetList::widgetAt(QPoint p) +{ + QWidget* pW = NULL; + pW = childAt(p); + if(NULL != pW){ + do{ + if( "UBTeacherStudentAction" == pW->objectName() || + "UBUrlWidget" == pW->objectName() || + "UBTBMediaPicture" == pW->objectName() || + "UBMediaWidget" == pW->objectName()){ + return pW; + }else{ + pW = pW->parentWidget(); + } + }while(NULL != pW && this != pW); + } + + return pW; +} + void UBWidgetList::updateSizes() { // Resize all the widgets diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h index 865386ad..d2cd3a6c 100644 --- a/src/customWidgets/UBWidgetList.h +++ b/src/customWidgets/UBWidgetList.h @@ -11,6 +11,7 @@ #include #include "interfaces/IResizeable.h" +#include "customWidgets/UBActionableWidget.h" typedef enum{ eWidgetListOrientation_Vertical, @@ -40,10 +41,17 @@ public: void setListElementSpacing(int margin) { mListElementsSpacing = margin; } int listElementsSpacing() {return mListElementsSpacing; } +signals: + void closeWidget(QWidget* w); + protected: + bool mCanRemove; + void resizeEvent(QResizeEvent* ev); + void mousePressEvent(QMouseEvent* ev); private: + QWidget* widgetAt(QPoint p); int scaleWidgets(QSize pSize); void scaleContainer(QSize pSize, int updateValue); void updateView(QSize pSize); @@ -55,6 +63,7 @@ private: int mListElementsSpacing; QMap mWidgetInfo; QLabel* mpEmptyLabel; + UBActionableWidget* mpCurrentWidget; }; #endif // UBWIDGETLIST_H diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri index aa7b0255..c531d4b3 100644 --- a/src/customWidgets/customWidgets.pri +++ b/src/customWidgets/customWidgets.pri @@ -2,10 +2,12 @@ HEADERS += src/customWidgets/UBWidgetList.h \ src/customWidgets/UBDraggableLabel.h \ src/customWidgets/UBMediaWidget.h \ - src/customWidgets/UBGlobals.h \ - src/customWidgets/UBDraggableMedia.h + src/globals/UBGlobals.h \ + src/customWidgets/UBDraggableMedia.h \ + src/customWidgets/UBActionableWidget.h SOURCES += src/customWidgets/UBWidgetList.cpp \ src/customWidgets/UBDraggableLabel.cpp \ src/customWidgets/UBMediaWidget.cpp \ - src/customWidgets/UBDraggableMedia.cpp + src/customWidgets/UBDraggableMedia.cpp \ + src/customWidgets/UBActionableWidget.cpp diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index a2a4eac0..70983bab 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -81,7 +81,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) mTransparentDrawingView->setMouseTracking(true); - mTransparentDrawingView->setAcceptDrops(false); + mTransparentDrawingView->setAcceptDrops(true); QString backgroundStyle = "QWidget {background-color: rgba(127, 127, 127, 0)}"; mTransparentDrawingView->setStyleSheet(backgroundStyle); diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 9d1f8d42..5aafded1 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -1150,11 +1150,10 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source, UBMetadataDcSubsetAdaptor::persist(proxy); refreshDocumentThumbnailsView(); - // NOTE [Didier]: I think that selecting the thumbnail is not the role of the documentController - mDocumentUI->thumbnailWidget->selectItemAt(target); - // Notify the move to anyone interested in knowing it emit movedToIndex(target); + + UBApplication::boardController->setActiveDocumentScene(proxy, target); } diff --git a/src/document/UBDocumentProxy.cpp b/src/document/UBDocumentProxy.cpp index aafcfeda..add97241 100644 --- a/src/document/UBDocumentProxy.cpp +++ b/src/document/UBDocumentProxy.cpp @@ -295,6 +295,15 @@ QString UBDocumentProxy::sessionAuthors() return QString(); } +QString UBDocumentProxy::documentDate() +{ + if(mMetaDatas.contains(UBSettings::documentDate)){ + return metaData(UBSettings::documentDate).toString(); + }else{ + return QString(); + } +} + bool UBDocumentProxy::isModified() const { return mIsModified; diff --git a/src/document/UBDocumentProxy.h b/src/document/UBDocumentProxy.h index a8ec9b3b..6686a4f3 100644 --- a/src/document/UBDocumentProxy.h +++ b/src/document/UBDocumentProxy.h @@ -59,6 +59,7 @@ class UBDocumentProxy : public QObject QString sessionTopic(); void setSessionAuthor(const QString& authors); QString sessionAuthors(); + QString documentDate(); QSize defaultDocumentSize() const; diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 0f2d0c52..4a489a1f 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1755,6 +1755,9 @@ void UBGraphicsScene::addCache() mTools << cache; addItem(cache); + + cache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); + cache->setVisible(true); cache->setSelected(true); UBApplication::boardController->notifyCache(true); diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp index c430d84d..ea031cf1 100644 --- a/src/domain/UBGraphicsTextItemDelegate.cpp +++ b/src/domain/UBGraphicsTextItemDelegate.cpp @@ -305,10 +305,11 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta) bool bEndofTheSameBlock; int iBlockLen; int iPointSize; - int inewPointSize; + int iNextPointSize; int iCursorPos = startPos; // we search continuous blocks of the text with the same PointSize and allpy new settings for them. + cursor.setPosition (startPos, QTextCursor::MoveAnchor); while(iCursorPos < endPos) { bEndofTheSameBlock = false; @@ -326,17 +327,18 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta) iBlockLen++; cursor.setPosition (iCursorPos+iBlockLen+1, QTextCursor::KeepAnchor); - inewPointSize = cursor.charFormat().font().pointSize(); + iNextPointSize = cursor.charFormat().font().pointSize(); cursor.setPosition (iCursorPos+iBlockLen, QTextCursor::KeepAnchor); - if ((iPointSize != inewPointSize)||(iCursorPos+iBlockLen >= endPos)) + if ((iPointSize != iNextPointSize)||(iCursorPos+iBlockLen >= endPos)) bEndofTheSameBlock = true; }while(!bEndofTheSameBlock); //setting new parameners - curFont.setPointSize(iPointSize + delta); + int iNewPointSize = iPointSize + delta; + curFont.setPointSize( (iNewPointSize > 0)?iNewPointSize:1); textFormat.setFont(curFont); cursor.mergeCharFormat(textFormat); diff --git a/src/frameworks/UBBase32.cpp b/src/frameworks/UBBase32.cpp index efd0b614..29fcb75c 100644 --- a/src/frameworks/UBBase32.cpp +++ b/src/frameworks/UBBase32.cpp @@ -47,7 +47,7 @@ QByteArray UBBase32::decode(const QString& base32String) if (lookup < 0 || lookup >= 80) continue; - int digit = sBase32Lookup[lookup]; + int digit = sBase32Lookup[(int)lookup]; /* If this digit is not in the table, ignore it */ if (digit == 0xFF) diff --git a/src/frameworks/UBFileSystemUtils.cpp b/src/frameworks/UBFileSystemUtils.cpp index 5be2c1f8..97a7d157 100644 --- a/src/frameworks/UBFileSystemUtils.cpp +++ b/src/frameworks/UBFileSystemUtils.cpp @@ -16,10 +16,12 @@ #include "UBFileSystemUtils.h" #include +#include "globals/UBGlobals.h" +THIRD_PARTY_WARNINGS_DISABLE #include "quazipfile.h" - #include +THIRD_PARTY_WARNINGS_ENABLE #include "core/memcheck.h" diff --git a/src/globals/UBGlobals.h b/src/globals/UBGlobals.h new file mode 100644 index 00000000..363c11e4 --- /dev/null +++ b/src/globals/UBGlobals.h @@ -0,0 +1,47 @@ +#ifndef UBGLOBALS_H +#define UBGLOBALS_H + +#define DELETEPTR(ptr) if(NULL != ptr){ \ + delete ptr; \ + ptr = NULL; \ + } + +#ifdef Q_WS_WIN + +#define WARNINGS_DISABLE __pragma(warning(push, 0)); +#define WARNINGS_ENABLE __pragma(warning(pop)); + +#ifdef NO_THIRD_PARTY_WARNINGS +// disabling warning level to 0 and save old state +#define THIRD_PARTY_WARNINGS_DISABLE WARNINGS_DISABLE +#else +// just save old state (needs for not empty define) +#define THIRD_PARTY_WARNINGS_DISABLE __pragma(warning(push)); +#endif //#ifdef NO_THIRD_PARTY_WARNINGS +// anyway on WIN +#define THIRD_PARTY_WARNINGS_ENABLE WARNINGS_ENABLE + +#else //#ifdef Q_WS_WIN + +#define WARNINGS_DISABLE _Pragma("GCC diagnostic push"); \ +_Pragma("GCC diagnostic ignored \"-Wunused-parameter\""); \ +_Pragma("GCC diagnostic ignored \"-Wunused-variable\""); \ +_Pragma("GCC diagnostic ignored \"-Wsign-compare\""); + +#define WARNINGS_ENABLE _Pragma("GCC diagnostic pop"); + +#ifdef NO_THIRD_PARTY_WARNINGS +//disabling some warnings +#define THIRD_PARTY_WARNINGS_DISABLE WARNINGS_DISABLE + +#define THIRD_PARTY_WARNINGS_ENABLE WARNINGS_ENABLE +#else +// just save old state (needs for not empty define) +#define THIRD_PARTY_WARNINGS_ENABLE WARNINGS_ENABLE + +#endif //#ifdef NO_THIRD_PARTY_WARNINGS + +#endif //#ifdef Q_WS_WIN + +#endif // UBGLOBALS_H + diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp index 82f28d76..b168663f 100644 --- a/src/gui/UBDockPalette.cpp +++ b/src/gui/UBDockPalette.cpp @@ -697,7 +697,7 @@ void UBDockPalette::moveTabs() void UBDockPalette::resizeTabs() { int numTabs = mTabWidgets.size(); - mTabPalette->resize(2 * border(), (numTabs * TABSIZE) + qMax(numTabs - 1, 0) * tabSpacing()); + mTabPalette->setFixedSize(2 * border(), (numTabs * TABSIZE) + qMax(numTabs - 1, 0) * tabSpacing()); } QRect UBDockPalette::getTabPaletteRect() { diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h index ff3b546d..0d660e0a 100644 --- a/src/gui/UBDockPalette.h +++ b/src/gui/UBDockPalette.h @@ -191,8 +191,8 @@ private: void resizeTabs(); private: - UBTabDockPalete *mTabPalette; eUBDockPaletteType mPaletteType; + UBTabDockPalete *mTabPalette; }; #endif // UBDOCKPALETTE_H diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 4efea020..0f6b6eff 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -391,17 +391,13 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event) mCrntItem = pCrntItem; } - // HACK: for an unknown reason, the mousePressEvent of the item is not - // called when a click occurs on it. So I created this method in - // order to handle the click. - mCrntItem->notifyClick(mapToScene(event->pos())); - // Then display the related page emit changeCurrentPage(); refreshScene(); } bNavig = false; } + QGraphicsView::mousePressEvent(event); } /** @@ -448,7 +444,8 @@ void UBDocumentNavigator::onMovedToIndex(int index) UBSceneThumbnailNavigPixmap* pItem = dynamic_cast(mThumbnails.at(index)); if(NULL != pItem) { - mCrntItem = pItem; + if(mCrntItem) mCrntItem->setSelected(false);//deselecting previous one + mCrntItem = pItem; mCrntItem->setSelected(true); centerOn(mCrntItem); } diff --git a/src/gui/UBLibPathViewer.cpp b/src/gui/UBLibPathViewer.cpp index 2dff5098..ca79f7c0 100644 --- a/src/gui/UBLibPathViewer.cpp +++ b/src/gui/UBLibPathViewer.cpp @@ -284,7 +284,7 @@ void UBLibPathViewer::showBack() if(NULL != pLastElem) { mpBackElem->setPath(pLastElem->element()->path()); - mpBackElem->setType(eUBLibElementType_Folder); + mpBackElem->setType(pLastElem->element()->type()); mpBackElem->setName(pLastElem->element()->name()); } diff --git a/src/gui/UBLibraryWidget.cpp b/src/gui/UBLibraryWidget.cpp index 31371a83..568b0c4d 100644 --- a/src/gui/UBLibraryWidget.cpp +++ b/src/gui/UBLibraryWidget.cpp @@ -361,15 +361,12 @@ void UBLibraryWidget::dropEvent(QDropEvent *event) QString filePath; QString crntPath = urlList.at(i).toString(); -#ifdef Q_WS_MACX - filePath = QUrl(urlList.at(i)).toString(); -#else if(crntPath.startsWith("file:") || crntPath.startsWith("/")){ filePath = QUrl(crntPath).toLocalFile(); }else{ filePath = crntPath; } -#endif + mLibraryController->importItemOnLibrary(filePath); bDropAccepted = true; } diff --git a/src/gui/UBResources.cpp b/src/gui/UBResources.cpp index be2e7dcc..f1eb64ab 100644 --- a/src/gui/UBResources.cpp +++ b/src/gui/UBResources.cpp @@ -51,7 +51,6 @@ void UBResources::init() // Cursors penCursor = QCursor(Qt::CrossCursor); eraserCursor = QCursor(QPixmap(":/images/cursors/eraser.png"), 21, 21); - magnifierCursor = QCursor(QPixmap(":/images/cursors/magnifier.png"), 9, 9); markerCursor = QCursor(QPixmap(":/images/cursors/marker.png"), 3, 30); pointerCursor = QCursor(QPixmap(":/images/cursors/laser.png"), 2, 1); handCursor = QCursor(Qt::OpenHandCursor); @@ -60,5 +59,5 @@ void UBResources::init() arrowCursor = QCursor(Qt::ArrowCursor); textCursor = QCursor(Qt::ArrowCursor); rotateCursor = QCursor(QPixmap(":/images/cursors/rotate.png"), 16, 16); - drawLineRulerCursor = QCursor(QPixmap(":/images/cursors/drawRulerLine.png"), 3, 12); + drawLineRulerCursor = QCursor(QPixmap(":/images/cursors/drawRulerLine.png"), 3, 12); } diff --git a/src/gui/UBResources.h b/src/gui/UBResources.h index fd32fa6d..bae4eee6 100644 --- a/src/gui/UBResources.h +++ b/src/gui/UBResources.h @@ -37,7 +37,6 @@ class UBResources : public QObject QCursor penCursor; QCursor eraserCursor; - QCursor magnifierCursor; QCursor markerCursor; QCursor pointerCursor; QCursor handCursor; diff --git a/src/gui/UBTBDocumentEditWidget.cpp b/src/gui/UBTBDocumentEditWidget.cpp index 30f3438e..261372b3 100644 --- a/src/gui/UBTBDocumentEditWidget.cpp +++ b/src/gui/UBTBDocumentEditWidget.cpp @@ -1,7 +1,7 @@ #include #include "UBTBDocumentEditWidget.h" -#include "customWidgets/UBGlobals.h" +#include "globals/UBGlobals.h" UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) , mpPageViewButton(NULL) @@ -62,8 +62,8 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW mpKeywords->setObjectName("DockPaletteWidgetLineEdit"); mpLevel = new QComboBox(this); mpLevel->setObjectName("DockPaletteWidgetComboBox"); - mpTopic = new QComboBox(this); - mpTopic->setObjectName("DockPaletteWidgetComboBox"); + mpTopic = new QLineEdit(this); + mpTopic->setObjectName("DockPaletteWidgetLineEdit"); mpAuthor = new QLineEdit(this); mpAuthor->setObjectName("DockPaletteWidgetLineEdit"); mpKeywordLabel = new QLabel(tr("Keywords:"), this); @@ -120,7 +120,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW connect(mpLicenseCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLicenseCurrentIndexChanged(int))); connect(mpKeywords, SIGNAL(textChanged(QString)), this, SLOT(onKeywordChanged(QString))); connect(mpLevel, SIGNAL(currentIndexChanged(QString)), this, SLOT(onLevelChanged(QString))); - connect(mpTopic, SIGNAL(currentIndexChanged(QString)), this, SLOT(onTopicChanged(QString))); + connect(mpTopic, SIGNAL(textChanged(QString)), this, SLOT(onTopicChanged(QString))); connect(mpAuthor, SIGNAL(textChanged(QString)), this, SLOT(onAuthorChanged(QString))); } @@ -179,7 +179,7 @@ void UBTBDocumentEditWidget::updateFields() mpTarget->setPlainText(mpDataMgr->sessionTarget()); mpKeywords->setText(mpDataMgr->keywords()); // TODO: retrieve the level - // TODO retrieve the topic + mpTopic->setText(mpDataMgr->topic()); mpAuthor->setText(mpDataMgr->authors()); } @@ -192,7 +192,6 @@ void UBTBDocumentEditWidget::clearFields() void UBTBDocumentEditWidget::onKeywordChanged(const QString &kw) { mpDataMgr->setKeywords(kw); - qDebug() << ">>> KEYWORD CHANGED: " << kw; emit valueChanged(); } diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h index 7d782247..4b49a973 100644 --- a/src/gui/UBTBDocumentEditWidget.h +++ b/src/gui/UBTBDocumentEditWidget.h @@ -60,7 +60,7 @@ private: QComboBox* mpLicenseCombox; QLineEdit* mpKeywords; QComboBox* mpLevel; - QComboBox* mpTopic; + QLineEdit* mpTopic; QLineEdit* mpAuthor; QLabel* mpKeywordLabel; QLabel* mpLevelLabel; diff --git a/src/gui/UBTBDocumentPreviewWidget.cpp b/src/gui/UBTBDocumentPreviewWidget.cpp index 39d75199..ed54ee1b 100644 --- a/src/gui/UBTBDocumentPreviewWidget.cpp +++ b/src/gui/UBTBDocumentPreviewWidget.cpp @@ -1,30 +1,122 @@ -#include "customWidgets/UBGlobals.h" +#include "globals/UBGlobals.h" #include "UBTBDocumentPreviewWidget.h" UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) + , mpContainer(NULL) , mpPageViewButton(NULL) , mpEditButton(NULL) + , mpSessionLabel(NULL) + , mpSessionTitle(NULL) + , mpAuthorLabel(NULL) + , mpAuthors(NULL) + , mpCreationDate(NULL) + , mpTargetLabel(NULL) + , mpTarget(NULL) + , mpMetadataLabel(NULL) + , mpKeywordLabel(NULL) + , mpKeyword(NULL) + , mpLevelLabel(NULL) + , mpLevel(NULL) + , mpTopicLabel(NULL) + , mpTopic(NULL) + , mpLicense(NULL) { setObjectName(name); mpDataMgr = pDataMgr; setLayout(&mLayout); + mLayout.setContentsMargins(0, 0, 0, 0); - mpPageViewButton = new QPushButton(tr("Page View"), this); - mpPageViewButton->setObjectName("DockPaletteWidgetButton"); - mPageLayout.addStretch(1); - mPageLayout.addWidget(mpPageViewButton, 0); - mPageLayout.addStretch(1); - mLayout.addLayout(&mPageLayout); + mpContainer = new QWidget(this); + mpContainer->setLayout(&mContainerLayout); + mpContainer->setObjectName("UBTBPreviewWidget"); + + // Session Title + mpSessionLabel = new QLabel(tr("Session"), mpContainer); + mpSessionLabel->setAlignment(Qt::AlignRight); + mpSessionLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mContainerLayout.addWidget(mpSessionLabel, 0); + mpSessionTitle = new QLabel(mpContainer); + mpSessionTitle->setWordWrap(true); + mpSessionTitle->setAlignment(Qt::AlignRight); + mpSessionTitle->setObjectName("UBTeacherBarPreviewTitle"); + mContainerLayout.addWidget(mpSessionTitle, 0); + mContainerLayout.addWidget(&mTitleSeparator, 0); + + // Author(s) + mpAuthorLabel = new QLabel(tr("Author(s)"), mpContainer); + mpAuthorLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mContainerLayout.addWidget(mpAuthorLabel, 0); + mpAuthors = new QLabel(mpContainer); + mpAuthors->setWordWrap(true); + mpAuthors->setStyleSheet("padding-left:5px;"); + mContainerLayout.addWidget(mpAuthors, 0); + mContainerLayout.addWidget(&mAuthorSeparator, 0); + + // Dates + mpCreationDate = new QLabel(tr("Created on: "), mpContainer); + mpCreationDate->setStyleSheet("padding-left:5px;"); + mContainerLayout.addWidget(mpCreationDate); + mContainerLayout.addWidget(&mDateSeparator, 0); + + // Target + mpTargetLabel = new QLabel(tr("Target"), mpContainer); + mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mContainerLayout.addWidget(mpTargetLabel,0); + mpTarget = new QTextEdit(mpContainer); + mpTarget->setReadOnly(true); + mContainerLayout.addWidget(mpTarget, 1); + mContainerLayout.addWidget(&mTargetSeparator, 0); + + // Metadata + mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); + mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mContainerLayout.addWidget(mpMetadataLabel, 0); + + // Keyword + mpKeywordLabel = new QLabel(tr("Keywords:"), mpContainer); + mpKeywordLabel->setStyleSheet("padding-left:5px;"); + mpKeyword = new QLabel(mpContainer); + mpKeyword->setWordWrap(true); + mKeywordLayout.addWidget(mpKeywordLabel, 0); + mKeywordLayout.addWidget(mpKeyword, 1); + mContainerLayout.addLayout(&mKeywordLayout, 0); + + // Level + mpLevelLabel = new QLabel(tr("Level:"), mpContainer); + mpLevelLabel->setStyleSheet("padding-left:5px;"); + mpLevel = new QLabel(mpContainer); + mpLevel->setWordWrap(true); + mLevelLayout.addWidget(mpLevelLabel, 0); + mLevelLayout.addWidget(mpLevel, 1); + mContainerLayout.addLayout(&mLevelLayout, 0); - // TODO : Add the elements here + // Topic + mpTopicLabel = new QLabel(tr("Topic:"), mpContainer); + mpTopicLabel->setStyleSheet("padding-left:5px;"); + mpTopic = new QLabel(mpContainer); + mpTopic->setWordWrap(true); + mTopicLayout.addWidget(mpTopicLabel, 0); + mTopicLayout.addWidget(mpTopic, 1); + mContainerLayout.addLayout(&mTopicLayout, 0); + mContainerLayout.addWidget(&mMetadataSeparator, 0); + // License + mpLicense = new UBTBLicenseWidget(mpContainer); + mContainerLayout.addWidget(mpLicense, 0); + + mLayout.addWidget(mpContainer, 1); + + mpPageViewButton = new QPushButton(tr("Page View"), this); + mpPageViewButton->setObjectName("DockPaletteWidgetButton"); mpEditButton = new QPushButton(tr("Edit"), this); mpEditButton->setObjectName("DockPaletteWidgetButton"); - mPreviewLayout.addStretch(1); - mPreviewLayout.addWidget(mpEditButton, 0); - mPreviewLayout.addStretch(1); - mLayout.addLayout(&mPreviewLayout); + + mButtonsLayout.addWidget(mpPageViewButton, 0); + mButtonsLayout.addWidget(mpEditButton, 0); + mButtonsLayout.addStretch(1); + + mLayout.addLayout(&mButtonsLayout, 0); connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); @@ -32,8 +124,7 @@ UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataM UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget() { - DELETEPTR(mpPageViewButton); - DELETEPTR(mpEditButton); + } void UBTBDocumentPreviewWidget::onEdit() @@ -48,10 +139,23 @@ void UBTBDocumentPreviewWidget::onPageView() void UBTBDocumentPreviewWidget::updateFields() { - + mpSessionTitle->setText(mpDataMgr->sessionTitle()); + mpAuthors->setText(mpDataMgr->authors()); + mpCreationDate->setText(tr("Creation Date: %0").arg(mpDataMgr->creationDate())); + mpTarget->setText(mpDataMgr->sessionTarget()); + mpLicense->setLicense(mpDataMgr->sessionLicence()); + mpKeyword->setText(mpDataMgr->keywords()); + mpLevel->setText(mpDataMgr->level()); + mpTopic->setText(mpDataMgr->topic()); } void UBTBDocumentPreviewWidget::clearFields() { - + mpSessionTitle->setText(""); + mpAuthors->setText(""); + mpCreationDate->setText(""); + mpTarget->setText(""); + mpKeyword->setText(""); + mpLevel->setText(""); + mpTopic->setText(""); } diff --git a/src/gui/UBTBDocumentPreviewWidget.h b/src/gui/UBTBDocumentPreviewWidget.h index 99959afa..f2115c72 100644 --- a/src/gui/UBTBDocumentPreviewWidget.h +++ b/src/gui/UBTBDocumentPreviewWidget.h @@ -24,10 +24,35 @@ private slots: private: QVBoxLayout mLayout; - QHBoxLayout mPageLayout; - QHBoxLayout mPreviewLayout; + QHBoxLayout mButtonsLayout; + + QWidget* mpContainer; + QVBoxLayout mContainerLayout; QPushButton* mpPageViewButton; QPushButton* mpEditButton; + QLabel* mpSessionLabel; + QLabel* mpSessionTitle; + UBTBSeparator mTitleSeparator; + QLabel* mpAuthorLabel; + QLabel* mpAuthors; + UBTBSeparator mAuthorSeparator; + QLabel* mpCreationDate; + UBTBSeparator mDateSeparator; + QLabel* mpTargetLabel; + QTextEdit* mpTarget; + UBTBSeparator mTargetSeparator; + QLabel* mpMetadataLabel; + QHBoxLayout mKeywordLayout; + QLabel* mpKeywordLabel; + QLabel* mpKeyword; + QHBoxLayout mLevelLayout; + QLabel* mpLevelLabel; + QLabel* mpLevel; + QHBoxLayout mTopicLayout; + QLabel* mpTopicLabel; + QLabel* mpTopic; + UBTBSeparator mMetadataSeparator; + UBTBLicenseWidget* mpLicense; UBTeacherBarDataMgr* mpDataMgr; }; diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 39f6716c..7957d6ab 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -1,4 +1,4 @@ -#include "customWidgets/UBGlobals.h" +#include "globals/UBGlobals.h" #include "core/UBApplication.h" #include "frameworks/UBFileSystemUtils.h" #include "gui/UBMediaPlayer.h" @@ -100,6 +100,9 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked())); connect(mpPagePreviewButton, SIGNAL(clicked()), this, SLOT(onPagePreviewClicked())); connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString))); + connect(mpActions, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*))); + connect(mpLinks, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*))); + connect(mpMediaContainer, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*))); } UBTBPageEditWidget::~UBTBPageEditWidget() @@ -271,15 +274,36 @@ void UBTBPageEditWidget::clearFields() mClearingFields = false; } +void UBTBPageEditWidget::onCloseWidget(QWidget *w) +{ + if(NULL != w){ + if("UBTeacherStudentAction" == w->objectName()){ + UBTeacherStudentAction* pW = dynamic_cast(w); + mpActions->removeWidget(pW); + mActions.remove(mActions.indexOf(pW)); + DELETEPTR(w); + }else if("UBUrlWidget" == w->objectName()){ + UBUrlWidget* pW = dynamic_cast(w); + mpLinks->removeWidget(pW); + mUrls.remove(mUrls.indexOf(pW)); + DELETEPTR(w); + }else if("UBTBMediaPicture" == w->objectName() || "UBMediaWidget" == w->objectName()){ + mpMediaContainer->removeWidget(w); + mMedias.remove(mMedias.indexOf(w)); + DELETEPTR(w); + } + } +} + // --------------------------------------------------------------------------------------------- -UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) +UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):UBActionableWidget(parent, name) , mpLayout(NULL) , mpUrlLabel(NULL) , mpUrl(NULL) { - setObjectName(name); setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); + addAction(eAction_Close); mpLayout = new QVBoxLayout(this); setLayout(mpLayout); @@ -320,7 +344,7 @@ QString UBUrlWidget::url() QString str; if(NULL != mpUrl){ - str = mpUrl->text() + ";" + mpTitle->text(); + str = mpUrl->text();// + ";" + mpTitle->text(); } return str; @@ -435,12 +459,13 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url); if(mimeType.contains("image")){ QPixmap pix = QPixmap(url); - QLabel* label = new QLabel(); - pix.scaledToWidth(label->width()); - label->resize(pix.width(), pix.height()); - label->setPixmap(pix); - label->setScaledContents(true); - pW = label; + UBPictureWidget* pic = new UBPictureWidget(); + pix.scaledToWidth(pic->label()->width()); + pic->label()->resize(pix.width(), pix.height()); + pic->label()->setPixmap(pix); + pic->label()->setScaledContents(true); + pic->setObjectName("UBTBMediaPicture"); + pW = pic; } else if(mimeType.contains("video") || mimeType.contains("audio")){ UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); @@ -455,16 +480,15 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) return pW; } -UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) +UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):UBActionableWidget(parent, name) , mpText(NULL) , mpLayout(NULL) , mpComboLayout(NULL) , mpCombo(NULL) { - setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); + addAction(eAction_Close); // Create the GUI mpLayout = new QHBoxLayout(this); @@ -532,3 +556,28 @@ void UBTeacherStudentAction::setText(const QString& text) } } +// ------------------------------------------------------------- +UBPictureWidget::UBPictureWidget(QWidget *parent, const char *name):UBActionableWidget(parent, name) + , mpLayout(NULL) + , mpLabel(NULL) +{ + addAction(eAction_Close); + mpLayout = new QVBoxLayout(this); + setLayout(mpLayout); + mpLayout->setContentsMargins(10, 0, 10, 0); + mpLabel = new QLabel(this); + mpLayout->addWidget(mpLabel); + mpLabel->setGeometry( 10, 10, width()-2*10, height()); +} + +UBPictureWidget::~UBPictureWidget() +{ + DELETEPTR(mpLabel); + DELETEPTR(mpLayout); +} + +void UBPictureWidget::resizeEvent(QResizeEvent *ev) +{ + Q_UNUSED(ev); + mpLabel->setGeometry( 10, 10, width()-2*10, height()); +} diff --git a/src/gui/UBTBPageEditWidget.h b/src/gui/UBTBPageEditWidget.h index 0f3c61b9..0521c847 100644 --- a/src/gui/UBTBPageEditWidget.h +++ b/src/gui/UBTBPageEditWidget.h @@ -11,10 +11,11 @@ #include "core/UBPersistenceManager.h" #include "customWidgets/UBWidgetList.h" +#include "customWidgets/UBActionableWidget.h" #include "interfaces/IDropable.h" #include "UBTeacherBarDataMgr.h" -class UBTeacherStudentAction : public QWidget +class UBTeacherStudentAction : public UBActionableWidget { Q_OBJECT @@ -33,7 +34,7 @@ private: QComboBox* mpCombo; }; -class UBUrlWidget : public QWidget +class UBUrlWidget : public UBActionableWidget { public: UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); @@ -56,6 +57,22 @@ private: QLineEdit* mpTitle; }; +class UBPictureWidget : public UBActionableWidget +{ +public: + UBPictureWidget(QWidget* parent=0, const char* name="UBPictureWidget"); + ~UBPictureWidget(); + + QLabel* label(){return mpLabel;} + +protected: + void resizeEvent(QResizeEvent* ev); + +private: + QVBoxLayout* mpLayout; + QLabel* mpLabel; +}; + class UBTBMediaContainer : public UBWidgetList , public IDropable { @@ -104,6 +121,7 @@ private slots: void onMediaDropped(const QString& url); void onDocumentEditClicked(); void onPagePreviewClicked(); + void onCloseWidget(QWidget* w); private: QVBoxLayout mLayout; diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index 5d951d77..ae84996b 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -1,3 +1,5 @@ +#include + #include "UBTeacherBarDataMgr.h" #include "core/UBApplication.h" @@ -5,7 +7,7 @@ #include "board/UBBoardController.h" -#include "customWidgets/UBGlobals.h" +#include "globals/UBGlobals.h" #include "adaptors/UBMetadataDcSubsetAdaptor.h" @@ -59,7 +61,6 @@ void UBTeacherBarDataMgr::saveContent() documentProxy->setSessionTitle(mSessionTitle); documentProxy->setSessionTarget(mSessionTarget); documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence)); - qDebug() << "Saving keywords: " << mKeywords; documentProxy->setSessionKeywords(mKeywords); documentProxy->setSessionLevel(mLevel); documentProxy->setSessionTopic(mTopic); @@ -73,6 +74,7 @@ void UBTeacherBarDataMgr::saveContent() void UBTeacherBarDataMgr::loadContent(bool docChanged) { + Q_UNUSED(docChanged); clearLists(); UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); @@ -82,10 +84,15 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged) mSessionTarget = documentProxy->sessionTarget(); mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt(); mKeywords = documentProxy->sessionKeywords(); - qDebug() << "Keywords loaded: " << mKeywords << " (" << documentProxy->sessionKeywords() << ")"; mLevel = documentProxy->sessionLevel(); mTopic = documentProxy->sessionTopic(); mAuthors = documentProxy->sessionAuthors(); + if("" != documentProxy->documentDate()){ + mCreationDate = documentProxy->documentDate(); + }else{ + mCreationDate = QDate::currentDate().toString("yyyy-MM-dd"); + } + } // Page Title @@ -126,6 +133,7 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged) // ------------------------------------------------------------------------------------ UBTBSeparator::UBTBSeparator(QWidget *parent, const char *name):QFrame(parent) { + Q_UNUSED(name); setObjectName("UBTBSeparator"); setMinimumHeight(5); setMaximumHeight(5); diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index b182e892..900dfb38 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -115,6 +115,13 @@ public: void setAuthors(const QString& authors){mAuthors = authors;} QString authors(){return mAuthors;} + // Creation Date + void setCreationDate(const QString& date){mCreationDate = date;} + QString creationDate(){return mCreationDate;} + + // Last Modification + void setLastModificationDate(const QString& date){mLastModif = date;} + QString lastModificationDate(){return mLastModif;} // Others void clearLists(); @@ -131,6 +138,8 @@ private: QString mLevel; QString mTopic; QString mAuthors; + QString mCreationDate; + QString mLastModif; QVector mActionList; QVector mUrlList; diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 1a7feefc..46cf05e5 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -1,5 +1,5 @@ #include "core/UBApplication.h" -#include "customWidgets/UBGlobals.h" +#include "globals/UBGlobals.h" #include "board/UBBoardController.h" #include "frameworks/UBFileSystemUtils.h" @@ -37,6 +37,7 @@ void UBTeacherBarPreviewMedia::cleanMedia() void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList, bool isResizable) { + Q_UNUSED(isResizable); foreach(QWidget*eachWidget, pWidgetsList){ mWidget->addWidget(eachWidget); mWidgetList[eachWidget]="DRAG UNAVAILABLE"; @@ -134,6 +135,7 @@ void UBActionPreview::setContent(const QString &content) UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UBWidgetList(parent) { setObjectName(name); + mCanRemove = false; } UBTBPreviewContainer::~UBTBPreviewContainer() @@ -144,6 +146,7 @@ UBTBPreviewContainer::~UBTBPreviewContainer() // ------------------------------------------------------------------------------------ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) , mpEditButton(NULL) + , mpDocumentButton(NULL) , mpSessionTitle(NULL) , mpTitle(NULL) , mpTitleLabel(NULL) @@ -155,20 +158,27 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataM setObjectName(name); mpDataMgr = pDataMgr; setLayout(&mLayout); + mLayout.setContentsMargins(0, 0, 0, 0); setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); // Build the Preview widget + mpContainer = new QWidget(this); + mpContainer->setObjectName("UBTBPreviewWidget"); + mpContainer->setLayout(&mContainerLayout); + mLayout.addWidget(mpContainer, 1); + + // Session Title - mpTitleContainer = new QWidget(this); + mpTitleContainer = new QWidget(mpContainer); mpTitleContainer->setLayout(&mTitleLayout); - mpSessionTitle = new QLabel(this); + mpSessionTitle = new QLabel(mpContainer); mpSessionTitle->setText(tr("Session: ")); mpSessionTitle->setWordWrap(true); mpSessionTitle->setAlignment(Qt::AlignRight); mpSessionTitle->setObjectName("UBTBPreviewSessionTitle"); - mLayout.addWidget(mpSessionTitle); + mContainerLayout.addWidget(mpSessionTitle); // Title mpTitleContainer->setLayout(&mTitleLayout); @@ -187,27 +197,32 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataM mpPageNbrLabel->setObjectName("UBTBPreviewSessionTitle"); mTitleLayout.addWidget(mpPageNbrLabel); mTitleLayout.addWidget(&mTitleSeparator); - mLayout.addWidget(mpTitleContainer); + mContainerLayout.addWidget(mpTitleContainer); // Content - mpContentContainer = new UBTBPreviewContainer(this); - mLayout.addWidget(mpContentContainer, 1); + mpContentContainer = new UBTBPreviewContainer(mpContainer); + mContainerLayout.addWidget(mpContentContainer, 1); // License - mLayout.addWidget(&mLicenseSeparator); - mpLicenseLabel = new UBTBLicenseWidget(this); - mLayout.addWidget(mpLicenseLabel); + mContainerLayout.addWidget(&mLicenseSeparator); + mpLicenseLabel = new UBTBLicenseWidget(mpContainer); + mContainerLayout.addWidget(mpLicenseLabel); - // Edit button - mpEditButton = new QPushButton(tr("Edit infos"), this); + // Document Button + mpDocumentButton = new QPushButton(tr("Document View"), this); + mpDocumentButton->setObjectName("DockPaletteWidgetButton"); + + // Edit Button + mpEditButton = new QPushButton(tr("Edit"), this); mpEditButton->setObjectName("DockPaletteWidgetButton"); - mEditLayout.addStretch(1); + mEditLayout.addWidget(mpDocumentButton, 0); mEditLayout.addWidget(mpEditButton, 0); mEditLayout.addStretch(1); mLayout.addLayout(&mEditLayout, 0); connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); + connect(mpDocumentButton, SIGNAL(clicked()), this, SLOT(onDocumentClicked())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); } @@ -225,6 +240,11 @@ void UBTeacherBarPreviewWidget::onEdit() emit showEditMode(); } +void UBTeacherBarPreviewWidget::onDocumentClicked() +{ + emit showDocumentPreview(); +} + void UBTeacherBarPreviewWidget::updateFields() { // Session Title @@ -343,6 +363,7 @@ void UBTeacherBarPreviewWidget::generateComments() void UBTeacherBarPreviewWidget::showEvent(QShowEvent* ev) { + Q_UNUSED(ev); updateFields(); } diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h index 7fb2f92b..61d4a892 100644 --- a/src/gui/UBTeacherBarPreviewWidget.h +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -62,6 +62,7 @@ public: signals: void showEditMode(); + void showDocumentPreview(); protected: void showEvent(QShowEvent* ev); @@ -69,6 +70,7 @@ protected: private slots: void onEdit(); void onActiveSceneChanged(); + void onDocumentClicked(); private: void generateActions(); @@ -77,8 +79,12 @@ private: void generateComments(); QVBoxLayout mLayout; + QVBoxLayout mContainerLayout; QHBoxLayout mEditLayout; QPushButton* mpEditButton; + QPushButton* mpDocumentButton; + + QWidget* mpContainer; // Titles QVBoxLayout mTitleLayout; @@ -95,7 +101,6 @@ private: // License UBTBSeparator mLicenseSeparator; - // TODO : replace the QLabel of the license by a widget done for that! UBTBLicenseWidget* mpLicenseLabel; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 5aeb80a4..7ee9a70b 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -15,7 +15,7 @@ #include "customWidgets/UBDraggableLabel.h" #include "customWidgets/UBMediaWidget.h" -#include "customWidgets/UBGlobals.h" +#include "globals/UBGlobals.h" #include "core/memcheck.h" @@ -57,6 +57,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock connect(UBApplication::boardController, SIGNAL(activeDocumentChanged()), this, SLOT(onActiveDocumentChanged())); connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); + connect(mpPreview, SIGNAL(showDocumentPreview()), this, SLOT(onShowDocumentPreview())); connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpDocEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpPageEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); @@ -150,6 +151,11 @@ void UBTeacherBarWidget::onShowEditMode() onTBStateChanged(eTeacherBarState_PageEdit); } +void UBTeacherBarWidget::onShowDocumentPreview() +{ + onTBStateChanged(eTeacherBarState_DocumentPreview); +} + void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) { switch(state){ diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 26831bfe..a97a4626 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -48,6 +48,7 @@ private slots: void onShowEditMode(); void onTBStateChanged(eTeacherBarState state); void onActiveDocumentChanged(); + void onShowDocumentPreview(); private: bool isEmpty(); diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp index e589300b..c7821ab9 100644 --- a/src/gui/UBThumbnailWidget.cpp +++ b/src/gui/UBThumbnailWidget.cpp @@ -740,25 +740,21 @@ void UBSceneThumbnailNavigPixmap::paint(QPainter *painter, const QStyleOptionGra void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *event) { - // INFO: This implementation should work but this method is not called on a mousePressEvent, why? - // PLEASE DO NOT REMOVE THIS METHOD! We should reactivate this code when we will fix - // the mousePressEvent-not-called issue! - -// QPointF p = event->pos(); - -// // Here we check the position of the click and verify if it has to trig an action or not. -// if(bCanDelete && p.x() >= 0 && p.x() <= BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) -// { -// deletePage(); -// } -// if(bCanMoveUp && p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) -// { -// moveUpPage(); -// } -// if(bCanMoveDown && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 2*(BUTTONSIZE + BUTTONSPACING) + BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) -// { -// moveDownPage(); -// } + QPointF p = event->pos(); + + // Here we check the position of the click and verify if it has to trig an action or not. + if(bCanDelete && p.x() >= 0 && p.x() <= BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) + { + deletePage(); + } + if(bCanMoveUp && p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) + { + moveUpPage(); + } + if(bCanMoveDown && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 2*(BUTTONSIZE + BUTTONSPACING) + BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) + { + moveDownPage(); + } event->accept(); } @@ -809,32 +805,3 @@ void UBSceneThumbnailNavigPixmap::moveDownPage() { UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() + 1); } - -void UBSceneThumbnailNavigPixmap::notifyClick(QPointF clickedScenePos) -{ - QPointF p = clickedPos(clickedScenePos); - - // Here we check the position of the click and verify if it has to trig an action or not. - if(bCanDelete && p.x() >= 0 && p.x() <= BUTTONSIZE/2 && p.y() >= 0 && p.y() <= BUTTONSIZE/2) - { - deletePage(); - } - if(bCanMoveUp && p.x() >= (BUTTONSIZE + BUTTONSPACING)/2 && p.x() <= BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE/2) - { - moveUpPage(); - } - if(bCanMoveDown && p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= BUTTONSIZE + BUTTONSPACING + BUTTONSIZE/2 && p.y() >= 0 && p.y() <= BUTTONSIZE/2) - { - moveDownPage(); - } -} - -QPointF UBSceneThumbnailNavigPixmap::clickedPos(QPointF clickedScenePos) -{ - QPointF p; - - p.setX(clickedScenePos.x() - scenePos().x()); - p.setY(clickedScenePos.y() - scenePos().y()); - - return p; -} diff --git a/src/gui/UBThumbnailWidget.h b/src/gui/UBThumbnailWidget.h index f3f25d6a..ed47869b 100644 --- a/src/gui/UBThumbnailWidget.h +++ b/src/gui/UBThumbnailWidget.h @@ -292,7 +292,6 @@ class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap public: UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex); ~UBSceneThumbnailNavigPixmap(); - void notifyClick(QPointF clickedScenePos); protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event); @@ -305,7 +304,6 @@ class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap void deletePage(); void moveUpPage(); void moveDownPage(); - QPointF clickedPos(QPointF clickedScenePos); bool bButtonsVisible; bool bCanDelete; diff --git a/src/pdf-merger/ASCII85Decode.cpp b/src/pdf-merger/ASCII85Decode.cpp index 1a3d3ac9..640bf5fa 100644 --- a/src/pdf-merger/ASCII85Decode.cpp +++ b/src/pdf-merger/ASCII85Decode.cpp @@ -13,7 +13,7 @@ * along with this program. If not, see . */ #include - +#include #include "ASCII85Decode.h" #include "core/memcheck.h" @@ -51,6 +51,12 @@ void ASCII85Decode::_wput(std::string &cur,unsigned long tuple, int len) } } +bool ASCII85Decode::encode(std::string & decoded) +{ + Q_UNUSED(decoded); + return false; +} + bool ASCII85Decode::decode(std::string &encoded) { unsigned long tuple = 0; @@ -58,7 +64,6 @@ bool ASCII85Decode::decode(std::string &encoded) int count = 0; int size = encoded.size(); int i = 0; - bool found = false; for(;size;) { char ch = encoded[i++]; @@ -121,3 +126,7 @@ bool ASCII85Decode::decode(std::string &encoded) } return true; } +void ASCII85Decode::initialize(Object * objectWithStram) +{ + Q_UNUSED(objectWithStram); +}; diff --git a/src/pdf-merger/ASCII85Decode.h b/src/pdf-merger/ASCII85Decode.h index fb1094f0..a6d7ae3e 100644 --- a/src/pdf-merger/ASCII85Decode.h +++ b/src/pdf-merger/ASCII85Decode.h @@ -26,9 +26,9 @@ namespace merge_lib public: ASCII85Decode(){}; virtual ~ASCII85Decode(){}; - bool encode(std::string & decoded) {return false;} + bool encode(std::string & decoded); bool decode(std::string & encoded); - void initialize(Object * objectWithStram){}; + void initialize(Object * objectWithStram); private: void _wput(std::string &cur,unsigned long tuple, int len); diff --git a/src/pdf-merger/ASCIIHexDecode.cpp b/src/pdf-merger/ASCIIHexDecode.cpp index 17e184ac..93aa990e 100644 --- a/src/pdf-merger/ASCIIHexDecode.cpp +++ b/src/pdf-merger/ASCIIHexDecode.cpp @@ -13,7 +13,7 @@ * along with this program. If not, see . */ #include "ASCIIHexDecode.h" - +#include #include #include "Utils.h" @@ -42,6 +42,12 @@ static unsigned int convertHexVal(unsigned char c) return 0; } +bool ASCIIHexDecode::encode(std::string & decoded) +{ + Q_UNUSED(decoded); + return false; +} + bool ASCIIHexDecode::decode(std::string & encoded) { bool isLow = true; @@ -75,3 +81,8 @@ bool ASCIIHexDecode::decode(std::string & encoded) encoded = decoded; return true; } + +void ASCIIHexDecode::initialize(Object * objectWithStram) +{ + Q_UNUSED(objectWithStram); +} diff --git a/src/pdf-merger/ASCIIHexDecode.h b/src/pdf-merger/ASCIIHexDecode.h index 4b0e4a0b..35c80a36 100644 --- a/src/pdf-merger/ASCIIHexDecode.h +++ b/src/pdf-merger/ASCIIHexDecode.h @@ -26,9 +26,9 @@ namespace merge_lib public: ASCIIHexDecode(){}; virtual ~ASCIIHexDecode(){}; - bool encode(std::string & decoded){return false;} + bool encode(std::string & decoded); bool decode(std::string & encoded); - void initialize(Object * objectWithStram){}; + void initialize(Object * objectWithStram); }; } diff --git a/src/pdf-merger/CCITTFaxDecode.cpp b/src/pdf-merger/CCITTFaxDecode.cpp new file mode 100644 index 00000000..1b9310c9 --- /dev/null +++ b/src/pdf-merger/CCITTFaxDecode.cpp @@ -0,0 +1,36 @@ +/* + * 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 3 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 . + */ + +#include +#include "CCITTFaxDecode.h" + +using namespace merge_lib; + +bool CCITTFaxDecode::encode(std::string & decoded) +{ + Q_UNUSED(decoded); + return true; +} + +bool CCITTFaxDecode::decode(std::string & encoded) +{ + Q_UNUSED(encoded); + return true; +} + +void CCITTFaxDecode::initialize(Object * objectWithStram) +{ + Q_UNUSED(objectWithStram); +} diff --git a/src/pdf-merger/CCITTFaxDecode.h b/src/pdf-merger/CCITTFaxDecode.h index add43139..9bc65ac8 100644 --- a/src/pdf-merger/CCITTFaxDecode.h +++ b/src/pdf-merger/CCITTFaxDecode.h @@ -16,6 +16,8 @@ #define CCITTFaxDecode_H #include +#include "Decoder.h" + namespace merge_lib { // this class provides method for FlateDecode encoding and decoding @@ -24,9 +26,9 @@ namespace merge_lib public: CCITTFaxDecode(){}; virtual ~CCITTFaxDecode(){}; - bool encode(std::string & decoded) {return true;}; - bool decode(std::string & encoded) {return true;}; - void initialize(Object * objectWithStram){}; + bool encode(std::string & decoded); + bool decode(std::string & encoded); + void initialize(Object * objectWithStram); }; } diff --git a/src/pdf-merger/ContentHandler.cpp b/src/pdf-merger/ContentHandler.cpp index 0e298b39..8194524e 100644 --- a/src/pdf-merger/ContentHandler.cpp +++ b/src/pdf-merger/ContentHandler.cpp @@ -12,6 +12,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #include "ContentHandler.h" #include "Filter.h" #include "FlateDecode.h" diff --git a/src/pdf-merger/DCTDecode.cpp b/src/pdf-merger/DCTDecode.cpp new file mode 100644 index 00000000..603926c5 --- /dev/null +++ b/src/pdf-merger/DCTDecode.cpp @@ -0,0 +1,36 @@ +/* + * 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 3 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 . + */ + +#include +#include "DCTDecode.h" + +using namespace merge_lib; + +bool DCTDecode::encode(std::string & decoded) +{ + Q_UNUSED(decoded); + return true; +} + +bool DCTDecode::decode(std::string & encoded) +{ + Q_UNUSED(encoded); + return true; +} + +void DCTDecode::initialize(Object * objectWithStram) +{ + Q_UNUSED(objectWithStram); +} diff --git a/src/pdf-merger/DCTDecode.h b/src/pdf-merger/DCTDecode.h index 011b9520..3e22cdc8 100644 --- a/src/pdf-merger/DCTDecode.h +++ b/src/pdf-merger/DCTDecode.h @@ -16,7 +16,7 @@ #define DCTDecode_H #include - +#include "Decoder.h" namespace merge_lib { // this class provides method for FlateDecode encoding and decoding @@ -25,9 +25,9 @@ namespace merge_lib public: DCTDecode(){}; virtual ~DCTDecode(){}; - bool encode(std::string & decoded) {return true;}; - bool decode(std::string & encoded) {return true;}; - void initialize(Object * objectWithStram){}; + bool encode(std::string & decoded); + bool decode(std::string & encoded); + void initialize(Object * objectWithStram); }; } diff --git a/src/pdf-merger/Document.cpp b/src/pdf-merger/Document.cpp index ac3c0cb8..fad1ee2b 100644 --- a/src/pdf-merger/Document.cpp +++ b/src/pdf-merger/Document.cpp @@ -28,7 +28,8 @@ using namespace merge_lib; const std::string firstObj("%PDF-1.4\n1 0 obj\n<<\n/Title ()/Creator ()/Producer (Qt 4.5.0 (C) 1992-2009 Nokia Corporation and/or its subsidiary(-ies))/CreationDate (D:20090424120829)\n>>\nendobj\n"); const std::string zeroStr("0000000000"); -Document::Document(const char * fileName): _pages(), _maxObjectNumber(0),_root(0),_documentName(fileName) +Document::Document(const char * fileName): + _root(0), _pages(), _documentName(fileName), _maxObjectNumber(0) { } diff --git a/src/pdf-merger/FilterPredictor.cpp b/src/pdf-merger/FilterPredictor.cpp index 4be65d31..b828c515 100644 --- a/src/pdf-merger/FilterPredictor.cpp +++ b/src/pdf-merger/FilterPredictor.cpp @@ -15,6 +15,7 @@ #include "Config.h" #include #include +#include #include "FilterPredictor.h" #include "Utils.h" @@ -49,6 +50,12 @@ FilterPredictor::~FilterPredictor() { } + bool FilterPredictor::encode(std::string & decoded) + { + Q_UNUSED(decoded); + return false; + } + std::string FilterPredictor::getDictionaryContentStr(std::string & in, size_t &pos ) { size_t beg = in.find(DICT_START_TOKEN,pos); diff --git a/src/pdf-merger/FilterPredictor.h b/src/pdf-merger/FilterPredictor.h index 45897d9b..f201fc52 100644 --- a/src/pdf-merger/FilterPredictor.h +++ b/src/pdf-merger/FilterPredictor.h @@ -27,7 +27,7 @@ namespace merge_lib public: FilterPredictor(); virtual ~FilterPredictor(); - bool encode(std::string & decoded){return false;} + bool encode(std::string & decoded); bool decode(std::string & encoded); void initialize(Object * objectWithStream); diff --git a/src/pdf-merger/JBIG2Decode.cpp b/src/pdf-merger/JBIG2Decode.cpp new file mode 100644 index 00000000..6ef248d0 --- /dev/null +++ b/src/pdf-merger/JBIG2Decode.cpp @@ -0,0 +1,36 @@ +/* + * 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 3 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 . + */ + +#include +#include "JBIG2Decode.h" + +using namespace merge_lib; + +bool JBIG2Decode::encode(std::string & decoded) +{ + Q_UNUSED(decoded); + return true; +} + +bool JBIG2Decode::decode(std::string & encoded) +{ + Q_UNUSED(encoded); + return true; +} + +void JBIG2Decode::initialize(Object * objectWithStram) +{ + Q_UNUSED(objectWithStram); +} diff --git a/src/pdf-merger/JBIG2Decode.h b/src/pdf-merger/JBIG2Decode.h index f4ad9e17..4b7e7cbd 100644 --- a/src/pdf-merger/JBIG2Decode.h +++ b/src/pdf-merger/JBIG2Decode.h @@ -16,6 +16,7 @@ #define JBIG2Decode_H #include +#include "Decoder.h" namespace merge_lib { @@ -25,9 +26,9 @@ namespace merge_lib public: JBIG2Decode(){}; virtual ~JBIG2Decode(){}; - bool encode(std::string & decoded) {return true;}; - bool decode(std::string & encoded) {return true;}; - void initialize(Object * objectWithStram){}; + bool encode(std::string & decoded); + bool decode(std::string & encoded); + void initialize(Object * objectWithStram); }; } diff --git a/src/pdf-merger/LZWDecode.cpp b/src/pdf-merger/LZWDecode.cpp index fcc710df..0669dd7b 100644 --- a/src/pdf-merger/LZWDecode.cpp +++ b/src/pdf-merger/LZWDecode.cpp @@ -13,6 +13,7 @@ * along with this program. If not, see . */ #include +#include #include "LZWDecode.h" #include "FilterPredictor.h" @@ -31,8 +32,9 @@ LZWDecode::LZWDecode(): _readBits(0), _nextCode(0), _bitsToRead(0), - _curSequenceLength(0), - _first(true) + _first(true), + _curSequenceLength(0) + { clearTable(); } @@ -44,6 +46,12 @@ LZWDecode::~LZWDecode() } } +bool LZWDecode::encode(std::string & decoded) +{ + Q_UNUSED(decoded); + return true; +} + void LZWDecode::initialize(Object * objectWithStream) { if( objectWithStream ) diff --git a/src/pdf-merger/LZWDecode.h b/src/pdf-merger/LZWDecode.h index 882276ab..6d3d3cf8 100644 --- a/src/pdf-merger/LZWDecode.h +++ b/src/pdf-merger/LZWDecode.h @@ -27,7 +27,7 @@ namespace merge_lib public: LZWDecode(); virtual ~LZWDecode(); - bool encode(std::string & decoded) {return true;}; + bool encode(std::string & decoded); bool decode(std::string & encoded); void initialize(Object * objectWithStram); private: @@ -37,8 +37,8 @@ namespace merge_lib void clearTable(); int getCode(); - std::string &_encoded; std::string _dummy; + std::string &_encoded; size_t _curSymbolIndex; int _earlyChange; // early parameter diff --git a/src/pdf-merger/OverlayDocumentParser.cpp b/src/pdf-merger/OverlayDocumentParser.cpp index 379b63cd..91bf4293 100644 --- a/src/pdf-merger/OverlayDocumentParser.cpp +++ b/src/pdf-merger/OverlayDocumentParser.cpp @@ -15,6 +15,7 @@ #include "OverlayDocumentParser.h" #include #include +#include #include "Exception.h" #include "Object.h" @@ -74,7 +75,6 @@ void OverlayDocumentParser::_readXRefAndCreateObjects() notEndOfFile = false; } - unsigned long toReadAgain = 0; for(objIter = objectsAndPositions.begin(); objIter != objectsAndPositions.end(); ) { if((objectsAndSizes[objIter->first] + objIter->second <= nextPartStart) && (objIter->second >= partStart) && ((objIter->second < nextPartStart))) @@ -100,6 +100,11 @@ void OverlayDocumentParser::_readXRefAndCreateObjects() while(notEndOfFile); } +void OverlayDocumentParser::_getFileContent(const char * fileName) +{ + Q_UNUSED(fileName); +} + void OverlayDocumentParser::_getPartOfFileContent(long startOfPart, unsigned int length) { ifstream pdfFile; diff --git a/src/pdf-merger/OverlayDocumentParser.h b/src/pdf-merger/OverlayDocumentParser.h index fbba57da..d2fa7aec 100644 --- a/src/pdf-merger/OverlayDocumentParser.h +++ b/src/pdf-merger/OverlayDocumentParser.h @@ -38,7 +38,7 @@ namespace merge_lib private: //methods - void _getFileContent(const char * fileName){}; + void _getFileContent(const char * fileName); void _readXRefAndCreateObjects(); void _readXref(std::map & objectsAndSizes); void _getPartOfFileContent(long startOfPart, unsigned int length); diff --git a/src/pdf-merger/Page.cpp b/src/pdf-merger/Page.cpp index 6f3de10f..3cb7c18b 100644 --- a/src/pdf-merger/Page.cpp +++ b/src/pdf-merger/Page.cpp @@ -37,7 +37,7 @@ using namespace merge_lib; -Page::Page(unsigned int pageNumber): _pageNumber(pageNumber),_root(NULL), _rotation(0) +Page::Page(unsigned int pageNumber): _root(NULL),_pageNumber(pageNumber), _rotation(0) { } diff --git a/src/pdf-merger/PageElementHandler.cpp b/src/pdf-merger/PageElementHandler.cpp index c29ada4a..462ea8b7 100644 --- a/src/pdf-merger/PageElementHandler.cpp +++ b/src/pdf-merger/PageElementHandler.cpp @@ -12,8 +12,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "PageElementHandler.h" +#include "PageElementHandler.h" +#include #include "core/memcheck.h" using namespace merge_lib; @@ -88,3 +89,8 @@ unsigned int PageElementHandler::_findEndOfElementContent(unsigned int startOfPa } return _pageContent.rfind(">>"); } + +void PageElementHandler::_processObjectContent(unsigned int startOfPageElement) +{ + Q_UNUSED(startOfPageElement); +} diff --git a/src/pdf-merger/PageElementHandler.h b/src/pdf-merger/PageElementHandler.h index 721476c0..c00cd93e 100644 --- a/src/pdf-merger/PageElementHandler.h +++ b/src/pdf-merger/PageElementHandler.h @@ -73,14 +73,14 @@ namespace merge_lib void _createAllPageFieldsSet(); //members - std::string & _pageContent; Object * _page; + std::string & _pageContent; std::string _handlerName; PageElementHandler * _nextHandler; private: //methods - virtual void _processObjectContent(unsigned int startOfPageElement){}; + virtual void _processObjectContent(unsigned int startOfPageElement); virtual void _changeObjectContent(unsigned int startOfPageElement) = 0; virtual void _pageElementNotFound() {}; unsigned int _findStartOfPageElement() diff --git a/src/pdf-merger/Rectangle.cpp b/src/pdf-merger/Rectangle.cpp index be7c02b5..7fe82696 100644 --- a/src/pdf-merger/Rectangle.cpp +++ b/src/pdf-merger/Rectangle.cpp @@ -24,21 +24,21 @@ using namespace merge_lib; Rectangle::Rectangle(const char * rectangleName): -_rectangleName(rectangleName), x1(0), y1(0), x2(0), y2(0), +_rectangleName(rectangleName), _tm() {} Rectangle::Rectangle(const char * rectangleName, const std::string content): -_rectangleName(rectangleName), x1(0), y1(0), x2(0), -y2(0) +y2(0), +_rectangleName(rectangleName) { unsigned int rectanglePosition = Parser::findToken(content,rectangleName); diff --git a/src/pdf-merger/Rectangle.h b/src/pdf-merger/Rectangle.h index d0484a1d..8941333a 100644 --- a/src/pdf-merger/Rectangle.h +++ b/src/pdf-merger/Rectangle.h @@ -40,7 +40,7 @@ namespace merge_lib double getHeight(); //members - double x1, x2, y1, y2; + double x1, y1, x2, y2; private: //methods const std::string _getRectangleAsString(const char * delimeter); diff --git a/src/pdf-merger/RotationHandler.h b/src/pdf-merger/RotationHandler.h index 285063c9..7b06ae0c 100644 --- a/src/pdf-merger/RotationHandler.h +++ b/src/pdf-merger/RotationHandler.h @@ -15,6 +15,8 @@ #if !defined RotationHandler_h #define RotationHandler_h +#include + #include "PageElementHandler.h" #include "Page.h" @@ -55,7 +57,7 @@ namespace merge_lib strin>>rotation; _basePage.setRotation(rotation); } - virtual void _changeObjectContent(unsigned int startOfPageElement) {}; + virtual void _changeObjectContent(unsigned int startOfPageElement) {Q_UNUSED(startOfPageElement);}; //members Page & _basePage; diff --git a/src/pdf-merger/RunLengthDecode.cpp b/src/pdf-merger/RunLengthDecode.cpp index 33014041..cf5e64c0 100644 --- a/src/pdf-merger/RunLengthDecode.cpp +++ b/src/pdf-merger/RunLengthDecode.cpp @@ -12,12 +12,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "RunLengthDecode.h" +#include "RunLengthDecode.h" +#include #include "core/memcheck.h" using namespace merge_lib; +bool RunLengthDecode::encode(std::string & decoded) +{ + Q_UNUSED(decoded); + return false; +} + /* The encoded data is a sequence of runs, where each run consists of a length byte followed by 1 to 128 bytes of data. If the length byte is in the range 0 to 127, the following length + 1 (1 to 128) bytes @@ -57,3 +64,8 @@ bool RunLengthDecode::decode(std::string & encoded) } return true; } + +void RunLengthDecode::initialize(Object * objectWithStream) +{ + Q_UNUSED(objectWithStream); +}; diff --git a/src/pdf-merger/RunLengthDecode.h b/src/pdf-merger/RunLengthDecode.h index fd429eda..a6af064f 100644 --- a/src/pdf-merger/RunLengthDecode.h +++ b/src/pdf-merger/RunLengthDecode.h @@ -26,9 +26,9 @@ namespace merge_lib public: RunLengthDecode(){}; virtual ~RunLengthDecode(){}; - bool encode(std::string & decoded){return false;} + bool encode(std::string & decoded); bool decode(std::string & encoded); - void initialize(Object * objectWithStream){}; + void initialize(Object * objectWithStream); }; } diff --git a/src/pdf-merger/Utils.cpp b/src/pdf-merger/Utils.cpp index 74b056a4..7f117af8 100644 --- a/src/pdf-merger/Utils.cpp +++ b/src/pdf-merger/Utils.cpp @@ -12,6 +12,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +#include #include "Config.h" #include "Utils.h" #include "Exception.h" @@ -101,6 +103,7 @@ bool Utils::doubleEquals(const double left, const double right, const double eps double Utils::normalizeValue(double &val, const double epsilon ) { + Q_UNUSED(epsilon); if( Utils::doubleEquals(val,0)) { val = 0; diff --git a/src/pdf-merger/pdfMerger.pri b/src/pdf-merger/pdfMerger.pri index 0b0e6e39..b27b90c6 100644 --- a/src/pdf-merger/pdfMerger.pri +++ b/src/pdf-merger/pdfMerger.pri @@ -54,7 +54,10 @@ SOURCES += \ RemoveHimselfHandler.cpp \ RunLengthDecode.cpp \ Utils.cpp \ - OverlayDocumentParser.cpp + OverlayDocumentParser.cpp \ + src/pdf-merger/CCITTFaxDecode.cpp \ + src/pdf-merger/JBIG2Decode.cpp \ + src/pdf-merger/DCTDecode.cpp macx { @@ -82,3 +85,6 @@ linux-g++-64 { LIBS += -lz } + + + diff --git a/src/pdf/XPDFRenderer.h b/src/pdf/XPDFRenderer.h index b8ad475e..3b6d48c3 100644 --- a/src/pdf/XPDFRenderer.h +++ b/src/pdf/XPDFRenderer.h @@ -18,10 +18,15 @@ #include #include "PDFRenderer.h" #include + +#include "globals/UBGlobals.h" + +THIRD_PARTY_WARNINGS_DISABLE #include #include #include #include +THIRD_PARTY_WARNINGS_ENABLE class PDFDoc; diff --git a/src/podcast/youtube/UBYouTubePublisher.cpp b/src/podcast/youtube/UBYouTubePublisher.cpp index f160d4a4..ebd6fb61 100644 --- a/src/podcast/youtube/UBYouTubePublisher.cpp +++ b/src/podcast/youtube/UBYouTubePublisher.cpp @@ -112,6 +112,7 @@ void UBYouTubePublisher::postClientLoginRequest(const QString& userName, const Q void UBYouTubePublisher::postClientLoginResponse(bool success, const QByteArray& pPayload) { + Q_UNUSED(success); mAuthToken = ""; QString auth = QString::fromUtf8(pPayload); @@ -136,7 +137,7 @@ void UBYouTubePublisher::postClientLoginResponse(bool success, const QByteArray& if(mAuthToken.length() == 0) { UBApplication::showMessage(tr("YouTube authentication failed.")); - success = false; +// success = false; deleteLater(); } else diff --git a/src/web/UBOEmbedParser.cpp b/src/web/UBOEmbedParser.cpp index f4247bd0..1cb8e1f8 100644 --- a/src/web/UBOEmbedParser.cpp +++ b/src/web/UBOEmbedParser.cpp @@ -26,6 +26,7 @@ UBOEmbedParser::UBOEmbedParser(QObject *parent, const char* name) { + Q_UNUSED(parent); setObjectName(name); mParsedTitles.clear(); connect(this, SIGNAL(parseContent(QString)), this, SLOT(onParseContent(QString))); @@ -223,7 +224,6 @@ void UBOEmbedParser::onParseContent(QString url) void UBOEmbedParser::onFinished(QNetworkReply *reply) { - QNetworkReply::NetworkError err = reply->error(); if(QNetworkReply::NoError == reply->error()){ QString receivedDatas = reply->readAll().constData(); sOEmbedContent crntContent; diff --git a/src/web/browser/WBSearchLineEdit.cpp b/src/web/browser/WBSearchLineEdit.cpp index cc91b23d..cffca189 100644 --- a/src/web/browser/WBSearchLineEdit.cpp +++ b/src/web/browser/WBSearchLineEdit.cpp @@ -75,7 +75,6 @@ void WBClearButton::paintEvent(QPaintEvent *event) int height = this->height(); painter.setRenderHint(QPainter::Antialiasing, true); - QColor color = palette().color(QPalette::Mid); painter.setBrush(isDown() ? palette().color(QPalette::Dark) : palette().color(QPalette::Mid));