File indexing completed on 2024-05-12 05:07:55
0001 /* 0002 SPDX-FileCopyrightText: 2004-2020 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KMYMONEYACCOUNTCOMBO_H 0008 #define KMYMONEYACCOUNTCOMBO_H 0009 0010 #include "kmm_base_widgets_export.h" 0011 0012 // ---------------------------------------------------------------------------- 0013 // QT Includes 0014 0015 class QTreeView; 0016 0017 // ---------------------------------------------------------------------------- 0018 // KDE Includes 0019 0020 #include <KComboBox> 0021 0022 // ---------------------------------------------------------------------------- 0023 // Project Includes 0024 0025 #include "accountsproxymodel.h" 0026 #include "onlinebankingaccountsfilterproxymodel.h" 0027 0028 /** 0029 * @brief OnlineBankingAccountFilterProxyModel showing only the name column 0030 * 0031 * Is equivalent to AccountNamesFilterProxyModel using OnlineBankingAccountFilterProxyModel as base. 0032 */ 0033 typedef AccountNamesFilterProxyModelTpl<OnlineBankingAccountsFilterProxyModel> OnlineBankingAccountNamesFilterProxyModel; 0034 0035 0036 /** 0037 * @brief A general account selection widget based on a KComboBox 0038 * 0039 * This widget allows to select an account from the provided set of accounts. This 0040 * set is passed as model in the constructor or via setModel(). In case the widget 0041 * is configured to be editable via setEditable() the combo box contains a lineedit 0042 * widget. This lineedit provides auto completion. 0043 * 0044 * In addition to the KComboBox which supports a list view popup, this widget 0045 * provides a tree view popup to show the account hierarchy. 0046 * 0047 * @author Cristian Onet 0048 */ 0049 class KMM_BASE_WIDGETS_EXPORT KMyMoneyAccountCombo : public KComboBox 0050 { 0051 Q_OBJECT 0052 Q_DISABLE_COPY(KMyMoneyAccountCombo) 0053 0054 public: 0055 explicit KMyMoneyAccountCombo(QSortFilterProxyModel *model, QWidget* parent = nullptr); 0056 explicit KMyMoneyAccountCombo(QWidget* parent = nullptr); 0057 ~KMyMoneyAccountCombo(); 0058 0059 const QString& getSelected() const; 0060 0061 /** 0062 * Clears the cache of the last selected account 0063 */ 0064 void clearSelection(); 0065 0066 void setModel(QSortFilterProxyModel *model); 0067 0068 /** 0069 * Overridden to get specific behavior 0070 */ 0071 void setEditable(bool isEditable); 0072 0073 bool eventFilter(QObject* o, QEvent* e) override; 0074 0075 QTreeView* popup() const; 0076 0077 public Q_SLOTS: 0078 void expandAll(); 0079 void collapseAll(); 0080 void showPopup() override; 0081 void hidePopup() override; 0082 void setSelected(const QString& id); 0083 void setSplitActionVisible(bool show); 0084 0085 protected: 0086 void wheelEvent(QWheelEvent *ev) override; 0087 0088 protected Q_SLOTS: 0089 void activated(); 0090 void makeCompletion(const QString& txt) override; 0091 void selectItem(const QModelIndex& index); 0092 0093 Q_SIGNALS: 0094 void accountSelected(const QString&); 0095 void splitDialogRequest(); 0096 0097 private: 0098 void init(); 0099 0100 private: 0101 class Private; 0102 QScopedPointer<Private> const d; 0103 }; 0104 0105 0106 0107 class QAbstractButton; 0108 class KMyMoneyAccountComboSplitHelperPrivate; 0109 class KMM_BASE_WIDGETS_EXPORT KMyMoneyAccountComboSplitHelper : public QObject 0110 { 0111 Q_OBJECT 0112 Q_DISABLE_COPY(KMyMoneyAccountComboSplitHelper) 0113 0114 public: 0115 explicit KMyMoneyAccountComboSplitHelper(QComboBox* accountCombo, QAbstractItemModel *model); 0116 ~KMyMoneyAccountComboSplitHelper(); 0117 0118 public Q_SLOTS: 0119 void updateWidget(); 0120 0121 protected: 0122 bool eventFilter(QObject *watched, QEvent *event) override; 0123 0124 private Q_SLOTS: 0125 void modelDestroyed(); 0126 0127 Q_SIGNALS: 0128 void accountComboEnabled(bool enabled); 0129 void accountComboDisabled(bool disabled); 0130 0131 private: 0132 Q_DECLARE_PRIVATE(KMyMoneyAccountComboSplitHelper); 0133 QScopedPointer<KMyMoneyAccountComboSplitHelperPrivate> d_ptr; 0134 }; 0135 0136 0137 #endif 0138 // kate: space-indent on; indent-width 2; remove-trailing-space on; remove-trailing-space-save on;