// Add each dictionary to the spell check list widget.
foreach(QString dictionaryString, dictionariesStringList)
{
- // Create a new list widget item pointer named after the dictionary string.
- QListWidgetItem *listWidgetItemPointer = new QListWidgetItem(dictionaryString, spellCheckListWidgetPointer);
+ // Create a new list widget item pointer.
+ QListWidgetItem *listWidgetItemPointer = new QListWidgetItem();
- // Set the list widget item pointer to be checkable.
- listWidgetItemPointer->setFlags(listWidgetItemPointer->flags() | Qt::ItemIsUserCheckable);
+ // Create a dictionary check box widget with the name of the dictionary string.
+ QCheckBox *dictionaryCheckBoxWidget = new QCheckBox(dictionaryString);
// Check the language if it is currently enabled.
if (enabledSpellCheckLanguagesList.contains(dictionaryString))
- listWidgetItemPointer->setCheckState(Qt::Checked);
+ dictionaryCheckBoxWidget->setCheckState(Qt::Checked);
else
- listWidgetItemPointer->setCheckState(Qt::Unchecked);
+ dictionaryCheckBoxWidget->setCheckState(Qt::Unchecked);
- // Add the list widget item to the widget.
+ // Add the list widget item to the spell check list widget.
spellCheckListWidgetPointer->addItem(listWidgetItemPointer);
+
+ // Set the list widget item check box widget.
+ spellCheckListWidgetPointer->setItemWidget(listWidgetItemPointer, dictionaryCheckBoxWidget);
}
// Get a handle for the KConfig skeleton.
// Get the language item.
QListWidgetItem *languageItemPointer = spellCheckListWidgetPointer->item(i);
+ // Get the language check box.
+ QCheckBox *languageCheckBoxPointer = qobject_cast<QCheckBox*>(spellCheckListWidgetPointer->itemWidget(languageItemPointer));
+
// Add the item to the enabled languages if it is checked.
- if (languageItemPointer->checkState() == Qt::Checked)
- newSpellCheckLanguages.append(languageItemPointer->text());
+ if (languageCheckBoxPointer->checkState() == Qt::Checked)
+ {
+ // Get the text.
+ QString languageString = languageCheckBoxPointer->text();
+
+ // Remove all instances of `&`, which may have been added automatically when creating the check box text.
+ languageString.remove(QChar('&'));
+
+ // Add the language string to the list.
+ newSpellCheckLanguages.append(languageString);
+ }
}
// Update the spell check languages.