summaryrefslogtreecommitdiff
path: root/src/study/StudySettings.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
commitd24f813f3f2a05c112e803e4256b53535895fc98 (patch)
tree601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/study/StudySettings.cpp
Initial mirror commitHEADmaster
Diffstat (limited to 'src/study/StudySettings.cpp')
-rw-r--r--src/study/StudySettings.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/study/StudySettings.cpp b/src/study/StudySettings.cpp
new file mode 100644
index 0000000..c680f8e
--- /dev/null
+++ b/src/study/StudySettings.cpp
@@ -0,0 +1,93 @@
+#include "StudySettings.h"
+
+#include <QCoreApplication>
+#include <QStringList>
+#include <QtDebug>
+
+StudySettings::StudySettings()
+{
+ initDefaultStudy();
+}
+
+void StudySettings::initDefaultStudy()
+{
+ showRandomly = true;
+ newCardsShare = 0.2;
+ schedRandomness = 0.1;
+ cardsDayLimit = 80;
+ newCardsDayLimit = 10;
+ limitForAddingNewCards = 70;
+ dayShift = 3;
+
+ initEasiness = 2.5;
+ minEasiness = 1.3;
+ maxEasiness = 3.2;
+ difficultDelta = -0.14;
+ easyDelta = 0.1;
+
+ unknownInterval = 20./(24*60*60);
+ incorrectInterval = 1./(24*60);
+ learningInterval = 10./(24*60);
+ nextDayInterval = 0.9;
+ twoDaysInterval = 1.9;
+}
+
+StudySettings* StudySettings::inst()
+ {
+ static StudySettings instance;
+ return &instance;
+ }
+
+void StudySettings::load()
+ {
+ QSettings settings;
+ settings.beginGroup("Study");
+ loadStudy(settings);
+ settings.endGroup();
+ }
+
+void StudySettings::loadStudy(const QSettings& settings)
+{
+ showRandomly = settings.value("random", showRandomly).toBool();
+ newCardsShare = settings.value("new-cards-share", newCardsShare).toDouble();
+ schedRandomness =
+ settings.value("scheduling-randomness", schedRandomness).toDouble();
+ cardsDayLimit = settings.value("cards-daylimit", cardsDayLimit).toInt();
+ newCardsDayLimit = settings.value("new-cards-daylimit", newCardsDayLimit).toInt();
+ limitForAddingNewCards = settings.value("limit-for-adding-new-cards", limitForAddingNewCards).toInt();
+ dayShift = settings.value("dayshift", dayShift).toInt();
+
+ initEasiness = settings.value("init-easiness", initEasiness).toDouble();
+ minEasiness = settings.value("min-easiness", minEasiness).toDouble();
+ maxEasiness = settings.value("max-easiness", maxEasiness).toDouble();
+ difficultDelta = settings.value("difficult-delta", difficultDelta).toDouble();
+ easyDelta = settings.value("easy-delta", easyDelta).toDouble();
+ unknownInterval = settings.value("unknown-interval", unknownInterval).toDouble();
+ incorrectInterval = settings.value("incorrect-interval", incorrectInterval).toDouble();
+ learningInterval = settings.value("learning-interval", learningInterval).toDouble();
+ nextDayInterval = settings.value("next-day-interval", nextDayInterval).toDouble();
+}
+
+void StudySettings::save()
+ {
+ QSettings settings;
+ settings.beginGroup("Study");
+ settings.remove(""); // Remove old user settings
+ StudySettings defaults;
+ if(showRandomly != defaults.showRandomly)
+ settings.setValue( "random", showRandomly );
+ if(newCardsShare != defaults.newCardsShare)
+ settings.setValue( "new-cards-share", newCardsShare );
+ if(schedRandomness != defaults.schedRandomness)
+ settings.setValue( "scheduling-randomness", schedRandomness );
+ if(cardsDayLimit != defaults.cardsDayLimit)
+ settings.setValue( "cards-daylimit",cardsDayLimit );
+ if(newCardsDayLimit != defaults.newCardsDayLimit)
+ settings.setValue( "new-cards-daylimit", newCardsDayLimit );
+ if(limitForAddingNewCards != defaults.limitForAddingNewCards)
+ settings.setValue( "limit-for-adding-new-cards", limitForAddingNewCards );
+ if(dayShift != defaults.dayShift)
+ settings.setValue( "dayshift", dayShift );
+ settings.endGroup();
+}
+