16 #include <keduvocdocument.h>
17 #include <keduvocexpression.h>
18 #include <keduvocwordtype.h>
19 #include <keduvocdeclension.h>
26 using namespace Editor;
30 m_wordTypeWidget =
new QWidget(
this);
31 QVBoxLayout *wordTypeLayout =
new QVBoxLayout();
33 QLabel *label =
new QLabel();
34 wordTypeLayout->addWidget(label);
36 QPushButton *toVerb =
new QPushButton(i18n(
"Verb"));
37 toVerb->setObjectName(
"toVerb");
38 connect(toVerb, SIGNAL(pressed()),
this, SLOT(setWordType()));
39 wordTypeLayout->addWidget(toVerb, 1);
41 QPushButton *toNoun =
new QPushButton(i18n(
"Noun"));
42 toNoun->setObjectName(
"toNoun");
43 connect(toNoun, SIGNAL(pressed()),
this, SLOT(setWordType()));
44 wordTypeLayout->addWidget(toNoun, 1);
46 QPushButton *toAdjective =
new QPushButton(i18n(
"Adjective"));
47 toAdjective->setObjectName(
"toAdjective");
48 connect(toAdjective, SIGNAL(pressed()),
this, SLOT(setWordType()));
49 wordTypeLayout->addWidget(toAdjective, 1);
51 wordTypeLayout->addStretch();
53 m_wordTypeWidget->setDisabled(
true);
54 m_wordTypeWidget->setLayout(wordTypeLayout);
59 addWidget(m_wordTypeWidget);
60 addWidget(m_conjugationWidget);
61 addWidget(m_declensionWidget);
74 m_translation = translation;
76 if (!entry || !entry->translation(translation)) {
77 m_wordTypeWidget->setDisabled(
true);
78 setCurrentWidget(m_wordTypeWidget);
81 if (!entry->translation(translation)->wordType() ||
82 !(entry->translation(translation)->wordType()->wordType() & KEduVocWordFlag::Verb
83 || entry->translation(translation)->wordType()->wordType() & KEduVocWordFlag::Noun
84 || entry->translation(translation)->wordType()->wordType() & KEduVocWordFlag::Adjective
87 qobject_cast<QLabel*>(m_wordTypeWidget->layout()->itemAt(0)->widget())->setText(i18n(
"\"%1\" is a:", entry->translation(translation)->text()));
88 m_wordTypeWidget->setEnabled(
true);
89 setCurrentWidget(m_wordTypeWidget);
96 if (entry->translation(translation)->wordType()->wordType() & KEduVocWordFlag::Verb) {
97 setCurrentWidget(m_conjugationWidget);
100 setCurrentWidget(m_declensionWidget);
104 void InflectionWidget::setWordType()
110 KEduVocWordType* container = 0;
112 if (sender()->objectName() ==
"toVerb") {
113 container = m_doc->wordTypeContainer()->childOfType(KEduVocWordFlag::Verb);
115 else if (sender()->objectName() ==
"toNoun") {
116 KEduVocWordFlags type = KEduVocWordFlag::Noun;
118 QPointer<KDialog> getGenderDialog =
new KDialog(
this);
119 getGenderDialog->setCaption(i18n(
"Please select the noun's gender"));
120 getGenderDialog->setButtons(KDialog::Ok | KDialog::Cancel);
122 KComboBox *genderComboBox =
new KComboBox;
123 genderComboBox->addItem(i18n(
"Masculine"), KEduVocWordFlag::Masculine);
124 genderComboBox->addItem(i18n(
"Neuter"), KEduVocWordFlag::Neuter);
125 genderComboBox->addItem(i18n(
"Feminine"), KEduVocWordFlag::Feminine);
127 getGenderDialog->setMainWidget(genderComboBox);
129 if (getGenderDialog->exec() == KDialog::Accepted)
131 type = (KEduVocWordFlags)(type|genderComboBox->itemData(genderComboBox->currentIndex()).toInt());
134 delete getGenderDialog;
136 container = m_doc->wordTypeContainer()->childOfType(type);
138 else if (sender()->objectName() ==
"toAdjective") {
139 container = m_doc->wordTypeContainer()->childOfType(KEduVocWordFlag::Adjective);
143 m_entry->translation(m_translation)->setWordType(container);