Skip to content

Commit

Permalink
Merge branch 'reset_time'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dametrious Peyton committed Feb 28, 2015
2 parents 1e9b59b + c321732 commit 2144b8f
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 4 deletions.
29 changes: 26 additions & 3 deletions harbour/nemosyne/Nemosyne/Manager.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import QtQuick 2.1
import Sailfish.Silica 1.0
import harbour.nemosyne.Nemosyne 1.0
import harbour.nemosyne.QmlLogger 2.0
import harbour.nemosyne.SailfishWidgets.Database 1.3
import harbour.nemosyne.SailfishWidgets.FileManagement 1.3
import harbour.nemosyne.SailfishWidgets.Utilities 1.3
import harbour.nemosyne.SailfishWidgets.Settings 1.3
import harbour.nemosyne.SailfishWidgets.JS 1.3

SQLiteDatabase {
Expand All @@ -23,6 +25,17 @@ SQLiteDatabase {
signal cardAdded()
signal databaseValid(bool valid)

ApplicationSettings {
id: settings
applicationName: "harbour-nemosyne"
fileName: "settings"

property int hourMode: DefaultTime.DefaultHours
property int resetHour: 0
property int resetMinute: 0
property string timeText: "00:00"
}

DynamicLoader {
id: cardCreator
onObjectCompleted: {
Expand Down Expand Up @@ -120,6 +133,7 @@ SQLiteDatabase {
databaseValid(result)
}


/*!
The Mnemosyne 2.3 algorithm is more complex allowing for randomization of
cards on a stack and avoiding sister cards.
Expand All @@ -143,11 +157,20 @@ SQLiteDatabase {

initTrackingValues();

var resetDate = new Date(Date.now() - 1000*60*60*24)
resetDate.setHours(settings.resetHour)
resetDate.setMinutes(settings.resetMinute)
var utcDate = new Date(resetDate.getUTCFullYear(), resetDate.getUTCMonth(), resetDate.getUTCDate(), resetDate.getUTCHours(), resetDate.getUTCMinutes(), resetDate.getUTCSeconds(), resetDate.getUTCMilliseconds())

Console.debug("Current date: " + resetDate.getTime() / 1000)
Console.debug("Current UTC date: " + utcDate.getTime() / 1000)
Console.debug("searching in graded pool")
var result = exec("SELECT * FROM cards WHERE grade>=2 " +
"AND strftime('%s',datetime('now', 'start of day', '-1 day')) >=next_rep AND active=1 " +
prepare("SELECT * FROM cards WHERE grade>=2 " +
"AND :nextRep >= next_rep AND active=1 " +
"ORDER BY next_rep DESC LIMIT 1;")
if(!result) {
bind(":nextRep", resetDate.getTime() / 1000)
var result;
if(!(result = exec())) {
Console.error("next: " + "memory stack " + lastError)
return
}
Expand Down
2 changes: 1 addition & 1 deletion qml/harbour-nemosyne.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ApplicationWindow
}
}

Component.onCompleted: Console.LOG_PRIORITY = Console.INFO
Component.onCompleted: Console.LOG_PRIORITY = Console.DEBUG
}


3 changes: 3 additions & 0 deletions qml/pages/Question.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Dialog {
fileName: "settings"

property int defaultFontSizeId: 0
property string timeText: "00:00"

onTimeTextChanged: _next()
}

DynamicLoader {
Expand Down
38 changes: 38 additions & 0 deletions qml/pages/Settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Page {

property int defaultFontSizeId: 0
property bool slideRatings: false
property int resetHour: 0
property int resetMinute: 0
property int hourMode: DateTime.DefaultHours
property string timeText: "00:00"
}

Binding { target: settings; property: "defaultFontSizeId"; value: fontCombo.currentIndex }
Expand All @@ -27,6 +31,22 @@ Page {
}
}

Component {
id: timePicker
TimePickerDialog {
property int h: settings.resetHour

hour: hourMode === DateTime.TwelveHours ? (h == 12 ? 12 : h % 12) : h
minute: settings.resetMinute

onAccepted: {
settings.resetHour = hour
settings.resetMinute = minute
settings.timeText = timeText
}
}
}

PageColumn {
title: qsTr("Settings")

Expand All @@ -51,5 +71,23 @@ Page {
text: qsTr("Use Indicators")
checked: settings.slideRatings
}

Row {
spacing: Theme.paddingLarge

InformationalLabel {
color: Theme.primaryColor
text: qsTr("Card Reset Time")
}

LabelButton {
id: button
text: settings.timeText

onClicked: {
pageStack.push(timePicker, {})
}
}
}
}
}
4 changes: 4 additions & 0 deletions translations/harbour-nemosyne-ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
<source>Rate cards by indicators instead of push-up menu</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Card Reset Time</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatusBar</name>
Expand Down
4 changes: 4 additions & 0 deletions translations/harbour-nemosyne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
<source>Rate cards by indicators instead of push-up menu</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Card Reset Time</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatusBar</name>
Expand Down

0 comments on commit 2144b8f

Please sign in to comment.