preferencesAboutTextFull
shibakaneki 13 years ago
commit 001528da50
  1. 2
      resources/library/applications/Calculatrice.wgt/config.xml
  2. 31
      resources/library/interactivities/Ass images.wgt/css/basic.css
  3. BIN
      resources/library/interactivities/Ass images.wgt/img/slate-help-white.png
  4. BIN
      resources/library/interactivities/Ass images.wgt/img/slate-help.png
  5. 3
      resources/library/interactivities/Ass images.wgt/index.html
  6. 24
      resources/library/interactivities/Ass images.wgt/js/script.js
  7. 2
      resources/library/interactivities/Ass images.wgt/locales/fr/index.html
  8. 25
      resources/library/interactivities/Ass images.wgt/locales/fr/js/script.js
  9. 2
      resources/library/interactivities/Ass images.wgt/locales/ru/index.html
  10. 22
      resources/library/interactivities/Ass images.wgt/locales/ru/js/script.js
  11. 18
      resources/library/interactivities/Ordre mots.wgt/locales/fr/scripts/template2.js
  12. 18
      resources/library/interactivities/Ordre mots.wgt/locales/ru/scripts/template2.js
  13. 11
      resources/library/interactivities/Ordre mots.wgt/scripts/template2.js
  14. 7
      resources/library/interactivities/Ordre mots.wgt/styles/of_puppets.css
  15. 10
      resources/library/search/Audio Planete.wgs/index.html
  16. 10
      resources/library/search/Flash Planete.wgs/index.html
  17. 136
      resources/library/search/Image Planete.wgs/index.html
  18. 11
      resources/library/search/Video Planete.wgs/index.html
  19. 4
      src/adaptors/UBCFFSubsetAdaptor.cpp
  20. 4
      src/adaptors/UBSvgSubsetAdaptor.cpp
  21. 50
      src/adaptors/UBThumbnailAdaptor.cpp
  22. 13
      src/adaptors/UBThumbnailAdaptor.h
  23. 52
      src/adaptors/publishing/UBDocumentPublisher.cpp
  24. 7
      src/adaptors/publishing/UBDocumentPublisher.h
  25. 2
      src/api/UBWidgetUniboardAPI.cpp
  26. 279
      src/board/UBBoardController.cpp
  27. 30
      src/board/UBBoardController.h
  28. 6
      src/board/UBBoardPaletteManager.cpp
  29. 1
      src/board/UBBoardView.cpp
  30. 2
      src/board/UBLibraryController.cpp
  31. 17
      src/core/UB.h
  32. 2
      src/core/UBApplication.cpp
  33. 38
      src/core/UBApplicationController.cpp
  34. 4
      src/core/UBApplicationController.h
  35. 4
      src/core/UBPersistenceManager.cpp
  36. 127
      src/document/UBDocumentContainer.cpp
  37. 67
      src/document/UBDocumentContainer.h
  38. 230
      src/document/UBDocumentController.cpp
  39. 15
      src/document/UBDocumentController.h
  40. 6
      src/document/UBDocumentProxy.h
  41. 2
      src/document/document.pri
  42. 1
      src/domain/UBGraphicsDelegateFrame.cpp
  43. 6
      src/domain/UBGraphicsMediaItem.cpp
  44. 56
      src/frameworks/UBFileSystemUtils.cpp
  45. 6
      src/frameworks/UBFileSystemUtils.h
  46. 215
      src/gui/UBDocumentNavigator.cpp
  47. 26
      src/gui/UBDocumentNavigator.h
  48. 9
      src/gui/UBDocumentThumbnailWidget.cpp
  49. 4
      src/gui/UBDocumentTreeWidget.cpp
  50. 48
      src/gui/UBFeaturesWidget.cpp
  51. 23
      src/gui/UBNavigatorPalette.cpp
  52. 2
      src/gui/UBNavigatorPalette.h
  53. 47
      src/gui/UBPageNavigationWidget.cpp
  54. 6
      src/gui/UBPageNavigationWidget.h
  55. 14
      src/gui/UBTeacherGuideWidget.cpp
  56. 8
      src/gui/UBTeacherGuideWidgetsTools.cpp
  57. 19
      src/gui/UBThumbnailWidget.cpp
  58. 8
      src/gui/UBThumbnailWidget.h
  59. 8
      src/tools/UBGraphicsCurtainItemDelegate.cpp
  60. 1
      src/tools/UBGraphicsCurtainItemDelegate.h

@ -4,7 +4,7 @@
id="http://uniboard.mnemis.com/widgets/calculator" id="http://uniboard.mnemis.com/widgets/calculator"
version="1.1" version="1.1"
width="200" width="200"
height="295" height="300"
ub:resizable="false"> ub:resizable="false">
<name>Calculator</name> <name>Calculator</name>
<content src="index.html"/> <content src="index.html"/>

