mirror of
https://github.com/jorenchik/mdemory.git
synced 2026-03-22 00:26:21 +00:00
functions in camelcase
This commit is contained in:
@@ -133,19 +133,19 @@ std::string outputMdem(std::vector<Question*> questions, time_t time = 0) {
|
||||
for (auto question: questions) {
|
||||
ss << std::endl;
|
||||
std::string cooldownPart;
|
||||
if (question->Cooldown != 0) {
|
||||
cooldownPart = std::format(" [{:.2f}]", question->Cooldown);
|
||||
if (question->cooldown != 0) {
|
||||
cooldownPart = std::format(" [{:.2f}]", question->cooldown);
|
||||
}
|
||||
ss << wrapText(
|
||||
std::format("-{}{} >\n",
|
||||
cooldownPart,
|
||||
" " + escapeText(question->QuestionText)),
|
||||
" " + escapeText(question->questionText)),
|
||||
wrap_width
|
||||
);
|
||||
if (MultiElementQuestion* mw = dynamic_cast<MultiElementQuestion*>(question)) {
|
||||
for (auto choice: mw->Choices) {
|
||||
for (auto choice: mw->choices) {
|
||||
char opener;
|
||||
if (choice.IsCorrect) {
|
||||
if (choice.isCorrect) {
|
||||
opener = '+';
|
||||
} else {
|
||||
opener = '-';
|
||||
@@ -160,12 +160,12 @@ std::string outputMdem(std::vector<Question*> questions, time_t time = 0) {
|
||||
"\t{}{} {}\n",
|
||||
opener,
|
||||
orderModifier,
|
||||
escapeText(choice.Answer)
|
||||
escapeText(choice.answer)
|
||||
)
|
||||
, wrap_width);
|
||||
}
|
||||
} else if (GroupQuestion* gq = dynamic_cast<GroupQuestion*>(question)) {
|
||||
for (auto group: gq->Groups) {
|
||||
for (auto group: gq->groups) {
|
||||
ss << wrapText(
|
||||
std::format(
|
||||
"\t- {}:\n",
|
||||
@@ -207,23 +207,23 @@ void makePages() {
|
||||
|
||||
void setupMdem(Mdem *mdem, Question *question) {
|
||||
std::stringstream ss;
|
||||
if (question->Cooldown > 0) {
|
||||
ss << std::format("[{:.2f}] ", question->Cooldown);
|
||||
if (question->cooldown > 0) {
|
||||
ss << std::format("[{:.2f}] ", question->cooldown);
|
||||
}
|
||||
ss << question->QuestionText;
|
||||
ss << question->questionText;
|
||||
mdem->wFrontText.setText(
|
||||
QString::fromStdString(ss.str())
|
||||
);
|
||||
if (MultiElementQuestion* mw = dynamic_cast<MultiElementQuestion*>(question)) {
|
||||
auto choices = mw->Choices;
|
||||
auto choices = mw->choices;
|
||||
for (size_t k = 0; k < choices.size(); ++k) {
|
||||
auto answer = choices[k].Answer;
|
||||
auto answer = choices[k].answer;
|
||||
switch (mw->type) {
|
||||
case MultiElementType::Order:
|
||||
answer = std::format("{}. {}", k + 1, answer);
|
||||
break;
|
||||
case MultiElementType::MultiChoice:
|
||||
if (choices[k].IsCorrect) {
|
||||
if (choices[k].isCorrect) {
|
||||
answer = std::format("+ {}", answer);
|
||||
} else {
|
||||
answer = std::format("- {}", answer);
|
||||
@@ -244,7 +244,7 @@ void setupMdem(Mdem *mdem, Question *question) {
|
||||
}
|
||||
mdem->labelCount = choices.size();
|
||||
} else if (GroupQuestion* mw = dynamic_cast<GroupQuestion*>(question)) {
|
||||
auto groups = mw->Groups;
|
||||
auto groups = mw->groups;
|
||||
std::vector<std::string> elements;
|
||||
for (size_t k = 0; k < groups.size(); ++k) {
|
||||
auto answer = groups[k].name;
|
||||
@@ -267,7 +267,7 @@ void setupMdem(Mdem *mdem, Question *question) {
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchPage(int pageIdx);
|
||||
void switchPage(int pageIdx);
|
||||
|
||||
std::string getFilename(std::string path) {
|
||||
static const std::regex lastPathElementExp = std::regex("(.+\\/)*(.+)");
|
||||
@@ -363,7 +363,7 @@ Mdem* makeMdem() {
|
||||
}
|
||||
}
|
||||
makePages();
|
||||
SwitchPage(pagination->currentPage);
|
||||
switchPage(pagination->currentPage);
|
||||
}
|
||||
if (editMdem == mdem) {
|
||||
editorWindow->hide();
|
||||
@@ -442,14 +442,14 @@ void CreateMdems(std::vector<Question*>& questions) {
|
||||
|
||||
void update(bool isChanged) {
|
||||
if (pagination->currentPage > -1) {
|
||||
SwitchPage(pagination->currentPage);
|
||||
switchPage(pagination->currentPage);
|
||||
}
|
||||
if (currentMdem.length() > 0) {
|
||||
updateMdemInfo(getFilename(currentMdem), isChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchPage(int pageIdx) {
|
||||
void switchPage(int pageIdx) {
|
||||
pagination->currentPage = pageIdx;
|
||||
|
||||
// Hide all pagination buttons
|
||||
@@ -566,7 +566,7 @@ void reloadMdem(std::string path) {
|
||||
buffer = buffers[path];
|
||||
currentMdemBuffer = buffer;
|
||||
makePages();
|
||||
SwitchPage(0);
|
||||
switchPage(0);
|
||||
updateMdemInfo(getFilename(filename), buffer->isModified);
|
||||
currentMdem = path;
|
||||
errorView->box.hide();
|
||||
@@ -630,7 +630,7 @@ void reloadMdem(std::string path) {
|
||||
hMdemScroll->addItem(mdemSpacer);
|
||||
}
|
||||
makePages();
|
||||
SwitchPage(0);
|
||||
switchPage(0);
|
||||
updateMdemInfo(filename, false);
|
||||
} else {
|
||||
std::cout << std::format("Could not open the file: {}", currentPath.toStdString()) << std::endl;
|
||||
@@ -731,7 +731,7 @@ void setupEditorSave() {
|
||||
res.value.questions.end()
|
||||
);
|
||||
makePages();
|
||||
SwitchPage(0);
|
||||
switchPage(0);
|
||||
editorWindow->hide();
|
||||
updateMdemInfo(getFilename(currentMdem), true);
|
||||
}
|
||||
@@ -1025,7 +1025,7 @@ QMainWindow *initMdemListWindow() {
|
||||
pagination->firstButton.hide();
|
||||
QObject::connect(&pagination->firstButton, &QToolButton::clicked, []() {
|
||||
if (pagination->pages.size() > 0) {
|
||||
SwitchPage(0);
|
||||
switchPage(0);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1034,7 +1034,7 @@ QMainWindow *initMdemListWindow() {
|
||||
pagination->prevButton.hide();
|
||||
QObject::connect(&pagination->prevButton, &QToolButton::clicked, []() {
|
||||
if (pagination->pages.size() > 0) {
|
||||
SwitchPage(pagination->currentPage - 1);
|
||||
switchPage(pagination->currentPage - 1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1047,7 +1047,7 @@ QMainWindow *initMdemListWindow() {
|
||||
auto pageNum = std::stoi(elButton->text().toStdString().c_str());
|
||||
auto pageIdx = pageNum - 1;
|
||||
if (pageIdx < pagination->pages.size()) {
|
||||
SwitchPage(pageIdx);
|
||||
switchPage(pageIdx);
|
||||
}
|
||||
});
|
||||
pagination->paginationButtons.push_back(elButton);
|
||||
@@ -1058,7 +1058,7 @@ QMainWindow *initMdemListWindow() {
|
||||
pagination->nextButton.hide();
|
||||
QObject::connect(&pagination->nextButton, &QToolButton::clicked, []() {
|
||||
if (pagination->pages.size() > 0) {
|
||||
SwitchPage(pagination->currentPage + 1);
|
||||
switchPage(pagination->currentPage + 1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1067,7 +1067,7 @@ QMainWindow *initMdemListWindow() {
|
||||
pagination->lastButton.hide();
|
||||
QObject::connect(&pagination->lastButton, &QToolButton::clicked, []() {
|
||||
if (pagination->pages.size() > 0) {
|
||||
SwitchPage(pagination->pages.size() - 1);
|
||||
switchPage(pagination->pages.size() - 1);
|
||||
}
|
||||
});
|
||||
hPagination->addStretch(1);
|
||||
|
||||
Reference in New Issue
Block a user