Implemented the Teacher Bar Document Preview widget

preferencesAboutTextFull
shibakaneki 13 years ago
parent c8b054f42b
commit 01aa493e29
  1. 3
      src/adaptors/UBMetadataDcSubsetAdaptor.cpp
  2. 1
      src/core/UBSettings.cpp
  3. 1
      src/core/UBSettings.h
  4. 9
      src/document/UBDocumentProxy.cpp
  5. 1
      src/document/UBDocumentProxy.h
  6. 134
      src/gui/UBTBDocumentPreviewWidget.cpp
  7. 29
      src/gui/UBTBDocumentPreviewWidget.h
  8. 10
      src/gui/UBTeacherBarDataMgr.cpp
  9. 9
      src/gui/UBTeacherBarDataMgr.h

@ -276,7 +276,6 @@ QMap<QString, QVariant> UBMetadataDcSubsetAdaptor::load(QString pPath)
qWarning() << "Document size not found, using default view size" << docSize; qWarning() << "Document size not found, using default view size" << docSize;
metadata.insert(UBSettings::documentSize, QVariant(docSize)); metadata.insert(UBSettings::documentSize, QVariant(docSize));
} }
if (!updatedAtFound) if (!updatedAtFound)
@ -284,6 +283,8 @@ QMap<QString, QVariant> UBMetadataDcSubsetAdaptor::load(QString pPath)
metadata.insert(UBSettings::documentUpdatedAt, date + "T00:00:00Z"); metadata.insert(UBSettings::documentUpdatedAt, date + "T00:00:00Z");
} }
metadata.insert(UBSettings::documentDate, QVariant(date));
return metadata; return metadata;
} }

@ -43,6 +43,7 @@ QString UBSettings::sessionKeywords = QString("sessionKeywords");
QString UBSettings::sessionLevel = QString("sessionLevel"); QString UBSettings::sessionLevel = QString("sessionLevel");
QString UBSettings::sessionTopic = QString("sessionTopic"); QString UBSettings::sessionTopic = QString("sessionTopic");
QString UBSettings::sessionAuthors = QString("sessionAuthors"); QString UBSettings::sessionAuthors = QString("sessionAuthors");
QString UBSettings::documentDate = QString("date");
QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:"); QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:");

@ -160,6 +160,7 @@ class UBSettings : public QObject
static QString sessionLevel; static QString sessionLevel;
static QString sessionTopic; static QString sessionTopic;
static QString sessionAuthors; static QString sessionAuthors;
static QString documentDate;
static QString trashedDocumentGroupNamePrefix; static QString trashedDocumentGroupNamePrefix;

