Some optimizations on empty wxString comparison and on Search (Database)

This commit is contained in:
2010-08-21 09:54:04 +02:00
parent 3802460429
commit d12e00c6fb
7 changed files with 49 additions and 47 deletions

View File

@@ -135,7 +135,7 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event)
return;
}
if (_amountFrom->GetLineText(0) != wxT(""))
if (_amountFrom->GetLineText(0).Length())
{
amountFrom = new wxString;
*amountFrom = _amountFrom->GetLineText(0);
@@ -149,7 +149,7 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event)
if (af < 0) af *= -1;
}
if (_amountTo->GetLineText(0) != wxT(""))
if (_amountTo->GetLineText(0).Length())
{
amountTo = new wxString;
*amountTo = _amountTo->GetLineText(0);
@@ -174,7 +174,7 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event)
_grid->DeleteRows(1, _grid->GetNumberRows()-1);
if (_description->GetLineText(0) != wxT(""))
if (_description->GetLineText(0).Length())
{
description = new wxString;
*description = _description->GetLineText(0);
@@ -273,14 +273,14 @@ void SearchPanel::OnOperationModified(wxGridEvent& event)
_grid->SetCellValue(event.GetRow(), DEBIT, wxT(""));
value = _grid->GetCellValue(event.GetRow(), DESCRIPTION);
if (value != wxT(""))
if (value.Length())
{
new_op.description = value;
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), DATE);
if (value != wxT(""))
if (value.Length())
{
date.ParseFormat(value, wxT("%d/%m/%Y"));
new_op.day = date.GetDay()-1;
@@ -290,7 +290,7 @@ void SearchPanel::OnOperationModified(wxGridEvent& event)
}
value = _grid->GetCellValue(event.GetRow(), DEBIT);
if (value != wxT(""))
if (value.Length())
{
value.ToDouble(&new_op.amount);
new_op.amount *= -1.0;
@@ -298,28 +298,28 @@ void SearchPanel::OnOperationModified(wxGridEvent& event)
}
value = _grid->GetCellValue(event.GetRow(), CREDIT);
if (value != wxT(""))
if (value.Length())
{
value.ToDouble(&new_op.amount);
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), CATEGORY);
if (value != wxT(""))
if (value.Length())
{
new_op.category = user->GetCategoryId(value);
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), ACCOUNT);
if (value != wxT(""))
if (value.Length())
{
new_op.account = user->GetAccountId(value);
op_complete--;
}
value = _grid->GetCellValue(event.GetRow(), CHECKED);
if (value != wxT("") && value != wxT("0"))
if (value.Length() && value != wxT("0"))
new_op.checked = true;
else
new_op.checked = false;