51 } |
51 } |
52 |
52 |
53 |
53 |
54 void SmartLineEdit::addCommands(const QStringList & commands) |
54 void SmartLineEdit::addCommands(const QStringList & commands) |
55 { |
55 { |
56 m_keywordMutex.lock(); |
|
57 |
|
58 m_cmds->append(commands); |
56 m_cmds->append(commands); |
59 |
|
60 m_keywordMutex.unlock(); |
|
61 } |
57 } |
62 |
58 |
63 |
59 |
64 void SmartLineEdit::removeCommands(const QStringList & commands) |
60 void SmartLineEdit::removeCommands(const QStringList & commands) |
65 { |
61 { |
66 m_keywordMutex.lock(); |
|
67 |
|
68 foreach (const QString & cmd, commands) |
62 foreach (const QString & cmd, commands) |
69 { |
63 { |
70 m_cmds->removeAll(cmd); |
64 m_cmds->removeAll(cmd); |
71 } |
65 } |
72 |
|
73 m_keywordMutex.unlock(); |
|
74 } |
66 } |
75 |
67 |
76 |
68 |
77 void SmartLineEdit::addNickname(const QString & name) |
69 void SmartLineEdit::addNickname(const QString & name) |
78 { |
70 { |
79 m_keywordMutex.lock(); |
|
80 |
|
81 m_sorted_nicks->insert(name.toLower(), name); |
71 m_sorted_nicks->insert(name.toLower(), name); |
82 m_nicks->append(name); |
72 m_nicks->append(name); |
83 |
|
84 m_keywordMutex.unlock(); |
|
85 } |
73 } |
86 |
74 |
87 |
75 |
88 void SmartLineEdit::removeNickname(const QString & name) |
76 void SmartLineEdit::removeNickname(const QString & name) |
89 { |
77 { |
90 m_keywordMutex.lock(); |
|
91 |
|
92 m_sorted_nicks->remove(name.toLower()); |
78 m_sorted_nicks->remove(name.toLower()); |
93 m_nicks->removeAll(name); |
79 m_nicks->removeAll(name); |
94 |
|
95 m_keywordMutex.unlock(); |
|
96 } |
80 } |
97 |
81 |
98 |
82 |
99 void SmartLineEdit::reset() |
83 void SmartLineEdit::reset() |
100 { |
84 { |
101 // forget keywords |
85 // forget keywords |
102 m_keywordMutex.lock(); |
|
103 |
|
104 m_cmds->clear(); |
86 m_cmds->clear(); |
105 m_sorted_nicks->clear(); |
87 m_sorted_nicks->clear(); |
106 m_nicks->clear(); |
88 m_nicks->clear(); |
107 resetAutoCompletionStatus(); |
89 resetAutoCompletionStatus(); |
108 |
|
109 m_keywordMutex.unlock(); |
|
110 |
90 |
111 // forget history |
91 // forget history |
112 HistoryLineEdit::reset(); |
92 HistoryLineEdit::reset(); |
113 } |
93 } |
114 |
94 |
171 postfix = m_postfix; |
151 postfix = m_postfix; |
172 isFirstWord = prefix.isEmpty(); |
152 isFirstWord = prefix.isEmpty(); |
173 } |
153 } |
174 else |
154 else |
175 { |
155 { |
176 m_keywordMutex.lock(); |
|
177 m_cmds->sort(); |
156 m_cmds->sort(); |
178 m_nicks = new QStringList(m_sorted_nicks->values()); |
157 m_nicks = new QStringList(m_sorted_nicks->values()); |
179 m_keywordMutex.unlock(); |
|
180 |
158 |
181 int cp = cursorPosition(); |
159 int cp = cursorPosition(); |
182 |
160 |
183 // cursor is not in or at end/beginning of word |
161 // cursor is not in or at end/beginning of word |
184 if ((cp = matchMe.length()) || (QString(matchMe.at(cp)).contains(m_whitespace))) |
162 if ((cp = matchMe.length()) || (QString(matchMe.at(cp)).contains(m_whitespace))) |