Remove delete column (replaced by Suppr shortcut)

This commit is contained in:
Grégory Soutadé 2018-11-01 10:58:16 +01:00
parent 0a80a781a7
commit fa9f7497f5
5 changed files with 36 additions and 50 deletions

View File

@ -1,9 +1,10 @@
v0.8 (07/10/2018)
v0.8 (01/11/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)
Add ctrl+r shortcut to check/uncheck operations
Remove delete column (replaced by Suppr shortcut)
** Dev **
** Bugs **
Current account value is badly computed if operations are not in date order

View File

@ -202,9 +202,9 @@ void AccountPanel::Init(KissCount* kiss, wxUI *parent, int curMode)
vbox->addWidget(_costRepartitionBanner);
hbox->addLayout(vbox);
hbox->setStretch(0, 1);
hbox->setStretch(0, 1.5);
hbox->setStretch(1, 4);
hbox->setStretch(2, 1);
hbox->setStretch(2, 1.5);
ChangeUser();

View File

@ -44,19 +44,12 @@ CostRepartitionBanner::CostRepartitionBanner(KissCount* kiss, QFrame* parent, QS
QPen pen;
pen.setWidth(2);
pen.setColor(Qt::black);
//_pie->pieDiagram()->setPen(pen);
QLegend* legend = _pie->legend();
legend->detachFromChart();
legend->setAlignment(Qt::AlignTop);
legend->setVisible(false);
legend->setShowToolTips(true);
// legend->setAlignment(Qt::AlignBottom);
//_pie->addLegend(KDChart::Position::South);
// KDChart::Legend* legend = //_pie->legend();
// legend->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
// legend->setOrientation( Qt::Vertical );
_pie->setMargins(QMargins(5, 5, 5, 5));
@ -69,18 +62,6 @@ CostRepartitionBanner::CostRepartitionBanner(KissCount* kiss, QFrame* parent, QS
}
_pie->addSeries(series);
//_pie->setTitle(_("Cost repartition"));
//_pie->setMaximumSize( 200, 400 );
// KDChart::TextAttributes legendTextAttr(legend->textAttributes());
// legendTextAttr.setFontSize(64);
// legendTextAttr.setAutoShrink(true);
// legend->setTextAttributes(legendTextAttr);
// legendTextAttr = KDChart::TextAttributes(legend->titleTextAttributes());
// legendTextAttr.setFontSize(64);
// legendTextAttr.setAutoShrink(true);
// legend->setTitleTextAttributes(legendTextAttr);
_statsGrid = new QTableWidget(this);
_statsGrid->verticalHeader()->setHidden(true);
@ -104,7 +85,7 @@ CostRepartitionBanner::CostRepartitionBanner(KissCount* kiss, QFrame* parent, QS
vbox->addWidget(chartView);
setMaximumWidth(350);
setMaximumWidth(450);
}
void CostRepartitionBanner::Reset()

View File

@ -53,7 +53,7 @@ GridAccount::GridAccount(KissCount* kiss, KissPanel *parent,
_loadOperations(false),
_curMonth(0), _curYear(0), _treeSignalMapper(this), _checkSignalMapper(this),
_deleteSignalMapper(this), _inModification(false), _completer(0),
_transfertCompletionIndex(0), _ctrlT(0)
_transfertCompletionIndex(0), _ctrlT(0), _ctrlR(0), _suppr(0)
{
DEFAULT_FONT(font);
int i;
@ -83,10 +83,6 @@ GridAccount::GridAccount(KissCount* kiss, KissPanel *parent,
item->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
setItem(0, i, item);
}
label = new QLabel();
label->setPixmap(QPixmap(DELETE_ICON));
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setCellWidget(0, OP_DELETE, label);
label = new QLabel();
label->setPixmap(QPixmap(CHECKED_ICON));
@ -115,12 +111,10 @@ GridAccount::GridAccount(KissCount* kiss, KissPanel *parent,
resizeColumnToContents(TAG);
resizeColumnToContents(OP_DATE);
resizeColumnToContents(ACCOUNT);
resizeColumnToContents(OP_DELETE);
resizeColumnToContents(CHECKED);
connect(&_treeSignalMapper, SIGNAL(mapped(int)), this, SLOT(OnMetaClicked(int)));
connect(&_checkSignalMapper, SIGNAL(mapped(int)), this, SLOT(OnCheckClicked(int)));
connect(&_deleteSignalMapper, SIGNAL(mapped(int)), this, SLOT(OnDeleteClicked(int)));
setItemDelegate(new TableViewDelegate(this));
connect(this, SIGNAL(cellChanged(int, int)), this, SLOT(OnOperationModified(int, int)));
@ -128,6 +122,7 @@ GridAccount::GridAccount(KissCount* kiss, KissPanel *parent,
{
_ctrlT = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_T), this, SLOT(OnCtrlT()));
_ctrlR = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_R), this, SLOT(OnCtrlR()));
_suppr = new QShortcut(QKeySequence(Qt::Key_Delete), this, SLOT(OnSuppr()));
}
}
@ -141,6 +136,10 @@ GridAccount::~GridAccount()
delete _completer;
if (_ctrlT)
delete _ctrlT;
if (_ctrlR)
delete _ctrlR;
if (_suppr)
delete _suppr;
}
void GridAccount::ResetWeeks()
@ -330,7 +329,6 @@ void GridAccount::LoadOperations(std::vector<Operation>* operations, int month,
resizeColumnToContents(CATEGORY);
resizeColumnToContents(OP_DATE);
resizeColumnToContents(ACCOUNT);
resizeColumnToContents(OP_DELETE);
resizeColumnToContents(CHECKED);
resizeRowsToContents();
@ -469,12 +467,6 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
else
setItem(line, TAG, new QTableWidgetItem(""));
checkBox = new QCheckBox();
checkBox->setCheckState(Qt::Unchecked);
InsertCenteredWidget(line, OP_DELETE, checkBox);
_deleteSignalMapper.setMapping(checkBox, op.id);
connect(checkBox, SIGNAL(stateChanged(int)), &_deleteSignalMapper, SLOT(map()));
checkBox = new QCheckBox();
checkBox->setCheckState((op.checked) ? Qt::Checked : Qt::Unchecked);
InsertCenteredWidget(line, CHECKED, checkBox);
@ -547,7 +539,6 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
}
SET_READ_ONLY(this->item(line, CHECKED));
SET_READ_ONLY(this->item(line, OP_DELETE));
SET_ROW_FONT(line, user->GetCategoryFont(0));
}
@ -624,9 +615,6 @@ void GridAccount::RemoveRow(const Operation& op, int line, bool deleteOp)
QCheckBox* checkBox = qobject_cast<QCheckBox*> (GetCenteredWidget(line, CHECKED));
if (checkBox)
checkBox->disconnect(&_checkSignalMapper, SLOT(map()));
checkBox = qobject_cast<QCheckBox*> (GetCenteredWidget(line, OP_DELETE));
if (checkBox)
checkBox->disconnect(&_deleteSignalMapper, SLOT(map()));
removeRow(line);
_displayedOperations.erase(_displayedOperations.begin()+line);
if (op.fix_cost) _fixCosts--;
@ -919,19 +907,12 @@ void GridAccount::OnDeleteClicked(int id)
if (_inModification || _loadOperations) return;
QCheckBox* checkBox = qobject_cast<QCheckBox*> (_deleteSignalMapper.mapping(id));
if (checkBox->checkState() == Qt::Unchecked) return;
it = std::find(_displayedOperations.begin(), _displayedOperations.end(), id);
if (it == _displayedOperations.end()) return ;
if (QMessageBox::question(0, "KissCount", _("Are you sure want to delete : \n")+it->description, QMessageBox::Yes|QMessageBox::No) == QMessageBox::No)
{
checkBox->setCheckState(Qt::Unchecked);
return;
}
op = *it; // Make a copy
@ -1736,3 +1717,25 @@ void GridAccount::OnCtrlR(void)
rows.push_back(row);
}
}
void GridAccount::OnSuppr(void)
{
QModelIndexList selected = selectedIndexes();
std::vector<int> rows;
std::vector<int>::iterator it;
int 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())
continue;
OnDeleteClicked(_displayedOperations[row].id);
rows.push_back(row);
}
}

View File

@ -43,7 +43,7 @@ class GridAccount : public QTableWidget
public:
class OperationNotFound {};
enum {TREE, DESCRIPTION, OP_DATE, DEBIT, CREDIT, CATEGORY, TAG, ACCOUNT, OP_DELETE, CHECKED, NUMBER_COLS_OPS};
enum {TREE, DESCRIPTION, OP_DATE, DEBIT, CREDIT, CATEGORY, TAG, ACCOUNT, CHECKED, NUMBER_COLS_OPS};
GridAccount(KissCount* kiss, KissPanel *parent,
bool canAddOperation, bool setWeek, bool synchronizeWithDatabase);
@ -73,6 +73,7 @@ private slots:
void OnDeleteClicked(int id);
void OnCtrlT(void);
void OnCtrlR(void);
void OnSuppr(void);
private:
KissPanel* _parent;
@ -89,7 +90,7 @@ private:
bool _inModification;
QCompleter* _completer;
int _transfertCompletionIndex;
QShortcut* _ctrlT, *_ctrlR;
QShortcut* _ctrlT, *_ctrlR, *_suppr;
void SetWeek(int week, int line);
void ResetWeeks();