~beernarrd/ubuntu-keyboard/slovenian-layout

« back to all changes in this revision

Viewing changes to src/view/abstracttexteditor.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-05-27 15:37:47 UTC
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: package-import@ubuntu.com-20140527153747-1kyarbk91aon0tu6
Tags: upstream-0.99.trunk.phablet2+14.10.20140527
ImportĀ upstreamĀ versionĀ 0.99.trunk.phablet2+14.10.20140527

Show diffs side-by-side

added added

removed removed

Lines of Context:
742
742
    return leftSurrounding.right(length);
743
743
}
744
744
 
745
 
//! \brief Emits wordCandidatesChanged() signal with current preedit
746
 
//! as a candidate.
747
 
void AbstractTextEditor::showUserCandidate()
748
 
{
749
 
    Q_D(AbstractTextEditor);
750
 
 
751
 
    if (d->text->preedit().isEmpty()) {
752
 
        return;
753
 
    }
754
 
 
755
 
    WordCandidateList candidates;
756
 
    WordCandidate candidate(WordCandidate::SourceUser, d->text->preedit());
757
 
 
758
 
    candidates << candidate;
759
 
 
760
 
    Q_EMIT wordCandidatesChanged(candidates);
761
 
}
762
 
 
763
745
//! \brief Adds \a word to user dictionary.
764
746
//! \param word Word to be added.
765
747
void AbstractTextEditor::addToUserDictionary(const QString &word)
787
769
{
788
770
    Q_D(AbstractTextEditor);
789
771
 
 
772
    QString textOnLeft = d->text->surroundingLeft();
 
773
 
790
774
    if (d->text->preedit().isEmpty()) {
791
775
        sendKeyPressAndReleaseEvents(Qt::Key_Backspace, Qt::NoModifier);
 
776
        // Deletion of surrounding text isn't updated in the model until later
 
777
        // Update it locally here for autocaps detection
 
778
        textOnLeft.chop(1);
792
779
    } else {
793
780
        d->text->removeFromPreedit(1);
 
781
        textOnLeft += d->text->preedit();
794
782
        
795
783
        // Don't find word candidates if the user is holding down backspace
796
784
        if(!d->repeating_backspace) {
812
800
        }
813
801
    }
814
802
 
 
803
    textOnLeft = textOnLeft.trimmed();
 
804
 
 
805
    const bool auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(textOnLeft);
 
806
    if (auto_caps_activated && d->auto_caps_enabled) {
 
807
        Q_EMIT autoCapsActivated();
 
808
    }
 
809
 
815
810
    d->backspace_sent = true;
816
811
}
817
812