@ -4,6 +4,7 @@ html, body{
margin: 0; margin: 0;
padding: 0; padding: 0;
border-radius: 50px; border-radius: 50px;
overflow: hidden;
} }
.without_radius{ .without_radius{
@ -283,7 +284,6 @@ body{
#wgt_name{ #wgt_name{
height: 44px; height: 44px;
width: 300px;
margin: 10px 10px 0 10px; margin: 10px 10px 0 10px;
padding: 0; padding: 0;
float: left; float: left;
@ -292,9 +292,8 @@ body{
color: #8c5730; color: #8c5730;
} }
#wgt_reload, #wgt_edit, #wgt_display{ #wgt_reload, #wgt_edit, #wgt_display, #wgt_help{
cursor: pointer; cursor: pointer;
width: 80px;
height: 44px; height: 44px;
margin: 10px 10px 0 0; margin: 10px 10px 0 0;
float: right; float: right;
@ -304,7 +303,6 @@ body{
} }
#wgt_display{ #wgt_display{
width: 100px;
padding-left: 40px; padding-left: 40px;
background-image: url(../img/slate-edit.png); background-image: url(../img/slate-edit.png);
background-repeat: no-repeat; background-repeat: no-repeat;
@ -313,7 +311,6 @@ body{
} }
#wgt_edit{ #wgt_edit{
width: 100px;
padding-left: 40px; padding-left: 40px;
background-image: url(../img/slate-edit.png); background-image: url(../img/slate-edit.png);
background-repeat: no-repeat; background-repeat: no-repeat;
@ -398,3 +395,27 @@ body{
color: white !important; color: white !important;
background-image: url(../img/ar_down_white.png) !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{
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -16,6 +16,7 @@
lang = sankore.locale().substr(0,2); lang = sankore.locale().substr(0,2);
} else } else
lang = "en"; lang = "en";
lang = "fr";
if(lang == "en"){ if(lang == "en"){
if(window.sankore) if(window.sankore)
sankore.enableDropOnWidget(false); sankore.enableDropOnWidget(false);
@ -51,6 +52,7 @@
<td class="b_top_left">&nbsp;</td> <td class="b_top_left">&nbsp;</td>
<td class="b_top_center"> <td class="b_top_center">
<div id="wgt_name"></div> <div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div> <div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div> <div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div> <div id="wgt_edit"></div>
@ -66,6 +68,7 @@
<tr> <tr>
<td class="b_center_left">&nbsp;</td> <td class="b_center_left">&nbsp;</td>
<td> <td>
<div id="help"></div>
<div id="data"> <div id="data">
</div> </div>

@ -8,7 +8,9 @@ var sankoreLang = {
reload: "Reload", reload: "Reload",
slate: "Wood", slate: "Wood",
pad: "Pad", pad: "Pad",
none: "None" none: "None",
help: "Help",
help_content: "This is an example of help content ..."
}; };
//main function //main function
@ -18,6 +20,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload); $("#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='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none); $(".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(){ $("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){ if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click"); $("#wgt_edit").trigger("click");
@ -618,6 +637,7 @@ function changeStyle(val){
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); $("#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_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color"); $("#wgt_name").removeClass("pad_color");
@ -634,6 +654,7 @@ function changeStyle(val){
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#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_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color"); $("#wgt_name").addClass("pad_color");
@ -649,6 +670,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_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_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");

@ -22,6 +22,7 @@
<td class="b_top_left">&nbsp;</td> <td class="b_top_left">&nbsp;</td>
<td class="b_top_center"> <td class="b_top_center">
<div id="wgt_name"></div> <div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div> <div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div> <div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div> <div id="wgt_edit"></div>
@ -37,6 +38,7 @@
<tr> <tr>
<td class="b_center_left">&nbsp;</td> <td class="b_center_left">&nbsp;</td>
<td> <td>
<div id="help"></div>
<div id="data"> <div id="data">
</div> </div>

@ -8,7 +8,9 @@ var sankoreLang = {
reload: "Recharger", reload: "Recharger",
slate: "ardoise", slate: "ardoise",
pad: "tablette", pad: "tablette",
none: "aucun" none: "aucun",
help: "aide",
help_content: "Ceci est un exemple de contenu de l'aide ..."
}; };
//main function //main function
@ -18,6 +20,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload); $("#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='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none); $(".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(){ $("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){ if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click"); $("#wgt_edit").trigger("click");
@ -613,6 +632,7 @@ function changeStyle(val){
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); $("#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_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color"); $("#wgt_name").removeClass("pad_color");
@ -629,6 +649,7 @@ function changeStyle(val){
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#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_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color"); $("#wgt_name").addClass("pad_color");
@ -644,6 +665,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_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_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
@ -761,4 +783,3 @@ function onDropTarget(obj, event) {
} }
return false; return false;
} }

@ -22,6 +22,7 @@
<td class="b_top_left">&nbsp;</td> <td class="b_top_left">&nbsp;</td>
<td class="b_top_center"> <td class="b_top_center">
<div id="wgt_name"></div> <div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div> <div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div> <div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div> <div id="wgt_edit"></div>
@ -37,6 +38,7 @@
<tr> <tr>
<td class="b_center_left">&nbsp;</td> <td class="b_center_left">&nbsp;</td>
<td> <td>
<div id="help"></div>
<div id="data"> <div id="data">
</div> </div>

@ -11,6 +11,7 @@ var sankoreLang = {
none: "Нет" none: "Нет"
}; };
//main function //main function
function start(){ function start(){
@ -18,6 +19,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload); $("#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='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none); $(".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(){ $("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){ if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click"); $("#wgt_edit").trigger("click");
@ -613,6 +631,7 @@ function changeStyle(val){
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); $("#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_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color"); $("#wgt_name").removeClass("pad_color");
@ -629,6 +648,7 @@ function changeStyle(val){
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#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_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color"); $("#wgt_name").addClass("pad_color");
@ -644,6 +664,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_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_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
@ -761,4 +782,3 @@ function onDropTarget(obj, event) {
} }
return false; return false;
} }

@ -47,8 +47,6 @@ if(window.sankore){
word = sankoreLang.example; word = sankoreLang.example;
} }
var doCheckWord = true;
// array of dom elements // array of dom elements
var letters = []; var letters = [];
@ -67,9 +65,12 @@ var widget_padding = 0;
var min_view_width = 400; var min_view_width = 400;
$(document).ready(function(){ $(document).ready(function(){
if(sankore.preference("ord_words_style","")){ if(window.sankore){
changeStyle(sankore.preference("ord_words_style","")); if(sankore.preference("ord_words_style","")){
$(".style_select").val(sankore.preference("ord_words_style","")); changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style",""));
} else
changeStyle("3")
} else } else
changeStyle("3") changeStyle("3")
$("#wgt_display").text(sankoreLang.view); $("#wgt_display").text(sankoreLang.view);
@ -300,7 +301,7 @@ turns the widget into the view mode
function modeView() function modeView()
{ {
if( editMode ){ if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" ); word = $( "#mp_word .wgt_cont" ).val();
} }
wgtState = false; wgtState = false;
@ -360,14 +361,15 @@ function modeEdit()
{ {
editMode = true; editMode = true;
wgtState = 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) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val()); 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(); modeView();
var str = ""; var str = "";

@ -47,8 +47,6 @@ if(window.sankore){
word = sankoreLang.example; word = sankoreLang.example;
} }
var doCheckWord = true;
// array of dom elements // array of dom elements
var letters = []; var letters = [];
@ -67,9 +65,12 @@ var widget_padding = 0;
var min_view_width = 400; var min_view_width = 400;
$(document).ready(function(){ $(document).ready(function(){
if(sankore.preference("ord_words_style","")){ if(window.sankore){
changeStyle(sankore.preference("ord_words_style","")); if(sankore.preference("ord_words_style","")){
$(".style_select").val(sankore.preference("ord_words_style","")); changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style",""));
} else
changeStyle("3")
} else } else
changeStyle("3") changeStyle("3")
$("#wgt_display").text(sankoreLang.view); $("#wgt_display").text(sankoreLang.view);
@ -300,7 +301,7 @@ turns the widget into the view mode
function modeView() function modeView()
{ {
if( editMode ){ if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" ); word = $( "#mp_word .wgt_cont" ).val();
} }
wgtState = false; wgtState = false;
@ -360,14 +361,15 @@ function modeEdit()
{ {
editMode = true; editMode = true;
wgtState = 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) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val()); 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(); modeView();
var str = ""; var str = "";

@ -65,12 +65,14 @@ var widget_padding = 0;
var min_view_width = 400; var min_view_width = 400;
$(document).ready(function(){ $(document).ready(function(){
if(window.sankore) if(window.sankore){
if(sankore.preference("ord_words_style","")){ if(sankore.preference("ord_words_style","")){
changeStyle(sankore.preference("ord_words_style","")); changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style","")); $(".style_select").val(sankore.preference("ord_words_style",""));
} else } else
changeStyle("3") changeStyle("3")
} else
changeStyle("3")
$("#wgt_display").text(sankoreLang.view); $("#wgt_display").text(sankoreLang.view);
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_display, #wgt_edit").click(function(event){ $("#wgt_display, #wgt_edit").click(function(event){
@ -299,7 +301,7 @@ turns the widget into the view mode
function modeView() function modeView()
{ {
if( editMode ){ if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" ); word = $( "#mp_word .wgt_cont" ).val();
} }
wgtState = false; wgtState = false;
@ -359,14 +361,15 @@ function modeEdit()
{ {
editMode = true; editMode = true;
wgtState = 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) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val()); 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(); modeView();
var str = ""; var str = "";

@ -12,7 +12,7 @@ body{
.letter{ .letter{
min-width: 30px; min-width: 30px;
max-width: 500px; max-width: 600px;
height: 40px; height: 40px;
overflow: hidden; overflow: hidden;
border: solid 1px #ccc; border: solid 1px #ccc;
@ -43,11 +43,12 @@ body{
text-align: center; text-align: center;
} }
#mp_word input{ #mp_word .wgt_cont{
font: 32px tahoma; font: 32px tahoma;
letter-spacing: 0.1em; letter-spacing: 0.1em;
width: 98%; width: 98%;
overflow: auto; min-height: 200px;
resize: vertical;
} }
#mp_msg{ #mp_msg{

@ -107,7 +107,6 @@
function imageDragging(e){ function imageDragging(e){
e.dataTransfer.setData("text/plain",$(this).find("input:hidden").eq(0).val()); e.dataTransfer.setData("text/plain",$(this).find("input:hidden").eq(0).val());
// alert($(this).find("input:hidden").eq(0).val());
} }
function imageDragleave(e){ function imageDragleave(e){
@ -235,15 +234,12 @@
function createMetaData(parent){ function createMetaData(parent){
var meta = ""; var meta = "";
//alert($(this).find("input:hidden").eq(0).val()); //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() + parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" + "</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() + parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" + "</value></data><data><key>Height</key><value>n/a</value></data>"+
parent.find("input:hidden").eq(2).val() + "<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() + parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>"; "</value></data></metadata>";
return meta; return meta;

@ -234,16 +234,12 @@
function createMetaData(parent){ function createMetaData(parent){
var meta = ""; var meta = "";
//alert($(this).find("input:hidden").eq(0).val()); meta = "<metadata><data><key>Type</key><value>Flash</value></data><data><key>Url</key><value>" +
meta = "<metadata><data><key>Type</key><value>Image</value></data><data><key>Url</key><value>" +
parent.find("input:hidden").eq(0).val() + parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" + "</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() + parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" + "</value></data><data><key>Height</key><value>n/a</value></data>"+
parent.find("input:hidden").eq(2).val() + "<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() + parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>"; "</value></data></metadata>";
return meta; return meta;

@ -22,10 +22,10 @@
for (var i = 0; i < 8; i++) { for (var i = 0; i < 8; i++) {
if (i * limit < totalResults) { if (i * limit < totalResults) {
var link = $("<a class='pager_button'></a>").attr('href', 'javascript:gotoPage('+i+');').html(i+1).appendTo(pagesDiv); var link = $("<a class='pager_button'></a>").attr('href', 'javascript:gotoPage('+i+');').html(i+1).appendTo(pagesDiv);
if (curPage == i) { if (curPage == i) {
link.addClass('active'); link.addClass('active');
} }
} }
} }
@ -50,59 +50,65 @@
} }
function searchFail(jqXHR, textStatus, errorThrown) { 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) { function searchComplete(json) {
// Grab our content div, clear it. // Grab our content div, clear it.
var totalResults = json.totalResults; var totalResults = json.totalResults;
var contentDiv = $('#searchResult').empty(); var contentDiv = $('#searchResult').empty();
// Loop through our results, printing them to the page. // Loop through our results, printing them to the page.
var results = json.rows; var results = json.rows;
for (var i = 0; i < results.length; i++) { for (var i = 0; i < results.length; i++) {
// For each result write it's title and image to the screen // For each result write it's title and image to the screen
var result = results[i]; var result = results[i];
var imgContainer = $("<div class='imgContainer' draggable='true'>"); var imgContainer = $("<div class='imgContainer' draggable='true'>");
//var title = document.createElement('div'); //var title = document.createElement('div');
var iUrl = $("<input type='hidden'/>"); var iUrl = $("<input type='hidden'/>");
var iContent = $("<input type='hidden'/>"); var iContent = $("<input type='hidden'/>");
var iHeight = $("<input type='hidden'/>"); var iHeight = $("<input type='hidden'/>");
var iWidth = $("<input type='hidden'/>"); var iWidth = $("<input type='hidden'/>");
var iTitle = $("<input type='hidden'/>"); var iTitle = $("<input type='hidden'/>");
// We use titleNoFormatting so that no HTML tags are left in the // We use titleNoFormatting so that no HTML tags are left in the
// title // title
//title.innerHTML = result.title; //title.innerHTML = result.title;
var newImg = document.createElement('img'); var newImg = document.createElement('img');
// There is also a result.file property which has the escaped version // There is also a result.file property which has the escaped version
if (thumbnails) { if (thumbnails) {
newImg.src = result.file; newImg.src = result.file;
} else { if(result.height >= result.width)
newImg.src = "./images/thumbnail_icon.png"; newImg.height = minHeight;
} else{
var imgWidth = (result.tbWidth > minWidth)?result.tbWidth:minWidth; newImg.width = minWidth;
var imgHeight = (result.tbHeight > minHeight)?result.tbHeight:minHeight; //newImg.style.margin = (120 - result.height)/2 + "px 0";
imgContainer.width(imgWidth).height(imgHeight); }
imgContainer.append($(newImg)); } else {
iUrl.attr("value", result.file); newImg.src = "./images/thumbnail_icon.png";
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);
} }
// Now add links to additional pages of search results. var imgWidth = (result.tbWidth > minWidth)?result.tbWidth:minWidth;
addPaginationLinks(totalResults); 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);
}
// Now add links to additional pages of search results.
addPaginationLinks(totalResults);
} }
function imageDragging(e){ function imageDragging(e){
@ -166,9 +172,9 @@
filtersDisplayed = true; filtersDisplayed = true;
} }
}); });
*/ */
/*togglePages.click(function(event){ /*togglePages.click(function(event){
if(mode){ if(mode){
hide = false; hide = false;
$("#search, #disclaimer").slideDown('slow', function(){ $("#search, #disclaimer").slideDown('slow', function(){
@ -204,10 +210,10 @@
}); });
( (
$(".imgContainer").live("click",function(){ $(".imgContainer").live("click",function(){
sankore.sendFileMetadata(createMetaData($(this))); sankore.sendFileMetadata(createMetaData($(this)));
})); }));
/*$(window).resize(function(){ /*$(window).resize(function(){
disclaimer.width($("body").width()-20); disclaimer.width($("body").width()-20);
search.width($("body").width()-20); search.width($("body").width()-20);
toggleIcon.css("margin-left",(togglePages.width()/2 - 7)); toggleIcon.css("margin-left",(togglePages.width()/2 - 7));
@ -216,21 +222,21 @@
}); });
function gotoPage(i) { function gotoPage(i) {
runSearch(currentTerm, i); runSearch(currentTerm, i);
} }
// launching the search on planete sankore // launching the search on planete sankore
function runSearch(term, index) { function runSearch(term, index) {
currentTerm = term; currentTerm = term;
currentIndex = index; 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; 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({ $.ajax({
url: url, url: url,
success: searchComplete, success: searchComplete,
error: searchFail, error: searchFail,
dataType: "json" dataType: "json"
}); });
} }
function createMetaData(parent){ function createMetaData(parent){

@ -203,7 +203,7 @@
}); });
( (
$(".imgContainer").live("click",function(){ $(".imgContainer").live("click",function(){
sankore.sendFileMetadata(createMetaData($(this))); sankore.sendFileMetadata(createMetaData($(this)));
})); }));
/*$(window).resize(function(){ /*$(window).resize(function(){
@ -235,15 +235,12 @@
function createMetaData(parent){ function createMetaData(parent){
var meta = ""; var meta = "";
//alert($(this).find("input:hidden").eq(0).val()); //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() + parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" + "</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() + parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" + "</value></data><data><key>Height</key><value>n/a</value></data>"+
parent.find("input:hidden").eq(2).val() + "<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() + parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>"; "</value></data></metadata>";
return meta; return meta;

@ -1078,7 +1078,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistCurrentScene()
{ {
if (mCurrentScene != 0 && mCurrentScene->isModified()) 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); UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1);
mCurrentScene->setModified(false); mCurrentScene->setModified(false);
@ -1102,7 +1102,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistScenes()
UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, i); UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, i);
UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i); UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i);
tmpScene->setModified(true); tmpScene->setModified(true);
UBThumbnailAdaptor::persistScene(mProxy->persistencePath(), tmpScene, i); UBThumbnailAdaptor::persistScene(mProxy, tmpScene, i);
delete tmpScene; delete tmpScene;
mCurrentScene->setModified(false); mCurrentScene->setModified(false);

@ -56,6 +56,8 @@
#include "interfaces/IDataStorage.h" #include "interfaces/IDataStorage.h"
#include "document/UBDocumentContainer.h"
#include "pdf/PDFRenderer.h" #include "pdf/PDFRenderer.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -313,7 +315,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex)
{ {
QString result; 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); QFile file(fileName);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
QByteArray fileByteArray=file.readAll(); QByteArray fileByteArray=file.readAll();

@ -58,7 +58,7 @@ void UBThumbnailAdaptor::generateMissingThumbnails(UBDocumentProxy* proxy)
if (displayMessage && thumbCount == 1) if (displayMessage && thumbCount == 1)
UBApplication::showMessage(tr("Generating preview thumbnails ...")); UBApplication::showMessage(tr("Generating preview thumbnails ..."));
persistScene(proxy->persistencePath(), scene, iPageNo); persistScene(proxy, scene, iPageNo);
} }
if (displayMessage && thumbCount > 0) if (displayMessage && thumbCount > 0)
@ -68,10 +68,48 @@ void UBThumbnailAdaptor::generateMissingThumbnails(UBDocumentProxy* proxy)
} }
} }
const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex)
{
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);
QFile file(fileName);
if (!file.exists())
{
generateMissingThumbnails(proxy);
}
QPixmap* pix = new QPixmap();
if (file.exists())
{
//Warning. Works only with modified Qt
#ifdef Q_WS_X11
pix->load(fileName, 0, Qt::AutoColor);
#else
pix->load(fileName, 0, Qt::AutoColor, false);
#endif
}
return pix;
}
void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList<const QPixmap*>& list)
{
generateMissingThumbnails(proxy);
foreach(const QPixmap* pm, list)
delete pm;
list.clear();
for(int i=0; i<proxy->pageCount(); i++)
list.append(get(proxy, i));
}
/*
QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy) QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
{ {
QList<QPixmap> thumbnails; QList<QPixmap> thumbnails;
qDebug() << "Loadinf thumbnails for " << proxy->name();
if (!proxy || proxy->persistencePath().isEmpty()) if (!proxy || proxy->persistencePath().isEmpty())
return thumbnails; return thumbnails;
@ -107,6 +145,8 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index) QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
{ {
qDebug() << "Loadinf thumbnails for " << proxy->name();
int existingPageCount = proxy->pageCount(); int existingPageCount = proxy->pageCount();
if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index > existingPageCount) if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index > existingPageCount)
@ -131,10 +171,14 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
} }
return QPixmap(); return QPixmap();
} }
*/
void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified) void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified)
{ {
QString fileName = pDocPath + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);
qDebug() << "Persiste scene on path " << proxy->persistencePath() << ", index " << pageIndex;
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);
QFile thumbFile(fileName); QFile thumbFile(fileName);

@ -25,15 +25,18 @@ class UBThumbnailAdaptor //static class
{ {
Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor) Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor)
private: UBThumbnailAdaptor() {}
public: public:
static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false); 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); 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); UBThumbnailAdaptor() {}
}; };
#endif // UBTHUMBNAILADAPTOR_H #endif // UBTHUMBNAILADAPTOR_H

@ -33,6 +33,7 @@
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "document/UBDocumentContainer.h"
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
@ -57,7 +58,6 @@ THIRD_PARTY_WARNINGS_ENABLE
UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *parent) UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *parent)
: QObject(parent) : QObject(parent)
, mSourceDocument(pDocument) , mSourceDocument(pDocument)
, mPublishingDocument(0)
, mUsername("") , mUsername("")
, mPassword("") , mPassword("")
, bLoginCookieSet(false) , bLoginCookieSet(false)
@ -69,10 +69,6 @@ UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *pa
UBDocumentPublisher::~UBDocumentPublisher() UBDocumentPublisher::~UBDocumentPublisher()
{ {
if(mPublishingDocument){
delete mPublishingDocument;
mPublishingDocument = NULL;
}
} }
@ -115,8 +111,8 @@ void UBDocumentPublisher::buildUbwFile()
{ {
QUuid publishingUuid = QUuid::createUuid(); QUuid publishingUuid = QUuid::createUuid();
mPublishingDocument = new UBDocumentProxy(tmpDir); mPublishingPath = tmpDir;
mPublishingDocument->setPageCount(mSourceDocument->pageCount()); mPublishingSize = mSourceDocument->pageCount();
rasterizeScenes(); rasterizeScenes();
@ -124,24 +120,24 @@ void UBDocumentPublisher::buildUbwFile()
UBExportFullPDF pdfExporter; UBExportFullPDF pdfExporter;
pdfExporter.setVerbode(false); pdfExporter.setVerbode(false);
pdfExporter.persistsDocument(mSourceDocument, mPublishingDocument->persistencePath() + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".pdf"); pdfExporter.persistsDocument(mSourceDocument, mPublishingPath + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".pdf");
UBExportDocument ubzExporter; UBExportDocument ubzExporter;
ubzExporter.setVerbode(false); ubzExporter.setVerbode(false);
ubzExporter.persistsDocument(mSourceDocument, mPublishingDocument->persistencePath() + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".ubz"); ubzExporter.persistsDocument(mSourceDocument, mPublishingPath + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".ubz");
// remove all useless files // remove all useless files
for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) { for (int pageIndex = 0; pageIndex < mPublishingSize; pageIndex++) {
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg",pageIndex); QString filename = mPublishingPath + UBFileSystemUtils::digitFileFormat("/page%1.svg",pageIndex);
QFile::remove(filename); QFile::remove(filename);
} }
UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::imageDirectory); UBFileSystemUtils::deleteDir(mPublishingPath + "/" + UBPersistenceManager::imageDirectory);
UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::objectDirectory); UBFileSystemUtils::deleteDir(mPublishingPath + "/" + UBPersistenceManager::objectDirectory);
UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::videoDirectory); UBFileSystemUtils::deleteDir(mPublishingPath + "/" + UBPersistenceManager::videoDirectory);
UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::audioDirectory); UBFileSystemUtils::deleteDir(mPublishingPath + "/" + UBPersistenceManager::audioDirectory);
mTmpZipFile = UBFileSystemUtils::defaultTempDirPath() + "/" + UBStringUtils::toCanonicalUuid(QUuid::createUuid()) + ".ubw~"; mTmpZipFile = UBFileSystemUtils::defaultTempDirPath() + "/" + UBStringUtils::toCanonicalUuid(QUuid::createUuid()) + ".ubw~";
@ -156,7 +152,7 @@ void UBDocumentPublisher::buildUbwFile()
QuaZipFile outFile(&zip); QuaZipFile outFile(&zip);
if (!UBFileSystemUtils::compressDirInZip(mPublishingDocument->persistencePath(), "", &outFile, true)) if (!UBFileSystemUtils::compressDirInZip(mPublishingPath, "", &outFile, true))
{ {
qWarning("Export failed. compressDirInZip failed ..."); qWarning("Export failed. compressDirInZip failed ...");
zip.close(); zip.close();
@ -187,13 +183,14 @@ void UBDocumentPublisher::buildUbwFile()
void UBDocumentPublisher::rasterizeScenes() void UBDocumentPublisher::rasterizeScenes()
{ {
for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) for (int pageIndex = 0; pageIndex < mPublishingSize; pageIndex++)
{ {
UBApplication::showMessage(tr("Converting page %1/%2 ...").arg(UBApplication::boardController->pageFromSceneIndex(pageIndex)).arg(mPublishingDocument->pageCount()), true); UBApplication::showMessage(tr("Converting page %1/%2 ...").arg(UBDocumentContainer::pageFromSceneIndex(pageIndex)).arg(mPublishingSize), true);
UBSvgSubsetRasterizer rasterizer(mPublishingDocument, pageIndex); UBDocumentProxy publishingDocument(mPublishingPath);
UBSvgSubsetRasterizer rasterizer(&publishingDocument, pageIndex);
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.jpg",pageIndex); QString filename = mPublishingPath + UBFileSystemUtils::digitFileFormat("/page%1.jpg",pageIndex);
rasterizer.rasterizeToFile(filename); rasterizer.rasterizeToFile(filename);
@ -203,7 +200,7 @@ void UBDocumentPublisher::rasterizeScenes()
void UBDocumentPublisher::updateGoogleMapApiKey() void UBDocumentPublisher::updateGoogleMapApiKey()
{ {
QDir widgestDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::widgetDirectory); QDir widgestDir(mPublishingPath + "/" + UBPersistenceManager::widgetDirectory);
QString uniboardWebGoogleMapApiKey = UBSettings::settings()->uniboardWebGoogleMapApiKey->get().toString(); QString uniboardWebGoogleMapApiKey = UBSettings::settings()->uniboardWebGoogleMapApiKey->get().toString();
@ -242,9 +239,10 @@ void UBDocumentPublisher::updateGoogleMapApiKey()
void UBDocumentPublisher::upgradeDocumentForPublishing() void UBDocumentPublisher::upgradeDocumentForPublishing()
{ {
for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) for (int pageIndex = 0; pageIndex < mPublishingSize; pageIndex++)
{ {
UBGraphicsScene *scene = UBSvgSubsetAdaptor::loadScene(mPublishingDocument, pageIndex); UBDocumentProxy publishingDocument(mPublishingPath);
UBGraphicsScene *scene = UBSvgSubsetAdaptor::loadScene(&publishingDocument, pageIndex);
QList<UBGraphicsW3CWidgetItem*> widgets; QList<UBGraphicsW3CWidgetItem*> widgets;
@ -252,12 +250,12 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
UBGraphicsW3CWidgetItem *widgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(item); UBGraphicsW3CWidgetItem *widgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(item);
if(widgetItem){ if(widgetItem){
generateWidgetPropertyScript(widgetItem, UBApplication::boardController->pageFromSceneIndex(pageIndex)); generateWidgetPropertyScript(widgetItem, UBDocumentContainer::pageFromSceneIndex(pageIndex));
widgets << widgetItem; widgets << widgetItem;
} }
} }
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.json",pageIndex); QString filename = mPublishingPath + UBFileSystemUtils::digitFileFormat("/page%1.json",pageIndex);
QFile jsonFile(filename); QFile jsonFile(filename);
if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
@ -369,7 +367,7 @@ void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *
if (!startFileName.startsWith("http://")) if (!startFileName.startsWith("http://"))
{ {
QString startFilePath = mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + widgetItem->uuid().toString() + ".wgt/" + startFileName; QString startFilePath = mPublishingPath + "/" + UBPersistenceManager::widgetDirectory + "/" + widgetItem->uuid().toString() + ".wgt/" + startFileName;
QFile startFile(startFilePath); QFile startFile(startFilePath);
@ -434,7 +432,7 @@ void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *
lines << " widget.preferences.clear = function() {}"; lines << " widget.preferences.clear = function() {}";
lines << " var uniboard = {};"; lines << " var uniboard = {};";
lines << " uniboard.pageCount = " + QString("%1").arg(mPublishingDocument->pageCount()) + ";"; lines << " uniboard.pageCount = " + QString("%1").arg(mPublishingSize) + ";";
lines << " uniboard.currentPageNumber = " + QString("%1").arg(pageNumber) + ";"; lines << " uniboard.currentPageNumber = " + QString("%1").arg(pageNumber) + ";";
lines << " uniboard.uuid = '" + UBStringUtils::toCanonicalUuid(widgetItem->uuid()) + "'"; lines << " uniboard.uuid = '" + UBStringUtils::toCanonicalUuid(widgetItem->uuid()) + "'";
lines << " uniboard.lang = navigator.language;"; lines << " uniboard.lang = navigator.language;";

@ -106,7 +106,12 @@ private slots:
private: private:
UBDocumentProxy *mSourceDocument; UBDocumentProxy *mSourceDocument;
UBDocumentProxy *mPublishingDocument;
//UBDocumentProxy *mPublishingDocument;
QString mPublishingPath;
int mPublishingSize;
void init(); void init();
void sendUbw(QString username, QString password); void sendUbw(QString username, QString password);
QString getBase64Of(QString stringToEncode); QString getBase64Of(QString stringToEncode);

@ -346,7 +346,7 @@ QString UBWidgetUniboardAPI::pageThumbnail(const int pageNumber)
if (UBApplication::boardController->activeScene() != mScene) if (UBApplication::boardController->activeScene() != mScene)
return ""; return "";
UBDocumentProxy *doc = UBApplication::boardController->activeDocument(); UBDocumentProxy *doc = UBApplication::boardController->selectedDocument();
if (!doc) if (!doc)
return ""; return "";

@ -1,7 +1,7 @@
/* /*
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
@ -72,9 +72,8 @@
//#include <typeinfo> //#include <typeinfo>
UBBoardController::UBBoardController(UBMainWindow* mainWindow) UBBoardController::UBBoardController(UBMainWindow* mainWindow)
: QObject(mainWindow->centralWidget()) : UBDocumentContainer(mainWindow->centralWidget())
, mMainWindow(mainWindow) , mMainWindow(mainWindow)
, mActiveDocument(0)
, mActiveScene(0) , mActiveScene(0)
, mActiveSceneIndex(-1) , mActiveSceneIndex(-1)
, mPaletteManager(0) , mPaletteManager(0)
@ -107,17 +106,17 @@ void UBBoardController::init()
setupViews(); setupViews();
setupToolbar(); setupToolbar();
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentWillBeDeleted(UBDocumentProxy*)) //connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentWillBeDeleted(UBDocumentProxy*))
, this, SLOT(documentWillBeDeleted(UBDocumentProxy*))); // , this, SLOT(documentWillBeDeleted(UBDocumentProxy*)));
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneCreated(UBDocumentProxy*, int)) //connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneCreated(UBDocumentProxy*, int))
, this, SLOT(documentSceneChanged(UBDocumentProxy*, int))); // , this, SLOT(documentSceneChanged(UBDocumentProxy*, int)));
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneDeleted(UBDocumentProxy*, int)) //connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneDeleted(UBDocumentProxy*, int))
, this, SLOT(documentSceneChanged(UBDocumentProxy*, int))); // , this, SLOT(documentSceneChanged(UBDocumentProxy*, int)));
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneMoved(UBDocumentProxy*, int)) //connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneMoved(UBDocumentProxy*, int))
, this, SLOT(documentSceneChanged(UBDocumentProxy*, int))); // , this, SLOT(documentSceneChanged(UBDocumentProxy*, int)));
connect(UBApplication::undoStack, SIGNAL(canUndoChanged(bool)) connect(UBApplication::undoStack, SIGNAL(canUndoChanged(bool))
, this, SLOT(undoRedoStateChange(bool))); , this, SLOT(undoRedoStateChange(bool)));
@ -160,20 +159,6 @@ int UBBoardController::currentPage()
return mActiveSceneIndex + 1; return mActiveSceneIndex + 1;
} }
int UBBoardController::pageFromSceneIndex(int sceneIndex)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return sceneIndex;
return sceneIndex+1;
}
int UBBoardController::sceneIndexFromPage(int page)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return page-1;
return page;
}
void UBBoardController::setupViews() void UBBoardController::setupViews()
{ {
mControlContainer = new QWidget(mMainWindow->centralWidget()); mControlContainer = new QWidget(mMainWindow->centralWidget());
@ -400,11 +385,6 @@ void UBBoardController::stopScript()
freezeW3CWidgets(true); freezeW3CWidgets(true);
} }
bool UBBoardController::cacheIsVisible()
{
return mCacheWidgetIsEnabled;
}
void UBBoardController::initToolbarTexts() void UBBoardController::initToolbarTexts()
{ {
QList<QAction*> allToolbarActions; QList<QAction*> allToolbarActions;
@ -480,12 +460,12 @@ void UBBoardController::addScene()
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene(); persistCurrentScene();
UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mActiveDocument, mActiveSceneIndex + 1); UBDocumentContainer::addPage(mActiveSceneIndex + 1);
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
setActiveDocumentScene(mActiveDocument, mActiveSceneIndex + 1); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
setActiveDocumentScene(mActiveSceneIndex + 1);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
emit newPageAdded();
} }
@ -495,12 +475,12 @@ void UBBoardController::addScene(UBGraphicsScene* scene, bool replaceActiveIfEmp
{ {
UBGraphicsScene* clone = scene->sceneDeepCopy(); UBGraphicsScene* clone = scene->sceneDeepCopy();
if (scene->document() && (scene->document() != mActiveDocument)) if (scene->document() && (scene->document() != selectedDocument()))
{ {
foreach(QUrl relativeFile, scene->relativeDependencies()) foreach(QUrl relativeFile, scene->relativeDependencies())
{ {
QString source = scene->document()->persistencePath() + "/" + relativeFile.toString(); QString source = scene->document()->persistencePath() + "/" + relativeFile.toString();
QString target = mActiveDocument->persistencePath() + "/" + relativeFile.toString(); QString target = selectedDocument()->persistencePath() + "/" + relativeFile.toString();
QFileInfo fi(target); QFileInfo fi(target);
QDir d = fi.dir(); QDir d = fi.dir();
@ -512,17 +492,16 @@ void UBBoardController::addScene(UBGraphicsScene* scene, bool replaceActiveIfEmp
if (replaceActiveIfEmpty && mActiveScene->isEmpty()) if (replaceActiveIfEmpty && mActiveScene->isEmpty())
{ {
UBPersistenceManager::persistenceManager()->persistDocumentScene(mActiveDocument, clone, mActiveSceneIndex); setActiveDocumentScene(mActiveSceneIndex);
setActiveDocumentScene(mActiveDocument, mActiveSceneIndex);
} }
else else
{ {
persistCurrentScene(); persistCurrentScene();
UBPersistenceManager::persistenceManager()->insertDocumentSceneAt(mActiveDocument, clone, mActiveSceneIndex + 1); UBPersistenceManager::persistenceManager()->insertDocumentSceneAt(selectedDocument(), clone, mActiveSceneIndex + 1);
setActiveDocumentScene(mActiveDocument, mActiveSceneIndex + 1); setActiveDocumentScene(mActiveSceneIndex + 1);
} }
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
} }
} }
@ -537,22 +516,48 @@ void UBBoardController::addScene(UBDocumentProxy* proxy, int sceneIndex, bool re
} }
} }
void UBBoardController::duplicateScene(int nIndex)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene();
QList<int> scIndexes;
scIndexes << nIndex;
duplicatePages(scIndexes);
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
setActiveDocumentScene(nIndex + 1);
QApplication::restoreOverrideCursor();
emit pageChanged();
}
void UBBoardController::duplicateScene() void UBBoardController::duplicateScene()
{ {
if (UBApplication::applicationController->displayMode() != UBApplicationController::Board) if (UBApplication::applicationController->displayMode() != UBApplicationController::Board)
return; return;
duplicateScene(mActiveSceneIndex);
}
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); void UBBoardController::deleteScene(int nIndex)
persistCurrentScene(); {
if (selectedDocument()->pageCount()>2)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene();
UBPersistenceManager::persistenceManager()->duplicateDocumentScene(mActiveDocument, mActiveSceneIndex); QList<int> scIndexes;
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); scIndexes << nIndex;
deletePages(scIndexes);
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
setActiveDocumentScene(mActiveDocument, mActiveSceneIndex + 1);
QApplication::restoreOverrideCursor();
emit pageChanged(); if (nIndex >= pageCount())
nIndex = pageCount()-1;
setActiveDocumentScene(nIndex);
QApplication::restoreOverrideCursor();
}
} }
@ -598,7 +603,7 @@ void UBBoardController::clearSceneBackground()
void UBBoardController::showDocumentsDialog() void UBBoardController::showDocumentsDialog()
{ {
if (mActiveDocument) if (selectedDocument())
persistCurrentScene(); persistCurrentScene();
UBApplication::mainWindow->actionLibrary->setChecked(false); UBApplication::mainWindow->actionLibrary->setChecked(false);
@ -725,7 +730,7 @@ void UBBoardController::previousScene()
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene(); persistCurrentScene();
setActiveDocumentScene(mActiveDocument, mActiveSceneIndex - 1); setActiveDocumentScene(mActiveSceneIndex - 1);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@ -736,11 +741,11 @@ void UBBoardController::previousScene()
void UBBoardController::nextScene() void UBBoardController::nextScene()
{ {
if (mActiveSceneIndex < mActiveDocument->pageCount() - 1) if (mActiveSceneIndex < selectedDocument()->pageCount() - 1)
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene(); persistCurrentScene();
setActiveDocumentScene(mActiveDocument, mActiveSceneIndex + 1); setActiveDocumentScene(mActiveSceneIndex + 1);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@ -755,7 +760,7 @@ void UBBoardController::firstScene()
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene(); persistCurrentScene();
setActiveDocumentScene(mActiveDocument, 0); setActiveDocumentScene(0);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@ -766,11 +771,11 @@ void UBBoardController::firstScene()
void UBBoardController::lastScene() void UBBoardController::lastScene()
{ {
if (mActiveSceneIndex < mActiveDocument->pageCount() - 1) if (mActiveSceneIndex < selectedDocument()->pageCount() - 1)
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene(); persistCurrentScene();
setActiveDocumentScene(mActiveDocument, mActiveDocument->pageCount() - 1); setActiveDocumentScene(selectedDocument()->pageCount() - 1);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@ -855,18 +860,16 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground) void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{ {
QGraphicsItem *oldBackgroundObject = NULL;
if (isBackground)
oldBackgroundObject = mActiveScene->backgroundObject();
QString mimeType = pContentTypeHeader; QString mimeType = pContentTypeHeader;
// In some cases "image/jpeg;charset=" is returned by the drag-n-drop. That is // In some cases "image/jpeg;charset=" is retourned by the drag-n-drop. That is
// why we will check if an ; exists and take the first part (the standard allows this kind of mimetype) // why we will check if an ; exists and take the first part (the standard allows this kind of mimetype)
int position=mimeType.indexOf(";"); int position=mimeType.indexOf(";");
if(position != -1) if(position != -1)
mimeType=mimeType.left(position); mimeType=mimeType.left(position);
UBMimeType::Enum itemMimeType = UBFileSystemUtils::mimeTypeFromString(mimeType);
if (!pSuccess) if (!pSuccess)
{ {
UBApplication::showMessage(tr("Downloading content %1 failed").arg(sourceUrl.toString())); UBApplication::showMessage(tr("Downloading content %1 failed").arg(sourceUrl.toString()));
@ -876,11 +879,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
if (!sourceUrl.toString().startsWith("file://") && !sourceUrl.toString().startsWith("uniboardTool://")) if (!sourceUrl.toString().startsWith("file://") && !sourceUrl.toString().startsWith("uniboardTool://"))
UBApplication::showMessage(tr("Download finished")); UBApplication::showMessage(tr("Download finished"));
if (mimeType == "image/jpeg" if (UBMimeType::RasterImage == itemMimeType)
|| mimeType == "image/png"
|| mimeType == "image/gif"
|| mimeType == "image/tiff"
|| mimeType == "image/bmp")
{ {
qDebug() << "accepting mime type" << mimeType << "as raster image"; qDebug() << "accepting mime type" << mimeType << "as raster image";
@ -903,7 +902,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
} }
else if (mimeType == "image/svg+xml") else if (UBMimeType::VectorImage == itemMimeType)
{ {
qDebug() << "accepting mime type" << mimeType << "as vecto image"; qDebug() << "accepting mime type" << mimeType << "as vecto image";
@ -921,7 +920,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
} }
else if (mimeType == "application/vnd.apple-widget") //mime type invented by us :-( else if (UBMimeType::AppleWidget == itemMimeType) //mime type invented by us :-(
{ {
qDebug() << "accepting mime type" << mimeType << "as Apple widget"; qDebug() << "accepting mime type" << mimeType << "as Apple widget";
@ -945,7 +944,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
} }
else if (mimeType == "application/widget") else if (UBMimeType::W3CWidget == itemMimeType)
{ {
qDebug() << "accepting mime type" << mimeType << "as W3C widget"; qDebug() << "accepting mime type" << mimeType << "as W3C widget";
QUrl widgetUrl = sourceUrl; QUrl widgetUrl = sourceUrl;
@ -966,7 +965,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
} }
else if (mimeType.startsWith("video/")) else if (UBMimeType::Video == itemMimeType)
{ {
qDebug() << "accepting mime type" << mimeType << "as video"; qDebug() << "accepting mime type" << mimeType << "as video";
@ -977,7 +976,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QUrl url = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager() QUrl url = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()
->addVideoFileToDocument(mActiveDocument, sourceUrl, pData, uuid)); ->addVideoFileToDocument(selectedDocument(), sourceUrl, pData, uuid));
mediaVideoItem = mActiveScene->addMedia(url, false, pPos); mediaVideoItem = mActiveScene->addMedia(url, false, pPos);
@ -995,7 +994,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
else if (mimeType.startsWith("audio/")) else if (UBMimeType::Audio == itemMimeType)
{ {
qDebug() << "accepting mime type" << mimeType << "as audio"; qDebug() << "accepting mime type" << mimeType << "as audio";
@ -1006,9 +1005,10 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QUrl url = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager() QUrl url = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()
->addVideoFileToDocument(mActiveDocument, sourceUrl, pData, uuid)); ->addVideoFileToDocument(selectedDocument(), sourceUrl, pData, uuid));
audioMediaItem = mActiveScene->addMedia(url, false, pPos); audioMediaItem = mActiveScene->addMedia(url, false, pPos);
audioMediaItem->setSourceUrl(sourceUrl); audioMediaItem->setSourceUrl(sourceUrl);
audioMediaItem->setUuid(uuid); audioMediaItem->setUuid(uuid);
} }
@ -1024,7 +1024,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
else if (mimeType.startsWith("application/x-shockwave-flash")) else if (UBMimeType::Flash == itemMimeType)
{ {
qDebug() << "accepting mime type" << mimeType << "as flash"; qDebug() << "accepting mime type" << mimeType << "as flash";
@ -1071,7 +1071,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
delete eduMediaFile; delete eduMediaFile;
} }
else if (mimeType.startsWith("application/pdf")) else if (UBMimeType::PDF == itemMimeType)
{ {
qDebug() << "accepting mime type" << mimeType << "as PDF"; qDebug() << "accepting mime type" << mimeType << "as PDF";
qDebug() << "pdf data length: " << pData.size(); qDebug() << "pdf data length: " << pData.size();
@ -1079,23 +1079,23 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
int result = 0; int result = 0;
if(!sourceUrl.isEmpty()){ if(!sourceUrl.isEmpty()){
QFile sourceFile(sourceUrl.toLocalFile()); QFile sourceFile(sourceUrl.toLocalFile());
result = UBDocumentManager::documentManager()->addFileToDocument(mActiveDocument, sourceFile); result = UBDocumentManager::documentManager()->addFileToDocument(selectedDocument(), sourceFile);
} }
else if(pData.size()){ else if(pData.size()){
QTemporaryFile pdfFile("XXXXXX.pdf"); QTemporaryFile pdfFile("XXXXXX.pdf");
if (pdfFile.open()) if (pdfFile.open())
{ {
pdfFile.write(pData); pdfFile.write(pData);
result = UBDocumentManager::documentManager()->addFileToDocument(mActiveDocument, pdfFile); result = UBDocumentManager::documentManager()->addFileToDocument(selectedDocument(), pdfFile);
pdfFile.close(); pdfFile.close();
} }
} }
if (result){ if (result){
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
} }
} }
else if (mimeType.startsWith("application/vnd.mnemis-uniboard-tool")) else if (UBMimeType::UniboardTool == itemMimeType)
{ {
qDebug() << "accepting mime type" << mimeType << "as Uniboard Tool"; qDebug() << "accepting mime type" << mimeType << "as Uniboard Tool";
@ -1197,23 +1197,18 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBApplication::showMessage(tr("Unknown content type %1").arg(pContentTypeHeader)); UBApplication::showMessage(tr("Unknown content type %1").arg(pContentTypeHeader));
qWarning() << "ignoring mime type" << pContentTypeHeader ; qWarning() << "ignoring mime type" << pContentTypeHeader ;
} }
if (isBackground && oldBackgroundObject != mActiveScene->backgroundObject())
{
if (mActiveScene->isURStackIsEnabled()) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(mActiveScene, oldBackgroundObject, mActiveScene->backgroundObject());
UBApplication::undoStack->push(uc);
}
}
} }
void UBBoardController::setActiveDocumentScene(int pSceneIndex)
{
setActiveDocumentScene(selectedDocument(), pSceneIndex);
}
void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, const int pSceneIndex) void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, const int pSceneIndex, bool forceReload)
{ {
saveViewState(); saveViewState();
bool documentChange = mActiveDocument != pDocumentProxy; bool documentChange = selectedDocument() != pDocumentProxy;
int index = pSceneIndex; int index = pSceneIndex;
int sceneCount = pDocumentProxy->pageCount(); int sceneCount = pDocumentProxy->pageCount();
@ -1231,11 +1226,14 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
if(sceneChange) if(sceneChange)
emit activeSceneWillChange(); emit activeSceneWillChange();
persistCurrentScene();
ClearUndoStack(); ClearUndoStack();
mActiveScene = targetScene; mActiveScene = targetScene;
mActiveDocument = pDocumentProxy;
mActiveSceneIndex = index; mActiveSceneIndex = index;
setDocument(pDocumentProxy, forceReload);
updateSystemScaleFactor(); updateSystemScaleFactor();
@ -1260,9 +1258,6 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
if(documentChange) if(documentChange)
{ {
emit activeDocumentChanged();
// Notify the navigator palette that the document has changed
emit setDocOnPageNavigator(pDocumentProxy);
UBGraphicsTextItem::lastUsedTextColor = QColor(); UBGraphicsTextItem::lastUsedTextColor = QColor();
} }
@ -1274,6 +1269,22 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
} }
} }
void UBBoardController::moveSceneToIndex(int source, int target)
{
if (selectedDocument())
{
persistCurrentScene();
UBDocumentContainer::movePageToIndex(source, target);
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(selectedDocument());
setActiveDocumentScene(target);
}
}
void UBBoardController::ClearUndoStack() void UBBoardController::ClearUndoStack()
{ {
QSet<QGraphicsItem*> uniqueItems; QSet<QGraphicsItem*> uniqueItems;
@ -1331,7 +1342,7 @@ void UBBoardController::adjustDisplayViews()
if (UBApplication::applicationController) if (UBApplication::applicationController)
{ {
UBApplication::applicationController->adjustDisplayView(); UBApplication::applicationController->adjustDisplayView();
UBApplication::applicationController->adjustPreviousViews(mActiveSceneIndex, mActiveDocument); UBApplication::applicationController->adjustPreviousViews(mActiveSceneIndex, selectedDocument());
} }
} }
@ -1381,7 +1392,7 @@ void UBBoardController::boardViewResized(QResizeEvent* event)
void UBBoardController::documentWillBeDeleted(UBDocumentProxy* pProxy) void UBBoardController::documentWillBeDeleted(UBDocumentProxy* pProxy)
{ {
if (mActiveDocument == pProxy) if (selectedDocument() == pProxy)
{ {
if (!mIsClosing) if (!mIsClosing)
setActiveDocumentScene(UBPersistenceManager::persistenceManager()->createDocument()); setActiveDocumentScene(UBPersistenceManager::persistenceManager()->createDocument());
@ -1411,6 +1422,7 @@ void UBBoardController::setDisabled(bool disable)
void UBBoardController::selectionChanged() void UBBoardController::selectionChanged()
{ {
updateActionStates(); updateActionStates();
emit pageSelectionChanged(activeSceneIndex());
} }
@ -1427,18 +1439,12 @@ void UBBoardController::undoRedoStateChange(bool canUndo)
void UBBoardController::updateActionStates() void UBBoardController::updateActionStates()
{ {
mMainWindow->actionBack->setEnabled(mActiveDocument && (mActiveSceneIndex > 0)); mMainWindow->actionBack->setEnabled(selectedDocument() && (mActiveSceneIndex > 0));
mMainWindow->actionForward->setEnabled(mActiveDocument && (mActiveSceneIndex < mActiveDocument->pageCount() - 1)); mMainWindow->actionForward->setEnabled(selectedDocument() && (mActiveSceneIndex < selectedDocument()->pageCount() - 1));
mMainWindow->actionErase->setEnabled(mActiveScene && !mActiveScene->isEmpty()); mMainWindow->actionErase->setEnabled(mActiveScene && !mActiveScene->isEmpty());
} }
UBDocumentProxy* UBBoardController::activeDocument() const
{
return mActiveDocument;
}
UBGraphicsScene* UBBoardController::activeScene() const UBGraphicsScene* UBBoardController::activeScene() const
{ {
return mActiveScene; return mActiveScene;
@ -1455,9 +1461,9 @@ void UBBoardController::documentSceneChanged(UBDocumentProxy* pDocumentProxy, in
{ {
Q_UNUSED(pIndex); Q_UNUSED(pIndex);
if(mActiveDocument == pDocumentProxy) if(selectedDocument() == pDocumentProxy)
{ {
setActiveDocumentScene(mActiveDocument, mActiveSceneIndex); setActiveDocumentScene(mActiveSceneIndex);
} }
} }
@ -1472,9 +1478,9 @@ void UBBoardController::lastWindowClosed()
{ {
if (!mCleanupDone) if (!mCleanupDone)
{ {
if (mActiveDocument->pageCount() == 1 && (!mActiveScene || mActiveScene->isEmpty())) if (selectedDocument()->pageCount() == 1 && (!mActiveScene || mActiveScene->isEmpty()))
{ {
UBPersistenceManager::persistenceManager()->deleteDocument(mActiveDocument); UBPersistenceManager::persistenceManager()->deleteDocument(selectedDocument());
} }
else else
{ {
@ -1597,13 +1603,14 @@ void UBBoardController::show()
void UBBoardController::persistCurrentScene() void UBBoardController::persistCurrentScene()
{ {
if(UBPersistenceManager::persistenceManager() if(UBPersistenceManager::persistenceManager()
&& mActiveDocument && mActiveScene && selectedDocument() && mActiveScene
&& (mActiveSceneIndex >= 0)) && (mActiveSceneIndex >= 0)
&& mActiveScene->isModified())
{ {
emit activeSceneWillBePersisted(); emit activeSceneWillBePersisted();
UBPersistenceManager::persistenceManager()->persistDocumentScene(mActiveDocument, mActiveScene, mActiveSceneIndex); UBPersistenceManager::persistenceManager()->persistDocumentScene(selectedDocument(), mActiveScene, mActiveSceneIndex);
UBMetadataDcSubsetAdaptor::persist(mActiveDocument); updatePage(mActiveSceneIndex);
} }
} }
@ -1688,7 +1695,7 @@ void UBBoardController::setPageSize(QSize newSize)
updateSystemScaleFactor(); updateSystemScaleFactor();
updatePageSizeState(); updatePageSizeState();
adjustDisplayViews(); adjustDisplayViews();
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBSettings::settings()->pageSize->set(newSize); UBSettings::settings()->pageSize->set(newSize);
} }
@ -1704,7 +1711,6 @@ void UBBoardController::notifyCache(bool visible)
{ {
emit cacheDisabled(); emit cacheDisabled();
} }
mCacheWidgetIsEnabled = visible; mCacheWidgetIsEnabled = visible;
} }
@ -1811,7 +1817,7 @@ void UBBoardController::grabScene(const QRectF& pSceneRect)
mActiveScene->setRenderingQuality(UBItem::RenderingQualityNormal); mActiveScene->setRenderingQuality(UBItem::RenderingQualityNormal);
mPaletteManager->addItem(QPixmap::fromImage(image)); mPaletteManager->addItem(QPixmap::fromImage(image));
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
} }
} }
@ -1839,11 +1845,10 @@ UBGraphicsMediaItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool st
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QUrl concreteUrl = pSourceUrl; QUrl concreteUrl = pSourceUrl;
concreteUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager() concreteUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()->addVideoFileToDocument(selectedDocument(), pSourceUrl.toLocalFile(), uuid));
->addVideoFileToDocument(mActiveDocument, pSourceUrl.toLocalFile(), uuid));
UBGraphicsMediaItem* vi = mActiveScene->addMedia(concreteUrl, startPlay, pos); UBGraphicsMediaItem* vi = mActiveScene->addMedia(concreteUrl, startPlay, pos);
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
if (vi) { if (vi) {
vi->setUuid(uuid); vi->setUuid(uuid);
@ -1859,11 +1864,10 @@ UBGraphicsMediaItem* UBBoardController::addAudio(const QUrl& pSourceUrl, bool st
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QUrl concreteUrl = pSourceUrl; QUrl concreteUrl = pSourceUrl;
concreteUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager() concreteUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()->addAudioFileToDocument(selectedDocument(), pSourceUrl.toLocalFile(), uuid));
->addAudioFileToDocument(mActiveDocument, pSourceUrl.toLocalFile(), uuid));
UBGraphicsMediaItem* ai = mActiveScene->addMedia(concreteUrl, startPlay, pos); UBGraphicsMediaItem* ai = mActiveScene->addMedia(concreteUrl, startPlay, pos);
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
if (ai){ if (ai){
ai->setUuid(uuid); ai->setUuid(uuid);
@ -1881,7 +1885,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QUrl newUrl = pUrl; QUrl newUrl = pUrl;
newUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()->addGraphicsWidgteToDocument(mActiveDocument, pUrl.toLocalFile(), uuid)); newUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()->addGraphicsWidgteToDocument(selectedDocument(), pUrl.toLocalFile(), uuid));
w3cWidgetItem = mActiveScene->addW3CWidget(newUrl, pos); w3cWidgetItem = mActiveScene->addW3CWidget(newUrl, pos);
@ -1891,14 +1895,15 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
w3cWidgetItem->setSourceUrl(pUrl); w3cWidgetItem->setSourceUrl(pUrl);
QString struuid = UBStringUtils::toCanonicalUuid(uuid); QString struuid = UBStringUtils::toCanonicalUuid(uuid);
QString snapshotPath = mActiveDocument->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + struuid + ".png"; QString snapshotPath = selectedDocument()->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + struuid + ".png";
w3cWidgetItem->setSnapshotPath(QUrl::fromLocalFile(snapshotPath)); w3cWidgetItem->setSnapshotPath(QUrl::fromLocalFile(snapshotPath));
UBGraphicsWidgetItem *tmpItem = dynamic_cast<UBGraphicsWidgetItem*>(w3cWidgetItem); UBGraphicsWidgetItem *tmpItem = dynamic_cast<UBGraphicsWidgetItem*>(w3cWidgetItem);
if (tmpItem) if (tmpItem)
tmpItem->widgetWebView()->takeSnapshot().save(snapshotPath, "PNG"); tmpItem->widgetWebView()->takeSnapshot().save(snapshotPath, "PNG");
} }
return w3cWidgetItem;
return 0;
} }
void UBBoardController::cut() void UBBoardController::cut()
@ -1937,7 +1942,7 @@ void UBBoardController::cut()
mimeGi->setData(UBApplication::mimeTypeUniboardPageItem, QByteArray()); mimeGi->setData(UBApplication::mimeTypeUniboardPageItem, QByteArray());
clipboard->setMimeData(mimeGi); clipboard->setMimeData(mimeGi);
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
} }
//---------------------------------------------------------// //---------------------------------------------------------//
@ -1975,7 +1980,7 @@ void UBBoardController::paste()
QPointF pos(0, 0); QPointF pos(0, 0);
processMimeData(clipboard->mimeData(), pos); processMimeData(clipboard->mimeData(), pos);
mActiveDocument->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
} }
@ -1988,15 +1993,15 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if (mimeData) if (mimeData)
{ {
int previousActiveSceneIndex = activeSceneIndex(); int previousActiveSceneIndex = activeSceneIndex();
int previousPageCount = activeDocument()->pageCount(); int previousPageCount = selectedDocument()->pageCount();
foreach (UBMimeDataItem sourceItem, mimeData->items()) foreach (UBMimeDataItem sourceItem, mimeData->items())
addScene(sourceItem.documentProxy(), sourceItem.sceneIndex(), true); addScene(sourceItem.documentProxy(), sourceItem.sceneIndex(), true);
if (activeDocument()->pageCount() < previousPageCount + mimeData->items().count()) if (selectedDocument()->pageCount() < previousPageCount + mimeData->items().count())
setActiveDocumentScene(activeDocument(), previousActiveSceneIndex); setActiveDocumentScene(previousActiveSceneIndex);
else else
setActiveDocumentScene(activeDocument(), previousActiveSceneIndex + 1); setActiveDocumentScene(previousActiveSceneIndex + 1);
return; return;
} }
@ -2031,12 +2036,8 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if("" != url) if("" != url)
{ {
downloadURL(url, pPos); downloadURL(url, pPos);
return;
} }
else
{
mActiveScene->addTextHtml(qsHtml, pPos);
}
return;
} }
if (pMimeData->hasUrls()) if (pMimeData->hasUrls())
@ -2072,11 +2073,11 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if("" != pMimeData->text()){ if("" != pMimeData->text()){
// Sometimes, it is possible to have an URL as text. we check here if it is the case // Sometimes, it is possible to have an URL as text. we check here if it is the case
QString qsTmp = pMimeData->text().remove(QRegExp("[\\0]")); QString qsTmp = pMimeData->text().remove(QRegExp("[\\0]"));
if(qsTmp.startsWith("http://") || qsTmp.startsWith("https://")){ if(qsTmp.startsWith("http")){
downloadURL(QUrl(qsTmp), pPos); downloadURL(QUrl(qsTmp), pPos);
} }
else{ else{
mActiveScene->addTextHtml(pMimeData->text(), pPos); mActiveScene->addTextHtml(pMimeData->html(), pPos);
} }
} }
else{ else{
@ -2196,11 +2197,11 @@ void UBBoardController::addItem()
void UBBoardController::importPage() void UBBoardController::importPage()
{ {
int pageCount = mActiveDocument->pageCount(); int pageCount = selectedDocument()->pageCount();
if (UBApplication::documentController->addFileToDocument(mActiveDocument)) if (UBApplication::documentController->addFileToDocument(selectedDocument()))
{ {
setActiveDocumentScene(mActiveDocument, pageCount); setActiveDocumentScene(pageCount);
} }
} }

@ -19,6 +19,7 @@
#include <QtGui> #include <QtGui>
#include <QObject> #include <QObject>
#include "document/UBDocumentContainer.h"
class UBMainWindow; class UBMainWindow;
class UBApplication; class UBApplication;
@ -40,7 +41,7 @@ class UBGraphicsWidgetItem;
class UBBoardPaletteManager; class UBBoardPaletteManager;
class UBBoardController : public QObject class UBBoardController : public UBDocumentContainer
{ {
Q_OBJECT Q_OBJECT
@ -50,7 +51,7 @@ class UBBoardController : public QObject
void init(); void init();
void setupLayout(); void setupLayout();
UBDocumentProxy* activeDocument() const;
UBGraphicsScene* activeScene() const; UBGraphicsScene* activeScene() const;
int activeSceneIndex() const; int activeSceneIndex() const;
QSize displayViewport(); QSize displayViewport();
@ -60,14 +61,6 @@ class UBBoardController : public QObject
int currentPage(); int currentPage();
int pageFromSceneIndex(int sceneIndex);
int sceneIndexFromPage(int page);
UBDocumentProxy* activeDocument()
{
return mActiveDocument;
}
QWidget* controlContainer() QWidget* controlContainer()
{ {
return mControlContainer; return mControlContainer;
@ -158,10 +151,17 @@ class UBBoardController : public QObject
void displayMetaData(QMap<QString, QString> metadatas); void displayMetaData(QMap<QString, QString> metadatas);
void ClearUndoStack(); 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: public slots:
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0);
void showDocumentsDialog(); void showDocumentsDialog();
void showKeyboard(bool show); void showKeyboard(bool show);
void togglePodcast(bool checked); void togglePodcast(bool checked);
@ -222,14 +222,12 @@ class UBBoardController : public QObject
void freezeW3CWidget(QGraphicsItem* item, bool freeze); void freezeW3CWidget(QGraphicsItem* item, bool freeze);
void startScript(); void startScript();
void stopScript(); void stopScript();
bool cacheIsVisible();
signals: signals:
void newPageAdded(); void newPageAdded();
void activeSceneWillBePersisted(); void activeSceneWillBePersisted();
void activeSceneWillChange(); void activeSceneWillChange();
void activeSceneChanged(); void activeSceneChanged();
void activeDocumentChanged();
void zoomChanged(qreal pZoomFactor); void zoomChanged(qreal pZoomFactor);
void systemScaleFactorChanged(qreal pSystemScaleFactor); void systemScaleFactorChanged(qreal pSystemScaleFactor);
void penColorChanged(); void penColorChanged();
@ -238,10 +236,9 @@ class UBBoardController : public QObject
void cacheEnabled(); void cacheEnabled();
void cacheDisabled(); void cacheDisabled();
void pageChanged(); void pageChanged();
void setDocOnPageNavigator(UBDocumentProxy* doc);
void documentReorganized(int index); void documentReorganized(int index);
void displayMetadata(QMap<QString, QString> metadata); void displayMetadata(QMap<QString, QString> metadata);
void scrollToSelectedPage(); void pageSelectionChanged(int index);
protected: protected:
void setupViews(); void setupViews();
@ -263,7 +260,6 @@ class UBBoardController : public QObject
void adjustDisplayViews(); void adjustDisplayViews();
UBMainWindow *mMainWindow; UBMainWindow *mMainWindow;
UBDocumentProxy* mActiveDocument;
UBGraphicsScene* mActiveScene; UBGraphicsScene* mActiveScene;
int mActiveSceneIndex; int mActiveSceneIndex;
UBBoardPaletteManager *mPaletteManager; UBBoardPaletteManager *mPaletteManager;

@ -134,8 +134,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
//------------------------------------------------// //------------------------------------------------//
// Create the widgets for the dock palettes // Create the widgets for the dock palettes
mpPageNavigWidget = new UBPageNavigationWidget();
#ifdef USE_WEB_WIDGET #ifdef USE_WEB_WIDGET
mpLibWidget = new UBLibWidget(); mpLibWidget = new UBLibWidget();
#endif #endif
@ -352,7 +350,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased()
QList<QAction*>pageActions; QList<QAction*>pageActions;
pageActions << UBApplication::mainWindow->actionNewPage; pageActions << UBApplication::mainWindow->actionNewPage;
UBBoardController* boardController = UBApplication::boardController; 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->actionDuplicatePage;
pageActions << UBApplication::mainWindow->actionImportPage; pageActions << UBApplication::mainWindow->actionImportPage;
@ -568,7 +566,7 @@ void UBBoardPaletteManager::activeSceneChanged()
if (mpPageNavigWidget) if (mpPageNavigWidget)
{ {
mpPageNavigWidget->setPageNumber(UBApplication::boardController->pageFromSceneIndex(pageIndex), activeScene->document()->pageCount()); mpPageNavigWidget->setPageNumber(UBDocumentContainer::pageFromSceneIndex(pageIndex), activeScene->document()->pageCount());
} }
if (mZoomPalette) if (mZoomPalette)

@ -1040,6 +1040,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
mMouseButtonIsPressed = false; mMouseButtonIsPressed = false;
mPendingStylusReleaseEvent = false; mPendingStylusReleaseEvent = false;
mTabletStylusIsPressed = false; mTabletStylusIsPressed = false;
movingItem = NULL;
mLongPressTimer.stop(); mLongPressTimer.stop();
} }

@ -562,7 +562,7 @@ void UBLibraryController::removeBackground()
UBGraphicsScene* UBLibraryController::activeScene() UBGraphicsScene* UBLibraryController::activeScene()
{ {
if (mBoardController->activeDocument()) if (mBoardController->selectedDocument())
return mBoardController->activeScene(); return mBoardController->activeScene();
return 0; return 0;

@ -20,6 +20,23 @@
#define UB_MAX_ZOOM 15 #define UB_MAX_ZOOM 15
struct UBMimeType
{
enum Enum
{
RasterImage = 0,
VectorImage,
AppleWidget,
W3CWidget,
Video,
Audio,
Flash,
PDF,
UniboardTool,
UNKNOWN
};
};
struct UBStylusTool struct UBStylusTool
{ {
enum Enum enum Enum

@ -317,8 +317,6 @@ int UBApplication::exec(const QString& pFileToImport)
connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized())); connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized()));
#endif #endif
connect(documentController, SIGNAL(movedToIndex(int)), boardController, SIGNAL(documentReorganized(int)));
mPreferencesController = new UBPreferencesController(mainWindow); mPreferencesController = new UBPreferencesController(mainWindow);
connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show())); connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show()));

@ -63,7 +63,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, UBBo
, mControlView(pControlView) , mControlView(pControlView)
, mDisplayView(pDisplayView) , mDisplayView(pDisplayView)
, mMirror(0) , mMirror(0)
, mFtp(0)
, mMainMode(Board) , mMainMode(Board)
, mDisplayManager(0) , mDisplayManager(0)
, mAutomaticCheckForUpdates(false) , mAutomaticCheckForUpdates(false)
@ -120,7 +119,6 @@ UBApplicationController::~UBApplicationController()
delete mBlackScene; delete mBlackScene;
delete mMirror; delete mMirror;
if (mFtp) delete mFtp;
if (mHttp) delete mHttp; if (mHttp) delete mHttp;
} }
@ -340,8 +338,7 @@ void UBApplicationController::showBoard()
int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex(); int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex();
if (selectedSceneIndex != -1) if (selectedSceneIndex != -1)
{ {
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), selectedSceneIndex); UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->selectedDocument(), selectedSceneIndex, true);
UBApplication::boardController->emitScrollSignal();
} }
} }
@ -522,42 +519,27 @@ void UBApplicationController::showSankoreEditor()
emit mainModeChanged(mMainMode); 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() void UBApplicationController::checkUpdate()
{ {
//TODO change this when upgrade the qt version if(mHttp)
// networkAccessible : NetworkAccessibility not yet available
if(mHttp)
delete mHttp; delete mHttp;
QUrl url("http://www.google.com"); QUrl url("http://ftp.open-sankore.org/update.json");
mHttp = new QHttp(url.host()); 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()); mHttp->get(url.path());
} }
void UBApplicationController::ftpCommandFinished(int id, bool error) void UBApplicationController::updateRequestFinished(int id, bool error)
{ {
if (error){ if (error){
qWarning() << "ftp command id" << id << "return the error: " << mFtp->errorString(); qWarning() << "http command id" << id << "return the error: " << mHttp->errorString();
mFtp->close(); mHttp->close();
} }
else{ else{
QString responseString = QString(mFtp->readAll()); QString responseString = QString(mHttp->readAll());
qDebug() << responseString;
if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){ if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mFtp->close(); mHttp->close();
downloadJsonFinished(responseString); downloadJsonFinished(responseString);
} }
} }

@ -134,8 +134,7 @@ class UBApplicationController : public QObject
void checkUpdateAtLaunch(); void checkUpdateAtLaunch();
private slots: private slots:
void ftpCommandFinished(int id, bool error); void updateRequestFinished(int id, bool error);
void runCheckUpdate(int id, bool error);
protected: protected:
@ -152,7 +151,6 @@ class UBApplicationController : public QObject
UBScreenMirror* mMirror; UBScreenMirror* mMirror;
int mInitialHScroll, mInitialVScroll; int mInitialHScroll, mInitialVScroll;
QFtp* mFtp;
private: private:

@ -608,10 +608,10 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
if (pScene->isModified()) if (pScene->isModified())
{ {
UBThumbnailAdaptor::persistScene(pDocumentProxy->persistencePath(), pScene, pSceneIndex);
UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex); UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
pScene->setModified(false); pScene->setModified(false);
} }

@ -0,0 +1,127 @@
/*
* 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;
}

@ -0,0 +1,67 @@
/*
* 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_ */

@ -58,7 +58,7 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBDocumentController::UBDocumentController(UBMainWindow* mainWindow) UBDocumentController::UBDocumentController(UBMainWindow* mainWindow)
: QObject(mainWindow->centralWidget()) : UBDocumentContainer(mainWindow->centralWidget())
, mSelectionType(None) , mSelectionType(None)
, mParentWidget(mainWindow->centralWidget()) , mParentWidget(mainWindow->centralWidget())
, mBoardController(UBApplication::boardController) , mBoardController(UBApplication::boardController)
@ -72,15 +72,16 @@ UBDocumentController::UBDocumentController(UBMainWindow* mainWindow)
{ {
setupViews(); setupViews();
setupToolbar(); setupToolbar();
this->selectDocument(UBApplication::boardController->activeDocument()); this->selectDocument(UBApplication::boardController->selectedDocument());
connect(this, SIGNAL(exportDone()), mMainWindow, SLOT(onExportDone())); connect(this, SIGNAL(exportDone()), mMainWindow, SLOT(onExportDone()));
connect(mMainWindow->actionNewPage, SIGNAL(triggered()), this, SLOT(reloadThumbs())); //connect(mMainWindow->actionNewPage, SIGNAL(triggered()), this, SLOT(reloadThumbs()));
connect(this, SIGNAL(documentThumbnailsUpdated(UBDocumentContainer*)), this, SLOT(refreshDocumentThumbnailsView(UBDocumentContainer*)));
} }
void UBDocumentController::reloadThumbs() //void UBDocumentController::reloadThumbs()
{ //{
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy()); // UBThumbnailAdaptor::load(selectedDocumentProxy(), mDocumentThumbs);
} //}
UBDocumentController::~UBDocumentController() UBDocumentController::~UBDocumentController()
{ {
@ -154,6 +155,8 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
if (selected) if (selected)
{ {
setDocument(proxy);
selected->setSelected(true); selected->setSelected(true);
selected->parent()->setExpanded(true); selected->parent()->setExpanded(true);
@ -162,7 +165,7 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
if (setAsCurrentDocument) if (setAsCurrentDocument)
{ {
selected->setIcon(0, QIcon(":/images/currentDocument.png")); selected->setIcon(0, QIcon(":/images/currentDocument.png"));
if (proxy != mBoardController->activeDocument()) if (proxy != mBoardController->selectedDocument())
mBoardController->setActiveDocumentScene(proxy); mBoardController->setActiveDocumentScene(proxy);
} }
@ -170,9 +173,6 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
mDocumentUI->documentTreeWidget->scrollToItem(selected); mDocumentUI->documentTreeWidget->scrollToItem(selected);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView();
mSelectionType = Document; mSelectionType = Document;
} }
} }
@ -253,7 +253,7 @@ UBDocumentGroupTreeItem* UBDocumentController::selectedDocumentGroupTreeItem()
void UBDocumentController::itemSelectionChanged() void UBDocumentController::itemSelectionChanged()
{ {
refreshDocumentThumbnailsView(); reloadThumbnails();
if (selectedDocumentProxy()) if (selectedDocumentProxy())
mSelectionType = Document; mSelectionType = Document;
@ -266,62 +266,6 @@ void UBDocumentController::itemSelectionChanged()
} }
void UBDocumentController::refreshDocumentThumbnailsView()
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<QGraphicsItem*> items;
QList<QUrl> itemsPath;
UBDocumentProxy *proxy = selectedDocumentProxy();
QGraphicsPixmapItem *selection = 0;
QStringList labels;
if (proxy)
{
mCurrentDocument = proxy;
for (int i = 0; i < mDocumentThumbs.count(); i++)
{
QPixmap pix = mDocumentThumbs.at(i);
QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(pix, proxy, i); // deleted by the tree widget
if (proxy == mBoardController->activeDocument() && mBoardController->activeSceneIndex() == i)
{
selection = pixmapItem;
}
items << pixmapItem;
labels << tr("Page %1").arg(UBApplication::boardController->pageFromSceneIndex(i));
itemsPath.append(QUrl::fromLocalFile(proxy->persistencePath() + QString("/pages/%1").arg(UBApplication::boardController->pageFromSceneIndex(i))));
}
}
mDocumentUI->thumbnailWidget->setGraphicsItems(items, itemsPath, labels, UBApplication::mimeTypeUniboardPage);
UBDocumentProxyTreeItem* proxyTi = selectedDocumentProxyTreeItem();
if (proxyTi && (proxyTi->parent() == mTrashTi))
mDocumentUI->thumbnailWidget->setDragEnabled(false);
else
mDocumentUI->thumbnailWidget->setDragEnabled(true);
mDocumentUI->thumbnailWidget->ensureVisible(0, 0, 10, 10);
if (selection) {
disconnect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
UBSceneThumbnailPixmap *currentScene = dynamic_cast<UBSceneThumbnailPixmap*>(selection);
if (currentScene)
mDocumentUI->thumbnailWidget->hightlightItem(currentScene->sceneIndex());
connect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
}
emit refreshThumbnails();
QApplication::restoreOverrideCursor();
}
void UBDocumentController::setupViews() void UBDocumentController::setupViews()
{ {
@ -485,7 +429,7 @@ void UBDocumentController::setupPalettes()
void UBDocumentController::show() void UBDocumentController::show()
{ {
selectDocument(mBoardController->activeDocument()); selectDocument(mBoardController->selectedDocument());
selectionChanged(); selectionChanged();
@ -559,22 +503,11 @@ void UBDocumentController::duplicateSelectedItem()
} }
if (selectedSceneIndexes.count() > 0) if (selectedSceneIndexes.count() > 0)
{ {
UBSceneThumbnailPixmap *thumb = dynamic_cast<UBSceneThumbnailPixmap*>(selectedItems.at(0)); duplicatePages(selectedSceneIndexes);
UBDocumentProxy *proxy = thumb->proxy();
int offset = 0; selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
if (proxy) UBMetadataDcSubsetAdaptor::persist(selectedDocument());
{ mDocumentUI->thumbnailWidget->selectItemAt(selectedSceneIndexes.last() + selectedSceneIndexes.size());
foreach (int sceneIndex, selectedSceneIndexes)
{
UBPersistenceManager::persistenceManager()->duplicateDocumentScene(proxy, sceneIndex + offset);
mDocumentThumbs.insert(sceneIndex + offset, mDocumentThumbs.at(sceneIndex + offset));
offset++;
}
}
refreshDocumentThumbnailsView();
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy);
mDocumentUI->thumbnailWidget->selectItemAt(selectedSceneIndexes.last() + offset);
} }
} }
else else
@ -626,7 +559,7 @@ void UBDocumentController::deleteSelectedItem()
if (index >= 0) if (index >= 0)
{ {
if (proxyTi->proxy() == mBoardController->activeDocument()) if (proxyTi->proxy() == mBoardController->selectedDocument())
{ {
selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(index))->proxy()); selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(index))->proxy());
} }
@ -635,7 +568,7 @@ void UBDocumentController::deleteSelectedItem()
} }
else if (proxyTi->parent()->childCount() > 1) else if (proxyTi->parent()->childCount() > 1)
{ {
if (proxyTi->proxy() == mBoardController->activeDocument()) if (proxyTi->proxy() == mBoardController->selectedDocument())
{ {
selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(1))->proxy()); selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(1))->proxy());
} }
@ -644,7 +577,7 @@ void UBDocumentController::deleteSelectedItem()
} }
else else
{ {
if (proxyTi->proxy() == mBoardController->activeDocument()) if (proxyTi->proxy() == mBoardController->selectedDocument())
{ {
for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++)
{ {
@ -665,7 +598,7 @@ void UBDocumentController::deleteSelectedItem()
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy()); UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
refreshDocumentThumbnailsView(); reloadThumbnails();
} }
else else
{ {
@ -722,7 +655,7 @@ void UBDocumentController::deleteSelectedItem()
for (int i = 0; i < groupTi->childCount(); i++) for (int i = 0; i < groupTi->childCount(); i++)
{ {
UBDocumentProxyTreeItem* proxyTi = dynamic_cast<UBDocumentProxyTreeItem*>(groupTi->child(i)); UBDocumentProxyTreeItem* proxyTi = dynamic_cast<UBDocumentProxyTreeItem*>(groupTi->child(i));
if (proxyTi && proxyTi->proxy() && proxyTi->proxy() == mBoardController->activeDocument()) if (proxyTi && proxyTi->proxy() && proxyTi->proxy() == mBoardController->selectedDocument())
{ {
changeCurrentDocument = true; changeCurrentDocument = true;
break; break;
@ -780,7 +713,7 @@ void UBDocumentController::deleteSelectedItem()
} }
} }
refreshDocumentThumbnailsView(); reloadThumbnails();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@ -818,19 +751,6 @@ void UBDocumentController::documentZoomSliderValueChanged (int value)
} }
UBGraphicsScene* UBDocumentController::activeScene()
{
if (mBoardController->activeDocument())
{
return mBoardController->activeScene();
}
else
{
return 0;
}
}
void UBDocumentController::loadDocumentProxies() void UBDocumentController::loadDocumentProxies()
{ {
QList<QPointer<UBDocumentProxy> > proxies = UBPersistenceManager::persistenceManager()->documentProxies; QList<QPointer<UBDocumentProxy> > proxies = UBPersistenceManager::persistenceManager()->documentProxies;
@ -890,7 +810,7 @@ void UBDocumentController::loadDocumentProxies()
QTreeWidgetItem* docItem = new UBDocumentProxyTreeItem(docGroupItem, proxy, !isInTrash); QTreeWidgetItem* docItem = new UBDocumentProxyTreeItem(docGroupItem, proxy, !isInTrash);
docItem->setText(0, docName); docItem->setText(0, docName);
if (mBoardController->activeDocument() == proxy) if (mBoardController->selectedDocument() == proxy)
{ {
mDocumentUI->documentTreeWidget->expandItem(docGroupItem); mDocumentUI->documentTreeWidget->expandItem(docGroupItem);
mDocumentUI->documentTreeWidget->setCurrentItem(docGroupItem); mDocumentUI->documentTreeWidget->setCurrentItem(docGroupItem);
@ -1051,8 +971,7 @@ void UBDocumentController::addFolderOfImages()
{ {
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document); UBMetadataDcSubsetAdaptor::persist(document);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy()); reloadThumbnails();
refreshDocumentThumbnailsView();
} }
} }
} }
@ -1066,8 +985,7 @@ void UBDocumentController::addFileToDocument()
if (document) if (document)
{ {
addFileToDocument(document); addFileToDocument(document);
mDocumentThumbs = UBThumbnailAdaptor::load(document); reloadThumbnails();
refreshDocumentThumbnailsView();
} }
} }
@ -1114,12 +1032,11 @@ bool UBDocumentController::addFileToDocument(UBDocumentProxy* document)
void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source, int target) void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source, int target)
{ {
UBPersistenceManager::persistenceManager()->moveSceneToIndex(proxy, source, target); UBDocumentContainer::movePageToIndex(source, target);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy); UBMetadataDcSubsetAdaptor::persist(proxy);
mDocumentThumbs.insert(target, mDocumentThumbs.takeAt(source));
refreshDocumentThumbnailsView();
mDocumentUI->thumbnailWidget->hightlightItem(target); mDocumentUI->thumbnailWidget->hightlightItem(target);
} }
@ -1183,11 +1100,11 @@ void UBDocumentController::selectionChanged()
else if(pageSelected){ else if(pageSelected){
QList<QGraphicsItem*> selection = mDocumentUI->thumbnailWidget->selectedItems(); QList<QGraphicsItem*> selection = mDocumentUI->thumbnailWidget->selectedItems();
if(pageCount == 1) if(pageCount == 1)
mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBApplication::boardController->pageFromSceneIndex(0))); mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(0)));
else{ else{
for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1){ for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1){
if(dynamic_cast<UBSceneThumbnailPixmap*>(selection.at(i))->sceneIndex() == 0){ if(dynamic_cast<UBSceneThumbnailPixmap*>(selection.at(i))->sceneIndex() == 0){
mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBApplication::boardController->pageFromSceneIndex(0))); mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(0)));
firstSceneSelected = true; firstSceneSelected = true;
} }
} }
@ -1202,7 +1119,7 @@ void UBDocumentController::selectionChanged()
mMainWindow->actionRename->setEnabled((groupSelected || docSelected) && !trashSelected && !defaultGroupSelected); mMainWindow->actionRename->setEnabled((groupSelected || docSelected) && !trashSelected && !defaultGroupSelected);
mMainWindow->actionAddToWorkingDocument->setEnabled(pageSelected mMainWindow->actionAddToWorkingDocument->setEnabled(pageSelected
&& !(selectedDocumentProxy() == mBoardController->activeDocument()) && !trashSelected); && !(selectedDocumentProxy() == mBoardController->selectedDocument()) && !trashSelected);
bool deleteEnabled = false; bool deleteEnabled = false;
if (trashSelected) if (trashSelected)
@ -1261,7 +1178,7 @@ void UBDocumentController::documentSceneChanged(UBDocumentProxy* proxy, int pSce
if (proxy == selectedDocumentProxy()) if (proxy == selectedDocumentProxy())
{ {
refreshDocumentThumbnailsView(); reloadThumbnails();
} }
} }
@ -1350,11 +1267,11 @@ void UBDocumentController::addToDocument()
mBoardController->addScene(pageInfoList.at(i).first, pageInfoList.at(i).second, true); mBoardController->addScene(pageInfoList.at(i).first, pageInfoList.at(i).second, true);
} }
int newActiveSceneIndex = selectedItems.count() == mBoardController->activeDocument()->pageCount() ? 0 : oldActiveSceneIndex + 1; int newActiveSceneIndex = selectedItems.count() == mBoardController->selectedDocument()->pageCount() ? 0 : oldActiveSceneIndex + 1;
mDocumentUI->thumbnailWidget->selectItemAt(newActiveSceneIndex, false); mDocumentUI->thumbnailWidget->selectItemAt(newActiveSceneIndex, false);
selectDocument(mBoardController->activeDocument()); selectDocument(mBoardController->selectedDocument());
mBoardController->activeDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); mBoardController->selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(mBoardController->activeDocument()); UBMetadataDcSubsetAdaptor::persist(mBoardController->selectedDocument());
UBApplication::applicationController->showBoard(); UBApplication::applicationController->showBoard();
} }
@ -1527,8 +1444,7 @@ void UBDocumentController::addImages()
{ {
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document); UBMetadataDcSubsetAdaptor::persist(document);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy()); reloadThumbnails();
refreshDocumentThumbnailsView();
} }
} }
} }
@ -1635,20 +1551,12 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Page"), tr("Are you sure you want to remove %n page(s) from the selected document '%1'?", "", sceneIndexes.count()).arg(proxy->metaData(UBSettings::documentName).toString()))) if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Page"), tr("Are you sure you want to remove %n page(s) from the selected document '%1'?", "", sceneIndexes.count()).arg(proxy->metaData(UBSettings::documentName).toString())))
{ {
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes); UBDocumentContainer::deletePages(sceneIndexes);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy); UBMetadataDcSubsetAdaptor::persist(proxy);
int offset = 0;
foreach(int index, sceneIndexes)
{
mDocumentThumbs.removeAt(index - offset);
offset++;
}
refreshDocumentThumbnailsView();
int minIndex = proxy->pageCount() - 1; int minIndex = proxy->pageCount() - 1;
foreach (int i, sceneIndexes) foreach (int i, sceneIndexes)
minIndex = qMin(i, minIndex); minIndex = qMin(i, minIndex);
@ -1680,9 +1588,9 @@ bool UBDocumentController::pageCanBeMovedUp(int page)
bool UBDocumentController::pageCanBeMovedDown(int page) bool UBDocumentController::pageCanBeMovedDown(int page)
{ {
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return page != 0 && page < mCurrentDocument->pageCount() - 1; return page != 0 && page < selectedDocument()->pageCount() - 1;
else else
return page < mCurrentDocument->pageCount() - 1; return page < selectedDocument()->pageCount() - 1;
} }
bool UBDocumentController::pageCanBeDuplicated(int page) bool UBDocumentController::pageCanBeDuplicated(int page)
@ -1695,3 +1603,57 @@ bool UBDocumentController::pageCanBeDeleted(int page)
return page != 0; return page != 0;
} }
void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<QGraphicsItem*> items;
QList<QUrl> itemsPath;
UBDocumentProxy *proxy = selectedDocumentProxy();
QGraphicsPixmapItem *selection = 0;
QStringList labels;
if (proxy)
{
setDocument(proxy);
for (int i = 0; i < selectedDocument()->pageCount(); i++)
{
const QPixmap* pix = pageAt(i);
QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(*pix, proxy, i); // deleted by the tree widget
if (proxy == mBoardController->selectedDocument() && mBoardController->activeSceneIndex() == i)
{
selection = pixmapItem;
}
items << pixmapItem;
labels << tr("Page %1").arg(pageFromSceneIndex(i));
itemsPath.append(QUrl::fromLocalFile(proxy->persistencePath() + QString("/pages/%1").arg(UBDocumentContainer::pageFromSceneIndex(i))));
}
}
mDocumentUI->thumbnailWidget->setGraphicsItems(items, itemsPath, labels, UBApplication::mimeTypeUniboardPage);
UBDocumentProxyTreeItem* proxyTi = selectedDocumentProxyTreeItem();
if (proxyTi && (proxyTi->parent() == mTrashTi))
mDocumentUI->thumbnailWidget->setDragEnabled(false);
else
mDocumentUI->thumbnailWidget->setDragEnabled(true);
mDocumentUI->thumbnailWidget->ensureVisible(0, 0, 10, 10);
if (selection) {
disconnect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
UBSceneThumbnailPixmap *currentScene = dynamic_cast<UBSceneThumbnailPixmap*>(selection);
if (currentScene)
mDocumentUI->thumbnailWidget->hightlightItem(currentScene->sceneIndex());
connect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
}
//emit refreshThumbnails();
QApplication::restoreOverrideCursor();
}

