KissCount

KissCount Commit Details

Date:2013-02-26 16:04:27 (7 years 4 months ago)
Author:Grégory Soutadé
Branch:dev, master, qt5
Commit:d6ef8aebdb74f40f6a3964ba5f6411471374fed4
Parents: eaba622a3fd7199f73e21c22daaafb2d6877b4b1
Message:Add cost repartition to SearchPanel

Changes:
Msrc/view/CostRepartitionBanner.cpp (1 diff)
Msrc/view/SearchPanel.cpp (7 diffs)
Msrc/view/SearchPanel.hpp (2 diffs)

File differences

src/view/CostRepartitionBanner.cpp
105105
106106
107107
108
108109
109110
110111
_statsGrid->setItem(1, 0, new QTableWidgetItem(_("Non fix")));
_statsGrid->setItem(1, 1, new QTableWidgetItem(""));
_statsGrid->item(1, 1)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
for(i=0; i<nb_categories; i++)
{
src/view/SearchPanel.cpp
2525
2626
2727
28
29
2830
2931
3032
......
5658
5759
5860
61
62
63
64
65
66
67
68
69
70
71
72
5973
6074
6175
6276
6377
6478
79
80
6581
6682
6783
......
7995
8096
8197
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
82132
83133
84134
......
111161
112162
113163
164
165
114166
115167
116168
......
148200
149201
150202
203
204
151205
152206
153207
......
196250
197251
198252
253
254
199255
200256
201257
......
222278
223279
224280
281
282
225283
226284
227285
DEFAULT_FONT(font);
std::vector<Account>::iterator accountIt;
std::vector<Category>::iterator categoryIt;
int i;
User* user = _kiss->GetUser();
QVBoxLayout *vbox = new QVBoxLayout;
QVBoxLayout *vbox2 = new QVBoxLayout;
connect(_changeCategoryButton, SIGNAL(clicked()), this, SLOT(OnButtonChangeCategory()));
connect(_renameButton, SIGNAL(clicked()), this, SLOT(OnButtonRename()));
_categories = new QString[user->GetCategoriesNumber()] ;
_categoriesValues = new int[user->GetCategoriesNumber()] ;
for(i=0, categoryIt = user->_categories.begin();
categoryIt != user->_categories.end();
categoryIt++, i++)
{
_categoriesIndexes[categoryIt->id] = i;
_categories[i] = _(categoryIt->name.toStdString().c_str()) ;
}
_costRepartitionBanner = new CostRepartitionBanner(_kiss, this, _categories);
vbox2->addWidget(_changeAccountButton);
vbox2->addWidget(_changeCategoryButton);
vbox2->addWidget(_renameButton);
hbox->addLayout(vbox2);
hbox->addWidget(_costRepartitionBanner);
vbox->addLayout(hbox, 2);
}
return _("Search");
}
void SearchPanel::UpdateCostRepartition()
{
int i;
User* user = _kiss->GetUser();
double total=0.0;
std::vector<Operation>::iterator it;
Account account;
Operation op;
_costRepartitionBanner->Reset();
for (i=0; i<user->GetCategoriesNumber(); i++)
_categoriesValues[i] = 0.0;
for(it=_operations->begin(); it!=_operations->end(); it++)
{
if (it->meta) continue;
op = *it;
account = user->GetAccount(op.account);
if (account.blocked && op.transfert && op.amount > 0)
op.amount = -op.amount;
if (op.amount >= 0) continue;
_categoriesValues[_categoriesIndexes[op.category]] -= op.amount;
total -= op.amount;
}
_costRepartitionBanner->UpdateCosts(_categoriesValues, total);
}
void SearchPanel::OnEnter(void* caller)
{
SearchPanel* _this = (SearchPanel*) caller;
_wxUI->setEnabled(true);
_kiss->setOverrideCursor(QCursor(Qt::ArrowCursor));
UpdateCostRepartition();
_wxUI->layout();
}
_grid->MassUpdate(rows, true, ChangeAccount, params);
UpdateCostRepartition();
_wxUI->NeedReload();
}
_grid->MassUpdate(rows, true, ChangeCategory, params);
UpdateCostRepartition();
_wxUI->NeedReload();
}
_grid->MassUpdate(rows, false, ChangeName, params);
UpdateCostRepartition();
_wxUI->NeedReload();
}
src/view/SearchPanel.hpp
2626
2727
2828
29
2930
3031
3132
......
5354
5455
5556
57
58
5659
5760
5861
62
63
64
65
5966
6067
6168
#include "grid/GridAccount.hpp"
#include "AccountPanel.hpp"
#include "SearchBanner.hpp"
#include "CostRepartitionBanner.hpp"
#include <model/model.hpp>
void OnButtonRename();
private:
void UpdateCostRepartition();
std::vector<Operation> *_operations;
SearchBanner* _banner;
GridAccount *_grid;
CostRepartitionBanner *_costRepartitionBanner;
QString* _categories;
int *_categoriesValues;
std::map<int, int> _categoriesIndexes;
QPushButton* _searchButton, *_renameButton, *_changeAccountButton, *_changeCategoryButton;
static void OnEnter(void* caller);

Archive Download the corresponding diff file