Factorize some code in GridAccount
Set default font for everybody Fix a bug in DateDelegate (bad month) Fix a bug in GridAccount : Tab added for sub operations when saving Fix a bug in GridAccount : credit was considered as a debit
This commit is contained in:
parent
63b235d8db
commit
c94bf51007
|
@ -97,7 +97,7 @@ int User::GetCategoryId(const QString& catName)
|
||||||
|
|
||||||
const QFont User::GetCategoryFont(int catId)
|
const QFont User::GetCategoryFont(int catId)
|
||||||
{
|
{
|
||||||
QFont f;
|
DEFAULT_FONT(f);
|
||||||
Category cat;
|
Category cat;
|
||||||
|
|
||||||
for (unsigned int i=0; i<_categories.size(); i++)
|
for (unsigned int i=0; i<_categories.size(); i++)
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #include "grid/wxGridCellBitmapRenderer.hpp"
|
|
||||||
// #include "GenerateDialog.hpp"
|
|
||||||
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -45,7 +42,6 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
std::vector<Account>::iterator accountIt;
|
std::vector<Account>::iterator accountIt;
|
||||||
std::vector<Category>::iterator categoryIt;
|
std::vector<Category>::iterator categoryIt;
|
||||||
DEFAULT_FONT(font);
|
|
||||||
int nbCategories;
|
int nbCategories;
|
||||||
|
|
||||||
setLayout(hbox);
|
setLayout(hbox);
|
||||||
|
@ -65,7 +61,6 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
_calendar->setFirstDayOfWeek(Qt::Monday);
|
_calendar->setFirstDayOfWeek(Qt::Monday);
|
||||||
_calendar->setNavigationBarVisible(false);
|
_calendar->setNavigationBarVisible(false);
|
||||||
_calendar->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
|
_calendar->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
|
||||||
|
|
||||||
_calendar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
_calendar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
|
||||||
_accounts = new QString[user->GetAccountsNumber()];
|
_accounts = new QString[user->GetAccountsNumber()];
|
||||||
|
@ -215,7 +210,7 @@ void AccountPanel::InitStatsGrid(User* user)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int nb_categories = user->GetCategoriesNumber();
|
int nb_categories = user->GetCategoriesNumber();
|
||||||
QFont font;
|
DEFAULT_FONT(font);
|
||||||
|
|
||||||
if (!_statsGrid->rowCount())
|
if (!_statsGrid->rowCount())
|
||||||
{
|
{
|
||||||
|
@ -228,11 +223,8 @@ void AccountPanel::InitStatsGrid(User* user)
|
||||||
}
|
}
|
||||||
_statsGrid->setRowCount(nb_categories+CATS_STATS+1); // Headers + blank + categories + non fix
|
_statsGrid->setRowCount(nb_categories+CATS_STATS+1); // Headers + blank + categories + non fix
|
||||||
|
|
||||||
// _statsGrid->SetDefaultCellFont(font);
|
|
||||||
|
|
||||||
_statsGrid->setItem(TOTAL_CREDIT, 0, new QTableWidgetItem(_("Total Credit")));
|
_statsGrid->setItem(TOTAL_CREDIT, 0, new QTableWidgetItem(_("Total Credit")));
|
||||||
_statsGrid->setItem(TOTAL_DEBIT, 0, new QTableWidgetItem(_("Total Debit")));
|
_statsGrid->setItem(TOTAL_DEBIT, 0, new QTableWidgetItem(_("Total Debit")));
|
||||||
font = _statsGrid->item(TOTAL_DEBIT, 0)->font();
|
|
||||||
|
|
||||||
for(i=0; i<nb_categories; i++)
|
for(i=0; i<nb_categories; i++)
|
||||||
{
|
{
|
||||||
|
@ -372,7 +364,6 @@ void AccountPanel::ShowMonth(int month, int year)
|
||||||
// std::vector<Operation> operations;
|
// std::vector<Operation> operations;
|
||||||
// _fixCosts = 0;
|
// _fixCosts = 0;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
// DEFAULT_FONT(font);
|
|
||||||
// std::vector<Category>::iterator categoryIt;
|
// std::vector<Category>::iterator categoryIt;
|
||||||
std::map<unsigned int, std::vector<Operation> >::iterator monthIt;
|
std::map<unsigned int, std::vector<Operation> >::iterator monthIt;
|
||||||
QDate curDate = QDate::currentDate();
|
QDate curDate = QDate::currentDate();
|
||||||
|
@ -445,7 +436,9 @@ void AccountPanel::InitAccountsGrid(User* user, int month, int year)
|
||||||
int i, a;
|
int i, a;
|
||||||
QTableWidgetItem* item;
|
QTableWidgetItem* item;
|
||||||
QString v;
|
QString v;
|
||||||
QFont font;
|
DEFAULT_FONT(font);
|
||||||
|
|
||||||
|
font.setBold(true);
|
||||||
|
|
||||||
if (_accountsGrid->rowCount())
|
if (_accountsGrid->rowCount())
|
||||||
_accountsGrid->clear();
|
_accountsGrid->clear();
|
||||||
|
@ -458,8 +451,7 @@ void AccountPanel::InitAccountsGrid(User* user, int month, int year)
|
||||||
|
|
||||||
for(i=0; i<NUMBER_COLS_ACCOUNTS; i++)
|
for(i=0; i<NUMBER_COLS_ACCOUNTS; i++)
|
||||||
{
|
{
|
||||||
QFont font = _accountsGrid->horizontalHeaderItem(i)->font();
|
_accountsGrid->horizontalHeaderItem(i)->font();
|
||||||
font.setBold(true);
|
|
||||||
_accountsGrid->horizontalHeaderItem(i)->setFont(font);
|
_accountsGrid->horizontalHeaderItem(i)->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,12 +479,8 @@ void AccountPanel::InitAccountsGrid(User* user, int month, int year)
|
||||||
if (a != ACCOUNT_INIT)
|
if (a != ACCOUNT_INIT)
|
||||||
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
||||||
if (a == ACCOUNT_CUR)
|
if (a == ACCOUNT_CUR)
|
||||||
{
|
|
||||||
font = item->font();
|
|
||||||
font.setBold(true);
|
|
||||||
item->setFont(font);
|
item->setFont(font);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_accountsInitValues[it->id] = value;
|
_accountsInitValues[it->id] = value;
|
||||||
_accountsGrid->item(curLine, ACCOUNT_INIT)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
_accountsGrid->item(curLine, ACCOUNT_INIT)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
_accountsGrid->item(curLine, ACCOUNT_CUR)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
_accountsGrid->item(curLine, ACCOUNT_CUR)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
|
@ -38,7 +38,7 @@ void DateDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
QComboBox *combo = qobject_cast<QComboBox *>(editor);
|
QComboBox *combo = qobject_cast<QComboBox *>(editor);
|
||||||
QString s ;
|
QString s ;
|
||||||
|
|
||||||
s = s.sprintf("%02d/%02d/%04d", combo->currentIndex()+1, _month+1, _year);
|
s = s.sprintf("%02d/%02d/%04d", combo->currentIndex()+1, _month, _year);
|
||||||
|
|
||||||
model->setData(index, qVariantFromValue(s));
|
model->setData(index, qVariantFromValue(s));
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,7 @@ GridAccount::GridAccount(KissCount* kiss, QWidget *parent,
|
||||||
_curMonth(0), _curYear(0), _treeSignalMapper(this), _checkSignalMapper(this),
|
_curMonth(0), _curYear(0), _treeSignalMapper(this), _checkSignalMapper(this),
|
||||||
_deleteSignalMapper(this), _inModification(false)
|
_deleteSignalMapper(this), _inModification(false)
|
||||||
{
|
{
|
||||||
//DEFAULT_FONT(font);
|
DEFAULT_FONT(font);
|
||||||
QFont font;
|
|
||||||
int i;
|
int i;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
std::vector<Account>::iterator accountIt;
|
std::vector<Account>::iterator accountIt;
|
||||||
|
@ -69,16 +68,15 @@ GridAccount::GridAccount(KissCount* kiss, QWidget *parent,
|
||||||
setShowGrid(false);
|
setShowGrid(false);
|
||||||
|
|
||||||
setColumnWidth (DESCRIPTION, columnWidth(DESCRIPTION)*3);
|
setColumnWidth (DESCRIPTION, columnWidth(DESCRIPTION)*3);
|
||||||
//SetDefaultCellFont(font);
|
setFont(font);
|
||||||
|
|
||||||
|
font.setBold(true);
|
||||||
QString colsName[] = {"", _("Description"), _("Date"), _("Debit"), _("Credit"), _("Category"), _("Account"), "", ""};
|
QString colsName[] = {"", _("Description"), _("Date"), _("Debit"), _("Credit"), _("Category"), _("Account"), "", ""};
|
||||||
for(i=0; i<NUMBER_COLS_OPS; i++)
|
for(i=0; i<NUMBER_COLS_OPS; i++)
|
||||||
{
|
{
|
||||||
item = new QTableWidgetItem(colsName[i]);
|
item = new QTableWidgetItem(colsName[i]);
|
||||||
item->setText(colsName[i]);
|
item->setText(colsName[i]);
|
||||||
item->setBackground(view::OWN_CYAN);
|
item->setBackground(view::OWN_CYAN);
|
||||||
font = item->font();
|
|
||||||
font.setBold(true);
|
|
||||||
item->setFont(font);
|
item->setFont(font);
|
||||||
SET_READ_ONLY(item);
|
SET_READ_ONLY(item);
|
||||||
item->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
item->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||||
|
@ -312,7 +310,7 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||||
QColor color;
|
QColor color;
|
||||||
QDate curDate = QDate::currentDate();
|
QDate curDate = QDate::currentDate();
|
||||||
QString description, v;
|
QString description, v;
|
||||||
QFont font;
|
DEFAULT_FONT(font);
|
||||||
Category cat ;
|
Category cat ;
|
||||||
Operation op2;
|
Operation op2;
|
||||||
QTableWidgetItem* item;
|
QTableWidgetItem* item;
|
||||||
|
@ -473,6 +471,9 @@ void GridAccount::InsertIntoGrid(Operation& op)
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
Operation parent;
|
Operation parent;
|
||||||
|
|
||||||
|
if (op.parent)
|
||||||
|
parent = GetOperation(op.parent);
|
||||||
|
|
||||||
// No previous fix operations
|
// No previous fix operations
|
||||||
if (op.fix_cost && !_displayedOperations[1].id)
|
if (op.fix_cost && !_displayedOperations[1].id)
|
||||||
i = 1;
|
i = 1;
|
||||||
|
@ -503,7 +504,6 @@ void GridAccount::InsertIntoGrid(Operation& op)
|
||||||
|
|
||||||
if (op.parent)
|
if (op.parent)
|
||||||
{
|
{
|
||||||
parent = GetOperation(op.parent);
|
|
||||||
if ((i-start) > (int)(parent.childs.size()))
|
if ((i-start) > (int)(parent.childs.size()))
|
||||||
i = start + parent.childs.size();
|
i = start + parent.childs.size();
|
||||||
if (parent.day >= op.day)
|
if (parent.day >= op.day)
|
||||||
|
@ -783,9 +783,11 @@ void GridAccount::OnDeleteClicked(int id)
|
||||||
_kiss->DeleteOperation(*it);
|
_kiss->DeleteOperation(*it);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
|
|
||||||
if (op.parent && op_tmp.childs.size() < 2)
|
if (op.parent)
|
||||||
{
|
{
|
||||||
if (op.childs.size() == 1)
|
if (op_tmp.childs.size() < 2)
|
||||||
|
{
|
||||||
|
if (op_tmp.childs.size() == 1)
|
||||||
{
|
{
|
||||||
op_tmp2 = GetOperation(op_tmp.childs[0]);
|
op_tmp2 = GetOperation(op_tmp.childs[0]);
|
||||||
op_tmp2.parent = 0;
|
op_tmp2.parent = 0;
|
||||||
|
@ -793,6 +795,7 @@ void GridAccount::OnDeleteClicked(int id)
|
||||||
row = GetDisplayedRow(op_tmp2.id);
|
row = GetDisplayedRow(op_tmp2.id);
|
||||||
_displayedOperations[row] = op_tmp2;
|
_displayedOperations[row] = op_tmp2;
|
||||||
}
|
}
|
||||||
|
|
||||||
row = GetDisplayedRow(op.parent);
|
row = GetDisplayedRow(op.parent);
|
||||||
removeRow(row);
|
removeRow(row);
|
||||||
DeleteOperation(op_tmp);
|
DeleteOperation(op_tmp);
|
||||||
|
@ -815,6 +818,14 @@ void GridAccount::OnDeleteClicked(int id)
|
||||||
SET_ROW_COLOR(row, color, user->GetCategory(op.category).forecolor);
|
SET_ROW_COLOR(row, color, user->GetCategory(op.category).forecolor);
|
||||||
SET_ROW_FONT(row, user->GetCategoryFont(op.category));
|
SET_ROW_FONT(row, user->GetCategoryFont(op.category));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateMeta(op_tmp);
|
||||||
|
row = GetDisplayedRow(op_tmp.id);
|
||||||
|
RemoveMeta(op_tmp, row, true, false);
|
||||||
|
InsertIntoGrid(op_tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (op.fix_cost)
|
if (op.fix_cost)
|
||||||
_fixCosts--;
|
_fixCosts--;
|
||||||
ComputeWeeks();
|
ComputeWeeks();
|
||||||
|
@ -839,6 +850,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
double amount;
|
double amount;
|
||||||
QFont font;
|
QFont font;
|
||||||
Category cat ;
|
Category cat ;
|
||||||
|
bool fix_cost;
|
||||||
|
|
||||||
// Avoid recursives calls
|
// Avoid recursives calls
|
||||||
if (_inModification || _loadOperations) return;
|
if (_inModification || _loadOperations) return;
|
||||||
|
@ -855,7 +867,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
value = item(row, DESCRIPTION)->text();
|
value = item(row, DESCRIPTION)->text();
|
||||||
if (value.length())
|
if (value.length())
|
||||||
{
|
{
|
||||||
new_op.description = value;
|
new_op.description = value.trimmed();
|
||||||
op_complete--;
|
op_complete--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,7 +922,6 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
new_op.amount *= -1.0;
|
new_op.amount *= -1.0;
|
||||||
setItem(row, DEBIT, new QTableWidgetItem(value.sprintf("%.2lf", new_op.amount)));
|
setItem(row, DEBIT, new QTableWidgetItem(value.sprintf("%.2lf", new_op.amount)));
|
||||||
}
|
}
|
||||||
if (new_op.amount != 0.0) new_op.amount *= -1.0;
|
|
||||||
op_complete--;
|
op_complete--;
|
||||||
new_op.formula = _displayedOperations[row].formula;
|
new_op.formula = _displayedOperations[row].formula;
|
||||||
}
|
}
|
||||||
|
@ -937,7 +948,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
|
|
||||||
color = user->GetCategory(new_op.category).backcolor;
|
color = user->GetCategory(new_op.category).backcolor;
|
||||||
|
|
||||||
if (col == CATEGORY && new_op.checked)
|
if (new_op.checked)
|
||||||
{
|
{
|
||||||
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
|
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
|
||||||
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
|
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
|
||||||
|
@ -948,11 +959,15 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
SET_ROW_COLOR(row, color, user->GetCategory(new_op.category).forecolor);
|
SET_ROW_COLOR(row, color, user->GetCategory(new_op.category).forecolor);
|
||||||
SET_ROW_FONT(row, user->GetCategoryFont(new_op.category));
|
SET_ROW_FONT(row, user->GetCategoryFont(new_op.category));
|
||||||
|
|
||||||
// Modify a fix operation
|
fix_cost = (row <= _fixCosts);
|
||||||
if (row < _fixCosts || !_canAddOperation)
|
|
||||||
|
// Modify an operation
|
||||||
|
if (!_canAddOperation || (row < _fixCosts ||
|
||||||
|
(row > _fixCosts &&
|
||||||
|
row < (int)(_displayedOperations.size()-1))))
|
||||||
{
|
{
|
||||||
new_op.id = cur_op.id;
|
new_op.id = cur_op.id;
|
||||||
new_op.fix_cost = true;
|
new_op.fix_cost = fix_cost;
|
||||||
new_op.transfert = cur_op.transfert;
|
new_op.transfert = cur_op.transfert;
|
||||||
new_op.meta = cur_op.meta;
|
new_op.meta = cur_op.meta;
|
||||||
new_op.parent = cur_op.parent;
|
new_op.parent = cur_op.parent;
|
||||||
|
@ -965,62 +980,13 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
removeRow(row);
|
removeRow(row);
|
||||||
DeleteOperation(cur_op);
|
DeleteOperation(cur_op);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
|
if (fix_cost)
|
||||||
_fixCosts--;
|
_fixCosts--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
UpdateOperation(new_op);
|
|
||||||
(_displayedOperations)[row] = new_op;
|
(_displayedOperations)[row] = new_op;
|
||||||
}
|
|
||||||
}
|
|
||||||
// Add a fixCost
|
|
||||||
else if (row == _fixCosts)
|
|
||||||
{
|
|
||||||
if (op_complete) {
|
|
||||||
_inModification = false ;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
need_insertion = true;
|
|
||||||
new_op.fix_cost = true;
|
|
||||||
new_op.meta = false;
|
|
||||||
new_op._virtual = false;
|
|
||||||
|
|
||||||
for(i=0; i<NUMBER_COLS_OPS; i++)
|
|
||||||
{
|
|
||||||
if (i == CATEGORY) continue;
|
|
||||||
setItem(row, i, new QTableWidgetItem(""));
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFAULT_FONT(font);
|
|
||||||
|
|
||||||
SET_ROW_COLOR(row, view::OWN_YELLOW, Qt::black);
|
|
||||||
SET_ROW_FONT(row, font);
|
|
||||||
|
|
||||||
new_op.id = _kiss->AddOperation(new_op);
|
|
||||||
}
|
|
||||||
// Modify an operation
|
|
||||||
else if (row < (int)(_displayedOperations.size()-1))
|
|
||||||
{
|
|
||||||
new_op.id = cur_op.id;
|
|
||||||
new_op.fix_cost = false;
|
|
||||||
new_op.transfert = cur_op.transfert;
|
|
||||||
new_op.meta = cur_op.meta;
|
|
||||||
new_op.parent = cur_op.parent;
|
|
||||||
new_op.childs = cur_op.childs;
|
|
||||||
new_op._virtual = cur_op._virtual;
|
|
||||||
|
|
||||||
if (cur_op.day != new_op.day)
|
|
||||||
{
|
|
||||||
need_insertion = true;
|
|
||||||
removeRow(row);
|
|
||||||
DeleteOperation(cur_op);
|
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UpdateOperation(new_op);
|
UpdateOperation(new_op);
|
||||||
(_displayedOperations)[row] = new_op;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Add an operation
|
// Add an operation
|
||||||
else
|
else
|
||||||
|
@ -1030,38 +996,59 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
need_insertion = true;
|
need_insertion = true;
|
||||||
new_op.fix_cost = false;
|
new_op.fix_cost = fix_cost;
|
||||||
new_op.meta = false;
|
new_op.meta = false;
|
||||||
new_op._virtual = false;
|
new_op._virtual = false;
|
||||||
|
new_op.parent = 0;
|
||||||
|
|
||||||
for(i=0; i<NUMBER_COLS_OPS; i++)
|
for(i=0; i<NUMBER_COLS_OPS; i++)
|
||||||
{
|
{
|
||||||
|
if (fix_cost && i == CATEGORY) continue;
|
||||||
setItem(row, i, new QTableWidgetItem(""));
|
setItem(row, i, new QTableWidgetItem(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULT_FONT(font);
|
DEFAULT_FONT(font);
|
||||||
|
|
||||||
|
if (fix_cost)
|
||||||
|
{
|
||||||
|
SET_ROW_COLOR(row, view::OWN_YELLOW, Qt::black);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
SET_ROW_COLOR(row, view::OWN_GREEN, Qt::black);
|
SET_ROW_COLOR(row, view::OWN_GREEN, Qt::black);
|
||||||
|
}
|
||||||
|
|
||||||
SET_ROW_FONT(row, font);
|
SET_ROW_FONT(row, font);
|
||||||
|
|
||||||
new_op.id = _kiss->AddOperation(new_op);
|
new_op.id = _kiss->AddOperation(new_op);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user->GetAccount(new_op.account).blocked && new_op.amount < 0)
|
if (!new_op.meta && user->GetAccount(new_op.account).blocked && new_op.amount < 0)
|
||||||
QMessageBox::warning(0, _("Warning"), _("You made a debit on a blocked account"));
|
QMessageBox::warning(0, _("Warning"), _("You made a debit on a blocked account"));
|
||||||
|
|
||||||
if (need_insertion)
|
if (need_insertion)
|
||||||
{
|
|
||||||
InsertIntoGrid(new_op);
|
InsertIntoGrid(new_op);
|
||||||
UpdateOperation(new_op);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_op.parent)
|
if (new_op.parent)
|
||||||
{
|
{
|
||||||
row = GetDisplayedRow(new_op.parent);
|
row = GetDisplayedRow(new_op.parent);
|
||||||
|
|
||||||
|
last_day = new_op.day;
|
||||||
new_op = _displayedOperations[row];
|
new_op = _displayedOperations[row];
|
||||||
|
|
||||||
|
it = std::find(new_op.childs.begin(), new_op.childs.end(), cur_op.id);
|
||||||
|
new_op.childs.erase(it);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for(it = new_op.childs.begin(); it != new_op.childs.end(); it++)
|
||||||
|
{
|
||||||
|
op2 = GetOperation(*it);
|
||||||
|
if (op2.day > last_day) break;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_op.childs.insert(new_op.childs.begin()+i, cur_op.id);
|
||||||
|
|
||||||
last_day = new_op.day;
|
last_day = new_op.day;
|
||||||
|
|
||||||
UpdateMeta(new_op);
|
UpdateMeta(new_op);
|
||||||
|
@ -1075,7 +1062,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
else
|
else
|
||||||
color = view::OWN_GREEN;
|
color = view::OWN_GREEN;
|
||||||
|
|
||||||
QCheckBox* checkBox = qobject_cast<QCheckBox*> (_checkSignalMapper.mapping(op.parent));
|
QCheckBox* checkBox = qobject_cast<QCheckBox*> (_checkSignalMapper.mapping(new_op.id));
|
||||||
if (new_op.checked)
|
if (new_op.checked)
|
||||||
{
|
{
|
||||||
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
|
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
|
||||||
|
@ -1087,15 +1074,6 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
else
|
else
|
||||||
checkBox->setCheckState(Qt::Unchecked);
|
checkBox->setCheckState(Qt::Unchecked);
|
||||||
|
|
||||||
|
|
||||||
SET_ROW_COLOR(row, color, cat.forecolor);
|
|
||||||
|
|
||||||
if (new_op.category && cat.font.length())
|
|
||||||
{
|
|
||||||
font = user->GetCategoryFont(cat.id);
|
|
||||||
SET_ROW_FONT(row, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
setItem(row, OP_DATE, new QTableWidgetItem(v.sprintf("%02d/%02d/%d", new_op.day+1, _curMonth+1, _curYear)));
|
setItem(row, OP_DATE, new QTableWidgetItem(v.sprintf("%02d/%02d/%d", new_op.day+1, _curMonth+1, _curYear)));
|
||||||
|
|
||||||
if (!_displayedOperations[row].amount)
|
if (!_displayedOperations[row].amount)
|
||||||
|
@ -1119,6 +1097,17 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->item(row, OP_DATE)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||||
|
this->item(row, DEBIT)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
this->item(row, CREDIT)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
SET_ROW_COLOR(row, color, cat.forecolor);
|
||||||
|
|
||||||
|
if (new_op.category && cat.font.length())
|
||||||
|
{
|
||||||
|
SET_ROW_FONT(row, user->GetCategoryFont(cat.id));
|
||||||
|
}
|
||||||
|
|
||||||
// Move updated meta
|
// Move updated meta
|
||||||
if ((int)new_op.day != last_day)
|
if ((int)new_op.day != last_day)
|
||||||
{
|
{
|
||||||
|
@ -1156,6 +1145,11 @@ void GridAccount::UpdateMeta(Operation& meta)
|
||||||
meta.checked = true;
|
meta.checked = true;
|
||||||
meta.amount = 0;
|
meta.amount = 0;
|
||||||
|
|
||||||
|
op = GetOperation(meta.childs[0]);
|
||||||
|
meta.year = op.year;
|
||||||
|
meta.month = op.month;
|
||||||
|
meta.day = op.day;
|
||||||
|
|
||||||
for(it=meta.childs.begin(); it!=meta.childs.end(); it++)
|
for(it=meta.childs.begin(); it!=meta.childs.end(); it++)
|
||||||
{
|
{
|
||||||
op = GetOperation(*it);
|
op = GetOperation(*it);
|
||||||
|
|
|
@ -32,6 +32,8 @@ class ImportEngine;
|
||||||
|
|
||||||
#include <controller/KissCount.hpp>
|
#include <controller/KissCount.hpp>
|
||||||
|
|
||||||
|
#include "view.hpp"
|
||||||
|
|
||||||
#include <qtranslator.h>
|
#include <qtranslator.h>
|
||||||
#include <qtextcodec.h>
|
#include <qtextcodec.h>
|
||||||
|
|
||||||
|
@ -101,7 +103,11 @@ public:
|
||||||
_kiss(kiss),
|
_kiss(kiss),
|
||||||
_wxUI(parent),
|
_wxUI(parent),
|
||||||
_KissButton(0)
|
_KissButton(0)
|
||||||
{hide();}
|
{
|
||||||
|
DEFAULT_FONT(font);
|
||||||
|
hide();
|
||||||
|
setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnShow()=0;
|
virtual void OnShow()=0;
|
||||||
virtual KissPanel* CreatePanel()=0;
|
virtual KissPanel* CreatePanel()=0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user