@ -17,6 +17,7 @@
#define UBDOCUMENTCONTROLLER_H_ #define UBDOCUMENTCONTROLLER_H_
#include <QtGui> #include <QtGui>
#include "document/UBDocumentContainer.h"
namespace Ui namespace Ui
{ {
@ -35,7 +36,7 @@ class UBDocumentProxyTreeItem;
class UBMainWindow; class UBMainWindow;
class UBDocumentToolsPalette; class UBDocumentToolsPalette;
class UBDocumentController : public QObject class UBDocumentController : public UBDocumentContainer
{ {
Q_OBJECT; Q_OBJECT;
@ -47,7 +48,6 @@ class UBDocumentController : public QObject
QWidget* controlView(); QWidget* controlView();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy); UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
bool addFileToDocument(UBDocumentProxy* document); bool addFileToDocument(UBDocumentProxy* document);
UBDocumentProxy* getCurrentDocument() { return mCurrentDocument; };
void deletePages(QList<QGraphicsItem*> itemsToDelete); void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex(); int getSelectedItemIndex();
@ -57,9 +57,9 @@ class UBDocumentController : public QObject
bool pageCanBeDeleted(int page); bool pageCanBeDeleted(int page);
signals: signals:
void refreshThumbnails(); //void refreshThumbnails();
void exportDone(); void exportDone();
void movedToIndex(int index); //void movedToIndex(int index);
public slots: public slots:
void createNewDocument(); void createNewDocument();
@ -80,14 +80,13 @@ class UBDocumentController : public QObject
void copy(); void copy();
void paste(); void paste();
void focusChanged(QWidget *old, QWidget *current); void focusChanged(QWidget *old, QWidget *current);
void reloadThumbs(); //void reloadThumbs();
protected: protected:
virtual void setupViews(); virtual void setupViews();
virtual void setupToolbar(); virtual void setupToolbar();
void setupPalettes(); void setupPalettes();
bool isOKToOpenDocument(UBDocumentProxy* proxy); bool isOKToOpenDocument(UBDocumentProxy* proxy);
UBGraphicsScene* activeScene();
UBDocumentProxy* selectedDocumentProxy(); UBDocumentProxy* selectedDocumentProxy();
UBDocumentProxyTreeItem* selectedDocumentProxyTreeItem(); UBDocumentProxyTreeItem* selectedDocumentProxyTreeItem();
UBDocumentGroupTreeItem* selectedDocumentGroupTreeItem(); UBDocumentGroupTreeItem* selectedDocumentGroupTreeItem();
@ -114,14 +113,11 @@ class UBDocumentController : public QObject
UBDocumentToolsPalette *mToolsPalette; UBDocumentToolsPalette *mToolsPalette;
bool mToolsPalettePositionned; bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi; UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument;
QList<QPixmap> mDocumentThumbs;
private slots: private slots:
void documentZoomSliderValueChanged (int value); void documentZoomSliderValueChanged (int value);
void loadDocumentProxies(); void loadDocumentProxies();
void itemSelectionChanged(); void itemSelectionChanged();
void refreshDocumentThumbnailsView();
void exportDocument(); void exportDocument();
void itemChanged(QTreeWidgetItem * item, int column); void itemChanged(QTreeWidgetItem * item, int column);
void thumbnailViewResized(); void thumbnailViewResized();
@ -138,6 +134,7 @@ class UBDocumentController : public QObject
void addFileToDocument(); void addFileToDocument();
void addImages(); void addImages();
void refreshDocumentThumbnailsView(UBDocumentContainer* source);
}; };

@ -26,7 +26,9 @@ class UBGraphicsScene;
class UBDocumentProxy : public QObject class UBDocumentProxy : public QObject
{ {
Q_OBJECT; Q_OBJECT
friend class UBPersistenceManager;
public: public:
@ -60,6 +62,8 @@ class UBDocumentProxy : public QObject
bool isModified() const; bool isModified() const;
int pageCount(); int pageCount();
protected:
void setPageCount(int pPageCount); void setPageCount(int pPageCount);
int incPageCount(); int incPageCount();
int decPageCount(); int decPageCount();

@ -1,6 +1,8 @@
HEADERS += src/document/UBDocumentController.h \ HEADERS += src/document/UBDocumentController.h \
src/document/UBDocumentContainer.h \
src/document/UBDocumentProxy.h src/document/UBDocumentProxy.h
SOURCES += src/document/UBDocumentController.cpp \ SOURCES += src/document/UBDocumentController.cpp \
src/document/UBDocumentContainer.cpp \
src/document/UBDocumentProxy.cpp src/document/UBDocumentProxy.cpp

@ -544,7 +544,6 @@ void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if(isResizing()){ if(isResizing()){
mResizing = false; mResizing = false;
} }
mDelegate->setButtonsVisible(true);
} }

@ -38,8 +38,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
{ {
update(); update();
QString s = pMediaFileUrl.toLocalFile();
mMediaObject = new Phonon::MediaObject(this); mMediaObject = new Phonon::MediaObject(this);
if (pMediaFileUrl.toLocalFile().contains("videos")) if (pMediaFileUrl.toLocalFile().contains("videos"))
{ {
@ -142,8 +140,8 @@ void UBGraphicsMediaItem::clearSource()
{ {
QString path = mediaFileUrl().toLocalFile(); QString path = mediaFileUrl().toLocalFile();
//if path is absolute clean duplicated path string //if path is absolute clean duplicated path string
if (!path.contains(UBApplication::boardController->activeDocument()->persistencePath())) if (!path.contains(UBApplication::boardController->selectedDocument()->persistencePath()))
path = UBApplication::boardController->activeDocument()->persistencePath() + "/" + path; path = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + path;
if (!UBFileSystemUtils::deleteFile(path)) if (!UBFileSystemUtils::deleteFile(path))
qDebug() << "cannot delete file: " << path; qDebug() << "cannot delete file: " << path;

@ -20,6 +20,7 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "document/UBDocumentContainer.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
@ -334,7 +335,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath)
QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit) 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')); 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) QString UBFileSystemUtils::getFirstExistingFileFromList(const QString& path, const QStringList& files)
{ {

@ -18,6 +18,8 @@
#include <QtCore> #include <QtCore>
#include "core/UB.h"
class QuaZipFile; class QuaZipFile;
class UBProcessingProgressListener; class UBProcessingProgressListener;
@ -57,6 +59,10 @@ class UBFileSystemUtils
static QString fileExtensionFromMimeType(const QString& pMimeType); 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 normalizeFilePath(const QString& pFilePath);
static QString extension(const QString& filaname); static QString extension(const QString& filaname);

@ -1,7 +1,7 @@
/* /*
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
@ -40,12 +40,9 @@
*/ */
UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGraphicsView(parent) UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGraphicsView(parent)
, mScene(NULL) , mScene(NULL)
, mCrntItem(NULL)
, mCrntDoc(NULL)
, mNbColumns(1) , mNbColumns(1)
, mThumbnailWidth(0) , mThumbnailWidth(0)
, mThumbnailMinWidth(100) , mThumbnailMinWidth(100)
, bNavig(false)
{ {
setObjectName(name); setObjectName(name);
mScene = new QGraphicsScene(this); mScene = new QGraphicsScene(this);
@ -55,11 +52,9 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
setFrameShadow(QFrame::Plain); setFrameShadow(QFrame::Plain);
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(generateThumbnails())); connect(UBApplication::boardController, SIGNAL(documentThumbnailsUpdated(UBDocumentContainer*)), this, SLOT(generateThumbnails(UBDocumentContainer*)));
connect(UBApplication::boardController, SIGNAL(newPageAdded()), this, SLOT(addNewPage())); connect(UBApplication::boardController, SIGNAL(documentPageUpdated(int)), this, SLOT(updateSpecificThumbnail(int)));
connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(UBApplication::boardController, SIGNAL(pageSelectionChanged(int)), this, SLOT(onScrollToSelectedPage(int)));
connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int)));
connect(UBApplication::boardController, SIGNAL(scrollToSelectedPage()), this, SLOT(onScrollToSelectedPage()));
} }
/** /**
@ -67,12 +62,6 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
*/ */
UBDocumentNavigator::~UBDocumentNavigator() UBDocumentNavigator::~UBDocumentNavigator()
{ {
if(NULL != mCrntItem)
{
delete mCrntItem;
mCrntItem = NULL;
}
if(NULL != mScene) if(NULL != mScene)
{ {
delete mScene; delete mScene;
@ -80,27 +69,11 @@ UBDocumentNavigator::~UBDocumentNavigator()
} }
} }
/**
* \brief Set the current document
* @param document as the new document
*/
void UBDocumentNavigator::setDocument(UBDocumentProxy *document)
{
// Here we set a new document to the navigator. We must clear the current
// content and add all the pages of the given document.
if(document)
{
mCrntDoc = document;
}
}
/** /**
* \brief Generate the thumbnails * \brief Generate the thumbnails
*/ */
void UBDocumentNavigator::generateThumbnails() void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
{ {
// Get the thumbnails
QList<QPixmap> thumbs = UBThumbnailAdaptor::load(mCrntDoc);
mThumbsWithLabels.clear(); mThumbsWithLabels.clear();
foreach(QGraphicsItem* it, mScene->items()) foreach(QGraphicsItem* it, mScene->items())
@ -109,11 +82,11 @@ void UBDocumentNavigator::generateThumbnails()
delete it; delete it;
} }
for(int i = 0; i < thumbs.count(); i++) for(int i = 0; i < source->selectedDocument()->pageCount(); i++)
{ {
QPixmap pix = thumbs.at(i); const QPixmap* pix = source->pageAt(i);
QGraphicsPixmapItem* pixmapItem = new UBSceneThumbnailNavigPixmap(pix, mCrntDoc, i); UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i);
UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(tr("Page %0").arg(UBApplication::boardController->pageFromSceneIndex(i))); UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(tr("Page %0").arg(UBDocumentContainer::pageFromSceneIndex(i)));
UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem); UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem);
thumbWithText.setBorder(border()); thumbWithText.setBorder(border());
@ -121,74 +94,54 @@ void UBDocumentNavigator::generateThumbnails()
mScene->addItem(pixmapItem); mScene->addItem(pixmapItem);
mScene->addItem(labelItem); mScene->addItem(labelItem);
// Get the selected item
if(UBApplication::boardController->activeSceneIndex() == i)
{
mCrntItem = dynamic_cast<UBSceneThumbnailNavigPixmap*>(pixmapItem);
mCrntItem->setSelected(true);
}
} }
// Draw the items // Draw the items
refreshScene(); refreshScene();
} }
/** void UBDocumentNavigator::onScrollToSelectedPage(int index)
* \brief Refresh the given thumbnail
* @param iPage as the given page related thumbnail
*/
void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
{ {
// Generate the new thumbnail qDebug() << "Selection in widet: " << index;
UBGraphicsScene* pScene = UBApplication::boardController->activeScene(); int c = 0;
foreach(UBImgTextThumbnailElement el, mThumbsWithLabels)
if(NULL != pScene)
{ {
// Save the current state of the scene if (c==index)
pScene->setModified(true);
if(UBApplication::boardController)
{
UBApplication::boardController->persistCurrentScene();
}else
{ {
UBThumbnailAdaptor::persistScene(mCrntDoc->persistencePath(), pScene, iPage); el.getThumbnail()->setSelected(true);
} }
else
// Load it
QPixmap pix = UBThumbnailAdaptor::load(mCrntDoc, iPage);
UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(pix, mCrntDoc, iPage);
if(pixmapItem)
{ {
// Get the old thumbnail el.getThumbnail()->setSelected(false);
QGraphicsItem* pItem = mThumbsWithLabels.at(iPage).getThumbnail();
if(NULL != pItem)
{
mScene->removeItem(pItem);
mScene->addItem(pixmapItem);
mThumbsWithLabels[iPage].setThumbnail(pixmapItem);
delete pItem;
}
} }
c++;
} }
// centerOn(mThumbsWithLabels[index].getThumbnail());
} }
/** /**
* \brief Add a new page to the thumbnails list * \brief Refresh the given thumbnail
* * @param iPage as the given page related thumbnail
* This method is called automatically by the board controller each time the user
* adds a new page, duplicates a page or imports a document.
*/ */
void UBDocumentNavigator::addNewPage() void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
{ {
if(!bNavig) // Generate the new thumbnail
//UBGraphicsScene* pScene = UBApplication::boardController->activeScene();
const QPixmap* pix = UBApplication::boardController->pageAt(iPage);
UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix,
UBApplication::boardController->selectedDocument(), iPage);
// Get the old thumbnail
UBSceneThumbnailNavigPixmap* oldItem = mThumbsWithLabels.at(iPage).getThumbnail();
if(NULL != oldItem)
{ {
generateThumbnails(); mScene->removeItem(oldItem);
if(NULL != mCrntItem) mScene->addItem(newItem);
{ mThumbsWithLabels[iPage].setThumbnail(newItem);
mCrntItem->setSelected(true); delete oldItem;
}
} }
} }
/** /**
@ -277,7 +230,6 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
QGraphicsItem* pClickedItem = itemAt(event->pos()); QGraphicsItem* pClickedItem = itemAt(event->pos());
if(NULL != pClickedItem) if(NULL != pClickedItem)
{ {
bNavig = true;
// First, select the clicked item // First, select the clicked item
UBSceneThumbnailNavigPixmap* pCrntItem = dynamic_cast<UBSceneThumbnailNavigPixmap*>(pClickedItem); UBSceneThumbnailNavigPixmap* pCrntItem = dynamic_cast<UBSceneThumbnailNavigPixmap*>(pClickedItem);
@ -293,92 +245,29 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
const UBImgTextThumbnailElement& el = mThumbsWithLabels.at(i); const UBImgTextThumbnailElement& el = mThumbsWithLabels.at(i);
if(el.getCaption() == pTextItem) if(el.getCaption() == pTextItem)
{ {
pCrntItem = dynamic_cast<UBSceneThumbnailNavigPixmap*>(el.getThumbnail()); pCrntItem = el.getThumbnail();
break; break;
} }
} }
} }
} }
else
{
if(NULL != mCrntItem && mCrntItem != pCrntItem)
{
// Unselect the previous item
mCrntItem->setSelected(false);
int iOldPage = -1;
for(int i = 0; i < mThumbsWithLabels.size(); i++)
if (mThumbsWithLabels.at(i).getThumbnail() == mCrntItem)
{
iOldPage = i;
break;
}
updateSpecificThumbnail(iOldPage);
mCrntItem = pCrntItem;
// Then display the related page
emit changeCurrentPage();
refreshScene();
}
}
bNavig = false; int index = 0;
}
QGraphicsView::mousePressEvent(event);
}
/**
* \brief Get the selected page number
* @return the selected page number
*/
int UBDocumentNavigator::selectedPageNumber()
{
int nbr = NO_PAGESELECTED;
if(NULL != mCrntItem)
{
for(int i = 0; i < mThumbsWithLabels.size(); i++) for(int i = 0; i < mThumbsWithLabels.size(); i++)
if (mThumbsWithLabels.at(i).getThumbnail() == mCrntItem) {
{ if (mThumbsWithLabels.at(i).getThumbnail() == pCrntItem)
nbr = i; {
break; index = i;
} break;
} }
}
return nbr; qDebug() << "Selected Scene: " << index;
} UBApplication::boardController->setActiveDocumentScene(index);
}
/** QGraphicsView::mousePressEvent(event);
* \brief Get the current document
* @return the current document
*/
UBDocumentProxy* UBDocumentNavigator::currentDoc()
{
return mCrntDoc;
}
/**
* \brief Occurs when the selection changed
*/
void UBDocumentNavigator::onSelectionChanged()
{
// QList<QGraphicsItem*> qlItems = mScene->selectedItems();
// qDebug() << "The number of selected items is " << qlItems.count();
} }
/** void UBDocumentNavigator::mouseReleaseEvent(QMouseEvent *event)
* \brief Occurs when a page has been moved to another index in the document
* @param index as the new index
*/
void UBDocumentNavigator::onMovedToIndex(int index)
{ {
if(index < mThumbsWithLabels.size()){ event->accept();
UBSceneThumbnailNavigPixmap* pItem = dynamic_cast<UBSceneThumbnailNavigPixmap*>(mThumbsWithLabels.at(index).getThumbnail());
if(NULL != pItem)
{
if(mCrntItem) mCrntItem->setSelected(false);//deselecting previous one
mCrntItem = pItem;
mCrntItem->setSelected(true);
centerOn(mCrntItem);
}
}
} }

