File indexing completed on 2024-05-19 05:08:32

0001 /*
0002     SPDX-FileCopyrightText: 2010-2014 Cristian Oneț <onet.cristian@gmail.com>
0003     SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-FileCopyrightText: 2019 Thomas Baumgart <tbaumgart@kde.org>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef KMYMONEYACCOUNTTREEVIEW_H
0009 #define KMYMONEYACCOUNTTREEVIEW_H
0010 
0011 #include "kmm_base_widgets_export.h"
0012 
0013 // ----------------------------------------------------------------------------
0014 // QT Includes
0015 
0016 #include <QScopedPointer>
0017 
0018 // ----------------------------------------------------------------------------
0019 // KDE Includes
0020 
0021 // ----------------------------------------------------------------------------
0022 // Project Includes
0023 
0024 #include "kmymoneytreeview.h"
0025 
0026 class AccountsProxyModel;
0027 class KMyMoneyAccountTreeViewPrivate;
0028 class SelectedObjects;
0029 
0030 namespace eMenu {
0031 enum class Action;
0032 enum class Menu;
0033 }
0034 
0035 /**
0036   * This view was created to handle the actions that could be performed with the accounts.
0037   */
0038 class KMM_BASE_WIDGETS_EXPORT KMyMoneyAccountTreeView : public KMyMoneyTreeView
0039 {
0040     Q_OBJECT
0041     Q_DISABLE_COPY(KMyMoneyAccountTreeView)
0042 
0043 public:
0044     explicit KMyMoneyAccountTreeView(QWidget* parent = nullptr);
0045     ~KMyMoneyAccountTreeView();
0046 
0047     AccountsProxyModel* proxyModel() const;
0048 
0049     /**
0050      * This method attaches the @a model to the view while
0051      * inserting the @sa proxyModel() in between them.
0052      */
0053     void setModel(QAbstractItemModel* model) override;
0054 
0055     /**
0056      * This method replaces the existing proxy model with @a model.
0057      * @a model will be reparented to the this object.
0058      *
0059      * @note It is advisable to replace this soon after construction
0060      * and not during operation.
0061      */
0062     void setProxyModel(AccountsProxyModel* model);
0063 
0064 protected Q_SLOTS:
0065     void customContextMenuRequested(const QPoint);
0066     void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
0067 
0068 Q_SIGNALS:
0069     void requestSelectionChange(const SelectedObjects& selections);
0070     void requestCustomContextMenu(eMenu::Menu contextMenu, const QPoint& pos);
0071     void requestActionTrigger(eMenu::Action action);
0072 
0073 private:
0074     const QScopedPointer<KMyMoneyAccountTreeViewPrivate> d_ptr;
0075     Q_DECLARE_PRIVATE(KMyMoneyAccountTreeView)
0076 };
0077 
0078 #endif // KMYMONEYACCOUNTTREEVIEW_H