Changeset 27564

Show
Ignore:
Timestamp:
11/16/08 18:02:40 (2 months ago)
Author:
sts
Message:

* complete-accept directly completes if the completion is unique

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lyx-devel/trunk/src/frontends/qt4/GuiCompleter.cpp

    r27561 r27564  
    235235 
    236236 
     237bool GuiCompleter::uniqueCompletionAvailable() const 
     238{ 
     239        if (!modelActive_) 
     240                return false; 
     241 
     242        size_t n = popup()->model()->rowCount(); 
     243        if (n > 1 || n == 0) 
     244                return false; 
     245 
     246        // if there is exactly one, we have to check whether it is a  
     247        // real completion, i.e. longer than the current prefix. 
     248        if (completionPrefix() == currentCompletion()) 
     249                return false; 
     250 
     251        return true; 
     252} 
     253 
     254 
    237255bool GuiCompleter::completionAvailable() const 
    238256{ 
     
    639657         
    640658        // check that inline completion is active 
    641         if (!inlineVisible()) { 
     659        if (!inlineVisible() && !uniqueCompletionAvailable()) { 
    642660                // try to activate the inline completion 
    643661                if (cur.inset().inlineCompletionSupported(cur)) { 
     
    661679        } 
    662680         
     681        // Make undo possible 
     682        cur.recordUndo(); 
     683 
    663684        // If completion is active, at least complete by one character 
    664685        docstring prefix = cur.inset().completionPrefix(cur); 
     
    803824                return docstring(); 
    804825        QString s = model.data(model.index(0, 0), Qt::EditRole).toString(); 
    805          
     826 
    806827        if (modelSorting() == QCompleter::UnsortedModel) { 
    807828                // For unsorted model we cannot do more than iteration. 
     
    852873        cur.updateFlags(Update::None); 
    853874         
     875        cur.recordUndo(); 
     876 
    854877        docstring prefix = cur.inset().completionPrefix(cur); 
    855878        docstring postfix = qstring_to_ucs4(completion.mid(prefix.length())); 
  • lyx-devel/trunk/src/frontends/qt4/GuiCompleter.h

    r25108 r27564  
    7171        /// 
    7272        docstring longestUniqueCompletion() const; 
     73        /// 
     74        bool uniqueCompletionAvailable() const; 
    7375         
    7476public Q_SLOTS: