From fa9f7497f546e4a92aa601c93156c5c8068e012f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 1 Nov 2018 10:58:16 +0100 Subject: [PATCH] Remove delete column (replaced by Suppr shortcut) --- ChangeLog | 3 +- src/view/AccountPanel.cpp | 4 +-- src/view/CostRepartitionBanner.cpp | 21 +----------- src/view/grid/GridAccount.cpp | 53 ++++++++++++++++-------------- src/view/grid/GridAccount.hpp | 5 +-- 5 files changed, 36 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ed3f52..0fc272d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index 7b45bc4..5fabb5d 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -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(); diff --git a/src/view/CostRepartitionBanner.cpp b/src/view/CostRepartitionBanner.cpp index de490db..a39193c 100644 --- a/src/view/CostRepartitionBanner.cpp +++ b/src/view/CostRepartitionBanner.cpp @@ -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() diff --git a/src/view/grid/GridAccount.cpp b/src/view/grid/GridAccount.cpp index 96098bf..4b0fc2c 100644 --- a/src/view/grid/GridAccount.cpp +++ b/src/view/grid/GridAccount.cpp @@ -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* 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 (GetCenteredWidget(line, CHECKED)); if (checkBox) checkBox->disconnect(&_checkSignalMapper, SLOT(map())); - checkBox = qobject_cast (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 (_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 rows; + std::vector::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); + } +} diff --git a/src/view/grid/GridAccount.hpp b/src/view/grid/GridAccount.hpp index 9c97807..93d874c 100644 --- a/src/view/grid/GridAccount.hpp +++ b/src/view/grid/GridAccount.hpp @@ -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();