summaryrefslogtreecommitdiff
path: root/src/main-view/CardPreview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main-view/CardPreview.cpp')
-rw-r--r--src/main-view/CardPreview.cpp55
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);
+}