blob: 3207d45a8b2e2237cdaf127959c22f997d953574 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
//
// C++ Implementation: leitnersystem
//
// Description:
//
//
// Author: Martin Pfeiffer <[email protected]>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "leitnersystem.h"
#include <kdebug.h>
LeitnerSystem::LeitnerSystem(TQValueList<LeitnerBox>& boxes, TQString name)
{
if( !boxes.empty() )
m_boxes = boxes;
if( name.isNull() )
m_systemName = name;
}
LeitnerSystem::LeitnerSystem()
{
}
LeitnerSystem::~LeitnerSystem()
{
}
TQStringList LeitnerSystem::getBoxNameList()
{
TQStringList boxNameList;
TQValueList<LeitnerBox>::iterator it;
for(it = m_boxes.begin(); it != m_boxes.end(); ++it)
{
boxNameList.append((*it).getBoxName());
}
return boxNameList;
}
int LeitnerSystem::getNumberOfBoxes()
{
return m_boxes.count();
}
LeitnerBox* LeitnerSystem::getBoxWithNumber( int number )
{
return &m_boxes[ number ];
}
LeitnerBox* LeitnerSystem::getBoxWithName( const TQString& name )
{
TQValueList<LeitnerBox>::iterator it;
for(it = m_boxes.begin(); it != m_boxes.end(); ++it)
{
if((*it).getBoxName() == name)
return &(*it);
}
return 0;
}
TQString& LeitnerSystem::getSystemName()
{
return m_systemName;
}
const TQString& LeitnerSystem::getNextBox( TQString& previousBox )
{
for( int i = 0; i < m_boxes.count(); i++ )
{
if( m_boxes[i].getVocabCount() > 0 )
return getBox( i );
}
return TQString::null;
}
const TQString& LeitnerSystem::getCorrectBox( int box )
{
return m_boxes[ box ].getCorrectWordBox()->getBoxName();
}
const TQString& LeitnerSystem::getWrongBox( int box )
{
return m_boxes[ box ].getWrongWordBox()->getBoxName();
}
int LeitnerSystem::getWrongBoxNumber( int box )
{
return getNumber( m_boxes[ box ].getWrongWordBox() );
}
int LeitnerSystem::getCorrectBoxNumber( int box )
{
return getNumber( m_boxes[ box ].getCorrectWordBox() );
}
void LeitnerSystem::deleteBox( int box )
{
m_boxes.remove( m_boxes.at( box ) );
}
void LeitnerSystem::deleteBox( LeitnerBox* box )
{
m_boxes.remove( *box );
}
bool LeitnerSystem::insertBox( const TQString& name, int correctWordBox, int wrongWordBox )
{
if( getBoxNameList().tqcontains( name ) != 0 )
return false;
LeitnerBox tmpBox;
tmpBox.setBoxName( name );
tmpBox.setCorrectWordBox( getBoxWithNumber( correctWordBox ) );
tmpBox.setWrongWordBox( getBoxWithNumber( wrongWordBox ) );
m_boxes.append( tmpBox );
return true;
}
void LeitnerSystem::setSystemName( const TQString& name )
{
m_systemName = name;
}
int LeitnerSystem::getNumber( LeitnerBox* box )
{
if( m_boxes.findIndex( *box ) == -1 )
kdDebug() << "muhaha" << endl;
return m_boxes.findIndex( *box );
}
bool LeitnerSystem::setBoxName( int box, const TQString& name )
{
if( getBoxWithName( name ) == 0 || getBoxWithName( name ) == getBoxWithNumber( box ) )
{
getBoxWithNumber( box )->setBoxName( name );
return true;
}
else
return false;
}
bool LeitnerSystem::setBoxName( LeitnerBox* box, const TQString& name )
{
if( getBoxWithName( name ) == 0 || getBoxWithName( name ) == box )
{
box->setBoxName( name );
return true;
}
else
return false;
}
bool LeitnerSystem::insertBox( const TQString& name )
{
if( getBoxNameList().tqcontains( name ) != 0 )
return false;
LeitnerBox tmpBox;
tmpBox.setBoxName( name );
//tmpBox.setVocabCount( count );
m_boxes.append( tmpBox );
return true;
}
void LeitnerSystem::setCorrectBox( const TQString& box, const TQString& correctWordBox )
{
getBoxWithName( box )->setCorrectWordBox( getBoxWithName( correctWordBox ) );
}
void LeitnerSystem::setWrongBox( const TQString& box, const TQString& wrongWordBox )
{
getBoxWithName( box )->setWrongWordBox( getBoxWithName( wrongWordBox ) );
}
const TQString& LeitnerSystem::getBox( int i )
{
return getBoxWithNumber( i )->getBoxName();
}
|