File indexing completed on 2024-05-12 05:07:46
0001 /* 0002 SPDX-FileCopyrightText: 2015-2020 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef LEDGERVIEWPAGE_H 0007 #define LEDGERVIEWPAGE_H 0008 0009 // ---------------------------------------------------------------------------- 0010 // QT Includes 0011 0012 #include <QWidget> 0013 0014 // ---------------------------------------------------------------------------- 0015 // KDE Includes 0016 0017 // ---------------------------------------------------------------------------- 0018 // Project Includes 0019 0020 namespace eMenu { 0021 enum class Menu; 0022 enum class Action; 0023 } 0024 0025 class MyMoneyAccount; 0026 class SelectedObjects; 0027 struct AccountBalances; 0028 0029 class LedgerViewPage : public QWidget 0030 { 0031 Q_OBJECT 0032 protected: 0033 class Private; 0034 Private* d; 0035 0036 public: 0037 explicit LedgerViewPage(QWidget* parent = 0, const QString& configGroupName = QString()); 0038 virtual ~LedgerViewPage(); 0039 0040 virtual void setAccount(const MyMoneyAccount& id); 0041 virtual QString accountId() const; 0042 0043 /** 0044 * This method is used to modify the visibility of the 0045 * empty entry at the end of the ledger. The default 0046 * for the parameter @a show is @c true. 0047 */ 0048 void setShowEntryForNewTransaction(bool show = true); 0049 0050 void selectJournalEntry(const QString& id); 0051 0052 const SelectedObjects& selections() const; 0053 0054 /** 0055 * Execute the @a action based on the selected objects found in @a selections. 0056 * 0057 * @retval true in case operation succeeded 0058 * @retval false in case operation was aborted or failed 0059 */ 0060 virtual bool executeAction(eMenu::Action action, const SelectedObjects& selections); 0061 0062 void pushView(LedgerViewPage* view); 0063 LedgerViewPage* popView(); 0064 bool hasPushedView() const; 0065 0066 QString accountName(); 0067 0068 QList<int> splitterSizes() const; 0069 void setSplitterSizes(QList<int> sizes); 0070 0071 /** 0072 * Initialize the model for the view if called 0073 * for the first time. Successive calls don't 0074 * have an effect. 0075 * 0076 * @sa showEvent() 0077 */ 0078 void prepareToShow(); 0079 0080 protected: 0081 explicit LedgerViewPage(Private& dd, QWidget* parent = nullptr, const QString& configGroupName = QString()); 0082 void showEvent(QShowEvent* event) override; 0083 void initModel(); 0084 0085 public Q_SLOTS: 0086 void showTransactionForm(bool show); 0087 void splitterChanged(int pos, int index); 0088 void slotSettingsChanged(); 0089 virtual void updateSummaryInformation(const QHash<QString, AccountBalances>& balances); 0090 0091 protected Q_SLOTS: 0092 void startEdit(); 0093 void finishEdit(); 0094 void keepSelection(); 0095 void reloadFilter(); 0096 void slotRequestSelectionChanged(const SelectedObjects& selections) const; 0097 0098 Q_SIGNALS: 0099 void requestSelectionChanged(const SelectedObjects& selection); 0100 void requestCustomContextMenu(eMenu::Menu type, const QPoint& pos); 0101 0102 void transactionSelected(const QModelIndex& idx); 0103 void aboutToStartEdit(); 0104 void aboutToFinishEdit(); 0105 0106 void resizeSection(QWidget* view, const QString& configGroupName, int section, int oldSize, int newSize); 0107 void sectionResized(QWidget* view, const QString& configGroupName, int section, int oldSize, int newSize); 0108 void moveSection(QWidget* view, int section, int oldIndex, int newIndex); 0109 void sectionMoved(QWidget* view, int section, int oldIndex, int newIndex); 0110 0111 void requestView(QWidget* viewWidget, const QString& accountId, const QString& journalEntryId); 0112 }; 0113 0114 #endif // LEDGERVIEWPAGE_H 0115