24 #include <qpushbutton.h>
25 #include <qlistwidget.h>
26 #include <qlineedit.h>
31 #include <kstandarddirs.h>
34 #include <kmessagebox.h>
37 #include "keduvocdocument.h"
38 #include "keduvocexpression.h"
47 if(!fileName.isEmpty())
49 m_fileName = fileName;
50 KEduVocDocument *doc =
new KEduVocDocument(
this);
51 doc->open(KUrl::fromPath(m_fileName));
52 for(
int i = 0; i < doc->lesson()->entryCount(KEduVocLesson::Recursive); i++)
54 KEduVocExpression expr = *doc->lesson()->entries(KEduVocLesson::Recursive).value(i);
55 m_vocabList.append(expr);
56 lboxWords->addItem(doc->lesson()->entries(KEduVocLesson::Recursive).value(i)->translation(0)->text());
58 txtVocabName->setText(doc->title());
59 txtDescription->setText(doc->documentComment());
62 connect(btnSave, SIGNAL(clicked()),
this, SLOT(
slotSave()));
63 connect(btnNewWord, SIGNAL(clicked()),
this, SLOT(
slotNewWord()));
64 connect(btnRemoveWord, SIGNAL(clicked()),
this, SLOT(
slotRemoveWord()));
65 connect(btnClose, SIGNAL(clicked()),
this, SLOT(
slotClose()));
72 connect(txtVocabName, SIGNAL(textChanged(QString)),
this, SLOT(
slotTextChanged(QString)));
73 connect(txtDescription, SIGNAL(textChanged(QString)),
this, SLOT(
slotTextChanged(QString)));
78 m_textChanged =
false;
87 KEduVocDocument *doc =
new KEduVocDocument(
this);
88 doc->setTitle(txtVocabName->text());
89 doc->setDocumentComment(txtDescription->text());
91 doc->appendIdentifier(
id);
92 for(
int i = 0; i < m_vocabList.size(); i++)
94 doc->lesson()->appendEntry(&m_vocabList[i]);
97 QString fileName = txtVocabName->text().toLower().remove(
' ') +
".kvtml";
98 doc->saveAs(KUrl::fromPath(KGlobal::dirs()->saveLocation(
"data",
"kvtml/" +
KanagramSettings::dataLanguage()) + fileName), KEduVocDocument::Automatic,
"kanagram");
102 m_textChanged =
false;
108 if(m_textChanged && lboxWords->count() > 0)
110 int code = KMessageBox::warningYesNo(
this, i18n(
"Would you like to save your changes?"), i18n(
"Save Changes Dialog"));
111 if(code == KMessageBox::Yes)
125 lboxWords->addItem(i18n(
"New Item"));
126 KEduVocExpression expr = KEduVocExpression();
127 m_vocabList.append(expr);
128 m_textChanged =
true;
134 disconnect(txtWord, SIGNAL(textChanged(QString)),
this, SLOT(
slotWordTextChanged(QString)));
135 disconnect(txtHint, SIGNAL(textChanged(QString)),
this, SLOT(
slotHintTextChanged(QString)));
136 if(lboxWords->currentRow() >= 0)
138 txtWord->setText(m_vocabList[lboxWords->currentRow()].translation(0)->text());
139 txtHint->setText(m_vocabList[lboxWords->currentRow()].translation(0)->comment());
148 if(lboxWords->currentRow() != -1)
150 m_vocabList[lboxWords->currentRow()].setTranslation(0, changes);
151 lboxWords->currentItem()->setText(changes);
153 m_textChanged =
true;
159 if(lboxWords->currentRow() != -1)
160 m_vocabList[lboxWords->currentRow()].translation(0)->setComment(changes);
161 m_textChanged =
true;
168 m_textChanged =
true;
176 if (lboxWords->count()) {
177 m_vocabList.erase(m_vocabList.begin() + lboxWords->currentRow());
178 delete lboxWords->takeItem(lboxWords->currentRow());
181 m_textChanged =
true;
184 #include "vocabedit.moc"
void slotTextChanged(const QString &changes)
VocabEdit(QWidget *parent)
void refreshView()
reload the list of vocabularies from what's on disk
void slotWordTextChanged(const QString &changes)
Vocabulary Settings class.
void slotHintTextChanged(const QString &changes)
static QString dataLanguage()
Get Set the default translation.
void slotSelectionChanged()