* Corrects a lot of bugs

* Add Tabulation when it's a meta operation child
This commit is contained in:
Grégory Soutadé 2010-10-14 22:16:22 +02:00
parent f33f6ab85a
commit f2dcfcb356
6 changed files with 94 additions and 12 deletions

View File

@ -59,6 +59,7 @@ enum {CST, ADD, SUB, MUL, DIV, MOD, EXP};
enum {DOUBLE_POINTED=1, INVALID_CHAR, INVALID_PARENTHESIS, INVALID_OPERATION};
#ifdef DEBUG
#define P(x) x
#else
@ -80,7 +81,7 @@ double atof(char* s, int size)
if (neg > 0)
{
res += (*s - '0') / neg;
res += (double) (*s - '0') / (double)neg;
neg *= 10;
}
else

View File

@ -313,6 +313,7 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
description = op.description;
UNESCAPE_CHARS(description);
SetCellValue(line, DESCRIPTION, description);
SetCellRenderer(line, DESCRIPTION, new wxGridCellTabStringRenderer ());
SetCellValue(line, DATE, wxString::Format(wxT("%02d/%02d/%d"), op.day+1, month+1, year));
if (op.amount < 0)
SetCellValue(line, DEBIT, wxString::Format(wxT("%.2lf"), -op.amount));
@ -328,7 +329,10 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
SetCellRenderer(line, CHECKED, new wxGridCellBoolRenderer ());
SetCellEditor(line, CHECKED, new wxGridCellFastBoolEditor ());
color = cat.backcolor;
if (op.category.Length())
color = cat.backcolor;
else
color = OWN_GREEN;
if (op.checked)
{
@ -494,7 +498,7 @@ void GridAccount::RemoveMeta(Operation& op, int line, bool removeRoot, bool dele
if (treeRenderer->IsCollapsed())
{
DeleteRows(line+1, 1);
if (_displayedOperations[line+1].fix_cost) _fixCosts--;
if (op2.fix_cost) _fixCosts--;
_displayedOperations.erase(_displayedOperations.begin()+line+1);
}
@ -517,6 +521,7 @@ void GridAccount::RemoveMeta(Operation& op, int line, bool removeRoot, bool dele
DeleteOperation(op);
_kiss->DeleteOperation(op);
}
if (op.fix_cost) _fixCosts--;
}
treeRenderer->DecRef();
@ -1040,7 +1045,7 @@ void GridAccount::Group()
std::vector<wxString>::iterator it3;
wxString parent = wxT("");
Operation op, op2;
int fix = -1, i;
int fix = -1, i, row;
GetSelectedOperations(&selected);
@ -1110,15 +1115,10 @@ void GridAccount::Group()
{
if (rows.size() < 1) return;
for(i=0, it2=_displayedOperations.begin(); it2!=_displayedOperations.end(); it2++, i++)
if (it2->id.Length() && it2->id == parent)
{
RemoveMeta(*it2, i, true, false);
op = *it2;
break;
}
row = GetDisplayedRow(parent);
op = _displayedOperations[row];
if (op.id.Length()) return;
//if (op.id.Length()) return;
}
std::sort(rows.begin(), rows.end());
@ -1131,6 +1131,7 @@ void GridAccount::Group()
RemoveMeta(ops[i], rows[i]-i, true, false);
else
{
if (ops[i].fix_cost) _fixCosts--;
DeleteRows(rows[i]-i, 1);
_displayedOperations.erase(_displayedOperations.begin()+rows[i]-i);
}
@ -1141,6 +1142,7 @@ void GridAccount::Group()
RemoveMeta(ops[i], rows[i], true, false);
else
{
if (ops[i].fix_cost) _fixCosts--;
DeleteRows(rows[i], 1);
_displayedOperations.erase(_displayedOperations.begin()+rows[i]);
}
@ -1149,6 +1151,8 @@ void GridAccount::Group()
for(it2=ops.begin(); it2!=ops.end(); it2++)
{
if (it2->id == parent) continue;
for (i=0, it3=op.childs.begin(); it3!=op.childs.end(); it3++, i++)
{
op2 = GetOperation(*it3);

View File

@ -31,6 +31,7 @@
#include "wxGridCellTreeButtonRenderer.h"
#include "wxGridCellTreeButtonEditor.h"
#include "wxGridCellFormulaEditor.h"
#include "wxGridCellTabStringRenderer.h"
class KissCount;

View File

@ -52,6 +52,7 @@ bool wxGridCellFormulaEditor::EndEdit (int row, int col, wxGrid *grid/*, const w
bool ret;
res = res.Trim();
res.Replace(wxT(","), wxT("."), true);
if (res.StartsWith(wxT("=")))
{

View File

@ -0,0 +1,40 @@
/*
Copyright 2010 Grégory Soutadé
This file is part of KissCount.
KissCount is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KissCount is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
*/
#include "wxGridCellTabStringRenderer.h"
void wxGridCellTabStringRenderer::Draw (wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected)
{
wxString d;
wxGridTableBase * table ;
if (!((GridAccount*) &grid)->_displayedOperations[row].parent.Length())
{
wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
return;
}
table = grid.GetTable();
d = table->GetValue(row, col).Trim();
table->SetValue(row, col, wxT(" ") + d);
wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
table->SetValue(row, col, d);
}

View File

@ -0,0 +1,35 @@
/*
Copyright 2010 Grégory Soutadé
This file is part of KissCount.
KissCount is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KissCount is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WXGRIDCELLTABSTRINGRENDERER_H
#define WXGRIDCELLTABSTRINGRENDERER_H
#include <wx/grid.h>
#include <wx/bitmap.h>
#include <wx/dc.h>
#include "GridAccount.h"
class wxGridCellTabStringRenderer : public wxGridCellStringRenderer
{
public:
virtual void Draw (wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected);
};
#endif