28 #include <QPushButton>
39 QString FromToEntryPage::gradeToString(
int i)
43 return i18n(KV_NORM_TEXT);
46 return i18n(KV_LEV1_TEXT);
49 return i18n(KV_LEV2_TEXT);
52 return i18n(KV_LEV3_TEXT);
55 return i18n(KV_LEV4_TEXT);
58 return i18n(KV_LEV5_TEXT);
61 return i18n(KV_LEV6_TEXT);
64 return i18n(KV_LEV7_TEXT);
67 return i18n(KV_LEV1_TEXT);
77 m_translationFrom = fromIdentifier;
78 m_translationTo = toIdentifier;
82 connect(fauxami_line, SIGNAL(textChanged(
const QString&)),
this, SLOT(slotFalseFriendChanged(
const QString &)));
84 connect(never, SIGNAL(clicked()),
this, SLOT(slotNever()));
85 connect(today, SIGNAL(clicked()),
this, SLOT(slotToday()));
86 connect(gradebox, SIGNAL(activated(
int)),
this, SLOT(slotGradeSelected(
int)));
88 connect(queryDateEdit, SIGNAL(dateChanged(
const QDate &)),
this, SLOT(slotDateChanged(
const QDate &)));
89 connect(totalCountEdit, SIGNAL(valueChanged(
int)),
this, SLOT(totalCountChanged(
int)));
90 connect(badCountEdit, SIGNAL(valueChanged(
int)),
this, SLOT(badCountChanged(
int)));
92 connect(resetGradesButton, SIGNAL(clicked()), SLOT(slotResetGrades()));
94 for (
int i = 0; i <= KV_MAX_GRADE; i++) {
95 gradebox->addItem(gradeToString(i));
101 void FromToEntryPage::slotFalseFriendChanged(
const QString& s)
110 m_gradeChanged =
true;
118 m_practiceDateChanged =
true;
124 void FromToEntryPage::slotNever()
126 m_practiceDateChanged =
true;
127 queryDateEdit->setDate(queryDateEdit->minimumDate());
128 queryDateEdit->setTime(queryDateEdit->minimumTime());
133 void FromToEntryPage::slotDateChanged(
const QDate & d)
135 m_practiceDateChanged =
true;
142 m_totalCountChanged =
true;
149 m_wrongCountChanged =
true;
160 direc_label->setTitle(
QString(i18n(
"Confidence Levels from %1 to %2", m_doc->identifier(m_translationFrom).name(), m_doc->identifier(m_translationTo).name())));
162 KEduVocExpression *firstEntry = m_doc->entry(m_entries.
value(0));
164 queryDateEdit->setDateTime(
165 firstEntry->translation(m_translationTo)
166 .gradeFrom(m_translationFrom).practiceDate());
168 gradebox->setCurrentIndex(firstEntry->translation(m_translationTo).gradeFrom(m_translationFrom).grade());
170 totalCountEdit->setValue(firstEntry->translation(m_translationTo).gradeFrom(m_translationFrom).practiceCount());
172 badCountEdit->setValue(firstEntry->translation(m_translationTo).gradeFrom(m_translationFrom).badCount());
174 if (m_entries.
count() > 1) {
176 foreach(
int entry, m_entries) {
178 KEduVocExpression *currentEntry = m_doc->entry(entry);
179 if (firstEntry->translation(m_translationTo)
180 .gradeFrom(m_translationFrom).grade()
181 != currentEntry->translation(m_translationTo)
182 .gradeFrom(m_translationFrom).grade()) {
183 gradebox->setCurrentIndex(-1);
186 if (firstEntry->translation(m_translationTo)
187 .gradeFrom(m_translationFrom).practiceDate()
188 != currentEntry->translation(m_translationTo)
189 .gradeFrom(m_translationFrom).practiceDate()) {
190 queryDateEdit->setDate(queryDateEdit->minimumDate());
191 queryDateEdit->setTime(queryDateEdit->minimumTime());
195 if (firstEntry->translation(m_translationTo)
196 .gradeFrom(m_translationFrom).practiceCount()
197 != currentEntry->translation(m_translationTo)
198 .gradeFrom(m_translationFrom).practiceCount()) {
199 totalCountEdit->clear();
203 if (firstEntry->translation(m_translationTo)
204 .gradeFrom(m_translationFrom).badCount()
205 != currentEntry->translation(m_translationTo)
206 .gradeFrom(m_translationFrom).badCount()) {
207 badCountEdit->clear();
211 fauxami_line->setEnabled(
false);
212 fauxami_line->setText(
QString());
214 fauxami_line->setEnabled(
true);
215 fauxami_line->setText(firstEntry->translation(m_translationTo).falseFriend(m_translationFrom));
218 m_gradeChanged =
false;
219 m_practiceDateChanged =
false;
220 m_totalCountChanged =
false;
221 m_wrongCountChanged =
false;
227 kDebug() <<
"Grade page commit data: " << m_translationFrom << m_translationTo;
228 if (m_entries.
count() == 1) {
230 KEduVocTranslation * trans = &m_doc->entry(m_entries.
value(0))->translation(m_translationTo);
231 trans->setFalseFriend(m_translationFrom, fauxami_line->text());
235 foreach(
int entry, m_entries) {
236 if (m_gradeChanged) {
237 m_doc->entry(entry)->translation(m_translationTo).gradeFrom(m_translationFrom).setGrade(gradebox->currentIndex());
239 if (m_totalCountChanged) {
240 m_doc->entry(entry)->translation(m_translationTo).gradeFrom(m_translationFrom).setPracticeCount(totalCountEdit->value());
242 if (m_wrongCountChanged) {
243 m_doc->entry(entry)->translation(m_translationTo).gradeFrom(m_translationFrom).setBadCount(badCountEdit->value());
245 if (m_practiceDateChanged) {
246 m_doc->entry(entry)->translation(m_translationTo).gradeFrom(m_translationFrom).setPracticeDate(queryDateEdit->dateTime());
251 void FromToEntryPage::slotResetGrades()
253 queryDateEdit->setDate(queryDateEdit->minimumDate());
254 queryDateEdit->setTime(queryDateEdit->minimumTime());
256 gradebox->setCurrentIndex(KV_MIN_GRADE);
257 totalCountEdit->setValue(0);
258 badCountEdit->setValue(0);
260 m_gradeChanged =
true;
261 m_practiceDateChanged =
true;
262 m_totalCountChanged =
true;
263 m_wrongCountChanged =
true;
269 #include "FromToEntryPage.moc"
int count(const T &value) const
QDateTime currentDateTime()
void setData(const QList< int > &entries)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
FromToEntryPage(KEduVocDocument *doc, int fromIdentifier, int toIdentifier, QWidget *parent=0)