@ -22,6 +22,7 @@
#include <QThread> #include <QThread>
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "document/UBDocumentContainer.h"
#include "UBThumbnailWidget.h" #include "UBThumbnailWidget.h"
#define NO_PAGESELECTED -1 #define NO_PAGESELECTED -1
@ -33,42 +34,31 @@ public:
UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator"); UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator");
~UBDocumentNavigator(); ~UBDocumentNavigator();
void setDocument(UBDocumentProxy* document);
void setNbColumns(int nbColumns); void setNbColumns(int nbColumns);
int nbColumns(); int nbColumns();
void setThumbnailMinWidth(int width); void setThumbnailMinWidth(int width);
int thumbnailMinWidth(); int thumbnailMinWidth();
int selectedPageNumber();
UBDocumentProxy* currentDoc();
signals:
void changeCurrentPage();
public slots: public slots:
void onMovedToIndex(int index); void onScrollToSelectedPage(int index);// { if (mCrntItem) centerOn(mCrntItem); }
void onScrollToSelectedPage() { centerOn(mCrntItem); } void generateThumbnails(UBDocumentContainer* source);
void updateSpecificThumbnail(int iPage);
protected: protected:
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
private slots:
void addNewPage();
void onSelectionChanged();
void generateThumbnails();
private: private:
void refreshScene(); void refreshScene();
void updateSpecificThumbnail(int iPage);
int border(); int border();
/** The scene */ /** The scene */
QGraphicsScene* mScene; QGraphicsScene* mScene;
/** The current selected item */ /** The current selected item */
UBSceneThumbnailNavigPixmap* mCrntItem; //UBSceneThumbnailNavigPixmap* mCrntItem;
/** The current document */
UBDocumentProxy* mCrntDoc;
/** The list of current thumbnails with labels*/ /** The list of current thumbnails with labels*/
QList<UBImgTextThumbnailElement> mThumbsWithLabels; QList<UBImgTextThumbnailElement> mThumbsWithLabels;
/** The current number of columns */ /** The current number of columns */
@ -77,8 +67,6 @@ private:
int mThumbnailWidth; int mThumbnailWidth;
/** The current thumbnails minimum width */ /** The current thumbnails minimum width */
int mThumbnailMinWidth; int mThumbnailMinWidth;
/** A flag indicating that a thumbnail refresh is in progress */
bool bNavig;
}; };
#endif // UBDOCUMENTNAVIGATOR_H #endif // UBDOCUMENTNAVIGATOR_H

