-rw-r--r-- | noncore/apps/opie-reader/Navigation.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/Navigation.cpp b/noncore/apps/opie-reader/Navigation.cpp index 7b392ba..4f11887 100644 --- a/noncore/apps/opie-reader/Navigation.cpp +++ b/noncore/apps/opie-reader/Navigation.cpp | |||
@@ -1,50 +1,52 @@ | |||
1 | #include "Navigation.h" | 1 | #include "Navigation.h" |
2 | 2 | ||
3 | #include <string.h> | ||
4 | |||
3 | void CNavigation::saveposn(size_t posn) | 5 | void CNavigation::saveposn(size_t posn) |
4 | { | 6 | { |
5 | // qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend); | 7 | // qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend); |
6 | historycurrent = historyend = (historycurrent+1)%NAVIGATION_HISTORY_SIZE; | 8 | historycurrent = historyend = (historycurrent+1)%NAVIGATION_HISTORY_SIZE; |
7 | history[historycurrent] = posn; | 9 | history[historycurrent] = posn; |
8 | if (historystart == historyend) historystart = (historystart+1)%NAVIGATION_HISTORY_SIZE; | 10 | if (historystart == historyend) historystart = (historystart+1)%NAVIGATION_HISTORY_SIZE; |
9 | // qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend); | 11 | // qDebug("Saved:%u [%u,%u,%u]", posn, historystart, historycurrent, historyend); |
10 | } | 12 | } |
11 | 13 | ||
12 | bool CNavigation::forward(size_t& loc) | 14 | bool CNavigation::forward(size_t& loc) |
13 | { | 15 | { |
14 | if (historycurrent != historyend) | 16 | if (historycurrent != historyend) |
15 | { | 17 | { |
16 | historycurrent = (historycurrent + 1)%NAVIGATION_HISTORY_SIZE; | 18 | historycurrent = (historycurrent + 1)%NAVIGATION_HISTORY_SIZE; |
17 | loc = history[historycurrent]; | 19 | loc = history[historycurrent]; |
18 | //qDebug("Forward:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); | 20 | //qDebug("Forward:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); |
19 | return true; | 21 | return true; |
20 | } | 22 | } |
21 | else | 23 | else |
22 | { | 24 | { |
23 | return false; | 25 | return false; |
24 | } | 26 | } |
25 | } | 27 | } |
26 | 28 | ||
27 | bool CNavigation::back(size_t& loc) | 29 | bool CNavigation::back(size_t& loc) |
28 | { | 30 | { |
29 | if (historyend != historystart) | 31 | if (historyend != historystart) |
30 | { | 32 | { |
31 | //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); | 33 | //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); |
32 | if (historycurrent == historyend && history[historycurrent] != loc) | 34 | if (historycurrent == historyend && history[historycurrent] != loc) |
33 | { | 35 | { |
34 | historyend = (historyend+1) % NAVIGATION_HISTORY_SIZE; | 36 | historyend = (historyend+1) % NAVIGATION_HISTORY_SIZE; |
35 | history[historyend] = loc; | 37 | history[historyend] = loc; |
36 | } | 38 | } |
37 | else | 39 | else |
38 | { | 40 | { |
39 | size_t sv = historycurrent; | 41 | size_t sv = historycurrent; |
40 | historycurrent = (historycurrent + NAVIGATION_HISTORY_SIZE - 1) % NAVIGATION_HISTORY_SIZE; | 42 | historycurrent = (historycurrent + NAVIGATION_HISTORY_SIZE - 1) % NAVIGATION_HISTORY_SIZE; |
41 | if (historycurrent == historystart) | 43 | if (historycurrent == historystart) |
42 | { | 44 | { |
43 | historycurrent = sv; | 45 | historycurrent = sv; |
44 | return false; | 46 | return false; |
45 | } | 47 | } |
46 | } | 48 | } |
47 | loc = history[historycurrent]; | 49 | loc = history[historycurrent]; |
48 | //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); | 50 | //qDebug("Back:%u [%u,%u,%u]", loc, historystart, historycurrent, historyend); |
49 | return true; | 51 | return true; |
50 | } | 52 | } |