Commit 001528da authored by shibakaneki's avatar shibakaneki

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

parents 805edd5b 0d4d6024
......@@ -4,7 +4,7 @@
id="http://uniboard.mnemis.com/widgets/calculator"
version="1.1"
width="200"
height="295"
height="300"
ub:resizable="false">
<name>Calculator</name>
<content src="index.html"/>
......
......@@ -4,6 +4,7 @@ html, body{
margin: 0;
padding: 0;
border-radius: 50px;
overflow: hidden;
}
.without_radius{
......@@ -283,7 +284,6 @@ body{
#wgt_name{
height: 44px;
width: 300px;
margin: 10px 10px 0 10px;
padding: 0;
float: left;
......@@ -292,9 +292,8 @@ body{
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;
......@@ -304,7 +303,6 @@ body{
}
#wgt_display{
width: 100px;
padding-left: 40px;
background-image: url(../img/slate-edit.png);
background-repeat: no-repeat;
......@@ -313,7 +311,6 @@ body{
}
#wgt_edit{
width: 100px;
padding-left: 40px;
background-image: url(../img/slate-edit.png);
background-repeat: no-repeat;
......@@ -398,3 +395,27 @@ body{
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;
}
.open{
}
\ No newline at end of file
......@@ -16,6 +16,7 @@
lang = sankore.locale().substr(0,2);
} else
lang = "en";
lang = "fr";
if(lang == "en"){
if(window.sankore)
sankore.enableDropOnWidget(false);
......@@ -51,6 +52,7 @@
<td class="b_top_left">&nbsp;</td>
<td class="b_top_center">
<div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div>
......@@ -66,6 +68,7 @@
<tr>
<td class="b_center_left">&nbsp;</td>
<td>
<div id="help"></div>
<div id="data">
</div>
......
......@@ -8,7 +8,9 @@ var sankoreLang = {
reload: "Reload",
slate: "Wood",
pad: "Pad",
none: "None"
none: "None",
help: "Help",
help_content: "This is an example of help content ..."
};
//main function
......@@ -18,6 +20,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload);
$("#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);
......@@ -39,6 +43,21 @@ function start(){
}
}
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").slideUp("100", function(){
tmp.removeClass("open");
$("#data").show();
});
} else {
$("#data").hide();
$("#help").slideDown("100", function(){
tmp.addClass("open");
});
}
});
$("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click");
......@@ -312,7 +331,7 @@ function exportData(){
}
if(window.sankore)
sankore.setPreference("associer", JSON.stringify(array_to_export));
sankore.setPreference("associer", JSON.stringify(array_to_export));
}
//import
......@@ -618,6 +637,7 @@ function changeStyle(val){
$(".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");
......@@ -634,6 +654,7 @@ function changeStyle(val){
$(".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");
......@@ -649,6 +670,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_help").addClass("pad_color").addClass("pad_help");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
......
......@@ -10,18 +10,19 @@
<script type="text/javascript" src="../../js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document).ready(function(){
sankore.enableDropOnWidget(false);
start();
});
</script>
</head>
<body>
<body>
<table class="body_table" cellpadding=0 cellspacing=0>
<tr style="height: 54px;">
<td class="b_top_left">&nbsp;</td>
<td class="b_top_center">
<div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div>
......@@ -37,6 +38,7 @@
<tr>
<td class="b_center_left">&nbsp;</td>
<td>
<div id="help"></div>
<div id="data">
</div>
......
......@@ -8,7 +8,9 @@ var sankoreLang = {
reload: "Recharger",
slate: "ardoise",
pad: "tablette",
none: "aucun"
none: "aucun",
help: "aide",
help_content: "Ceci est un exemple de contenu de l'aide ..."
};
//main function
......@@ -18,6 +20,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload);
$("#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);
......@@ -39,6 +43,21 @@ function start(){
}
}
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").slideUp("100", function(){
tmp.removeClass("open");
$("#data").show();
});
} else {
$("#data").hide();
$("#help").slideDown("100", function(){
tmp.addClass("open");
});
}
});
$("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click");
......@@ -613,6 +632,7 @@ function changeStyle(val){
$(".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");
......@@ -629,6 +649,7 @@ function changeStyle(val){
$(".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");
......@@ -644,6 +665,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_help").addClass("pad_color").addClass("pad_help");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
......@@ -760,5 +782,4 @@ function onDropTarget(obj, event) {
event.cancelBubble = true;
}
return false;
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@
<td class="b_top_left">&nbsp;</td>
<td class="b_top_center">
<div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div>
......@@ -37,6 +38,7 @@
<tr>
<td class="b_center_left">&nbsp;</td>
<td>
<div id="help"></div>
<div id="data">
</div>
......
......@@ -11,6 +11,7 @@ var sankoreLang = {
none: "Нет"
};
//main function
function start(){
......@@ -18,6 +19,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload);
$("#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);
......@@ -39,6 +42,21 @@ function start(){
}
}
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").slideUp("100", function(){
tmp.removeClass("open");
$("#data").show();
});
} else {
$("#data").hide();
$("#help").slideDown("100", function(){
tmp.addClass("open");
});
}
});
$("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click");
......@@ -613,6 +631,7 @@ function changeStyle(val){
$(".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");
......@@ -629,6 +648,7 @@ function changeStyle(val){
$(".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");
......@@ -644,6 +664,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_help").addClass("pad_color").addClass("pad_help");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
......@@ -760,5 +781,4 @@ function onDropTarget(obj, event) {
event.cancelBubble = true;
}
return false;
}
}
\ No newline at end of file
......@@ -47,8 +47,6 @@ if(window.sankore){
word = sankoreLang.example;
}
var doCheckWord = true;
// array of dom elements
var letters = [];
......@@ -67,10 +65,13 @@ var widget_padding = 0;
var min_view_width = 400;
$(document).ready(function(){
if(sankore.preference("ord_words_style","")){
changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style",""));
} else
if(window.sankore){
if(sankore.preference("ord_words_style","")){
changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style",""));
} else
changeStyle("3")
} else
changeStyle("3")
$("#wgt_display").text(sankoreLang.view);
$("#wgt_edit").text(sankoreLang.edit);
......@@ -300,7 +301,7 @@ turns the widget into the view mode
function modeView()
{
if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" );
word = $( "#mp_word .wgt_cont" ).val();
}
wgtState = false;
......@@ -360,14 +361,15 @@ function modeEdit()
{
editMode = true;
wgtState = true;
$( "#mp_word").css( "margin-left", 0 ).empty().append('<input value="'+word+'">');
$( "#mp_word").sortable( "destroy" );
$( "#mp_word").css( "margin-left", 0 ).empty().append('<textarea class="wgt_cont">'+word+'</textarea>');
}
if (window.widget) {
window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val());
if($( "#mp_word input:text" ).attr( "value" ))
if($( "#mp_word .wgt_cont" ).val())
{
modeView();
var str = "";
......
......@@ -47,8 +47,6 @@ if(window.sankore){
word = sankoreLang.example;
}
var doCheckWord = true;
// array of dom elements
var letters = [];
......@@ -67,10 +65,13 @@ var widget_padding = 0;
var min_view_width = 400;
$(document).ready(function(){
if(sankore.preference("ord_words_style","")){
changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style",""));
} else
if(window.sankore){
if(sankore.preference("ord_words_style","")){
changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style",""));
} else
changeStyle("3")
} else
changeStyle("3")
$("#wgt_display").text(sankoreLang.view);
$("#wgt_edit").text(sankoreLang.edit);
......@@ -300,7 +301,7 @@ turns the widget into the view mode
function modeView()
{
if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" );
word = $( "#mp_word .wgt_cont" ).val();
}
wgtState = false;
......@@ -360,14 +361,15 @@ function modeEdit()
{
editMode = true;
wgtState = true;
$( "#mp_word").css( "margin-left", 0 ).empty().append('<input value="'+word+'">');
$( "#mp_word").sortable( "destroy" );
$( "#mp_word").css( "margin-left", 0 ).empty().append('<textarea class="wgt_cont">'+word+'</textarea>');
}
if (window.widget) {
window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val());
if($( "#mp_word input:text" ).attr( "value" ))
if($( "#mp_word .wgt_cont" ).val())
{
modeView();
var str = "";
......
......@@ -65,12 +65,14 @@ var widget_padding = 0;
var min_view_width = 400;
$(document).ready(function(){
if(window.sankore)
if(window.sankore){
if(sankore.preference("ord_words_style","")){
changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style",""));
} else
changeStyle("3")
} else
changeStyle("3")
$("#wgt_display").text(sankoreLang.view);
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_display, #wgt_edit").click(function(event){
......@@ -299,7 +301,7 @@ turns the widget into the view mode
function modeView()
{
if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" );
word = $( "#mp_word .wgt_cont" ).val();
}
wgtState = false;
......@@ -359,14 +361,15 @@ function modeEdit()
{
editMode = true;
wgtState = true;
$( "#mp_word").css( "margin-left", 0 ).empty().append('<input value="'+word+'">');
$( "#mp_word").sortable( "destroy" );
$( "#mp_word").css( "margin-left", 0 ).empty().append('<textarea class="wgt_cont">'+word+'</textarea>');
}
if (window.widget) {
window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val());
if($( "#mp_word input:text" ).attr( "value" ))
if($( "#mp_word .wgt_cont" ).val())
{
modeView();
var str = "";
......
......@@ -12,7 +12,7 @@ body{
.letter{
min-width: 30px;
max-width: 500px;
max-width: 600px;
height: 40px;
overflow: hidden;
border: solid 1px #ccc;
......@@ -43,11 +43,12 @@ body{
text-align: center;
}
#mp_word input{
#mp_word .wgt_cont{
font: 32px tahoma;
letter-spacing: 0.1em;
width: 98%;
overflow: auto;
min-height: 200px;
resize: vertical;
}
#mp_msg{
......
......@@ -107,7 +107,6 @@
function imageDragging(e){
e.dataTransfer.setData("text/plain",$(this).find("input:hidden").eq(0).val());
// alert($(this).find("input:hidden").eq(0).val());
}
function imageDragleave(e){
......@@ -235,15 +234,12 @@
function createMetaData(parent){
var meta = "";
//alert($(this).find("input:hidden").eq(0).val());
meta = "<metadata><data><key>Type</key><value>Image</value></data><data><key>Url</key><value>" +
meta = "<metadata><data><key>Type</key><value>Audio</value></data><data><key>Url</key><value>" +
parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" +
parent.find("input:hidden").eq(2).val() +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Height</key><value>n/a</value></data>"+
"<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>";
return meta;
......
......@@ -234,16 +234,12 @@
function createMetaData(parent){
var meta = "";
//alert($(this).find("input:hidden").eq(0).val());
meta = "<metadata><data><key>Type</key><value>Image</value></data><data><key>Url</key><value>" +
meta = "<metadata><data><key>Type</key><value>Flash</value></data><data><key>Url</key><value>" +
parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" +
parent.find("input:hidden").eq(2).val() +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Height</key><value>n/a</value></data>"+
"<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>";
return meta;
......
......@@ -22,10 +22,10 @@
for (var i = 0; i < 8; i++) {
if (i * limit < totalResults) {
var link = $("<a class='pager_button'></a>").attr('href', 'javascript:gotoPage('+i+');').html(i+1).appendTo(pagesDiv);
if (curPage == i) {
link.addClass('active');
}
var link = $("<a class='pager_button'></a>").attr('href', 'javascript:gotoPage('+i+');').html(i+1).appendTo(pagesDiv);
if (curPage == i) {
link.addClass('active');
}
}
}
......@@ -50,59 +50,65 @@
}
function searchFail(jqXHR, textStatus, errorThrown) {
alert('Impossible to connect to Planete Sankore: ' + textStatus + ' ' + errorThrown);
alert('Impossible to connect to Planete Sankore: ' + textStatus + ' ' + errorThrown);
}
function searchComplete(json) {
// Grab our content div, clear it.
var totalResults = json.totalResults;
var contentDiv = $('#searchResult').empty();
// Loop through our results, printing them to the page.
var results = json.rows;
for (var i = 0; i < results.length; i++) {
// For each result write it's title and image to the screen
var result = results[i];
var imgContainer = $("<div class='imgContainer' draggable='true'>");
//var title = document.createElement('div');
var iUrl = $("<input type='hidden'/>");
var iContent = $("<input type='hidden'/>");
var iHeight = $("<input type='hidden'/>");
var iWidth = $("<input type='hidden'/>");
var iTitle = $("<input type='hidden'/>");
// Grab our content div, clear it.
var totalResults = json.totalResults;
var contentDiv = $('#searchResult').empty();
// Loop through our results, printing them to the page.
var results = json.rows;
for (var i = 0; i < results.length; i++) {
// For each result write it's title and image to the screen
var result = results[i];
var imgContainer = $("<div class='imgContainer' draggable='true'>");
//var title = document.createElement('div');
var iUrl = $("<input type='hidden'/>");
var iContent = $("<input type='hidden'/>");
var iHeight = $("<input type='hidden'/>");
var iWidth = $("<input type='hidden'/>");
var iTitle = $("<input type='hidden'/>");
// We use titleNoFormatting so that no HTML tags are left in the
// title
//title.innerHTML = result.title;
var newImg = document.createElement('img');
// We use titleNoFormatting so that no HTML tags are left in the
// title
//title.innerHTML = result.title;
var newImg = document.createElement('img');
// There is also a result.file property which has the escaped version
if (thumbnails) {
newImg.src = result.file;
} else {
newImg.src = "./images/thumbnail_icon.png";
}
var imgWidth = (result.tbWidth > minWidth)?result.tbWidth:minWidth;
var imgHeight = (result.tbHeight > minHeight)?result.tbHeight:minHeight;
imgContainer.width(imgWidth).height(imgHeight);
imgContainer.append($(newImg));
iUrl.attr("value", result.file);
iContent.attr("value", result.title);
iHeight.attr("value", result.height);
iWidth.attr("value", result.width);
iTitle.attr("value",result.title);
//imgContainer.append($(title));
imgContainer.append(iUrl);
imgContainer.append(iContent);
imgContainer.append(iHeight);
imgContainer.append(iWidth);
imgContainer.append(iTitle);
// There is also a result.file property which has the escaped version
if (thumbnails) {
newImg.src = result.file;
if(result.height >= result.width)
newImg.height = minHeight;
else{
newImg.width = minWidth;
//newImg.style.margin = (120 - result.height)/2 + "px 0";
}
} else {
newImg.src = "./images/thumbnail_icon.png";
}
var imgWidth = (result.tbWidth > minWidth)?result.tbWidth:minWidth;
var imgHeight = (result.tbHeight > minHeight)?result.tbHeight:minHeight;
imgContainer.width(imgWidth).height(imgHeight);
imgContainer.append($(newImg));
iUrl.attr("value", result.file);
iContent.attr("value", result.title);
iHeight.attr("value", result.height);
iWidth.attr("value", result.width);
iTitle.attr("value",result.title);
//imgContainer.append($(title));
imgContainer.append(iUrl);
imgContainer.append(iContent);
imgContainer.append(iHeight);
imgContainer.append(iWidth);
imgContainer.append(iTitle);
// Put our title + image in the content
imgContainer.appendTo(contentDiv);
// Put our title + image in the content
imgContainer.appendTo(contentDiv);
}
// Now add links to additional pages of search results.
addPaginationLinks(totalResults);
}
// Now add links to additional pages of search results.
addPaginationLinks(totalResults);
}
function imageDragging(e){
......@@ -166,9 +172,9 @@
filtersDisplayed = true;
}
});
*/
*/
/*togglePages.click(function(event){
/*togglePages.click(function(event){
if(mode){
hide = false;
$("#search, #disclaimer").slideDown('slow', function(){
......@@ -204,10 +210,10 @@
});
(
$(".imgContainer").live("click",function(){
sankore.sendFileMetadata(createMetaData($(this)));
sankore.sendFileMetadata(createMetaData($(this)));
}));
/*$(window).resize(function(){
/*$(window).resize(function(){
disclaimer.width($("body").width()-20);
search.width($("body").width()-20);
toggleIcon.css("margin-left",(togglePages.width()/2 - 7));
......@@ -216,21 +222,21 @@
});
function gotoPage(i) {
runSearch(currentTerm, i);
runSearch(currentTerm, i);
}
// launching the search on planete sankore
function runSearch(term, index) {
currentTerm = term;
currentIndex = index;
var start = index * limit;
var start = index * limit;
var url = "http://planete.sankore.org/xwiki/bin/view/Search/Resources?xpage=plain&category=" + category + "&level=&sort=title&dir=ASC&terms=" + escape(term) + "&start=" + start + "&limit=" + limit;
$.ajax({
url: url,
success: searchComplete,
error: searchFail,
dataType: "json"
});
$.ajax({
url: url,
success: searchComplete,
error: searchFail,
dataType: "json"
});
}
function createMetaData(parent){
......
......@@ -203,7 +203,7 @@
});
(
$(".imgContainer").live("click",function(){
sankore.sendFileMetadata(createMetaData($(this)));
sankore.sendFileMetadata(createMetaData($(this)));
}));
/*$(window).resize(function(){
......@@ -235,15 +235,12 @@
function createMetaData(parent){
var meta = "";
//alert($(this).find("input:hidden").eq(0).val());
meta = "<metadata><data><key>Type</key><value>Image</value></data><data><key>Url</key><value>" +
meta = "<metadata><data><key>Type</key><value>Video</value></data><data><key>Url</key><value>" +
parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" +
parent.find("input:hidden").eq(2).val() +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Height</key><value>n/a</value></data>"+
"<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>";
return meta;
......
......@@ -1078,7 +1078,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistCurrentScene()
{
if (mCurrentScene != 0 && mCurrentScene->isModified())
{
UBThumbnailAdaptor::persistScene(mProxy->persistencePath(), mCurrentScene, mProxy->pageCount() - 1);
UBThumbnailAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1);
UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1);
mCurrentScene->setModified(false);
......@@ -1102,7 +1102,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistScenes()
UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, i);
UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i);
tmpScene->setModified(true);
UBThumbnailAdaptor::persistScene(mProxy->persistencePath(), tmpScene, i);
UBThumbnailAdaptor::persistScene(mProxy, tmpScene, i);
delete tmpScene;
mCurrentScene->setModified(false);
......
......@@ -56,6 +56,8 @@
#include "interfaces/IDataStorage.h"
#include "document/UBDocumentContainer.h"
#include "pdf/PDFRenderer.h"
#include "core/memcheck.h"
......@@ -313,7 +315,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex)
{
QString result;
QString fileName = UBApplication::boardController->activeDocument()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sceneIndex);
QString fileName = UBApplication::boardController->selectedDocument()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sceneIndex);
QFile file(fileName);
file.open(QIODevice::ReadOnly);
QByteArray fileByteArray=file.readAll();
......
This diff is collapsed.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBTHUMBNAILADAPTOR_H
#define UBTHUMBNAILADAPTOR_H
#include <QtCore>
class UBDocument;
class UBDocumentProxy;
class UBGraphicsScene;
class UBThumbnailAdaptor //static class
{
Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor)
private: UBThumbnailAdaptor() {}
public:
static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static void generateMissingThumbnails(UBDocumentProxy* proxy);
static QList<QPixmap> load(UBDocumentProxy* proxy);
static QPixmap load(UBDocumentProxy* proxy, int index);
static QUrl thumbnailUrl(UBDocumentProxy* proxy, int pageIndex);
};
#endif // UBTHUMBNAILADAPTOR_H
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBTHUMBNAILADAPTOR_H
#define UBTHUMBNAILADAPTOR_H
#include <QtCore>
class UBDocument;
class UBDocumentProxy;
class UBGraphicsScene;
class UBThumbnailAdaptor //static class
{
Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor)
public:
static QUrl thumbnailUrl(UBDocumentProxy* proxy, int pageIndex);
static void persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static const QPixmap* get(UBDocumentProxy* proxy, int index);
static void load(UBDocumentProxy* proxy, QList<const QPixmap*>& list);
private:
static void generateMissingThumbnails(UBDocumentProxy* proxy);
UBThumbnailAdaptor() {}
};
#endif // UBTHUMBNAILADAPTOR_H
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTPUBLISHER_H
#define UBDOCUMENTPUBLISHER_H
#include <QtGui>
#include <QtNetwork>
#include "ui_webPublishing.h"
#define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain"
typedef struct
{
QString title;
QString description;
} sDocumentInfos;
class UBDocumentProxy;
class UBServerXMLHttpRequest;
class UBGraphicsW3CWidgetItem;
class QWebView;
class UBProxyLoginDlg : public QDialog
{
Q_OBJECT
public:
UBProxyLoginDlg(QWidget* parent=0, const char* name="ProxyLoginDlg");
~UBProxyLoginDlg();
QString username(){return mpUsername->text();}
QString password(){return mpPassword->text();}
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpUserLayout;
QHBoxLayout* mpPasswordLayout;
QDialogButtonBox* mpButtons;
QLabel* mpUserLabel;
QLabel* mpPasswordLabel;
QLineEdit* mpUsername;
QLineEdit* mpPassword;
};
class UBPublicationDlg : public QDialog
{
Q_OBJECT
public:
UBPublicationDlg(QWidget* parent=0, const char* name="UBPublicationDlg");
~UBPublicationDlg();
QString title(){return mpTitle->text();}
QString description(){return mpDescription->document()->toPlainText();}
private slots:
void onTextChanged();
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpTitleLayout;
QLabel* mpTitleLabel;
QLineEdit* mpTitle;
QLabel* mpDescLabel;
QTextEdit* mpDescription;
QDialogButtonBox* mpButtons;
};
class UBDocumentPublisher : public QObject
{
Q_OBJECT;
public:
explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0);
virtual ~UBDocumentPublisher();
void publish();
signals:
void loginDone();
protected:
virtual void updateGoogleMapApiKey();
virtual void rasterizeScenes();
virtual void upgradeDocumentForPublishing();
virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber);
private slots:
void onFinished(QNetworkReply* reply);
private:
UBDocumentProxy *mSourceDocument;
UBDocumentProxy *mPublishingDocument;
void init();
void sendUbw(QString username, QString password);
QString getBase64Of(QString stringToEncode);
QHBoxLayout* mpLayout;
QNetworkAccessManager* mpNetworkMgr;
QNetworkCookieJar* mpCookieJar;
QString mUsername;
QString mPassword;
QString mCrlf;
bool bLoginCookieSet;
void buildUbwFile();
QString mTmpZipFile;
QList<QNetworkCookie> mCookies;
sDocumentInfos mDocInfos;
};
#endif // UBDOCUMENTPUBLISHER_H
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTPUBLISHER_H
#define UBDOCUMENTPUBLISHER_H
#include <QtGui>
#include <QtNetwork>
#include "ui_webPublishing.h"
#define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain"
typedef struct
{
QString title;
QString description;
} sDocumentInfos;
class UBDocumentProxy;
class UBServerXMLHttpRequest;
class UBGraphicsW3CWidgetItem;
class QWebView;
class UBProxyLoginDlg : public QDialog
{
Q_OBJECT
public:
UBProxyLoginDlg(QWidget* parent=0, const char* name="ProxyLoginDlg");
~UBProxyLoginDlg();
QString username(){return mpUsername->text();}
QString password(){return mpPassword->text();}
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpUserLayout;
QHBoxLayout* mpPasswordLayout;
QDialogButtonBox* mpButtons;
QLabel* mpUserLabel;
QLabel* mpPasswordLabel;
QLineEdit* mpUsername;
QLineEdit* mpPassword;
};
class UBPublicationDlg : public QDialog
{
Q_OBJECT
public:
UBPublicationDlg(QWidget* parent=0, const char* name="UBPublicationDlg");
~UBPublicationDlg();
QString title(){return mpTitle->text();}
QString description(){return mpDescription->document()->toPlainText();}
private slots:
void onTextChanged();
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpTitleLayout;
QLabel* mpTitleLabel;
QLineEdit* mpTitle;
QLabel* mpDescLabel;
QTextEdit* mpDescription;
QDialogButtonBox* mpButtons;
};
class UBDocumentPublisher : public QObject
{
Q_OBJECT;
public:
explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0);
virtual ~UBDocumentPublisher();
void publish();
signals:
void loginDone();
protected:
virtual void updateGoogleMapApiKey();
virtual void rasterizeScenes();
virtual void upgradeDocumentForPublishing();
virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber);
private slots:
void onFinished(QNetworkReply* reply);
private:
UBDocumentProxy *mSourceDocument;
//UBDocumentProxy *mPublishingDocument;
QString mPublishingPath;
int mPublishingSize;
void init();
void sendUbw(QString username, QString password);
QString getBase64Of(QString stringToEncode);
QHBoxLayout* mpLayout;
QNetworkAccessManager* mpNetworkMgr;
QNetworkCookieJar* mpCookieJar;
QString mUsername;
QString mPassword;
QString mCrlf;
bool bLoginCookieSet;
void buildUbwFile();
QString mTmpZipFile;
QList<QNetworkCookie> mCookies;
sDocumentInfos mDocInfos;
};
#endif // UBDOCUMENTPUBLISHER_H
......@@ -346,7 +346,7 @@ QString UBWidgetUniboardAPI::pageThumbnail(const int pageNumber)
if (UBApplication::boardController->activeScene() != mScene)
return "";
UBDocumentProxy *doc = UBApplication::boardController->activeDocument();
UBDocumentProxy *doc = UBApplication::boardController->selectedDocument();
if (!doc)
return "";
......
This diff is collapsed.
......@@ -19,6 +19,7 @@
#include <QtGui>
#include <QObject>
#include "document/UBDocumentContainer.h"
class UBMainWindow;
class UBApplication;
......@@ -40,7 +41,7 @@ class UBGraphicsWidgetItem;
class UBBoardPaletteManager;
class UBBoardController : public QObject
class UBBoardController : public UBDocumentContainer
{
Q_OBJECT
......@@ -50,7 +51,7 @@ class UBBoardController : public QObject
void init();
void setupLayout();
UBDocumentProxy* activeDocument() const;
UBGraphicsScene* activeScene() const;
int activeSceneIndex() const;
QSize displayViewport();
......@@ -60,14 +61,6 @@ class UBBoardController : public QObject
int currentPage();
int pageFromSceneIndex(int sceneIndex);
int sceneIndexFromPage(int page);
UBDocumentProxy* activeDocument()
{
return mActiveDocument;
}
QWidget* controlContainer()
{
return mControlContainer;
......@@ -158,10 +151,17 @@ class UBBoardController : public QObject
void displayMetaData(QMap<QString, QString> metadatas);
void ClearUndoStack();
void emitScrollSignal() { emit scrollToSelectedPage(); }
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false);
void setActiveDocumentScene(int pSceneIndex);
void moveSceneToIndex(int source, int target);
void duplicateScene(int index);
void deleteScene(int index);
bool cacheIsVisible() {return mCacheWidgetIsEnabled;}
public slots:
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0);
void showDocumentsDialog();
void showKeyboard(bool show);
void togglePodcast(bool checked);
......@@ -222,14 +222,12 @@ class UBBoardController : public QObject
void freezeW3CWidget(QGraphicsItem* item, bool freeze);
void startScript();
void stopScript();
bool cacheIsVisible();
signals:
void newPageAdded();
void activeSceneWillBePersisted();
void activeSceneWillChange();
void activeSceneChanged();
void activeDocumentChanged();
void zoomChanged(qreal pZoomFactor);
void systemScaleFactorChanged(qreal pSystemScaleFactor);
void penColorChanged();
......@@ -238,10 +236,9 @@ class UBBoardController : public QObject
void cacheEnabled();
void cacheDisabled();
void pageChanged();
void setDocOnPageNavigator(UBDocumentProxy* doc);
void documentReorganized(int index);
void displayMetadata(QMap<QString, QString> metadata);
void scrollToSelectedPage();
void pageSelectionChanged(int index);
protected:
void setupViews();
......@@ -263,7 +260,6 @@ class UBBoardController : public QObject
void adjustDisplayViews();
UBMainWindow *mMainWindow;
UBDocumentProxy* mActiveDocument;
UBGraphicsScene* mActiveScene;
int mActiveSceneIndex;
UBBoardPaletteManager *mPaletteManager;
......
......@@ -134,8 +134,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
//------------------------------------------------//
// Create the widgets for the dock palettes
mpPageNavigWidget = new UBPageNavigationWidget();
#ifdef USE_WEB_WIDGET
mpLibWidget = new UBLibWidget();
#endif
......@@ -352,7 +350,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased()
QList<QAction*>pageActions;
pageActions << UBApplication::mainWindow->actionNewPage;
UBBoardController* boardController = UBApplication::boardController;
if(UBApplication::documentController->pageCanBeDuplicated(boardController->pageFromSceneIndex(boardController->activeSceneIndex())))
if(UBApplication::documentController->pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(boardController->activeSceneIndex())))
pageActions << UBApplication::mainWindow->actionDuplicatePage;
pageActions << UBApplication::mainWindow->actionImportPage;
......@@ -568,7 +566,7 @@ void UBBoardPaletteManager::activeSceneChanged()
if (mpPageNavigWidget)
{
mpPageNavigWidget->setPageNumber(UBApplication::boardController->pageFromSceneIndex(pageIndex), activeScene->document()->pageCount());
mpPageNavigWidget->setPageNumber(UBDocumentContainer::pageFromSceneIndex(pageIndex), activeScene->document()->pageCount());
}
if (mZoomPalette)
......
......@@ -1040,6 +1040,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
mMouseButtonIsPressed = false;
mPendingStylusReleaseEvent = false;
mTabletStylusIsPressed = false;
movingItem = NULL;
mLongPressTimer.stop();
}
......
......@@ -562,7 +562,7 @@ void UBLibraryController::removeBackground()
UBGraphicsScene* UBLibraryController::activeScene()
{
if (mBoardController->activeDocument())
if (mBoardController->selectedDocument())
return mBoardController->activeScene();
return 0;
......
......@@ -20,6 +20,23 @@
#define UB_MAX_ZOOM 15
struct UBMimeType
{
enum Enum
{
RasterImage = 0,
VectorImage,
AppleWidget,
W3CWidget,
Video,
Audio,
Flash,
PDF,
UniboardTool,
UNKNOWN
};
};
struct UBStylusTool
{
enum Enum
......
......@@ -317,8 +317,6 @@ int UBApplication::exec(const QString& pFileToImport)
connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized()));
#endif
connect(documentController, SIGNAL(movedToIndex(int)), boardController, SIGNAL(documentReorganized(int)));
mPreferencesController = new UBPreferencesController(mainWindow);
connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show()));
......
......@@ -63,7 +63,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, UBBo
, mControlView(pControlView)
, mDisplayView(pDisplayView)
, mMirror(0)
, mFtp(0)
, mMainMode(Board)
, mDisplayManager(0)
, mAutomaticCheckForUpdates(false)
......@@ -120,7 +119,6 @@ UBApplicationController::~UBApplicationController()
delete mBlackScene;
delete mMirror;
if (mFtp) delete mFtp;
if (mHttp) delete mHttp;
}
......@@ -340,8 +338,7 @@ void UBApplicationController::showBoard()
int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex();
if (selectedSceneIndex != -1)
{
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), selectedSceneIndex);
UBApplication::boardController->emitScrollSignal();
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->selectedDocument(), selectedSceneIndex, true);
}
}
......@@ -522,42 +519,27 @@ void UBApplicationController::showSankoreEditor()
emit mainModeChanged(mMainMode);
}
void UBApplicationController::runCheckUpdate(int id, bool error)
{
Q_UNUSED(id);
if(!error){
if(mFtp!=NULL)
delete mFtp;
mFtp = new QFtp(this);
connect(mFtp, SIGNAL(commandFinished(int,bool)), this, SLOT(ftpCommandFinished(int,bool)));
mFtp->connectToHost("91.121.248.138",21);
mFtp->login("anonymous", "anonymous");
mFtp->get("update.json",0);
}
}
void UBApplicationController::checkUpdate()
{
//TODO change this when upgrade the qt version
// networkAccessible : NetworkAccessibility not yet available
if(mHttp)
if(mHttp)
delete mHttp;
QUrl url("http://www.google.com");
QUrl url("http://ftp.open-sankore.org/update.json");
mHttp = new QHttp(url.host());
connect(mHttp, SIGNAL(requestFinished(int,bool)), this, SLOT(runCheckUpdate(int,bool)));
connect(mHttp, SIGNAL(requestFinished(int,bool)), this, SLOT(updateRequestFinished(int,bool)));
mHttp->get(url.path());
}
void UBApplicationController::ftpCommandFinished(int id, bool error)
void UBApplicationController::updateRequestFinished(int id, bool error)
{
if (error){
qWarning() << "ftp command id" << id << "return the error: " << mFtp->errorString();
mFtp->close();
qWarning() << "http command id" << id << "return the error: " << mHttp->errorString();
mHttp->close();
}
else{
QString responseString = QString(mFtp->readAll());
QString responseString = QString(mHttp->readAll());
qDebug() << responseString;
if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mFtp->close();
mHttp->close();
downloadJsonFinished(responseString);
}
}
......
......@@ -134,8 +134,7 @@ class UBApplicationController : public QObject
void checkUpdateAtLaunch();
private slots:
void ftpCommandFinished(int id, bool error);
void runCheckUpdate(int id, bool error);
void updateRequestFinished(int id, bool error);
protected:
......@@ -152,7 +151,6 @@ class UBApplicationController : public QObject
UBScreenMirror* mMirror;
int mInitialHScroll, mInitialVScroll;
QFtp* mFtp;
private:
......
......@@ -608,10 +608,10 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
if (pScene->isModified())
{
UBThumbnailAdaptor::persistScene(pDocumentProxy->persistencePath(), pScene, pSceneIndex);
UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
pScene->setModified(false);
}
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBDocumentContainer.h"
#include "adaptors/UBThumbnailAdaptor.h"
#include "core/UBPersistenceManager.h"
#include "core/memcheck.h"
UBDocumentContainer::UBDocumentContainer(QObject * parent)
:QObject(parent)
,mCurrentDocument(NULL)
{}
UBDocumentContainer::~UBDocumentContainer()
{
foreach(const QPixmap* pm, mDocumentThumbs)
delete pm;
}
void UBDocumentContainer::setDocument(UBDocumentProxy* document, bool forceReload)
{
if (mCurrentDocument != document || forceReload)
{
mCurrentDocument = document;
reloadThumbnails();
emit documentSet(mCurrentDocument);
}
}
void UBDocumentContainer::duplicatePages(QList<int>& pageIndexes)
{
int offset = 0;
foreach(int sceneIndex, pageIndexes)
{
UBPersistenceManager::persistenceManager()->duplicateDocumentScene(mCurrentDocument, sceneIndex + offset);
insertThumbPage(sceneIndex + offset);
offset++;
}
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::movePageToIndex(int source, int target)
{
UBPersistenceManager::persistenceManager()->moveSceneToIndex(mCurrentDocument, source, target);
deleteThumbPage(source);
insertThumbPage(target);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::deletePages(QList<int>& pageIndexes)
{
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(mCurrentDocument, pageIndexes);
int offset = 0;
foreach(int index, pageIndexes)
{
deleteThumbPage(index - offset);
offset++;
}
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::addPage(int index)
{
UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mCurrentDocument, index);
insertThumbPage(index);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::updatePage(int index)
{
updateThumbPage(index);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::deleteThumbPage(int index)
{
mDocumentThumbs.removeAt(index);
emit documentPageDeleted(index);
}
void UBDocumentContainer::updateThumbPage(int index)
{
mDocumentThumbs[index] = UBThumbnailAdaptor::get(mCurrentDocument, index);
emit documentPageUpdated(index);
}
void UBDocumentContainer::insertThumbPage(int index)
{
mDocumentThumbs.insert(index, UBThumbnailAdaptor::get(mCurrentDocument, index));
emit documentPageAdded(index);
}
void UBDocumentContainer::reloadThumbnails()
{
if (mCurrentDocument)
{
UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs);
emit documentThumbnailsUpdated(this);
}
}
int UBDocumentContainer::pageFromSceneIndex(int sceneIndex)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return sceneIndex;
return sceneIndex+1;
}
int UBDocumentContainer::sceneIndexFromPage(int page)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return page;
return page-1;
}
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTCONTAINER_H_
#define UBDOCUMENTCONTAINER_H_
#include <QtGui>
#include "UBDocumentProxy.h"
class UBDocumentContainer : public QObject
{
Q_OBJECT
public:
UBDocumentContainer(QObject * parent = 0);
virtual ~UBDocumentContainer();
void setDocument(UBDocumentProxy* document, bool forceReload = false);
UBDocumentProxy* selectedDocument(){return mCurrentDocument;}
int pageCount(){return mDocumentThumbs.size();}
const QPixmap* pageAt(int index){return mDocumentThumbs[index];}
static int pageFromSceneIndex(int sceneIndex);
static int sceneIndexFromPage(int sceneIndex);
void duplicatePages(QList<int>& pageIndexes);
void movePageToIndex(int source, int target);
void deletePages(QList<int>& pageIndexes);
void addPage(int index);
void updatePage(int index);
private:
void deleteThumbPage(int index);
void updateThumbPage(int index);
void insertThumbPage(int index);
UBDocumentProxy* mCurrentDocument;
QList<const QPixmap*> mDocumentThumbs;
protected:
void reloadThumbnails();
signals:
void documentSet(UBDocumentProxy* document);
void documentPageAdded(int index);
void documentPageDeleted(int index);
void documentPageUpdated(int index);
void documentThumbnailsUpdated(UBDocumentContainer* source);
};
#endif /* UBDOCUMENTPROXY_H_ */
This diff is collapsed.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTCONTROLLER_H_
#define UBDOCUMENTCONTROLLER_H_
#include <QtGui>
namespace Ui
{
class documents;
}
#include "gui/UBMessageWindow.h"
class UBGraphicsScene;
class QDialog;
class UBDocumentProxy;
class UBBoardController;
class UBThumbnailsScene;
class UBDocumentGroupTreeItem;
class UBDocumentProxyTreeItem;
class UBMainWindow;
class UBDocumentToolsPalette;
class UBDocumentController : public QObject
{
Q_OBJECT;
public:
UBDocumentController(UBMainWindow* mainWindow);
virtual ~UBDocumentController();
void closing();
QWidget* controlView();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
bool addFileToDocument(UBDocumentProxy* document);
UBDocumentProxy* getCurrentDocument() { return mCurrentDocument; };
void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex();
bool pageCanBeMovedUp(int page);
bool pageCanBeMovedDown(int page);
bool pageCanBeDuplicated(int page);
bool pageCanBeDeleted(int page);
signals:
void refreshThumbnails();
void exportDone();
void movedToIndex(int index);
public slots:
void createNewDocument();
void createNewDocumentGroup();
void deleteSelectedItem();
void renameSelectedItem();
void openSelectedItem();
void duplicateSelectedItem();
void importFile();
void moveSceneToIndex(UBDocumentProxy* proxy, int source, int target);
void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true);
void show();
void hide();
void showMessage(const QString& message, bool showSpinningWheel);
void hideMessage();
void toggleDocumentToolsPalette();
void cut();
void copy();
void paste();
void focusChanged(QWidget *old, QWidget *current);
void reloadThumbs();
protected:
virtual void setupViews();
virtual void setupToolbar();
void setupPalettes();
bool isOKToOpenDocument(UBDocumentProxy* proxy);
UBGraphicsScene* activeScene();
UBDocumentProxy* selectedDocumentProxy();
UBDocumentProxyTreeItem* selectedDocumentProxyTreeItem();
UBDocumentGroupTreeItem* selectedDocumentGroupTreeItem();
QStringList allGroupNames();
enum LastSelectedElementType
{
None = 0, Folder, Document, Page
};
LastSelectedElementType mSelectionType;
private:
QWidget *mParentWidget;
UBBoardController *mBoardController;
Ui::documents* mDocumentUI;
UBMainWindow* mMainWindow;
QWidget *mDocumentWidget;
QPointer<UBMessageWindow> mMessageWindow;
QAction* mAddFolderOfImagesAction;
QAction* mAddFileToDocumentAction;
QAction* mAddImagesAction;
bool mIsClosing;
UBDocumentToolsPalette *mToolsPalette;
bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument;
QList<QPixmap> mDocumentThumbs;
private slots:
void documentZoomSliderValueChanged (int value);
void loadDocumentProxies();
void itemSelectionChanged();
void refreshDocumentThumbnailsView();
void exportDocument();
void itemChanged(QTreeWidgetItem * item, int column);
void thumbnailViewResized();
void pageSelectionChanged();
void selectionChanged();
void documentSceneChanged(UBDocumentProxy* proxy, int pSceneIndex);
void pageDoubleClicked(QGraphicsItem* item, int index);
void pageClicked(QGraphicsItem* item, int index);
void itemClicked(QTreeWidgetItem * item, int column );
void addToDocument();
void addDocumentInTree(UBDocumentProxy* pDocument);
void updateDocumentInTree(UBDocumentProxy* pDocument);
void addFolderOfImages();
void addFileToDocument();
void addImages();
};
#endif /* UBDOCUMENTCONTROLLER_H_ */
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTCONTROLLER_H_
#define UBDOCUMENTCONTROLLER_H_
#include <QtGui>
#include "document/UBDocumentContainer.h"
namespace Ui
{
class documents;
}
#include "gui/UBMessageWindow.h"
class UBGraphicsScene;
class QDialog;
class UBDocumentProxy;
class UBBoardController;
class UBThumbnailsScene;
class UBDocumentGroupTreeItem;
class UBDocumentProxyTreeItem;
class UBMainWindow;
class UBDocumentToolsPalette;
class UBDocumentController : public UBDocumentContainer
{
Q_OBJECT;
public:
UBDocumentController(UBMainWindow* mainWindow);
virtual ~UBDocumentController();
void closing();
QWidget* controlView();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
bool addFileToDocument(UBDocumentProxy* document);
void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex();
bool pageCanBeMovedUp(int page);
bool pageCanBeMovedDown(int page);
bool pageCanBeDuplicated(int page);
bool pageCanBeDeleted(int page);
signals:
//void refreshThumbnails();
void exportDone();
//void movedToIndex(int index);
public slots:
void createNewDocument();
void createNewDocumentGroup();
void deleteSelectedItem();
void renameSelectedItem();
void openSelectedItem();
void duplicateSelectedItem();
void importFile();
void moveSceneToIndex(UBDocumentProxy* proxy, int source, int target);
void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true);
void show();
void hide();
void showMessage(const QString& message, bool showSpinningWheel);
void hideMessage();
void toggleDocumentToolsPalette();
void cut();
void copy();
void paste();
void focusChanged(QWidget *old, QWidget *current);
//void reloadThumbs();
protected:
virtual void setupViews();
virtual void setupToolbar();
void setupPalettes();
bool isOKToOpenDocument(UBDocumentProxy* proxy);
UBDocumentProxy* selectedDocumentProxy();
UBDocumentProxyTreeItem* selectedDocumentProxyTreeItem();
UBDocumentGroupTreeItem* selectedDocumentGroupTreeItem();
QStringList allGroupNames();
enum LastSelectedElementType
{
None = 0, Folder, Document, Page
};
LastSelectedElementType mSelectionType;
private:
QWidget *mParentWidget;
UBBoardController *mBoardController;
Ui::documents* mDocumentUI;
UBMainWindow* mMainWindow;
QWidget *mDocumentWidget;
QPointer<UBMessageWindow> mMessageWindow;
QAction* mAddFolderOfImagesAction;
QAction* mAddFileToDocumentAction;
QAction* mAddImagesAction;
bool mIsClosing;
UBDocumentToolsPalette *mToolsPalette;
bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi;
private slots:
void documentZoomSliderValueChanged (int value);
void loadDocumentProxies();
void itemSelectionChanged();
void exportDocument();
void itemChanged(QTreeWidgetItem * item, int column);
void thumbnailViewResized();
void pageSelectionChanged();
void selectionChanged();
void documentSceneChanged(UBDocumentProxy* proxy, int pSceneIndex);
void pageDoubleClicked(QGraphicsItem* item, int index);
void pageClicked(QGraphicsItem* item, int index);
void itemClicked(QTreeWidgetItem * item, int column );
void addToDocument();
void addDocumentInTree(UBDocumentProxy* pDocument);
void updateDocumentInTree(UBDocumentProxy* pDocument);
void addFolderOfImages();
void addFileToDocument();
void addImages();
void refreshDocumentThumbnailsView(UBDocumentContainer* source);
};
#endif /* UBDOCUMENTCONTROLLER_H_ */
This diff is collapsed.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTPROXY_H_
#define UBDOCUMENTPROXY_H_
#include <QtGui>
#include "frameworks/UBStringUtils.h"
#include "core/UBSettings.h"
class UBGraphicsScene;
class UBDocumentProxy : public QObject
{
Q_OBJECT;
public:
UBDocumentProxy();
UBDocumentProxy(const QString& pPersistencePath);
virtual ~UBDocumentProxy();
QString persistencePath() const;
void setPersistencePath(const QString& pPersistencePath);
void setMetaData(const QString& pKey , const QVariant& pValue);
QVariant metaData(const QString& pKey) const;
QHash<QString, QVariant> metaDatas() const;
QString name() const;
QString groupName() const;
QDateTime documentDate();
QDateTime lastUpdate();
QSize defaultDocumentSize() const;
void setDefaultDocumentSize(QSize pSize);
void setDefaultDocumentSize(int pWidth, int pHeight);
QUuid uuid() const;
void setUuid(const QUuid& uuid);
bool isModified() const;
int pageCount();
void setPageCount(int pPageCount);
int incPageCount();
int decPageCount();
signals:
void defaultDocumentSizeChanged();
private:
void init();
QString mPersistencePath;
QHash<QString, QVariant> mMetaDatas;
bool mIsModified;
int mPageCount;
};
inline bool operator==(const UBDocumentProxy &proxy1, const UBDocumentProxy &proxy2)
{
return proxy1.persistencePath() == proxy2.persistencePath();
}
inline uint qHash(const UBDocumentProxy &key)
{
return qHash(key.persistencePath());
}
#endif /* UBDOCUMENTPROXY_H_ */
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTPROXY_H_
#define UBDOCUMENTPROXY_H_
#include <QtGui>
#include "frameworks/UBStringUtils.h"
#include "core/UBSettings.h"
class UBGraphicsScene;
class UBDocumentProxy : public QObject
{
Q_OBJECT
friend class UBPersistenceManager;
public:
UBDocumentProxy();
UBDocumentProxy(const QString& pPersistencePath);
virtual ~UBDocumentProxy();
QString persistencePath() const;
void setPersistencePath(const QString& pPersistencePath);
void setMetaData(const QString& pKey , const QVariant& pValue);
QVariant metaData(const QString& pKey) const;
QHash<QString, QVariant> metaDatas() const;
QString name() const;
QString groupName() const;
QDateTime documentDate();
QDateTime lastUpdate();
QSize defaultDocumentSize() const;
void setDefaultDocumentSize(QSize pSize);
void setDefaultDocumentSize(int pWidth, int pHeight);
QUuid uuid() const;
void setUuid(const QUuid& uuid);
bool isModified() const;
int pageCount();
protected:
void setPageCount(int pPageCount);
int incPageCount();
int decPageCount();
signals:
void defaultDocumentSizeChanged();
private:
void init();
QString mPersistencePath;
QHash<QString, QVariant> mMetaDatas;
bool mIsModified;
int mPageCount;
};
inline bool operator==(const UBDocumentProxy &proxy1, const UBDocumentProxy &proxy2)
{
return proxy1.persistencePath() == proxy2.persistencePath();
}
inline uint qHash(const UBDocumentProxy &key)
{
return qHash(key.persistencePath());
}
#endif /* UBDOCUMENTPROXY_H_ */
HEADERS += src/document/UBDocumentController.h \
src/document/UBDocumentContainer.h \
src/document/UBDocumentProxy.h
SOURCES += src/document/UBDocumentController.cpp \
SOURCES += src/document/UBDocumentController.cpp \
src/document/UBDocumentContainer.cpp \
src/document/UBDocumentProxy.cpp
\ No newline at end of file
......@@ -544,7 +544,6 @@ void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if(isResizing()){
mResizing = false;
}
mDelegate->setButtonsVisible(true);
}
......
......@@ -38,8 +38,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
{
update();
QString s = pMediaFileUrl.toLocalFile();
mMediaObject = new Phonon::MediaObject(this);
if (pMediaFileUrl.toLocalFile().contains("videos"))
{
......@@ -142,8 +140,8 @@ void UBGraphicsMediaItem::clearSource()
{
QString path = mediaFileUrl().toLocalFile();
//if path is absolute clean duplicated path string
if (!path.contains(UBApplication::boardController->activeDocument()->persistencePath()))
path = UBApplication::boardController->activeDocument()->persistencePath() + "/" + path;
if (!path.contains(UBApplication::boardController->selectedDocument()->persistencePath()))
path = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + path;
if (!UBFileSystemUtils::deleteFile(path))
qDebug() << "cannot delete file: " << path;
......
......@@ -20,6 +20,7 @@
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "document/UBDocumentContainer.h"
#include "globals/UBGlobals.h"
......@@ -334,7 +335,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath)
QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit)
{
int pageDigit = UBApplication::boardController->pageFromSceneIndex(digit);
int pageDigit = UBDocumentContainer::pageFromSceneIndex(digit);
return s.arg(pageDigit, 3, 10, QLatin1Char('0'));
}
......@@ -534,6 +535,59 @@ QString UBFileSystemUtils::fileExtensionFromMimeType(const QString& pMimeType)
}
UBMimeType::Enum UBFileSystemUtils::mimeTypeFromString(const QString& typeString)
{
UBMimeType::Enum type = UBMimeType::UNKNOWN;
if (typeString == "image/jpeg"
|| typeString == "image/png"
|| typeString == "image/gif"
|| typeString == "image/tiff"
|| typeString == "image/bmp")
{
type = UBMimeType::RasterImage;
}
else if (typeString == "image/svg+xml")
{
type = UBMimeType::VectorImage;
}
else if (typeString == "application/vnd.apple-widget")
{
type = UBMimeType::AppleWidget;
}
else if (typeString == "application/widget")
{
type = UBMimeType::W3CWidget;
}
else if (typeString.startsWith("video/"))
{
type = UBMimeType::Video;
}
else if (typeString.startsWith("audio/"))
{
type = UBMimeType::Audio;
}
else if (typeString.startsWith("application/x-shockwave-flash"))
{
type = UBMimeType::Flash;
}
else if (typeString.startsWith("application/pdf"))
{
type = UBMimeType::PDF;
}
else if (typeString.startsWith("application/vnd.mnemis-uniboard-tool"))
{
type = UBMimeType::UniboardTool;
}
return type;
}
UBMimeType::Enum UBFileSystemUtils::mimeTypeFromUrl(const QUrl& url)
{
return mimeTypeFromString(mimeTypeFromFileName(url.toString()));
}
QString UBFileSystemUtils::getFirstExistingFileFromList(const QString& path, const QStringList& files)
{
......
......@@ -18,6 +18,8 @@
#include <QtCore>
#include "core/UB.h"
class QuaZipFile;
class UBProcessingProgressListener;
......@@ -57,6 +59,10 @@ class UBFileSystemUtils
static QString fileExtensionFromMimeType(const QString& pMimeType);
static UBMimeType::Enum mimeTypeFromString(const QString& typeString);
static UBMimeType::Enum mimeTypeFromUrl(const QUrl& url);
static QString normalizeFilePath(const QString& pFilePath);
static QString extension(const QString& filaname);
......
This diff is collapsed.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTNAVIGATOR_H
#define UBDOCUMENTNAVIGATOR_H
#include <QResizeEvent>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QMouseEvent>
#include <QThread>
#include "document/UBDocumentProxy.h"
#include "UBThumbnailWidget.h"
#define NO_PAGESELECTED -1
class UBDocumentNavigator : public QGraphicsView
{
Q_OBJECT
public:
UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator");
~UBDocumentNavigator();
void setDocument(UBDocumentProxy* document);
void setNbColumns(int nbColumns);
int nbColumns();
void setThumbnailMinWidth(int width);
int thumbnailMinWidth();
int selectedPageNumber();
UBDocumentProxy* currentDoc();
signals:
void changeCurrentPage();
public slots:
void onMovedToIndex(int index);
void onScrollToSelectedPage() { centerOn(mCrntItem); }
protected:
virtual void resizeEvent(QResizeEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
private slots:
void addNewPage();
void onSelectionChanged();
void generateThumbnails();
private:
void refreshScene();
void updateSpecificThumbnail(int iPage);
int border();
/** The scene */
QGraphicsScene* mScene;
/** The current selected item */
UBSceneThumbnailNavigPixmap* mCrntItem;
/** The current document */
UBDocumentProxy* mCrntDoc;
/** The list of current thumbnails with labels*/
QList<UBImgTextThumbnailElement> mThumbsWithLabels;
/** The current number of columns */
int mNbColumns;
/** The current thumbnails width */
int mThumbnailWidth;
/** The current thumbnails minimum width */
int mThumbnailMinWidth;
/** A flag indicating that a thumbnail refresh is in progress */
bool bNavig;
};
#endif // UBDOCUMENTNAVIGATOR_H
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTNAVIGATOR_H
#define UBDOCUMENTNAVIGATOR_H
#include <QResizeEvent>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QMouseEvent>
#include <QThread>
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentContainer.h"
#include "UBThumbnailWidget.h"
#define NO_PAGESELECTED -1
class UBDocumentNavigator : public QGraphicsView
{
Q_OBJECT
public:
UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator");
~UBDocumentNavigator();
void setNbColumns(int nbColumns);
int nbColumns();
void setThumbnailMinWidth(int width);
int thumbnailMinWidth();
public slots:
void onScrollToSelectedPage(int index);// { if (mCrntItem) centerOn(mCrntItem); }
void generateThumbnails(UBDocumentContainer* source);
void updateSpecificThumbnail(int iPage);
protected:
virtual void resizeEvent(QResizeEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
private:
void refreshScene();
int border();
/** The scene */
QGraphicsScene* mScene;
/** The current selected item */
//UBSceneThumbnailNavigPixmap* mCrntItem;
/** The list of current thumbnails with labels*/
QList<UBImgTextThumbnailElement> mThumbsWithLabels;
/** The current number of columns */
int mNbColumns;
/** The current thumbnails width */
int mThumbnailWidth;
/** The current thumbnails minimum width */
int mThumbnailMinWidth;
};
#endif // UBDOCUMENTNAVIGATOR_H
This diff is collapsed.
This diff is collapsed.
......@@ -362,27 +362,52 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
{
QString previewImageUrl;
previewImageUrl = ":images/libpalette/loading.png";
switch (UBFileSystemUtils::mimeTypeFromUrl(QUrl(metadata["Url"])))
{
case UBMimeType::RasterImage:
case UBMimeType::VectorImage:
{
previewImageUrl = ":images/libpalette/loading.png";
if (!imageGatherer)
imageGatherer = new UBDownloadHttpFile(0, this);
if (!imageGatherer)
imageGatherer = new UBDownloadHttpFile(0, this);
connect(imageGatherer, SIGNAL(downloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onPreviewLoaded(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)));
connect(imageGatherer, SIGNAL(downloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onPreviewLoaded(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)));
// We send here the request and store its reply in order to be able to cancel it if needed
imageGatherer->get(QUrl(metadata["Url"]), QPoint(0,0), QSize(), false);
// We send here the request and store its reply in order to be able to cancel it if needed
imageGatherer->get(QUrl(metadata["Url"]), QPoint(0,0), QSize(), false);
} break;
case UBMimeType::Audio:
{
previewImageUrl = ":images/libpalette/soundIcon.svg";
}break;
case UBMimeType::Video:
{
previewImageUrl = ":images/libpalette/movieIcon.svg";
}break;
case UBMimeType::Flash:
{
previewImageUrl = ":images/libpalette/FlashIcon.svg";
}break;
}
UBFeature feature( QString(), QPixmap(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata );
UBFeature feature( QString(), QPixmap(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata );
featureProperties->showElement( feature );
switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES );
featureProperties->showElement( feature );
switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES );
}
void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{
Q_UNUSED(id);
Q_UNUSED(pSuccess);
Q_UNUSED(isBackground);
Q_UNUSED(pSize);
Q_UNUSED(pPos);
QImage img;
img.loadFromData(pData);
QPixmap pix = QPixmap::fromImage(img);
......@@ -779,6 +804,7 @@ void UBFeatureProperties::setOrigPixmap(QPixmap &pix)
void UBFeatureProperties::setThumbnail(QPixmap &pix)
{
mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH));
adaptSize();
}
void UBFeatureProperties::adaptSize()
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -245,7 +245,7 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged()
cleanData();
load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex()));
mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
}
......@@ -483,7 +483,7 @@ void UBTeacherGuidePresentationWidget::onActiveSceneChanged()
{
cleanData();
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage()));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
}
......@@ -535,9 +535,9 @@ void UBTeacherGuidePresentationWidget::showData(QVector<tUBGEElementNode*> data)
newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
QString mimeTypeString;
#ifdef Q_WS_WIN
mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString();
mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString();
#else
mimeTypeString = UBApplication::boardController->activeDocument()->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);
......@@ -882,7 +882,7 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel)
void UBTeacherGuidePageZeroWidget::onActiveSceneChanged()
{
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(documentProxy && UBApplication::boardController->currentPage() == 0){
QDateTime creationDate = documentProxy->documentDate();
mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate));
......@@ -901,7 +901,7 @@ void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event )
void UBTeacherGuidePageZeroWidget::loadData()
{
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
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());
......@@ -925,7 +925,7 @@ void UBTeacherGuidePageZeroWidget::persistData()
// check necessary because at document closing hide event is send after boardcontroller set
// to NULL
if(UBApplication::boardController){
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text());
documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text());
documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text());
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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