@ -68,7 +68,7 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
if (sceneItem) if (sceneItem)
{ {
int pageIndex = UBApplication::boardController->pageFromSceneIndex(sceneItem->sceneIndex()); int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneItem->sceneIndex());
if(pageIndex != 0){ if(pageIndex != 0){
QDrag *drag = new QDrag(this); QDrag *drag = new QDrag(this);
QList<UBMimeDataItem> mimeDataItems; QList<UBMimeDataItem> mimeDataItems;
@ -153,7 +153,7 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
int pageIndex = -1; int pageIndex = -1;
if(mClosestDropItem){ if(mClosestDropItem){
pageIndex = UBApplication::boardController->pageFromSceneIndex(mClosestDropItem->sceneIndex()); pageIndex = UBDocumentContainer::pageFromSceneIndex(mClosestDropItem->sceneIndex());
if(pageIndex == 0){ if(pageIndex == 0){
event->acceptProposedAction(); event->acceptProposedAction();
return; return;
@ -173,7 +173,7 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
{ {
mClosestDropItem = item; mClosestDropItem = item;
minDistance = distance; minDistance = distance;
pageIndex = UBApplication::boardController->pageFromSceneIndex(mClosestDropItem->sceneIndex()); pageIndex = UBDocumentContainer::pageFromSceneIndex(mClosestDropItem->sceneIndex());
} }
} }
} }
@ -221,7 +221,7 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event)
if (mClosestDropItem) if (mClosestDropItem)
{ {
int targetIndex = mDropIsRight ? mGraphicItems.indexOf(mClosestDropItem) + 1 : mGraphicItems.indexOf(mClosestDropItem); int targetIndex = mDropIsRight ? mGraphicItems.indexOf(mClosestDropItem) + 1 : mGraphicItems.indexOf(mClosestDropItem);
if(UBApplication::boardController->pageFromSceneIndex(targetIndex) == 0){ if(UBDocumentContainer::pageFromSceneIndex(targetIndex) == 0){
event->ignore(); event->ignore();
return; return;
} }
@ -279,7 +279,6 @@ void UBDocumentThumbnailWidget::deleteDropCaret()
} }
} }
void UBDocumentThumbnailWidget::setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsItems, void UBDocumentThumbnailWidget::setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsItems,
const QList<QUrl>& pItemPaths, const QStringList pLabels, const QList<QUrl>& pItemPaths, const QStringList pLabels,
const QString& pMimeType) const QString& pMimeType)

