QTfrontend/ui/widget/SmartLineEdit.cpp
changeset 6149 0b92341adb6a
parent 6147 b4d7d8d62feb
child 6150 1d98752c1fba
equal deleted inserted replaced
6148:726daa066fea 6149:0b92341adb6a
    27     m_whitespace = QRegExp("\\s");
    27     m_whitespace = QRegExp("\\s");
    28 
    28 
    29     m_cmds  = new QStringList();
    29     m_cmds  = new QStringList();
    30     m_nicks = new QStringList();
    30     m_nicks = new QStringList();
    31 
    31 
    32     reset();
    32     resetAutoCompletionStatus();
    33 
    33 
    34     // reset when cursor is moved or content is changed
    34     // reset autocompletion status when cursor is moved or content is changed
    35     connect(this, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(reset()));
    35     connect(this, SIGNAL(cursorPositionChanged(int, int)),
    36     connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(reset()));
    36             this, SLOT(resetAutoCompletionStatus()));
       
    37     connect(this, SIGNAL(textChanged(const QString&)),
       
    38             this, SLOT(resetAutoCompletionStatus()));
    37 }
    39 }
    38 
    40 
    39 
    41 
    40 void SmartLineEdit::addCommands(const QStringList & commands)
    42 void SmartLineEdit::addCommands(const QStringList & commands)
    41 {
    43 {
    75     m_mutex.lock();
    77     m_mutex.lock();
    76 
    78 
    77     m_nicks->removeAll(name);
    79     m_nicks->removeAll(name);
    78 
    80 
    79     m_mutex.unlock();
    81     m_mutex.unlock();
       
    82 }
       
    83 
       
    84 void SmartLineEdit::forgetEverything()
       
    85 {
       
    86     m_mutex.lock();
       
    87 
       
    88     m_cmds->clear();
       
    89     m_nicks->clear();
       
    90 
       
    91     m_mutex.unlock();
       
    92 
       
    93     resetAutoCompletionStatus();
    80 }
    94 }
    81 
    95 
    82 bool SmartLineEdit::event(QEvent * event)
    96 bool SmartLineEdit::event(QEvent * event)
    83 {
    97 {
    84     // we only want special treatment for key press events
    98     // we only want special treatment for key press events
   235         m_prefix = prefix;
   249         m_prefix = prefix;
   236         m_postfix = postfix;
   250         m_postfix = postfix;
   237     }
   251     }
   238 }
   252 }
   239 
   253 
   240 void SmartLineEdit::reset()
   254 void SmartLineEdit::resetAutoCompletionStatus()
   241 {
   255 {
   242     m_beforeMatch = "";
   256     m_beforeMatch = "";
   243     m_hasJustMatched = false;
   257     m_hasJustMatched = false;
   244     m_prefix = "";
   258     m_prefix = "";
   245     m_postfix = "";
   259     m_postfix = "";