KissCount

KissCount Commit Details

Date:2020-04-19 16:47:35 (3 months 15 days ago)
Author:Grégory Soutadé
Branch:dev
Commit:c57405a4074439e927bef26bdf366c899de2a74c
Parents: 196a0cc5aba3199aff8d08cccad4aeba09b00dd9
Message:Add a constructor for Operation (to clear all fields) Setup default date when insert an operation in GridAccount

Changes:
Msrc/model/Operation.hpp (1 diff)
Msrc/view/grid/GridAccount.cpp (31 diffs)

File differences

src/model/Operation.hpp
4242
4343
4444
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
4565
4666
4767
std::vector<int> childs;
int tag;
Operation()
{
id = 0;
parent = 0;
day = 0;
month = 0;
year = 0;
amount = 0.0;
description = "";
category = 0;
fix_cost = false;
account = 0;
checked = 0;
transfert = 0;
formula = "";
meta = false;
_virtual = false;
tag = 0;
}
bool operator == (int opId)
{
return id == opId;
src/view/grid/GridAccount.cpp
4545
4646
4747
48
49
50
48
49
50
5151
5252
53
53
5454
5555
56
56
5757
5858
5959
......
9090
9191
9292
93
94
93
94
9595
9696
9797
......
9999
100100
101101
102
103
102
103
104104
105105
106106
......
162162
163163
164164
165
165
166166
167167
168168
......
203203
204204
205205
206
206
207207
208208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223209
224210
225211
......
258244
259245
260246
261
247
262248
263249
264250
......
344330
345331
346332
347
333
348334
349335
350336
......
463449
464450
465451
466
452
467453
468454
469455
......
480466
481467
482468
483
469
484470
485471
486472
......
490476
491477
492478
493
494
495
479
480
481
496482
497483
498484
......
514500
515501
516502
503
504
505
506
507
517508
518509
519510
......
536527
537528
538529
530
539531
540532
541533
......
543535
544536
545537
546
538
547539
548540
549541
......
554546
555547
556548
557
549
558550
559551
560552
......
600592
601593
602594
603
595
604596
605597
606598
......
730722
731723
732724
733
734
735
725
726
727
736728
737729
738730
......
762754
763755
764756
765
757
766758
767759
768760
......
980972
981973
982974
983
975
984976
985
977
986978
987979
988980
989981
990
982
991983
992984
993985
......
10281020
10291021
10301022
1031
1023
10321024
10331025
10341026
......
11271119
11281120
11291121
1130
1122
11311123
11321124
11331125
......
11381130
11391131
11401132
1141
1133
11421134
11431135
11441136
......
11921184
11931185
11941186
1195
11961187
11971188
11981189
1199
1190
12001191
12011192
12021193
......
13121303
13131304
13141305
1315
1306
13161307
13171308
13181309
......
13231314
13241315
13251316
1326
1317
13271318
13281319
13291320
......
13631354
13641355
13651356
1366
1357
13671358
13681359
13691360
13701361
1371
1362
13721363
13731364
13741365
......
14441435
14451436
14461437
1447
1438
14481439
14491440
14501441
......
14961487
14971488
14981489
1499
1490
15001491
15011492
15021493
......
15291520
15301521
15311522
1532
1523
15331524
15341525
15351526
15361527
15371528
1538
1529
15391530
15401531
15411532
......
16241615
16251616
16261617
1627
1618
16281619
16291620
16301621
......
16461637
16471638
16481639
1649
1640
16501641
16511642
16521643
......
17531744
17541745
17551746
1756
1747
17571748
17581749
17591750
#define SET_READ_ONLY(item) item->setFlags(item->flags() & ~Qt::ItemIsEditable);
GridAccount::GridAccount(KissCount* kiss, KissPanel *parent,
bool canAddOperation, bool setWeek, bool synchronizeWithDatabase)
: QTableWidget(parent), _fixCosts(0), _week1(0),
_week2(0), _week3(0), _week4(0), _week5(0), _canAddOperation(canAddOperation),
bool canAddOperation, bool setWeek, bool synchronizeWithDatabase)
: QTableWidget(parent), _fixCosts(0), _week1(0),
_week2(0), _week3(0), _week4(0), _week5(0), _canAddOperation(canAddOperation),
_parent(parent), _kiss(kiss), _setWeek(setWeek),
_databaseSynchronization(synchronizeWithDatabase), _accounts(0),
_loadOperations(false),
_loadOperations(false),
_curMonth(0), _curYear(0), _treeSignalMapper(this), _checkSignalMapper(this),
_deleteSignalMapper(this), _inModification(false), _completer(0),
_transfertCompletionIndex(0), _ctrlT(0), _ctrlR(0), _suppr(0)
_transfertCompletionIndex(0), _lastCtrlH(0), _ctrlT(0), _ctrlR(0), _suppr(0)
{
DEFAULT_FONT(font);
int i;
setCellWidget(0, CHECKED, label);
_categories = new QString[user->GetCategoriesNumber()-1] ;
for(i=0, categoryIt = user->_categories.begin()+1;
categoryIt != user->_categories.end();
for(i=0, categoryIt = user->_categories.begin()+1;
categoryIt != user->_categories.end();
categoryIt++, i++)
{
_categories[i] = _(categoryIt->name.toStdString().c_str()) ;
_tags = new QString[user->GetTagsNumber()+1] ;
_tags[0] = _("No Tag");
for(i=1, tagIt = user->_tags.begin();
tagIt != user->_tags.end();
for(i=1, tagIt = user->_tags.begin();
tagIt != user->_tags.end();
tagIt++, i++)
{
_tags[i] = _(tagIt->name.toStdString().c_str()) ;
std::vector<Operation>::iterator it = std::find(_operations->begin(), _operations->end(), id);
if (it != _operations->end()) return *it;
throw OperationNotFound();
}
User* user = _kiss->GetUser();
std::vector<Account>::iterator accountIt;
int curLine = 0, i;
Operation NULLop;
Operation NULLop = Operation();
QStringList list;
NULLop.id = 0;
NULLop.parent = 0;
NULLop.amount = 0.0;
NULLop.description = "";
NULLop.category = 0;
NULLop.tag = 0;
NULLop.fix_cost = false;
NULLop.account = 0;
NULLop.checked = 0;
NULLop.transfert = 0;
NULLop.formula = "";
NULLop.meta = false;
NULLop._virtual = false;
_loadOperations = true;
_operations = operations;
_curMonth = month;
if (_accounts) delete[] _accounts;
_accounts = new QString[_nbAccounts];
for (i=0,
for (i=0,
accountIt = user->_accounts.begin();
accountIt != user->_accounts.end();
accountIt++, i++)
if (!_canAddOperation) return;
for (it = _displayedOperations.begin(), curLine=0;
it != _displayedOperations.end();
it != _displayedOperations.end();
it++, curLine++)
{
if (it->id && !it->fix_cost) break;
setItem(line, TAG, new QTableWidgetItem(_(tag.name.toStdString().c_str())));
else
setItem(line, TAG, new QTableWidgetItem(""));
checkBox = new QCheckBox();
checkBox->setCheckState((op.checked) ? Qt::Checked : Qt::Unchecked);
InsertCenteredWidget(line, CHECKED, checkBox);
if (line <= _fixCosts)
cat = user->GetCategory(1);
if (op.category)
color = cat.backcolor;
else
if (op.checked)
{
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
color.setRgb(r, g, b, color.alpha());
}
// NULL Op
item = new QTableWidgetItem("");
setItem(line, DESCRIPTION, item);
op.month = _curMonth;
op.year = _curYear;
op.day = 0;
if (fix)
{
SET_ROW_COLOR(line, view::OWN_YELLOW, Qt::black);
else
day = 1;
op.day = day-1;
setItem(line, OP_DATE, new QTableWidgetItem(_kiss->FormatDate(day, month+1, year)));
SET_ROW_COLOR(line, view::OWN_GREEN, Qt::black);
}
SET_READ_ONLY(this->item(line, CHECKED));
SET_ROW_FONT(line, user->GetCategoryFont(0));
}
this->item(line, OP_DATE)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
this->item(line, DEBIT)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
this->item(line, CREDIT)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
QPushButton* button = new QPushButton("+");
_treeSignalMapper.setMapping(button, op.id);
connect(button, SIGNAL(clicked()), &_treeSignalMapper, SLOT(map()));
button->setMaximumSize(QSize(height, height));
InsertCenteredWidget(line, TREE, button);
{
parent = GetOperation(it->parent);
it2 = std::find(parent.childs.begin(), parent.childs.end(), it->id);
if (it2 != parent.childs.end())
parent.childs.erase(it2);
}
if (check)
{
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
color.setRgb(r, g, b);
}
SET_ROW_COLOR(line, color, user->GetCategory(op.category).forecolor);
if (deleteOp)
DeleteOperation(op2);
}
}
}
}
op.childs.clear();
Category cat ;
Tag tag;
bool fix_cost;
Operation NULLop;
Operation NULLop = Operation();
Account account;
// Avoid recursives calls
if (_inModification || _loadOperations) return;
_inModification = true ;
cur_op = (_displayedOperations)[row] ;
new_op.id = 0;
new_op.year = date.year();
op_complete--;
}
if (!cur_op.meta && col == DESCRIPTION &&
(!item(row, CATEGORY)->text().length() ||
!item(row, ACCOUNT)->text().length()))
fix_cost = (row <= _fixCosts);
// Modify an operation
if (!_canAddOperation || (row < _fixCosts ||
if (!_canAddOperation || (row < _fixCosts ||
(row > _fixCosts &&
row < (int)(_displayedOperations.size()-1))))
{
new_op.parent = cur_op.parent;
new_op.childs = cur_op.childs;
new_op._virtual = account._virtual;
UpdateOperation(new_op);
if (cur_op.day != new_op.day)
}
RemoveRow(new_op, row, false);
NULLop.id = 0;
InsertOperation(user, NULLop, row, new_op.fix_cost, _curMonth, _curYear);
new_op.id = new_op_id;
if (transfertCompleted)
_transfertCompletionIndex = (_transfertCompletionIndex + 1) % 2;
}
std::vector<int>::iterator it;
std::vector<Operation> ops;
std::vector<Operation>::iterator it2;
std::vector<int>::iterator it3;
std::vector<int>::iterator it3;
int parent = 0, deletedRows;
Operation op, op2;
int fix = -1, i, a, row;
for (int i = 0; i < selected.size(); ++i)
{
row = selected[i].row();
it = std::find(rows.begin(), rows.end(), row);
if (it != rows.end())
if (fix == -1)
fix = op.fix_cost ? 1 : 0;
ops.push_back(op);
rows.push_back(row);
}
}
if (!ops.size()) return;
if (!parent)
if (it3 == op.childs.end())
op.childs.push_back(it2->id);
else if (*it3 == it2->id)
else if (*it3 == it2->id)
continue;
else
op.childs.insert(op.childs.begin()+i, it2->id);
std::vector<Operation> ops;
std::vector<int> ops2;
std::vector<Operation>::iterator it2;
std::vector<int>::iterator it3;
std::vector<int>::iterator it3;
int parent = 0;
Operation op, op2;
int fix = -1, i, line;
if (fix == -1)
fix = op.fix_cost ? 1 : 0;
if(op.meta)
{
parent = op.id;
continue;
}
if (!parent && op.parent)
parent = op.parent;
UpdateOperation(op);
if (op.meta && do_childs)
if (op.meta && do_childs)
{
for(b=0; b<(int)op.childs.size(); b++)
{
_parent->NeedReload();
}
if (it->meta && do_childs)
if (it->meta && do_childs)
{
for(b=0; b<(int)it->childs.size(); b++)
{
for (int i = 0; i < selected.size(); ++i)
{
row = selected[i].row();
if (row == _fixCosts || row == (int)_displayedOperations.size()-1)
continue;

Archive Download the corresponding diff file