@ -295,6 +295,15 @@ QString UBDocumentProxy::sessionAuthors()
return QString(); return QString();
} }
QString UBDocumentProxy::documentDate()
{
if(mMetaDatas.contains(UBSettings::documentDate)){
return metaData(UBSettings::documentDate).toString();
}else{
return QString();
}
}
bool UBDocumentProxy::isModified() const bool UBDocumentProxy::isModified() const
{ {
return mIsModified; return mIsModified;

@ -59,6 +59,7 @@ class UBDocumentProxy : public QObject
QString sessionTopic(); QString sessionTopic();
void setSessionAuthor(const QString& authors); void setSessionAuthor(const QString& authors);
QString sessionAuthors(); QString sessionAuthors();
QString documentDate();
QSize defaultDocumentSize() const; QSize defaultDocumentSize() const;

@ -4,27 +4,119 @@
UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent)
, mpPageViewButton(NULL) , mpPageViewButton(NULL)
, mpEditButton(NULL) , mpEditButton(NULL)
, mpSessionLabel(NULL)
, mpSessionTitle(NULL)
, mpAuthorLabel(NULL)
, mpAuthors(NULL)
, mpCreationDate(NULL)
, mpTargetLabel(NULL)
, mpTarget(NULL)
, mpMetadataLabel(NULL)
, mpKeywordLabel(NULL)
, mpKeyword(NULL)
, mpLevelLabel(NULL)
, mpLevel(NULL)
, mpTopicLabel(NULL)
, mpTopic(NULL)
, mpLicense(NULL)
, mpContainer(NULL)
{ {
setObjectName(name); setObjectName(name);
mpDataMgr = pDataMgr; mpDataMgr = pDataMgr;
setLayout(&mLayout); setLayout(&mLayout);
mLayout.setContentsMargins(0, 0, 0, 0);
mpPageViewButton = new QPushButton(tr("Page View"), this); mpContainer = new QWidget(this);
mpPageViewButton->setObjectName("DockPaletteWidgetButton"); mpContainer->setLayout(&mContainerLayout);
mPageLayout.addStretch(1); mpContainer->setObjectName("UBTeacherBarPreviewWidget");
mPageLayout.addWidget(mpPageViewButton, 0);
mPageLayout.addStretch(1); // Session Title
mLayout.addLayout(&mPageLayout); mpSessionLabel = new QLabel(tr("Session"), mpContainer);
mpSessionLabel->setAlignment(Qt::AlignRight);
mpSessionLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout.addWidget(mpSessionLabel, 0);
mpSessionTitle = new QLabel(mpContainer);
mpSessionTitle->setWordWrap(true);
mpSessionTitle->setAlignment(Qt::AlignRight);
mpSessionTitle->setObjectName("UBTeacherBarPreviewTitle");
mContainerLayout.addWidget(mpSessionTitle, 0);
mContainerLayout.addWidget(&mTitleSeparator, 0);
// Author(s)
mpAuthorLabel = new QLabel(tr("Author(s)"), mpContainer);
mpAuthorLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout.addWidget(mpAuthorLabel, 0);
mpAuthors = new QLabel(mpContainer);
mpAuthors->setWordWrap(true);
mpAuthors->setStyleSheet("padding-left:5px;");
mContainerLayout.addWidget(mpAuthors, 0);
mContainerLayout.addWidget(&mAuthorSeparator, 0);
// Dates
mpCreationDate = new QLabel(tr("Created on: "), mpContainer);
mpCreationDate->setStyleSheet("padding-left:5px;");
mContainerLayout.addWidget(mpCreationDate);
mContainerLayout.addWidget(&mDateSeparator, 0);
// Target
mpTargetLabel = new QLabel(tr("Target"), mpContainer);
mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout.addWidget(mpTargetLabel,0);
mpTarget = new QTextEdit(mpContainer);
mpTarget->setReadOnly(true);
mContainerLayout.addWidget(mpTarget, 1);
mContainerLayout.addWidget(&mTargetSeparator, 0);
// Metadata
mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer);
mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout.addWidget(mpMetadataLabel, 0);
// Keyword
mpKeywordLabel = new QLabel(tr("<b>Keywords:</b>"), mpContainer);
mpKeywordLabel->setStyleSheet("padding-left:5px;");
mpKeyword = new QLabel(mpContainer);
mpKeyword->setWordWrap(true);
mKeywordLayout.addWidget(mpKeywordLabel, 0);
mKeywordLayout.addWidget(mpKeyword, 1);
mContainerLayout.addLayout(&mKeywordLayout, 0);
// Level
mpLevelLabel = new QLabel(tr("<b>Level:</b>"), mpContainer);
mpLevelLabel->setStyleSheet("padding-left:5px;");
mpLevel = new QLabel(mpContainer);
mpLevel->setWordWrap(true);
mLevelLayout.addWidget(mpLevelLabel, 0);
mLevelLayout.addWidget(mpLevel, 1);
mContainerLayout.addLayout(&mLevelLayout, 0);
// TODO : Add the elements here // Topic
mpTopicLabel = new QLabel(tr("<b>Topic:</b>"), mpContainer);
mpTopicLabel->setStyleSheet("padding-left:5px;");
mpTopic = new QLabel(mpContainer);
mpTopic->setWordWrap(true);
mTopicLayout.addWidget(mpTopicLabel, 0);
mTopicLayout.addWidget(mpTopic, 1);
mContainerLayout.addLayout(&mTopicLayout, 0);
mContainerLayout.addWidget(&mMetadataSeparator, 0);
// License
mpLicense = new UBTBLicenseWidget(mpContainer);
mContainerLayout.addWidget(mpLicense, 0);
mLayout.addWidget(mpContainer, 1);
mpPageViewButton = new QPushButton(tr("Page View"), this);
mpPageViewButton->setObjectName("DockPaletteWidgetButton");
mpEditButton = new QPushButton(tr("Edit"), this); mpEditButton = new QPushButton(tr("Edit"), this);
mpEditButton->setObjectName("DockPaletteWidgetButton"); mpEditButton->setObjectName("DockPaletteWidgetButton");
mPreviewLayout.addStretch(1);
mPreviewLayout.addWidget(mpEditButton, 0); mButtonsLayout.addWidget(mpPageViewButton, 0);
mPreviewLayout.addStretch(1); mButtonsLayout.addWidget(mpEditButton, 0);
mLayout.addLayout(&mPreviewLayout); mButtonsLayout.addStretch(1);
mLayout.addLayout(&mButtonsLayout, 0);
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView()));
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit()));
@ -32,8 +124,7 @@ UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataM
UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget() UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget()
{ {
DELETEPTR(mpPageViewButton);
DELETEPTR(mpEditButton);
} }
void UBTBDocumentPreviewWidget::onEdit() void UBTBDocumentPreviewWidget::onEdit()
@ -48,10 +139,23 @@ void UBTBDocumentPreviewWidget::onPageView()
void UBTBDocumentPreviewWidget::updateFields() void UBTBDocumentPreviewWidget::updateFields()
{ {
mpSessionTitle->setText(mpDataMgr->sessionTitle());
mpAuthors->setText(mpDataMgr->authors());
mpCreationDate->setText(tr("<b>Creation Date:</b> %0").arg(mpDataMgr->creationDate()));
mpTarget->setText(mpDataMgr->sessionTarget());
mpLicense->setLicense(mpDataMgr->sessionLicence());
mpKeyword->setText(mpDataMgr->keywords());
mpLevel->setText(mpDataMgr->level());
mpTopic->setText(mpDataMgr->topic());
} }
void UBTBDocumentPreviewWidget::clearFields() void UBTBDocumentPreviewWidget::clearFields()
{ {
mpSessionTitle->setText("");
mpAuthors->setText("");
mpCreationDate->setText("");
mpTarget->setText("");
mpKeyword->setText("");
mpLevel->setText("");
mpTopic->setText("");
} }

