diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 |
commit | d24f813f3f2a05c112e803e4256b53535895fc98 (patch) | |
tree | 601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/main-view/CardPreview.cpp |
Diffstat (limited to 'src/main-view/CardPreview.cpp')
-rw-r--r-- | src/main-view/CardPreview.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main-view/CardPreview.cpp b/src/main-view/CardPreview.cpp new file mode 100644 index 0000000..aa59031 --- /dev/null +++ b/src/main-view/CardPreview.cpp @@ -0,0 +1,55 @@ +#include "CardPreview.h" +#include "../study/CardSideView.h" +#include "../dictionary/Card.h" + +CardPreview::CardPreview(QWidget* parent): + QDockWidget(parent) +{ + setDockProperties(); + createCardSides(); + createInternalWidget(); +} + +void CardPreview::setDockProperties() +{ + setWindowTitle(tr("Card preview")); + setObjectName("Card-preview"); + setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); +} + +void CardPreview::createCardSides() +{ + questionSide = new CardSideView(CardSideView::QstMode); + answerSide = new CardSideView(CardSideView::AnsMode); +} + +void CardPreview::createInternalWidget() +{ + QVBoxLayout* mainLt = new QVBoxLayout; + mainLt->addWidget(questionSide, 1); + mainLt->addWidget(answerSide, 1); + + QWidget* internalWidget = new QWidget; + internalWidget->setLayout(mainLt); + setWidget(internalWidget); +} + +void CardPreview::setPack(const CardPack* pack) +{ + questionSide->setPack(pack); + answerSide->setPack(pack); +} + +void CardPreview::setContent(const CardPack* pack, Card* card) +{ + setPack(pack); + QString question; + QStringList answers; + if(card) + { + question = card->getQuestion(); + answers = card->getAnswers(); + } + questionSide->setQuestion(question); + answerSide->setQstAnsr(question, answers); +} |