From 4e7dac2f60259a2f8554d2acfae868e38eed2992 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 25 Jul 2012 10:21:40 +0200 Subject: [PATCH 1/5] Changed page 0 with title page --- src/document/UBDocumentController.cpp | 6 +++++- src/gui/UBDocumentNavigator.cpp | 4 +++- src/gui/UBPageNavigationWidget.cpp | 2 -- src/gui/UBTeacherGuideWidget.cpp | 5 ++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 7adbc6fd..a4e59fd4 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -1624,7 +1624,11 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*) } items << pixmapItem; - labels << tr("Page %1").arg(pageFromSceneIndex(i)); + int pageIndex = pageFromSceneIndex(i); + if(pageIndex) + labels << tr("Page %1").arg(pageIndex); + else + labels << tr("Title page"); itemsPath.append(QUrl::fromLocalFile(proxy->persistencePath() + QString("/pages/%1").arg(UBDocumentContainer::pageFromSceneIndex(i)))); } diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index ce726365..f4026d11 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -86,7 +86,9 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) { const QPixmap* pix = source->pageAt(i); UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i); - UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(tr("Page %0").arg(UBDocumentContainer::pageFromSceneIndex(i))); + int pageIndex = UBDocumentContainer::pageFromSceneIndex(i); + QString label = pageIndex == 0 ? tr("Title page") : tr("Page %0").arg(pageIndex); + UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label); UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem); thumbWithText.setBorder(border()); diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp index 0cd9a7ab..7bb61d0d 100644 --- a/src/gui/UBPageNavigationWidget.cpp +++ b/src/gui/UBPageNavigationWidget.cpp @@ -74,8 +74,6 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name mTimeFormat = mTimeFormat.remove(":s"); mTimerID = startTimer(1000); - //connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage())); - //connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(onSetDocOnPageNavigator(UBDocumentProxy*))); } /** diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 592242fd..193a8dfa 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -135,7 +135,6 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const if(UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){ UBSvgSubsetAdaptor::addElementToBeStored(QString("teacherGuide"),this); - //connect(UBApplication::boardController,SIGNAL(activeDocumentChanged()),this,SLOT(onActiveDocumentChanged())); connect(UBApplication::boardController,SIGNAL(documentSet(UBDocumentProxy*)),this,SLOT(onActiveDocumentChanged())); } } @@ -198,7 +197,7 @@ QVector UBTeacherGuideEditionWidget::save(int pageIndex) tIDataStorage* data = new tIDataStorage(); data->name = "teacherGuide"; data->type = eElementType_START; - data->attributes.insert("version","1.50"); + data->attributes.insert("version","2.00"); result << data; data = new tIDataStorage(); @@ -635,7 +634,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpPageNumberLabel = new QLabel(this); mpPageNumberLabel->setAlignment(Qt::AlignRight); mpPageNumberLabel->setObjectName("UBTGPageNumberLabel"); - mpPageNumberLabel->setText(tr("Page 0")); + mpPageNumberLabel->setText(tr("Title page")); mpLayout->addWidget(mpPageNumberLabel); mpButtonTitleLayout = new QHBoxLayout(0); From 1f4444f27bb8dde9955186a99ebc25dfcd4ed3a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Jul 2012 18:04:12 +0200 Subject: [PATCH 2/5] help for 'selectionner' widget --- .../Selectionner.wgt/css/basic.css | 35 +++++-- .../Selectionner.wgt/img/slate-help-white.png | Bin 0 -> 553 bytes .../Selectionner.wgt/img/slate-help.png | Bin 0 -> 1795 bytes .../Selectionner.wgt/index.html | 2 + .../Selectionner.wgt/js/script.js | 33 ++++++- .../Selectionner.wgt/locales/fr/index.html | 2 + .../Selectionner.wgt/locales/fr/js/script.js | 87 ++++++++++++----- .../Selectionner.wgt/locales/ru/index.html | 2 + .../Selectionner.wgt/locales/ru/js/script.js | 89 +++++++++++++----- 9 files changed, 190 insertions(+), 60 deletions(-) create mode 100644 resources/library/interactivities/Selectionner.wgt/img/slate-help-white.png create mode 100644 resources/library/interactivities/Selectionner.wgt/img/slate-help.png diff --git a/resources/library/interactivities/Selectionner.wgt/css/basic.css b/resources/library/interactivities/Selectionner.wgt/css/basic.css index 75e7c3aa..63a3511a 100644 --- a/resources/library/interactivities/Selectionner.wgt/css/basic.css +++ b/resources/library/interactivities/Selectionner.wgt/css/basic.css @@ -4,6 +4,7 @@ html, body{ margin: 0; padding: 0; border-radius: 50px; + overflow: hidden; } body{ @@ -132,13 +133,13 @@ body{ border: 1px solid #ccc; -moz-box-shadow: #ccc -1px 0 4px; -webkit-box-shadow: #ccc -1px 0 4px; - box-shadow: #ccc -1px 0 4px; - background-color: white; + box-shadow: #ccc -1px 0 4px; } .text_block{ display: table; text-align: center; + background-color: white; } .audio_block{ @@ -317,7 +318,6 @@ body{ #wgt_name{ height: 44px; - width: 200px; margin: 10px 10px 0 10px; padding: 0; float: left; @@ -326,9 +326,8 @@ body{ color: #8c5730; } -#wgt_reload, #wgt_edit, #wgt_display{ +#wgt_reload, #wgt_edit, #wgt_display, #wgt_help{ cursor: pointer; - width: 80px; height: 44px; margin: 10px 10px 0 0; float: right; @@ -338,7 +337,6 @@ body{ } #wgt_display{ - width: 100px; padding-left: 40px; background-image: url(../img/slate-edit.png); background-repeat: no-repeat; @@ -347,7 +345,6 @@ body{ } #wgt_edit{ - width: 100px; padding-left: 40px; background-image: url(../img/slate-edit.png); background-repeat: no-repeat; @@ -439,4 +436,28 @@ body{ background-color: #333 !important; color: white !important; background-image: url(../img/ar_down_white.png) !important; +} + +.pad_help{ + background-image: url(../img/slate-help-white.png) !important; +} + +#wgt_help{ + padding-left: 32px; + background-image: url(../img/slate-help.png); + background-repeat: no-repeat; + background-position: top 0; +} + +#help{ + width: 100%; + height: 100%; + overflow: auto; + display: none; + background-color: #ccc; + padding: 5px; +} + +.open{ + } \ No newline at end of file diff --git a/resources/library/interactivities/Selectionner.wgt/img/slate-help-white.png b/resources/library/interactivities/Selectionner.wgt/img/slate-help-white.png new file mode 100644 index 0000000000000000000000000000000000000000..7b5ebfd8d29a9283767b2a42ff801178434f729d GIT binary patch literal 553 zcmV+^0@nSBP)_pb~$&L3vDaAXI=gPRvNf*c8S$Ood*7f2B<470o|&+qb$b4UIY z13>CP>OuPOnGLstkOR8%{g1qObmu=Q0HhwIk75S^eUb3s#)bdn0FXYAeu^Bhd-aTS z|0w`a{dn!bn+;`^bqp!VV#MfYB#=_6QA{$9mV`ss0iQp-IZBD)pWhRqpFlQo_)i&d zptvOb{rlHea%_g`qr4~v(gJ_~{<%zwYKh_U?Zrw@-n>WPS6;vE1r zEP==XNFXwOfiY3-0T}r6=l54;W)?17>VZN3jfI7ko0J9#3n|%Z%fg=f0wNOHxa2>) zd2yfQyh>~ofWWf{H{at6dyqT{S)6cfhz|IL#UD~4PjM7%n%~7BDX)rC{`te(3^a`b zU{mWgfu`7NQlo$*2LQ!35XgcXNOb^7*$@Qgcjh%IY8cj{i{HO-zB#dcQXRSjs2T-O r^#wS5UqE6-M>qsV8zl4q009O7eJ4TJ=dcL@00000NkvXXu0mjfuXXIg literal 0 HcmV?d00001 diff --git a/resources/library/interactivities/Selectionner.wgt/img/slate-help.png b/resources/library/interactivities/Selectionner.wgt/img/slate-help.png new file mode 100644 index 0000000000000000000000000000000000000000..069052d0061dacbeaa3bd022259a5db0e37a9f16 GIT binary patch literal 1795 zcmaJ?Yfuws6kQ%FAfUs`V%6>}AZQ`UCO}LiA%P?U8VVsuP)1ymg+xd;B#Q|FDK9}0 z8N@1s4oc9DRuQEwqAdt&i&AZiqUGTrC}=y1Kv4#(6uUvd{wUp<-S08yoO|y5?l-$P zB7B3L&2k$60PI3Tcp_p1O|R8L;;S_nUJ-*U&X?d(SR$@NG$_E8VF@T0szj1d5sJvt zQ`^u00I&cRVhJu0ZemI?B?&QMNP4B3U;{uvpk9qglTjQ@K$8?I7BupGGXyGREGWiL zND-=oQMn?-ph2Sy;bN&FS;~+>fow29&m;ttD2{-7Wr|A6)U%*zT_!O%ZIdBz8iFUY zp!cRE!U!-J)1aUqiQ*%r_)|cCm;}>&>2$g`NTt9OGKETpsXj2BNux3;6maH&h-eyF zB2&Z@%)}yAEJ%*yY9^Vi)9FY$8VS=RkzoddVbY*deF%h)HeH1ydLNb6ZB~JYYNZ;5 z8dqQ{(4>eYU}-oDBAmWYL8+dTRcU9+L==pyN7Q7PL@}i_3ls|fAF5Q&p|!XO{owaM zg|*^zHA)ttS}aW?B@Qmp%@j(_4A!6sj%magmNHw#2swshS~;c$gQNVw7==oP>9o^m zp^zD>(&C6piiYx75Wy!Y6f!2mpC*8P>ApOe0mCpK=K8_G!Twxs5TDNA(ip+BTplJ( zQ=%$-mMijbiz!<{9dT@>dkOv^LwGq%Ow+L$fjfc z*D=p-5xrxY&NVHum}`4fMfAFcXlh6v9!K1j^iUpGtnV3$5y~C8A65R{=k6<1bcmgb z?mN|=s;;Z^5Y<6m{Ptj@$lGSs$wiU8(e`6JABgn|`eLnNyubI1hs)$;v0>?FVWiE; zJCr@EkEZPGY&6FI5$e#ek(5Qbok**gxI!N}T47Z(aA8Zq%^fTJJi!>+>*0vb=(bdW zQ)`cVB#c7TK8~u9FEq=w zjgCeo=0L6`aA#nBaSjz!Jn(;cHf(fi_wbq+%OgQoxj=#_8|f8x4DtZM+V-SkzJ)Qx z|JL%nw7goYnsYU;+uvrg*}Sl{vk4nq1j(+WN9(W@MmLwt67aBRfL& zdr9%9=7*t@G#no-4pD6?3G3Rj0L(+H(d+9b!`tt{om*3%{Z;wpQRYh5oXO;qb@|}&BeSBtV*>m%b98Oi7 z9Zcy=DH6cSl%_cgub0zd7DKmf6xU@a7G@+%tZ~xY&$WO|Q%B zZ%=Lgx;ac&ztrAhYO3SL;8^n{&0*>t 
+
@@ -63,6 +64,7 @@   +
diff --git a/resources/library/interactivities/Selectionner.wgt/js/script.js b/resources/library/interactivities/Selectionner.wgt/js/script.js index b8c299fa..f8a5f9a2 100644 --- a/resources/library/interactivities/Selectionner.wgt/js/script.js +++ b/resources/library/interactivities/Selectionner.wgt/js/script.js @@ -13,7 +13,9 @@ var sankoreLang = { reload: "Reload", slate: "Wood", pad: "Pad", - none: "None" + none: "None", + help: "Help", + help_content: "This is an example of help content ..." }; //main function @@ -23,6 +25,8 @@ function start(){ $("#wgt_edit").text(sankoreLang.edit); $("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_reload").text(sankoreLang.reload); + $("#wgt_help").text(sankoreLang.help); + $("#help").html(sankoreLang.help_content); $(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='3']").text(sankoreLang.none); @@ -50,6 +54,21 @@ function start(){ } } + $("#wgt_help").click(function(){ + var tmp = $(this); + if($(this).hasClass("open")){ + $("#help").slideUp("100", function(){ + tmp.removeClass("open"); + $("#data").show(); + }); + } else { + $("#data").hide(); + $("#help").slideDown("100", function(){ + tmp.addClass("open"); + }); + } + }); + $("#wgt_reload").click(function(){ if($("#wgt_display").hasClass("selected")){ $(".cont").each(function(){ @@ -252,7 +271,7 @@ function exportData(){ tmp_block.src = $(this).find("source").attr("src"); tmp_block.hidden = $(this).parent().find("input:hidden").val(); tmp_block.type = "audio"; - tmp_block.checked = $(this).find("input:checkbox").attr("checked"); + tmp_block.checked = $(this).parent().find("input:checkbox").attr("checked"); } if($(this).hasClass("text_block")){ tmp_block.text = $(this).find(".text_subblock").text(); @@ -294,7 +313,10 @@ function importData(data){ var img_block = $("
").insertBefore(imgs_container.find(".clear")); $("").appendTo(img_block); $("").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_block) - $("").appendTo(img_block); + var img = $("").appendTo(img_block); + img.height(data[i].blocks[j].h); + if((120 - data[i].blocks[j].h) > 0) + img.css("margin",(120 - data[i].blocks[j].h)/2 + "px 0"); break; case "audio": var img_tmp = $("
").insertBefore(imgs_container.find(".clear")); @@ -422,6 +444,7 @@ function changeStyle(val){ $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); + $("#wgt_help").removeClass("pad_color").removeClass("pad_help"); $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_name").removeClass("pad_color"); @@ -438,6 +461,7 @@ function changeStyle(val){ $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload"); + $("#wgt_help").addClass("pad_color").addClass("pad_help"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_name").addClass("pad_color"); @@ -453,6 +477,7 @@ function changeStyle(val){ $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_center").addClass("without_back").removeClass("bbc_pad"); + $("#wgt_help").addClass("pad_color").addClass("pad_help"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit"); @@ -495,6 +520,8 @@ function onDropTarget(obj, event) { tmp_img.attr("height", "120"); else{ tmp_img.attr("width","120"); + var h = tmp_img.height(); + tmp_img.attr("height",h); tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0"); } }, 6); diff --git a/resources/library/interactivities/Selectionner.wgt/locales/fr/index.html b/resources/library/interactivities/Selectionner.wgt/locales/fr/index.html index ce540ec1..218567a2 100644 --- a/resources/library/interactivities/Selectionner.wgt/locales/fr/index.html +++ b/resources/library/interactivities/Selectionner.wgt/locales/fr/index.html @@ -22,6 +22,7 @@  
+
@@ -37,6 +38,7 @@   +
diff --git a/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js b/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js index b798bdfb..465f601e 100644 --- a/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js +++ b/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js @@ -13,7 +13,9 @@ var sankoreLang = { reload: "Recharger", slate: "ardoise", pad: "tablette", - none: "aucun" + none: "aucun", + help: "aide", + help_content: "Ceci est un exemple de contenu de l'aide ..." }; //main function @@ -23,6 +25,8 @@ function start(){ $("#wgt_edit").text(sankoreLang.edit); $("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_reload").text(sankoreLang.reload); + $("#wgt_help").text(sankoreLang.help); + $("#help").html(sankoreLang.help_content); $(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='3']").text(sankoreLang.none); @@ -50,8 +54,33 @@ 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(){ - window.location.reload(); + if($("#wgt_display").hasClass("selected")){ + $(".cont").each(function(){ + var container = $(this); + container.find(".img_block, .text_block").each(function(){ + $(this).find("input:checkbox").removeAttr("checked"); + $(this).find("input:checkbox").parent().parent().removeClass("right"); + }); + }); + } + else + $("#wgt_display").trigger("click"); }); $(".style_select").change(function (event){ @@ -149,31 +178,31 @@ function start(){ if($(this).is(":checked")) $(this).parent().find("input:hidden").val(1); else - $(this).parent().find("input:hidden").val(0); - } - }); + $(this).parent().find("input:hidden").val(0); + } + }); - //play/pause event - $(".play, .stop").live("click", function(){ - var tmp_audio = $(this); - var audio = tmp_audio.parent().find("audio").get(0); - if($(this).hasClass("play")){ + //play/pause event + $(".play, .stop").live("click", function(){ + var tmp_audio = $(this); + var audio = tmp_audio.parent().find("audio").get(0); + if($(this).hasClass("play")){ if(tmp_audio.parent().find("source").attr("src")){ - tmp_audio.removeClass("play").addClass("stop"); - var id = setInterval(function(){ - if(audio.currentTime == audio.duration){ - clearInterval(id); - tmp_audio.removeClass("stop").addClass("play"); - } + tmp_audio.removeClass("play").addClass("stop"); + var id = setInterval(function(){ + if(audio.currentTime == audio.duration){ + clearInterval(id); + tmp_audio.removeClass("stop").addClass("play"); + } }, 10); - tmp_audio.parent().find("input").val(id); - audio.play(); + tmp_audio.parent().find("input").val(id); + audio.play(); } - } else { - $(this).removeClass("stop").addClass("play"); - clearInterval( tmp_audio.parent().find("input").val()) - audio.pause(); - } + } else { + $(this).removeClass("stop").addClass("play"); + clearInterval( tmp_audio.parent().find("input").val()) + audio.pause(); + } }); $(".replay").live("click", function(){ @@ -240,7 +269,7 @@ function exportData(){ tmp_block.src = $(this).find("source").attr("src").replace("../../",""); tmp_block.hidden = $(this).parent().find("input:hidden").val(); tmp_block.type = "audio"; - tmp_block.checked = $(this).find("input:checkbox").attr("checked"); + tmp_block.checked = $(this).parent().find("input:checkbox").attr("checked"); } if($(this).hasClass("text_block")){ tmp_block.text = $(this).find(".text_subblock").text(); @@ -282,7 +311,10 @@ function importData(data){ var img_block = $("
").insertBefore(imgs_container.find(".clear")); $("").appendTo(img_block); $("").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_block) - $("").appendTo(img_block); + var img = $("").appendTo(img_block); + img.height(data[i].blocks[j].h); + if((120 - data[i].blocks[j].h) > 0) + img.css("margin",(120 - data[i].blocks[j].h)/2 + "px 0"); break; case "audio": var img_tmp = $("
").insertBefore(imgs_container.find(".clear")); @@ -411,6 +443,7 @@ function changeStyle(val){ $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); + $("#wgt_help").removeClass("pad_color").removeClass("pad_help"); $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_name").removeClass("pad_color"); @@ -427,6 +460,7 @@ function changeStyle(val){ $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload"); + $("#wgt_help").addClass("pad_color").addClass("pad_help"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_name").addClass("pad_color"); @@ -442,6 +476,7 @@ function changeStyle(val){ $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_center").addClass("without_back").removeClass("bbc_pad"); + $("#wgt_help").addClass("pad_color").addClass("pad_help"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit"); @@ -484,6 +519,8 @@ function onDropTarget(obj, event) { tmp_img.attr("height", "120"); else{ tmp_img.attr("width","120"); + var h = tmp_img.height(); + tmp_img.attr("height",h); tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0"); } }, 6); diff --git a/resources/library/interactivities/Selectionner.wgt/locales/ru/index.html b/resources/library/interactivities/Selectionner.wgt/locales/ru/index.html index 6c4d34f9..1e415855 100644 --- a/resources/library/interactivities/Selectionner.wgt/locales/ru/index.html +++ b/resources/library/interactivities/Selectionner.wgt/locales/ru/index.html @@ -22,6 +22,7 @@  
+
@@ -37,6 +38,7 @@   +
diff --git a/resources/library/interactivities/Selectionner.wgt/locales/ru/js/script.js b/resources/library/interactivities/Selectionner.wgt/locales/ru/js/script.js index 33e5c16c..872e57bf 100644 --- a/resources/library/interactivities/Selectionner.wgt/locales/ru/js/script.js +++ b/resources/library/interactivities/Selectionner.wgt/locales/ru/js/script.js @@ -13,7 +13,9 @@ var sankoreLang = { reload: "Обновить", slate: "Узор", pad: "Планшет", - none: "Нет" + none: "Нет", + help: "Помощь", + help_content: "Пример текста помощи ..." }; //main function @@ -23,6 +25,8 @@ function start(){ $("#wgt_edit").text(sankoreLang.edit); $("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_reload").text(sankoreLang.reload); + $("#wgt_help").text(sankoreLang.help); + $("#help").html(sankoreLang.help_content); $(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='3']").text(sankoreLang.none); @@ -50,8 +54,33 @@ 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(){ - window.location.reload(); + if($("#wgt_display").hasClass("selected")){ + $(".cont").each(function(){ + var container = $(this); + container.find(".img_block, .text_block").each(function(){ + $(this).find("input:checkbox").removeAttr("checked"); + $(this).find("input:checkbox").parent().parent().removeClass("right"); + }); + }); + } + else + $("#wgt_display").trigger("click"); }); $(".style_select").change(function (event){ @@ -149,31 +178,31 @@ function start(){ if($(this).is(":checked")) $(this).parent().find("input:hidden").val(1); else - $(this).parent().find("input:hidden").val(0); - } - }); + $(this).parent().find("input:hidden").val(0); + } + }); - //play/pause event - $(".play, .stop").live("click", function(){ - var tmp_audio = $(this); - var audio = tmp_audio.parent().find("audio").get(0); - if($(this).hasClass("play")){ + //play/pause event + $(".play, .stop").live("click", function(){ + var tmp_audio = $(this); + var audio = tmp_audio.parent().find("audio").get(0); + if($(this).hasClass("play")){ if(tmp_audio.parent().find("source").attr("src")){ - tmp_audio.removeClass("play").addClass("stop"); - var id = setInterval(function(){ - if(audio.currentTime == audio.duration){ - clearInterval(id); - tmp_audio.removeClass("stop").addClass("play"); - } + tmp_audio.removeClass("play").addClass("stop"); + var id = setInterval(function(){ + if(audio.currentTime == audio.duration){ + clearInterval(id); + tmp_audio.removeClass("stop").addClass("play"); + } }, 10); - tmp_audio.parent().find("input").val(id); - audio.play(); + tmp_audio.parent().find("input").val(id); + audio.play(); } - } else { - $(this).removeClass("stop").addClass("play"); - clearInterval( tmp_audio.parent().find("input").val()) - audio.pause(); - } + } else { + $(this).removeClass("stop").addClass("play"); + clearInterval( tmp_audio.parent().find("input").val()) + audio.pause(); + } }); $(".replay").live("click", function(){ @@ -209,6 +238,8 @@ function start(){ $(".close_img").live("click", function(){ $(this).parent().remove(); }); + + } //export @@ -238,7 +269,7 @@ function exportData(){ tmp_block.src = $(this).find("source").attr("src").replace("../../",""); tmp_block.hidden = $(this).parent().find("input:hidden").val(); tmp_block.type = "audio"; - tmp_block.checked = $(this).find("input:checkbox").attr("checked"); + tmp_block.checked = $(this).parent().find("input:checkbox").attr("checked"); } if($(this).hasClass("text_block")){ tmp_block.text = $(this).find(".text_subblock").text(); @@ -280,7 +311,10 @@ function importData(data){ var img_block = $("
").insertBefore(imgs_container.find(".clear")); $("").appendTo(img_block); $("").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_block) - $("").appendTo(img_block); + var img = $("").appendTo(img_block); + img.height(data[i].blocks[j].h); + if((120 - data[i].blocks[j].h) > 0) + img.css("margin",(120 - data[i].blocks[j].h)/2 + "px 0"); break; case "audio": var img_tmp = $("
").insertBefore(imgs_container.find(".clear")); @@ -409,6 +443,7 @@ function changeStyle(val){ $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); + $("#wgt_help").removeClass("pad_color").removeClass("pad_help"); $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_name").removeClass("pad_color"); @@ -425,6 +460,7 @@ function changeStyle(val){ $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload"); + $("#wgt_help").addClass("pad_color").addClass("pad_help"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_name").addClass("pad_color"); @@ -440,6 +476,7 @@ function changeStyle(val){ $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_center").addClass("without_back").removeClass("bbc_pad"); + $("#wgt_help").addClass("pad_color").addClass("pad_help"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit"); @@ -482,6 +519,8 @@ function onDropTarget(obj, event) { tmp_img.attr("height", "120"); else{ tmp_img.attr("width","120"); + var h = tmp_img.height(); + tmp_img.attr("height",h); tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0"); } }, 6); From d15d5805f7fc3ddc2cf68f83f348ab283eb4e5af Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 26 Jul 2012 09:37:55 +0200 Subject: [PATCH 3/5] fixed issue 663 --- .../teacherGuide/indexingParameters.xml | 7 + src/adaptors/UBSvgSubsetAdaptor.cpp | 6 +- src/board/UBBoardController.cpp | 10 +- src/board/UBBoardPaletteManager.h | 2 + src/core/UBApplicationController.cpp | 4 +- src/core/UBPersistenceManager.cpp | 14 +- src/gui/UBDockTeacherGuideWidget.cpp | 5 + src/gui/UBDockTeacherGuideWidget.h | 2 + src/gui/UBTeacherGuideWidget.cpp | 494 ++++++++++-------- src/gui/UBTeacherGuideWidget.h | 5 + 10 files changed, 316 insertions(+), 233 deletions(-) diff --git a/resources/customizations/teacherGuide/indexingParameters.xml b/resources/customizations/teacherGuide/indexingParameters.xml index 09c4917a..2a194515 100644 --- a/resources/customizations/teacherGuide/indexingParameters.xml +++ b/resources/customizations/teacherGuide/indexingParameters.xml @@ -1,6 +1,7 @@ + @@ -22,6 +23,7 @@ + @@ -29,6 +31,7 @@ + @@ -50,6 +53,7 @@ + @@ -80,6 +84,7 @@ + @@ -125,6 +130,7 @@ + @@ -169,6 +175,7 @@ + diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index a56fd342..a9a325e8 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -45,6 +45,7 @@ #include "board/UBBoardView.h" #include "board/UBBoardController.h" #include "board/UBDrawingController.h" +#include "board/UBBoardPaletteManager.h" #include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBStringUtils.h" @@ -54,6 +55,9 @@ #include "core/UBPersistenceManager.h" #include "core/UBApplication.h" +#include "gui/UBTeacherGuideWidget.h" +#include "gui/UBDockTeacherGuideWidget.h" + #include "interfaces/IDataStorage.h" #include "document/UBDocumentContainer.h" @@ -1142,7 +1146,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement() bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) { - if (mScene->isModified()) + if (mScene->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified())) { //Creating dom structure to store information diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index d7c333a7..db95ad67 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -38,6 +38,9 @@ #include "gui/UBToolWidget.h" #include "gui/UBKeyboardPalette.h" #include "gui/UBMagnifer.h" +#include "gui/UBDockPaletteWidget.h" +#include "gui/UBDockTeacherGuideWidget.h" +#include "gui/UBTeacherGuideWidget.h" #include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsItemUndoCommand.h" @@ -1464,7 +1467,10 @@ void UBBoardController::lastWindowClosed() { if (!mCleanupDone) { - if (selectedDocument()->pageCount() == 1 && (!mActiveScene || mActiveScene->isEmpty())) + bool teacherGuideModified = false; + if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget()) + teacherGuideModified = UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified(); + if (selectedDocument()->pageCount() == 1 && (!mActiveScene || mActiveScene->isEmpty()) && !teacherGuideModified) { UBPersistenceManager::persistenceManager()->deleteDocument(selectedDocument()); } @@ -1591,7 +1597,7 @@ void UBBoardController::persistCurrentScene() if(UBPersistenceManager::persistenceManager() && selectedDocument() && mActiveScene && (mActiveSceneIndex >= 0) - && mActiveScene->isModified()) + && (mActiveScene->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()))) { emit activeSceneWillBePersisted(); diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h index 31f3dd92..b924a03a 100644 --- a/src/board/UBBoardPaletteManager.h +++ b/src/board/UBBoardPaletteManager.h @@ -69,6 +69,8 @@ class UBBoardPaletteManager : public QObject void setCurrentWebToolsPalette(UBWebToolsPalette *palette) {mWebToolsCurrentPalette = palette;} UBWebToolsPalette* mWebToolsCurrentPalette; + UBDockTeacherGuideWidget* teacherGuideDockWidget() { return mpTeacherGuideWidget;} + void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode); void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false); void startDownloads(); diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index ad2a19ae..0598e490 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -40,6 +40,8 @@ #include "gui/UBScreenMirror.h" #include "gui/UBMainWindow.h" +#include "gui/UBDockTeacherGuideWidget.h" +#include "gui/UBTeacherGuideWidget.h" #include "domain/UBGraphicsPixmapItem.h" #include "domain/UBW3CWidget.h" @@ -419,7 +421,7 @@ void UBApplicationController::showDocument() if (UBApplication::boardController) { - if (UBApplication::boardController->activeScene()->isModified()) + if (UBApplication::boardController->activeScene()->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified())) UBApplication::boardController->persistCurrentScene(); UBApplication::boardController->hide(); } diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index a279ab4c..bc90fc52 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -25,6 +25,9 @@ #include "core/UBSettings.h" #include "core/UBSetting.h" +#include "gui/UBDockTeacherGuideWidget.h" +#include "gui/UBTeacherGuideWidget.h" + #include "document/UBDocumentProxy.h" #include "adaptors/UBExportPDF.h" @@ -33,6 +36,7 @@ #include "adaptors/UBMetadataDcSubsetAdaptor.h" #include "board/UBBoardController.h" +#include "board/UBBoardPaletteManager.h" #include "interfaces/IDataStorage.h" @@ -591,7 +595,6 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy, } } - void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* pScene, const int pSceneIndex) { checkIfDocumentRepositoryExists(); @@ -603,10 +606,15 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, QDir dir(pDocumentProxy->persistencePath()); dir.mkpath(pDocumentProxy->persistencePath()); - if (pDocumentProxy->isModified()) + UBBoardPaletteManager* paletteManager = UBApplication::boardController->paletteManager(); + bool teacherGuideModified = false; + if(paletteManager->teacherGuideDockWidget()) + teacherGuideModified = paletteManager->teacherGuideDockWidget()->teacherGuideWidget()->isModified(); + + if (pDocumentProxy->isModified() || teacherGuideModified) UBMetadataDcSubsetAdaptor::persist(pDocumentProxy); - if (pScene->isModified()) + if (pScene->isModified() || teacherGuideModified) { UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex); diff --git a/src/gui/UBDockTeacherGuideWidget.cpp b/src/gui/UBDockTeacherGuideWidget.cpp index 522d0052..cb84751b 100644 --- a/src/gui/UBDockTeacherGuideWidget.cpp +++ b/src/gui/UBDockTeacherGuideWidget.cpp @@ -44,3 +44,8 @@ UBDockTeacherGuideWidget::~UBDockTeacherGuideWidget() DELETEPTR(mpTeacherGuideWidget); DELETEPTR(mpLayout); } + +UBTeacherGuideWidget* UBDockTeacherGuideWidget::teacherGuideWidget() +{ + return mpTeacherGuideWidget; +} diff --git a/src/gui/UBDockTeacherGuideWidget.h b/src/gui/UBDockTeacherGuideWidget.h index 250b0381..8edea3ca 100644 --- a/src/gui/UBDockTeacherGuideWidget.h +++ b/src/gui/UBDockTeacherGuideWidget.h @@ -31,6 +31,8 @@ public: bool visibleInMode(eUBDockPaletteWidgetMode mode){ return mode == eUBDockPaletteWidget_BOARD; } + UBTeacherGuideWidget* teacherGuideWidget(); + private: QVBoxLayout* mpLayout; UBTeacherGuideWidget* mpTeacherGuideWidget; diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 193a8dfa..3d5241fa 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -49,15 +49,12 @@ #define UBTG_SEPARATOR_FIXED_HEIGHT 3 -typedef enum -{ +typedef enum { eUBTGAddSubItemWidgetType_None, - eUBTGAddSubItemWidgetType_Action , + eUBTGAddSubItemWidgetType_Action, eUBTGAddSubItemWidgetType_Media, eUBTGAddSubItemWidgetType_Url -}eUBTGAddSubItemWidgetType; - - +} eUBTGAddSubItemWidgetType; /*************************************************************************** * class UBTeacherGuideEditionWidget * @@ -86,18 +83,18 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpLayout->addWidget(mpPageNumberLabel); // tree basic configuration - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ + if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) { mpDocumentTitle = new QLabel(this); mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle"); mpLayout->addWidget(mpDocumentTitle); } - mpPageTitle = new UBTGAdaptableText(0,this); + mpPageTitle = new UBTGAdaptableText(0, this); mpPageTitle->setObjectName("UBTGEditionPageTitle"); mpPageTitle->setPlaceHolderText(tr("Type title here ...")); mpLayout->addWidget(mpPageTitle); - mpComment = new UBTGAdaptableText(0,this); + mpComment = new UBTGAdaptableText(0, this); mpComment->setObjectName("UBTGEditionComment"); mpComment->setPlaceHolderText(tr("Type comment here ...")); mpLayout->addWidget(mpComment); @@ -122,20 +119,20 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed); mpTreeWidget->header()->setDefaultSectionSize(18); - connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); - connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged())); + connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int))); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); - mpAddAnActionItem = new UBAddItem(tr("Add an action"),eUBTGAddSubItemWidgetType_Action,mpTreeWidget); - mpAddAMediaItem = new UBAddItem(tr("Add a media"),eUBTGAddSubItemWidgetType_Media,mpTreeWidget); - mpAddALinkItem = new UBAddItem(tr("Add a link"),eUBTGAddSubItemWidgetType_Url,mpTreeWidget); + mpAddAnActionItem = new UBAddItem(tr("Add an action"), eUBTGAddSubItemWidgetType_Action, mpTreeWidget); + mpAddAMediaItem = new UBAddItem(tr("Add a media"), eUBTGAddSubItemWidgetType_Media, mpTreeWidget); + mpAddALinkItem = new UBAddItem(tr("Add a link"), eUBTGAddSubItemWidgetType_Url, mpTreeWidget); mpRootWidgetItem->addChild(mpAddAnActionItem); mpRootWidgetItem->addChild(mpAddAMediaItem); mpRootWidgetItem->addChild(mpAddALinkItem); - if(UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){ - UBSvgSubsetAdaptor::addElementToBeStored(QString("teacherGuide"),this); - connect(UBApplication::boardController,SIGNAL(documentSet(UBDocumentProxy*)),this,SLOT(onActiveDocumentChanged())); + if (UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()) { + UBSvgSubsetAdaptor::addElementToBeStored(QString("teacherGuide"), this); + connect(UBApplication::boardController, SIGNAL(documentSet(UBDocumentProxy*)), this, SLOT(onActiveDocumentChanged())); } } @@ -149,7 +146,7 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget() DELETEPTR(mpAddAnActionItem); DELETEPTR(mpAddAMediaItem); DELETEPTR(mpAddALinkItem); - DELETEPTR(mpTreeWidget) + DELETEPTR(mpTreeWidget); DELETEPTR(mpLayout); } @@ -162,7 +159,7 @@ void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event) void UBTeacherGuideEditionWidget::onActiveDocumentChanged() { int activeSceneIndex = UBApplication::boardController->activeSceneIndex(); - if(UBApplication::boardController->pageFromSceneIndex(activeSceneIndex) != 0) + if (UBApplication::boardController->pageFromSceneIndex(activeSceneIndex) != 0) load(UBSvgSubsetAdaptor::readTeacherGuideNode(activeSceneIndex)); } @@ -172,61 +169,62 @@ void UBTeacherGuideEditionWidget::load(QString element) QDomDocument doc("TeacherGuide"); doc.setContent(element); - for(QDomElement element = doc.documentElement().firstChildElement(); !element.isNull(); element = element.nextSiblingElement()) { + for (QDomElement element = doc.documentElement().firstChildElement(); + !element.isNull(); element = element.nextSiblingElement()) { QString tagName = element.tagName(); - if(tagName == "title") + if (tagName == "title") mpPageTitle->setInitialText(element.attribute("value")); - else if(tagName == "comment") + else if (tagName == "comment") mpComment->setInitialText(element.attribute("value")); - else if(tagName == "media") - onAddItemClicked(mpAddAMediaItem,0,&element); - else if(tagName == "link") - onAddItemClicked(mpAddALinkItem,0,&element); - else if(tagName == "action") - onAddItemClicked(mpAddAnActionItem,0,&element); + else if (tagName == "media") + onAddItemClicked(mpAddAMediaItem, 0, &element); + else if (tagName == "link") + onAddItemClicked(mpAddALinkItem, 0, &element); + else if (tagName == "action") + onAddItemClicked(mpAddAnActionItem, 0, &element); } } - - QVector UBTeacherGuideEditionWidget::save(int pageIndex) { QVector result; - if(pageIndex != UBApplication::boardController->currentPage()) + if (pageIndex != UBApplication::boardController->currentPage()) return result; tIDataStorage* data = new tIDataStorage(); data->name = "teacherGuide"; data->type = eElementType_START; - data->attributes.insert("version","2.00"); + data->attributes.insert("version", "2.00"); result << data; data = new tIDataStorage(); data->name = "title"; data->type = eElementType_UNIQUE; - data->attributes.insert("value",mpPageTitle->text()); - if(mpPageTitle->text().length()){ + data->attributes.insert("value", mpPageTitle->text()); + if (mpPageTitle->text().length()) result << data; - } data = new tIDataStorage(); data->name = "comment"; data->type = eElementType_UNIQUE; - data->attributes.insert("value",mpComment->text()); - if(mpComment->text().length()) + data->attributes.insert("value", mpComment->text()); + if (mpComment->text().length()) result << data; QList children = getChildrenList(mpAddAnActionItem); children << getChildrenList(mpAddAMediaItem); children << getChildrenList(mpAddALinkItem); - foreach(QTreeWidgetItem* widgetItem, children){ - tUBGEElementNode* node = dynamic_cast(mpTreeWidget->itemWidget(widgetItem,0))->saveData(); - if(node){ + foreach(QTreeWidgetItem* widgetItem, children) { + tUBGEElementNode* node = + dynamic_cast(mpTreeWidget->itemWidget( + widgetItem, 0))->saveData(); + if (node) { data = new tIDataStorage(); data->name = node->name; data->type = eElementType_UNIQUE; foreach(QString currentKey, node->attributes.keys()) - data->attributes.insert(currentKey,node->attributes.value(currentKey)); + data->attributes.insert(currentKey, + node->attributes.value(currentKey)); result << data; } } @@ -241,12 +239,12 @@ QVector UBTeacherGuideEditionWidget::save(int pageIndex) void UBTeacherGuideEditionWidget::onActiveSceneChanged() { int currentPage = UBApplication::boardController->currentPage(); - if(currentPage > 0){ + if (currentPage > 0) { cleanData(); - load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex())); + load( UBSvgSubsetAdaptor::readTeacherGuideNode( UBApplication::boardController->activeSceneIndex())); mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage)); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - if(mpDocumentTitle) + if (mpDocumentTitle) mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); } } @@ -259,44 +257,46 @@ void UBTeacherGuideEditionWidget::cleanData() children << mpAddAMediaItem->takeChildren(); children << mpAddALinkItem->takeChildren(); - foreach(QTreeWidgetItem* item, children){ + foreach(QTreeWidgetItem* item, children) { DELETEPTR(item); } } -QList UBTeacherGuideEditionWidget::getChildrenList(QTreeWidgetItem* widgetItem) +QList UBTeacherGuideEditionWidget::getChildrenList( QTreeWidgetItem* widgetItem) { - QListresult; - for(int i=0;ichildCount();i+=1) + QList result; + for (int i = 0; i < widgetItem->childCount(); i += 1) result << widgetItem->child(i); return result; } QVector UBTeacherGuideEditionWidget::getPageAndCommentData() { - QVectorresult; + QVector result; tUBGEElementNode* pageTitle = new tUBGEElementNode(); pageTitle->name = "pageTitle"; - pageTitle->attributes.insert("value",mpPageTitle->text()); + pageTitle->attributes.insert("value", mpPageTitle->text()); result << pageTitle; tUBGEElementNode* comment = new tUBGEElementNode(); comment->name = "comment"; - comment->attributes.insert("value",mpComment->text()); + comment->attributes.insert("value", mpComment->text()); result << comment; return result; } QVector UBTeacherGuideEditionWidget::getData() { - QVectorresult; + QVector result; QList children = getChildrenList(mpAddAnActionItem); children << getChildrenList(mpAddAMediaItem); children << getChildrenList(mpAddALinkItem); result << getPageAndCommentData(); - foreach(QTreeWidgetItem* widgetItem, children){ - tUBGEElementNode* node = dynamic_cast(mpTreeWidget->itemWidget(widgetItem,0))->saveData(); - if(node) + foreach(QTreeWidgetItem* widgetItem, children) { + tUBGEElementNode* node = + dynamic_cast(mpTreeWidget->itemWidget( + widgetItem, 0))->saveData(); + if (node) result << node; } return result; @@ -304,31 +304,33 @@ QVector UBTeacherGuideEditionWidget::getData() void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement *element) { - int addSubItemWidgetType = widget->data(column,Qt::UserRole).toInt(); - if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None){ + int addSubItemWidgetType = widget->data(column, Qt::UserRole).toInt(); + if (addSubItemWidgetType != eUBTGAddSubItemWidgetType_None) { QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(widget); - newWidgetItem->setData(column,Qt::UserRole,eUBTGAddSubItemWidgetType_None); - newWidgetItem->setData(1,Qt::UserRole,eUBTGAddSubItemWidgetType_None); - newWidgetItem->setIcon(1,QIcon(":images/close.svg")); + newWidgetItem->setData(column, Qt::UserRole, eUBTGAddSubItemWidgetType_None); + newWidgetItem->setData(1, Qt::UserRole, eUBTGAddSubItemWidgetType_None); + newWidgetItem->setIcon(1, QIcon(":images/close.svg")); - switch(addSubItemWidgetType) - { - case eUBTGAddSubItemWidgetType_Action:{ + switch (addSubItemWidgetType) { + case eUBTGAddSubItemWidgetType_Action: { UBTGActionWidget* actionWidget = new UBTGActionWidget(widget); - if(element) actionWidget->initializeWithDom(*element); - mpTreeWidget->setItemWidget(newWidgetItem,0,actionWidget); + if (element) + actionWidget->initializeWithDom(*element); + mpTreeWidget->setItemWidget(newWidgetItem, 0, actionWidget); break; } - case eUBTGAddSubItemWidgetType_Media:{ + case eUBTGAddSubItemWidgetType_Media: { UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(widget); - if(element) mediaWidget->initializeWithDom(*element); - mpTreeWidget->setItemWidget(newWidgetItem,0,mediaWidget); + if (element) + mediaWidget->initializeWithDom(*element); + mpTreeWidget->setItemWidget(newWidgetItem, 0, mediaWidget); break; } - case eUBTGAddSubItemWidgetType_Url:{ + case eUBTGAddSubItemWidgetType_Url: { UBTGUrlWidget* urlWidget = new UBTGUrlWidget(); - if(element) urlWidget->initializeWithDom(*element); - mpTreeWidget->setItemWidget(newWidgetItem,0,urlWidget); + if (element) + urlWidget->initializeWithDom(*element); + mpTreeWidget->setItemWidget(newWidgetItem, 0, urlWidget); break; } default: @@ -337,42 +339,53 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int return; } - if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded() ) + if (addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded()) widget->setExpanded(true); - else{ + else { //to update the tree and subtrees widget->setExpanded(false); widget->setExpanded(true); } - } - else if(column == 1 && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None){ - UBTGMediaWidget* media = dynamic_cast(mpTreeWidget->itemWidget(widget,0)); - if(media) media->removeSource(); + } else if (column == 1 + && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None) { + UBTGMediaWidget* media = dynamic_cast(mpTreeWidget->itemWidget(widget, 0)); + if (media) + media->removeSource(); int index = mpTreeWidget->currentIndex().row(); - QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild(index); + QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild( + index); delete toBeDeletedWidgetItem; } } +bool UBTeacherGuideEditionWidget::isModified() +{ + bool result = false; + result |= mpPageTitle->text().length() > 0; + result |= mpComment->text().length() > 0; + result |= mpAddAnActionItem->childCount() > 0; + result |= mpAddAMediaItem->childCount() > 0; + result |= mpAddALinkItem->childCount() > 0; + return result; +} + /*************************************************************************** * class UBTeacherGuidePresentationWidget * ***************************************************************************/ -typedef enum -{ +typedef enum { tUBTGActionAssociateOnClickItem_NONE, tUBTGActionAssociateOnClickItem_URL, tUBTGActionAssociateOnClickItem_MEDIA, tUBTGActionAssociateOnClickItem_EXPAND -}tUBTGActionAssociateOnClickItem; +} tUBTGActionAssociateOnClickItem; -typedef enum -{ +typedef enum { tUBTGTreeWidgetItemRole_HasAnAction = Qt::UserRole, tUBTGTreeWidgetItemRole_HasAnUrl -}tUBTGTreeWidgetItemRole; - +} tUBTGTreeWidgetItemRole; -UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *parent, const char *name) : QWidget(parent) +UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *parent, const char *name) : + QWidget(parent) , mpPageTitle(NULL) , mpComment(NULL) , mpLayout(NULL) @@ -402,10 +415,10 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare mpModePushButton->setMaximumWidth(32); mpModePushButton->installEventFilter(this); - connect(mpModePushButton,SIGNAL(clicked()),parentWidget(),SLOT(changeMode())); + connect(mpModePushButton, SIGNAL(clicked()), parentWidget(), SLOT(changeMode())); mpButtonTitleLayout->addWidget(mpModePushButton); - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ + if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) { mpDocumentTitle = new QLabel(this); mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle"); mpButtonTitleLayout->addWidget(mpDocumentTitle); @@ -413,13 +426,13 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare mpLayout->addLayout(mpButtonTitleLayout); - mpPageTitle = new UBTGAdaptableText(0,this); + mpPageTitle = new UBTGAdaptableText(0, this); mpPageTitle->setObjectName("UBTGPresentationPageTitle"); mpPageTitle->setReadOnly(true); mpPageTitle->setStyleSheet("background-color:transparent"); mpLayout->addWidget(mpPageTitle); - mpComment = new UBTGAdaptableText(0,this); + mpComment = new UBTGAdaptableText(0, this); mpComment->setObjectName("UBTGPresentationComment"); mpComment->setReadOnly(true); mpComment->setStyleSheet("background-color:transparent"); @@ -440,8 +453,8 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare mpTreeWidget->setDropIndicatorShown(false); mpTreeWidget->header()->close(); mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); - connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged())); + connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int))); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); } UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget() @@ -461,7 +474,7 @@ UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget() bool UBTeacherGuidePresentationWidget::eventFilter(QObject* object, QEvent* event) { Q_UNUSED(object); - if(event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave) + if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave) return true; return false; } @@ -472,7 +485,7 @@ void UBTeacherGuidePresentationWidget::cleanData() mpComment->showText(""); //tree clean QList itemToRemove = mpRootWidgetItem->takeChildren(); - foreach(QTreeWidgetItem* eachItem, itemToRemove){ + foreach(QTreeWidgetItem* eachItem, itemToRemove) { DELETEPTR(eachItem); } // the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero @@ -482,81 +495,81 @@ void UBTeacherGuidePresentationWidget::cleanData() void UBTeacherGuidePresentationWidget::onActiveSceneChanged() { cleanData(); - mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); + mpPageNumberLabel->setText( tr("Page: %0").arg(UBApplication::boardController->currentPage())); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - if(mpDocumentTitle) - mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); + if (mpDocumentTitle) + mpDocumentTitle->setText( documentProxy->metaData(UBSettings::sessionTitle).toString()); } void UBTeacherGuidePresentationWidget::createMediaButtonItem() { - if(!mpMediaSwitchItem){ + if (!mpMediaSwitchItem) { mpMediaSwitchItem = new QTreeWidgetItem(mpRootWidgetItem); - mpMediaSwitchItem->setText(0,"+"); + mpMediaSwitchItem->setText(0, "+"); mpMediaSwitchItem->setExpanded(false); - mpMediaSwitchItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_EXPAND); - mpMediaSwitchItem->setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200))); - mpMediaSwitchItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),16))); - mpMediaSwitchItem->setData(0,Qt::TextAlignmentRole,QVariant(Qt::AlignCenter)); + mpMediaSwitchItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_EXPAND); + mpMediaSwitchItem->setData(0, Qt::BackgroundRole, QVariant(QColor(200, 200, 200))); + mpMediaSwitchItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 16))); + mpMediaSwitchItem->setData(0, Qt::TextAlignmentRole, QVariant(Qt::AlignCenter)); mpRootWidgetItem->addChild(mpMediaSwitchItem); } } - -void UBTeacherGuidePresentationWidget::showData(QVector data) +void UBTeacherGuidePresentationWidget::showData( QVector data) { cleanData(); - foreach(tUBGEElementNode* element, data){ - if(element->name == "pageTitle") + foreach(tUBGEElementNode* element, data) { + if (element->name == "pageTitle") mpPageTitle->showText(element->attributes.value("value")); else if (element->name == "comment") mpComment->showText(element->attributes.value("value")); - else if(element->name == "action"){ - QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpRootWidgetItem); - newWidgetItem->setText(0,element->attributes.value("task")); + else if (element->name == "action") { + QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem( mpRootWidgetItem); + newWidgetItem->setText(0, element->attributes.value("task")); newWidgetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - QString colorString = element->attributes.value("owner").toInt() == 0 ? "red":"green"; - UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem,0); + QString colorString = element->attributes.value("owner").toInt() == 0 ? "red" : "green"; + UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem, + 0); textWidget->bottomMargin(14); - textWidget->setStyleSheet("QWidget {background: #EEEEEE; border:none; color:" + colorString + ";}"); + textWidget->setStyleSheet( "QWidget {background: #EEEEEE; border:none; color:" + colorString + ";}"); textWidget->showText(element->attributes.value("task")); - textWidget->document()->setDefaultFont(QFont(QApplication::font().family(),11)); - mpTreeWidget->setItemWidget(newWidgetItem,0,textWidget); + textWidget->document()->setDefaultFont( QFont(QApplication::font().family(), 11)); + mpTreeWidget->setItemWidget(newWidgetItem, 0, textWidget); mpRootWidgetItem->addChild(newWidgetItem); } - else if(element->name == "media"){ + else if (element->name == "media") { createMediaButtonItem(); - QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); - newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/"+ element->attributes.value("mediaType") +".png")); - newWidgetItem->setText(0,element->attributes.value("title")); - newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_MEDIA); - newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); - QString mimeTypeString; + QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem( mpMediaSwitchItem); + newWidgetItem->setIcon(0, QIcon( ":images/teacherGuide/" + element->attributes.value("mediaType") + ".png")); + newWidgetItem->setText(0, element->attributes.value("title")); + newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_MEDIA); + newWidgetItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 11))); + QString mimeTypeString; #ifdef Q_WS_WIN - mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString(); + mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString(); #else - mimeTypeString = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath"); + mimeTypeString = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + element->attributes.value("relativePath"); #endif newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString); - newWidgetItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable); + newWidgetItem->setFlags( Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable); mpRootWidgetItem->addChild(newWidgetItem); QTreeWidgetItem* mediaItem = new QTreeWidgetItem(newWidgetItem); - mediaItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); - UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"),newWidgetItem); + mediaItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_NONE); + UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"), newWidgetItem); newWidgetItem->setExpanded(false); - mpTreeWidget->setItemWidget(mediaItem,0,mediaWidget); + mpTreeWidget->setItemWidget(mediaItem, 0, mediaWidget); } - else if(element->name == "link"){ + else if (element->name == "link") { createMediaButtonItem(); - QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); - newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/link.png")); - newWidgetItem->setText(0,element->attributes.value("title")); - newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_URL); - newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnUrl,QVariant(element->attributes.value("url"))); - newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); + QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem( mpMediaSwitchItem); + newWidgetItem->setIcon(0, QIcon(":images/teacherGuide/link.png")); + newWidgetItem->setText(0, element->attributes.value("title")); + newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_URL); + newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnUrl, QVariant(element->attributes.value("url"))); + newWidgetItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 11))); newWidgetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); mpRootWidgetItem->addChild(newWidgetItem); } @@ -565,20 +578,20 @@ void UBTeacherGuidePresentationWidget::showData(QVector data) void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, int column) { - int associateAction = widget->data(column,tUBTGTreeWidgetItemRole_HasAnAction).toInt(); - if(column == 0 && associateAction != tUBTGActionAssociateOnClickItem_NONE){ - switch(associateAction) - { + int associateAction = widget->data(column, + tUBTGTreeWidgetItemRole_HasAnAction).toInt(); + if (column == 0 && associateAction != tUBTGActionAssociateOnClickItem_NONE) { + switch (associateAction) { case tUBTGActionAssociateOnClickItem_EXPAND: widget->setExpanded(!widget->isExpanded()); - if(widget->isExpanded()) - mpMediaSwitchItem->setText(0,"-"); + if (widget->isExpanded()) + mpMediaSwitchItem->setText(0, "-"); else - mpMediaSwitchItem->setText(0,"+"); + mpMediaSwitchItem->setText(0, "+"); break; case tUBTGActionAssociateOnClickItem_URL: - widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString(); - UBApplication::webController->loadUrl(QUrl(widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString())); + widget->data(column, tUBTGTreeWidgetItemRole_HasAnUrl).toString(); + UBApplication::webController->loadUrl( QUrl( widget->data(column, tUBTGTreeWidgetItemRole_HasAnUrl).toString())); break; case tUBTGActionAssociateOnClickItem_MEDIA: widget->setExpanded(!widget->isExpanded()); @@ -589,11 +602,11 @@ void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, } } - /*************************************************************************** - * class UBTeacherGuidePageZeroEditionWidget * + * class UBTeacherGuidePageZeroWidget * ***************************************************************************/ -UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name): QWidget(parent) +UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name) : + QWidget(parent) , mpLayout(NULL) , mpButtonTitleLayout(NULL) , mpModePushButton(NULL) @@ -622,7 +635,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons , mpSchoolTypeValueLabel(NULL) , mpSeparatorIndex(NULL) , mpLicenceLabel(NULL) - , mpLicenceBox(NULL) + , mpLicenceBox( NULL) , mpLicenceIcon(NULL) , mpLicenceLayout(NULL) , mpSceneItemSessionTitle(NULL) @@ -644,9 +657,9 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpModePushButton->setMaximumWidth(32); mpModePushButton->installEventFilter(this); mpButtonTitleLayout->addWidget(mpModePushButton); - connect(mpModePushButton,SIGNAL(clicked()),this,SLOT(switchToMode())); + connect(mpModePushButton, SIGNAL(clicked()), this, SLOT(switchToMode())); - mpSessionTitle = new UBTGAdaptableText(0,this,"UBTGSessionTitle"); + mpSessionTitle = new UBTGAdaptableText(0, this, "UBTGSessionTitle"); mpSessionTitle->setPlaceHolderText(tr("Type session title here ...")); mpButtonTitleLayout->addWidget(mpSessionTitle); @@ -663,7 +676,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpAuthorsLabel->setStyleSheet(chapterStyle); mpLayout->addWidget(mpAuthorsLabel); - mpAuthors = new UBTGAdaptableText(0,this); + mpAuthors = new UBTGAdaptableText(0, this); mpAuthors->setObjectName("UBTGZeroPageInputText"); mpAuthors->setPlaceHolderText(tr("Type authors here ...")); mpLayout->addWidget(mpAuthors); @@ -687,7 +700,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpObjectivesLabel->setStyleSheet(chapterStyle); mpLayout->addWidget(mpObjectivesLabel); - mpObjectives = new UBTGAdaptableText(0,this); + mpObjectives = new UBTGAdaptableText(0, this); mpObjectives->setObjectName("UBTGZeroPageInputText"); mpObjectives->setPlaceHolderText(tr("Type objectives here...")); mpLayout->addWidget(mpObjectives); @@ -708,7 +721,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpKeywordsLabel->setText(tr("Keywords:")); mpKeywordsLabel->setStyleSheet(chapterStyle); mpLayout->addWidget(mpKeywordsLabel); - mpKeywords = new UBTGAdaptableText(0,this); + mpKeywords = new UBTGAdaptableText(0, this); mpKeywords->setPlaceHolderText(tr("Type keywords here ...")); mpLayout->addWidget(mpKeywords); @@ -720,7 +733,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpSchoolLevelBox = new QComboBox(this); mpSchoolLevelBox->setMinimumHeight(22); mpSchoolLevelBox->setObjectName("DockPaletteWidgetComboBox"); - connect(mpSchoolLevelBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(onSchoolLevelChanged(QString))); + connect(mpSchoolLevelBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(onSchoolLevelChanged(QString))); mpLayout->addWidget(mpSchoolLevelBox); mpSchoolLevelValueLabel = new QLabel(this); mpLayout->addWidget(mpSchoolLevelValueLabel); @@ -771,8 +784,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpLayout->addLayout(mpLicenceLayout); mpLayout->addStretch(1); - - connect(UBApplication::boardController,SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); fillComboBoxes(); } @@ -812,7 +824,7 @@ UBTeacherGuidePageZeroWidget::~UBTeacherGuidePageZeroWidget() bool UBTeacherGuidePageZeroWidget::eventFilter(QObject* object, QEvent* event) { Q_UNUSED(object); - if(event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave) + if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave) return true; return false; } @@ -821,7 +833,7 @@ void UBTeacherGuidePageZeroWidget::fillComboBoxes() { QString parametersConfigFilePath = UBSettings::settings()->applicationCustomizationDirectory() + "/teacherGuide/indexingParameters.xml"; QFile parametersFile(parametersConfigFilePath); - if(!parametersFile.exists()){ + if (!parametersFile.exists()) { qCritical() << "UBTeacherGuidePageZeroEditionWidget fillComboBoxes file not found " << parametersConfigFilePath; return; } @@ -833,48 +845,54 @@ void UBTeacherGuidePageZeroWidget::fillComboBoxes() QDomElement rootElement = doc.elementsByTagName("teacherGuide").at(0).toElement(); QDomNodeList subjects = rootElement.elementsByTagName("subjects"); - for(int baseLevelCounter = 0; baseLevelCounter < subjects.count(); baseLevelCounter += 1){ + for (int baseLevelCounter = 0; baseLevelCounter < subjects.count(); baseLevelCounter += 1) { QDomNode subjectsForBaseLevel = subjects.at(baseLevelCounter); QDomNodeList subjectsList = subjectsForBaseLevel.childNodes(); QStringList subjectsRelatedToBaseLevel; - for(int j = 0; j < subjectsList.count(); j += 1){ + for (int j = 0; j < subjectsList.count(); j += 1) { subjectsRelatedToBaseLevel.append(subjectsList.at(j).toElement().attribute("label")); } - mSubjects.insert(subjectsForBaseLevel.toElement().attribute("baseLevel"),subjectsRelatedToBaseLevel); + mSubjects.insert( subjectsForBaseLevel.toElement().attribute("baseLevel"), subjectsRelatedToBaseLevel); } QDomNodeList gradeLevels = rootElement.elementsByTagName("gradeLevels").at(0).childNodes(); - for(int i=0; iaddItem(gradeLevels.at(i).toElement().attribute("label")); + for (int i = 0; i < gradeLevels.count(); i += 1) { + mGradeLevelsMap.insert(gradeLevels.at(i).toElement().attribute("label"), gradeLevels.at(i).toElement().attribute("baseLevel")); + mpSchoolLevelBox->addItem( gradeLevels.at(i).toElement().attribute("label")); } - QDomNodeList types = rootElement.elementsByTagName("types").at(0).childNodes(); - for(int i=0; iaddItem(types.at(i).toElement().attribute("label")); parametersFile.close(); QStringList licences; - licences << tr("Attribution CC BY") << tr("Attribution-NoDerivs CC BY-ND") << tr("Attribution-ShareAlike CC BY-SA") << tr("Attribution-NonCommercial CC BY-NC") << tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND") << tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA") << tr("Public domain") << tr("Copyright"); + licences << tr("Attribution CC BY") << tr("Attribution-NoDerivs CC BY-ND") + << tr("Attribution-ShareAlike CC BY-SA") + << tr("Attribution-NonCommercial CC BY-NC") + << tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND") + << tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA") + << tr("Public domain") << tr("Copyright"); mpLicenceBox->addItems(licences); QStringList licenceIconList; - licenceIconList << ":images/licenses/ccby.png" << ":images/licenses/ccbynd.png" << ":images/licenses/ccbysa.png" << ":images/licenses/ccbync.png" << ":images/licenses/ccbyncnd.png" << ":images/licenses/ccbyncsa.png"; - for(int i = 0; i < licenceIconList.count(); i+=1) - mpLicenceBox->setItemData(i,licenceIconList.at(i)); + licenceIconList << ":images/licenses/ccby.png" + << ":images/licenses/ccbynd.png" << ":images/licenses/ccbysa.png" + << ":images/licenses/ccbync.png" << ":images/licenses/ccbyncnd.png" + << ":images/licenses/ccbyncsa.png"; + for (int i = 0; i < licenceIconList.count(); i += 1) + mpLicenceBox->setItemData(i, licenceIconList.at(i)); } void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel) { QStringList subjects = mSubjects.value(mGradeLevelsMap.value(schoolLevel)); mpSchoolSubjectsBox->clear(); - if(subjects.count()){ + if (subjects.count()) { mpSchoolSubjectsItemLabel->setEnabled(true); mpSchoolSubjectsBox->setEnabled(true); mpSchoolSubjectsBox->addItems(subjects); - } - else{ + } else { mpSchoolSubjectsItemLabel->setDisabled(true); mpSchoolSubjectsBox->setDisabled(true); } @@ -883,17 +901,17 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel) void UBTeacherGuidePageZeroWidget::onActiveSceneChanged() { UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - if(documentProxy && UBApplication::boardController->currentPage() == 0){ + if (documentProxy && UBApplication::boardController->currentPage() == 0) { QDateTime creationDate = documentProxy->documentDate(); - mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate)); + mpCreationLabel->setText( tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate)); QDateTime updatedDate = documentProxy->lastUpdate(); - mpLastModifiedLabel->setText(tr("Updated the:\n") + updatedDate.toString(Qt::DefaultLocaleShortDate)); + mpLastModifiedLabel->setText( tr("Updated the:\n") + updatedDate.toString(Qt::DefaultLocaleShortDate)); loadData(); updateSceneTitle(); } } -void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event ) +void UBTeacherGuidePageZeroWidget::hideEvent(QHideEvent * event) { persistData(); QWidget::hideEvent(event); @@ -902,56 +920,56 @@ void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event ) void UBTeacherGuidePageZeroWidget::loadData() { UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - mpSessionTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); - mpAuthors->setText(documentProxy->metaData(UBSettings::sessionAuthors).toString()); - mpObjectives->setText(documentProxy->metaData(UBSettings::sessionObjectives).toString()); - mpKeywords->setText(documentProxy->metaData(UBSettings::sessionKeywords).toString()); + mpSessionTitle->setText( documentProxy->metaData(UBSettings::sessionTitle).toString()); + mpAuthors->setText( documentProxy->metaData(UBSettings::sessionAuthors).toString()); + mpObjectives->setText( documentProxy->metaData(UBSettings::sessionObjectives).toString()); + mpKeywords->setText( documentProxy->metaData(UBSettings::sessionKeywords).toString()); int currentIndex = mpSchoolLevelBox->findText(documentProxy->metaData(UBSettings::sessionGradeLevel).toString()); - mpSchoolLevelBox->setCurrentIndex((currentIndex!=-1) ? currentIndex : 0); + mpSchoolLevelBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); currentIndex = mpSchoolSubjectsBox->findText(documentProxy->metaData(UBSettings::sessionSubjects).toString()); - mpSchoolSubjectsBox->setCurrentIndex((currentIndex!=-1) ? currentIndex : 0); + mpSchoolSubjectsBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); currentIndex = mpSchoolTypeBox->findText(documentProxy->metaData(UBSettings::sessionType).toString()); - mpSchoolTypeBox->setCurrentIndex((currentIndex!=-1) ? currentIndex : 0); + mpSchoolTypeBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); currentIndex = mpLicenceBox->findText(documentProxy->metaData(UBSettings::sessionLicence).toString()); - mpLicenceBox->setCurrentIndex((currentIndex!=-1) ? currentIndex : 0); + mpLicenceBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); } void UBTeacherGuidePageZeroWidget::persistData() { // check necessary because at document closing hide event is send after boardcontroller set // to NULL - if(UBApplication::boardController){ + if (UBApplication::boardController) { UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text()); + documentProxy->setMetaData(UBSettings::sessionTitle, mpSessionTitle->text()); documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text()); - documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text()); - documentProxy->setMetaData(UBSettings::sessionKeywords,mpKeywords->text()); - documentProxy->setMetaData(UBSettings::sessionGradeLevel,mpSchoolLevelBox->currentText()); - documentProxy->setMetaData(UBSettings::sessionSubjects,mpSchoolSubjectsBox->currentText()); - documentProxy->setMetaData(UBSettings::sessionType,mpSchoolTypeBox->currentText()); - documentProxy->setMetaData(UBSettings::sessionLicence,mpLicenceBox->currentText()); + documentProxy->setMetaData(UBSettings::sessionObjectives, mpObjectives->text()); + documentProxy->setMetaData(UBSettings::sessionKeywords, mpKeywords->text()); + documentProxy->setMetaData(UBSettings::sessionGradeLevel, mpSchoolLevelBox->currentText()); + documentProxy->setMetaData(UBSettings::sessionSubjects, mpSchoolSubjectsBox->currentText()); + documentProxy->setMetaData(UBSettings::sessionType, mpSchoolTypeBox->currentText()); + documentProxy->setMetaData(UBSettings::sessionLicence, mpLicenceBox->currentText()); } } void UBTeacherGuidePageZeroWidget::updateSceneTitle() { QString sessionTitle = mpSessionTitle->text(); - if(!sessionTitle.isEmpty()) + if (!sessionTitle.isEmpty()) UBApplication::boardController->activeScene()->textForObjectName(mpSessionTitle->text()); } void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) { - if(mode == tUBTGZeroPageMode_EDITION){ + if (mode == tUBTGZeroPageMode_EDITION) { QString inputStyleSheet("QTextEdit { background: white; border-radius: 10px; border: 2px;}"); mpModePushButton->hide(); mpSessionTitle->setReadOnly(false); mpSessionTitle->setStyleSheet(inputStyleSheet); - QFont titleFont(QApplication::font().family(),11,-1); + QFont titleFont(QApplication::font().family(), 11, -1); mpSessionTitle->document()->setDefaultFont(titleFont); mpAuthors->setReadOnly(false); mpAuthors->setStyleSheet(inputStyleSheet); @@ -969,13 +987,13 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) mpLicenceValueLabel->hide(); mpLicenceBox->show(); } - else{ - QString inputStyleSheet("QTextEdit { background: transparent; border: none;}"); + else { + QString inputStyleSheet( "QTextEdit { background: transparent; border: none;}"); mpModePushButton->show(); mpSessionTitle->showText(mpSessionTitle->text()); mpSessionTitle->setStyleSheet(inputStyleSheet); updateSceneTitle(); - QFont titleFont(QApplication::font().family(),14,1); + QFont titleFont(QApplication::font().family(), 14, 1); mpSessionTitle->document()->setDefaultFont(titleFont); mpAuthors->setStyleSheet(inputStyleSheet); mpAuthors->setTextColor(QColor(Qt::black)); @@ -997,7 +1015,7 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) mpSchoolTypeBox->hide(); mpLicenceValueLabel->setText(mpLicenceBox->currentText()); QString licenceIconPath = mpLicenceBox->itemData(mpLicenceBox->currentIndex()).toString(); - if(!licenceIconPath.isEmpty()){ + if (!licenceIconPath.isEmpty()) { mpLicenceIcon->setPixmap(QPixmap(licenceIconPath)); mpLicenceIcon->show(); } @@ -1010,85 +1028,101 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) QVector UBTeacherGuidePageZeroWidget::getData() { - QVectorresult; + QVector result; tUBGEElementNode* elementNode = new tUBGEElementNode(); elementNode->name = "sessionTitle"; - elementNode->attributes.insert("value",mpSessionTitle->text()); + elementNode->attributes.insert("value", mpSessionTitle->text()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "authors"; - elementNode->attributes.insert("value",mpAuthors->text()); + elementNode->attributes.insert("value", mpAuthors->text()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "creationDate"; - elementNode->attributes.insert("value",mpCreationLabel->text()); + elementNode->attributes.insert("value", mpCreationLabel->text()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "lastModifiedDate"; - elementNode->attributes.insert("value",mpLastModifiedLabel->text()); + elementNode->attributes.insert("value", mpLastModifiedLabel->text()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "goals"; - elementNode->attributes.insert("value",mpObjectives->text()); + elementNode->attributes.insert("value", mpObjectives->text()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "keywords"; - elementNode->attributes.insert("value",mpKeywords->text()); + elementNode->attributes.insert("value", mpKeywords->text()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "schoolLevel"; - elementNode->attributes.insert("value",mpSchoolLevelBox->currentText()); + elementNode->attributes.insert("value", mpSchoolLevelBox->currentText()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "schoolBranch"; - elementNode->attributes.insert("value",mpSchoolSubjectsBox->currentText()); + elementNode->attributes.insert("value", mpSchoolSubjectsBox->currentText()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "schoolType"; - elementNode->attributes.insert("value",mpSchoolTypeBox->currentText()); + elementNode->attributes.insert("value", mpSchoolTypeBox->currentText()); result << elementNode; elementNode = new tUBGEElementNode(); elementNode->name = "licence"; - elementNode->attributes.insert("value",mpLicenceBox->currentText()); + elementNode->attributes.insert("value", mpLicenceBox->currentText()); result << elementNode; return result; } +bool UBTeacherGuidePageZeroWidget::isModified() +{ + bool result = false; + result |= mpSessionTitle->text().length() > 0; + result |= mpAuthors->text().length() > 0; + result |= mpObjectives->text().length() > 0; + result |= mpKeywords->text().length() > 0; + result |= mpSchoolLevelBox->currentIndex() > 0; + result |= mpSchoolSubjectsBox->currentIndex() > 0; + result |= mpSchoolTypeBox->currentIndex() > 0; + result |= mpLicenceBox->currentIndex() > 0; + return result; +} + /*************************************************************************** * class UBTeacherGuideWidget * ***************************************************************************/ -UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget* parent, const char* name): QStackedWidget(parent) +UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget* parent, const char* name) : + QStackedWidget(parent) , mpPageZeroWidget(NULL) , mpEditionWidget(NULL) , mpPresentationWidget(NULL) { setObjectName(name); - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ + if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) { mpPageZeroWidget = new UBTeacherGuidePageZeroWidget(this); addWidget(mpPageZeroWidget); } - if(UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){ + if (UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()) { mpEditionWidget = new UBTeacherGuideEditionWidget(this); addWidget(mpEditionWidget); mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); addWidget(mpPresentationWidget); } - connect(UBApplication::boardController->controlView(),SIGNAL(clickOnBoard()),this,SLOT(showPresentationMode())); + connect(UBApplication::boardController->controlView(), + SIGNAL(clickOnBoard()), this, SLOT(showPresentationMode())); connectToStylusPalette(); - connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged())); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, + SLOT(onActiveSceneChanged())); } - UBTeacherGuideWidget::~UBTeacherGuideWidget() { DELETEPTR(mpPageZeroWidget); @@ -1096,32 +1130,32 @@ UBTeacherGuideWidget::~UBTeacherGuideWidget() DELETEPTR(mpPresentationWidget); } - void UBTeacherGuideWidget::onActiveSceneChanged() { - if(UBApplication::boardController->currentPage() == 0){ + if (UBApplication::boardController->currentPage() == 0) { setCurrentWidget(mpPageZeroWidget); mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_EDITION); - }else + } + else setCurrentWidget(mpEditionWidget); } void UBTeacherGuideWidget::connectToStylusPalette() { - if(UBApplication::boardController->paletteManager()) - connect(UBApplication::boardController->paletteManager()->stylusPalette(),SIGNAL(itemOnActionPaletteChanged()),this,SLOT(showPresentationMode())); + if (UBApplication::boardController->paletteManager()) + connect( UBApplication::boardController->paletteManager()->stylusPalette(), SIGNAL(itemOnActionPaletteChanged()), this, SLOT(showPresentationMode())); else - QTimer::singleShot(100,this,SLOT(connectToStylusPalette())); + QTimer::singleShot(100, this, SLOT(connectToStylusPalette())); } void UBTeacherGuideWidget::showPresentationMode() { - if(currentWidget()==mpPageZeroWidget){ + if (currentWidget() == mpPageZeroWidget) { mCurrentData = mpPageZeroWidget->getData(); mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_PRESENTATION); } - else if(currentWidget()==mpEditionWidget){ + else if (currentWidget() == mpEditionWidget) { mCurrentData = mpEditionWidget->getData(); mpPresentationWidget->showData(mCurrentData); setCurrentWidget(mpPresentationWidget); @@ -1130,9 +1164,17 @@ void UBTeacherGuideWidget::showPresentationMode() void UBTeacherGuideWidget::changeMode() { - if(currentWidget() == mpEditionWidget) + if (currentWidget() == mpEditionWidget) setCurrentWidget(mpPresentationWidget); else setCurrentWidget(mpEditionWidget); } + +bool UBTeacherGuideWidget::isModified() +{ + if (currentWidget() == mpPageZeroWidget) + return mpPageZeroWidget->isModified(); + else + return mpEditionWidget->isModified(); +} diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h index ecd22084..16ac64e5 100644 --- a/src/gui/UBTeacherGuideWidget.h +++ b/src/gui/UBTeacherGuideWidget.h @@ -50,6 +50,8 @@ public: void load(QString element); QVector save(int pageIndex); + bool isModified(); + public slots: void onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement* element = 0); void onActiveSceneChanged(); @@ -124,6 +126,7 @@ public: ~UBTeacherGuidePageZeroWidget(); QVector getData(); + bool isModified(); public slots: @@ -198,6 +201,8 @@ public: explicit UBTeacherGuideWidget(QWidget* parent = 0, const char* name="UBTeacherGuideWidget"); ~UBTeacherGuideWidget(); + bool isModified(); + public slots: void changeMode(); void showPresentationMode(); From 3f4d3f625989d3fc5411e3a7b265588a108a3773 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 26 Jul 2012 11:18:33 +0200 Subject: [PATCH 4/5] improved gui of teacher bar --- src/gui/UBTeacherGuideWidget.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 3d5241fa..6608d402 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -105,6 +105,7 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpLayout->addWidget(mpSeparator); mpTreeWidget = new QTreeWidget(this); + mpTreeWidget->setStyleSheet("selection-background-color:transparent; padding-bottom:5px; padding-top:5px;"); mpLayout->addWidget(mpTreeWidget); mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); @@ -118,6 +119,7 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch); mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed); mpTreeWidget->header()->setDefaultSectionSize(18); + mpTreeWidget->setSelectionMode(QAbstractItemView::NoSelection); connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int))); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); @@ -215,16 +217,13 @@ QVector UBTeacherGuideEditionWidget::save(int pageIndex) children << getChildrenList(mpAddALinkItem); foreach(QTreeWidgetItem* widgetItem, children) { - tUBGEElementNode* node = - dynamic_cast(mpTreeWidget->itemWidget( - widgetItem, 0))->saveData(); + tUBGEElementNode* node = dynamic_cast(mpTreeWidget->itemWidget( widgetItem, 0))->saveData(); if (node) { data = new tIDataStorage(); data->name = node->name; data->type = eElementType_UNIQUE; foreach(QString currentKey, node->attributes.keys()) - data->attributes.insert(currentKey, - node->attributes.value(currentKey)); + data->attributes.insert(currentKey, node->attributes.value(currentKey)); result << data; } } @@ -293,9 +292,7 @@ QVector UBTeacherGuideEditionWidget::getData() children << getChildrenList(mpAddALinkItem); result << getPageAndCommentData(); foreach(QTreeWidgetItem* widgetItem, children) { - tUBGEElementNode* node = - dynamic_cast(mpTreeWidget->itemWidget( - widgetItem, 0))->saveData(); + tUBGEElementNode* node = dynamic_cast(mpTreeWidget->itemWidget( widgetItem, 0))->saveData(); if (node) result << node; } @@ -346,14 +343,13 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int widget->setExpanded(false); widget->setExpanded(true); } - } else if (column == 1 - && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None) { + } + else if (column == 1 && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None) { UBTGMediaWidget* media = dynamic_cast(mpTreeWidget->itemWidget(widget, 0)); if (media) media->removeSource(); int index = mpTreeWidget->currentIndex().row(); - QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild( - index); + QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild(index); delete toBeDeletedWidgetItem; } } @@ -447,12 +443,14 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare mpLayout->addWidget(mpTreeWidget); mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); + mpTreeWidget->setSelectionMode(QAbstractItemView::NoSelection); mpTreeWidget->setDragEnabled(true); mpTreeWidget->setRootIsDecorated(false); mpTreeWidget->setIndentation(0); mpTreeWidget->setDropIndicatorShown(false); mpTreeWidget->header()->close(); mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + mpTreeWidget->setStyleSheet("selection-background-color:transparent; padding-bottom:5px; padding-top:5px; "); connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int))); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); } @@ -495,7 +493,7 @@ void UBTeacherGuidePresentationWidget::cleanData() void UBTeacherGuidePresentationWidget::onActiveSceneChanged() { cleanData(); - mpPageNumberLabel->setText( tr("Page: %0").arg(UBApplication::boardController->currentPage())); + mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); if (mpDocumentTitle) mpDocumentTitle->setText( documentProxy->metaData(UBSettings::sessionTitle).toString()); @@ -529,8 +527,7 @@ void UBTeacherGuidePresentationWidget::showData( QVector data newWidgetItem->setText(0, element->attributes.value("task")); newWidgetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); QString colorString = element->attributes.value("owner").toInt() == 0 ? "red" : "green"; - UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem, - 0); + UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem, 0); textWidget->bottomMargin(14); textWidget->setStyleSheet( "QWidget {background: #EEEEEE; border:none; color:" + colorString + ";}"); textWidget->showText(element->attributes.value("task")); From bc7523b81bef0405e2213d4fdab100c8c5da5566 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Jul 2012 12:49:05 +0200 Subject: [PATCH 5/5] some audio drop zone fixes in 'ass sons' widget --- .../interactivities/Ass sons.wgt/js/script.js | 8 ++++---- .../Ass sons.wgt/locales/fr/js/script.js | 12 ++++++------ .../Ass sons.wgt/locales/ru/js/script.js | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/resources/library/interactivities/Ass sons.wgt/js/script.js b/resources/library/interactivities/Ass sons.wgt/js/script.js index 796dc06c..c93936a9 100644 --- a/resources/library/interactivities/Ass sons.wgt/js/script.js +++ b/resources/library/interactivities/Ass sons.wgt/js/script.js @@ -700,11 +700,11 @@ function addContainer(){ var close = $("
").appendTo(container); var number = $("
"+ ($(".cont").size() + 1) +"
").appendTo(sub_container); var text = $("
").appendTo(sub_container); - text.attr("ondragenter", "return false;") - .attr("ondragleave", "$(this).removeClass('gray'); return false;") - .attr("ondragover", "$(this).addClass('gray'); return false;") - .attr("ondrop", "$(this).removeClass('gray'); return onDropAudio(this,event);"); var audio_block = $("
").appendTo(text); + audio_block.attr("ondragenter", "return false;") + .attr("ondragleave", "$(this).removeClass('audio_gray'); return false;") + .attr("ondragover", "$(this).addClass('audio_gray'); return false;") + .attr("ondrop", "$(this).removeClass('audio_gray'); return onDropAudio(this,event);"); $("
").appendTo(audio_block); $("
").appendTo(audio_block); var source = $("").attr("src", ""); diff --git a/resources/library/interactivities/Ass sons.wgt/locales/fr/js/script.js b/resources/library/interactivities/Ass sons.wgt/locales/fr/js/script.js index cc1fd6cf..7ba4904d 100644 --- a/resources/library/interactivities/Ass sons.wgt/locales/fr/js/script.js +++ b/resources/library/interactivities/Ass sons.wgt/locales/fr/js/script.js @@ -685,11 +685,11 @@ function addContainer(){ var close = $("
").appendTo(container); var number = $("
"+ ($(".cont").size() + 1) +"
").appendTo(sub_container); var text = $("
").appendTo(sub_container); - text.attr("ondragenter", "return false;") - .attr("ondragleave", "$(this).removeClass('gray'); return false;") - .attr("ondragover", "$(this).addClass('gray'); return false;") - .attr("ondrop", "$(this).removeClass('gray'); return onDropAudio(this,event);"); var audio_block = $("
").appendTo(text); + audio_block.attr("ondragenter", "return false;") + .attr("ondragleave", "$(this).removeClass('audio_gray'); return false;") + .attr("ondragover", "$(this).addClass('audio_gray'); return false;") + .attr("ondrop", "$(this).removeClass('audio_gray'); return onDropAudio(this,event);"); $("
").appendTo(audio_block); $("
").appendTo(audio_block); var source = $("").attr("src", ""); @@ -850,8 +850,8 @@ function onDropAudio(obj, event) { textData = stringToXML(textData); var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent; - if(tmp_type.substr(0, 5) == "audio"){ - var audio_block = $(obj).find(".audio_block"); + if(tmp_type.substr(0, 5) == "audio"){ + var audio_block = $(obj); $(obj).find("audio").remove(); audio_block.find(":first-child").removeClass("stop").addClass("play"); var source = $("").attr("src", "../../" + tmp); diff --git a/resources/library/interactivities/Ass sons.wgt/locales/ru/js/script.js b/resources/library/interactivities/Ass sons.wgt/locales/ru/js/script.js index d10aefee..f8ae3dfb 100644 --- a/resources/library/interactivities/Ass sons.wgt/locales/ru/js/script.js +++ b/resources/library/interactivities/Ass sons.wgt/locales/ru/js/script.js @@ -685,11 +685,11 @@ function addContainer(){ var close = $("
").appendTo(container); var number = $("
"+ ($(".cont").size() + 1) +"
").appendTo(sub_container); var text = $("
").appendTo(sub_container); - text.attr("ondragenter", "return false;") - .attr("ondragleave", "$(this).removeClass('gray'); return false;") - .attr("ondragover", "$(this).addClass('gray'); return false;") - .attr("ondrop", "$(this).removeClass('gray'); return onDropAudio(this,event);"); var audio_block = $("
").appendTo(text); + audio_block.attr("ondragenter", "return false;") + .attr("ondragleave", "$(this).removeClass('audio_gray'); return false;") + .attr("ondragover", "$(this).addClass('audio_gray'); return false;") + .attr("ondrop", "$(this).removeClass('audio_gray'); return onDropAudio(this,event);"); $("
").appendTo(audio_block); $("
").appendTo(audio_block); var source = $("").attr("src", ""); @@ -851,7 +851,7 @@ function onDropAudio(obj, event) { var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent; if(tmp_type.substr(0, 5) == "audio"){ - var audio_block = $(obj).find(".audio_block"); + var audio_block = $(obj); $(obj).find("audio").remove(); audio_block.find(":first-child").removeClass("stop").addClass("play"); var source = $("").attr("src", "../../" + tmp);