diff --git a/src/kvirc/kernel/KviOptions.cpp b/src/kvirc/kernel/KviOptions.cpp index 114847b991..f75678107d 100644 --- a/src/kvirc/kernel/KviOptions.cpp +++ b/src/kvirc/kernel/KviOptions.cpp @@ -636,8 +636,7 @@ KviUIntOption g_uintOptionsTable[KVI_NUM_UINT_OPTIONS] = { UINT_OPTION("ToolBarButtonStyle", 0, KviOption_groupTheme), // 0 = Qt::ToolButtonIconOnly UINT_OPTION("MaximumBlowFishKeySize", 56, KviOption_sectFlagNone), UINT_OPTION("CustomCursorWidth", 1, KviOption_resetUpdateGui), - UINT_OPTION("UserListMinimumWidth", 100, KviOption_sectFlagUserListView | KviOption_resetUpdateGui | KviOption_groupTheme), - UINT_OPTION("NickCompletionOrder", 2, KviOption_sectFlagNone) + UINT_OPTION("UserListMinimumWidth", 100, KviOption_sectFlagUserListView | KviOption_resetUpdateGui | KviOption_groupTheme) }; #define FONT_OPTION(_name, _face, _size, _flags) \ diff --git a/src/kvirc/kernel/KviOptions.h b/src/kvirc/kernel/KviOptions.h index e99451613b..e22b807ea3 100644 --- a/src/kvirc/kernel/KviOptions.h +++ b/src/kvirc/kernel/KviOptions.h @@ -595,9 +595,8 @@ DECLARE_OPTION_STRUCT(KviStringListOption, QStringList) #define KviOption_uintMaximumBlowFishKeySize 80 #define KviOption_uintCustomCursorWidth 81 /* Interface */ #define KviOption_uintUserListMinimumWidth 82 -#define KviOption_uintNickCompletionOrder 83 -#define KVI_NUM_UINT_OPTIONS 84 +#define KVI_NUM_UINT_OPTIONS 83 namespace KviIdentdOutputMode { diff --git a/src/kvirc/ui/KviInputEditor.cpp b/src/kvirc/ui/KviInputEditor.cpp index 81e7485a6b..23c4418e11 100644 --- a/src/kvirc/ui/KviInputEditor.cpp +++ b/src/kvirc/ui/KviInputEditor.cpp @@ -2368,12 +2368,10 @@ void KviInputEditor::standardNickCompletion(bool bAddMask, QString & szWord, boo if(m_pUserListView->completeNickStandard(szWord, m_szLastCompletedNick, szBuffer, bAddMask)) { - // Because szBuffer does not necessarily equal the completed nickname, - // completeNickStandard will update m_szLastCompletedNick with the nickname. - // completed: save the buffer m_szLastCompletionBuffer = m_szTextBuffer; m_iLastCompletionCursorPosition = m_iCursorPosition; + m_szLastCompletedNick = szBuffer; standardNickCompletionInsertCompletedText(szWord, szBuffer, bFirstWordInLine, bInCommand); m_bLastCompletionFinished = 0; // REPAINT CALLED FROM OUTSIDE! @@ -2399,6 +2397,7 @@ void KviInputEditor::standardNickCompletion(bool bAddMask, QString & szWord, boo if(m_pUserListView->completeNickStandard(szWord, m_szLastCompletedNick, szBuffer, bAddMask)) { // completed + m_szLastCompletedNick = szBuffer; standardNickCompletionInsertCompletedText(szWord, szBuffer, bFirstWordInLine, bInCommand); m_bLastCompletionFinished = 0; // REPAINT CALLED FROM OUTSIDE! @@ -2418,12 +2417,12 @@ void KviInputEditor::standardNickCompletion(bool bAddMask, QString & szWord, boo //getWordBeforeCursor(word,&bFirstWordInLine); if(szWord.isEmpty()) return; - m_szLastCompletedNick = ""; - if(m_pUserListView->completeNickStandard(szWord, m_szLastCompletedNick, szBuffer, bAddMask)) + if(m_pUserListView->completeNickStandard(szWord, "", szBuffer, bAddMask)) { // completed m_szLastCompletionBuffer = m_szTextBuffer; m_iLastCompletionCursorPosition = m_iCursorPosition; + m_szLastCompletedNick = szBuffer; standardNickCompletionInsertCompletedText(szWord, szBuffer, bFirstWordInLine, bInCommand); m_bLastCompletionFinished = 0; // REPAINT CALLED FROM OUTSIDE! diff --git a/src/kvirc/ui/KviUserListView.cpp b/src/kvirc/ui/KviUserListView.cpp index a055d1ee4c..6a520511b8 100644 --- a/src/kvirc/ui/KviUserListView.cpp +++ b/src/kvirc/ui/KviUserListView.cpp @@ -245,7 +245,6 @@ KviUserListView::KviUserListView(QWidget * pParent, KviWindowToolPageButton * pB m_ieEntries = 0; m_iIEntries = 0; m_iSelectedCount = 0; - m_CompletionList = nullptr; applyOptions(); } @@ -257,7 +256,6 @@ KviUserListView::~KviUserListView() delete m_pToolTip; delete m_pViewArea; delete m_pUsersLabel; - delete m_CompletionList; } void KviUserListView::emitRightClick() @@ -487,115 +485,60 @@ void KviUserListView::completeNickBashLike(const QString & szBegin, std::vector< } } -bool KviUserListView::completeNickStandard(const QString & szBegin, QString & szSkipAfter, QString & szBuffer, bool bAppendMask) +bool KviUserListView::completeNickStandard(const QString & szBegin, const QString & szSkipAfter, QString & szBuffer, bool bAppendMask) { - // For normal nickname completion, we'll build a list of matching nicknames in order, - // then look through it to the next nickname each time Tab is pressed. - if (m_CompletionList == nullptr) - { - // No list; build it. - m_CompletionList = new std::list(); - - KviUserListEntry * pEntry = m_pHeadItem; - - for(KviUserListEntry * pEntry = m_pHeadItem; pEntry; pEntry = pEntry->m_pNext) - { - // FIXME: completion should skip my own nick or place it as last entry in the chain (?) - - // if(KviConsoleWindow * c = m_pKviWindow->console()) - // { - // if(kvi_strEqualCI(entry->m_szNick.ptr(),c->currentNickName()) - // } - - if(pEntry->m_szNick.length() >= szBegin.length()) - { - bool bEqual = KviQString::equalCIN(szBegin, pEntry->m_szNick, szBegin.length()); - if(!bEqual && KVI_OPTION_BOOL(KviOption_boolIgnoreSpecialCharactersInNickCompletion)) - { - QString szTmp = pEntry->m_szNick; - szTmp.remove(QRegExp("[^a-zA-Z0-9]")); - bEqual = KviQString::equalCIN(szBegin, szTmp, szBegin.length()); - } - - if(bEqual) - { - // Matching entry; insert it into the list. - std::list::iterator it; - switch (KVI_OPTION_UINT(KviOption_uintNickCompletionOrder)) - { - case 0: // As listed - m_CompletionList->push_back(pEntry->m_szNick); - break; - case 1: // Alphabetical - for (it = m_CompletionList->begin(); it != m_CompletionList->end(); ++it) - { - if ((KviQString::cmpCI(pEntry->m_szNick, *it, - KVI_OPTION_BOOL(KviOption_boolPlaceNickWithNonAlphaCharsAtEnd)) < 0)) - { - break; - } - } - m_CompletionList->insert(it, pEntry->m_szNick); - break; - default: // Last action time - for (it = m_CompletionList->begin(); it != m_CompletionList->end(); ++it) - { - if (pEntry->m_lastActionTime > (*m_pEntryDict->find(*it)).m_lastActionTime) - { - break; - } - } - m_CompletionList->insert(it, pEntry->m_szNick); - break; - } - - } - } - } - } - - // The list exists; find the next match. - std::list::iterator it = m_CompletionList->begin(); + KviUserListEntry * pEntry = m_pHeadItem; if(!szSkipAfter.isEmpty()) { - while(it != m_CompletionList->end()) + while(pEntry) { - if(KviQString::equalCI(szSkipAfter, *it)) + if(KviQString::equalCI(szSkipAfter, pEntry->m_szNick)) { - ++it; + pEntry = pEntry->m_pNext; break; } - ++it; + pEntry = pEntry->m_pNext; } } - if(it != m_CompletionList->end()) + // FIXME: completion should skip my own nick or place it as last entry in the chain (?) + + // if(KviConsoleWindow * c = m_pKviWindow->console()) + // { + // if(kvi_strEqualCI(entry->m_szNick.ptr(),c->currentNickName()) + // } + + // Ok...now the real completion + while(pEntry) { - szSkipAfter = *it; - szBuffer = *it; - if(bAppendMask) + if(pEntry->m_szNick.length() >= szBegin.length()) { - KviUserListEntry * entry = m_pEntryDict->find(*it); - if (entry) + bool bEqual = KviQString::equalCIN(szBegin, pEntry->m_szNick, szBegin.length()); + if(!bEqual && KVI_OPTION_BOOL(KviOption_boolIgnoreSpecialCharactersInNickCompletion)) { - szBuffer += "!"; - szBuffer += entry->m_pGlobalData->user(); - szBuffer += "@"; - szBuffer += entry->m_pGlobalData->host(); + QString szTmp = pEntry->m_szNick; + szTmp.remove(QRegExp("[^a-zA-Z0-9]")); + bEqual = KviQString::equalCIN(szBegin, szTmp, szBegin.length()); } - else + + if(bEqual) { - // They left the user list during the completion session. - szBuffer += "!*@*"; + // This is ok. + szBuffer = pEntry->m_szNick; + if(bAppendMask) + { + szBuffer += "!"; + szBuffer += pEntry->m_pGlobalData->user(); + szBuffer += "@"; + szBuffer += pEntry->m_pGlobalData->host(); + } + return true; } } - return true; + pEntry = pEntry->m_pNext; } - // No more matches; delete the list. - delete m_CompletionList; - m_CompletionList = nullptr; return false; } diff --git a/src/kvirc/ui/KviUserListView.h b/src/kvirc/ui/KviUserListView.h index f2a26e37a2..1210102698 100644 --- a/src/kvirc/ui/KviUserListView.h +++ b/src/kvirc/ui/KviUserListView.h @@ -276,8 +276,6 @@ class KVIRC_API KviUserListView : public KviWindowToolWidget int m_iIEntries; KviWindow * m_pKviWindow; - std::list * m_CompletionList; - public: /** * \brief Updates the list view area @@ -722,12 +720,12 @@ class KVIRC_API KviUserListView : public KviWindowToolWidget * It looks for the letters typed, if it found at least a result, it * cycles through the completed nicknames * \param szBegin The starting of the nick - * \param szSkipAfter The string to skip after the nick is completed. Will be updated with the completed nickname. + * \param szSkipAfter The string to skip after the nick is completed * \param szBuffer The buffer where to store the data * \param bAppendMask Whether to append the complete mask * \return bool */ - bool completeNickStandard(const QString & szBegin, QString & szSkipAfter, QString & szBuffer, bool bAppendMask); + bool completeNickStandard(const QString & szBegin, const QString & szSkipAfter, QString & szBuffer, bool bAppendMask); /** * \brief Completes the nick in Bash-like behaviour diff --git a/src/modules/options/OptionsWidget_input.cpp b/src/modules/options/OptionsWidget_input.cpp index 69b37f88c3..870e23ab34 100644 --- a/src/modules/options/OptionsWidget_input.cpp +++ b/src/modules/options/OptionsWidget_input.cpp @@ -159,11 +159,6 @@ OptionsWidget_inputFeatures::OptionsWidget_inputFeatures(QWidget * parent) addBoolSelector(g, __tr2qs_ctx("Ignore special characters in nick completion", "options"), KviOption_boolIgnoreSpecialCharactersInNickCompletion); - // TODO: Add a combo box for KviOption_uintNickCompletionOrder - // 0: as listed - // 1: alphabetical - // 2: by last action time - KviBoolSelector * d = addBoolSelector(0, 7, 0, 7, __tr2qs_ctx("Use a custom cursor width", "options"), KviOption_boolEnableCustomCursorWidth); KviUIntSelector * f = addUIntSelector(0, 8, 0, 8, __tr2qs_ctx("Custom cursor width:", "options"), KviOption_uintCustomCursorWidth, 1, 24, 8, KVI_OPTION_BOOL(KviOption_boolEnableCustomCursorWidth)); f->setSuffix(__tr2qs_ctx(" pixels", "options")); diff --git a/src/modules/options/OptionsWidget_input.h b/src/modules/options/OptionsWidget_input.h index 0f16ee986c..4e6867b491 100644 --- a/src/modules/options/OptionsWidget_input.h +++ b/src/modules/options/OptionsWidget_input.h @@ -54,9 +54,6 @@ class OptionsWidget_inputLook : public KviOptionsWidget class OptionsWidget_inputFeatures : public KviOptionsWidget { Q_OBJECT -private: - QComboBox * m_pNickCompletionOrder; - public: OptionsWidget_inputFeatures(QWidget * parent); ~OptionsWidget_inputFeatures();