File indexing completed on 2024-05-12 16:43:51

0001 /*
0002     SPDX-FileCopyrightText: 2012 Alessandro Russo <axela74@yahoo.it>
0003     SPDX-FileCopyrightText: 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KTAGSVIEW_H
0008 #define KTAGSVIEW_H
0009 
0010 // ----------------------------------------------------------------------------
0011 // QT Includes
0012 
0013 // ----------------------------------------------------------------------------
0014 // KDE Includes
0015 
0016 // ----------------------------------------------------------------------------
0017 // Project Includes
0018 
0019 #include "kmymoneyviewbase.h"
0020 
0021 class QListWidgetItem;
0022 class KListWidgetSearchLine;
0023 class MyMoneyObject;
0024 class MyMoneyTag;
0025 
0026 template <typename T> class QList;
0027 
0028 /**
0029   * @author Alessandro Russo
0030   */
0031 
0032 class KTagsViewPrivate;
0033 class KTagsView : public KMyMoneyViewBase
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     explicit KTagsView(QWidget *parent = nullptr);
0039     ~KTagsView() override;
0040 
0041     void updateTagActions(const QList<MyMoneyTag>& tags);
0042     void executeCustomAction(eView::Action action) override;
0043 
0044 public Q_SLOTS:
0045     void slotSelectTagAndTransaction(const QString& tagId, const QString& accountId, const QString& transactionId);
0046     void slotSelectTagAndTransaction(const QString& tagId);
0047     void slotStartRename(QListWidgetItem*);
0048     void slotHelp();
0049 
0050     void refresh();
0051 
0052 protected:
0053     void showEvent(QShowEvent* event) override;
0054     void loadTags();
0055     void selectedTags(QList<MyMoneyTag>& tagsList) const;
0056     void ensureTagVisible(const QString& id);
0057     void clearItemData();
0058 
0059 protected Q_SLOTS:
0060     /**
0061       * This method loads the m_transactionList, clears
0062       * the m_TransactionPtrVector and rebuilds and sorts
0063       * it according to the current settings. Then it
0064       * loads the m_transactionView with the transaction data.
0065       */
0066     void showTransactions();
0067 
0068     /**
0069       * This slot is called whenever the selection in m_tagsList
0070       * is about to change.
0071       */
0072     void slotSelectTag(QListWidgetItem* cur, QListWidgetItem* prev);
0073 
0074     /**
0075       * This slot is called whenever the selection in m_tagsList
0076       * has been changed.
0077       */
0078     void slotSelectTag();
0079 
0080     /**
0081       * This slot marks the current selected tag as modified (dirty).
0082       */
0083     void slotTagDataChanged();
0084 
0085     /**
0086       * This slot is called when the name of a tag is changed inside
0087       * the tag list view and only a single tag is selected.
0088       */
0089     void slotRenameSingleTag(QListWidgetItem *ta);
0090 
0091     /**
0092       * Updates the tag data in m_tag from the information in the
0093       * tag information widget.
0094       */
0095     void slotUpdateTag();
0096 
0097     void slotSelectTransaction();
0098 
0099     void slotChangeFilter(int index);
0100 
0101 Q_SIGNALS:
0102     void transactionSelected(const QString& accountId, const QString& transactionId);
0103 
0104 private:
0105     Q_DISABLE_COPY(KTagsView)
0106     Q_DECLARE_PRIVATE(KTagsView)
0107 
0108 private Q_SLOTS:
0109     /**
0110       * This slot receives the signal from the listview control that an item was right-clicked,
0111       * If @p points to a real tag item, emits openContextMenu().
0112       *
0113       * @param p position of the pointer device
0114       */
0115     void slotShowTagsMenu(const QPoint& p);
0116 
0117     void slotSelectTags(const QList<MyMoneyTag>& list);
0118 
0119     void slotNewTag();
0120     void slotRenameTag();
0121     void slotDeleteTag();
0122 };
0123 
0124 #endif