@ -24,10 +24,35 @@ private slots:
private: private:
QVBoxLayout mLayout; QVBoxLayout mLayout;
QHBoxLayout mPageLayout; QHBoxLayout mButtonsLayout;
QHBoxLayout mPreviewLayout;
QWidget* mpContainer;
QVBoxLayout mContainerLayout;
QPushButton* mpPageViewButton; QPushButton* mpPageViewButton;
QPushButton* mpEditButton; QPushButton* mpEditButton;
QLabel* mpSessionLabel;
QLabel* mpSessionTitle;
UBTBSeparator mTitleSeparator;
QLabel* mpAuthorLabel;
QLabel* mpAuthors;
UBTBSeparator mAuthorSeparator;
QLabel* mpCreationDate;
UBTBSeparator mDateSeparator;
QLabel* mpTargetLabel;
QTextEdit* mpTarget;
UBTBSeparator mTargetSeparator;
QLabel* mpMetadataLabel;
QHBoxLayout mKeywordLayout;
QLabel* mpKeywordLabel;
QLabel* mpKeyword;
QHBoxLayout mLevelLayout;
QLabel* mpLevelLabel;
QLabel* mpLevel;
QHBoxLayout mTopicLayout;
QLabel* mpTopicLabel;
QLabel* mpTopic;
UBTBSeparator mMetadataSeparator;
UBTBLicenseWidget* mpLicense;
UBTeacherBarDataMgr* mpDataMgr; UBTeacherBarDataMgr* mpDataMgr;
}; };

@ -1,3 +1,5 @@
#include <QDate>
#include "UBTeacherBarDataMgr.h" #include "UBTeacherBarDataMgr.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
@ -59,7 +61,6 @@ void UBTeacherBarDataMgr::saveContent()
documentProxy->setSessionTitle(mSessionTitle); documentProxy->setSessionTitle(mSessionTitle);
documentProxy->setSessionTarget(mSessionTarget); documentProxy->setSessionTarget(mSessionTarget);
documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence)); documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence));
qDebug() << "Saving keywords: " << mKeywords;
documentProxy->setSessionKeywords(mKeywords); documentProxy->setSessionKeywords(mKeywords);
documentProxy->setSessionLevel(mLevel); documentProxy->setSessionLevel(mLevel);
documentProxy->setSessionTopic(mTopic); documentProxy->setSessionTopic(mTopic);
@ -82,10 +83,15 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged)
mSessionTarget = documentProxy->sessionTarget(); mSessionTarget = documentProxy->sessionTarget();
mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt(); mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt();
mKeywords = documentProxy->sessionKeywords(); mKeywords = documentProxy->sessionKeywords();
qDebug() << "Keywords loaded: " << mKeywords << " (" << documentProxy->sessionKeywords() << ")";
mLevel = documentProxy->sessionLevel(); mLevel = documentProxy->sessionLevel();
mTopic = documentProxy->sessionTopic(); mTopic = documentProxy->sessionTopic();
mAuthors = documentProxy->sessionAuthors(); mAuthors = documentProxy->sessionAuthors();
if("" != documentProxy->documentDate()){
mCreationDate = documentProxy->documentDate();
}else{
mCreationDate = QDate::currentDate().toString("yyyy-MM-dd");
}
} }
// Page Title // Page Title

@ -115,6 +115,13 @@ public:
void setAuthors(const QString& authors){mAuthors = authors;} void setAuthors(const QString& authors){mAuthors = authors;}
QString authors(){return mAuthors;} QString authors(){return mAuthors;}
// Creation Date
void setCreationDate(const QString& date){mCreationDate = date;}
QString creationDate(){return mCreationDate;}
// Last Modification
void setLastModificationDate(const QString& date){mLastModif = date;}
QString lastModificationDate(){return mLastModif;}
// Others // Others
void clearLists(); void clearLists();
@ -131,6 +138,8 @@ private:
QString mLevel; QString mLevel;
QString mTopic; QString mTopic;
QString mAuthors; QString mAuthors;
QString mCreationDate;
QString mLastModif;
QVector<sAction> mActionList; QVector<sAction> mActionList;
QVector<sLink> mUrlList; QVector<sLink> mUrlList;

Loading…
Cancel
Save