File indexing completed on 2024-05-19 05:08:28
0001 /* 0002 SPDX-FileCopyrightText: 2019-2020 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef SPLITVIEW_H 0007 #define SPLITVIEW_H 0008 0009 // ---------------------------------------------------------------------------- 0010 // QT Includes 0011 0012 #include <QTableView> 0013 #include <QVector> 0014 0015 // ---------------------------------------------------------------------------- 0016 // KDE Includes 0017 0018 // ---------------------------------------------------------------------------- 0019 // Project Includes 0020 0021 #include "mymoneyenums.h" 0022 0023 class MyMoneyAccount; 0024 class MyMoneyMoney; 0025 class MyMoneySecurity; 0026 0027 class SplitView : public QTableView 0028 { 0029 Q_OBJECT 0030 public: 0031 explicit SplitView(QWidget* parent = 0); 0032 virtual ~SplitView(); 0033 0034 /** 0035 * This method is used to modify the visibility of the 0036 * empty entry at the end of the ledger. The default 0037 * for the parameter @a show is @c true. 0038 */ 0039 void setShowEntryForNewTransaction(bool show = true); 0040 0041 void setSingleLineDetailRole(eMyMoney::Model::Roles role); 0042 0043 /** 0044 * Returns true if the sign of the values displayed has 0045 * been inverted depending on the account type. 0046 */ 0047 bool showValuesInverted() const; 0048 0049 void setColumnsHidden(QVector<int> columns); 0050 void setColumnsShown(QVector<int> columns); 0051 0052 void setModel(QAbstractItemModel * model) override; 0053 0054 void setCommodity(const MyMoneySecurity& commodity); 0055 0056 void selectMostRecentTransaction(); 0057 0058 void skipStartEditing(); 0059 void blockEditorStart(bool blocked); 0060 0061 void setTransactionPayeeId(const QString& id); 0062 0063 void setReadOnlyMode(bool readOnly); 0064 0065 void setTotalTransactionValue(const MyMoneyMoney& transactionValue); 0066 0067 public Q_SLOTS: 0068 /** 0069 * This method scrolls the ledger so that the current item is visible 0070 */ 0071 void ensureCurrentItemIsVisible(); 0072 0073 /** 0074 * Overridden for internal reasons. No change in base functionality 0075 */ 0076 void edit(const QModelIndex& index) { 0077 QTableView::edit(index); 0078 } 0079 0080 void slotSettingsChanged(); 0081 0082 protected: 0083 bool edit(const QModelIndex& index, EditTrigger trigger, QEvent* event) final override; 0084 void mousePressEvent(QMouseEvent* event) final override; 0085 void mouseMoveEvent(QMouseEvent* event) final override; 0086 void mouseDoubleClickEvent(QMouseEvent* event) final override; 0087 void wheelEvent(QWheelEvent *event) final override; 0088 void moveEvent(QMoveEvent *event) final override; 0089 void resizeEvent(QResizeEvent* event) final override; 0090 void paintEvent(QPaintEvent* event) final override; 0091 int sizeHintForRow(int row) const final override; 0092 int sizeHintForColumn(int row) const final override; 0093 /** 0094 * Overridden to prevent moving to the end using End or PageDown to start the editor 0095 */ 0096 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override; 0097 0098 protected Q_SLOTS: 0099 void closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint) final override; 0100 void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) final override; 0101 0102 virtual void adjustDetailColumn(int newViewportWidth); 0103 0104 Q_SIGNALS: 0105 void transactionSelected(const QModelIndex& idx); 0106 void aboutToStartEdit(); 0107 void aboutToFinishEdit(); 0108 void deleteSelectedSplits(); 0109 0110 protected: 0111 class Private; 0112 Private * const d; 0113 }; 0114 #endif // SPLITVIEW_H 0115