mirror of
https://github.com/jorenchik/mdemory.git
synced 2026-03-22 00:26:21 +00:00
layout and mdem buffer struct
This commit is contained in:
@@ -187,6 +187,7 @@ struct GroupView {
|
||||
MoveListView itemList;
|
||||
};
|
||||
|
||||
#define ITEM_POOL_CHUNK 200
|
||||
|
||||
// Main components
|
||||
QMainWindow *trainWindow;
|
||||
@@ -229,15 +230,17 @@ std::vector<QStandardItemModel*> groupModels;
|
||||
|
||||
// Questions & State
|
||||
std::vector<Question*> trainQuestions = std::vector<Question*>();
|
||||
int32_t currentQuestionIndex = -1;
|
||||
int32_t currentQuestionIndex = -1;
|
||||
std::vector<GroupView*> groupViews;
|
||||
PracticeAlgorithm practiceAlgoritm;
|
||||
|
||||
std::default_random_engine rng;
|
||||
std::vector<QStandardItem*> itemPool;
|
||||
|
||||
PracticeAlgorithm practiceAlgoritm;
|
||||
|
||||
#define ITEM_POOL_CHUNK 200
|
||||
QToolButton *btnNotRemembered;
|
||||
QToolButton *btnHard;
|
||||
QToolButton *btnMedium;
|
||||
QToolButton *btnEasy;
|
||||
|
||||
QStandardItem* acquireItem() {
|
||||
if (itemPool.size() <= 0) {
|
||||
@@ -343,6 +346,13 @@ void setupOrderQuestion(MultiElementQuestion *question) {
|
||||
orderList->update();
|
||||
}
|
||||
btnTriggerAnswer->hide();
|
||||
|
||||
if (practiceAlgoritm == SPACED) {
|
||||
btnNotRemembered->show();
|
||||
btnHard->show();
|
||||
btnMedium->show();
|
||||
btnEasy->show();
|
||||
}
|
||||
}
|
||||
);
|
||||
btnTriggerAnswer->show();
|
||||
@@ -482,6 +492,10 @@ void setupQuestion(Question *question) {
|
||||
releaseAllItems();
|
||||
QObject::disconnect(btnTriggerAnswer, 0, 0, 0);
|
||||
if (auto *question = dynamic_cast<MultiElementQuestion*>(trainQuestions[currentQuestionIndex])) {
|
||||
btnNotRemembered->hide();
|
||||
btnHard->hide();
|
||||
btnMedium->hide();
|
||||
btnEasy->hide();
|
||||
switch (question->type) {
|
||||
case MultiElementType::Order:
|
||||
setupOrderQuestion(question);
|
||||
@@ -511,7 +525,16 @@ void updatePaginationVisibility() {
|
||||
}
|
||||
}
|
||||
|
||||
void setQuestions(std::vector<Question*> questions, PracticeAlgorithm algorithm) {
|
||||
void initiatePractice(
|
||||
std::vector<Question*> questions,
|
||||
PracticeAlgorithm algorithm,
|
||||
time_t *trainedAt
|
||||
) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
time_t unix_timestamp = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
now.time_since_epoch()
|
||||
).count();
|
||||
|
||||
trainQuestions = questions;
|
||||
if (questions.size() <= 0) {
|
||||
return;
|
||||
@@ -520,6 +543,11 @@ void setQuestions(std::vector<Question*> questions, PracticeAlgorithm algorithm)
|
||||
updatePaginationVisibility();
|
||||
setupQuestion(trainQuestions[currentQuestionIndex]);
|
||||
practiceAlgoritm = algorithm;
|
||||
|
||||
btnNotRemembered->hide();
|
||||
btnHard->hide();
|
||||
btnMedium->hide();
|
||||
btnEasy->hide();
|
||||
}
|
||||
|
||||
void initTrainWindow() {
|
||||
@@ -613,13 +641,38 @@ void initTrainWindow() {
|
||||
hButtons = new QHBoxLayout();
|
||||
btnPrev = new QToolButton();
|
||||
leftSpacer = new QSpacerItem(50, 50, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
btnTriggerAnswer = new QToolButton();
|
||||
|
||||
btnNotRemembered = new QToolButton();
|
||||
btnHard = new QToolButton();
|
||||
btnMedium = new QToolButton();
|
||||
btnEasy = new QToolButton();
|
||||
|
||||
btnNotRemembered->setText("Not remembered");
|
||||
btnHard->setText("Hard");
|
||||
btnMedium->setText("Medium");
|
||||
btnEasy->setText("Easy");
|
||||
|
||||
btnTriggerAnswer = new QToolButton();
|
||||
|
||||
rightSpacer = new QSpacerItem(50, 50, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
btnNext = new QToolButton();
|
||||
|
||||
hButtons->addWidget(btnPrev);
|
||||
hButtons->addItem(leftSpacer);
|
||||
hButtons->addWidget(btnTriggerAnswer);
|
||||
|
||||
hButtons->addWidget(btnNotRemembered);
|
||||
hButtons->addWidget(btnHard);
|
||||
QObject::connect(btnHard, &QToolButton::clicked, []() {
|
||||
const double hourCooldown = 25.0;
|
||||
auto question = trainQuestions[currentQuestionIndex];
|
||||
question->Cooldown = hourCooldown;
|
||||
});
|
||||
hButtons->addWidget(btnMedium);
|
||||
hButtons->addWidget(btnEasy);
|
||||
|
||||
hButtons->addItem(rightSpacer);
|
||||
hButtons->addWidget(btnNext);
|
||||
vButtonBox->addWidget(actionButtons);
|
||||
|
||||
Reference in New Issue
Block a user