Remove delete column (replaced by Suppr shortcut)

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

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();