* Corrects a lot of bugs
* Add Tabulation when it's a meta operation child
This commit is contained in:
parent
f33f6ab85a
commit
f2dcfcb356
|
@ -59,6 +59,7 @@ enum {CST, ADD, SUB, MUL, DIV, MOD, EXP};
|
||||||
|
|
||||||
enum {DOUBLE_POINTED=1, INVALID_CHAR, INVALID_PARENTHESIS, INVALID_OPERATION};
|
enum {DOUBLE_POINTED=1, INVALID_CHAR, INVALID_PARENTHESIS, INVALID_OPERATION};
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define P(x) x
|
#define P(x) x
|
||||||
#else
|
#else
|
||||||
|
@ -80,7 +81,7 @@ double atof(char* s, int size)
|
||||||
|
|
||||||
if (neg > 0)
|
if (neg > 0)
|
||||||
{
|
{
|
||||||
res += (*s - '0') / neg;
|
res += (double) (*s - '0') / (double)neg;
|
||||||
neg *= 10;
|
neg *= 10;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -313,6 +313,7 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||||
description = op.description;
|
description = op.description;
|
||||||
UNESCAPE_CHARS(description);
|
UNESCAPE_CHARS(description);
|
||||||
SetCellValue(line, DESCRIPTION, 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));
|
SetCellValue(line, DATE, wxString::Format(wxT("%02d/%02d/%d"), op.day+1, month+1, year));
|
||||||
if (op.amount < 0)
|
if (op.amount < 0)
|
||||||
SetCellValue(line, DEBIT, wxString::Format(wxT("%.2lf"), -op.amount));
|
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 ());
|
SetCellRenderer(line, CHECKED, new wxGridCellBoolRenderer ());
|
||||||
SetCellEditor(line, CHECKED, new wxGridCellFastBoolEditor ());
|
SetCellEditor(line, CHECKED, new wxGridCellFastBoolEditor ());
|
||||||
|
|
||||||
color = cat.backcolor;
|
if (op.category.Length())
|
||||||
|
color = cat.backcolor;
|
||||||
|
else
|
||||||
|
color = OWN_GREEN;
|
||||||
|
|
||||||
if (op.checked)
|
if (op.checked)
|
||||||
{
|
{
|
||||||
|
@ -494,7 +498,7 @@ void GridAccount::RemoveMeta(Operation& op, int line, bool removeRoot, bool dele
|
||||||
if (treeRenderer->IsCollapsed())
|
if (treeRenderer->IsCollapsed())
|
||||||
{
|
{
|
||||||
DeleteRows(line+1, 1);
|
DeleteRows(line+1, 1);
|
||||||
if (_displayedOperations[line+1].fix_cost) _fixCosts--;
|
if (op2.fix_cost) _fixCosts--;
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+line+1);
|
_displayedOperations.erase(_displayedOperations.begin()+line+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +521,7 @@ void GridAccount::RemoveMeta(Operation& op, int line, bool removeRoot, bool dele
|
||||||
DeleteOperation(op);
|
DeleteOperation(op);
|
||||||
_kiss->DeleteOperation(op);
|
_kiss->DeleteOperation(op);
|
||||||
}
|
}
|
||||||
|
if (op.fix_cost) _fixCosts--;
|
||||||
}
|
}
|
||||||
|
|
||||||
treeRenderer->DecRef();
|
treeRenderer->DecRef();
|
||||||
|
@ -1040,7 +1045,7 @@ void GridAccount::Group()
|
||||||
std::vector<wxString>::iterator it3;
|
std::vector<wxString>::iterator it3;
|
||||||
wxString parent = wxT("");
|
wxString parent = wxT("");
|
||||||
Operation op, op2;
|
Operation op, op2;
|
||||||
int fix = -1, i;
|
int fix = -1, i, row;
|
||||||
|
|
||||||
GetSelectedOperations(&selected);
|
GetSelectedOperations(&selected);
|
||||||
|
|
||||||
|
@ -1110,15 +1115,10 @@ void GridAccount::Group()
|
||||||
{
|
{
|
||||||
if (rows.size() < 1) return;
|
if (rows.size() < 1) return;
|
||||||
|
|
||||||
for(i=0, it2=_displayedOperations.begin(); it2!=_displayedOperations.end(); it2++, i++)
|
row = GetDisplayedRow(parent);
|
||||||
if (it2->id.Length() && it2->id == parent)
|
op = _displayedOperations[row];
|
||||||
{
|
|
||||||
RemoveMeta(*it2, i, true, false);
|
|
||||||
op = *it2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (op.id.Length()) return;
|
//if (op.id.Length()) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(rows.begin(), rows.end());
|
std::sort(rows.begin(), rows.end());
|
||||||
|
@ -1131,6 +1131,7 @@ void GridAccount::Group()
|
||||||
RemoveMeta(ops[i], rows[i]-i, true, false);
|
RemoveMeta(ops[i], rows[i]-i, true, false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (ops[i].fix_cost) _fixCosts--;
|
||||||
DeleteRows(rows[i]-i, 1);
|
DeleteRows(rows[i]-i, 1);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+rows[i]-i);
|
_displayedOperations.erase(_displayedOperations.begin()+rows[i]-i);
|
||||||
}
|
}
|
||||||
|
@ -1141,6 +1142,7 @@ void GridAccount::Group()
|
||||||
RemoveMeta(ops[i], rows[i], true, false);
|
RemoveMeta(ops[i], rows[i], true, false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (ops[i].fix_cost) _fixCosts--;
|
||||||
DeleteRows(rows[i], 1);
|
DeleteRows(rows[i], 1);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+rows[i]);
|
_displayedOperations.erase(_displayedOperations.begin()+rows[i]);
|
||||||
}
|
}
|
||||||
|
@ -1149,6 +1151,8 @@ void GridAccount::Group()
|
||||||
|
|
||||||
for(it2=ops.begin(); it2!=ops.end(); it2++)
|
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++)
|
for (i=0, it3=op.childs.begin(); it3!=op.childs.end(); it3++, i++)
|
||||||
{
|
{
|
||||||
op2 = GetOperation(*it3);
|
op2 = GetOperation(*it3);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "wxGridCellTreeButtonRenderer.h"
|
#include "wxGridCellTreeButtonRenderer.h"
|
||||||
#include "wxGridCellTreeButtonEditor.h"
|
#include "wxGridCellTreeButtonEditor.h"
|
||||||
#include "wxGridCellFormulaEditor.h"
|
#include "wxGridCellFormulaEditor.h"
|
||||||
|
#include "wxGridCellTabStringRenderer.h"
|
||||||
|
|
||||||
class KissCount;
|
class KissCount;
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ bool wxGridCellFormulaEditor::EndEdit (int row, int col, wxGrid *grid/*, const w
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
res = res.Trim();
|
res = res.Trim();
|
||||||
|
res.Replace(wxT(","), wxT("."), true);
|
||||||
|
|
||||||
if (res.StartsWith(wxT("=")))
|
if (res.StartsWith(wxT("=")))
|
||||||
{
|
{
|
||||||
|
|
40
src/view/grid/wxGridCellTabStringRenderer.cpp
Normal file
40
src/view/grid/wxGridCellTabStringRenderer.cpp
Normal 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);
|
||||||
|
}
|
35
src/view/grid/wxGridCellTabStringRenderer.h
Normal file
35
src/view/grid/wxGridCellTabStringRenderer.h
Normal 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
|
Loading…
Reference in New Issue
Block a user