diff --git a/release.linux.sh b/release.linux.sh index 18ae40d6..79bdc17c 100755 --- a/release.linux.sh +++ b/release.linux.sh @@ -111,8 +111,8 @@ else LAST_COMMITED_VERSION="`git describe $(git rev-list --tags --max-count=1)`" if [ "v$VERSION" != "$LAST_COMMITED_VERSION" ]; then echo creating a tag with the version $VERSION -# git tag -a "v$VERSION" -m "Generating setup for v$VERSION" -# git push origin --tags + git tag -a "v$VERSION" -m "Generating setup for v$VERSION" + git push origin --tags fi fi @@ -353,4 +353,4 @@ cd $RELEASE_DIR rm ../../../install/linux/Open-Sankore.tar.gz tar cvzf ../../../install/linux/Open-Sankore.tar.gz Open-Sankore.$VERSION -C . -notify-send "Open-Sankore" "tar.gz Build done" \ No newline at end of file +notify-send "Open-Sankore" "tar.gz Build done" diff --git a/resources/customizations/teacherGuide/indexingParameters.xml b/resources/customizations/teacherGuide/indexingParameters.xml new file mode 100644 index 00000000..09c4917a --- /dev/null +++ b/resources/customizations/teacherGuide/indexingParameters.xml @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/style.qss b/resources/style.qss index 38eeecbc..4dcd73ae 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -254,8 +254,7 @@ UBTGAdaptableText#UBTGPresentationComment border : none; } -QFrame#UBTGEditionSeparator, -QFrame#UBTGPresentationSepartor +QFrame#UBTGSeparator { background-color: #cccccc; } diff --git a/src/adaptors/UBCFFSubsetAdaptor.cpp b/src/adaptors/UBCFFSubsetAdaptor.cpp index cb08d742..19e8a016 100644 --- a/src/adaptors/UBCFFSubsetAdaptor.cpp +++ b/src/adaptors/UBCFFSubsetAdaptor.cpp @@ -41,8 +41,6 @@ #include "core/UBApplication.h" #include "QFile" -#include - #include "core/memcheck.h" //#include "qtlogger.h" diff --git a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp index 10ee3cc4..1608dece 100644 --- a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp +++ b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp @@ -97,7 +97,7 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy) xmlWriter.writeTextElement(nsDc, "title", proxy->metaData(UBSettings::documentName).toString()); xmlWriter.writeTextElement(nsDc, "type", proxy->metaData(UBSettings::documentGroupName).toString()); - xmlWriter.writeTextElement(nsDc, "date", QDate::currentDate().toString("yyyy-MM-dd")); + xmlWriter.writeTextElement(nsDc, "date", proxy->metaData(UBSettings::documentDate).toString()); xmlWriter.writeTextElement(nsDc, "format", "image/svg+xml"); // introduced in UB 4.2 @@ -108,8 +108,7 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy) xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "size", QString("%1x%2").arg(width).arg(height)); // introduced in UB 4.4 - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", proxy->metaData(UBSettings::documentUpdatedAt).toString()); - + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTimeUtc())); // introduced in OpenSankore 1.40.00 xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTitle,proxy->metaData(UBSettings::sessionTitle).toString()); xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTarget,proxy->metaData(UBSettings::sessionTarget).toString()); @@ -278,13 +277,21 @@ QMap UBMetadataDcSubsetAdaptor::load(QString pPath) metadata.insert(UBSettings::documentSize, QVariant(docSize)); } - if (!updatedAtFound) - { - metadata.insert(UBSettings::documentUpdatedAt, date + "T00:00:00Z"); + // this is necessary to update the old files date + QString dateString = metadata.value(UBSettings::documentDate).toString(); + if(dateString.length() < 10){ + metadata.remove(UBSettings::documentDate); + metadata.insert(UBSettings::documentDate,dateString+"T00:00:00Z"); + } + + if (!updatedAtFound) { + metadata.insert(UBSettings::documentUpdatedAt, dateString); } metadata.insert(UBSettings::documentDate, QVariant(date)); + + return metadata; } diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 8d0e1952..59efb4e5 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -239,7 +239,9 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, } doc->setMetaData(UBSettings::documentVersion, UBSettings::currentFileVersion); - doc->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); + QString currentDate = UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()); + doc->setMetaData(UBSettings::documentUpdatedAt,currentDate); + doc->setMetaData(UBSettings::documentDate,currentDate); if (withEmptyPage) createDocumentSceneAt(doc, 0); diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index acc5495e..30b3f4d8 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -509,7 +509,6 @@ void UBDocumentController::openSelectedItem() if (proxy && isOKToOpenDocument(proxy)) { - //mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex()); UBApplication::applicationController->showBoard(); } } @@ -1639,4 +1638,4 @@ int UBDocumentController::getSelectedItemIndex() return thumb->sceneIndex(); } else return -1; -} \ No newline at end of file +} diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index 5b1daa2b..76a8d42e 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -34,7 +34,6 @@ class UBDocumentGroupTreeItem; class UBDocumentProxyTreeItem; class UBMainWindow; class UBDocumentToolsPalette; -//class UBKeyboardPalette; class UBDocumentController : public QObject { @@ -77,8 +76,6 @@ class UBDocumentController : public QObject void paste(); void focusChanged(QWidget *old, QWidget *current); -// void showKeyboard(bool show); - protected: virtual void setupViews(); virtual void setupToolbar(); diff --git a/src/document/UBDocumentProxy.cpp b/src/document/UBDocumentProxy.cpp index add97241..67f11b0f 100644 --- a/src/document/UBDocumentProxy.cpp +++ b/src/document/UBDocumentProxy.cpp @@ -295,13 +295,18 @@ QString UBDocumentProxy::sessionAuthors() return QString(); } -QString UBDocumentProxy::documentDate() +QDateTime UBDocumentProxy::documentDate() { - if(mMetaDatas.contains(UBSettings::documentDate)){ - return metaData(UBSettings::documentDate).toString(); - }else{ - return QString(); - } + if(mMetaDatas.contains(UBSettings::documentDate)) + return UBStringUtils::fromUtcIsoDate(metaData(UBSettings::documentDate).toString()); + return QDateTime::currentDateTime(); +} + +QDateTime UBDocumentProxy::lastUpdate() +{ + if(mMetaDatas.contains(UBSettings::documentUpdatedAt)) + return UBStringUtils::fromUtcIsoDate(metaData(UBSettings::documentUpdatedAt).toString()); + return QDateTime().currentDateTime(); } bool UBDocumentProxy::isModified() const diff --git a/src/document/UBDocumentProxy.h b/src/document/UBDocumentProxy.h index 6686a4f3..b35a62a5 100644 --- a/src/document/UBDocumentProxy.h +++ b/src/document/UBDocumentProxy.h @@ -59,7 +59,9 @@ class UBDocumentProxy : public QObject QString sessionTopic(); void setSessionAuthor(const QString& authors); QString sessionAuthors(); - QString documentDate(); + QDateTime documentDate(); + + QDateTime lastUpdate(); QSize defaultDocumentSize() const; diff --git a/src/frameworks/UBStringUtils.cpp b/src/frameworks/UBStringUtils.cpp index 7e014b41..8005b284 100644 --- a/src/frameworks/UBStringUtils.cpp +++ b/src/frameworks/UBStringUtils.cpp @@ -105,6 +105,11 @@ QString UBStringUtils::toUtcIsoDateTime(const QDateTime& dateTime) return dateTime.toUTC().toString(Qt::ISODate) + "Z"; } +QDateTime UBStringUtils::fromUtcIsoDate(const QString& dateString) +{ + return QDateTime::fromString(dateString,Qt::ISODate).toLocalTime(); +} + diff --git a/src/frameworks/UBStringUtils.h b/src/frameworks/UBStringUtils.h index 6386f8ba..581332df 100644 --- a/src/frameworks/UBStringUtils.h +++ b/src/frameworks/UBStringUtils.h @@ -33,6 +33,7 @@ class UBStringUtils static QString toCanonicalUuid(const QUuid& uuid); static QString toUtcIsoDateTime(const QDateTime& dateTime); + static QDateTime fromUtcIsoDate(const QString& dateString); }; diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 8d770c64..d6ca56f2 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -19,10 +19,12 @@ #include #include #include +#include #include "UBTeacherGuideWidget.h" #include "core/UBApplication.h" +#include "core/UBPersistenceManager.h" #include "globals/UBGlobals.h" @@ -35,6 +37,9 @@ #include "web/UBWebController.h" +#include "document/UBDocumentProxy.h" +#include "document/UBDocumentController.h" + #define UBTG_SEPARATOR_FIXED_HEIGHT 3 @@ -81,7 +86,7 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpLayout->addWidget(mpComment); mpSeparator = new QFrame(this); - mpSeparator->setObjectName("UBTGEditionSeparator"); + mpSeparator->setObjectName("UBTGSeparator"); mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); mpLayout->addWidget(mpSeparator); @@ -308,7 +313,7 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare mpSeparator = new QFrame(this); mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); - mpSeparator->setObjectName("UBTGPresentationSepartor"); + mpSeparator->setObjectName("UBTGSepartor"); mpLayout->addWidget(mpSeparator); mpTreeWidget = new QTreeWidget(this); @@ -406,7 +411,6 @@ void UBTeacherGuidePresentationWidget::showData(QVector data) mpRootWidgetItem->addChild(newWidgetItem); QTreeWidgetItem* mediaItem = new QTreeWidgetItem(newWidgetItem); - //mediaItem->setBackground(0,QBrush(QColor("#EEEEEF"))); mediaItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"),newWidgetItem); newWidgetItem->setExpanded(false); @@ -451,21 +455,402 @@ void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, } } + +/*************************************************************************** + * class UBTeacherGuidePageZeroEditionWidget * + ***************************************************************************/ +UBTeacherGuidePageZeroEditionWidget::UBTeacherGuidePageZeroEditionWidget(QWidget* parent, const char* name): QWidget(parent) + , mpLayout(NULL) + , mpButtonTitleLayout(NULL) + , mpModePushButton(NULL) + , mpPageNumberLabel(NULL) + , mpSessionTitle(NULL) + , mpSeparatorSessionTitle(NULL) + , mpAuthorsLabel(NULL) + , mpAuthors(NULL) + , mpSeparatorAuthors(NULL) + , mpCreationLabel(NULL) + , mpLastModifiedLabel(NULL) + , mpGoalsLabel(NULL) + , mpGoals(NULL) + , mpSeparatorGoals(NULL) + , mpIndexLabel(NULL) + , mpKeywordsLabel(NULL) + , mpKeywords(NULL) + , mpSchoolLevelItemLabel(NULL) + , mpSchoolLevelBox(NULL) + , mpSchoolLevelValueLabel(NULL) + , mpSchoolBranchItemLabel(NULL) + , mpSchoolBranchBox(NULL) + , mpSchoolBranchValueLabel(NULL) + , mpSchoolTypeItemLabel(NULL) + , mpSchoolTypeBox(NULL) + , mpSchoolTypeValueLabel(NULL) + , mpSeparatorIndex(NULL) + , mpLicenceLabel(NULL) + , mpLicenceBox(NULL) + , mpLicenceIcon(NULL) + , mpLicenceLayout(NULL) +{ + setObjectName(name); + + mpLayout = new QVBoxLayout(this); + mpPageNumberLabel = new QLabel(this); + mpPageNumberLabel->setAlignment(Qt::AlignRight); + mpPageNumberLabel->setObjectName("UBTGPresentationPageNumberLabel"); + mpPageNumberLabel->setText(tr("Page 0")); + mpLayout->addWidget(mpPageNumberLabel); + + mpButtonTitleLayout = new QHBoxLayout(0); + + mpModePushButton = new QPushButton(this); + mpModePushButton->setIcon(QIcon(":images/pencil.svg")); + mpModePushButton->setMaximumWidth(32); + mpButtonTitleLayout->addWidget(mpModePushButton); + connect(mpModePushButton,SIGNAL(clicked()),this,SLOT(switchToMode())); + + mpSessionTitle = new UBTGAdaptableText(0,this); + mpSessionTitle->setPlaceHolderText(tr("Type session title here ...")); + mpSessionTitle->setObjectName("UBTGEditionModeSessionTitle"); + mpButtonTitleLayout->addWidget(mpSessionTitle); + + mpLayout->addLayout(mpButtonTitleLayout); + + mpSeparatorSessionTitle = new QFrame(this); + mpSeparatorSessionTitle->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); + mpSeparatorSessionTitle->setObjectName("UBTGSeparator"); + mpLayout->addWidget(mpSeparatorSessionTitle); + + mpAuthorsLabel = new QLabel(this); + mpAuthorsLabel->setObjectName("UBTGZeroPageEditionModeTitle"); + mpAuthorsLabel->setText(tr("Author(s)")); + mpLayout->addWidget(mpAuthorsLabel); + + mpAuthors = new UBTGAdaptableText(0,this); + mpAuthors->setObjectName("UBTGZeroPageInputText"); + mpAuthors->setPlaceHolderText(tr("Type authors here ...")); + mpLayout->addWidget(mpAuthors); + + mpCreationLabel = new QLabel(this); + mpCreationLabel->setObjectName("UBTGZeroPageDateLabel"); + mpLayout->addWidget(mpCreationLabel); + + mpLastModifiedLabel = new QLabel(this); + mpLastModifiedLabel->setObjectName("UBTGZeroPageDateLabel"); + mpLayout->addWidget(mpLastModifiedLabel); + + mpSeparatorAuthors = new QFrame(this); + mpSeparatorAuthors->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); + mpSeparatorAuthors->setObjectName("UBTGSeparator"); + mpLayout->addWidget(mpSeparatorAuthors); + + mpGoalsLabel = new QLabel(this); + mpGoalsLabel->setObjectName("UBTGZeroPageEditionModeTitle"); + mpGoalsLabel->setText(tr("Goal(s)")); + mpLayout->addWidget(mpGoalsLabel); + + mpGoals = new UBTGAdaptableText(0,this); + mpGoals->setObjectName("UBTGZeroPageInputText"); + mpGoals->setPlaceHolderText(tr("Type goals here...")); + mpLayout->addWidget(mpGoals); + + mpSeparatorGoals = new QFrame(this); + mpSeparatorGoals->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); + mpSeparatorGoals->setObjectName("UBTGSeparator"); + mpLayout->addWidget(mpSeparatorGoals); + + mpIndexLabel = new QLabel(this); + mpIndexLabel->setObjectName("UBTGZeroPageEditionModeTitle"); + mpIndexLabel->setText(tr("Resource indexing")); + mpLayout->addWidget(mpIndexLabel); + + mpKeywordsLabel = new QLabel(this); + mpKeywordsLabel->setObjectName("UBTGZeroPageItemLabel"); + mpKeywordsLabel->setText(tr("Keywords:")); + mpLayout->addWidget(mpKeywordsLabel); + mpKeywords = new UBTGAdaptableText(0,this); + mpKeywords->setPlaceHolderText(tr("Type keywords here ...")); + mpLayout->addWidget(mpKeywords); + + mpSchoolLevelItemLabel = new QLabel(this); + mpSchoolLevelItemLabel->setObjectName("UBTGZeroPageItemLabel"); + mpSchoolLevelItemLabel->setText(tr("Level:")); + mpLayout->addWidget(mpSchoolLevelItemLabel); + mpSchoolLevelBox = new QComboBox(this); + mpSchoolLevelBox->setObjectName("DockPaletteWidgetComboBox"); + connect(mpSchoolLevelBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(onSchoolLevelChanged(QString))); + mpLayout->addWidget(mpSchoolLevelBox); + mpSchoolLevelValueLabel = new QLabel(this); + mpLayout->addWidget(mpSchoolLevelValueLabel); + + mpSchoolBranchItemLabel = new QLabel(this); + mpSchoolBranchItemLabel->setObjectName("UBTGZeroPageItemLabel"); + mpSchoolBranchItemLabel->setText(tr("Branch:")); + mpLayout->addWidget(mpSchoolBranchItemLabel); + mpSchoolBranchBox = new QComboBox(this); + mpSchoolBranchBox->setObjectName("DockPaletteWidgetComboBox"); + mpLayout->addWidget(mpSchoolBranchBox); + mpSchoolBranchValueLabel = new QLabel(this); + mpLayout->addWidget(mpSchoolBranchValueLabel); + + mpSchoolTypeItemLabel = new QLabel(this); + mpSchoolTypeItemLabel->setObjectName("UBTGZeroPageItemLabel"); + mpSchoolTypeItemLabel->setText(tr("Type:")); + mpLayout->addWidget(mpSchoolTypeItemLabel); + mpSchoolTypeBox = new QComboBox(this); + mpSchoolTypeBox->setObjectName("DockPaletteWidgetComboBox"); + mpLayout->addWidget(mpSchoolTypeBox); + mpSchoolTypeValueLabel = new QLabel(this); + mpLayout->addWidget(mpSchoolTypeValueLabel); + + mpSeparatorIndex = new QFrame(this); + mpSeparatorIndex->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); + mpSeparatorIndex->setObjectName("UBTGSeparator"); + mpLayout->addWidget(mpSeparatorIndex); + + mpLicenceLabel = new QLabel(this); + mpLicenceLabel->setObjectName("UBTGZeroPageItemLabel"); + mpLicenceLabel->setText(tr("Licence:")); + mpLayout->addWidget(mpLicenceLabel); + mpLicenceBox = new QComboBox(this); + mpLicenceBox->setObjectName("DockPaletteWidgetComboBox"); + mpLayout->addWidget(mpLicenceBox); + mpLicenceLayout = new QHBoxLayout(0); + mpLicenceIcon = new QLabel(this); + mpLicenceLayout->addWidget(mpLicenceIcon); + mpLicenceValueLabel = new QLabel(this); + mpLicenceLayout->addWidget(mpLicenceValueLabel); + mpLayout->addLayout(mpLicenceLayout); + mpLayout->addStretch(1); + connect(UBApplication::boardController,SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); + fillComboBoxes(); +} + +UBTeacherGuidePageZeroEditionWidget::~UBTeacherGuidePageZeroEditionWidget() +{ + DELETEPTR(mpPageNumberLabel); + DELETEPTR(mpSessionTitle); + DELETEPTR(mpSeparatorSessionTitle); + DELETEPTR(mpAuthorsLabel); + DELETEPTR(mpAuthors); + DELETEPTR(mpSeparatorAuthors); + DELETEPTR(mpCreationLabel); + DELETEPTR(mpLastModifiedLabel); + DELETEPTR(mpGoalsLabel); + DELETEPTR(mpGoals); + DELETEPTR(mpSeparatorGoals); + DELETEPTR(mpIndexLabel); + DELETEPTR(mpKeywordsLabel); + DELETEPTR(mpKeywords); + DELETEPTR(mpSchoolLevelItemLabel); + DELETEPTR(mpSchoolLevelBox); + DELETEPTR(mpSchoolBranchItemLabel); + DELETEPTR(mpSchoolBranchBox); + DELETEPTR(mpSchoolTypeItemLabel); + DELETEPTR(mpSchoolTypeBox); + DELETEPTR(mpSeparatorIndex); + DELETEPTR(mpLicenceLabel); + DELETEPTR(mpLicenceBox); + DELETEPTR(mpLicenceValueLabel); + DELETEPTR(mpLicenceIcon); + DELETEPTR(mpModePushButton); + DELETEPTR(mpLicenceLayout); + DELETEPTR(mpButtonTitleLayout); + DELETEPTR(mpLayout); +} + +void UBTeacherGuidePageZeroEditionWidget::fillComboBoxes() +{ + QString parametersConfigFilePath = UBSettings::settings()->applicationCustomizationDirectory() + "/teacherGuide/indexingParameters.xml"; + QFile parametersFile(parametersConfigFilePath); + if(!parametersFile.exists()){ + qCritical() << "UBTeacherGuidePageZeroEditionWidget fillComboBoxes file not found " << parametersConfigFilePath; + return; + } + + parametersFile.open(QFile::ReadOnly); + + QDomDocument doc; + doc.setContent(parametersFile.readAll()); + QDomElement rootElement = doc.elementsByTagName("teacherGuide").at(0).toElement(); + + QDomNodeList subjects = rootElement.elementsByTagName("subjects"); + 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){ + subjectsRelatedToBaseLevel.append(subjectsList.at(j).toElement().attribute("label")); + } + 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")); + } + + + 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"); + + mpLicenceBox->addItems(licences); +} + +void UBTeacherGuidePageZeroEditionWidget::onSchoolLevelChanged(QString schoolLevel) +{ + QStringList subjects = mSubjects.value(mGradeLevelsMap.value(schoolLevel)); + mpSchoolBranchBox->clear(); + if(subjects.count()){ + mpSchoolBranchItemLabel->setEnabled(true); + mpSchoolBranchBox->setEnabled(true); + mpSchoolBranchBox->addItems(subjects); + } + else{ + mpSchoolBranchItemLabel->setDisabled(true); + mpSchoolBranchBox->setDisabled(true); + } +} + +void UBTeacherGuidePageZeroEditionWidget::onActiveSceneChanged() +{ + UBDocumentProxy* documentProxy = UBApplication::documentController ? UBApplication::documentController->getCurrentDocument() : 0; + if(UBApplication::documentController && UBApplication::boardController->activeSceneIndex() == 0){ + QDateTime creationDate = documentProxy->documentDate(); + mpCreationLabel->setText(tr("Created the:") + creationDate.toString(Qt::SystemLocaleShortDate)); + QDateTime updatedDate = documentProxy->lastUpdate(); + mpLastModifiedLabel->setText(tr("Updated the:") + updatedDate.toString(Qt::SystemLocaleShortDate)); + } +} + + +void UBTeacherGuidePageZeroEditionWidget::switchToMode(tUBTGZeroPageMode mode) +{ + if(mode == tUBTGZeroPageMode_EDITION){ + mpModePushButton->hide(); + mpSessionTitle->setReadOnly(false); + mpAuthors->setReadOnly(false); + mpGoals->setReadOnly(false); + mpKeywords->setReadOnly(false); + mpSchoolLevelValueLabel->hide(); + mpSchoolLevelBox->show(); + mpSchoolBranchValueLabel->hide(); + mpSchoolBranchBox->show(); + mpSchoolTypeValueLabel->hide(); + mpSchoolTypeBox->show(); + mpLicenceIcon->hide(); + mpLicenceValueLabel->hide(); + mpLicenceBox->show(); + } + else{ + mpModePushButton->show(); + mpSessionTitle->setReadOnly(true); + mpAuthors->setReadOnly(true); + mpGoals->setReadOnly(true); + mpKeywords->setReadOnly(true); + mpSchoolLevelValueLabel->setText(mpSchoolLevelBox->currentText()); + mpSchoolLevelValueLabel->show(); + mpSchoolLevelBox->hide(); + mpSchoolBranchValueLabel->setText(mpSchoolBranchBox->currentText()); + mpSchoolBranchValueLabel->show(); + mpSchoolBranchBox->hide(); + mpSchoolTypeValueLabel->setText(mpSchoolTypeBox->currentText()); + mpSchoolTypeValueLabel->show(); + mpSchoolTypeBox->hide(); + mpLicenceValueLabel->setText(mpLicenceBox->currentText()); + 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"; + if(mpLicenceBox->currentIndex() < 6){ + mpLicenceIcon->setPixmap(licenceIconList.at(mpLicenceBox->currentIndex())); + mpLicenceIcon->show(); + } + mpLicenceValueLabel->show(); + mpLicenceBox->hide(); + } +} + +QVector UBTeacherGuidePageZeroEditionWidget::getData() +{ + QVectorresult; + tUBGEElementNode* elementNode = new tUBGEElementNode(); + elementNode->type = "sessionTitle"; + elementNode->attributes.insert("value",mpSessionTitle->text()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "authors"; + elementNode->attributes.insert("value",mpAuthors->text()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "creationDate"; + elementNode->attributes.insert("value",mpCreationLabel->text()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "lastModifiedDate"; + elementNode->attributes.insert("value",mpLastModifiedLabel->text()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "goals"; + elementNode->attributes.insert("value",mpGoals->text()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "keywords"; + elementNode->attributes.insert("value",mpKeywords->text()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "schoolLevel"; + elementNode->attributes.insert("value",mpSchoolLevelBox->currentText()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "schoolBranch"; + elementNode->attributes.insert("value",mpSchoolBranchBox->currentText()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "schoolType"; + elementNode->attributes.insert("value",mpSchoolTypeBox->currentText()); + result << elementNode; + + elementNode = new tUBGEElementNode(); + elementNode->type = "licence"; + elementNode->attributes.insert("value",mpLicenceBox->currentText()); + result << elementNode; + return result; +} + /*************************************************************************** * class UBTeacherGuideWidget * ***************************************************************************/ -UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget *parent, const char *name): QStackedWidget(parent) +UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget* parent, const char* name): QStackedWidget(parent) + , mpPageZeroEditonWidget(NULL) , mpEditionWidget(NULL) , mpPresentationWidget(NULL) { setObjectName(name); - mpEditionWidget = new UBTeacherGuideEditionWidget(this); - addWidget(mpEditionWidget); - mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); - addWidget(mpPresentationWidget); + mpPageZeroEditonWidget = new UBTeacherGuidePageZeroEditionWidget(this); + addWidget(mpPageZeroEditonWidget); + setCurrentWidget(mpPageZeroEditonWidget); + // mpEditionWidget = new UBTeacherGuideEditionWidget(this); +// addWidget(mpEditionWidget); +// mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); +// addWidget(mpPresentationWidget); +// setCurrentWidget(mpPresentationWidget); + - setCurrentWidget(mpPresentationWidget); connect(UBApplication::boardController->controlView(),SIGNAL(clickOnBoard()),this,SLOT(showPresentationMode())); connectToStylusPalette(); } @@ -487,7 +872,11 @@ void UBTeacherGuideWidget::connectToStylusPalette() void UBTeacherGuideWidget::showPresentationMode() { - if(currentWidget()!=mpPresentationWidget){ + if(currentWidget()==mpPageZeroEditonWidget){ + mCurrentData = mpPageZeroEditonWidget->getData(); + mpPageZeroEditonWidget->switchToMode(tUBTGZeroPageMode_PRESENTATION); + } + else if(currentWidget()==mpEditionWidget){ mCurrentData = mpEditionWidget->getData(); mpPresentationWidget->showData(mCurrentData); setCurrentWidget(mpPresentationWidget); diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h index fc984d4a..20d7e395 100644 --- a/src/gui/UBTeacherGuideWidget.h +++ b/src/gui/UBTeacherGuideWidget.h @@ -21,10 +21,17 @@ class QHeaderView; class QLabel; class QVBoxLayout; class QPushButton; +class UBDocumentProxy; #include "UBTeacherGuideWidgetsTools.h" #include "UBTGWidgetTreeDelegate.h" +typedef enum +{ + tUBTGZeroPageMode_EDITION, + tUBTGZeroPageMode_PRESENTATION +}tUBTGZeroPageMode; + /*************************************************************************** * class UBTeacherGuideEditionWidget * ***************************************************************************/ @@ -95,7 +102,73 @@ private: }; +/*************************************************************************** + * class UBTeacherGuidePageZeroPresentationWidget * + ***************************************************************************/ +class UBTeacherGuidePageZeroEditionWidget : public QWidget +{ + Q_OBJECT + +public: + explicit UBTeacherGuidePageZeroEditionWidget(QWidget* parent, const char* name = "UBTeacherGuidePageZeroEditionWidget"); + ~UBTeacherGuidePageZeroEditionWidget(); + + QVector getData(); + +public slots: + void onActiveSceneChanged(); + void switchToMode(tUBTGZeroPageMode mode = tUBTGZeroPageMode_EDITION); + +private: + void fillComboBoxes(); + + QVBoxLayout* mpLayout; + QHBoxLayout* mpButtonTitleLayout; + QPushButton* mpModePushButton; + QLabel* mpPageNumberLabel; + UBTGAdaptableText* mpSessionTitle; + QFrame* mpSeparatorSessionTitle; + + QLabel* mpAuthorsLabel; + UBTGAdaptableText* mpAuthors; + QFrame* mpSeparatorAuthors; + + QLabel* mpCreationLabel; + QLabel* mpLastModifiedLabel; + QLabel* mpGoalsLabel; + UBTGAdaptableText* mpGoals; + QFrame* mpSeparatorGoals; + + QLabel* mpIndexLabel; + QLabel* mpKeywordsLabel; + UBTGAdaptableText* mpKeywords; + + QLabel* mpSchoolLevelItemLabel; + QComboBox* mpSchoolLevelBox; + QLabel* mpSchoolLevelValueLabel; + + QLabel* mpSchoolBranchItemLabel; + QComboBox* mpSchoolBranchBox; + QLabel* mpSchoolBranchValueLabel; + + QLabel* mpSchoolTypeItemLabel; + QComboBox* mpSchoolTypeBox; + QLabel* mpSchoolTypeValueLabel; + QFrame* mpSeparatorIndex; + + QLabel* mpLicenceLabel; + QComboBox* mpLicenceBox; + QLabel* mpLicenceValueLabel; + QLabel* mpLicenceIcon; + QHBoxLayout* mpLicenceLayout; + + QMap mGradeLevelsMap; + QMap mSubjects; + +private slots: + void onSchoolLevelChanged(QString schoolLevel); +}; /*************************************************************************** * class UBTeacherGuideWidget * @@ -114,6 +187,7 @@ public slots: void connectToStylusPalette(); private: + UBTeacherGuidePageZeroEditionWidget* mpPageZeroEditonWidget; UBTeacherGuideEditionWidget* mpEditionWidget; UBTeacherGuidePresentationWidget* mpPresentationWidget; QVectormCurrentData;