KissCount

KissCount Commit Details

Date:2020-04-19 16:50:07 (3 months 15 days ago)
Author:Grégory Soutadé
Branch:dev
Commit:2e89948c1f0dc2b43819ae7d3098c1f21ba97444
Parents: c57405a4074439e927bef26bdf366c899de2a74c
Message:Add ctrl+h shortcut to setup current operation date to yesterday. If called twice, set date to last operation date (if any)

Changes:
MChangeLog (1 diff)
Msrc/view/grid/GridAccount.cpp (2 diffs)
Msrc/view/grid/GridAccount.hpp (3 diffs)

File differences

ChangeLog
1
1
22
3
34
5
46
57
68
v0.9 (27/07/2019)
v0.9 (19/04/2020)
** User **
Add ctrl+h shortcut to setup current operation date to yesterday. If called twice, set date to last operation date (if any)
** Dev **
Add a constructor for Operation (to clear all fields)
** Bugs **
Check index in ctrl+t, ctrl+r and suppr callback to avoid doing something on non existant operation
src/view/grid/GridAccount.cpp
122122
123123
124124
125
125126
126127
127128
......
17341735
17351736
17361737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
17371806
17381807
17391808
{
_ctrlT = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_T), this, SLOT(OnCtrlT()));
_ctrlR = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_R), this, SLOT(OnCtrlR()));
_ctrlH = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_H), this, SLOT(OnCtrlH()));
_suppr = new QShortcut(QKeySequence(Qt::Key_Delete), this, SLOT(OnSuppr()));
}
}
}
}
void GridAccount::OnCtrlH(void)
{
QModelIndexList selected = selectedIndexes();
Operation op, prev_op;
QString value;
QDate date;
int row, day;
if (selected.size() != 1)
return;
row = selected[0].row();
op = _displayedOperations[row];
if (op.meta)
return;
if (!op.id)
{
op.month = _curMonth;
op.year = _curYear;
value = item(row, OP_DATE)->text();
if (value.length())
{
date = QDate::fromString(value, _kiss->GetDateLocalFormat());
op.day = date.day()-1;
}
else
op.day = 0;
// Set previous operation day
if (row <= _fixCosts)
_lastCtrlH = row;
}
// Ctrl+H multiple times
// Set day to previous operation day
if (_lastCtrlH == row)
{
if (row < 2)
return;
prev_op = _displayedOperations[row-1];
// No previous operation or day already equal
if (!prev_op.id || op.day == prev_op.day)
return;
day = prev_op.day;
}
// Set day to yesterday
else
{
day = QDate::currentDate().day()-1;
day--;
}
_inModification = true ;
op.day = day;
if (op.id)
UpdateOperation(op);
item(row, OP_DATE)->setText(_kiss->FormatDate(op.day+1, op.month+1, op.year));
_lastCtrlH = row;
_inModification = false ;
}
void GridAccount::OnSuppr(void)
{
QModelIndexList selected = selectedIndexes();
src/view/grid/GridAccount.hpp
4545
4646
4747
48
48
4949
5050
5151
......
7373
7474
7575
76
7677
7778
7879
......
8990
9091
9192
92
93
93
94
9495
9596
9697
enum {TREE, DESCRIPTION, OP_DATE, DEBIT, CREDIT, CATEGORY, TAG, ACCOUNT, CHECKED, NUMBER_COLS_OPS};
GridAccount(KissCount* kiss, KissPanel *parent,
GridAccount(KissCount* kiss, KissPanel *parent,
bool canAddOperation, bool setWeek, bool synchronizeWithDatabase);
~GridAccount();
void OnDeleteClicked(int id);
void OnCtrlT(void);
void OnCtrlR(void);
void OnCtrlH(void);
void OnSuppr(void);
private:
QSignalMapper _treeSignalMapper, _checkSignalMapper, _deleteSignalMapper;
bool _inModification;
QCompleter* _completer;
int _transfertCompletionIndex;
QShortcut* _ctrlT, *_ctrlR, *_suppr;
int _transfertCompletionIndex, _lastCtrlH;
QShortcut* _ctrlT, *_ctrlR, *_ctrlH, *_suppr;
void SetWeek(int week, int line);
void ResetWeeks();

Archive Download the corresponding diff file