KissCount

KissCount Commit Details

Date:2018-10-07 11:55:41 (1 year 12 days ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:ec3ac0a8b46724249c89a61891d974730c319370
Parents: 74528b4a00f725c8bf3c0cbea6dd63987b3e008a
Message:Add quick transfert dialog (ctrl+t shortcut)

Changes:
Csrc/view/GenerateDialog.hpp → src/view/grid/TransfertDialog.hpp
Asrc/view/grid/TransfertDialog.cpp (full)
MChangeLog (1 diff)
Msrc/view/grid/GridAccount.cpp (5 diffs)
Msrc/view/grid/GridAccount.hpp (3 diffs)

File differences

ChangeLog
1
1
22
33
44
5
56
67
78
89
9
10
11
1012
1113
1214
v0.8 (03/10/2018)
v0.8 (07/10/2018)
** User **
Add multi month operation support : Normal operation with description "... (XX/YY)" will be forwarded to next month
Auto fill operation amount if it was the same for the last 3 operations
Add quick transfert dialog (ctrl+t shortcut)
** Dev **
** Bugs **
Current account value is badly computed if operations are not in date order
NULLop was set with random values which can cause misunderstanding when entering a new operation
Resize date column for new operations (can be bold while other are not)
KissCount crash or do something wrong when selecting multiple columns for group/ungroup operations
v0.7.1 (07/05/2018)
src/view/grid/GridAccount.cpp
2727
2828
2929
30
3031
3132
3233
......
5253
5354
5455
55
56
5657
5758
5859
......
122123
123124
124125
126
127
128
125129
126130
127131
......
132136
133137
134138
139
140
135141
136142
137143
......
16601666
16611667
16621668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
#include "FloatDelegate.hpp"
#include "FormulaDelegate.hpp"
#include "TabDelegate.hpp"
#include "TransfertDialog.hpp"
#define SET_ROW_COLOR(row, backcolor, forecolor) for(int i=0; i<NUMBER_COLS_OPS; i++) \
{\
_loadOperations(false),
_curMonth(0), _curYear(0), _treeSignalMapper(this), _checkSignalMapper(this),
_deleteSignalMapper(this), _inModification(false), _completer(0),
_transfertCompletionIndex(0)
_transfertCompletionIndex(0), _ctrlT(0)
{
DEFAULT_FONT(font);
int i;
connect(&_deleteSignalMapper, SIGNAL(mapped(int)), this, SLOT(OnDeleteClicked(int)));
setItemDelegate(new TableViewDelegate(this));
connect(this, SIGNAL(cellChanged(int, int)), this, SLOT(OnOperationModified(int, int)));
if (canAddOperation)
_ctrlT = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_T), this, SLOT(OnCtrlT()));
}
GridAccount::~GridAccount()
delete[] _accounts;
if (_completer)
delete _completer;
if (_ctrlT)
delete _ctrlT;
}
void GridAccount::ResetWeeks()
_parent->setEnabled(true);
_kiss->setOverrideCursor(QCursor(Qt::ArrowCursor));
}
void GridAccount::OnCtrlT(void)
{
Operation op, op2;
QModelIndexList selected = selectedIndexes();
int account, idx;
bool groupOperations;
User* user = _kiss->GetUser();
std::vector<Operation>::iterator it;
if (selected.size() > 1 || !selected.size())
return;
op = _displayedOperations[selected[0].row()] ;
if (op.parent || op.meta || op.transfert)
return;
TransfertDialog g(_kiss, user, op, &account, &groupOperations);
g.setModal(true);
if (g.exec())
{
op2 = op;
op2.account = account;
op2.amount *= -1;
op2.id = _kiss->AddOperation(op2);
InsertOperationWithWeek(user, op2, selected[0].row()+1, op.fix_cost, op.month, op.year);
for (idx = 0, it = _operations->begin(); it != _operations->end(); it++, idx++)
{
if (it->id == op.id)
{
_operations->insert(_operations->begin()+idx+1, op2);
break;
}
}
if (groupOperations)
{
setRangeSelected(QTableWidgetSelectionRange(selected[0].row(), 0, selected[0].row()+1, 0), true);
Group();
}
}
}
src/view/grid/GridAccount.hpp
3030
3131
3232
33
3334
3435
3536
......
7071
7172
7273
74
7375
7476
7577
......
8688
8789
8890
91
8992
9093
9194
#include <QTableWidget>
#include <QSignalMapper>
#include <QCompleter>
#include <QShortcut>
class KissCount;
void OnMetaClicked(int id);
void OnCheckClicked(int id);
void OnDeleteClicked(int id);
void OnCtrlT(void);
private:
KissPanel* _parent;
bool _inModification;
QCompleter* _completer;
int _transfertCompletionIndex;
QShortcut* _ctrlT;
void SetWeek(int week, int line);
void ResetWeeks();
src/view/grid/TransfertDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Copyright 2010-2018 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 "TransfertDialog.hpp"
#include <QLabel>
TransfertDialog::TransfertDialog(KissCount* kiss, User* user, Operation& curOperation,
int* selectedAccount, bool* groupOperations) :
QDialog(0, Qt::Dialog), _kiss(kiss), _outSelectedAccount(selectedAccount),
_outGroupOperations(groupOperations)
{
std::vector<Account>::iterator accountIt;
QGridLayout* gridLayout;
Operation op_tmp;
bool hasPrevious;
int selectedIndex = -1, curIndex = 0;
gridLayout = new QGridLayout(this);
setWindowTitle(_("Create Transfert"));
setModal(true);
gridLayout->addWidget(new QLabel(_("Transfert to "), this), 0, 0);
_account = new QComboBox(this);
gridLayout->addWidget(_account, 0, 1);
_ok = new QPushButton(_("OK"), this);
QPushButton* cancel = new QPushButton(_("Cancel"), this);
gridLayout->addWidget(_ok, 0, 2);
gridLayout->addWidget(cancel, 1, 2);
if(_kiss->SearchPreviousOperation(&op_tmp, curOperation, curOperation.month,
curOperation.year, true, 1))
{
hasPrevious = (op_tmp.transfert)?true:false;
}
for (accountIt = user->_accounts.begin();
accountIt != user->_accounts.end();
accountIt++, curIndex++)
{
if (accountIt->id != curOperation.account &&
accountIt->validAt(curOperation.month, curOperation.year))
{
_account->addItem(accountIt->name);
_accounts.push_back(accountIt->id);
if (hasPrevious && accountIt->id == op_tmp.account)
selectedIndex = curIndex;
}
}
if (selectedIndex != -1)
_account->setCurrentIndex(selectedIndex);
_groupOperations = new QCheckBox(_("Group operations"));
_groupOperations->setChecked(true);
gridLayout->addWidget(_groupOperations, 1, 1);
connect(_ok, SIGNAL(clicked()), this, SLOT(OnOK()));
connect(cancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
_ok->setFocus();
}
void TransfertDialog::OnOK()
{
*_outSelectedAccount = _accounts[_account->currentIndex()];
*_outGroupOperations = (_groupOperations->checkState() == Qt::Checked);
done(1);
}
void TransfertDialog::OnCancel()
{
*_outSelectedAccount = -1;
done(0);
}
src/view/grid/TransfertDialog.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Copyright 2010-2018 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 TRANSFERTDIALOG_H
#define TRANSFERTDIALOG_H
#include <QDialog>
#include <QComboBox>
#include <QCheckBox>
#include <view/wxUI.hpp>
class TransfertDialog : public QDialog
{
Q_OBJECT;
public:
TransfertDialog(KissCount* kiss, User* user, Operation& curOperation,
int* selectedAccount, bool* groupOperations);
private slots:
void OnOK();
void OnCancel();
private:
KissCount* _kiss;
wxUI* _wxUI;
QComboBox* _account;
std::vector<int> _accounts;
QCheckBox* _groupOperations;
QPushButton* _ok;
int* _outSelectedAccount;
bool* _outGroupOperations;
};
#endif

Archive Download the corresponding diff file