@ -200,7 +200,9 @@ void UBDocumentTreeWidget::focusInEvent(QFocusEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
itemSelectionChanged(); // Tolik
//itemSelectionChanged();
QTreeWidget::focusInEvent(event); QTreeWidget::focusInEvent(event);
} }

@ -362,27 +362,52 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
{ {
QString previewImageUrl; 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) if (!imageGatherer)
imageGatherer = new UBDownloadHttpFile(0, this); 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 // 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); 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 ); UBFeature feature( QString(), QPixmap(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata ); feature.setMetadata( metadata );
featureProperties->showElement( feature ); featureProperties->showElement( feature );
switchToProperties(); switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES ); mActionBar->setCurrentState( IN_PROPERTIES );
} }
void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground) 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; QImage img;
img.loadFromData(pData); img.loadFromData(pData);
QPixmap pix = QPixmap::fromImage(img); QPixmap pix = QPixmap::fromImage(img);
@ -779,6 +804,7 @@ void UBFeatureProperties::setOrigPixmap(QPixmap &pix)
void UBFeatureProperties::setThumbnail(QPixmap &pix) void UBFeatureProperties::setThumbnail(QPixmap &pix)
{ {
mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH)); mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH));
adaptSize();
} }
void UBFeatureProperties::adaptSize() void UBFeatureProperties::adaptSize()

