Skip to content

Commit

Permalink
Signal if we are able to assign dictionnary
Browse files Browse the repository at this point in the history
  • Loading branch information
Montel committed Oct 30, 2017
1 parent d87a940 commit 46156b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ui/dictionarycombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,26 @@ QString DictionaryComboBox::currentDictionary() const
return itemData(currentIndex()).toString();
}

void DictionaryComboBox::setCurrentByDictionaryName(const QString &name)
bool DictionaryComboBox::assignDictionnaryName(const QString &name)
{
if (name.isEmpty() || name == currentText()) {
return;
return false;
}

int idx = findText(name);
if (idx == -1) {
qCDebug(SONNET_LOG_UI) << "name not found" << name;
return;
return false;
}

setCurrentIndex(idx);
d->slotDictionaryChanged(idx);
return true;
}

void DictionaryComboBox::setCurrentByDictionaryName(const QString &name)
{
assignDictionnaryName(name);
}

void DictionaryComboBox::setCurrentByDictionary(const QString &dictionary)
Expand Down
9 changes: 9 additions & 0 deletions src/ui/dictionarycombobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,20 @@ class SONNETUI_EXPORT DictionaryComboBox : public QComboBox
*/
void setCurrentByDictionaryName(const QString &dictionaryName);

/**
* Sets the current dictionaryName to the given dictionaryName
* Return true if dictionnary was found.
* @since 5.40
* TODO merge with previous method in kf6
*/
bool assignDictionnaryName(const QString &name);

/**
* Sets the current dictionary to the given dictionary.
*/
void setCurrentByDictionary(const QString &dictionary);


Q_SIGNALS:
/**
* @em Emitted whenever the current dictionary changes. Either
Expand Down

0 comments on commit 46156b1

Please sign in to comment.