File indexing completed on 2024-05-12 16:43:52
0001 /* 0002 SPDX-FileCopyrightText: 2015 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef LEDGERVIEW_H 0007 #define LEDGERVIEW_H 0008 0009 // ---------------------------------------------------------------------------- 0010 // QT Includes 0011 0012 #include <QTableView> 0013 0014 // ---------------------------------------------------------------------------- 0015 // KDE Includes 0016 0017 // ---------------------------------------------------------------------------- 0018 // Project Includes 0019 0020 class MyMoneyAccount; 0021 0022 class LedgerView : public QTableView 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit LedgerView(QWidget* parent = 0); 0027 virtual ~LedgerView(); 0028 0029 virtual void setAccount(const MyMoneyAccount& acc); 0030 virtual QString accountId() const; 0031 0032 /** 0033 * This method is used to modify the visibility of the 0034 * empty entry at the end of the ledger. The default 0035 * for the parameter @a show is @c true. 0036 */ 0037 void setShowEntryForNewTransaction(bool show = true); 0038 0039 /** 0040 * Returns true if the sign of the values displayed has 0041 * been inverted depending on the account type. 0042 */ 0043 bool showValuesInverted() const; 0044 0045 public Q_SLOTS: 0046 /** 0047 * This method scrolls the ledger so that the current item is visible 0048 */ 0049 void ensureCurrentItemIsVisible(); 0050 0051 /** 0052 * Overridden for internal reasons. No change in base functionality 0053 */ 0054 void edit(const QModelIndex& index) { 0055 QTableView::edit(index); 0056 } 0057 0058 protected: 0059 bool edit(const QModelIndex& index, EditTrigger trigger, QEvent* event) final override; 0060 void mousePressEvent(QMouseEvent* event) final override; 0061 void mouseMoveEvent(QMouseEvent* event) final override; 0062 void mouseDoubleClickEvent(QMouseEvent* event) final override; 0063 void wheelEvent(QWheelEvent *event) final override; 0064 void moveEvent(QMoveEvent *event) final override; 0065 void resizeEvent(QResizeEvent* event) final override; 0066 void paintEvent(QPaintEvent* event) final override; 0067 int sizeHintForRow(int row) const final override; 0068 0069 protected Q_SLOTS: 0070 void closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint) final override; 0071 void rowsInserted(const QModelIndex& index, int start, int end) final override; 0072 void rowsAboutToBeRemoved(const QModelIndex& index, int start, int end) final override; 0073 void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) final override; 0074 0075 virtual void adjustDetailColumn(int newViewportWidth); 0076 virtual void adjustDetailColumn(); 0077 0078 virtual void recalculateBalances(); 0079 0080 virtual void accountChanged(); 0081 0082 Q_SIGNALS: 0083 void transactionSelected(const QString& transactionSplitId); 0084 void aboutToStartEdit(); 0085 void aboutToFinishEdit(); 0086 0087 protected: 0088 class Private; 0089 Private * const d; 0090 }; 0091 0092 class SplitView : public LedgerView 0093 { 0094 Q_OBJECT 0095 public: 0096 explicit SplitView(QWidget* parent = 0); 0097 virtual ~SplitView(); 0098 0099 protected Q_SLOTS: 0100 void recalculateBalances() final override {} 0101 }; 0102 #endif // LEDGERVIEW_H 0103