@ -63,7 +63,6 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):
mTimeFormat = mTimeFormat.remove(":s"); mTimeFormat = mTimeFormat.remove(":s");
mTimerID = startTimer(1000); mTimerID = startTimer(1000);
connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage()));
} }
/** /**
@ -104,34 +103,12 @@ UBNavigatorPalette::~UBNavigatorPalette()
* \brief Set the current document in the navigator * \brief Set the current document in the navigator
* @param document as the given document * @param document as the given document
*/ */
void UBNavigatorPalette::setDocument(UBDocumentProxy *document)
{
if(mNavigator->currentDoc() != document)
{
mNavigator->setDocument(document);
}
}
/**
* \brief Change the current page
*/
void UBNavigatorPalette::changeCurrentPage()
{
// Get the index of the page to display
int iPage = mNavigator->selectedPageNumber();
if(NO_PAGESELECTED != iPage)
{
// Display the selected page
UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage);
}
}
/** /**
* \brief Refresh the thumbnails widget * \brief Refresh the thumbnails widget
*/ */
void UBNavigatorPalette::refresh() void UBNavigatorPalette::refresh()
{ {
mNavigator->setDocument(UBApplication::boardController->activeDocument());
} }
/** /**

@ -58,8 +58,6 @@ private:
QString mTimeFormat; QString mTimeFormat;
int mTimerID; int mTimerID;
private slots:
void changeCurrentPage();
}; };

@ -17,6 +17,8 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "document/UBDocumentContainer.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -72,8 +74,8 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name
mTimeFormat = mTimeFormat.remove(":s"); mTimeFormat = mTimeFormat.remove(":s");
mTimerID = startTimer(1000); mTimerID = startTimer(1000);
connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage())); //connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage()));
connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(onSetDocOnPageNavigator(UBDocumentProxy*))); //connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(onSetDocOnPageNavigator(UBDocumentProxy*)));
} }
/** /**
@ -110,41 +112,14 @@ UBPageNavigationWidget::~UBPageNavigationWidget()
} }
} }
/**
* \brief Set the current document in the navigator
* @param document as the given document
*/
void UBPageNavigationWidget::setDocument(UBDocumentProxy *document)
{
if(mNavigator->currentDoc() != document)
{
mNavigator->setDocument(document);
}
}
/**
* \brief Change the current page
*/
void UBPageNavigationWidget::changeCurrentPage()
{
// Get the index of the page to display
int iPage = mNavigator->selectedPageNumber();
if(NO_PAGESELECTED != iPage)
{
// Display the selected page
UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage);
// emit here the signal to indicate that page change
UBApplication::boardController->notifyPageChanged();
}
}
/** /**
* \brief Refresh the thumbnails widget * \brief Refresh the thumbnails widget
*/ */
void UBPageNavigationWidget::refresh() void UBPageNavigationWidget::refresh()
{ {
mNavigator->setDocument(UBApplication::boardController->activeDocument()); // TOLIK!!!
// mNavigator->setDocument(UBApplication::boardController->activeDocument());
} }
/** /**
@ -175,7 +150,7 @@ void UBPageNavigationWidget::updateTime()
*/ */
void UBPageNavigationWidget::setPageNumber(int current, int total) void UBPageNavigationWidget::setPageNumber(int current, int total)
{ {
mPageNbr->setText(QString("%1 / %2").arg(current).arg(UBApplication::boardController->sceneIndexFromPage(total))); mPageNbr->setText(QString("%1 / %2").arg(current).arg(UBDocumentContainer::sceneIndexFromPage(total)));
} }
/** /**
@ -196,11 +171,3 @@ int UBPageNavigationWidget::border()
return 15; return 15;
} }
/**
* \brief Set the current document
* @param doc as the current document
*/
void UBPageNavigationWidget::onSetDocOnPageNavigator(UBDocumentProxy *doc)
{
setDocument(doc);
}

