8#include "dictionarycombobox.h"
16class DictionaryComboBoxPrivate
19 explicit DictionaryComboBoxPrivate(DictionaryComboBox *combo)
24 DictionaryComboBox *
const q;
25 void slotDictionaryChanged(
int idx);
28void DictionaryComboBoxPrivate::slotDictionaryChanged(
int idx)
30 Q_EMIT q->dictionaryChanged(q->itemData(idx).toString());
31 Q_EMIT q->dictionaryNameChanged(q->itemText(idx));
38 , d(new DictionaryComboBoxPrivate(this))
41 connect(
this, SIGNAL(activated(
int)), SLOT(slotDictionaryChanged(
int)));
44DictionaryComboBox::~DictionaryComboBox() =
default;
46QString DictionaryComboBox::currentDictionaryName()
const
51QString DictionaryComboBox::currentDictionary()
const
53 return itemData(currentIndex()).toString();
56bool DictionaryComboBox::assignDictionnaryName(
const QString &name)
62 int idx = findText(name);
64 qCDebug(SONNET_LOG_UI) <<
"name not found" <<
name;
69 d->slotDictionaryChanged(idx);
73void DictionaryComboBox::setCurrentByDictionaryName(
const QString &name)
75 assignDictionnaryName(name);
78bool DictionaryComboBox::assignByDictionnary(
const QString &dictionary)
83 if (dictionary == itemData(currentIndex()).
toString()) {
87 int idx = findData(dictionary);
89 qCDebug(SONNET_LOG_UI) <<
"dictionary not found" << dictionary;
94 d->slotDictionaryChanged(idx);
98void DictionaryComboBox::setCurrentByDictionary(
const QString &dictionary)
100 assignByDictionnary(dictionary);
103void DictionaryComboBox::reloadCombo()
109 while (i.hasNext()) {
111 addItem(i.key(), i.value());
114 insertSeparator(count());
119 while (i.hasNext()) {
121 if (preferredDictionaries.
contains(i.key())) {
124 addItem(i.key(), i.value());
130#include "moc_dictionarycombobox.cpp"
DictionaryComboBox(QWidget *parent=nullptr)
Constructor.
QMap< QString, QString > preferredDictionaries() const
QMap< QString, QString > availableDictionaries() const
char * toString(const EngineQuery &query)
QString name(GameStandardAction id)
bool contains(const Key &key) const const
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)