Better auto completion for transfert operation (not two times the same operation completed)
This commit is contained in:
parent
9991415e2c
commit
bfd16a6540
|
@ -1,4 +1,4 @@
|
|||
v0.3 (27/03/2012)
|
||||
v0.3 (11/04/2012)
|
||||
** User **
|
||||
New interface in Qt
|
||||
Use BDD file from .local/share/kisscount
|
||||
|
@ -7,6 +7,7 @@ v0.3 (27/03/2012)
|
|||
Description is now auto-completed
|
||||
Snapshot feature
|
||||
Display date in locale format
|
||||
Better auto completion for transfert operation (not two times the same operation completed)
|
||||
|
||||
** Dev **
|
||||
Version 3 of database (account hidden item added)
|
||||
|
|
|
@ -410,10 +410,9 @@ std::vector<Operation>* KissCount::Search(QString* description, QDate* dateFrom,
|
|||
return _db->Search(_user, description, dateFrom, dateTo, amountFrom, amountTo, categories, types, accounts, true);
|
||||
}
|
||||
|
||||
bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType)
|
||||
bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType, int index)
|
||||
{
|
||||
std::vector<Operation>* operations;
|
||||
QDate* date ;
|
||||
//wxDateSpan threeMonths(0, 3); Not working :(
|
||||
std::vector<int> v;
|
||||
int i;
|
||||
|
@ -425,15 +424,12 @@ bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month
|
|||
month += 12;
|
||||
}
|
||||
|
||||
date = new QDate(year, month, 0);
|
||||
QDate date = QDate(year, month, 0);
|
||||
|
||||
if (limitToType)
|
||||
operations = _db->Search(_user, &op.description, date, 0, 0, 0, v, op.fix_cost ? +Database::FIX_OP : +Database::NON_FIX_OP, v, false);
|
||||
operations = _db->Search(_user, &op.description, &date, 0, 0, 0, v, op.fix_cost ? +Database::FIX_OP : +Database::NON_FIX_OP, v, false);
|
||||
else
|
||||
operations = _db->Search(_user, &op.description, date, 0, 0, 0, v, Database::ALL_OP, v, false);
|
||||
|
||||
|
||||
delete date;
|
||||
operations = _db->Search(_user, &op.description, &date, 0, 0, 0, v, Database::ALL_OP, v, false);
|
||||
|
||||
if (!operations->size())
|
||||
{
|
||||
|
@ -442,7 +438,7 @@ bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month
|
|||
}
|
||||
|
||||
for(i=operations->size()-1; i>=0; i--)
|
||||
if (!(*operations)[i].meta)
|
||||
if (!(*operations)[i].meta && index--)
|
||||
{
|
||||
*res = (*operations)[i];
|
||||
delete operations;
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
double* amountFrom, double* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts);
|
||||
|
||||
bool SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType);
|
||||
bool SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType, int index);
|
||||
|
||||
void GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
||||
std::map<int, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
|
|
|
@ -49,7 +49,8 @@ GridAccount::GridAccount(KissCount* kiss, QWidget *parent,
|
|||
_parent(parent), _kiss(kiss), _setWeek(setWeek),
|
||||
_databaseSynchronization(synchronizeWithDatabase), _loadOperations(false),
|
||||
_curMonth(0), _curYear(0), _treeSignalMapper(this), _checkSignalMapper(this),
|
||||
_deleteSignalMapper(this), _inModification(false), _completer(0)
|
||||
_deleteSignalMapper(this), _inModification(false), _completer(0),
|
||||
_transfertCompletionIndex(0)
|
||||
{
|
||||
DEFAULT_FONT(font);
|
||||
int i;
|
||||
|
@ -865,7 +866,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
|||
int op_complete = 6, i, last_day;
|
||||
QString value, v ;
|
||||
QDate date;
|
||||
bool need_insertion = false;
|
||||
bool need_insertion = false, transfertCompleted = false;
|
||||
QColor color ;
|
||||
unsigned char r, g, b;
|
||||
std::vector<int>::iterator it;
|
||||
|
@ -926,7 +927,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
|||
!item(row, ACCOUNT)->text().length()))
|
||||
{
|
||||
new_op.fix_cost = (row <= _fixCosts);
|
||||
if (_kiss->SearchPreviousOperation(&op_tmp, new_op, _curMonth, _curYear, _canAddOperation))
|
||||
if (_kiss->SearchPreviousOperation(&op_tmp, new_op, _curMonth, _curYear, _canAddOperation, _transfertCompletionIndex))
|
||||
{
|
||||
if (!item(row, CATEGORY)->text().length())
|
||||
setItem(row, CATEGORY, new QTableWidgetItem(_(user->GetCategoryName(op_tmp.category).toStdString().c_str())));
|
||||
|
@ -936,6 +937,8 @@ void GridAccount::OnOperationModified(int row, int col)
|
|||
|
||||
col = CATEGORY;
|
||||
new_op.fix_cost = (new_op.category == user->GetCategoryId("Fix"));
|
||||
if (op_tmp.transfert != 0)
|
||||
transfertCompleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1066,6 +1069,9 @@ void GridAccount::OnOperationModified(int row, int col)
|
|||
SET_ROW_FONT(row, font);
|
||||
|
||||
new_op.id = _kiss->AddOperation(new_op);
|
||||
|
||||
if (transfertCompleted)
|
||||
_transfertCompletionIndex = (_transfertCompletionIndex + 1) % 2;
|
||||
}
|
||||
|
||||
if (!new_op.meta && user->GetAccount(new_op.account).blocked && new_op.amount < 0)
|
||||
|
|
|
@ -85,6 +85,8 @@ private:
|
|||
QSignalMapper _treeSignalMapper, _checkSignalMapper, _deleteSignalMapper;
|
||||
bool _inModification;
|
||||
QCompleter* _completer;
|
||||
int _transfertCompletionIndex;
|
||||
|
||||
void SetWeek(int week, int line);
|
||||
void ResetWeeks();
|
||||
void ComputeWeeks();
|
||||
|
|
Loading…
Reference in New Issue
Block a user