@ -33,7 +33,7 @@ class UBPageNavigationWidget : public UBDockPaletteWidget
public: public:
UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget"); UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget");
~UBPageNavigationWidget(); ~UBPageNavigationWidget();
void setDocument(UBDocumentProxy* document); //void setDocument(UBDocumentProxy* document);
void refresh(); void refresh();
bool visibleInMode(eUBDockPaletteWidgetMode mode) bool visibleInMode(eUBDockPaletteWidgetMode mode)
@ -50,8 +50,6 @@ public slots:
protected: protected:
virtual void timerEvent(QTimerEvent *event); virtual void timerEvent(QTimerEvent *event);
private slots:
void onSetDocOnPageNavigator(UBDocumentProxy* doc);
private: private:
void updateTime(); void updateTime();
@ -68,8 +66,6 @@ private:
QString mTimeFormat; QString mTimeFormat;
int mTimerID; int mTimerID;
private slots:
void changeCurrentPage();
}; };
#endif // UBPAGENAVIGATIONWIDGET_H #endif // UBPAGENAVIGATIONWIDGET_H

@ -245,7 +245,7 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged()
cleanData(); cleanData();
load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex())); load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex()));
mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage)); mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle) if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
} }
@ -483,7 +483,7 @@ void UBTeacherGuidePresentationWidget::onActiveSceneChanged()
{ {
cleanData(); cleanData();
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage()));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle) if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); 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))); newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
QString mimeTypeString; QString mimeTypeString;
#ifdef Q_WS_WIN #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 #else
mimeTypeString = UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath"); mimeTypeString = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath");
#endif #endif
newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString); 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);
@ -882,7 +882,7 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel)
void UBTeacherGuidePageZeroWidget::onActiveSceneChanged() void UBTeacherGuidePageZeroWidget::onActiveSceneChanged()
{ {
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(documentProxy && UBApplication::boardController->currentPage() == 0){ if(documentProxy && UBApplication::boardController->currentPage() == 0){
QDateTime creationDate = documentProxy->documentDate(); QDateTime creationDate = documentProxy->documentDate();
mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate)); mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate));
@ -901,7 +901,7 @@ void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event )
void UBTeacherGuidePageZeroWidget::loadData() void UBTeacherGuidePageZeroWidget::loadData()
{ {
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
mpSessionTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); mpSessionTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
mpAuthors->setText(documentProxy->metaData(UBSettings::sessionAuthors).toString()); mpAuthors->setText(documentProxy->metaData(UBSettings::sessionAuthors).toString());
mpObjectives->setText(documentProxy->metaData(UBSettings::sessionObjectives).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 // check necessary because at document closing hide event is send after boardcontroller set
// to NULL // to NULL
if(UBApplication::boardController){ if(UBApplication::boardController){
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); 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::sessionAuthors, mpAuthors->text());
documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text()); documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text());

@ -316,7 +316,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWi
, mIsInitializationMode(false) , mIsInitializationMode(false)
{ {
setObjectName(name); setObjectName(name);
mMediaPath = UBApplication::boardController->activeDocument()->persistencePath()+ "/" + mediaPath; mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + mediaPath;
setAcceptDrops(false); setAcceptDrops(false);
createWorkWidget(); createWorkWidget();
setFixedHeight(200); setFixedHeight(200);
@ -340,7 +340,7 @@ void UBTGMediaWidget::initializeWithDom(QDomElement element)
{ {
mIsInitializationMode = true; mIsInitializationMode = true;
setAcceptDrops(false); setAcceptDrops(false);
mMediaPath = UBApplication::boardController->activeDocument()->persistencePath() + "/" + element.attribute("relativePath"); mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + element.attribute("relativePath");
qDebug() << mMediaPath; qDebug() << mMediaPath;
createWorkWidget(); createWorkWidget();
setFixedHeight(200); setFixedHeight(200);
@ -377,7 +377,7 @@ tUBGEElementNode* UBTGMediaWidget::saveData()
return 0; return 0;
tUBGEElementNode* result = new tUBGEElementNode(); tUBGEElementNode* result = new tUBGEElementNode();
QString relativePath = mMediaPath; QString relativePath = mMediaPath;
relativePath = relativePath.replace(UBApplication::boardController->activeDocument()->persistencePath()+"/",""); relativePath = relativePath.replace(UBApplication::boardController->selectedDocument()->persistencePath()+"/","");
result->name = "media"; result->name = "media";
result->attributes.insert("title",mpTitle->text()); result->attributes.insert("title",mpTitle->text());
result->attributes.insert("relativePath",relativePath); result->attributes.insert("relativePath",relativePath);
@ -394,7 +394,7 @@ void UBTGMediaWidget::createWorkWidget()
{ {
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath); QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath);
bool setMedia = true; bool setMedia = true;
UBDocumentProxy* proxyDocument = UBApplication::boardController->activeDocument(); UBDocumentProxy* proxyDocument = UBApplication::boardController->selectedDocument();
if(mimeType.contains("audio") || mimeType.contains("video")){ if(mimeType.contains("audio") || mimeType.contains("video")){
mMediaType = mimeType.contains("audio")? "audio":"movie"; mMediaType = mimeType.contains("audio")? "audio":"movie";
mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);

@ -211,7 +211,7 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event)
UBSceneThumbnailPixmap* sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(itemAt(mMousePressPos)); UBSceneThumbnailPixmap* sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(itemAt(mMousePressPos));
if(sceneItem){ if(sceneItem){
int pageIndex = UBApplication::boardController->pageFromSceneIndex(sceneItem->sceneIndex()); int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneItem->sceneIndex());
if(pageIndex == 0){ if(pageIndex == 0){
event->ignore(); event->ignore();
return; return;
@ -761,7 +761,7 @@ UBSceneThumbnailNavigPixmap::UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBD
, bCanMoveDown(false) , bCanMoveDown(false)
, bCanDuplicate(false) , bCanDuplicate(false)
{ {
if(0 <= UBApplication::boardController->pageFromSceneIndex(pSceneIndex)){ if(0 <= UBDocumentContainer::pageFromSceneIndex(pSceneIndex)){
setAcceptsHoverEvents(true); setAcceptsHoverEvents(true);
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
} }
@ -839,7 +839,7 @@ void UBSceneThumbnailNavigPixmap::updateButtonsState()
bCanDuplicate = false; bCanDuplicate = false;
if(proxy()){ if(proxy()){
int pageIndex = UBApplication::boardController->pageFromSceneIndex(sceneIndex()); int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneIndex());
UBDocumentController* documentController = UBApplication::documentController; UBDocumentController* documentController = UBApplication::documentController;
bCanDelete = documentController->pageCanBeDeleted(pageIndex); bCanDelete = documentController->pageCanBeDeleted(pageIndex);
bCanMoveUp = documentController->pageCanBeMovedUp(pageIndex); bCanMoveUp = documentController->pageCanBeMovedUp(pageIndex);
@ -853,25 +853,24 @@ void UBSceneThumbnailNavigPixmap::updateButtonsState()
void UBSceneThumbnailNavigPixmap::deletePage() void UBSceneThumbnailNavigPixmap::deletePage()
{ {
QList<QGraphicsItem*> itemsToDelete; UBApplication::boardController->deleteScene(sceneIndex());
itemsToDelete << this;
UBApplication::documentController->deletePages(itemsToDelete);
} }
void UBSceneThumbnailNavigPixmap::duplicatePage() void UBSceneThumbnailNavigPixmap::duplicatePage()
{ {
UBApplication::boardController->duplicateScene(); UBApplication::boardController->duplicateScene(sceneIndex());
} }
void UBSceneThumbnailNavigPixmap::moveUpPage() void UBSceneThumbnailNavigPixmap::moveUpPage()
{ {
UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() - 1); if (sceneIndex()!=0)
UBApplication::boardController->moveSceneToIndex(sceneIndex(), sceneIndex() - 1);
} }
void UBSceneThumbnailNavigPixmap::moveDownPage() void UBSceneThumbnailNavigPixmap::moveDownPage()
{ {
UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() + 1); if (sceneIndex() < UBApplication::boardController->selectedDocument()->pageCount()-1)
UBApplication::boardController->moveSceneToIndex(sceneIndex(), sceneIndex() + 1);
} }
void UBImgTextThumbnailElement::Place(int row, int col, qreal width, qreal height) void UBImgTextThumbnailElement::Place(int row, int col, qreal width, qreal height)

@ -400,19 +400,19 @@ class UBThumbnailTextItem : public QGraphicsTextItem
class UBImgTextThumbnailElement class UBImgTextThumbnailElement
{ {
private: private:
QGraphicsItem* thumbnail; UBSceneThumbnailNavigPixmap* thumbnail;
UBThumbnailTextItem* caption; UBThumbnailTextItem* caption;
int border; int border;
public: public:
UBImgTextThumbnailElement(QGraphicsItem* thumb, UBThumbnailTextItem* text): border(0) UBImgTextThumbnailElement(UBSceneThumbnailNavigPixmap* thumb, UBThumbnailTextItem* text): border(0)
{ {
this->thumbnail = thumb; this->thumbnail = thumb;
this->caption = text; this->caption = text;
} }
QGraphicsItem* getThumbnail() const { return this->thumbnail; } UBSceneThumbnailNavigPixmap* getThumbnail() const { return this->thumbnail; }
void setThumbnail(QGraphicsItem* newGItem) { this->thumbnail = newGItem; } void setThumbnail(UBSceneThumbnailNavigPixmap* newGItem) { this->thumbnail = newGItem; }
UBThumbnailTextItem* getCaption() const { return this->caption; } UBThumbnailTextItem* getCaption() const { return this->caption; }
void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; } void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; }

@ -40,6 +40,8 @@ void UBGraphicsCurtainItemDelegate::init()
{ {
UBGraphicsItemDelegate::init(); UBGraphicsItemDelegate::init();
mFrame->hide(); mFrame->hide();
mZOrderUpButton->hide();
mZOrderDownButton->hide();
} }
@ -87,6 +89,12 @@ QVariant UBGraphicsCurtainItemDelegate::itemChange(QGraphicsItem::GraphicsItemCh
return UBGraphicsItemDelegate::itemChange(change, value); return UBGraphicsItemDelegate::itemChange(change, value);
} }
void UBGraphicsCurtainItemDelegate::positionHandles()
{
UBGraphicsItemDelegate::positionHandles();
mZOrderUpButton->hide();
mZOrderDownButton->hide();
}
void UBGraphicsCurtainItemDelegate::remove(bool checked, bool canUndo) void UBGraphicsCurtainItemDelegate::remove(bool checked, bool canUndo)
{ {

@ -38,6 +38,7 @@ class UBGraphicsCurtainItemDelegate : public UBGraphicsItemDelegate
virtual bool mousePressEvent(QGraphicsSceneMouseEvent *event); virtual bool mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
virtual void positionHandles();
public slots: public slots:

Loading…
Cancel
Save