File indexing completed on 2024-05-12 05:06:15
0001 /* 0002 SPDX-FileCopyrightText: 2019 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef ITEMRENAMEPROXYMODEL_H 0007 #define ITEMRENAMEPROXYMODEL_H 0008 0009 #include "kmm_models_export.h" 0010 0011 // ---------------------------------------------------------------------------- 0012 // QT Includes 0013 0014 #include <QSortFilterProxyModel> 0015 0016 // ---------------------------------------------------------------------------- 0017 // KDE Includes 0018 0019 // ---------------------------------------------------------------------------- 0020 // Project Includes 0021 0022 0023 /** 0024 * A proxy model to provide in view rename for an item . 0025 * 0026 * /// @todo update description 0027 * 0028 * Here is an example of how to use this class in combination with the @ref institutionsModel. 0029 * (in the example @a widget is a pointer to a model/view widget): 0030 * 0031 * @code 0032 * InstitutionsFilterProxyModel *filterModel = new InstitutionsFilterProxyModel(widget); 0033 * filterModel->setSourceModel(MyMoneyFile::instance()->institutionsModel()); 0034 * filterModel->sort(0); 0035 * 0036 * widget->setModel(filterModel); 0037 * @endcode 0038 * 0039 * @author Thomas Baumgart 0040 * 0041 */ 0042 0043 class KMM_MODELS_EXPORT ItemRenameProxyModel : public QSortFilterProxyModel 0044 { 0045 Q_OBJECT 0046 Q_DISABLE_COPY(ItemRenameProxyModel) 0047 0048 public: 0049 typedef enum { 0050 eAllItem = 0, 0051 eReferencedItems, 0052 eUnReferencedItems, 0053 eOpenedItems, 0054 eClosedItems, 0055 // insert new values above this line 0056 eMaxItems, 0057 } ReferenceFilterType; 0058 0059 explicit ItemRenameProxyModel(QObject *parent = nullptr); 0060 virtual ~ItemRenameProxyModel(); 0061 0062 bool setData(const QModelIndex& idx, const QVariant& value, int role) override; 0063 0064 Qt::ItemFlags flags(const QModelIndex& idx) const override; 0065 void setRenameColumn(int column); 0066 0067 void setReferenceFilter(ReferenceFilterType filterType); 0068 void setReferenceFilter(const QVariant& filterType); 0069 0070 ReferenceFilterType referenceFilter() const; 0071 0072 protected: 0073 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0074 0075 Q_SIGNALS: 0076 void renameItem(const QModelIndex& idx, const QVariant& value); 0077 0078 private: 0079 int m_renameColumn; 0080 ReferenceFilterType m_referenceFilter; 0081 }; 0082 0083 #endif