|
Revision 1, 1.5 kB
(checked in by mjoc, 2 years ago)
|
Initial import.
|
| Line | |
|---|
| 1 |
# OpenDict |
|---|
| 2 |
# Copyright (c) 2003 Martynas Jocius <mjoc@akl.lt> |
|---|
| 3 |
# |
|---|
| 4 |
# This program is free software; you can redistribute it and/or modify |
|---|
| 5 |
# it under the terms of the GNU General Public License as published by |
|---|
| 6 |
# the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 |
# (at your opinion) any later version. |
|---|
| 8 |
# |
|---|
| 9 |
# This program is distributed in the hope that will be useful, |
|---|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
# MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
# GNU General Public License for more detals. |
|---|
| 13 |
# |
|---|
| 14 |
# You shoud have received a copy of the GNU General Public License |
|---|
| 15 |
# along with this program; if not, write to the Free Software |
|---|
| 16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|---|
| 17 |
# 02111-1307 USA |
|---|
| 18 |
# |
|---|
| 19 |
# Module: history |
|---|
| 20 |
|
|---|
| 21 |
class History: |
|---|
| 22 |
|
|---|
| 23 |
def __init__(self): |
|---|
| 24 |
|
|---|
| 25 |
self.pages = [] |
|---|
| 26 |
self.index = -1 |
|---|
| 27 |
|
|---|
| 28 |
def add(self, page): |
|---|
| 29 |
|
|---|
| 30 |
self.pages.append(page) |
|---|
| 31 |
self.index = len(self.pages) - 1 |
|---|
| 32 |
|
|---|
| 33 |
def clear(self): |
|---|
| 34 |
|
|---|
| 35 |
self.pages = [] |
|---|
| 36 |
self.index = -1 |
|---|
| 37 |
|
|---|
| 38 |
def back(self): |
|---|
| 39 |
|
|---|
| 40 |
if self.index > 0: |
|---|
| 41 |
self.index -= 1 |
|---|
| 42 |
page = self.pages[self.index] |
|---|
| 43 |
else: |
|---|
| 44 |
page = self.pages[self.index] |
|---|
| 45 |
|
|---|
| 46 |
return page |
|---|
| 47 |
|
|---|
| 48 |
def forward(self): |
|---|
| 49 |
|
|---|
| 50 |
if self.index < len(self.pages) - 1: |
|---|
| 51 |
self.index += 1 |
|---|
| 52 |
page = self.pages[self.index] |
|---|
| 53 |
else: |
|---|
| 54 |
page = self.pages[self.index] |
|---|
| 55 |
|
|---|
| 56 |
return page |
|---|
| 57 |
|
|---|
| 58 |
def canBack(self): |
|---|
| 59 |
|
|---|
| 60 |
return self.index > 0 |
|---|
| 61 |
|
|---|
| 62 |
def canForward(self): |
|---|
| 63 |
|
|---|
| 64 |
return self.index < len(self.pages) - 1 |
|---|
| 65 |
|
|---|