Commit 23bf38ed authored by Yimgo's avatar Yimgo

Merge branch 'master' into widget_fix

parents 880877ae d4072aae
......@@ -15,12 +15,19 @@
# ---------------------------------------------------------------------
MAKE_TAG=true
CREATE_DIENA_DISTRIBUTION_ZIP=false
if [ $# == "1" ]; then
if [ $1 == "notag" ]; then
for var in "$@"
do
if [ $var == "notag" ]; then
MAKE_TAG=false;
fi
fi
if [ $var == "diena" ]; then
CREATE_DIENA_DISTRIBUTION_ZIP=true;
fi
done
notifyError(){
notify-send -t 0 "Error occoured" "An error occours during the sankore build:\n\t$1" -i /usr/share/icons/oxygen/64x64/status/dialog-error.png
......@@ -39,7 +46,6 @@ alertIfPreviousVersionInstalled(){
fi
}
alertIfPreviousVersionInstalled
......@@ -318,11 +324,23 @@ chmod 755 "$BASE_WORKING_DIR/DEBIAN/prerm"
chmod 755 "$BASE_WORKING_DIR/DEBIAN/postint"
mkdir -p "install/linux"
DEBIAN_PACKAGE_NAME="Open-Sankore_${VERSION}_$ARCHITECTURE.deb"
fakeroot chown -R root:root $BASE_WORKING_DIR
dpkg -b "$BASE_WORKING_DIR" install/linux/Open-Sankore_${VERSION}_$ARCHITECTURE.deb
dpkg -b "$BASE_WORKING_DIR" "install/linux/$DEBIAN_PACKAGE_NAME"
notify-send "Open-Sankore" "Package built"
#clean up mess
fakeroot rm -rf $BASE_WORKING_DIR
if [ $CREATE_DIENA_DISTRIBUTION_ZIP == true ]; then
ZIP_NAME="Open-Sankoré_`lsb_release -is`_`lsb_release -rs`_${VERSION}_${ARCHITECTURE}.zip"
cd install/linux
`which zip` -1 --junk-paths ${ZIP_NAME} ${DEBIAN_PACKAGE_NAME} ../../ReleaseNotes.pdf ../../JournalDesModifications.pdf
cd -
notify-send "Open-Sankore" "Build Diena zip file for distribution"
fi
......@@ -21,13 +21,18 @@ notifyError(){
}
MAKE_TAG=true
CREATE_DIENA_DISTRIBUTION_ZIP=false
if [ $# == "1" ]; then
if [ $1 == "notag" ]; then
for var in "$@"
do
if [ $var == "notag" ]; then
MAKE_TAG=false;
fi
fi
if [ $var == "diena" ]; then
CREATE_DIENA_DISTRIBUTION_ZIP=true;
fi
done
alertIfPreviousVersionInstalled(){
APT_CACHE=`which apt-cache`
......@@ -320,11 +325,21 @@ chmod 755 "$BASE_WORKING_DIR/DEBIAN/prerm"
chmod 755 "$BASE_WORKING_DIR/DEBIAN/postint"
mkdir -p "install/linux"
DEBIAN_PACKAGE_NAME="Open-Sankore_${VERSION}_$ARCHITECTURE.deb"
fakeroot chown -R root:root $BASE_WORKING_DIR
dpkg -b "$BASE_WORKING_DIR" install/linux/Open-Sankore_${VERSION}_$ARCHITECTURE.deb
dpkg -b "$BASE_WORKING_DIR" "install/linux/$DEBIAN_PACKAGE_NAME"
notify-send "Open-Sankore" "Package built"
#clean up mess
fakeroot rm -rf $BASE_WORKING_DIR
if [ $CREATE_DIENA_DISTRIBUTION_ZIP == true ]; then
ZIP_NAME="Open-Sankoré_`lsb_release -is`_`lsb_release -rs`_${VERSION}_${ARCHITECTURE}.zip"
cd install/linux
`which zip` -1 --junk-paths ${ZIP_NAME} ${DEBIAN_PACKAGE_NAME} ../../ReleaseNotes.pdf ../../JournalDesModifications.pdf
cd -
notify-send "Open-Sankore" "Build Diena zip file for distribution"
fi
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<teacherGuide>
<gradeLevels>
<gradeLevel label="" baseLevel="Maternelle"/>
<gradeLevel label="Petite Section (3-4 ans)" baseLevel="Maternelle"/>
<gradeLevel label="Moyenne Section (4-5 ans)" baseLevel="Maternelle"/>
<gradeLevel label="Grande Section (5-6 ans)" baseLevel="Maternelle"/>
......@@ -22,6 +23,7 @@
<gradeLevel label="Education Spécialisée" baseLevel="Enseignement Professionnel" />
</gradeLevels>
<subjects baseLevel="Maternelle">
<subject label="" />
<subject label="Percevoir, sentir, imaginer, créer" />
<subject label="Découvrir l'écrit" />
<subject label="S'approprier le langage" />
......@@ -29,6 +31,7 @@
<subject label="Découvrir le monde" />
</subjects>
<subjects baseLevel="Elémentaire">
<subject label="" />
<subject label="Pratiques artistiques" />
<subject label="Pratiques artistiques - arts visuels" />
<subject label="Pratiques artistiques - éducation musicale" />
......@@ -50,6 +53,7 @@
<subject label="TUIC" />
</subjects>
<subjects baseLevel="Collège">
<subject label="" />
<subject label="Pratiques artistiques" />
<subject label="Pratiques artistiques - arts visuels" />
<subject label="Pratiques artistiques - éducation musicale" />
......@@ -80,6 +84,7 @@
<subject label="Education aux médias" />
</subjects>
<subjects baseLevel="Lycée">
<subject label="" />
<subject label="Enseignements artistiques" />
<subject label="Agriculture" />
<subject label="Arts" />
......@@ -125,6 +130,7 @@
<subject label="Philosophie" />
</subjects>
<subjects baseLevel="Enseignement Professionnel">
<subject label="" />
<subject label="Enseignements artistiques" />
<subject label="Agriculture" />
<subject label="Arts" />
......@@ -169,6 +175,7 @@
<subject label="Philosophie" />
</subjects>
<types>
<type label="" />
<type label="Activité : Evaluation/Travail à la maison" />
<type label="Activité : Exercice" />
<type label="Activité : Travaux Pratiques" />
......
*
{
color: #3F3F3F;
}
QMainWindow
{
background-color: #F1F1F1;
}
......
......@@ -700,11 +700,11 @@ function addContainer(){
var close = $("<div class='close_cont'>").appendTo(container);
var number = $("<div class='number_cont'>"+ ($(".cont").size() + 1) +"</div>").appendTo(sub_container);
var text = $("<div class='text_cont'>").appendTo(sub_container);
text.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('gray'); return false;")
.attr("ondragover", "$(this).addClass('gray'); return false;")
.attr("ondrop", "$(this).removeClass('gray'); return onDropAudio(this,event);");
var audio_block = $("<div class='audio_block'>").appendTo(text);
audio_block.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('audio_gray'); return false;")
.attr("ondragover", "$(this).addClass('audio_gray'); return false;")
.attr("ondrop", "$(this).removeClass('audio_gray'); return onDropAudio(this,event);");
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", "");
......
......@@ -685,11 +685,11 @@ function addContainer(){
var close = $("<div class='close_cont'>").appendTo(container);
var number = $("<div class='number_cont'>"+ ($(".cont").size() + 1) +"</div>").appendTo(sub_container);
var text = $("<div class='text_cont'>").appendTo(sub_container);
text.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('gray'); return false;")
.attr("ondragover", "$(this).addClass('gray'); return false;")
.attr("ondrop", "$(this).removeClass('gray'); return onDropAudio(this,event);");
var audio_block = $("<div class='audio_block'>").appendTo(text);
audio_block.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('audio_gray'); return false;")
.attr("ondragover", "$(this).addClass('audio_gray'); return false;")
.attr("ondrop", "$(this).removeClass('audio_gray'); return onDropAudio(this,event);");
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", "");
......@@ -850,8 +850,8 @@ function onDropAudio(obj, event) {
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $(obj).find(".audio_block");
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $(obj);
$(obj).find("audio").remove();
audio_block.find(":first-child").removeClass("stop").addClass("play");
var source = $("<source/>").attr("src", "../../" + tmp);
......
......@@ -685,11 +685,11 @@ function addContainer(){
var close = $("<div class='close_cont'>").appendTo(container);
var number = $("<div class='number_cont'>"+ ($(".cont").size() + 1) +"</div>").appendTo(sub_container);
var text = $("<div class='text_cont'>").appendTo(sub_container);
text.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('gray'); return false;")
.attr("ondragover", "$(this).addClass('gray'); return false;")
.attr("ondrop", "$(this).removeClass('gray'); return onDropAudio(this,event);");
var audio_block = $("<div class='audio_block'>").appendTo(text);
audio_block.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('audio_gray'); return false;")
.attr("ondragover", "$(this).addClass('audio_gray'); return false;")
.attr("ondrop", "$(this).removeClass('audio_gray'); return onDropAudio(this,event);");
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", "");
......@@ -851,7 +851,7 @@ function onDropAudio(obj, event) {
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $(obj).find(".audio_block");
var audio_block = $(obj);
$(obj).find("audio").remove();
audio_block.find(":first-child").removeClass("stop").addClass("play");
var source = $("<source/>").attr("src", "../../" + tmp);
......
......@@ -4,6 +4,7 @@ html, body{
margin: 0;
padding: 0;
border-radius: 50px;
overflow: hidden;
}
body{
......@@ -212,6 +213,7 @@ li>div{
.real_text{
width: 100%;
height: 100%;
word-wrap: break-word;
}
.block_border{
......@@ -357,7 +359,6 @@ li>div{
#wgt_name{
height: 44px;
width: 200px;
margin: 10px 10px 0 10px;
padding: 0;
float: left;
......@@ -366,9 +367,8 @@ li>div{
color: #8c5730;
}
#wgt_reload, #wgt_edit, #wgt_display{
#wgt_reload, #wgt_edit, #wgt_display, #wgt_help{
cursor: pointer;
width: 80px;
height: 44px;
margin: 10px 10px 0 0;
float: right;
......@@ -378,7 +378,6 @@ li>div{
}
#wgt_display{
width: 100px;
padding-left: 40px;
background-image: url(../img/slate-edit.png);
background-repeat: no-repeat;
......@@ -387,7 +386,6 @@ li>div{
}
#wgt_edit{
width: 100px;
padding-left: 40px;
background-image: url(../img/slate-edit.png);
background-repeat: no-repeat;
......@@ -479,4 +477,28 @@ li>div{
background-color: #333 !important;
color: white !important;
background-image: url(../img/ar_down_white.png) !important;
}
.pad_help{
background-image: url(../img/slate-help-white.png) !important;
}
#wgt_help{
padding-left: 32px;
background-image: url(../img/slate-help.png);
background-repeat: no-repeat;
background-position: top 0;
}
#help{
width: 100%;
height: 100%;
overflow: auto;
display: none;
background-color: #ccc;
padding: 5px 0 5px 5px;
}
.open{
}
\ No newline at end of file
......@@ -48,7 +48,8 @@
<tr style="height: 54px;">
<td class="b_top_left">&nbsp;</td>
<td class="b_top_center">
<div id="wgt_name"></div>
<div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div>
<select class="style_select">
......@@ -59,10 +60,11 @@
</td>
<td class="b_top_right">&nbsp;</td>
</tr>
<tr>
<td class="b_center_left">&nbsp;</td>
<td>
<div id="help"></div>
<div id="slider">
<ul>
</ul>
......@@ -72,7 +74,7 @@
</td>
<td class="b_center_right">&nbsp;</td>
</tr>
<tr style="height: 54px;">
<td class="b_bottom_left">&nbsp;</td>
<td class="b_bottom_center">&nbsp;</td>
......
......@@ -7,7 +7,9 @@ var sankoreLang = {
wgt_name: "Slider",
slate: "Wood",
pad: "Pad",
none: "None"
none: "None",
help: "Help",
help_content: "This is an example of help content ..."
};
//some flags
......@@ -27,6 +29,8 @@ function start(){
$("#wgt_display").text(sankoreLang.display);
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_help").text(sankoreLang.help);
$("#help").html(sankoreLang.help_content);
$(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none);
......@@ -50,11 +54,13 @@ function start(){
//events
if (window.widget) {
window.widget.onleave = function(){
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
if(!$("#wgt_help").hasClass("open")){
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
}
}
}
......@@ -62,6 +68,24 @@ function start(){
changeStyle($(this).find("option:selected").val());
})
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").hide();
tmp.removeClass("open");
$("#slider").show();
} else {
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
$("#slider").hide();
$("#help").show();
tmp.addClass("open");
}
});
$("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){
if(!$(this).hasClass("selected")){
......@@ -124,9 +148,9 @@ function start(){
$("#slider li>div").each(function(){
var container = $(this);
container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background\",\"none\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
.attr("ondrop", "$(this).css(\"background\",\"none\"); return onDropTarget(this,event);");
container.find(".text_block").each(function(){
$(this).draggable("destroy");
......@@ -156,6 +180,7 @@ function start(){
$("<div class='add_right'>").appendTo(container);
$("<div class='close_slide'>").appendTo(container);
$("<div class='add_text'>").appendTo(container);
$(window).trigger("resize")
});
$(this).css("display", "none");
$("#wgt_display").css("display", "block");
......@@ -264,15 +289,15 @@ function start(){
$("li>div").live("mousemove", function(){
if(resize_obj.clicked){
if(resize_obj.object.parent().hasClass("text_block")){
if(resize_obj.object.parent().hasClass("text_block")){
var width = resize_obj.object.parent().width() - resize_obj.left + event.clientX;
var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
//var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
resize_obj.left = event.clientX;
resize_obj.top = event.clientY;
resize_obj.object.parent().width(width).height(height);
resize_obj.object.parent().width(width).height("");
} else {
width = resize_obj.object.parent().width() - resize_obj.left + event.clientX;
height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
var img_width = resize_obj.object.parent().find("img").width() - resize_obj.left + event.clientX;
var img_height = resize_obj.object.parent().find("img").height() - resize_obj.top + event.clientY;
resize_obj.left = event.clientX;
......@@ -296,12 +321,15 @@ function start(){
new_li.width(cur_li.width()).height(cur_li.height()).css("float","left");
var new_div = $("<div>").appendTo(new_li);
new_div.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' contenteditable='true'>" + sankoreLang.new_slide + "</div>").addClass("block_border");
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' style='position: absolute;'>").addClass("block_border");
$("<div class='real_text' contenteditable='true'>" + sankoreLang.new_slide + "</div>").appendTo(example);
$("<div class='move_block' contenteditable='false'>").appendTo(example);
$("<div class='close_img' contenteditable='false'>").appendTo(example);
$("<div class='size_up' contenteditable='false'>").appendTo(example);
$("<div class='size_down' contenteditable='false'>").appendTo(example);
$("<div class='resize_block' contenteditable='false'>").appendTo(example);
example.css("top","40%").css("left","40%");
new_div.append(example);
......@@ -319,12 +347,15 @@ function start(){
new_li.width(cur_li.width()).height(cur_li.height()).css("float","left");
var new_div = $("<div>").appendTo(new_li);
new_div.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' contenteditable='true'>" + sankoreLang.new_slide + "</div>").addClass("block_border");
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' style='position: absolute;'>").addClass("block_border");
$("<div class='real_text' contenteditable='true'>" + sankoreLang.new_slide + "</div>").appendTo(example);
$("<div class='move_block' contenteditable='false'>").appendTo(example);
$("<div class='close_img' contenteditable='false'>").appendTo(example);
$("<div class='size_up' contenteditable='false'>").appendTo(example);
$("<div class='size_down' contenteditable='false'>").appendTo(example);
$("<div class='resize_block' contenteditable='false'>").appendTo(example);
example.css("top","40%").css("left","40%");
new_div.append(example);
......@@ -360,7 +391,6 @@ function exportData(){
var txt_block = new Object();
txt_block.top = $(this).position().top;
txt_block.left = $(this).position().left;
txt_block.h = $(this).height();
txt_block.w = $(this).width();
txt_block.fz = $(this).css("font-size");
txt_block.val = $(this).find(".real_text").html();
......@@ -408,7 +438,6 @@ function importData(data){
var text_div = $("<div class='text_block'><div class='real_text'>" + data[i].text[j].val + "</div></div>");
text_div.draggable().css("position","absolute")
.width(data[i].text[j].w)
.height(data[i].text[j].h)
.css("top", data[i].text[j].top)
.css("left", data[i].text[j].left)
.css("font-size", data[i].text[j].fz)
......@@ -525,7 +554,7 @@ function changeStyle(val){
$(".b_bottom_right").removeClass("bbr_pad").removeClass("without_back");
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_help").removeClass("pad_color").removeClass("pad_help");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color");
......@@ -541,7 +570,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("bbr_pad").removeClass("without_back");
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
......@@ -557,7 +586,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_pad");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
......@@ -580,7 +609,7 @@ function onDropTarget(obj, event) {
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $("<div class='audio_block'>").draggable().appendTo($(obj));
audio_block.css("position","absolute").css("top",event.clientY).css("left",event.clientX);
audio_block.css("position","absolute").css("top",event.clientY - 54).css("left",event.clientX - 54);
$("<div class='close_img' contenteditable='false'>").appendTo(audio_block);
audio_block.addClass("block_border");
$("<div class='play'>").appendTo(audio_block);
......@@ -590,7 +619,7 @@ function onDropTarget(obj, event) {
audio.append(source);
} else {
var img_block = $("<div class='img_block' style='text-align: center;'></div>").appendTo($(obj));
img_block.css("top",event.clientY).css("left",event.clientX);
img_block.css("top",event.clientY - 54).css("left",event.clientX - 54);
$("<div class='move_block' contenteditable='false'>").appendTo(img_block);
$("<div class='close_img' contenteditable='false'>").appendTo(img_block);
$("<div class='resize_block' contenteditable='false'>").appendTo(img_block);
......
......@@ -22,7 +22,8 @@
<tr style="height: 54px;">
<td class="b_top_left">&nbsp;</td>
<td class="b_top_center">
<div id="wgt_name"></div>
<div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div>
<select class="style_select">
......@@ -33,10 +34,11 @@
</td>
<td class="b_top_right">&nbsp;</td>
</tr>
<tr>
<td class="b_center_left">&nbsp;</td>
<td>
<div id="help"></div>
<div id="slider">
<ul>
</ul>
......@@ -46,7 +48,7 @@
</td>
<td class="b_center_right">&nbsp;</td>
</tr>
<tr style="height: 54px;">
<td class="b_bottom_left">&nbsp;</td>
<td class="b_bottom_center">&nbsp;</td>
......
......@@ -7,7 +7,9 @@ var sankoreLang = {
wgt_name: "Etudier",
slate: "Bois",
pad: "Pad",
none: "Aucun"
none: "Aucun",
help: "Aide",
help_content: "Ceci est un exemple de contenu de l'aide ..."
};
//some flags
......@@ -27,6 +29,8 @@ function start(){
$("#wgt_display").text(sankoreLang.display);
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_help").text(sankoreLang.help);
$("#help").html(sankoreLang.help_content);
$(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none);
......@@ -50,11 +54,13 @@ function start(){
//events
if (window.widget) {
window.widget.onleave = function(){
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
if(!$("#wgt_help").hasClass("open")){
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
}
}
}
......@@ -62,6 +68,24 @@ function start(){
changeStyle($(this).find("option:selected").val());
})
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").hide();
tmp.removeClass("open");
$("#slider").show();
} else {
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
$("#slider").hide();
$("#help").show();
tmp.addClass("open");
}
});
$("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){
if(!$(this).hasClass("selected")){
......@@ -124,9 +148,9 @@ function start(){
$("#slider li>div").each(function(){
var container = $(this);
container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background\",\"none\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
.attr("ondrop", "$(this).css(\"background\",\"none\"); return onDropTarget(this,event);");
container.find(".text_block").each(function(){
$(this).draggable("destroy");
......@@ -156,6 +180,7 @@ function start(){
$("<div class='add_right'>").appendTo(container);
$("<div class='close_slide'>").appendTo(container);
$("<div class='add_text'>").appendTo(container);
$(window).trigger("resize")
});
$(this).css("display", "none");
$("#wgt_display").css("display", "block");
......@@ -266,13 +291,13 @@ function start(){
if(resize_obj.clicked){
if(resize_obj.object.parent().hasClass("text_block")){
var width = resize_obj.object.parent().width() - resize_obj.left + event.clientX;
var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
//var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
resize_obj.left = event.clientX;
resize_obj.top = event.clientY;
resize_obj.object.parent().width(width).height(height);
resize_obj.object.parent().width(width);
} else {
width = resize_obj.object.parent().width() - resize_obj.left + event.clientX;
height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
var img_width = resize_obj.object.parent().find("img").width() - resize_obj.left + event.clientX;
var img_height = resize_obj.object.parent().find("img").height() - resize_obj.top + event.clientY;
resize_obj.left = event.clientX;
......@@ -296,12 +321,15 @@ function start(){
new_li.width(cur_li.width()).height(cur_li.height()).css("float","left");
var new_div = $("<div>").appendTo(new_li);
new_div.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' contenteditable='true'>" + sankoreLang.new_slide + "</div>").addClass("block_border");
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' style='position: absolute;'>").addClass("block_border");
$("<div class='real_text' contenteditable='true'>" + sankoreLang.new_slide + "</div>").appendTo(example);
$("<div class='move_block' contenteditable='false'>").appendTo(example);
$("<div class='close_img' contenteditable='false'>").appendTo(example);
$("<div class='size_up' contenteditable='false'>").appendTo(example);
$("<div class='size_down' contenteditable='false'>").appendTo(example);
$("<div class='resize_block' contenteditable='false'>").appendTo(example);
example.css("top","40%").css("left","40%");
new_div.append(example);
......@@ -319,12 +347,15 @@ function start(){
new_li.width(cur_li.width()).height(cur_li.height()).css("float","left");
var new_div = $("<div>").appendTo(new_li);
new_div.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' contenteditable='true'>" + sankoreLang.new_slide + "</div>").addClass("block_border");
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' style='position: absolute;'>").addClass("block_border");
$("<div class='real_text' contenteditable='true'>" + sankoreLang.new_slide + "</div>").appendTo(example);
$("<div class='move_block' contenteditable='false'>").appendTo(example);
$("<div class='close_img' contenteditable='false'>").appendTo(example);
$("<div class='size_up' contenteditable='false'>").appendTo(example);
$("<div class='size_down' contenteditable='false'>").appendTo(example);
$("<div class='resize_block' contenteditable='false'>").appendTo(example);
example.css("top","40%").css("left","40%");
new_div.append(example);
......@@ -360,7 +391,6 @@ function exportData(){
var txt_block = new Object();
txt_block.top = $(this).position().top;
txt_block.left = $(this).position().left;
txt_block.h = $(this).height();
txt_block.w = $(this).width();
txt_block.fz = $(this).css("font-size");
txt_block.val = $(this).find(".real_text").html();
......@@ -408,7 +438,6 @@ function importData(data){
var text_div = $("<div class='text_block'><div class='real_text'>" + data[i].text[j].val + "</div></div>");
text_div.draggable().css("position","absolute")
.width(data[i].text[j].w)
.height(data[i].text[j].h)
.css("top", data[i].text[j].top)
.css("left", data[i].text[j].left)
.css("font-size", data[i].text[j].fz)
......@@ -526,7 +555,7 @@ function changeStyle(val){
$(".b_bottom_right").removeClass("bbr_pad").removeClass("without_back");
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_help").removeClass("pad_color").removeClass("pad_help");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color");
......@@ -542,7 +571,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("bbr_pad").removeClass("without_back");
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
......@@ -558,7 +587,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_pad");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
......@@ -581,7 +610,7 @@ function onDropTarget(obj, event) {
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $("<div class='audio_block'>").draggable().appendTo($(obj));
audio_block.css("position","absolute").css("top",event.clientY).css("left",event.clientX);
audio_block.css("position","absolute").css("top",event.clientY - 54).css("left",event.clientX - 54);
$("<div class='close_img' contenteditable='false'>").appendTo(audio_block);
audio_block.addClass("block_border");
$("<div class='play'>").appendTo(audio_block);
......@@ -591,7 +620,7 @@ function onDropTarget(obj, event) {
audio.append(source);
} else {
var img_block = $("<div class='img_block' style='text-align: center;'></div>").appendTo($(obj));
img_block.css("top",event.clientY).css("left",event.clientX);
img_block.css("top",event.clientY - 54).css("left",event.clientX - 54);
$("<div class='move_block' contenteditable='false'>").appendTo(img_block);
$("<div class='close_img' contenteditable='false'>").appendTo(img_block);
$("<div class='resize_block' contenteditable='false'>").appendTo(img_block);
......
......@@ -22,7 +22,8 @@
<tr style="height: 54px;">
<td class="b_top_left">&nbsp;</td>
<td class="b_top_center">
<div id="wgt_name"></div>
<div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div>
<select class="style_select">
......@@ -33,10 +34,11 @@
</td>
<td class="b_top_right">&nbsp;</td>
</tr>
<tr>
<td class="b_center_left">&nbsp;</td>
<td>
<div id="help"></div>
<div id="slider">
<ul>
</ul>
......@@ -46,7 +48,7 @@
</td>
<td class="b_center_right">&nbsp;</td>
</tr>
<tr style="height: 54px;">
<td class="b_bottom_left">&nbsp;</td>
<td class="b_bottom_center">&nbsp;</td>
......
......@@ -7,7 +7,9 @@ var sankoreLang = {
wgt_name: "Слайдер",
slate: "Узор",
pad: "Планшет",
none: "Нет"
none: "Нет",
help: "Помощь",
help_content: "Пример текста помощи ..."
};
//some flags
......@@ -27,6 +29,8 @@ function start(){
$("#wgt_display").text(sankoreLang.display);
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_help").text(sankoreLang.help);
$("#help").html(sankoreLang.help_content);
$(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none);
......@@ -50,11 +54,13 @@ function start(){
//events
if (window.widget) {
window.widget.onleave = function(){
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
if(!$("#wgt_help").hasClass("open")){
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
}
}
}
......@@ -62,6 +68,24 @@ function start(){
changeStyle($(this).find("option:selected").val());
})
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").hide();
tmp.removeClass("open");
$("#slider").show();
} else {
exportData();
sankore.setPreference("etudier_style", $(".style_select").find("option:selected").val());
sankore.setPreference("etudier_cur_page", $("#slider").getPage());
sankore.setPreference("etudier_left_nav", $("#prevBtn a").css("display"));
sankore.setPreference("etudier_right_nav", $("#nextBtn a").css("display"));
$("#slider").hide();
$("#help").show();
tmp.addClass("open");
}
});
$("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){
if(!$(this).hasClass("selected")){
......@@ -123,9 +147,9 @@ function start(){
$("#slider li>div").each(function(){
var container = $(this);
container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background\",\"none\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
.attr("ondrop", "$(this).css(\"background\",\"none\"); return onDropTarget(this,event);");
container.find(".text_block").each(function(){
$(this).draggable("destroy");
......@@ -154,6 +178,7 @@ function start(){
$("<div class='add_right'>").appendTo(container);
$("<div class='close_slide'>").appendTo(container);
$("<div class='add_text'>").appendTo(container);
$(window).trigger("resize")
});
$(this).css("display", "none");
$("#wgt_display").css("display", "block");
......@@ -264,13 +289,13 @@ function start(){
if(resize_obj.clicked){
if(resize_obj.object.parent().hasClass("text_block")){
var width = resize_obj.object.parent().width() - resize_obj.left + event.clientX;
var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
//var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
resize_obj.left = event.clientX;
resize_obj.top = event.clientY;
resize_obj.object.parent().width(width).height(height);
resize_obj.object.parent().width(width).height("");
} else {
width = resize_obj.object.parent().width() - resize_obj.left + event.clientX;
height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
var img_width = resize_obj.object.parent().find("img").width() - resize_obj.left + event.clientX;
var img_height = resize_obj.object.parent().find("img").height() - resize_obj.top + event.clientY;
resize_obj.left = event.clientX;
......@@ -294,12 +319,15 @@ function start(){
new_li.width(cur_li.width()).height(cur_li.height()).css("float","left");
var new_div = $("<div>").appendTo(new_li);
new_div.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' contenteditable='true'>" + sankoreLang.new_slide + "</div>").addClass("block_border");
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' style='position: absolute;'>").addClass("block_border");
$("<div class='real_text' contenteditable='true'>" + sankoreLang.new_slide + "</div>").appendTo(example);
$("<div class='move_block' contenteditable='false'>").appendTo(example);
$("<div class='close_img' contenteditable='false'>").appendTo(example);
$("<div class='size_up' contenteditable='false'>").appendTo(example);
$("<div class='size_down' contenteditable='false'>").appendTo(example);
$("<div class='resize_block' contenteditable='false'>").appendTo(example);
example.css("top","40%").css("left","40%");
new_div.append(example);
......@@ -317,12 +345,15 @@ function start(){
new_li.width(cur_li.width()).height(cur_li.height()).css("float","left");
var new_div = $("<div>").appendTo(new_li);
new_div.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"white\"); return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#ccc\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"white\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' contenteditable='true'>" + sankoreLang.new_slide + "</div>").addClass("block_border");
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
var example = $("<div class='text_block' style='position: absolute;'>").addClass("block_border");
$("<div class='real_text' contenteditable='true'>" + sankoreLang.new_slide + "</div>").appendTo(example);
$("<div class='move_block' contenteditable='false'>").appendTo(example);
$("<div class='close_img' contenteditable='false'>").appendTo(example);
$("<div class='size_up' contenteditable='false'>").appendTo(example);
$("<div class='size_down' contenteditable='false'>").appendTo(example);
$("<div class='resize_block' contenteditable='false'>").appendTo(example);
example.css("top","40%").css("left","40%");
new_div.append(example);
......@@ -358,7 +389,6 @@ function exportData(){
var txt_block = new Object();
txt_block.top = $(this).position().top;
txt_block.left = $(this).position().left;
txt_block.h = $(this).height();
txt_block.w = $(this).width();
txt_block.fz = $(this).css("font-size");
txt_block.val = $(this).text();
......@@ -406,7 +436,6 @@ function importData(data){
var text_div = $("<div class='text_block'>" + data[i].text[j].val + "</div>");
text_div.draggable().css("position","absolute")
.width(data[i].text[j].w)
.height(data[i].text[j].h)
.css("top", data[i].text[j].top)
.css("left", data[i].text[j].left)
.css("font-size", data[i].text[j].fz)
......@@ -524,7 +553,7 @@ function changeStyle(val){
$(".b_bottom_right").removeClass("bbr_pad").removeClass("without_back");
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_help").removeClass("pad_color").removeClass("pad_help");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color");
......@@ -540,7 +569,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("bbr_pad").removeClass("without_back");
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
......@@ -556,7 +585,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_pad");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
......@@ -579,7 +608,7 @@ function onDropTarget(obj, event) {
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $("<div class='audio_block'>").draggable().appendTo($(obj));
audio_block.css("position","absolute").css("top",event.clientY).css("left",event.clientX);
audio_block.css("position","absolute").css("top",event.clientY - 54).css("left",event.clientX - 54);
$("<div class='close_img' contenteditable='false'>").appendTo(audio_block);
audio_block.addClass("block_border");
$("<div class='play'>").appendTo(audio_block);
......@@ -589,7 +618,7 @@ function onDropTarget(obj, event) {
audio.append(source);
} else {
var img_block = $("<div class='img_block' style='text-align: center;'></div>").appendTo($(obj));
img_block.css("top",event.clientY).css("left",event.clientX);
img_block.css("top",event.clientY - 54).css("left",event.clientX - 54);
$("<div class='move_block' contenteditable='false'>").appendTo(img_block);
$("<div class='close_img' contenteditable='false'>").appendTo(img_block);
$("<div class='resize_block' contenteditable='false'>").appendTo(img_block);
......
......@@ -5,7 +5,9 @@ QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget,
QWidget#UBTeacherGuideWidget,
QWidget#UBFeatureProperties
QWidget#UBFeatureProperties,
QWidget#UBFeaturesNavigatorWidget,
QWidget#PathList
{
background: #EEEEEE;
border-radius: 10px;
......@@ -26,14 +28,13 @@ QWidget#UBLibWebView
border: 2px solid #999999;
}
QWidget#UBFeaturesWebView
QListView
{
background: #EEEEEE;
border-radius : 10px;
border: 2px solid #999999;
border: 0px;
}
QListView
QWidget#UBFeaturesWebView
{
background: #EEEEEE;
border-radius : 10px;
......
......@@ -80,7 +80,7 @@ bool UBImportPDF::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFi
for(int pdfPageNumber = 1; pdfPageNumber <= pdfPageCount; pdfPageNumber++)
{
int pageIndex = documentPageCount + (pdfPageNumber - 1);
int pageIndex = documentPageCount + pdfPageNumber;
UBApplication::showMessage(tr("Importing page %1 of %2").arg(pdfPageNumber).arg(pdfPageCount), true);
UBGraphicsScene* scene = 0;
......
......@@ -45,6 +45,7 @@
#include "board/UBBoardView.h"
#include "board/UBBoardController.h"
#include "board/UBDrawingController.h"
#include "board/UBBoardPaletteManager.h"
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBStringUtils.h"
......@@ -54,6 +55,9 @@
#include "core/UBPersistenceManager.h"
#include "core/UBApplication.h"
#include "gui/UBTeacherGuideWidget.h"
#include "gui/UBDockTeacherGuideWidget.h"
#include "interfaces/IDataStorage.h"
#include "document/UBDocumentContainer.h"
......@@ -1142,7 +1146,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement()
bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
{
if (mScene->isModified())
if (mScene->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()))
{
//Creating dom structure to store information
......
......@@ -38,6 +38,9 @@
#include "gui/UBToolWidget.h"
#include "gui/UBKeyboardPalette.h"
#include "gui/UBMagnifer.h"
#include "gui/UBDockPaletteWidget.h"
#include "gui/UBDockTeacherGuideWidget.h"
#include "gui/UBTeacherGuideWidget.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsItemUndoCommand.h"
......@@ -1464,7 +1467,10 @@ void UBBoardController::lastWindowClosed()
{
if (!mCleanupDone)
{
if (selectedDocument()->pageCount() == 1 && (!mActiveScene || mActiveScene->isEmpty()))
bool teacherGuideModified = false;
if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget())
teacherGuideModified = UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified();
if (selectedDocument()->pageCount() == 1 && (!mActiveScene || mActiveScene->isEmpty()) && !teacherGuideModified)
{
UBPersistenceManager::persistenceManager()->deleteDocument(selectedDocument());
}
......@@ -1591,7 +1597,7 @@ void UBBoardController::persistCurrentScene()
if(UBPersistenceManager::persistenceManager()
&& selectedDocument() && mActiveScene
&& (mActiveSceneIndex >= 0)
&& mActiveScene->isModified())
&& (mActiveScene->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified())))
{
emit activeSceneWillBePersisted();
......
......@@ -83,9 +83,9 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mPendingPanButtonPressed(false)
, mPendingEraseButtonPressed(false)
, mpPageNavigWidget(NULL)
#ifdef USE_WEB_WIDGET
//#ifdef USE_WEB_WIDGET
, mpLibWidget(NULL)
#endif
//#endif
, mpCachePropWidget(NULL)
, mpDownloadWidget(NULL)
, mpDesktopLibWidget(NULL)
......@@ -134,6 +134,8 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
//------------------------------------------------//
// Create the widgets for the dock palettes
mpPageNavigWidget = new UBPageNavigationWidget();
#ifdef USE_WEB_WIDGET
mpLibWidget = new UBLibWidget();
#endif
......
......@@ -69,6 +69,8 @@ class UBBoardPaletteManager : public QObject
void setCurrentWebToolsPalette(UBWebToolsPalette *palette) {mWebToolsCurrentPalette = palette;}
UBWebToolsPalette* mWebToolsCurrentPalette;
UBDockTeacherGuideWidget* teacherGuideDockWidget() { return mpTeacherGuideWidget;}
void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode);
void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false);
void startDownloads();
......@@ -135,10 +137,10 @@ class UBBoardPaletteManager : public QObject
/** The page navigator widget */
UBPageNavigationWidget* mpPageNavigWidget;
#ifdef USE_WEB_WIDGET
//#ifdef USE_WEB_WIDGET
/** The library widget */
UBLibWidget* mpLibWidget;
#endif
//#endif
/** The cache properties widget */
UBCachePropertiesWidget* mpCachePropWidget;
......
......@@ -28,7 +28,7 @@ class UBRubberBand;
class UBBoardView : public QGraphicsView
{
Q_OBJECT;
Q_OBJECT
public:
......
......@@ -65,6 +65,10 @@ class UBDrawingController : public QObject
mIsDesktopMode = mode;
}
bool isInDesktopMode(){
return mIsDesktopMode;
}
public slots:
void setStylusTool(int tool);
......
......@@ -18,24 +18,37 @@
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "gui/UBFeaturesWidget.h"
const QString UBFeaturesController::virtualRootName = "root";
UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type)
: virtualPath(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type)
: virtualDir(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type)
{
}
UBFeature::~UBFeature()
{
for (int i = 0; i < mChildren.count(); i++) {
delete mChildren[i];
}
for (int i = 0; i < mParents.count(); i++) {
mParents[i]->mChildren.removeAll(this);
}
}
QString UBFeature::getUrl() const
{
if ( elementType == FEATURE_INTERNAL )
return getFullPath().toString();
/*if ( UBApplication::isFromWeb( getFullPath() ) )
return QUrl( getFullPath() );*/
return getFullPath().toLocalFile();
}
bool UBFeature::operator ==( const UBFeature &f )const
{
return virtualPath == f.getVirtualPath() && mName == f.getName() && mPath == f.getFullPath() && elementType == f.getType();
return virtualDir == f.getVirtualPath() && mName == f.getName() && mPath == f.getFullPath() && elementType == f.getType();
}
bool UBFeature::operator !=( const UBFeature &f )const
......@@ -51,74 +64,105 @@ bool UBFeature::isFolder() const
bool UBFeature::isDeletable()const
{
return elementType == FEATURE_ITEM;
return elementType == FEATURE_ITEM
|| elementType == FEATURE_FOLDER;
}
bool UBFeature::inTrash() const
{
return getFullPath().toLocalFile().startsWith(QUrl::fromLocalFile(UBSettings::userTrashDirPath()).toLocalFile() );
}
UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
QObject(pParentWidget),
mLastItemOffsetIndex(0)
QObject(pParentWidget)
,featuresList(0)
,mLastItemOffsetIndex(0)
{
rootPath = "/root";
initDirectoryTree();
//Initializing virtual structure of the list
rootPath = "/" + virtualRootName;
appPath = rootPath + "/Applications";
audiosPath = rootPath + "/Audios";
moviesPath = rootPath + "/Movies";
picturesPath = rootPath + "/Pictures";
flashPath = rootPath + "/Animations";
interactPath = rootPath + "/Interactivities";
shapesPath = rootPath + "/Shapes";
trashPath = rootPath + "/Trash";
favoritePath = rootPath + "/Favorites";
//Initializing physical directories from UBSettings
mUserAudioDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAudioDirectory());
mUserVideoDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userVideoDirectory());
mUserPicturesDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userImageDirectory());
mUserInteractiveDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userInteractiveDirectory());
mUserAnimationDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAnimationDirectory());
mLibPicturesDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationImageLibraryDirectory());
mLibInteractiveDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationInteractivesDirectory());
mLibApplicationsDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationApplicationsLibraryDirectory());
mLibShapesDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationShapeLibraryDirectory());
mLibSearchDirectoryPath =QUrl::fromLocalFile(UBSettings::settings()->userSearchDirectory());
trashDirectoryPath = QUrl::fromLocalFile(UBSettings::userTrashDirPath());
rootElement = UBFeature(QString(), QPixmap( ":images/libpalette/home.png" ), "root", QUrl());
audiosElement = UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath, FEATURE_CATEGORY);
moviesElement = UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath, FEATURE_CATEGORY);
picturesElement = UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath, FEATURE_CATEGORY);
flashElement = UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath, FEATURE_CATEGORY);
interactElement = UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath, FEATURE_CATEGORY);
applicationsElement = UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath, FEATURE_CATEGORY);
shapesElement = UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath, FEATURE_CATEGORY );
favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", QUrl("favorites"), FEATURE_FAVORITE );
webSearchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath, FEATURE_CATEGORY);
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH );
featuresList = new QList <UBFeature>();
scanFS();
featuresModel = new UBFeaturesModel(featuresList, this);
featuresModel->setSupportedDragActions(Qt::CopyAction | Qt::MoveAction);
featuresProxyModel = new UBFeaturesProxyModel(this);
featuresProxyModel->setFilterFixedString(rootPath);
featuresProxyModel->setSourceModel(featuresModel);
featuresProxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
featuresSearchModel = new UBFeaturesSearchProxyModel(this);
featuresSearchModel->setSourceModel(featuresModel);
featuresSearchModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
featuresPathModel = new UBFeaturesPathProxyModel(this);
featuresPathModel->setPath(rootPath);
featuresPathModel->setSourceModel(featuresModel);
connect(featuresModel, SIGNAL(dataRestructured()), featuresProxyModel, SLOT(invalidate()));
}
void UBFeaturesController::initDirectoryTree()
void UBFeaturesController::scanFS()
{
mUserAudioDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userAudioDirectory() );
mUserVideoDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userVideoDirectory() );
mUserPicturesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userImageDirectory() );
mUserInteractiveDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userInteractiveDirectory() );
mUserAnimationDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userAnimationDirectory() );
featuresList->clear();
featuresList->append(rootElement);
mLibPicturesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationImageLibraryDirectory() );
qDebug() << mLibPicturesDirectoryPath;
mLibInteractiveDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationInteractivesDirectory() );
mLibApplicationsDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationApplicationsLibraryDirectory() );
mLibShapesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationShapeLibraryDirectory() );
mLibSearchDirectoryPath =QUrl::fromLocalFile( UBSettings::settings()->userSearchDirectory() );
trashDirectoryPath = QUrl::fromLocalFile( UBSettings::userTrashDirPath() );
mLibAudiosDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationAudiosLibraryDirectory());
mLibVideosDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationVideosLibraryDirectory());
mLibAnimationsDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->applicationAnimationsLibraryDirectory());
*featuresList << audiosElement
<< moviesElement
<< picturesElement
<< flashElement
<< interactElement
<< applicationsElement
<< shapesElement
<< favoriteElement
<< webSearchElement
<< trashElement;
featuresList = new QList <UBFeature>();
loadFavoriteList();
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools();
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools();
featuresList->append( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QUrl() ) );
currentElement = featuresList->at(0);
appPath = rootPath + "/Applications";
audiosPath = rootPath + "/Audios";
moviesPath = rootPath + "/Movies";
picturesPath = rootPath + "/Pictures";
flashPath = rootPath + "/Animations";
interactPath = rootPath + "/Interactivities";
shapesPath = rootPath + "/Shapes";
trashPath = rootPath + "/Trash";
favoritePath = rootPath + "/Favorites";
audiosElement = UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath );
featuresList->append( audiosElement );
moviesElement = UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath );
featuresList->append( moviesElement );
picturesElement = UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath );
featuresList->append( picturesElement );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) );
flashElement = UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath );
featuresList->append( flashElement );
interactElement = UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath );
featuresList->append( interactElement );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) );
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH );
featuresList->append( trashElement );
favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", QUrl("favorites"), FEATURE_FAVORITE );
featuresList->append( favoriteElement );
webSearchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath );
featuresList->append( webSearchElement );
loadFavoriteList();
foreach (UBToolsManager::UBToolDescriptor tool, tools)
foreach (UBToolsManager::UBToolDescriptor tool, tools)
{
featuresList->append( UBFeature( appPath, tool.icon, tool.label, QUrl( tool.id ), FEATURE_INTERNAL ) );
if ( favoriteSet->find( QUrl( tool.id ) ) != favoriteSet->end() )
......@@ -126,25 +170,25 @@ void UBFeaturesController::initDirectoryTree()
featuresList->append( UBFeature( favoritePath, tool.icon, tool.label, QUrl( tool.id ), FEATURE_INTERNAL ) );
}
}
// Claudio:
// don't change the order of the scans
fileSystemScan( mLibAudiosDirectoryPath, audiosPath);
fileSystemScan( mLibVideosDirectoryPath, moviesPath);
fileSystemScan( mLibAnimationsDirectoryPath, flashPath);
fileSystemScan( mLibPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserInteractiveDirectoryPath, appPath );
fileSystemScan( mUserAudioDirectoryPath, audiosPath );
fileSystemScan( mUserPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserVideoDirectoryPath, moviesPath );
fileSystemScan( mUserAnimationDirectoryPath, flashPath );
fileSystemScan( mLibApplicationsDirectoryPath, appPath );
fileSystemScan( mLibShapesDirectoryPath, shapesPath );
fileSystemScan( mLibInteractiveDirectoryPath, interactPath );
fileSystemScan( trashDirectoryPath, trashPath );
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
//Claudio:
// don't change the order of the scans
fileSystemScan( mLibAudiosDirectoryPath, audiosPath);
fileSystemScan( mLibVideosDirectoryPath, moviesPath);
fileSystemScan( mLibAnimationsDirectoryPath, flashPath);
fileSystemScan( mLibPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserInteractiveDirectoryPath, appPath );
fileSystemScan( mUserAudioDirectoryPath, audiosPath );
fileSystemScan( mUserPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserVideoDirectoryPath, moviesPath );
fileSystemScan( mUserAnimationDirectoryPath, flashPath );
fileSystemScan( mLibApplicationsDirectoryPath, appPath );
fileSystemScan( mLibShapesDirectoryPath, shapesPath );
fileSystemScan( mLibInteractiveDirectoryPath, interactPath );
fileSystemScan( trashDirectoryPath, trashPath );
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
}
......@@ -191,7 +235,14 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
icon = QPixmap( thumbnailPath );
else icon = createThumbnail( fullFileName );*/
}
featuresList->append( UBFeature( currVirtualPath, icon, fileName, QUrl::fromLocalFile( fullFileName ), fileType ) );
UBFeature testFeature(currVirtualPath, icon, fileName, QUrl::fromLocalFile(fullFileName), fileType);
if (featuresList->contains(testFeature)) {
qDebug() << "the same feature found";
}
featuresList->append(testFeature);
if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() )
{
featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), fileType ) );
......@@ -199,7 +250,7 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
if ( fileType == FEATURE_FOLDER )
{
fileSystemScan( QUrl::fromLocalFile( fullFileName ), currVirtualPath + "/" + fileName );
fileSystemScan( QUrl::fromLocalFile( fullFileName ), currVirtualPath + "/" + fileName );
}
}
......@@ -219,12 +270,7 @@ void UBFeaturesController::loadFavoriteList()
{
QUrl path;
in >> path;
/*QFileInfo fileInfo( path );
QString fileName = fileInfo.fileName();
UBFeature elem( favoritePath, thumbnailForFile( path ), fileName, path, fileTypeFromUrl(path) );
featuresList->append( elem );*/
favoriteSet->insert( path );
favoriteSet->insert( path );
}
}
}
......@@ -243,7 +289,7 @@ void UBFeaturesController::saveFavoriteList()
file.close();
}
UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
void UBFeaturesController::addToFavorite( const QUrl &path )
{
QString filePath = fileNameFromUrl( path );
if ( favoriteSet->find( path ) == favoriteSet->end() )
......@@ -253,19 +299,24 @@ UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, path, fileTypeFromUrl(filePath) );
favoriteSet->insert( path );
saveFavoriteList();
return elem;
if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull())
featuresModel->addItem( elem );
}
return UBFeature();
}
void UBFeaturesController::removeFromFavorite( const QUrl &path )
void UBFeaturesController::removeFromFavorite( const QUrl &path, bool deleteManualy)
{
QString filePath = fileNameFromUrl( path );
// QString filePath = fileNameFromUrl( path );
if ( favoriteSet->find( path ) != favoriteSet->end() )
{
favoriteSet->erase( favoriteSet->find( path ) );
saveFavoriteList();
}
if (deleteManualy) {
featuresModel->deleteFavoriteItem(path.toString());
}
}
QString UBFeaturesController::fileNameFromUrl( const QUrl &url )
......@@ -376,15 +427,18 @@ UBFeature UBFeaturesController::importImage( const QImage &image, const UBFeatur
}
UBFeature UBFeaturesController::newFolder( const QString &name )
void UBFeaturesController::addNewFolder(const QString &name)
{
QString path = currentElement.getFullPath().toLocalFile() + "/" + name;
if(!QFileInfo(path).exists())
{
if(!QFileInfo(path).exists()) {
QDir().mkpath(path);
}
return UBFeature( currentElement.getFullVirtualPath(), QPixmap(":images/libpalette/folder.svg"),
name, QUrl::fromLocalFile( path ), FEATURE_FOLDER );
UBFeature newFeatureFolder = UBFeature( currentElement.getFullVirtualPath(), QPixmap(":images/libpalette/folder.svg"),
name, QUrl::fromLocalFile( path ), FEATURE_FOLDER );
featuresModel->addItem( newFeatureFolder );
featuresProxyModel->invalidate();
}
void UBFeaturesController::addItemToPage(const UBFeature &item)
......@@ -397,8 +451,7 @@ void UBFeaturesController::addItemAsBackground(const UBFeature &item)
UBApplication::boardController->downloadURL( item.getFullPath(), QPointF(), QSize(), true );
}
UBFeature UBFeaturesController::getDestinationForItem( const QUrl &url )
UBFeature UBFeaturesController::getParentFeatureForUrl( const QUrl &url )
{
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName( url.toString() );
......@@ -418,23 +471,29 @@ UBFeature UBFeaturesController::getDestinationForItem( const QUrl &url )
return UBFeature();
}
UBFeature UBFeaturesController::addDownloadedFile( const QUrl &sourceUrl, const QByteArray &pData )
void UBFeaturesController::addDownloadedFile(const QUrl &sourceUrl, const QByteArray &pData)
{
UBFeature dest = getDestinationForItem( sourceUrl );
UBFeature dest = getParentFeatureForUrl( sourceUrl );
if ( dest == UBFeature() )
return UBFeature();
return;
QString fileName = QFileInfo( sourceUrl.toString() ).fileName();
QString filePath = dest.getFullPath().toLocalFile() + "/" + fileName;
QFile file( filePath );
if( file.open(QIODevice::WriteOnly ))
if ( file.open(QIODevice::WriteOnly ))
{
file.write(pData);
file.close();
return UBFeature( dest.getFullVirtualPath(), thumbnailForFile( filePath ),
fileName, QUrl::fromLocalFile(filePath), FEATURE_ITEM );
UBFeature downloadedFeature = UBFeature( dest.getFullVirtualPath(), thumbnailForFile( filePath ),
fileName, QUrl::fromLocalFile(filePath), FEATURE_ITEM);
if (downloadedFeature != UBFeature()) {
featuresModel->addItem(downloadedFeature);
}
}
return UBFeature();
}
UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeature &destination )
......@@ -446,7 +505,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
Q_ASSERT( QFileInfo( sourcePath ).exists() );
UBFeature possibleDest = getDestinationForItem( url );
UBFeature possibleDest = getParentFeatureForUrl( url );
UBFeature dest = destination;
......@@ -472,59 +531,167 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = FEATURE_INTERACTIVE;
UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
return newElement;
return newElement;
}
void UBFeaturesController::rescanModel()
{
featuresModel->removeRows(0, featuresList->count());
//Could implement infolder scanning for better perfomance
scanFS();
refreshModels();
}
void UBFeaturesController::siftElements(const QString &pSiftValue)
{
featuresProxyModel->setFilterFixedString(pSiftValue);
featuresProxyModel->invalidate();
featuresPathModel->setPath(pSiftValue);
featuresPathModel->invalidate();
}
UBFeature UBFeaturesController::getFeature(const QModelIndex &index, QListView *pOnView)
{
return qobject_cast<QSortFilterProxyModel *>(pOnView->model())->data(index, Qt::UserRole + 1).value<UBFeature>();
}
void UBFeaturesController::searchStarted(const QString &pattern, QListView *pOnView)
{
if (pattern.isEmpty()) {
pOnView->setModel(featuresProxyModel);
featuresProxyModel->invalidate();
} else if ( pattern.size() > 2 ) {
featuresSearchModel->setFilterWildcard( "*" + pattern + "*" );
pOnView->setModel(featuresSearchModel );
featuresSearchModel->invalidate();
}
}
void UBFeaturesController::refreshModels()
{
featuresProxyModel->invalidate();
featuresSearchModel->invalidate();
featuresPathModel->invalidate();
}
UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeature &destination )
{
QString sourcePath = url.toLocalFile();
QString sourcePath = url.toLocalFile();
Q_ASSERT( QFileInfo( sourcePath ).exists() );
Q_ASSERT( QFileInfo( sourcePath ).exists() );
UBFeature possibleDest = getDestinationForItem( url );
UBFeature possibleDest = getParentFeatureForUrl( url );
UBFeature dest = destination;
UBFeature dest = destination;
if ( destination != trashElement &&
!destination.getFullVirtualPath().startsWith( possibleDest.getFullVirtualPath(), Qt::CaseInsensitive ) )
{
dest = possibleDest;
}
if ( destination != trashElement &&
!destination.getFullVirtualPath().startsWith( possibleDest.getFullVirtualPath(), Qt::CaseInsensitive ) )
{
dest = possibleDest;
}
QString name = QFileInfo( sourcePath ).fileName();
QString name = QFileInfo( sourcePath ).fileName();
QString destPath = dest.getFullPath().toLocalFile();
QString destVirtualPath = dest.getFullVirtualPath();
QString newFullPath = destPath + "/" + name;
QString destVirtualPath = dest.getFullVirtualPath();
QString newFullPath = destPath + "/" + name;
if ( !sourcePath.compare( newFullPath, Qt::CaseInsensitive ) )
QFile( sourcePath ).copy( newFullPath );
QFile( sourcePath ).copy( newFullPath );
QPixmap thumb = thumbnailForFile( newFullPath );
QPixmap thumb = thumbnailForFile( newFullPath );
UBFeatureElementType type = FEATURE_ITEM;
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = FEATURE_INTERACTIVE;
UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
return newElement;
return newElement;
}
void UBFeaturesController::deleteItem( const QUrl &url )
void UBFeaturesController::deleteItem(const QUrl &url)
{
QString path = url.toLocalFile();
Q_ASSERT( QFileInfo( path ).exists() );
QString path = url.toLocalFile();
Q_ASSERT( QFileInfo( path ).exists() );
QString thumbnailPath = UBFileSystemUtils::thumbnailPath( path );
if ( thumbnailPath.length() && QFileInfo( thumbnailPath ).exists() )
{
QFile::remove(thumbnailPath);
if ( thumbnailPath.length() && QFileInfo( thumbnailPath ).exists()) {
if (QFileInfo(thumbnailPath).isFile()) {
QFile::remove(thumbnailPath);
} else if (QFileInfo(thumbnailPath).isDir()){
if (!UBFileSystemUtils::deleteDir(thumbnailPath)) {
qDebug() << "Not able to delete directory";
}
}
}
if (QFileInfo(path).isFile()) {
QFile::remove( path );
} else if (QFileInfo(path).isDir()) {
UBFileSystemUtils::deleteDir(path);
}
QFile::remove( path );
}
void UBFeaturesController::deleteItem(const UBFeature &pFeature)
{
QUrl sourceUrl = pFeature.getFullPath();
featuresModel->deleteItem(pFeature);
deleteItem(sourceUrl);
}
bool UBFeaturesController::isTrash( const QUrl &url )
{
return url.toLocalFile().startsWith( trashDirectoryPath.toLocalFile() );
}
void UBFeaturesController::moveToTrash(UBFeature feature, bool deleteManualy)
{
featuresModel->moveData(feature, trashElement, Qt::MoveAction, deleteManualy);
removeFromFavorite(feature.getFullPath());
featuresModel->deleteFavoriteItem(UBFeaturesController::fileNameFromUrl(feature.getFullPath()));
}
UBFeaturesController::~UBFeaturesController()
{
if (featuresList) {
delete featuresList;
}
}
void UBFeaturesController::assignFeaturesListVeiw(UBFeaturesListView *pList)
{
pList->setDragDropMode( QAbstractItemView::DragDrop );
pList->setSelectionMode( QAbstractItemView::ContiguousSelection );
pList->setResizeMode( QListView::Adjust );
pList->setViewMode( QListView::IconMode );
pList->setIconSize(QSize(UBFeaturesWidget::defaultThumbnailSize, UBFeaturesWidget::defaultThumbnailSize));
pList->setGridSize(QSize(UBFeaturesWidget::defaultThumbnailSize + 20, UBFeaturesWidget::defaultThumbnailSize + 20));
itemDelegate = new UBFeaturesItemDelegate(this, pList);
pList->setItemDelegate(itemDelegate);
pList->setModel(featuresProxyModel);
}
void UBFeaturesController::assignPathListView(UBFeaturesListView *pList)
{
pList->setViewMode(QListView::IconMode );
pList->setIconSize(QSize(UBFeaturesWidget::defaultThumbnailSize - 10, UBFeaturesWidget::defaultThumbnailSize - 10));
pList->setGridSize(QSize(UBFeaturesWidget::defaultThumbnailSize + 10, UBFeaturesWidget::defaultThumbnailSize - 10));
pList->setFixedHeight(60);
pList->setSelectionMode(QAbstractItemView::NoSelection);
pList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
pList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
pList->setFlow(QListView::LeftToRight);
pList->setWrapping(false);
pList->setDragDropMode(QAbstractItemView::DropOnly);
pList->setModel( featuresPathModel);
pathItemDelegate = new UBFeaturesPathItemDelegate(this);
pList->setItemDelegate(pathItemDelegate);
}
......@@ -11,6 +11,15 @@
#include <QMap>
#include <QUrl>
#include <QByteArray>
#include <QtGui>
class UBFeaturesModel;
class UBFeaturesItemDelegate;
class UBFeaturesPathItemDelegate;
class UBFeaturesProxyModel;
class UBFeaturesSearchProxyModel;
class UBFeaturesPathProxyModel;
class UBFeaturesListView;
//#include "UBDockPaletteWidget.h"
......@@ -33,77 +42,120 @@ public:
UBFeature() {;}
//UBFeature(const UBFeature &f);
UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type = FEATURE_CATEGORY);
virtual ~UBFeature() {;}
// UBFeature();
virtual ~UBFeature();
QString getName() const { return mName; }
QPixmap getThumbnail() const {return mThumbnail;}
QString getVirtualPath() const { return virtualPath; }
QString getVirtualPath() const { return virtualDir; }
//QString getPath() const { return mPath; };
QUrl getFullPath() const { return mPath; }
QString getFullVirtualPath() const { return virtualPath + "/" + mName; }
QString getFullVirtualPath() const { return virtualDir + "/" + mName; }
QString getUrl() const;
void setFullPath(const QUrl &newPath) {mPath = newPath;}
void setFullVirtualPath(const QString &newVirtualPath) {virtualDir = newVirtualPath;}
UBFeatureElementType getType() const { return elementType; }
bool isFolder() const;
bool isDeletable() const;
bool inTrash() const;
bool operator ==( const UBFeature &f )const;
bool operator !=( const UBFeature &f )const;
const QMap<QString,QString> & getMetadata() const { return metadata; }
void setMetadata( const QMap<QString,QString> &data ) { metadata = data; }
bool hasChildren() const {return mChildren.count();}
bool hasParents() const {return mParents.count();}
bool hasRelationships() const {return mChildren.count() && mParents.count();}
private:
QString virtualPath;
QString virtualDir;
QPixmap mThumbnail;
QString mName;
QUrl mPath;
UBFeatureElementType elementType;
QMap<QString,QString> metadata;
QMap<QString,QString> metadata;
QList<UBFeature*> mChildren;
QList<UBFeature*> mParents;
};
Q_DECLARE_METATYPE( UBFeature )
class UBFeaturesController : public QObject
{
friend class UBFeaturesWidget;
Q_OBJECT
public:
UBFeaturesController(QWidget *parentWidget);
virtual ~UBFeaturesController();
QList <UBFeature>* getFeatures()const { return featuresList; }
QList <UBFeature>* getFeatures() const {return featuresList;}
const QString& getRootPath()const { return rootPath; }
const QString& getRootPath()const {return rootPath;}
void scanFS();
void addItemToPage( const UBFeature &item );
void addItemAsBackground( const UBFeature &item );
const UBFeature& getCurrentElement()const { return currentElement; }
void setCurrentElement( const UBFeature &elem ) { currentElement = elem; }
void addItemToPage(const UBFeature &item);
void addItemAsBackground(const UBFeature &item);
const UBFeature& getCurrentElement()const {return currentElement;}
void setCurrentElement( const UBFeature &elem ) {currentElement = elem;}
const UBFeature & getTrashElement () const { return trashElement; }
UBFeature addDownloadedFile( const QUrl &sourceUrl, const QByteArray &pData );
void addDownloadedFile( const QUrl &sourceUrl, const QByteArray &pData );
UBFeature moveItemToFolder( const QUrl &url, const UBFeature &destination );
UBFeature copyItemToFolder( const QUrl &url, const UBFeature &destination );
void rescanModel();
void siftElements(const QString &pSiftValue);
//TODO make less complicated for betteer maintainence
UBFeature getFeature(const QModelIndex &index, QListView *pOnView);
void searchStarted(const QString &pattern, QListView *pOnView);
void refreshModels();
void deleteItem( const QUrl &url );
void deleteItem(const UBFeature &pFeature);
bool isTrash( const QUrl &url );
UBFeature newFolder( const QString &name );
UBFeature addToFavorite( const QUrl &path );
void removeFromFavorite( const QUrl &path );
void moveToTrash(UBFeature feature, bool deleteManualy = false);
void addNewFolder(const QString &name);
void addToFavorite( const QUrl &path );
void removeFromFavorite(const QUrl &path, bool deleteManualy = false);
UBFeature importImage( const QImage &image, const UBFeature &destination );
void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath);
static QString fileNameFromUrl( const QUrl &url );
static QPixmap thumbnailForFile( const QString &path );
static bool isDeletable( const QUrl &url );
static char featureTypeSplitter() {return ':';}
static const QString virtualRootName;
void assignFeaturesListVeiw(UBFeaturesListView *pList);
void assignPathListView(UBFeaturesListView *pList);
private:
UBFeaturesItemDelegate *itemDelegate;
UBFeaturesPathItemDelegate *pathItemDelegate;
UBFeaturesModel *featuresModel;
UBFeaturesProxyModel *featuresProxyModel;
UBFeaturesSearchProxyModel *featuresSearchModel;
UBFeaturesPathProxyModel *featuresPathModel;
private:
void initDirectoryTree();
void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath);
static QPixmap createThumbnail(const QString &path);
static QPixmap createThumbnail(const QString &path);
//void addImageToCurrentPage( const QString &path );
void loadFavoriteList();
void saveFavoriteList();
UBFeature getDestinationForItem( const QUrl &url );
static UBFeatureElementType fileTypeFromUrl( const QString &path );
QList <UBFeature> *featuresList;
UBFeature *rootElement;
QList <UBFeature> *featuresList;
QUrl mUserAudioDirectoryPath;
QUrl mUserVideoDirectoryPath;
......@@ -136,19 +188,24 @@ private:
int mLastItemOffsetIndex;
UBFeature currentElement;
UBFeature trashElement;
UBFeature favoriteElement;
UBFeature rootElement;
UBFeature favoriteElement;
UBFeature audiosElement;
UBFeature moviesElement;
UBFeature picturesElement;
UBFeature interactElement;
UBFeature applicationsElement;
UBFeature flashElement;
UBFeature shapesElement;
UBFeature webSearchElement;
QSet <QUrl> *favoriteSet;
};
public:
UBFeature trashElement;
UBFeature getParentFeatureForUrl( const QUrl &url );
};
#endif
......@@ -40,6 +40,8 @@
#include "gui/UBScreenMirror.h"
#include "gui/UBMainWindow.h"
#include "gui/UBDockTeacherGuideWidget.h"
#include "gui/UBTeacherGuideWidget.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBW3CWidget.h"
......@@ -418,7 +420,7 @@ void UBApplicationController::showDocument()
if (UBApplication::boardController)
{
if (UBApplication::boardController->activeScene()->isModified())
if (UBApplication::boardController->activeScene()->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()))
UBApplication::boardController->persistCurrentScene();
UBApplication::boardController->hide();
}
......@@ -471,23 +473,30 @@ void UBApplicationController::showTutorial()
UBApplication::boardController->hide();
}
// it's needed not to duplicate webbrowser search in web mode. If I've breaked smbd's code let Ivan know
UBApplication::webController->show(UBWebController::Tutorial);
if (UBSettings::settings()->webUseExternalBrowser->get().toBool())
{
showDesktop(true);
UBApplication::webController->show(UBWebController::Tutorial);
mMainWindow->webToolBar->hide();
mMainWindow->boardToolBar->hide();
mMainWindow->documentToolBar->hide();
mMainWindow->tutorialToolBar->show();
}
else{
mMainWindow->webToolBar->hide();
mMainWindow->boardToolBar->hide();
mMainWindow->documentToolBar->hide();
mMainWindow->tutorialToolBar->show();
mMainMode = Tutorial;
mMainMode = Tutorial;
adaptToolBar();
adaptToolBar();
mUninoteController->hideWindow();
mUninoteController->hideWindow();
mirroringEnabled(false);
emit mainModeChanged(mMainMode);
UBApplication::webController->show(UBWebController::Tutorial);
mirroringEnabled(false);
emit mainModeChanged(mMainMode);
}
}
......@@ -537,7 +546,6 @@ void UBApplicationController::updateRequestFinished(int id, bool error)
}
else{
QString responseString = QString(mHttp->readAll());
qDebug() << responseString;
if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mHttp->close();
downloadJsonFinished(responseString);
......@@ -586,7 +594,10 @@ void UBApplicationController::checkUpdateRequest()
void UBApplicationController::hideDesktop()
{
mDisplayManager->adjustScreens(-1);
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
}
if (mMainMode == Board)
{
......
......@@ -25,6 +25,9 @@
#include "core/UBSettings.h"
#include "core/UBSetting.h"
#include "gui/UBDockTeacherGuideWidget.h"
#include "gui/UBTeacherGuideWidget.h"
#include "document/UBDocumentProxy.h"
#include "adaptors/UBExportPDF.h"
......@@ -33,6 +36,7 @@
#include "adaptors/UBMetadataDcSubsetAdaptor.h"
#include "board/UBBoardController.h"
#include "board/UBBoardPaletteManager.h"
#include "interfaces/IDataStorage.h"
......@@ -591,7 +595,6 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy,
}
}
void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* pScene, const int pSceneIndex)
{
checkIfDocumentRepositoryExists();
......@@ -603,10 +606,15 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
QDir dir(pDocumentProxy->persistencePath());
dir.mkpath(pDocumentProxy->persistencePath());
if (pDocumentProxy->isModified())
UBBoardPaletteManager* paletteManager = UBApplication::boardController->paletteManager();
bool teacherGuideModified = false;
if(paletteManager->teacherGuideDockWidget())
teacherGuideModified = paletteManager->teacherGuideDockWidget()->teacherGuideWidget()->isModified();
if (pDocumentProxy->isModified() || teacherGuideModified)
UBMetadataDcSubsetAdaptor::persist(pDocumentProxy);
if (pScene->isModified())
if (pScene->isModified() || teacherGuideModified)
{
UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
......
......@@ -74,6 +74,10 @@ void UBSetting::setString(const QString& pValue)
{
set(pValue);
}
void UBSetting::setInt(int pValue)
{
set(pValue);
}
UBColorListSetting::UBColorListSetting(UBSettings* parent)
......
......@@ -54,6 +54,7 @@ class UBSetting : public QObject
void setBool(bool pValue);
void setString(const QString& pValue);
void setInt(int pValue);
signals:
......
......@@ -225,6 +225,8 @@ void UBSettings::init()
appStartMode = new UBSetting(this, "App", "StartMode", "");
featureSliderPosition = new UBSetting(this, "Board", "FeatureSliderPosition", 40);
boardPenFineWidth = new UBSetting(this, "Board", "PenFineWidth", 1.5);
boardPenMediumWidth = new UBSetting(this, "Board", "PenMediumWidth", 3.0);
boardPenStrongWidth = new UBSetting(this, "Board", "PenStrongWidth", 8.0);
......
......@@ -249,6 +249,8 @@ class UBSettings : public QObject
UBSetting* appStartMode;
UBSetting* featureSliderPosition;
UBColorListSetting* boardPenLightBackgroundColors;
UBColorListSetting* boardPenLightBackgroundSelectedColors;
......
......@@ -386,7 +386,10 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils::setDesktopMode(false);
UBDrawingController::drawingController()->setInDestopMode(false);
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
}
emit restoreUniboard();
}
......
......@@ -1624,7 +1624,11 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*)
}
items << pixmapItem;
labels << tr("Page %1").arg(pageFromSceneIndex(i));
int pageIndex = pageFromSceneIndex(i);
if(pageIndex)
labels << tr("Page %1").arg(pageIndex);
else
labels << tr("Title page");
itemsPath.append(QUrl::fromLocalFile(proxy->persistencePath() + QString("/pages/%1").arg(UBDocumentContainer::pageFromSceneIndex(i))));
}
......
......@@ -359,7 +359,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
}
else if (mOperationMode == Resizing)
else if (mOperationMode == Resizing || mOperationMode == ResizingHorizontally)
{
mTranslateX = moveX;
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated());
......@@ -675,19 +675,22 @@ void UBGraphicsDelegateFrame::positionHandles()
QVariant vLocked = delegated()->data(UBGraphicsItemData::ItemLocked);
bool isLocked = (vLocked.isValid() && vLocked.toBool());
mBottomRightResizeGripSvgItem->setVisible(!isLocked);
mBottomResizeGripSvgItem->setVisible(!isLocked);
mLeftResizeGripSvgItem->setVisible(!isLocked);
mRightResizeGripSvgItem->setVisible(!isLocked);
mTopResizeGripSvgItem->setVisible(!isLocked);
bool bShowHorizontalResizers = ResizingHorizontally == mOperationMode;
bool bShowVerticalResizers = ResizingHorizontally != mOperationMode;
bool bShowAllResizers = Resizing == mOperationMode || Scaling == mOperationMode ;
mBottomRightResizeGripSvgItem->setVisible(!isLocked && bShowAllResizers);
mBottomResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mLeftResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mRightResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mTopResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mRotateButton->setVisible(mDelegate->canRotate() && !isLocked);
mBottomRightResizeGrip->setVisible(!isLocked);
mBottomResizeGrip->setVisible(!isLocked);
mLeftResizeGrip->setVisible(!isLocked);
mRightResizeGrip->setVisible(!isLocked);
mTopResizeGrip->setVisible(!isLocked);
mBottomRightResizeGrip->setVisible(!isLocked && bShowAllResizers);
mBottomResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mLeftResizeGrip->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mRightResizeGrip->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mTopResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
if (isLocked)
{
......@@ -714,9 +717,9 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
{
if(mDelegate->isLocked())
return None;
else if (bottomRightResizeGripRect().contains(pos))
else if (bottomRightResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode)
return ResizeBottomRight;
else if (bottomResizeGripRect().contains(pos)){
else if (bottomResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode){
if(mMirrorY){
return ResizeTop;
}else{
......@@ -738,7 +741,7 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
return ResizeRight;
}
}
else if (topResizeGripRect().contains(pos)){
else if (topResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode){
if(mMirrorY){
return ResizeBottom;
}else{
......
......@@ -46,7 +46,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
virtual void setAntiScale(qreal pAntiScale);
enum OperationMode {Scaling, Resizing};
enum OperationMode {Scaling, Resizing, ResizingHorizontally};
void setOperationMode(OperationMode pMode) {mOperationMode = pMode;}
bool isResizing(){return mResizing;}
......
......@@ -677,7 +677,8 @@ UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) :
mShifting(true),
mVisible(false),
mMinWidth(200),
mInitialHeight(26)
mInitialHeight(26),
mElementsPadding(2)
{
QRectF rect = this->rect();
rect.setHeight(mInitialHeight);
......@@ -698,7 +699,7 @@ void UBGraphicsToolBarItem::positionHandles()
foreach (QGraphicsItem* item, mItemsOnToolBar)
{
item->setPos(itemXOffset, 0);
itemXOffset += (item->boundingRect().width());
itemXOffset += (item->boundingRect().width()+mElementsPadding);
item->show();
}
}
......@@ -1155,7 +1156,7 @@ void DelegateMediaControl::paint(QPainter *painter,
mLCDTimerArea.setWidth(rect().height());
mSeecArea = rect();
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width());
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2);
path.addRoundedRect(mSeecArea, mSeecArea.height()/2, mSeecArea.height()/2);
painter->fillPath(path, brush());
......
......@@ -128,6 +128,7 @@ class DelegateMediaControl: public QObject, public QGraphicsRectItem
void positionHandles();
void updateTicker(qint64 time);
void totalTimeChanged(qint64 newTotalTime);
QSizeF lcdAreaSize(){return mLCDTimerArea.size();}
signals:
void used();
......@@ -165,6 +166,7 @@ class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject
int minWidth() { return mMinWidth; }
void positionHandles();
void update();
int getElementsPadding(){return mElementsPadding;}
private:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
......@@ -175,6 +177,7 @@ class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject
bool mVisible;
int mMinWidth;
int mInitialHeight;
int mElementsPadding;
QList<QGraphicsItem*> mItemsOnToolBar;
};
......
......@@ -21,7 +21,6 @@
#include "document/UBDocumentProxy.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
bool UBGraphicsMediaItem::sIsMutedByDefault = false;
......@@ -56,6 +55,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
if(mVideoWidget->sizeHint() == QSize(1,1)){
mVideoWidget->resize(320,240);
mVideoWidget->setMinimumSize(140,26);
}
setWidget(mVideoWidget);
haveLinkedImage = true;
......@@ -67,8 +67,16 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mMediaObject->setTickInterval(1000);
mAudioWidget = new QWidget();
mAudioWidget->resize(320,26);
mAudioWidget = new UBGraphicsMediaItem::UBAudioPresentationWidget();
int borderSize = 0;
UBGraphicsMediaItem::UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBGraphicsMediaItem::UBAudioPresentationWidget*>(mAudioWidget);
if (pAudioWidget)
{
borderSize = pAudioWidget->borderSize();
}
mAudioWidget->resize(320,26+3*borderSize);
mAudioWidget->setMinimumSize(150,26+borderSize);
setWidget(mAudioWidget);
haveLinkedImage = false;
}
......@@ -82,7 +90,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
itemDelegate->init();
setDelegate(itemDelegate);
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
if (mediaType_Audio == mMediaType)
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
else
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
......@@ -284,4 +295,4 @@ void UBGraphicsMediaItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->accept();
}
}
\ No newline at end of file
......@@ -21,12 +21,54 @@
#include <phonon/VideoWidget>
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.h"
class UBGraphicsMediaItem : public UBGraphicsProxyWidget
{
Q_OBJECT
public:
class UBAudioPresentationWidget : public QWidget
{
public:
UBAudioPresentationWidget(QWidget *parent = NULL)
:QWidget(parent)
, mBorderSize(10)
, mTitleSize(10)
{}
int borderSize()
{
return mBorderSize;
}
void setTitle(QString title = QString()){mTitle = title;}
QString getTitle(){return mTitle;}
private:
virtual void paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.fillRect(rect(), QBrush(Qt::black));
if (QString() != mTitle)
{
painter.setPen(QPen(Qt::white));
QRect titleRect = rect();
titleRect.setX(mBorderSize);
titleRect.setY(2);
titleRect.setHeight(15);
painter.drawText(titleRect, mTitle);
}
QWidget::paintEvent(event);
}
int mBorderSize;
int mTitleSize;
QString mTitle;
};
public:
typedef enum{
mediaType_Video,
......@@ -81,6 +123,17 @@ public:
virtual UBItem* deepCopy() const;
virtual void setSourceUrl(const QUrl &pSourceUrl)
{
UBGraphicsMediaItem::UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBGraphicsMediaItem::UBAudioPresentationWidget*>(mAudioWidget);
if (pAudioWidget)
{
pAudioWidget->setTitle(UBFileSystemUtils::lastPathComponent(pSourceUrl.toLocalFile()));
}
UBItem::setSourceUrl(pSourceUrl);
}
public slots:
void toggleMute();
......@@ -118,15 +171,6 @@ private:
QPointF mMouseMovePos;
bool haveLinkedImage;
QGraphicsPixmapItem *mLinkedImage;
QGraphicsPixmapItem *mLinkedImage;
};
class UBGraphicsUnitedMediaItem : public UBGraphicsMediaItem
{
public:
UBGraphicsUnitedMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent = 0);
};
#endif // UBGRAPHICSMEDIAITEM_H
......@@ -18,6 +18,7 @@
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsMediaItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "UBGraphicsScene.h"
......@@ -120,31 +121,48 @@ void UBGraphicsMediaItemDelegate::positionHandles()
{
UBGraphicsItemDelegate::positionHandles();
qreal AntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
UBGraphicsMediaItem *mediaItem = dynamic_cast<UBGraphicsMediaItem*>(mDelegated);
if (mediaItem)
{
if (mediaItem->getMediaType() != UBGraphicsMediaItem::mediaType_Audio)
{
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height()*AntiScaleRatio);
mToolBarItem->setScale(AntiScaleRatio);
QRectF toolBarRect = mToolBarItem->rect();
toolBarRect.setWidth(delegated()->boundingRect().width()/AntiScaleRatio);
mToolBarItem->setRect(toolBarRect);
QRectF toolBarRect = mToolBarItem->rect();
if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video)
{
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height());
// mToolBarItem->setScale(AntiScaleRatio);
toolBarRect.setWidth(delegated()->boundingRect().width());
}
else
else if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
{
mToolBarItem->setPos(0, 0);
int borderSize = 0;
UBGraphicsMediaItem::UBAudioPresentationWidget *audioWidget = dynamic_cast<UBGraphicsMediaItem::UBAudioPresentationWidget*>(delegated()->widget());
if (audioWidget)
borderSize = audioWidget->borderSize();
mToolBarItem->setPos(borderSize,delegated()->boundingRect().height()-(mToolBarItem->rect().height() + borderSize));
toolBarRect.setWidth((delegated()->boundingRect().width()-2*borderSize));
mToolBarItem->show();
}
mToolBarItem->setRect(toolBarRect);
}
int toolBarMinimumWidth = 0;
int mediaItemWidth = mToolBarItem->boundingRect().width();
foreach (DelegateButton* button, mButtons)
{
if (button->getSection() == Qt::TitleBarArea)
mediaItemWidth -= button->boundingRect().width();
{
mediaItemWidth -= button->boundingRect().width() + mToolBarItem->getElementsPadding();
toolBarMinimumWidth += button->boundingRect().width() + mToolBarItem->getElementsPadding();
}
}
toolBarMinimumWidth += mToolBarItem->boundingRect().height();
UBGraphicsMediaItem::UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBGraphicsMediaItem::UBAudioPresentationWidget*>(delegated()->widget());
if (pAudioWidget)
{
pAudioWidget->setMinimumSize(toolBarMinimumWidth + (int)mMediaControl->lcdAreaSize().width() + (int)mMediaControl->rect().height(),26+pAudioWidget->borderSize());
}
QRectF mediaItemRect = mMediaControl->rect();
......
......@@ -153,10 +153,30 @@ void UBGraphicsProxyWidget::resize(const QSizeF & pSize)
{
if (pSize != size())
{
QGraphicsProxyWidget::setMaximumSize(pSize.width(), pSize.height());
QGraphicsProxyWidget::resize(pSize.width(), pSize.height());
qreal sizeX = 0;
qreal sizeY = 0;
if (widget())
{
QSizeF minimumItemSize(widget()->minimumSize());
if (minimumItemSize.width() > pSize.width())
sizeX = minimumItemSize.width();
else
sizeX = pSize.width();
if (minimumItemSize.height() > pSize.height())
sizeY = minimumItemSize.height();
else
sizeY = pSize.height();
}
QSizeF size(sizeX, sizeY);
QGraphicsProxyWidget::setMaximumSize(size.width(), size.height());
QGraphicsProxyWidget::resize(size.width(), size.height());
if (widget())
widget()->resize(pSize.width(), pSize.height());
widget()->resize(size.width(), size.height());
if (mDelegate)
mDelegate->positionHandles();
if (scene())
......
......@@ -779,7 +779,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
if (mShouldUseOMP)
{
//#pragma omp parallel for
#pragma omp parallel for
for (int i = 0; i < collidItemsSize; i++)
{
UBGraphicsPolygonItem *collidingPolygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(collidItems.at(i));
......@@ -789,7 +789,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
if(eraserInnerRect.contains(collidingPolygonItem->boundingRect()))
{
//#pragma omp critical
#pragma omp critical
// Put the entire polygon into the remove list
toBeRemovedItems << collidingPolygonItem;
}
......@@ -826,7 +826,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
}
else */if (croppedPathSimplified.isEmpty())
{
//#pragma omp critical
#pragma omp critical
// Put the entire polygon into the remove list if the eraser removes all its visible content
toBeRemovedItems << collidingPolygonItem;
}
......@@ -837,7 +837,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons())
{
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol);
//#pragma omp critical
#pragma omp critical
if(NULL != pGroup){
croppedPolygonItem->setStrokesGroup(pGroup);
//pGroup->addToGroup(croppedPolygonItem);
......@@ -845,7 +845,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
// Add this new polygon to the 'added' list
toBeAddedItems << croppedPolygonItem;
}
//#pragma omp critical
#pragma omp critical
// Remove the original polygonitem because it has been replaced by many smaller polygons
toBeRemovedItems << collidingPolygonItem;
}
......@@ -902,7 +902,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
}
}
if(eDrawingMode_Vector == UBDrawingController::drawingController()->drawingMode()){
if(eDrawingMode_Vector == DRAWING_MODE && !UBDrawingController::drawingController()->isInDesktopMode()){
foreach(QGraphicsItem* item, toBeRemovedItems){
UBGraphicsPolygonItem* poly = dynamic_cast<UBGraphicsPolygonItem*>(item);
if(NULL != poly){
......@@ -920,7 +920,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
mRemovedItems += toBeRemovedItems;
}
if(eDrawingMode_Vector == UBDrawingController::drawingController()->drawingMode()){
if(eDrawingMode_Vector == DRAWING_MODE && !UBDrawingController::drawingController()->isInDesktopMode()){
foreach(QGraphicsItem* item, toBeAddedItems){
UBGraphicsPolygonItem* poly = dynamic_cast<UBGraphicsPolygonItem*>(item);
if(NULL != poly && NULL != poly->strokesGroup()){
......
......@@ -78,14 +78,14 @@ bool UBFileSystemUtils::isAZipFile(QString &filePath)
return result;
}
bool UBFileSystemUtils::copyFile(const QString &source, const QString &Destination, bool overwrite)
bool UBFileSystemUtils::copyFile(const QString &source, const QString &destination, bool overwrite)
{
if (!QFile::exists(source)) {
qDebug() << "file" << source << "does not present in fs";
return false;
}
QString normalizedDestination = Destination;
QString normalizedDestination = destination;
if (QFile::exists(normalizedDestination)) {
if (QFileInfo(normalizedDestination).isFile() && overwrite) {
QFile::remove(normalizedDestination);
......@@ -103,6 +103,15 @@ bool UBFileSystemUtils::copyFile(const QString &source, const QString &Destinati
return QFile::copy(source, normalizedDestination);
}
bool UBFileSystemUtils::copy(const QString &source, const QString &destination, bool overwrite)
{
if (QFileInfo(source).isDir()) {
return copyDir(source, destination);
} else {
return copyFile(source, destination, overwrite);
}
}
bool UBFileSystemUtils::deleteFile(const QString &path)
{
QFile f(path);
......
......@@ -49,6 +49,10 @@ class UBFileSystemUtils
static bool moveDir(const QString& pSourceDirPath, const QString& pTargetDirPath);
static bool copyFile(const QString &source, const QString &destination, bool overwrite = false);
static bool copy(const QString &source, const QString &Destination, bool overwrite = false);
static QString cleanName(const QString& name);
static QString digitFileFormat(const QString& s, int digit);
......@@ -73,8 +77,6 @@ class UBFileSystemUtils
static bool isAZipFile(QString &filePath);
static bool copyFile(const QString &source, const QString &Destination, bool overwrite = false);
static bool deleteFile(const QString &path);
/**
* Compress a source directory in a zip file.
......
......@@ -231,7 +231,6 @@ void UBActionPalette::mouseReleaseEvent(QMouseEvent * event)
void UBActionPalette::actionChanged()
{
emit itemOnActionPaletteChanged();
for(int i = 0; i < mActions.length() && i < mButtons.length(); i++)
{
mButtons.at(i)->setVisible(mActions.at(i)->isVisible());
......
......@@ -61,7 +61,6 @@ class UBActionPalette : public UBFloatingPalette
void closed();
void buttonGroupClicked(int id);
void customMouseReleased();
void itemOnActionPaletteChanged();
protected:
virtual void paintEvent(QPaintEvent *event);
......
......@@ -44,3 +44,8 @@ UBDockTeacherGuideWidget::~UBDockTeacherGuideWidget()
DELETEPTR(mpTeacherGuideWidget);
DELETEPTR(mpLayout);
}
UBTeacherGuideWidget* UBDockTeacherGuideWidget::teacherGuideWidget()
{
return mpTeacherGuideWidget;
}
......@@ -31,6 +31,8 @@ public:
bool visibleInMode(eUBDockPaletteWidgetMode mode){ return mode == eUBDockPaletteWidget_BOARD; }
UBTeacherGuideWidget* teacherGuideWidget();
private:
QVBoxLayout* mpLayout;
UBTeacherGuideWidget* mpTeacherGuideWidget;
......
......@@ -86,7 +86,9 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
{
const QPixmap* pix = source->pageAt(i);
UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i);
UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(tr("Page %0").arg(UBDocumentContainer::pageFromSceneIndex(i)));
int pageIndex = UBDocumentContainer::pageFromSceneIndex(i);
QString label = pageIndex == 0 ? tr("Title page") : tr("Page %0").arg(pageIndex);
UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label);
UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem);
thumbWithText.setBorder(border());
......
#include "UBFeaturesActionBar.h"
#include "core/memcheck.h"
#include "gui/UBFeaturesWidget.h"
UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWidget* parent, const char* name ) : QWidget (parent)
, featuresController(controller)
......@@ -8,6 +9,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
, mLayout(NULL)
, mpFavoriteAction(NULL)
, mpSocialAction(NULL)
, mpRescanModelAction(NULL)
, mpDeleteAction(NULL)
, mpSearchAction(NULL)
, mpCloseAction(NULL)
......@@ -15,6 +17,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
, mpNewFolderAction(NULL)
, mpFavoriteBtn(NULL)
, mpSocialBtn(NULL)
, mpRescanModelBtn(NULL)
, mpDeleteBtn(NULL)
, mpCloseBtn(NULL)
, mpRemoveFavoriteBtn(NULL)
......@@ -38,6 +41,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mpFavoriteAction = new QAction(QIcon(":/images/libpalette/miniFavorite.png"), tr("Add to favorites"), this);
mpSocialAction = new QAction(QIcon(":/images/libpalette/social.png"), tr("Share"), this);
mpSearchAction = new QAction(QIcon(":/images/libpalette/miniSearch.png"), tr("Search"), this);
mpRescanModelAction = new QAction(QIcon(":/images/cursors/rotate.png"), tr("Rescan file system"), this);
mpDeleteAction = new QAction(QIcon(":/images/libpalette/miniTrash.png"), tr("Delete"), this);
mpCloseAction = new QAction(QIcon(":/images/close.svg"), tr("Back to folder"), this);
mpRemoveFavorite = new QAction(QIcon(":/images/libpalette/trash_favorite.svg"), tr("Remove from favorites"), this);
......@@ -46,6 +50,10 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
// Create the buttons
mpFavoriteBtn = new UBActionButton(this, mpFavoriteAction);
mpSocialBtn = new UBActionButton(this, mpSocialAction);
//mpSearchBtn = new UBActionButton(this, mpSearchAction);
mpRescanModelBtn = new UBActionButton(this, mpRescanModelAction);
mpDeleteBtn = new UBActionButton(this, mpDeleteAction);
mpCloseBtn = new UBActionButton(this, mpCloseAction);
mpRemoveFavoriteBtn = new UBActionButton(this, mpRemoveFavorite);
......@@ -77,14 +85,17 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString)));
connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));
connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite()));
connect(mpRescanModelAction, SIGNAL(triggered()), this , SLOT(onActionRescanModel()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
// Build the default toolbar
mLayout->addWidget(mpFavoriteBtn);
mLayout->addWidget(mpSocialBtn);
mLayout->addWidget(mpNewFolderBtn);
mLayout->addWidget(mSearchBar);
//mLayout->addWidget(mpSearchBtn);
mLayout->addWidget(mpRescanModelBtn);
mLayout->addWidget(mpDeleteBtn);
mLayout->addWidget(mpCloseBtn);
mLayout->addWidget(mpRemoveFavoriteBtn);
......@@ -113,6 +124,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn->show();
mpNewFolderBtn->setEnabled(true);
mpDeleteBtn->setEnabled(true);
mpRescanModelBtn->show();
break;
case IN_ROOT:
mpFavoriteBtn->show();
......@@ -124,6 +136,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn->show();
mpNewFolderBtn->setEnabled(false);
mpDeleteBtn->setEnabled(false);
mpRescanModelBtn->show();
break;
case IN_PROPERTIES:
mpFavoriteBtn->show();
......@@ -134,6 +147,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide();
mpRemoveFavoriteBtn->hide();
mpNewFolderBtn->hide();
mpRescanModelBtn->hide();
break;
case IN_FAVORITE:
mpFavoriteBtn->hide();
......@@ -144,6 +158,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide();
mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide();
mpRescanModelBtn->hide();
break;
case IN_TRASH:
mpFavoriteBtn->hide();
......@@ -156,6 +171,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide();
//mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide();
mpRescanModelBtn->hide();
break;
default:
break;
......@@ -187,48 +203,57 @@ void UBFeaturesActionBar::onActionTrash()
{
emit deleteSelectedElements();
}
/*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
void UBFeaturesActionBar::onActionRescanModel()
{
event->acceptProposedAction();
emit rescanModel();
}
*/
void UBFeaturesActionBar::dragEnterEvent( QDragEnterEvent *event )
{
if (event->mimeData()->hasFormat("text/uri-list"))
{
const UBFeaturesMimeData *fMimeData = qobject_cast<const UBFeaturesMimeData*>(event->mimeData());
if (fMimeData) {
event->acceptProposedAction();
}
} else {
event->ignore();
}
}
void UBFeaturesActionBar::dropEvent( QDropEvent *event )
void UBFeaturesActionBar::dropEvent(QDropEvent *event)
{
QWidget *dest = childAt( event->pos() );
if ( dest == mpDeleteBtn )
{
QList <QUrl> urls = event->mimeData()->urls();
foreach ( QUrl url, urls )
{
if ( !UBFeaturesController::isDeletable( url ) )
return;
}
event->setDropAction( Qt::MoveAction );
const UBFeaturesMimeData *fMimeData = qobject_cast<const UBFeaturesMimeData*>(event->mimeData());
if (!fMimeData) {
qWarning() << "data came from not supported widget";
event->ignore();
return;
}
QWidget *dest = childAt(event->pos());
if (dest == mpDeleteBtn) {
QList<UBFeature> featuresList = fMimeData->features();
foreach (UBFeature curFeature, featuresList) {
if (!curFeature.isDeletable()) {
qWarning() << "Undeletable feature found, stopping deleting process";
event->ignore();
return;
}
}
event->setDropAction(Qt::MoveAction);
event->accept();
emit deleteElements( *event->mimeData() );
}
else if ( dest == mpFavoriteBtn )
{
event->setDropAction( Qt::CopyAction );
emit deleteElements(fMimeData);
} else if (dest == mpFavoriteBtn) {
event->setDropAction( Qt::CopyAction);
event->accept();
emit addToFavorite( *event->mimeData() );
}
else if ( dest == mpRemoveFavoriteBtn )
{
emit addToFavorite(fMimeData);
} else if (dest == mpRemoveFavoriteBtn) {
event->setDropAction( Qt::MoveAction );
event->accept();
emit removeFromFavorite( *event->mimeData() );
emit removeFromFavorite(fMimeData);
}
}
......
......@@ -7,6 +7,8 @@
#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h"
class UBFeaturesMimeData;
enum UBFeaturesActionBarState
{
IN_ROOT,
......@@ -24,25 +26,30 @@ public:
~UBFeaturesActionBar();
void setCurrentState( UBFeaturesActionBarState state );
signals:
void searchElement(const QString &text);
void newFolderToCreate();
void deleteElements( const QMimeData &data );
void addToFavorite( const QMimeData &data );
void removeFromFavorite( const QMimeData &data );
void deleteElements(const UBFeaturesMimeData *data);
void addToFavorite(const UBFeaturesMimeData *data);
void removeFromFavorite(const UBFeaturesMimeData *data);
void addElementsToFavorite();
void removeElementsFromFavorite();
void deleteSelectedElements();
void rescanModel();
private slots:
void onSearchTextChanged(QString txt);
void onActionNewFolder();
void onActionFavorite();
void onActionRemoveFavorite();
void onActionTrash();
void onActionRescanModel();
protected:
//void dragMoveEvent(QDragMoveEvent *event);
void dragEnterEvent( QDragEnterEvent *event );
void dragEnterEvent( QDragEnterEvent *event );
void dropEvent( QDropEvent *event );
private:
void setButtons();
UBFeaturesController *featuresController;
......@@ -56,6 +63,7 @@ private:
QHBoxLayout* mLayout;
QAction* mpFavoriteAction;
QAction* mpSocialAction;
QAction* mpRescanModelAction;
QAction* mpDeleteAction;
QAction* mpSearchAction;
QAction* mpCloseAction;
......@@ -63,13 +71,11 @@ private:
QAction* mpNewFolderAction;
UBActionButton* mpFavoriteBtn;
UBActionButton* mpSocialBtn;
UBActionButton* mpRescanModelBtn;
UBActionButton* mpDeleteBtn;
//UBActionButton* mpSearchBtn;
UBActionButton* mpCloseBtn;
UBActionButton* mpRemoveFavoriteBtn;
UBActionButton* mpNewFolderBtn;
};
#endif
\ No newline at end of file
#endif
......@@ -10,353 +10,226 @@
#include "globals/UBGlobals.h"
#include "board/UBBoardController.h"
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
: UBDockPaletteWidget(parent)
, imageGatherer(NULL)
const char *objNamePathList = "PathList";
const char *objNameFeatureList = "FeatureList";
const QMargins FeatureListMargins(0, 0, 0, 30);
const int FeatureListBorderOffset = 10;
const char featureTypeSplitter = ':';
static const QString mimeSankoreFeatureTypes = "Sankore/featureTypes";
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent), imageGatherer(NULL)
{
setObjectName(name);
mName = "FeaturesWidget";
mVisibleState = true;
int currentIconSize = UBSettings::settings()->libraryIconSize();
SET_STYLE_SHEET();
//setAttribute(Qt::WA_StyledBackground, true);
//setStyleSheet(UBApplication::globalStyleSheet());
SET_STYLE_SHEET();
mIconToLeft = QPixmap(":images/library_open.png");
mIconToRight = QPixmap(":images/library_close.png");
setAcceptDrops(true);
stackedWidget = new QStackedWidget(this);
layout = new QVBoxLayout(this);
controller = new UBFeaturesController(this);
//Main UBFeature functionality
controller = new UBFeaturesController(this);
featuresModel = new UBFeaturesModel(this);
featuresModel->setFeaturesList( controller->getFeatures() );
featuresModel->setSupportedDragActions( Qt::CopyAction | Qt::MoveAction );
featuresListView = new UBFeaturesListView(this);
pathListView = new UBFeaturesListView(this);
//Main layout including all the widgets in palette
layout = new QVBoxLayout(this);
//Path icon view on the top of the palette
pathListView = new UBFeaturesListView(this, objNamePathList);
controller->assignPathListView(pathListView);
featuresProxyModel = new UBFeaturesProxyModel(this);
featuresProxyModel->setFilterFixedString( controller->getRootPath() );
featuresProxyModel->setSourceModel( featuresModel );
featuresProxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
//Maintains the view of the main part of the palette. Consists of
//mNavigator
//featureProperties
//webVeiw
stackedWidget = new QStackedWidget(this);
featuresSearchModel = new UBFeaturesSearchProxyModel(this);
featuresSearchModel->setSourceModel( featuresModel );
featuresSearchModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
//Main features icon view with QSlider on the bottom
mNavigator = new UBFeaturesNavigatorWidget(this);
controller->assignFeaturesListVeiw(mNavigator->listView());
mNavigator->setSliderPosition(UBSettings::settings()->featureSliderPosition->get().toInt());
featuresPathModel = new UBFeaturesPathProxyModel(this);
featuresPathModel->setPath( controller->getRootPath() );
featuresPathModel->setSourceModel( featuresModel );
//Specifies the properties of a standalone element
featureProperties = new UBFeatureProperties(this);
//featuresListView->setStyleSheet( QString("background: #EEEEEE;border-radius: 10px;border: 2px solid #999999;") );
featuresListView->setDragDropMode( QAbstractItemView::DragDrop );
featuresListView->setSelectionMode( QAbstractItemView::ContiguousSelection );
featuresListView->setModel( featuresProxyModel );
featuresListView->setResizeMode( QListView::Adjust );
featuresListView->setViewMode( QListView::IconMode );
itemDelegate = new UBFeaturesItemDelegate( this, featuresListView );
featuresListView->setItemDelegate( itemDelegate );
//featuresListView->setSelectionRectVisible(false);
featuresListView->setIconSize( QSize(currentIconSize, currentIconSize) );
featuresListView->setGridSize( QSize(currentIconSize * 1.75, currentIconSize * 1.75) );
//pathListView->setStyleSheet( QString("background: #EEEEEE; border-radius : 10px; border : 2px solid #999999;") );
pathListView->setModel( featuresPathModel );
pathListView->setViewMode( QListView::IconMode );
pathListView->setIconSize( QSize(defaultThumbnailSize - 10, defaultThumbnailSize - 10) );
pathListView->setGridSize( QSize(defaultThumbnailSize + 10, defaultThumbnailSize - 10) );
pathListView->setFixedHeight( 60 );
pathItemDelegate = new UBFeaturesPathItemDelegate( this );
pathListView->setItemDelegate( pathItemDelegate );
pathListView->setSelectionMode( QAbstractItemView::NoSelection );
pathListView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
pathListView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
pathListView->setFlow( QListView::LeftToRight );
pathListView->setWrapping(false);
//pathListView->setResizeMode( QListView::Adjust );
//pathListView->setMovement( QListView::Static );
pathListView->setDragDropMode( QAbstractItemView::DropOnly );
//Used to show search bar on the search widget
webView = new UBFeaturesWebView(this);
//pathViewer = new UBFeaturesPathViewer( QPixmap(":images/libpalette/home.png"), controller->getRootPath(), pathScene, this );
featureProperties = new UBFeatureProperties(this);
webView = new UBFeaturesWebView(this);
//layout->addWidget( pathViewer );
//pathViewer->show();
//layout->addWidget( featuresListView );
layout->addWidget( pathListView );
layout->addWidget( stackedWidget );
stackedWidget->addWidget( featuresListView );
stackedWidget->addWidget( featureProperties );
stackedWidget->addWidget( webView );
stackedWidget->setCurrentIndex(ID_LISTVIEW);
currentStackedWidget = ID_LISTVIEW;
mActionBar = new UBFeaturesActionBar(controller, this);
thumbSlider = new QSlider( Qt::Horizontal, featuresListView );
thumbSlider->setMinimum( minThumbnailSize );
thumbSlider->setMaximum( maxThumbnailSize );
thumbSlider->setValue(currentIconSize);
//qDebug() << "init" << featuresListView->height();
thumbSlider->move( 0, featuresListView->height() );
thumbSlider->resize( thumbSlider->width(), thumbSlider->height() + 4 );
thumbSlider->show();
featuresListView->installEventFilter(this);
//layout->addWidget( thumbSlider );
layout->addWidget( mActionBar );
/*connect(featuresListView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex &, const QModelIndex & )),
this, SLOT(currentSelected(const QModelIndex &)));*/
connect( featuresListView, SIGNAL(clicked ( const QModelIndex & ) ),
this, SLOT( currentSelected(const QModelIndex &) ) );
connect( mActionBar, SIGNAL( searchElement(const QString &) ), this, SLOT( searchStarted(const QString &) ) );
connect( mActionBar, SIGNAL( newFolderToCreate() ), this, SLOT( createNewFolder() ) );
connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) );
connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) );
connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) );
connect( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) );
connect( mActionBar, SIGNAL( removeElementsFromFavorite() ), this, SLOT ( removeElementsFromFavorite() ) );
connect( mActionBar, SIGNAL( deleteSelectedElements() ), this, SLOT( deleteSelectedElements() ) );
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ),
this, SLOT( currentPathChanged( const QModelIndex & ) ) );
//connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) );
connect(thumbSlider, SIGNAL(valueChanged(int)), this, SLOT(thumbnailSizeChanged(int)));
connect( UBApplication::boardController, SIGNAL( displayMetadata( QMap<QString,QString> ) ),
this, SLOT( onDisplayMetadata( QMap<QString,QString> ) ) );
connect( UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray ) ),
this, SLOT( onAddDownloadedFileToLibrary( bool, QUrl, QString,QByteArray ) ) );
//filling stackwidget
stackedWidget->addWidget(mNavigator);
stackedWidget->addWidget(featureProperties);
stackedWidget->addWidget(webView);
stackedWidget->setCurrentIndex(ID_LISTVIEW);
currentStackedWidget = ID_LISTVIEW;
//Bottom actionbar for DnD, quick search etc
mActionBar = new UBFeaturesActionBar(controller, this);
//Filling main layout
layout->addWidget(pathListView);
layout->addWidget(stackedWidget);
layout->addWidget(mActionBar);
connect(mNavigator->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &)));
connect(mActionBar, SIGNAL(searchElement(const QString &)), this, SLOT( searchStarted(const QString &)));
connect(mActionBar, SIGNAL(newFolderToCreate()), this, SLOT(createNewFolder()));
connect(mActionBar, SIGNAL(deleteElements(const UBFeaturesMimeData *)), this, SLOT(deleteElements(const UBFeaturesMimeData *)));
connect(mActionBar, SIGNAL(deleteSelectedElements()), this, SLOT(deleteSelectedElements()));
connect(mActionBar, SIGNAL(addToFavorite(const UBFeaturesMimeData *)), this, SLOT(addToFavorite(const UBFeaturesMimeData *)));
connect(mActionBar, SIGNAL(removeFromFavorite(const UBFeaturesMimeData *)), this, SLOT(removeFromFavorite(const UBFeaturesMimeData *)));
connect(mActionBar, SIGNAL(addElementsToFavorite() ), this, SLOT ( addElementsToFavorite()) );
connect(mActionBar, SIGNAL(removeElementsFromFavorite()), this, SLOT (removeElementsFromFavorite()));
connect(mActionBar, SIGNAL(rescanModel()), this, SLOT(rescanModel()));
connect(pathListView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &)));
connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata( QMap<QString,QString>)));
connect(UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray))
, this, SLOT(onAddDownloadedFileToLibrary(bool, QUrl, QString,QByteArray)));
}
UBFeaturesWidget::~UBFeaturesWidget()
{
if ( thumbSlider != NULL )
{
delete thumbSlider;
thumbSlider = NULL;
}
if (NULL != imageGatherer)
delete imageGatherer;
}
bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event )
{
if ( target == featuresListView && event->type() == QEvent::Resize )
{
thumbSlider->move( 10, featuresListView->height() - thumbSlider->height() - 10 );
thumbSlider->resize( featuresListView->width() - 20, thumbSlider->height() );
//qDebug() << featuresListView->height();
//return true;
}
return UBDockPaletteWidget::eventFilter(target, event);
}
void UBFeaturesWidget::searchStarted( const QString &pattern )
void UBFeaturesWidget::searchStarted(const QString &pattern)
{
if ( pattern.isEmpty() )
{
featuresListView->setModel( featuresProxyModel );
featuresProxyModel->invalidate();
}
else if ( pattern.size() > 2 )
{
featuresSearchModel->setFilterWildcard( "*" + pattern + "*" );
featuresListView->setModel( featuresSearchModel );
featuresSearchModel->invalidate();
}
controller->searchStarted(pattern, mNavigator->listView());
}
void UBFeaturesWidget::currentSelected(const QModelIndex &current)
{
if (current.isValid())
{
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
/*QString name = model->data(current).toString();
QString path = model->data(current, Qt::UserRole).toString();
eUBLibElementType type = (eUBLibElementType)model->data(current, Qt::UserRole + 1).toInt();*/
UBFeature feature = model->data(current, Qt::UserRole + 1).value<UBFeature>();
if (!current.isValid()) {
qWarning() << "SLOT:currentSelected, invalid index catched";
return;
}
if ( feature.isFolder() )
{
QString newPath = feature.getFullVirtualPath();
//pathViewer->addPathElement( feature.getThumbnail(), newPath );
controller->setCurrentElement( feature );
QString objName = sender()->objectName();
model->setFilterFixedString( newPath );
model->invalidate();
switchToListView();
if (objName.isEmpty()) {
qWarning() << "incorrrect sender";
}
featuresPathModel->setPath( newPath );
featuresPathModel->invalidate();
if ( feature.getType() == FEATURE_FAVORITE )
{
mActionBar->setCurrentState( IN_FAVORITE );
}
else if (feature.getType() == FEATURE_TRASH)
{
mActionBar->setCurrentState( IN_TRASH );
}
else
{
mActionBar->setCurrentState( IN_FOLDER );
}
}
else if ( feature.getType() == FEATURE_SEARCH )
{
webView->showElement( feature );
switchToWebView();
}
else
{
featureProperties->showElement( feature );
switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES );
}
}
}
QListView *calledList = 0;
if (objName == objNamePathList) {
calledList = pathListView;
} else if (objName == objNameFeatureList) {
calledList = mNavigator->listView();
}
void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
{
if ( index.isValid() )
{
UBFeature feature = featuresPathModel->data(index, Qt::UserRole + 1).value<UBFeature>();
QString newPath = feature.getFullVirtualPath();
featuresPathModel->setPath( newPath );
featuresPathModel->invalidate();
featuresListView->setModel( featuresProxyModel );
featuresProxyModel->setFilterFixedString(newPath);
featuresProxyModel->invalidate();
switchToListView();
controller->setCurrentElement( feature );
if ( feature.getType() == FEATURE_CATEGORY && feature.getName() == "root" )
{
mActionBar->setCurrentState( IN_ROOT );
}
else if (feature.getType() == FEATURE_FAVORITE)
{
mActionBar->setCurrentState( IN_FAVORITE );
}
else if (feature.getType() == FEATURE_TRASH)
{
mActionBar->setCurrentState( IN_TRASH );
}
else
{
mActionBar->setCurrentState( IN_FOLDER );
}
}
UBFeature feature = controller->getFeature(current, calledList);
// QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( mNavigator->listView()->model() );
// UBFeature feature = model->data(current, Qt::UserRole + 1).value<UBFeature>();
if ( feature.isFolder() ) {
QString newPath = feature.getFullVirtualPath();
controller->setCurrentElement(feature);
controller->siftElements(newPath);
switchToListView();
if ( feature.getType() == FEATURE_FAVORITE ) {
mActionBar->setCurrentState( IN_FAVORITE );
} else if ( feature.getType() == FEATURE_CATEGORY && feature.getName() == "root" ) {
mActionBar->setCurrentState( IN_ROOT );
} else if (feature.getType() == FEATURE_TRASH) {
mActionBar->setCurrentState( IN_TRASH );
} else {
mActionBar->setCurrentState( IN_FOLDER );
}
} else if ( feature.getType() == FEATURE_SEARCH ) {
webView->showElement( feature );
switchToWebView();
} else {
featureProperties->showElement( feature );
switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES );
}
}
void UBFeaturesWidget::createNewFolder()
{
UBNewFolderDlg dlg;
if(QDialog::Accepted == dlg.exec())
{
UBFeature newFolder = controller->newFolder( dlg.folderName() );
featuresModel->addItem( newFolder );
featuresProxyModel->invalidate();
if(QDialog::Accepted == dlg.exec()) {
controller->addNewFolder(dlg.folderName());
}
}
void UBFeaturesWidget::deleteElements( const QMimeData & mimeData )
void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData )
{
if ( !mimeData.hasUrls() )
return;
QList<QUrl> urls = mimeData.urls();
if (!mimeData->features().count() )
return;
QList<UBFeature> featuresList = mimeData->features();
foreach ( QUrl url, urls )
{
if ( controller->isTrash( url ) )
{
controller->deleteItem( url );
}
else
{
UBFeature elem = controller->moveItemToFolder( url, controller->getTrashElement() );
controller->removeFromFavorite( url );
featuresModel->addItem( elem );
featuresModel->deleteFavoriteItem( UBFeaturesController::fileNameFromUrl( url ) );
}
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
foreach ( UBFeature curFeature, featuresList ) {
if ( curFeature.inTrash()) {
controller->deleteItem(curFeature.getFullPath());
} else {
controller->moveToTrash(curFeature);
}
}
controller->refreshModels();
}
void UBFeaturesWidget::deleteSelectedElements()
{
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes();
QList <QUrl> urls;
foreach ( QModelIndex sel, selected )
{
UBFeature feature = sel.data( Qt::UserRole + 1 ).value<UBFeature>();
if ( feature.isDeletable() )
urls.append( feature.getFullPath() );
}
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes();
foreach (QUrl url, urls)
foreach ( QModelIndex sel, selected )
{
if ( controller->isTrash( url ) )
{
controller->deleteItem( url );
}
else
{
UBFeature elem = controller->moveItemToFolder( url, controller->getTrashElement() );
controller->removeFromFavorite( url );
featuresModel->addItem( elem );
featuresModel->deleteFavoriteItem( url.toString() );
}
featuresModel->deleteItem( url.toString() );
UBFeature feature = sel.data(Qt::UserRole + 1).value<UBFeature>();
if (feature.isDeletable()) {
if (feature.inTrash()) {
controller->deleteItem(feature);
} else {
controller->moveToTrash(feature, true);
}
}
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
controller->refreshModels();
}
void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData )
void UBFeaturesWidget::rescanModel()
{
if ( !mimeData.hasUrls() )
return;
QList<QUrl> urls = mimeData.urls();
foreach ( QUrl url, urls )
{
UBFeature elem = controller->addToFavorite( url );
if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() )
featuresModel->addItem( elem );
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
controller->rescanModel();
}
void UBFeaturesWidget::removeFromFavorite( const QMimeData & mimeData )
void UBFeaturesWidget::addToFavorite( const UBFeaturesMimeData * mimeData )
{
if ( !mimeData.hasUrls() )
return;
QList<QUrl> urls = mimeData.urls();
foreach( QUrl url, urls )
{
controller->removeFromFavorite( url );
}
if ( !mimeData->hasUrls() )
return;
QList<QUrl> urls = mimeData->urls();
foreach ( QUrl url, urls ) {
controller->addToFavorite(url);
}
controller->refreshModels();
}
void UBFeaturesWidget::thumbnailSizeChanged( int value )
void UBFeaturesWidget::removeFromFavorite( const UBFeaturesMimeData * mimeData )
{
featuresListView->setIconSize( QSize( value, value ) );
featuresListView->setGridSize( QSize( value * 1.75, value * 1.75 ) );
UBSettings::settings()->setLibraryIconsize(value);
if ( !mimeData->hasUrls() )
return;
QList<QUrl> urls = mimeData->urls();
foreach( QUrl url, urls ) {
controller->removeFromFavorite(url);
}
}
void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
......@@ -418,61 +291,47 @@ void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QS
void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData)
{
if ( pSuccess )
{
UBFeature newFeature = controller->addDownloadedFile( sourceUrl, pData );
if ( newFeature != UBFeature() )
{
featuresModel->addItem( newFeature );
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
}
Q_UNUSED(pContentHeader)
if (pSuccess) {
controller->addDownloadedFile(sourceUrl, pData);
controller->refreshModels();
}
}
void UBFeaturesWidget::addElementsToFavorite()
{
if ( currentStackedWidget == ID_PROPERTIES )
{
if ( currentStackedWidget == ID_PROPERTIES ) {
UBFeature feature = featureProperties->getCurrentElement();
if ( feature != UBFeature() && !UBApplication::isFromWeb( feature.getFullPath().toString() ) )
{
UBFeature elem = controller->addToFavorite( feature.getFullPath() );
featuresModel->addItem( elem );
if ( feature != UBFeature() && !UBApplication::isFromWeb(feature.getFullPath().toString())) {
controller->addToFavorite( feature.getFullPath() );
}
}
else if ( currentStackedWidget == ID_LISTVIEW )
{
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes();
for ( int i = 0; i < selected.size(); ++i )
{
} else if ( currentStackedWidget == ID_LISTVIEW ) {
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes();
for ( int i = 0; i < selected.size(); ++i ) {
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
UBFeature elem = controller->addToFavorite( feature.getFullPath() );
if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() )
featuresModel->addItem( elem );
}
controller->addToFavorite(feature.getFullPath());
}
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
controller->refreshModels();
}
void UBFeaturesWidget::removeElementsFromFavorite()
{
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes();
//qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes();
QList <QUrl> items;
for ( int i = 0; i < selected.size(); ++i )
{
for ( int i = 0; i < selected.size(); ++i ) {
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
items.append( feature.getFullPath() );
}
foreach ( QUrl url, items )
{
controller->removeFromFavorite( url );
featuresModel->deleteFavoriteItem( url.toString() );
foreach ( QUrl url, items ) {
controller->removeFromFavorite(url, true);
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
controller->refreshModels();
}
void UBFeaturesWidget::switchToListView()
......@@ -493,77 +352,94 @@ void UBFeaturesWidget::switchToWebView()
currentStackedWidget = ID_WEBVIEW;
}
/*
void UBFeaturesWidget::currentPathChanged(const QString &path)
QStringList UBFeaturesMimeData::formats() const
{
int newDepth = path.count("/");
pathViewer->truncatePath(newDepth);
featuresListView->setModel( featuresProxyModel );
featuresProxyModel->setFilterFixedString(path);
featuresProxyModel->invalidate();
switchToListView();
return QMimeData::formats();
}
*/
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name )
: QListView(parent)
{
setObjectName(name);
//rubberBand = new UBRubberBand( QRubberBand::Rectangle, this );
}
/*
void UBFeaturesListView::mousePressEvent( QMouseEvent *event )
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event )
{
rubberOrigin = event->pos();
rubberBand->setGeometry( QRect( rubberOrigin, QSize() ) );
//qDebug() << rubberOrigin.x() << rubberOrigin.y();
rubberBand->show();
QListView::mousePressEvent(event);
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() )
event->acceptProposedAction();
}
void UBFeaturesListView::mouseMoveEvent( QMouseEvent *event )
void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event )
{
QPoint current = event->pos();
rubberBand->setGeometry( QRect( rubberOrigin, current ).normalized() );
const UBFeaturesMimeData *fMimeData = qobject_cast<const UBFeaturesMimeData*>(event->mimeData());
QModelIndex index = indexAt(event->pos());
UBFeature onFeature = model()->data(index, Qt::UserRole + 1).value<UBFeature>();
if (fMimeData) {
if (!index.isValid() || !onFeature.isFolder()) {
event->ignore();
return;
}
}
//setSelection( rubberBand->rect(), QItemSelectionModel::Select );
QListView::mouseMoveEvent(event);
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() ) {
event->acceptProposedAction();
} else {
event->ignore();
}
}
void UBFeaturesListView::mouseReleaseEvent( QMouseEvent *event )
void UBFeaturesListView::dropEvent( QDropEvent *event )
{
rubberBand->hide();
QListView::mouseReleaseEvent(event);
QWidget *eventSource = event->source();
if (eventSource && eventSource->objectName() == objNameFeatureList) {
event->setDropAction( Qt::MoveAction );
}
QListView::dropEvent( event );
}
*/
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event )
void UBFeaturesListView::thumbnailSizeChanged( int value )
{
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() )
event->acceptProposedAction();
setIconSize(QSize(value, value));
setGridSize(QSize(value + 20, value + 20 ));
UBSettings::settings()->featureSliderPosition->set(value);
}
void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event )
UBFeaturesNavigatorWidget::UBFeaturesNavigatorWidget(QWidget *parent, const char *name) :
QWidget(parent), mListView(0), mListSlder(0)
{
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() )
event->acceptProposedAction();
name = "UBFeaturesNavigatorWidget";
setObjectName(name);
SET_STYLE_SHEET()
mListView = new UBFeaturesListView(this, objNameFeatureList);
mListSlder = new QSlider(Qt::Horizontal, this);
mListSlder->setMinimum(UBFeaturesWidget::minThumbnailSize);
mListSlder->setMaximum(UBFeaturesWidget::maxThumbnailSize);
mListSlder->setValue(UBFeaturesWidget::minThumbnailSize);
mListSlder->setMinimumHeight(20);
mListView->setParent(this);
QVBoxLayout *mainLayer = new QVBoxLayout(this);
mainLayer->addWidget(mListView, 1);
mainLayer->addWidget(mListSlder, 0);
connect(mListSlder, SIGNAL(valueChanged(int)), mListView, SLOT(thumbnailSizeChanged(int)));
}
void UBFeaturesListView::dropEvent( QDropEvent *event )
void UBFeaturesNavigatorWidget::setSliderPosition(int pValue)
{
if( event->source() && dynamic_cast<UBFeaturesListView *>( event->source() ) )
{
event->setDropAction( Qt::MoveAction );
}
QListView::dropEvent( event );
mListSlder->setValue(pValue);
}
UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL)
, mpWebSettings(NULL)
......@@ -664,15 +540,14 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
, mpAddToLibButton(NULL)
, mpSetAsBackgroundButton(NULL)
, mpObjInfoLabel(NULL)
, mpObjInfos(NULL)
, mpThumbnail(NULL)
, mpOrigPixmap(NULL)
, mpElement(NULL)
, mpObjInfos(NULL)
{
setObjectName(name);
SET_STYLE_SHEET();
//setStyleSheet(UBApplication::globalStyleSheet());
// Create the GUI
mpLayout = new QVBoxLayout(this);
......@@ -790,6 +665,7 @@ UBFeature UBFeatureProperties::getCurrentElement() const
{
if ( mpElement )
return *mpElement;
return UBFeature();
}
......@@ -926,7 +802,6 @@ UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPus
UBFeatureItemButton::~UBFeatureItemButton()
{
}
QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
......@@ -934,18 +809,17 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
if (role == Qt::DisplayRole)
if (role == Qt::DisplayRole) {
return featuresList->at(index.row()).getName();
else if (role == Qt::DecorationRole)
{
}
else if (role == Qt::DecorationRole) {
return QIcon( featuresList->at(index.row()).getThumbnail() );
}
else if (role == Qt::UserRole)
{
} else if (role == Qt::UserRole) {
return featuresList->at(index.row()).getVirtualPath();
}
else if (role == Qt::UserRole + 1)
{
} else if (role == Qt::UserRole + 1) {
//return featuresList->at(index.row()).getType();
UBFeature f = featuresList->at(index.row());
return QVariant::fromValue( f );
......@@ -956,26 +830,29 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData *mimeData = new QMimeData();
UBFeaturesMimeData *mimeData = new UBFeaturesMimeData();
QList <QUrl> urlList;
QList <UBFeature> featuresList;
QByteArray typeData;
foreach (QModelIndex index, indexes)
{
if ( index.isValid() )
{
UBFeature element = data( index, Qt::UserRole + 1 ).value<UBFeature>();
foreach (QModelIndex index, indexes) {
if (index.isValid()) {
UBFeature element = data(index, Qt::UserRole + 1).value<UBFeature>();
urlList.push_back( element.getFullPath() );
/*if ( element.getType() == FEATURE_INTERNAL )
{
urlList.push_back( QUrl( element.getFullPath() ) );
}
else if ( element.getType() == FEATURE_INTERACTIVE || element.getType() == FEATURE_ITEM )
{
urlList.push_back( element.getFullPath() );
}*/
QString curPath = element.getFullPath().toLocalFile();
featuresList.append(element);
if (!typeData.isNull()) {
typeData += UBFeaturesController::featureTypeSplitter();
}
typeData += QString::number(element.getType()).toAscii();
}
}
mimeData->setUrls( urlList );
mimeData->setUrls(urlList);
mimeData->setFeatures(featuresList);
mimeData->setData(mimeSankoreFeatureTypes, typeData);
return mimeData;
}
......@@ -984,50 +861,41 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
{
Q_UNUSED(row)
if ( !mimeData->hasUrls() && !mimeData->hasImage() )
const UBFeaturesMimeData *fMimeData = qobject_cast<const UBFeaturesMimeData*>(mimeData);
bool dataFromSameModel = false;
if (fMimeData)
dataFromSameModel = true;
if ((!mimeData->hasUrls() && !mimeData->hasImage()) )
return false;
if ( action == Qt::IgnoreAction )
return true;
if ( column > 0 )
return false;
int endRow = 0;
UBFeature parentFeature;
if ( !parent.isValid() )
{
UBFeature parentFeature;
if (!parent.isValid()) {
parentFeature = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->getCurrentElement();
}
else
{
parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>();
}
if ( mimeData->hasUrls() )
{
QList<QUrl> urls = mimeData->urls();
foreach ( QUrl url, urls )
{
UBFeature element;
if ( action == Qt::MoveAction )
{
element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->moveItemToFolder( url, parentFeature );
}
else
{
element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->copyItemToFolder( url, parentFeature );
}
addItem( element );
}
} else {
parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>();
}
else if ( mimeData->hasImage() )
{
if (mimeData->hasUrls()) {
QList<UBFeature> featList = fMimeData->features();
for (int i = 0; i < featList.count(); i++) {
UBFeature sourceElement;
if (dataFromSameModel) {
sourceElement = featList.at(i);
moveData(sourceElement, parentFeature, Qt::MoveAction);
}
}
} else if ( mimeData->hasImage() ) {
QImage image = qvariant_cast<QImage>( mimeData->imageData() );
UBFeature element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->importImage( image, parentFeature );
addItem( element );
}
return true;
}
......@@ -1063,6 +931,16 @@ void UBFeaturesModel::deleteItem( const QString &path )
}
}
void UBFeaturesModel::deleteItem(const UBFeature &feature)
{
int i = featuresList->indexOf(feature);
if (i == -1) {
qDebug() << "no matches in deleting item from UBFEaturesModel";
return;
}
removeRow(i, QModelIndex());
}
bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent )
{
if ( row < 0 )
......@@ -1089,39 +967,100 @@ bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent )
return true;
}
void UBFeaturesModel::moveData(const UBFeature &source, const UBFeature &destination
, Qt::DropAction action = Qt::CopyAction, bool deleteManualy)
{
UBFeaturesController *curController = qobject_cast<UBFeaturesController *>(QObject::parent());
if (!curController)
return;
QString sourcePath = source.getFullPath().toLocalFile();
QString sourceVirtualPath = source.getVirtualPath();
UBFeatureElementType sourceType = source.getType();
QPixmap sourceIcon = source.getThumbnail();
Q_ASSERT( QFileInfo( sourcePath ).exists() );
QString name = QFileInfo( sourcePath ).fileName();
QString destPath = destination.getFullPath().toLocalFile();
QString destVirtualPath = destination.getFullVirtualPath();
QString destFullPath = destPath + "/" + name;
if ( sourcePath.compare(destFullPath, Qt::CaseInsensitive ) || destination.getType() != FEATURE_TRASH)
{
UBFileSystemUtils::copy(sourcePath, destFullPath);
if (action == Qt::MoveAction) {
curController->deleteItem( source.getFullPath() );
}
}
//Passing all the source container ubdating dependancy pathes
if (sourceType == FEATURE_FOLDER) {
for (int i = 0; i < featuresList->count(); i++) {
UBFeature &curFeature = (*featuresList)[i];
QString curFeatureFullPath = curFeature.getFullPath().toLocalFile();
QString curFeatureVirtualPath = curFeature.getVirtualPath();
if (curFeatureFullPath.contains(sourcePath) && curFeatureFullPath != sourcePath) {
UBFeature copyFeature = curFeature;
QUrl newPath = QUrl::fromLocalFile(curFeatureFullPath.replace(sourcePath, destFullPath));
QString newVirtualPath = curFeatureVirtualPath.replace(sourceVirtualPath, destVirtualPath);
//when copying to trash don't change the real path
if (destination.getType() != FEATURE_TRASH) {
// processing copy or move action for real FS
if (action == Qt::CopyAction) {
copyFeature.setFullPath(newPath);
} else {
curFeature.setFullPath(newPath);
}
}
// processing copy or move action for real FS
if (action == Qt::CopyAction) {
copyFeature.setFullVirtualPath(newVirtualPath);
} else {
curFeature.setFullVirtualPath(newVirtualPath);
}
if (action == Qt::CopyAction) {
addItem(copyFeature);
}
}
}
}
UBFeature newElement( destVirtualPath, sourceIcon, name, QUrl::fromLocalFile(destFullPath), sourceType );
addItem(newElement);
if (deleteManualy) {
deleteItem(source);
}
emit dataRestructured();
}
Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
{
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
Qt::ItemFlags resultFlags = QAbstractItemModel::flags(index);
if ( index.isValid() )
{
UBFeature item = index.data( Qt::UserRole + 1 ).value<UBFeature>();
if ( item.getType() == FEATURE_INTERACTIVE ||
item.getType() == FEATURE_ITEM ||
item.getType() == FEATURE_INTERNAL )
return Qt::ItemIsDragEnabled | defaultFlags;
if ( item.isFolder() && !item.getVirtualPath().isNull() )
return defaultFlags | Qt::ItemIsDropEnabled;
else return defaultFlags | Qt::ItemIsDropEnabled;
}
/*if ( index.isValid() )
{
UBFeature item = index.data( Qt::UserRole + 1 ).value<UBFeature>();
switch( item.getType() )
{
case FEATURE_CATEGORY:
case FEATURE_FOLDER:
case FEATURE_FAVORITE:
case FEATURE_TRASH:
return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
case FEATURE_INTERACTIVE:
case FEATURE_INTERNAL:
case FEATURE_ITEM:
return Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
default:;
}
}*/
return defaultFlags | Qt::ItemIsDropEnabled;
if ( item.getType() == FEATURE_INTERACTIVE
|| item.getType() == FEATURE_ITEM
|| item.getType() == FEATURE_INTERNAL
|| item.getType() == FEATURE_FOLDER)
resultFlags |= Qt::ItemIsDragEnabled;
if ( item.isFolder() && !item.getVirtualPath().isNull() )
resultFlags |= Qt::ItemIsDropEnabled;
}
return resultFlags;
}
......@@ -1134,13 +1073,12 @@ QStringList UBFeaturesModel::mimeTypes() const
int UBFeaturesModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid())
if (parent.isValid() || !featuresList)
return 0;
else
return featuresList->size();
}
bool UBFeaturesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
......@@ -1156,20 +1094,17 @@ bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIn
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>();
bool isFile = feature.getType() == FEATURE_INTERACTIVE ||
feature.getType() == FEATURE_INTERNAL ||
feature.getType() == FEATURE_ITEM;
bool isFile = feature.getType() == FEATURE_INTERACTIVE
|| feature.getType() == FEATURE_INTERNAL
|| feature.getType() == FEATURE_ITEM;
return isFile && filterRegExp().exactMatch( feature.getName() );
}
bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
/*QString name = sourceModel()->data(index, Qt::DisplayRole).toString();
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>();
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>();
return feature.isFolder() && path.startsWith( feature.getFullVirtualPath() );
}
......@@ -1182,13 +1117,13 @@ QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLoc
if (listView)
{
const QFontMetrics fm = listView->fontMetrics();
const QSize iSize = listView->iconSize();
const QSize iSize = listView->gridSize();
return elidedText( fm, iSize.width(), Qt::ElideRight, text );
}
return text;
}
UBFeaturesPathItemDelegate::UBFeaturesPathItemDelegate(QWidget *parent) : QStyledItemDelegate(parent)
UBFeaturesPathItemDelegate::UBFeaturesPathItemDelegate(QObject *parent) : QStyledItemDelegate(parent)
{
arrowPixmap = new QPixmap(":images/navig_arrow.png");
}
......
......@@ -16,13 +16,12 @@
#include <QDropEvent>
#include "UBDockPaletteWidget.h"
//#include "UBLibActionBar.h"
#include "core/UBSettings.h"
#include "board/UBFeaturesController.h"
#include "api/UBWidgetUniboardAPI.h"
#include "UBFeaturesActionBar.h"
#include "UBRubberBand.h"
#define THUMBNAIL_WIDTH 400
#define ID_LISTVIEW 0
#define ID_PROPERTIES 1
......@@ -41,6 +40,8 @@ class UBFeatureProperties;
class UBFeatureItemButton;
class UBFeaturesListView;
class UBFeaturesWebView;
class UBFeaturesNavigatorWidget;
class UBFeaturesMimeData;
class UBFeaturesWidget : public UBDockPaletteWidget
{
......@@ -54,82 +55,100 @@ public:
return mode == eUBDockPaletteWidget_BOARD
|| mode == eUBDockPaletteWidget_DESKTOP;
}
UBFeaturesController * getFeaturesController()const { return controller; };
UBFeaturesController * getFeaturesController() const { return controller; }
static const int minThumbnailSize = 20;
static const int maxThumbnailSize = 100;
static const int defaultThumbnailSize = 40;
private:
void switchToListView();
void switchToProperties();
void switchToWebView();
UBFeaturesController *controller;
UBFeaturesItemDelegate *itemDelegate;
UBFeaturesPathItemDelegate *pathItemDelegate;
UBFeaturesModel *featuresModel;
UBFeaturesProxyModel *featuresProxyModel;
UBFeaturesSearchProxyModel *featuresSearchModel;
UBFeaturesPathProxyModel *featuresPathModel;
UBFeaturesListView *featuresListView;
UBFeaturesListView *pathListView;
QSlider *thumbSlider;
QVBoxLayout *layout;
//UBFeaturesPathViewer *pathViewer;
//QGraphicsScene *pathScene;
UBFeaturesActionBar *mActionBar;
UBFeatureProperties *featureProperties;
UBFeaturesWebView *webView;
QStackedWidget *stackedWidget;
int currentStackedWidget;
UBDownloadHttpFile* imageGatherer;
public:
int scrollbarHorisontalPadding() const { return 10;}
int scrollbarVerticalIndent() const { return 0;}
private slots:
void onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void currentSelected( const QModelIndex & );
//void currentPathChanged(const QString &);
void currentPathChanged( const QModelIndex & );
void searchStarted( const QString & );
void createNewFolder();
void deleteElements( const QMimeData & );
void addToFavorite( const QMimeData & );
void removeFromFavorite( const QMimeData & );
void thumbnailSizeChanged( int );
void onDisplayMetadata( QMap<QString,QString> );
void currentSelected( const QModelIndex & );
void searchStarted( const QString & );
void createNewFolder();
void deleteElements( const UBFeaturesMimeData * );
void addToFavorite( const UBFeaturesMimeData *);
void removeFromFavorite( const UBFeaturesMimeData * );
void onDisplayMetadata( QMap<QString,QString> );
void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray);
void addElementsToFavorite();
void removeElementsFromFavorite();
void deleteSelectedElements();
void rescanModel();
private:
void switchToListView();
void switchToProperties();
void switchToWebView();
private:
UBFeaturesController *controller;
UBFeaturesNavigatorWidget *mNavigator;
UBFeaturesListView *pathListView;
QVBoxLayout *layout;
UBFeaturesActionBar *mActionBar;
UBFeatureProperties *featureProperties;
UBFeaturesWebView *webView;
QStackedWidget *stackedWidget;
int currentStackedWidget;
UBDownloadHttpFile* imageGatherer;
protected:
bool eventFilter(QObject *target, QEvent *event);
};
class UBFeaturesMimeData : public QMimeData
{
Q_OBJECT
public:
virtual QStringList formats() const;
QList<UBFeature> features() const {return mFeatures;}
void setFeatures(const QList<UBFeature> &fList) {mFeatures = fList;}
private:
QList<UBFeature> mFeatures;
};
class UBFeaturesListView : public QListView
{
Q_OBJECT
public:
UBFeaturesListView( QWidget* parent=0, const char* name="UBFeaturesListView" );
UBFeaturesListView( QWidget* parent=0, const char* name="UBFeaturesListView" );
virtual ~UBFeaturesListView() {;}
protected:
virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dropEvent( QDropEvent *event );
virtual void dropEvent( QDropEvent *event );
virtual void dragMoveEvent( QDragMoveEvent *event );
/*virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );*/
private slots:
void thumbnailSizeChanged(int);
};
// class created to have the same style for slider and QListView itself
class UBFeaturesNavigatorWidget: public QWidget
{
Q_OBJECT
public:
UBFeaturesNavigatorWidget(QWidget *parent, const char* name = "");
UBFeaturesListView *listView() {return mListView;}
void setSliderPosition(int pValue);
private:
//UBRubberBand *rubberBand;
//QPoint rubberOrigin;
UBFeaturesListView *mListView;
QSlider *mListSlder;
};
class UBFeaturesWebView : public QWidget
{
Q_OBJECT
......@@ -177,9 +196,9 @@ private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonLayout;
UBFeatureItemButton* mpAddPageButton;
UBFeatureItemButton* mpAddToLibButton;
UBFeatureItemButton* mpSetAsBackgroundButton;
UBFeatureItemButton *mpAddPageButton;
UBFeatureItemButton *mpAddToLibButton;
UBFeatureItemButton *mpSetAsBackgroundButton;
QLabel* mpObjInfoLabel;
QTreeWidget* mpObjInfos;
QLabel* mpThumbnail;
......@@ -189,9 +208,6 @@ private:
QTreeWidgetItem* mpItem;
};
class UBFeatureItemButton : public QPushButton
{
public:
......@@ -202,13 +218,18 @@ public:
class UBFeaturesModel : public QAbstractListModel
{
Q_OBJECT
signals:
void dataRestructured();
public:
UBFeaturesModel( QObject *parent = 0 ) : QAbstractListModel(parent) {;}
UBFeaturesModel(QList<UBFeature> *pFeaturesList, QObject *parent = 0) : QAbstractListModel(parent), featuresList(pFeaturesList) {;}
virtual ~UBFeaturesModel(){;}
void addItem( const UBFeature &item );
void deleteFavoriteItem( const QString &path );
void deleteItem( const QString &path );
void deleteItem(const UBFeature &feature);
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
QMimeData *mimeData( const QModelIndexList &indexes ) const;
......@@ -220,10 +241,11 @@ public:
bool removeRow(int row, const QModelIndex &parent = QModelIndex());
//bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
//bool insertRow(int row, const QModelIndex &parent = QModelIndex());
void moveData(const UBFeature &source, const UBFeature &destination, Qt::DropAction action, bool deleteManualy = false);
Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; }
// void setFeaturesList(QList <UBFeature> *flist ) { featuresList = flist; }
void setFeaturesList(QList <UBFeature> *flist ) { featuresList = flist; }
private:
QList <UBFeature> *featuresList;
};
......@@ -265,7 +287,7 @@ class UBFeaturesItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
UBFeaturesItemDelegate(QWidget *parent = 0, const QListView *lw = 0) : QStyledItemDelegate(parent) { listView = lw; }
UBFeaturesItemDelegate(QObject *parent = 0, const QListView *lw = 0) : QStyledItemDelegate(parent) { listView = lw; }
~UBFeaturesItemDelegate() {}
//UBFeaturesItemDelegate(const QListView *lw = 0) { listView = lw; };
//void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
......@@ -279,7 +301,7 @@ class UBFeaturesPathItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
UBFeaturesPathItemDelegate(QWidget *parent = 0);
UBFeaturesPathItemDelegate(QObject *parent = 0);
~UBFeaturesPathItemDelegate();
virtual QString displayText ( const QVariant & value, const QLocale & locale ) const;
void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
......
......@@ -74,8 +74,6 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name
mTimeFormat = mTimeFormat.remove(":s");
mTimerID = startTimer(1000);
//connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage()));
//connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(onSetDocOnPageNavigator(UBDocumentProxy*)));
}
/**
......
......@@ -43,7 +43,7 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p)
#elif defined(Q_WS_MAC)
customStyle = new QMacStyle();
#elif defined(Q_WS_X11)
// customStyle = QStyleFactory::create("oxygen");
customStyle = QStyleFactory::create("oxygen");
#endif
if (customStyle)
......@@ -246,4 +246,4 @@ void UBRubberBand::mouseReleaseEvent(QMouseEvent *event)
Q_UNUSED(event);
mMouseIsPressed = false;
unsetCursor();
}
\ No newline at end of file
}
......@@ -49,15 +49,12 @@
#define UBTG_SEPARATOR_FIXED_HEIGHT 3
typedef enum
{
typedef enum {
eUBTGAddSubItemWidgetType_None,
eUBTGAddSubItemWidgetType_Action ,
eUBTGAddSubItemWidgetType_Action,
eUBTGAddSubItemWidgetType_Media,
eUBTGAddSubItemWidgetType_Url
}eUBTGAddSubItemWidgetType;
} eUBTGAddSubItemWidgetType;
/***************************************************************************
* class UBTeacherGuideEditionWidget *
......@@ -86,18 +83,18 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
mpLayout->addWidget(mpPageNumberLabel);
// tree basic configuration
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){
if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) {
mpDocumentTitle = new QLabel(this);
mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle");
mpLayout->addWidget(mpDocumentTitle);
}
mpPageTitle = new UBTGAdaptableText(0,this);
mpPageTitle = new UBTGAdaptableText(0, this);
mpPageTitle->setObjectName("UBTGEditionPageTitle");
mpPageTitle->setPlaceHolderText(tr("Type title here ..."));
mpLayout->addWidget(mpPageTitle);
mpComment = new UBTGAdaptableText(0,this);
mpComment = new UBTGAdaptableText(0, this);
mpComment->setObjectName("UBTGEditionComment");
mpComment->setPlaceHolderText(tr("Type comment here ..."));
mpLayout->addWidget(mpComment);
......@@ -108,6 +105,7 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
mpLayout->addWidget(mpSeparator);
mpTreeWidget = new QTreeWidget(this);
mpTreeWidget->setStyleSheet("selection-background-color:transparent; padding-bottom:5px; padding-top:5px;");
mpLayout->addWidget(mpTreeWidget);
mpRootWidgetItem = mpTreeWidget->invisibleRootItem();
......@@ -121,22 +119,22 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch);
mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed);
mpTreeWidget->header()->setDefaultSectionSize(18);
mpTreeWidget->setSelectionMode(QAbstractItemView::NoSelection);
connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged()));
connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
mpAddAnActionItem = new UBAddItem(tr("Add an action"),eUBTGAddSubItemWidgetType_Action,mpTreeWidget);
mpAddAMediaItem = new UBAddItem(tr("Add a media"),eUBTGAddSubItemWidgetType_Media,mpTreeWidget);
mpAddALinkItem = new UBAddItem(tr("Add a link"),eUBTGAddSubItemWidgetType_Url,mpTreeWidget);
mpAddAnActionItem = new UBAddItem(tr("Add an action"), eUBTGAddSubItemWidgetType_Action, mpTreeWidget);
mpAddAMediaItem = new UBAddItem(tr("Add a media"), eUBTGAddSubItemWidgetType_Media, mpTreeWidget);
mpAddALinkItem = new UBAddItem(tr("Add a link"), eUBTGAddSubItemWidgetType_Url, mpTreeWidget);
mpRootWidgetItem->addChild(mpAddAnActionItem);
mpRootWidgetItem->addChild(mpAddAMediaItem);
mpRootWidgetItem->addChild(mpAddALinkItem);
if(UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){
UBSvgSubsetAdaptor::addElementToBeStored(QString("teacherGuide"),this);
//connect(UBApplication::boardController,SIGNAL(activeDocumentChanged()),this,SLOT(onActiveDocumentChanged()));
connect(UBApplication::boardController,SIGNAL(documentSet(UBDocumentProxy*)),this,SLOT(onActiveDocumentChanged()));
if (UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()) {
UBSvgSubsetAdaptor::addElementToBeStored(QString("teacherGuide"), this);
connect(UBApplication::boardController, SIGNAL(documentSet(UBDocumentProxy*)), this, SLOT(onActiveDocumentChanged()));
}
}
......@@ -150,7 +148,7 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
DELETEPTR(mpAddAnActionItem);
DELETEPTR(mpAddAMediaItem);
DELETEPTR(mpAddALinkItem);
DELETEPTR(mpTreeWidget)
DELETEPTR(mpTreeWidget);
DELETEPTR(mpLayout);
}
......@@ -163,7 +161,7 @@ void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event)
void UBTeacherGuideEditionWidget::onActiveDocumentChanged()
{
int activeSceneIndex = UBApplication::boardController->activeSceneIndex();
if(UBApplication::boardController->pageFromSceneIndex(activeSceneIndex) != 0)
if (UBApplication::boardController->pageFromSceneIndex(activeSceneIndex) != 0)
load(UBSvgSubsetAdaptor::readTeacherGuideNode(activeSceneIndex));
}
......@@ -173,61 +171,59 @@ void UBTeacherGuideEditionWidget::load(QString element)
QDomDocument doc("TeacherGuide");
doc.setContent(element);
for(QDomElement element = doc.documentElement().firstChildElement(); !element.isNull(); element = element.nextSiblingElement()) {
for (QDomElement element = doc.documentElement().firstChildElement();
!element.isNull(); element = element.nextSiblingElement()) {
QString tagName = element.tagName();
if(tagName == "title")
if (tagName == "title")
mpPageTitle->setInitialText(element.attribute("value"));
else if(tagName == "comment")
else if (tagName == "comment")
mpComment->setInitialText(element.attribute("value"));
else if(tagName == "media")
onAddItemClicked(mpAddAMediaItem,0,&element);
else if(tagName == "link")
onAddItemClicked(mpAddALinkItem,0,&element);
else if(tagName == "action")
onAddItemClicked(mpAddAnActionItem,0,&element);
else if (tagName == "media")
onAddItemClicked(mpAddAMediaItem, 0, &element);
else if (tagName == "link")
onAddItemClicked(mpAddALinkItem, 0, &element);
else if (tagName == "action")
onAddItemClicked(mpAddAnActionItem, 0, &element);
}
}
QVector<tIDataStorage*> UBTeacherGuideEditionWidget::save(int pageIndex)
{
QVector<tIDataStorage*> result;
if(pageIndex != UBApplication::boardController->currentPage())
if (pageIndex != UBApplication::boardController->currentPage())
return result;
tIDataStorage* data = new tIDataStorage();
data->name = "teacherGuide";
data->type = eElementType_START;
data->attributes.insert("version","1.50");
data->attributes.insert("version", "2.00");
result << data;
data = new tIDataStorage();
data->name = "title";
data->type = eElementType_UNIQUE;
data->attributes.insert("value",mpPageTitle->text());
if(mpPageTitle->text().length()){
data->attributes.insert("value", mpPageTitle->text());
if (mpPageTitle->text().length())
result << data;
}
data = new tIDataStorage();
data->name = "comment";
data->type = eElementType_UNIQUE;
data->attributes.insert("value",mpComment->text());
if(mpComment->text().length())
data->attributes.insert("value", mpComment->text());
if (mpComment->text().length())
result << data;
QList<QTreeWidgetItem*> children = getChildrenList(mpAddAnActionItem);
children << getChildrenList(mpAddAMediaItem);
children << getChildrenList(mpAddALinkItem);
foreach(QTreeWidgetItem* widgetItem, children){
tUBGEElementNode* node = dynamic_cast<iUBTGSaveData*>(mpTreeWidget->itemWidget(widgetItem,0))->saveData();
if(node){
foreach(QTreeWidgetItem* widgetItem, children) {
tUBGEElementNode* node = dynamic_cast<iUBTGSaveData*>(mpTreeWidget->itemWidget( widgetItem, 0))->saveData();
if (node) {
data = new tIDataStorage();
data->name = node->name;
data->type = eElementType_UNIQUE;
foreach(QString currentKey, node->attributes.keys())
data->attributes.insert(currentKey,node->attributes.value(currentKey));
data->attributes.insert(currentKey, node->attributes.value(currentKey));
result << data;
}
}
......@@ -242,12 +238,12 @@ QVector<tIDataStorage*> UBTeacherGuideEditionWidget::save(int pageIndex)
void UBTeacherGuideEditionWidget::onActiveSceneChanged()
{
int currentPage = UBApplication::boardController->currentPage();
if(currentPage > 0){
if (currentPage > 0) {
cleanData();
load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex()));
load( UBSvgSubsetAdaptor::readTeacherGuideNode( UBApplication::boardController->activeSceneIndex()));
mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage));
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle)
if (mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
}
}
......@@ -260,44 +256,44 @@ void UBTeacherGuideEditionWidget::cleanData()
children << mpAddAMediaItem->takeChildren();
children << mpAddALinkItem->takeChildren();
foreach(QTreeWidgetItem* item, children){
foreach(QTreeWidgetItem* item, children) {
DELETEPTR(item);
}
}
QList<QTreeWidgetItem*> UBTeacherGuideEditionWidget::getChildrenList(QTreeWidgetItem* widgetItem)
QList<QTreeWidgetItem*> UBTeacherGuideEditionWidget::getChildrenList( QTreeWidgetItem* widgetItem)
{
QList<QTreeWidgetItem*>result;
for(int i=0;i<widgetItem->childCount();i+=1)
QList<QTreeWidgetItem*> result;
for (int i = 0; i < widgetItem->childCount(); i += 1)
result << widgetItem->child(i);
return result;
}
QVector<tUBGEElementNode*> UBTeacherGuideEditionWidget::getPageAndCommentData()
{
QVector<tUBGEElementNode*>result;
QVector<tUBGEElementNode*> result;
tUBGEElementNode* pageTitle = new tUBGEElementNode();
pageTitle->name = "pageTitle";
pageTitle->attributes.insert("value",mpPageTitle->text());
pageTitle->attributes.insert("value", mpPageTitle->text());
result << pageTitle;
tUBGEElementNode* comment = new tUBGEElementNode();
comment->name = "comment";
comment->attributes.insert("value",mpComment->text());
comment->attributes.insert("value", mpComment->text());
result << comment;
return result;
}
QVector<tUBGEElementNode*> UBTeacherGuideEditionWidget::getData()
{
QVector<tUBGEElementNode*>result;
QVector<tUBGEElementNode*> result;
QList<QTreeWidgetItem*> children = getChildrenList(mpAddAnActionItem);
children << getChildrenList(mpAddAMediaItem);
children << getChildrenList(mpAddALinkItem);
result << getPageAndCommentData();
foreach(QTreeWidgetItem* widgetItem, children){
tUBGEElementNode* node = dynamic_cast<iUBTGSaveData*>(mpTreeWidget->itemWidget(widgetItem,0))->saveData();
if(node)
foreach(QTreeWidgetItem* widgetItem, children) {
tUBGEElementNode* node = dynamic_cast<iUBTGSaveData*>(mpTreeWidget->itemWidget( widgetItem, 0))->saveData();
if (node)
result << node;
}
return result;
......@@ -305,31 +301,33 @@ QVector<tUBGEElementNode*> UBTeacherGuideEditionWidget::getData()
void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement *element)
{
int addSubItemWidgetType = widget->data(column,Qt::UserRole).toInt();
if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None){
int addSubItemWidgetType = widget->data(column, Qt::UserRole).toInt();
if (addSubItemWidgetType != eUBTGAddSubItemWidgetType_None) {
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(widget);
newWidgetItem->setData(column,Qt::UserRole,eUBTGAddSubItemWidgetType_None);
newWidgetItem->setData(1,Qt::UserRole,eUBTGAddSubItemWidgetType_None);
newWidgetItem->setIcon(1,QIcon(":images/close.svg"));
newWidgetItem->setData(column, Qt::UserRole, eUBTGAddSubItemWidgetType_None);
newWidgetItem->setData(1, Qt::UserRole, eUBTGAddSubItemWidgetType_None);
newWidgetItem->setIcon(1, QIcon(":images/close.svg"));
switch(addSubItemWidgetType)
{
case eUBTGAddSubItemWidgetType_Action:{
switch (addSubItemWidgetType) {
case eUBTGAddSubItemWidgetType_Action: {
UBTGActionWidget* actionWidget = new UBTGActionWidget(widget);
if(element) actionWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem,0,actionWidget);
if (element)
actionWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem, 0, actionWidget);
break;
}
case eUBTGAddSubItemWidgetType_Media:{
case eUBTGAddSubItemWidgetType_Media: {
UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(widget);
if(element) mediaWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem,0,mediaWidget);
if (element)
mediaWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem, 0, mediaWidget);
break;
}
case eUBTGAddSubItemWidgetType_Url:{
case eUBTGAddSubItemWidgetType_Url: {
UBTGUrlWidget* urlWidget = new UBTGUrlWidget();
if(element) urlWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem,0,urlWidget);
if (element)
urlWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem, 0, urlWidget);
break;
}
default:
......@@ -338,42 +336,52 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int
return;
}
if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded() )
if (addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded())
widget->setExpanded(true);
else{
else {
//to update the tree and subtrees
widget->setExpanded(false);
widget->setExpanded(true);
}
}
else if(column == 1 && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None){
UBTGMediaWidget* media = dynamic_cast<UBTGMediaWidget*>(mpTreeWidget->itemWidget(widget,0));
if(media) media->removeSource();
else if (column == 1 && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None) {
UBTGMediaWidget* media = dynamic_cast<UBTGMediaWidget*>(mpTreeWidget->itemWidget(widget, 0));
if (media)
media->removeSource();
int index = mpTreeWidget->currentIndex().row();
QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild(index);
delete toBeDeletedWidgetItem;
}
}
bool UBTeacherGuideEditionWidget::isModified()
{
bool result = false;
result |= mpPageTitle->text().length() > 0;
result |= mpComment->text().length() > 0;
result |= mpAddAnActionItem->childCount() > 0;
result |= mpAddAMediaItem->childCount() > 0;
result |= mpAddALinkItem->childCount() > 0;
return result;
}
/***************************************************************************
* class UBTeacherGuidePresentationWidget *
***************************************************************************/
typedef enum
{
typedef enum {
tUBTGActionAssociateOnClickItem_NONE,
tUBTGActionAssociateOnClickItem_URL,
tUBTGActionAssociateOnClickItem_MEDIA,
tUBTGActionAssociateOnClickItem_EXPAND
}tUBTGActionAssociateOnClickItem;
} tUBTGActionAssociateOnClickItem;
typedef enum
{
typedef enum {
tUBTGTreeWidgetItemRole_HasAnAction = Qt::UserRole,
tUBTGTreeWidgetItemRole_HasAnUrl
}tUBTGTreeWidgetItemRole;
} tUBTGTreeWidgetItemRole;
UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *parent, const char *name) : QWidget(parent)
UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *parent, const char *name) :
QWidget(parent)
, mpPageTitle(NULL)
, mpComment(NULL)
, mpLayout(NULL)
......@@ -403,10 +411,10 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare
mpModePushButton->setMaximumWidth(32);
mpModePushButton->installEventFilter(this);
connect(mpModePushButton,SIGNAL(clicked()),parentWidget(),SLOT(changeMode()));
connect(mpModePushButton, SIGNAL(clicked()), parentWidget(), SLOT(changeMode()));
mpButtonTitleLayout->addWidget(mpModePushButton);
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){
if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) {
mpDocumentTitle = new QLabel(this);
mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle");
mpButtonTitleLayout->addWidget(mpDocumentTitle);
......@@ -414,13 +422,13 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare
mpLayout->addLayout(mpButtonTitleLayout);
mpPageTitle = new UBTGAdaptableText(0,this);
mpPageTitle = new UBTGAdaptableText(0, this);
mpPageTitle->setObjectName("UBTGPresentationPageTitle");
mpPageTitle->setReadOnly(true);
mpPageTitle->setStyleSheet("background-color:transparent");
mpLayout->addWidget(mpPageTitle);
mpComment = new UBTGAdaptableText(0,this);
mpComment = new UBTGAdaptableText(0, this);
mpComment->setObjectName("UBTGPresentationComment");
mpComment->setReadOnly(true);
mpComment->setStyleSheet("background-color:transparent");
......@@ -435,14 +443,16 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare
mpLayout->addWidget(mpTreeWidget);
mpRootWidgetItem = mpTreeWidget->invisibleRootItem();
mpTreeWidget->setSelectionMode(QAbstractItemView::NoSelection);
mpTreeWidget->setDragEnabled(true);
mpTreeWidget->setRootIsDecorated(false);
mpTreeWidget->setIndentation(0);
mpTreeWidget->setDropIndicatorShown(false);
mpTreeWidget->header()->close();
mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged()));
mpTreeWidget->setStyleSheet("selection-background-color:transparent; padding-bottom:5px; padding-top:5px; ");
connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
}
UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget()
......@@ -462,7 +472,7 @@ UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget()
bool UBTeacherGuidePresentationWidget::eventFilter(QObject* object, QEvent* event)
{
Q_UNUSED(object);
if(event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave)
if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave)
return true;
return false;
}
......@@ -473,7 +483,7 @@ void UBTeacherGuidePresentationWidget::cleanData()
mpComment->showText("");
//tree clean
QList<QTreeWidgetItem*> itemToRemove = mpRootWidgetItem->takeChildren();
foreach(QTreeWidgetItem* eachItem, itemToRemove){
foreach(QTreeWidgetItem* eachItem, itemToRemove) {
DELETEPTR(eachItem);
}
// the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero
......@@ -485,79 +495,78 @@ void UBTeacherGuidePresentationWidget::onActiveSceneChanged()
cleanData();
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage()));
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
if (mpDocumentTitle)
mpDocumentTitle->setText( documentProxy->metaData(UBSettings::sessionTitle).toString());
}
void UBTeacherGuidePresentationWidget::createMediaButtonItem()
{
if(!mpMediaSwitchItem){
if (!mpMediaSwitchItem) {
mpMediaSwitchItem = new QTreeWidgetItem(mpRootWidgetItem);
mpMediaSwitchItem->setText(0,"+");
mpMediaSwitchItem->setText(0, "+");
mpMediaSwitchItem->setExpanded(false);
mpMediaSwitchItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_EXPAND);
mpMediaSwitchItem->setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200)));
mpMediaSwitchItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),16)));
mpMediaSwitchItem->setData(0,Qt::TextAlignmentRole,QVariant(Qt::AlignCenter));
mpMediaSwitchItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_EXPAND);
mpMediaSwitchItem->setData(0, Qt::BackgroundRole, QVariant(QColor(200, 200, 200)));
mpMediaSwitchItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 16)));
mpMediaSwitchItem->setData(0, Qt::TextAlignmentRole, QVariant(Qt::AlignCenter));
mpRootWidgetItem->addChild(mpMediaSwitchItem);
}
}
void UBTeacherGuidePresentationWidget::showData(QVector<tUBGEElementNode*> data)
void UBTeacherGuidePresentationWidget::showData( QVector<tUBGEElementNode*> data)
{
cleanData();
foreach(tUBGEElementNode* element, data){
if(element->name == "pageTitle")
foreach(tUBGEElementNode* element, data) {
if (element->name == "pageTitle")
mpPageTitle->showText(element->attributes.value("value"));
else if (element->name == "comment")
mpComment->showText(element->attributes.value("value"));
else if(element->name == "action"){
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpRootWidgetItem);
newWidgetItem->setText(0,element->attributes.value("task"));
else if (element->name == "action") {
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem( mpRootWidgetItem);
newWidgetItem->setText(0, element->attributes.value("task"));
newWidgetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
QString colorString = element->attributes.value("owner").toInt() == 0 ? "red":"green";
UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem,0);
QString colorString = element->attributes.value("owner").toInt() == 0 ? "red" : "green";
UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem, 0);
textWidget->bottomMargin(14);
textWidget->setStyleSheet("QWidget {background: #EEEEEE; border:none; color:" + colorString + ";}");
textWidget->setStyleSheet( "QWidget {background: #EEEEEE; border:none; color:" + colorString + ";}");
textWidget->showText(element->attributes.value("task"));
textWidget->document()->setDefaultFont(QFont(QApplication::font().family(),11));
mpTreeWidget->setItemWidget(newWidgetItem,0,textWidget);
textWidget->document()->setDefaultFont( QFont(QApplication::font().family(), 11));
mpTreeWidget->setItemWidget(newWidgetItem, 0, textWidget);
mpRootWidgetItem->addChild(newWidgetItem);
}
else if(element->name == "media"){
else if (element->name == "media") {
createMediaButtonItem();
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem);
newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/"+ element->attributes.value("mediaType") +".png"));
newWidgetItem->setText(0,element->attributes.value("title"));
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_MEDIA);
newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
QString mimeTypeString;
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem( mpMediaSwitchItem);
newWidgetItem->setIcon(0, QIcon( ":images/teacherGuide/" + element->attributes.value("mediaType") + ".png"));
newWidgetItem->setText(0, element->attributes.value("title"));
newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_MEDIA);
newWidgetItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 11)));
QString mimeTypeString;
#ifdef Q_WS_WIN
mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString();
mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString();
#else
mimeTypeString = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath");
mimeTypeString = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + element->attributes.value("relativePath");
#endif
newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString);
newWidgetItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
newWidgetItem->setFlags( Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
mpRootWidgetItem->addChild(newWidgetItem);
QTreeWidgetItem* mediaItem = new QTreeWidgetItem(newWidgetItem);
mediaItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE);
UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"),newWidgetItem);
mediaItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_NONE);
UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"), newWidgetItem);
newWidgetItem->setExpanded(false);
mpTreeWidget->setItemWidget(mediaItem,0,mediaWidget);
mpTreeWidget->setItemWidget(mediaItem, 0, mediaWidget);
}
else if(element->name == "link"){
else if (element->name == "link") {
createMediaButtonItem();
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem);
newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/link.png"));
newWidgetItem->setText(0,element->attributes.value("title"));
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_URL);
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnUrl,QVariant(element->attributes.value("url")));
newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem( mpMediaSwitchItem);
newWidgetItem->setIcon(0, QIcon(":images/teacherGuide/link.png"));
newWidgetItem->setText(0, element->attributes.value("title"));
newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_URL);
newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnUrl, QVariant(element->attributes.value("url")));
newWidgetItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 11)));
newWidgetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
mpRootWidgetItem->addChild(newWidgetItem);
}
......@@ -566,20 +575,20 @@ void UBTeacherGuidePresentationWidget::showData(QVector<tUBGEElementNode*> data)
void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, int column)
{
int associateAction = widget->data(column,tUBTGTreeWidgetItemRole_HasAnAction).toInt();
if(column == 0 && associateAction != tUBTGActionAssociateOnClickItem_NONE){
switch(associateAction)
{
int associateAction = widget->data(column,
tUBTGTreeWidgetItemRole_HasAnAction).toInt();
if (column == 0 && associateAction != tUBTGActionAssociateOnClickItem_NONE) {
switch (associateAction) {
case tUBTGActionAssociateOnClickItem_EXPAND:
widget->setExpanded(!widget->isExpanded());
if(widget->isExpanded())
mpMediaSwitchItem->setText(0,"-");
if (widget->isExpanded())
mpMediaSwitchItem->setText(0, "-");
else
mpMediaSwitchItem->setText(0,"+");
mpMediaSwitchItem->setText(0, "+");
break;
case tUBTGActionAssociateOnClickItem_URL:
widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString();
UBApplication::webController->loadUrl(QUrl(widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString()));
widget->data(column, tUBTGTreeWidgetItemRole_HasAnUrl).toString();
UBApplication::webController->loadUrl( QUrl( widget->data(column, tUBTGTreeWidgetItemRole_HasAnUrl).toString()));
break;
case tUBTGActionAssociateOnClickItem_MEDIA:
widget->setExpanded(!widget->isExpanded());
......@@ -590,11 +599,11 @@ void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget,
}
}
/***************************************************************************
* class UBTeacherGuidePageZeroEditionWidget *
* class UBTeacherGuidePageZeroWidget *
***************************************************************************/
UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name): QWidget(parent)
UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name) :
QWidget(parent)
, mpLayout(NULL)
, mpButtonTitleLayout(NULL)
, mpModePushButton(NULL)
......@@ -623,7 +632,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
, mpSchoolTypeValueLabel(NULL)
, mpSeparatorIndex(NULL)
, mpLicenceLabel(NULL)
, mpLicenceBox(NULL)
, mpLicenceBox( NULL)
, mpLicenceIcon(NULL)
, mpLicenceLayout(NULL)
, mpSceneItemSessionTitle(NULL)
......@@ -635,7 +644,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpPageNumberLabel = new QLabel(this);
mpPageNumberLabel->setAlignment(Qt::AlignRight);
mpPageNumberLabel->setObjectName("UBTGPageNumberLabel");
mpPageNumberLabel->setText(tr("Page 0"));
mpPageNumberLabel->setText(tr("Title page"));
mpLayout->addWidget(mpPageNumberLabel);
mpButtonTitleLayout = new QHBoxLayout(0);
......@@ -645,9 +654,9 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpModePushButton->setMaximumWidth(32);
mpModePushButton->installEventFilter(this);
mpButtonTitleLayout->addWidget(mpModePushButton);
connect(mpModePushButton,SIGNAL(clicked()),this,SLOT(switchToMode()));
connect(mpModePushButton, SIGNAL(clicked()), this, SLOT(switchToMode()));
mpSessionTitle = new UBTGAdaptableText(0,this,"UBTGSessionTitle");
mpSessionTitle = new UBTGAdaptableText(0, this, "UBTGSessionTitle");
mpSessionTitle->setPlaceHolderText(tr("Type session title here ..."));
mpButtonTitleLayout->addWidget(mpSessionTitle);
......@@ -664,7 +673,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpAuthorsLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpAuthorsLabel);
mpAuthors = new UBTGAdaptableText(0,this);
mpAuthors = new UBTGAdaptableText(0, this);
mpAuthors->setObjectName("UBTGZeroPageInputText");
mpAuthors->setPlaceHolderText(tr("Type authors here ..."));
mpLayout->addWidget(mpAuthors);
......@@ -688,7 +697,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpObjectivesLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpObjectivesLabel);
mpObjectives = new UBTGAdaptableText(0,this);
mpObjectives = new UBTGAdaptableText(0, this);
mpObjectives->setObjectName("UBTGZeroPageInputText");
mpObjectives->setPlaceHolderText(tr("Type objectives here..."));
mpLayout->addWidget(mpObjectives);
......@@ -709,7 +718,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpKeywordsLabel->setText(tr("Keywords:"));
mpKeywordsLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpKeywordsLabel);
mpKeywords = new UBTGAdaptableText(0,this);
mpKeywords = new UBTGAdaptableText(0, this);
mpKeywords->setPlaceHolderText(tr("Type keywords here ..."));
mpLayout->addWidget(mpKeywords);
......@@ -721,7 +730,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpSchoolLevelBox = new QComboBox(this);
mpSchoolLevelBox->setMinimumHeight(22);
mpSchoolLevelBox->setObjectName("DockPaletteWidgetComboBox");
connect(mpSchoolLevelBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(onSchoolLevelChanged(QString)));
connect(mpSchoolLevelBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(onSchoolLevelChanged(QString)));
mpLayout->addWidget(mpSchoolLevelBox);
mpSchoolLevelValueLabel = new QLabel(this);
mpLayout->addWidget(mpSchoolLevelValueLabel);
......@@ -772,8 +781,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpLayout->addLayout(mpLicenceLayout);
mpLayout->addStretch(1);
connect(UBApplication::boardController,SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
fillComboBoxes();
}
......@@ -813,7 +821,7 @@ UBTeacherGuidePageZeroWidget::~UBTeacherGuidePageZeroWidget()
bool UBTeacherGuidePageZeroWidget::eventFilter(QObject* object, QEvent* event)
{
Q_UNUSED(object);
if(event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave)
if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave)
return true;
return false;
}
......@@ -822,7 +830,7 @@ void UBTeacherGuidePageZeroWidget::fillComboBoxes()
{
QString parametersConfigFilePath = UBSettings::settings()->applicationCustomizationDirectory() + "/teacherGuide/indexingParameters.xml";
QFile parametersFile(parametersConfigFilePath);
if(!parametersFile.exists()){
if (!parametersFile.exists()) {
qCritical() << "UBTeacherGuidePageZeroEditionWidget fillComboBoxes file not found " << parametersConfigFilePath;
return;
}
......@@ -834,48 +842,54 @@ void UBTeacherGuidePageZeroWidget::fillComboBoxes()
QDomElement rootElement = doc.elementsByTagName("teacherGuide").at(0).toElement();
QDomNodeList subjects = rootElement.elementsByTagName("subjects");
for(int baseLevelCounter = 0; baseLevelCounter < subjects.count(); baseLevelCounter += 1){
for (int baseLevelCounter = 0; baseLevelCounter < subjects.count(); baseLevelCounter += 1) {
QDomNode subjectsForBaseLevel = subjects.at(baseLevelCounter);
QDomNodeList subjectsList = subjectsForBaseLevel.childNodes();
QStringList subjectsRelatedToBaseLevel;
for(int j = 0; j < subjectsList.count(); j += 1){
for (int j = 0; j < subjectsList.count(); j += 1) {
subjectsRelatedToBaseLevel.append(subjectsList.at(j).toElement().attribute("label"));
}
mSubjects.insert(subjectsForBaseLevel.toElement().attribute("baseLevel"),subjectsRelatedToBaseLevel);
mSubjects.insert( subjectsForBaseLevel.toElement().attribute("baseLevel"), subjectsRelatedToBaseLevel);
}
QDomNodeList gradeLevels = rootElement.elementsByTagName("gradeLevels").at(0).childNodes();
for(int i=0; i<gradeLevels.count();i+=1){
mGradeLevelsMap.insert(gradeLevels.at(i).toElement().attribute("label"),gradeLevels.at(i).toElement().attribute("baseLevel"));
mpSchoolLevelBox->addItem(gradeLevels.at(i).toElement().attribute("label"));
for (int i = 0; i < gradeLevels.count(); i += 1) {
mGradeLevelsMap.insert(gradeLevels.at(i).toElement().attribute("label"), gradeLevels.at(i).toElement().attribute("baseLevel"));
mpSchoolLevelBox->addItem( gradeLevels.at(i).toElement().attribute("label"));
}
QDomNodeList types = rootElement.elementsByTagName("types").at(0).childNodes();
for(int i=0; i<types.count();i+=1)
for (int i = 0; i < types.count(); i += 1)
mpSchoolTypeBox->addItem(types.at(i).toElement().attribute("label"));
parametersFile.close();
QStringList licences;
licences << tr("Attribution CC BY") << tr("Attribution-NoDerivs CC BY-ND") << tr("Attribution-ShareAlike CC BY-SA") << tr("Attribution-NonCommercial CC BY-NC") << tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND") << tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA") << tr("Public domain") << tr("Copyright");
licences << tr("Attribution CC BY") << tr("Attribution-NoDerivs CC BY-ND")
<< tr("Attribution-ShareAlike CC BY-SA")
<< tr("Attribution-NonCommercial CC BY-NC")
<< tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND")
<< tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA")
<< tr("Public domain") << tr("Copyright");
mpLicenceBox->addItems(licences);
QStringList licenceIconList;
licenceIconList << ":images/licenses/ccby.png" << ":images/licenses/ccbynd.png" << ":images/licenses/ccbysa.png" << ":images/licenses/ccbync.png" << ":images/licenses/ccbyncnd.png" << ":images/licenses/ccbyncsa.png";
for(int i = 0; i < licenceIconList.count(); i+=1)
mpLicenceBox->setItemData(i,licenceIconList.at(i));
licenceIconList << ":images/licenses/ccby.png"
<< ":images/licenses/ccbynd.png" << ":images/licenses/ccbysa.png"
<< ":images/licenses/ccbync.png" << ":images/licenses/ccbyncnd.png"
<< ":images/licenses/ccbyncsa.png";
for (int i = 0; i < licenceIconList.count(); i += 1)
mpLicenceBox->setItemData(i, licenceIconList.at(i));
}
void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel)
{
QStringList subjects = mSubjects.value(mGradeLevelsMap.value(schoolLevel));
mpSchoolSubjectsBox->clear();
if(subjects.count()){
if (subjects.count()) {
mpSchoolSubjectsItemLabel->setEnabled(true);
mpSchoolSubjectsBox->setEnabled(true);
mpSchoolSubjectsBox->addItems(subjects);
}
else{
} else {
mpSchoolSubjectsItemLabel->setDisabled(true);
mpSchoolSubjectsBox->setDisabled(true);
}
......@@ -884,17 +898,17 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel)
void UBTeacherGuidePageZeroWidget::onActiveSceneChanged()
{
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(documentProxy && UBApplication::boardController->currentPage() == 0){
if (documentProxy && UBApplication::boardController->currentPage() == 0) {
QDateTime creationDate = documentProxy->documentDate();
mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate));
mpCreationLabel->setText( tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate));
QDateTime updatedDate = documentProxy->lastUpdate();
mpLastModifiedLabel->setText(tr("Updated the:\n") + updatedDate.toString(Qt::DefaultLocaleShortDate));
mpLastModifiedLabel->setText( tr("Updated the:\n") + updatedDate.toString(Qt::DefaultLocaleShortDate));
loadData();
updateSceneTitle();
}
}
void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event )
void UBTeacherGuidePageZeroWidget::hideEvent(QHideEvent * event)
{
persistData();
QWidget::hideEvent(event);
......@@ -903,56 +917,56 @@ void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event )
void UBTeacherGuidePageZeroWidget::loadData()
{
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
mpSessionTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
mpAuthors->setText(documentProxy->metaData(UBSettings::sessionAuthors).toString());
mpObjectives->setText(documentProxy->metaData(UBSettings::sessionObjectives).toString());
mpKeywords->setText(documentProxy->metaData(UBSettings::sessionKeywords).toString());
mpSessionTitle->setText( documentProxy->metaData(UBSettings::sessionTitle).toString());
mpAuthors->setText( documentProxy->metaData(UBSettings::sessionAuthors).toString());
mpObjectives->setText( documentProxy->metaData(UBSettings::sessionObjectives).toString());
mpKeywords->setText( documentProxy->metaData(UBSettings::sessionKeywords).toString());
int currentIndex = mpSchoolLevelBox->findText(documentProxy->metaData(UBSettings::sessionGradeLevel).toString());
mpSchoolLevelBox->setCurrentIndex((currentIndex!=-1) ? currentIndex : 0);
mpSchoolLevelBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0);
currentIndex = mpSchoolSubjectsBox->findText(documentProxy->metaData(UBSettings::sessionSubjects).toString());
mpSchoolSubjectsBox->setCurrentIndex((currentIndex!=-1) ? currentIndex : 0);
mpSchoolSubjectsBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0);
currentIndex = mpSchoolTypeBox->findText(documentProxy->metaData(UBSettings::sessionType).toString());
mpSchoolTypeBox->setCurrentIndex((currentIndex!=-1) ? currentIndex : 0);
mpSchoolTypeBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0);
currentIndex = mpLicenceBox->findText(documentProxy->metaData(UBSettings::sessionLicence).toString());
mpLicenceBox->setCurrentIndex((currentIndex!=-1) ? currentIndex : 0);
mpLicenceBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0);
}
void UBTeacherGuidePageZeroWidget::persistData()
{
// check necessary because at document closing hide event is send after boardcontroller set
// to NULL
if(UBApplication::boardController){
if (UBApplication::boardController) {
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text());
documentProxy->setMetaData(UBSettings::sessionTitle, mpSessionTitle->text());
documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text());
documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text());
documentProxy->setMetaData(UBSettings::sessionKeywords,mpKeywords->text());
documentProxy->setMetaData(UBSettings::sessionGradeLevel,mpSchoolLevelBox->currentText());
documentProxy->setMetaData(UBSettings::sessionSubjects,mpSchoolSubjectsBox->currentText());
documentProxy->setMetaData(UBSettings::sessionType,mpSchoolTypeBox->currentText());
documentProxy->setMetaData(UBSettings::sessionLicence,mpLicenceBox->currentText());
documentProxy->setMetaData(UBSettings::sessionObjectives, mpObjectives->text());
documentProxy->setMetaData(UBSettings::sessionKeywords, mpKeywords->text());
documentProxy->setMetaData(UBSettings::sessionGradeLevel, mpSchoolLevelBox->currentText());
documentProxy->setMetaData(UBSettings::sessionSubjects, mpSchoolSubjectsBox->currentText());
documentProxy->setMetaData(UBSettings::sessionType, mpSchoolTypeBox->currentText());
documentProxy->setMetaData(UBSettings::sessionLicence, mpLicenceBox->currentText());
}
}
void UBTeacherGuidePageZeroWidget::updateSceneTitle()
{
QString sessionTitle = mpSessionTitle->text();
if(!sessionTitle.isEmpty())
if (!sessionTitle.isEmpty())
UBApplication::boardController->activeScene()->textForObjectName(mpSessionTitle->text());
}
void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode)
{
if(mode == tUBTGZeroPageMode_EDITION){
if (mode == tUBTGZeroPageMode_EDITION) {
QString inputStyleSheet("QTextEdit { background: white; border-radius: 10px; border: 2px;}");
mpModePushButton->hide();
mpSessionTitle->setReadOnly(false);
mpSessionTitle->setStyleSheet(inputStyleSheet);
QFont titleFont(QApplication::font().family(),11,-1);
QFont titleFont(QApplication::font().family(), 11, -1);
mpSessionTitle->document()->setDefaultFont(titleFont);
mpAuthors->setReadOnly(false);
mpAuthors->setStyleSheet(inputStyleSheet);
......@@ -970,13 +984,13 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode)
mpLicenceValueLabel->hide();
mpLicenceBox->show();
}
else{
QString inputStyleSheet("QTextEdit { background: transparent; border: none;}");
else {
QString inputStyleSheet( "QTextEdit { background: transparent; border: none;}");
mpModePushButton->show();
mpSessionTitle->showText(mpSessionTitle->text());
mpSessionTitle->setStyleSheet(inputStyleSheet);
updateSceneTitle();
QFont titleFont(QApplication::font().family(),14,1);
QFont titleFont(QApplication::font().family(), 14, 1);
mpSessionTitle->document()->setDefaultFont(titleFont);
mpAuthors->setStyleSheet(inputStyleSheet);
mpAuthors->setTextColor(QColor(Qt::black));
......@@ -998,7 +1012,7 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode)
mpSchoolTypeBox->hide();
mpLicenceValueLabel->setText(mpLicenceBox->currentText());
QString licenceIconPath = mpLicenceBox->itemData(mpLicenceBox->currentIndex()).toString();
if(!licenceIconPath.isEmpty()){
if (!licenceIconPath.isEmpty()) {
mpLicenceIcon->setPixmap(QPixmap(licenceIconPath));
mpLicenceIcon->show();
}
......@@ -1011,85 +1025,100 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode)
QVector<tUBGEElementNode*> UBTeacherGuidePageZeroWidget::getData()
{
QVector<tUBGEElementNode*>result;
QVector<tUBGEElementNode*> result;
tUBGEElementNode* elementNode = new tUBGEElementNode();
elementNode->name = "sessionTitle";
elementNode->attributes.insert("value",mpSessionTitle->text());
elementNode->attributes.insert("value", mpSessionTitle->text());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "authors";
elementNode->attributes.insert("value",mpAuthors->text());
elementNode->attributes.insert("value", mpAuthors->text());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "creationDate";
elementNode->attributes.insert("value",mpCreationLabel->text());
elementNode->attributes.insert("value", mpCreationLabel->text());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "lastModifiedDate";
elementNode->attributes.insert("value",mpLastModifiedLabel->text());
elementNode->attributes.insert("value", mpLastModifiedLabel->text());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "goals";
elementNode->attributes.insert("value",mpObjectives->text());
elementNode->attributes.insert("value", mpObjectives->text());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "keywords";
elementNode->attributes.insert("value",mpKeywords->text());
elementNode->attributes.insert("value", mpKeywords->text());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "schoolLevel";
elementNode->attributes.insert("value",mpSchoolLevelBox->currentText());
elementNode->attributes.insert("value", mpSchoolLevelBox->currentText());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "schoolBranch";
elementNode->attributes.insert("value",mpSchoolSubjectsBox->currentText());
elementNode->attributes.insert("value", mpSchoolSubjectsBox->currentText());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "schoolType";
elementNode->attributes.insert("value",mpSchoolTypeBox->currentText());
elementNode->attributes.insert("value", mpSchoolTypeBox->currentText());
result << elementNode;
elementNode = new tUBGEElementNode();
elementNode->name = "licence";
elementNode->attributes.insert("value",mpLicenceBox->currentText());
elementNode->attributes.insert("value", mpLicenceBox->currentText());
result << elementNode;
return result;
}
bool UBTeacherGuidePageZeroWidget::isModified()
{
bool result = false;
result |= mpSessionTitle->text().length() > 0;
result |= mpAuthors->text().length() > 0;
result |= mpObjectives->text().length() > 0;
result |= mpKeywords->text().length() > 0;
result |= mpSchoolLevelBox->currentIndex() > 0;
result |= mpSchoolSubjectsBox->currentIndex() > 0;
result |= mpSchoolTypeBox->currentIndex() > 0;
result |= mpLicenceBox->currentIndex() > 0;
return result;
}
/***************************************************************************
* class UBTeacherGuideWidget *
***************************************************************************/
UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget* parent, const char* name): QStackedWidget(parent)
UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget* parent, const char* name) :
QStackedWidget(parent)
, mpPageZeroWidget(NULL)
, mpEditionWidget(NULL)
, mpPresentationWidget(NULL)
, mKeyboardActionFired(false)
{
setObjectName(name);
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){
if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) {
mpPageZeroWidget = new UBTeacherGuidePageZeroWidget(this);
addWidget(mpPageZeroWidget);
}
if(UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){
if (UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()) {
mpEditionWidget = new UBTeacherGuideEditionWidget(this);
addWidget(mpEditionWidget);
mpPresentationWidget = new UBTeacherGuidePresentationWidget(this);
addWidget(mpPresentationWidget);
}
connect(UBApplication::boardController->controlView(),SIGNAL(clickOnBoard()),this,SLOT(showPresentationMode()));
connect(UBApplication::boardController->controlView(), SIGNAL(clickOnBoard()), this, SLOT(showPresentationMode()));
connectToStylusPalette();
connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
}
UBTeacherGuideWidget::~UBTeacherGuideWidget()
{
DELETEPTR(mpPageZeroWidget);
......@@ -1097,32 +1126,58 @@ UBTeacherGuideWidget::~UBTeacherGuideWidget()
DELETEPTR(mpPresentationWidget);
}
void UBTeacherGuideWidget::onActiveSceneChanged()
{
if(UBApplication::boardController->currentPage() == 0){
if (UBApplication::boardController->currentPage() == 0) {
setCurrentWidget(mpPageZeroWidget);
mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_EDITION);
}else
}
else
setCurrentWidget(mpEditionWidget);
}
#include "core/UBApplication.h"
#include "gui/UBMainWindow.h"
void UBTeacherGuideWidget::onTriggeredAction(bool checked)
{
Q_UNUSED(checked);
if(!mKeyboardActionFired)
showPresentationMode();
mKeyboardActionFired=false;
}
void UBTeacherGuideWidget::onTriggeredKeyboardAction(bool checked)
{
Q_UNUSED(checked);
mKeyboardActionFired = true;
}
void UBTeacherGuideWidget::connectToStylusPalette()
{
if(UBApplication::boardController->paletteManager())
connect(UBApplication::boardController->paletteManager()->stylusPalette(),SIGNAL(itemOnActionPaletteChanged()),this,SLOT(showPresentationMode()));
else
QTimer::singleShot(100,this,SLOT(connectToStylusPalette()));
connect(UBApplication::mainWindow->actionPen, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionEraser, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionMarker, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionPointer, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionPlay, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionZoomIn, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionCapture, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionHand, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionLine, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionText, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool)));
connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(onTriggeredKeyboardAction(bool)));
}
void UBTeacherGuideWidget::showPresentationMode()
{
if(currentWidget()==mpPageZeroWidget){
if (currentWidget() == mpPageZeroWidget) {
mCurrentData = mpPageZeroWidget->getData();
mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_PRESENTATION);
}
else if(currentWidget()==mpEditionWidget){
else if (currentWidget() == mpEditionWidget) {
mCurrentData = mpEditionWidget->getData();
mpPresentationWidget->showData(mCurrentData);
setCurrentWidget(mpPresentationWidget);
......@@ -1131,9 +1186,17 @@ void UBTeacherGuideWidget::showPresentationMode()
void UBTeacherGuideWidget::changeMode()
{
if(currentWidget() == mpEditionWidget)
if (currentWidget() == mpEditionWidget)
setCurrentWidget(mpPresentationWidget);
else
setCurrentWidget(mpEditionWidget);
}
bool UBTeacherGuideWidget::isModified()
{
if (currentWidget() == mpPageZeroWidget)
return mpPageZeroWidget->isModified();
else
return mpEditionWidget->isModified();
}
......@@ -50,6 +50,8 @@ public:
void load(QString element);
QVector<tIDataStorage*> save(int pageIndex);
bool isModified();
public slots:
void onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement* element = 0);
void onActiveSceneChanged();
......@@ -124,6 +126,7 @@ public:
~UBTeacherGuidePageZeroWidget();
QVector<tUBGEElementNode*> getData();
bool isModified();
public slots:
......@@ -198,6 +201,8 @@ public:
explicit UBTeacherGuideWidget(QWidget* parent = 0, const char* name="UBTeacherGuideWidget");
~UBTeacherGuideWidget();
bool isModified();
public slots:
void changeMode();
void showPresentationMode();
......@@ -209,6 +214,11 @@ private:
UBTeacherGuideEditionWidget* mpEditionWidget;
UBTeacherGuidePresentationWidget* mpPresentationWidget;
QVector<tUBGEElementNode*>mCurrentData;
bool mKeyboardActionFired;
private slots:
void onTriggeredAction(bool checked);
void onTriggeredKeyboardAction(bool checked);
};
#endif // UBTEACHERGUIDEWIDGET_H
......@@ -177,10 +177,8 @@ void UBWebController::tutorialWebInstance()
QString tutorialPath = "/etc/Tutorial/tutorial" + language + "/index.html";
#if defined(Q_WS_MAC)
tutorialHtmlIndexFile = QApplication::applicationDirPath()+ "/../Resources" + tutorialPath;
#elif defined(Q_WS_WIN)
tutorialHtmlIndexFile = QApplication::applicationDirPath()+ tutorialPath;
#else
tutorialHtmlIndexFile = QApplication::applicationDirPath()+ tutorialPath;
tutorialHtmlIndexFile = QApplication::applicationDirPath() + tutorialPath;
#endif
QUrl currentUrl = QUrl::fromLocalFile(tutorialHtmlIndexFile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment