diff options
Diffstat (limited to 'plugins/BasicHistory/src/Searcher.cpp')
-rw-r--r-- | plugins/BasicHistory/src/Searcher.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/plugins/BasicHistory/src/Searcher.cpp b/plugins/BasicHistory/src/Searcher.cpp index c93685bcf3..57638e6c6d 100644 --- a/plugins/BasicHistory/src/Searcher.cpp +++ b/plugins/BasicHistory/src/Searcher.cpp @@ -33,14 +33,14 @@ Searcher::Searcher() void Searcher::ChangeFindDirection(bool isBack)
{
- if(isBack != findBack)
+ if (isBack != findBack)
{
findBack = isBack;
ClearFind();
TBBUTTONINFO tbInfo;
tbInfo.cbSize = sizeof(TBBUTTONINFO);
tbInfo.dwMask = TBIF_TEXT | TBIF_IMAGE;
- if(isBack)
+ if (isBack)
{
tbInfo.pszText = TranslateT("Find Previous");
tbInfo.iImage = 1;
@@ -58,7 +58,7 @@ void Searcher::ChangeFindDirection(bool isBack) void Searcher::ClearFind()
{
- if(lastFindSelection != -1)
+ if (lastFindSelection != -1)
{
SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_AND,~ECO_NOHIDESEL);
lastFindSelection = -1;
@@ -73,15 +73,15 @@ inline TCHAR mytoupper(TCHAR a, std::locale* loc) bool Searcher::CompareStr(std::wstring str, TCHAR *strFind)
{
std::locale loc;
- if(!matchCase)
+ if (!matchCase)
std::transform(str.begin(), str.end(), str.begin(), std::bind2nd(std::ptr_fun(mytoupper), &loc));
- if(!matchWholeWords)
+ if (!matchWholeWords)
return str.find(strFind) < str.length();
size_t findid = str.find(strFind);
size_t findLen = _tcslen(strFind);
while(findid < str.length())
{
- if((findid == 0 || std::isspace(str[findid - 1], loc) || std::ispunct(str[findid - 1], loc)) &&
+ if ((findid == 0 || std::isspace(str[findid - 1], loc) || std::ispunct(str[findid - 1], loc)) &&
(findid + findLen >= str.length() || std::isspace(str[findid + findLen], loc) || std::ispunct(str[findid + findLen], loc)))
return true;
findid = str.find(strFind, findid + 1);
@@ -100,7 +100,7 @@ void Searcher::Find() ft.chrg.cpMin = 0;
ft.chrg.cpMax = -1;
ft.lpstrText = str;
- if(context->currentGroup.size() < 1)
+ if (context->currentGroup.size() < 1)
{
SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_AND,~ECO_NOHIDESEL);
lastFindSelection = -1;
@@ -108,14 +108,14 @@ void Searcher::Find() }
GetWindowText(context->findWindow, str, 128);
- if(!str[0])
+ if (!str[0])
{
TCHAR buf[256];
mir_sntprintf(buf, 256, TranslateT("\"%s\" not found"), str);
MessageBox(context->hWnd, buf, TranslateT("Search"), MB_OK | MB_ICONINFORMATION);
return;
}
- if(!matchCase)
+ if (!matchCase)
{
std::locale loc;
std::transform(str, str + _tcslen(str), str, std::bind2nd(std::ptr_fun(mytoupper), &loc));
@@ -126,16 +126,16 @@ void Searcher::Find() int adder1 = findBack1 ? -1 : 1;
int adder2 = findBack2 ? -1 : 1;
WPARAM findStyle = (findBack1 ? 0 : FR_DOWN) | (matchCase ? FR_MATCHCASE : 0) | (matchWholeWords ? FR_WHOLEWORD : 0);
- if(lastFindSelection >= 0 && lastFindSelection < (int)context->currentGroup.size())
+ if (lastFindSelection >= 0 && lastFindSelection < (int)context->currentGroup.size())
{
- if(onlyIn && context->currentGroup[lastFindSelection].isMe || onlyOut && !context->currentGroup[lastFindSelection].isMe)
+ if (onlyIn && context->currentGroup[lastFindSelection].isMe || onlyOut && !context->currentGroup[lastFindSelection].isMe)
{
curSel = lastFindSelection + adder1;
}
else
{
SendDlgItemMessage(context->hWnd,IDC_EDIT,EM_EXGETSEL,0,(LPARAM)&ft.chrg);
- if(findBack1)
+ if (findBack1)
{
ft.chrg.cpMin = ft.chrg.cpMin < context->currentGroup[lastFindSelection].endPos ? ft.chrg.cpMin : context->currentGroup[lastFindSelection].endPos;
ft.chrg.cpMax = context->currentGroup[lastFindSelection].startPos;
@@ -146,13 +146,13 @@ void Searcher::Find() ft.chrg.cpMax = context->currentGroup[lastFindSelection].endPos;
}
SendMessage(context->editWindow,EM_FINDTEXTEX, findStyle,(LPARAM)&ft);
- if(ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0)
+ if (ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0)
{
curSel = lastFindSelection + adder1;
}
else
{
- if(isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos)))
+ if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos)))
{
finished = true;
}
@@ -174,51 +174,51 @@ void Searcher::Find() SendMessage(context->editWindow,EM_EXGETSEL,0,(LPARAM)&ft.chrg);
startFindPos = findBack1 ? ft.chrg.cpMin : (ft.chrg.cpMax >= 0 ? ft.chrg.cpMax : ft.chrg.cpMin);
startFindSel = context->selected;
- if(startFindPos < 0)
+ if (startFindPos < 0)
startFindPos = 0;
isFindSelChanged = false;
startFindContact = context->hContact;
isFindContactChanged = !allUsers;
- if(findBack1)
+ if (findBack1)
for(curSel = (int)context->currentGroup.size() - 1; curSel >= 0; --curSel)
{
- if(context->currentGroup[curSel].startPos < startFindPos)
+ if (context->currentGroup[curSel].startPos < startFindPos)
break;
}
else
for(; curSel < (int)context->currentGroup.size(); ++curSel)
{
- if(context->currentGroup[curSel].endPos > startFindPos)
+ if (context->currentGroup[curSel].endPos > startFindPos)
break;
}
}
- if(!finished)
+ if (!finished)
{
for(; curSel < (int)context->currentGroup.size() && curSel >= 0; curSel += adder1)
{
- if(onlyIn && context->currentGroup[curSel].isMe || onlyOut && !context->currentGroup[curSel].isMe)
+ if (onlyIn && context->currentGroup[curSel].isMe || onlyOut && !context->currentGroup[curSel].isMe)
continue;
- if(CompareStr(context->currentGroup[curSel].description, str))
+ if (CompareStr(context->currentGroup[curSel].description, str))
{
- if(findBack1)
+ if (findBack1)
{
ft.chrg.cpMin = context->currentGroup[curSel].endPos;
ft.chrg.cpMax = context->currentGroup[curSel].startPos;
- if(!isFindSelChanged && ft.chrg.cpMin > startFindPos)
+ if (!isFindSelChanged && ft.chrg.cpMin > startFindPos)
ft.chrg.cpMin = startFindPos;
}
else
{
ft.chrg.cpMin = context->currentGroup[curSel].startPos;
ft.chrg.cpMax = context->currentGroup[curSel].endPos;
- if(!isFindSelChanged && ft.chrg.cpMin < startFindPos)
+ if (!isFindSelChanged && ft.chrg.cpMin < startFindPos)
ft.chrg.cpMin = startFindPos;
}
SendMessage(context->editWindow,EM_FINDTEXTEX, findStyle,(LPARAM)&ft);
- if(!(ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0))
+ if (!(ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0))
{
- if(isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos)))
+ if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos)))
{
finished = true;
break;
@@ -232,17 +232,17 @@ void Searcher::Find() }
}
- if(isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel)
+ if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel)
{
finished = true;
}
- if(!finished)
+ if (!finished)
{
isFindSelChanged = true;
- if(onlyGroup)
+ if (onlyGroup)
{
- if(IsInSel(context->selected, str))
+ if (IsInSel(context->selected, str))
{
CHARRANGE ch;
ch.cpMin = ch.cpMax = findBack1 ? MAXLONG : 0;
@@ -256,10 +256,10 @@ void Searcher::Find() {
for(int sel = context->selected + adder2; ; sel += adder2)
{
- if(sel < 0)
+ if (sel < 0)
{
isFindContactChanged = true;
- if(allUsers)
+ if (allUsers)
{
HANDLE hNext = context->hContact;
do
@@ -272,10 +272,10 @@ void Searcher::Find() sel = (int)context->eventList.size() - 1;
}
- else if(sel >= (int)context->eventList.size())
+ else if (sel >= (int)context->eventList.size())
{
isFindContactChanged = true;
- if(allUsers)
+ if (allUsers)
{
HANDLE hNext = context->hContact;
do
@@ -288,7 +288,7 @@ void Searcher::Find() sel = 0;
}
- if(IsInSel(sel, str))
+ if (IsInSel(sel, str))
{
LVITEM item = {0};
item.mask = LVIF_STATE;
@@ -309,18 +309,18 @@ void Searcher::Find() Find();
return;
}
- if(startFindContact == context->hContact && sel == startFindSel)
+ if (startFindContact == context->hContact && sel == startFindSel)
break;
}
}
}
- if(startFindContact != context->hContact)
+ if (startFindContact != context->hContact)
{
context->SelectContact(startFindContact);
}
- if(startFindSel != context->selected)
+ if (startFindSel != context->selected)
{
LVITEM item = {0};
item.mask = LVIF_STATE;
@@ -340,7 +340,7 @@ void Searcher::Find() SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ft.chrgText);
SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_AND,~ECO_NOHIDESEL);
lastFindSelection = -1;
- if(isStart)
+ if (isStart)
{
TCHAR buf[256];
GetWindowText(context->findWindow, str, 128);
@@ -355,7 +355,7 @@ void Searcher::Find() bool Searcher::IsInSel(int sel, TCHAR *strFind)
{
- if(sel < 0 || sel >= (int)context->eventList.size())
+ if (sel < 0 || sel >= (int)context->eventList.size())
return false;
TCHAR str[MAXSELECTSTR + 8]; // for safety reason
@@ -363,13 +363,13 @@ bool Searcher::IsInSel(int sel, TCHAR *strFind) for(std::deque<EventList::EventIndex>::iterator it = context->eventList[sel].begin(); it != context->eventList[sel].end(); ++it)
{
EventList::EventIndex hDbEvent = *it;
- if(context->GetEventData(hDbEvent, data))
+ if (context->GetEventData(hDbEvent, data))
{
bool isMe = data.isMe;
- if(onlyIn && isMe || onlyOut && !isMe)
+ if (onlyIn && isMe || onlyOut && !isMe)
continue;
context->GetEventMessage(hDbEvent, str);
- if(CompareStr(str, strFind))
+ if (CompareStr(str, strFind))
{
return true;
}
@@ -381,7 +381,7 @@ bool Searcher::IsInSel(int sel, TCHAR *strFind) bool Searcher::Compare(const bool isMe, const std::wstring& message, TCHAR *strFind)
{
- if(onlyIn && isMe || onlyOut && !isMe)
+ if (onlyIn && isMe || onlyOut && !isMe)
return false;
return CompareStr(message, strFind);
|