18 #include <QContextMenuEvent>
23 #include <KLocalizedString>
24 #include <KMessageBox>
25 #include <KSelectAction>
27 #include <keduvocexpression.h>
28 #include <keduvocwordtype.h>
34 using namespace Editor;
40 m_actionNewWordType =
new KAction(
this);
41 m_actionNewWordType->setText(i18n(
"New"));
42 m_actionNewWordType->setIcon(KIcon(
"lesson-add"));
43 m_actionNewWordType->setWhatsThis(i18n(
"Add a new word type to your document"));
44 m_actionNewWordType->setToolTip(m_actionNewWordType->whatsThis());
45 m_actionNewWordType->setStatusTip(m_actionNewWordType->whatsThis());
46 m_actionNewWordType->setStatusTip(m_actionNewWordType->whatsThis());
48 m_actionRenameWordType =
new KAction(
this);
49 m_actionRenameWordType->setText(i18n(
"Rename"));
50 m_actionRenameWordType->setIcon(KIcon(
"edit-rename"));
51 m_actionRenameWordType->setWhatsThis(i18n(
"Rename the selected word type"));
52 m_actionRenameWordType->setToolTip(m_actionRenameWordType->whatsThis());
53 m_actionRenameWordType->setStatusTip(m_actionRenameWordType->whatsThis());
54 m_actionRenameWordType->setStatusTip(m_actionRenameWordType->whatsThis());
56 m_actionDeleteWordType =
new KAction(
this);
57 m_actionDeleteWordType->setText(i18n(
"Delete Word Type"));
58 m_actionDeleteWordType->setIcon(KIcon(
"lesson-remove"));
59 m_actionDeleteWordType->setWhatsThis(i18n(
"Delete the selected word type."));
60 m_actionDeleteWordType->setToolTip(m_actionDeleteWordType->whatsThis());
61 m_actionDeleteWordType->setStatusTip(m_actionDeleteWordType->whatsThis());
62 m_actionDeleteWordType->setStatusTip(m_actionDeleteWordType->whatsThis());
64 m_actionSpecialTypeMenu =
new KSelectAction(
this);
65 m_actionSpecialTypeMenu->setText(i18nc(
"Let the user select what grammatical meaning is connected to a word type (nouns have gender, verbs conjugations etc)",
"Grammar"));
67 m_actionSpecialTypeMenu->setWhatsThis(i18n(
"To let Parley know the grammatical meaning of a word type."));
68 m_actionSpecialTypeMenu->setToolTip(m_actionSpecialTypeMenu->whatsThis());
69 m_actionSpecialTypeMenu->setStatusTip(m_actionSpecialTypeMenu->whatsThis());
70 m_actionSpecialTypeMenu->setStatusTip(m_actionSpecialTypeMenu->whatsThis());
73 m_nounAction =
new KAction(
this);
74 m_nounAction->setText(i18n(
"Noun"));
75 m_nounAction->setCheckable(
true);
76 m_nounAction->setWhatsThis(i18n(
"This word type folder contains nouns."));
77 m_nounAction->setToolTip(m_nounAction->whatsThis());
78 m_nounAction->setStatusTip(m_nounAction->whatsThis());
79 m_nounAction->setStatusTip(m_nounAction->whatsThis());
81 m_nounMaleAction =
new KAction(
this);
82 m_nounMaleAction->setText(i18n(
"Masculine Noun"));
83 m_nounMaleAction->setCheckable(
true);
84 m_nounMaleAction->setWhatsThis(i18n(
"This word type folder contains masculine nouns."));
85 m_nounMaleAction->setToolTip(m_nounMaleAction->whatsThis());
86 m_nounMaleAction->setStatusTip(m_nounMaleAction->whatsThis());
87 m_nounMaleAction->setStatusTip(m_nounMaleAction->whatsThis());
89 m_nounFemaleAction =
new KAction(
this);
90 m_nounFemaleAction->setText(i18n(
"Feminine Noun"));
91 m_nounFemaleAction->setCheckable(
true);
92 m_nounFemaleAction->setWhatsThis(i18n(
"This word type folder contains feminine nouns."));
93 m_nounFemaleAction->setToolTip(m_nounFemaleAction->whatsThis());
94 m_nounFemaleAction->setStatusTip(m_nounFemaleAction->whatsThis());
95 m_nounFemaleAction->setStatusTip(m_nounFemaleAction->whatsThis());
97 m_nounNeutralAction =
new KAction(
this);
98 m_nounNeutralAction->setText(i18n(
"Neuter Noun"));
99 m_nounNeutralAction->setCheckable(
true);
100 m_nounNeutralAction->setWhatsThis(i18n(
"This word type folder contains neuter nouns."));
101 m_nounNeutralAction->setToolTip(m_nounNeutralAction->whatsThis());
102 m_nounNeutralAction->setStatusTip(m_nounNeutralAction->whatsThis());
103 m_nounNeutralAction->setStatusTip(m_nounNeutralAction->whatsThis());
105 m_adjectiveAction =
new KAction(
this);
106 m_adjectiveAction->setText(i18n(
"Adjective"));
107 m_adjectiveAction->setCheckable(
true);
108 m_adjectiveAction->setWhatsThis(i18n(
"This word type folder contains adjectives."));
109 m_adjectiveAction->setToolTip(m_adjectiveAction->whatsThis());
110 m_adjectiveAction->setStatusTip(m_adjectiveAction->whatsThis());
111 m_adjectiveAction->setStatusTip(m_adjectiveAction->whatsThis());
113 m_adverbAction =
new KAction(
this);
114 m_adverbAction->setText(i18n(
"Adverb"));
115 m_adverbAction->setCheckable(
true);
116 m_adverbAction->setWhatsThis(i18n(
"This word type folder contains adverbs."));
117 m_adverbAction->setToolTip(m_adverbAction->whatsThis());
118 m_adverbAction->setStatusTip(m_adverbAction->whatsThis());
119 m_adverbAction->setStatusTip(m_adverbAction->whatsThis());
122 m_verbAction =
new KAction(
this);
123 m_verbAction->setText(i18n(
"Verb"));
124 m_verbAction->setCheckable(
true);
125 m_verbAction->setWhatsThis(i18n(
"This word type folder contains verbs."));
126 m_verbAction->setToolTip(m_verbAction->whatsThis());
127 m_verbAction->setStatusTip(m_verbAction->whatsThis());
128 m_verbAction->setStatusTip(m_verbAction->whatsThis());
130 m_conjunctionAction =
new KAction(
this);
131 m_conjunctionAction->setText(i18n(
"Conjunction"));
132 m_conjunctionAction->setCheckable(
true);
133 m_conjunctionAction->setWhatsThis(i18n(
"This word type folder contains conjunctions."));
134 m_conjunctionAction->setToolTip(m_conjunctionAction->whatsThis());
135 m_conjunctionAction->setStatusTip(m_conjunctionAction->whatsThis());
136 m_conjunctionAction->setStatusTip(m_conjunctionAction->whatsThis());
138 m_noneAction =
new KAction(
this);
139 m_noneAction->setText(i18n(
"No Special Type"));
140 m_noneAction->setCheckable(
true);
141 m_noneAction->setChecked(
true);
142 m_noneAction->setWhatsThis(i18n(
"This word type folder contains no word type with special meaning."));
143 m_noneAction->setToolTip(m_noneAction->whatsThis());
144 m_noneAction->setStatusTip(m_noneAction->whatsThis());
145 m_noneAction->setStatusTip(m_noneAction->whatsThis());
150 m_actionSpecialTypeMenu->addAction(m_noneAction);
151 m_actionSpecialTypeMenu->addAction(separator);
152 m_actionSpecialTypeMenu->addAction(m_nounAction);
153 m_actionSpecialTypeMenu->addAction(m_nounMaleAction);
154 m_actionSpecialTypeMenu->addAction(m_nounFemaleAction);
155 m_actionSpecialTypeMenu->addAction(m_nounNeutralAction);
156 m_actionSpecialTypeMenu->addAction(m_adjectiveAction);
157 m_actionSpecialTypeMenu->addAction(m_adverbAction);
158 m_actionSpecialTypeMenu->addAction(m_verbAction);
159 m_actionSpecialTypeMenu->addAction(m_conjunctionAction);
161 connect(m_actionNewWordType, SIGNAL(triggered()),
163 connect(m_actionRenameWordType, SIGNAL(triggered()),
165 connect(m_actionDeleteWordType, SIGNAL(triggered()),
180 connect(m_noneAction, SIGNAL(triggered()),
181 SLOT(setWordTypeNone()));
182 connect(m_nounAction, SIGNAL(triggered()),
183 SLOT(setWordTypeNoun()));
184 connect(m_nounMaleAction, SIGNAL(triggered()),
185 SLOT(setWordTypeNounMale()));
186 connect(m_nounFemaleAction, SIGNAL(triggered()),
187 SLOT(setWordTypeNounFemale()));
188 connect(m_nounNeutralAction, SIGNAL(triggered()),
189 SLOT(setWordTypeNounNeutral()));
190 connect(m_adjectiveAction, SIGNAL(triggered()),
191 SLOT(setWordTypeAdjective()));
192 connect(m_adverbAction, SIGNAL(triggered()),
193 SLOT(setWordTypeAdverb()));
194 connect(m_verbAction, SIGNAL(triggered()),
195 SLOT(setWordTypeVerb()));
196 connect(m_conjunctionAction, SIGNAL(triggered()),
197 SLOT(setWordTypeConjunction()));
216 if (!selectedIndex.
isValid()) {
232 KMessageBox::information(
this, i18n(
"The root word type cannot be deleted."));
236 KEduVocWordType* WordType =
static_cast<KEduVocWordType*
>(selectedIndex.
internalPointer());
238 int count = WordType->entryCount();
241 KMessageBox::warningYesNo(
this, i18np(
"There is a word left with this word type. It will lose its type. Continue?",
"There are %1 words left with this word type. They will lose their word type. Continue?", count)) == KMessageBox::Yes) {
258 m_noneAction->setChecked(
true);
260 else if (t.testFlag(KEduVocWordFlag::Noun) && t.testFlag(KEduVocWordFlag::Masculine))
261 m_nounMaleAction->setChecked(
true);
263 else if (t.testFlag(KEduVocWordFlag::Noun) && t.testFlag(KEduVocWordFlag::Feminine))
264 m_nounFemaleAction->setChecked(
true);
266 else if (t.testFlag(KEduVocWordFlag::Noun) && t.testFlag(KEduVocWordFlag::Neuter))
267 m_nounNeutralAction->setChecked(
true);
269 else if (t.testFlag(KEduVocWordFlag::Noun))
270 m_nounAction->setChecked(
true);
272 else if (t.testFlag(KEduVocWordFlag::Adjective))
273 m_adjectiveAction->setChecked(
true);
275 else if (t.testFlag(KEduVocWordFlag::Adverb))
276 m_adverbAction->setChecked(
true);
278 else if (t.testFlag(KEduVocWordFlag::Verb))
279 m_verbAction->setChecked(
true);
281 else if (t.testFlag(KEduVocWordFlag::Conjunction))
282 m_conjunctionAction->setChecked(
true);
288 void WordTypeView::setWordTypeNone()
291 wordType->setWordType(KEduVocWordFlag::NoInformation);
294 void WordTypeView::setWordTypeNoun()
297 wordType->setWordType(KEduVocWordFlag::Noun);
300 void WordTypeView::setWordTypeNounMale()
303 wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Masculine);
306 void WordTypeView::setWordTypeNounFemale()
309 wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Feminine);
312 void WordTypeView::setWordTypeNounNeutral()
315 wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Neuter);
318 void WordTypeView::setWordTypeAdjective()
321 wordType->setWordType(KEduVocWordFlag::Adjective);
324 void WordTypeView::setWordTypeAdverb()
327 wordType->setWordType(KEduVocWordFlag::Adverb);
330 void WordTypeView::setWordTypeVerb()
333 wordType->setWordType(KEduVocWordFlag::Verb);
337 void WordTypeView::setWordTypeConjunction()
340 wordType->setWordType(KEduVocWordFlag::Conjunction);
344 #include "wordtypeview.moc"
void setSeparator(bool b)
QModelIndex currentIndex() const
QItemSelectionModel * selectionModel() const
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
View for containers (KEduVocContainer).
void slotRename()
let the user type a new name for the container
void setTranslation(KEduVocExpression *entry, int translationId)
void slotCreateNewWordType()
Append a word type to the model and automatically set an edit up so the user can change "New lesson" ...
virtual void select(const QModelIndex &index, QFlags< QItemSelectionModel::SelectionFlag > command)
void * internalPointer() const
QModelIndex parent() const
void contextMenuEvent(QContextMenuEvent *event)
WordTypeView(EditorWindow *parent)
QModelIndex appendContainer(const QModelIndex &parent, const QString &containerName=QString())
ContainerModel * m_model
ContainerModel for this view.
void deleteContainer(const QModelIndex &containerIndex)
void edit(const QModelIndex &index)
void setCurrentIndex(const QModelIndex &index, QFlags< QItemSelectionModel::SelectionFlag > command)
void slotDeleteWordType()
Remove a word type.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)