File indexing completed on 2024-06-16 04:47:29
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 #ifndef SKGSPLITTABLEDELEGATE_H 0007 #define SKGSPLITTABLEDELEGATE_H 0008 /** @file 0009 * This file is Skrooge plugin for bank management. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 0014 #include <qitemdelegate.h> 0015 0016 class SKGDocument; 0017 class SKGTableWidget; 0018 0019 /** 0020 * This file is Skrooge plugin for transaction management 0021 */ 0022 class SKGSplitTableDelegate : public QItemDelegate 0023 { 0024 Q_OBJECT 0025 public: 0026 /** 0027 * Default Constructor 0028 * @param iParent parent widget 0029 * @param iDoc the document 0030 * @param iListAttribut the list of corresponding attribute 0031 */ 0032 explicit SKGSplitTableDelegate(QObject* iParent, SKGDocument* iDoc, QStringList iListAttribut = QStringList()); 0033 0034 /** 0035 * Default Destructor 0036 */ 0037 ~SKGSplitTableDelegate() override; 0038 0039 /** 0040 * Returns the widget used to edit the item specified by index for editing. 0041 * The parent widget and style option are used to control how the editor widget appears. 0042 * @param iParent parent widget 0043 * @param option options 0044 * @param index index 0045 * @return the widget 0046 */ 0047 QWidget* createEditor(QWidget* iParent, 0048 const QStyleOptionViewItem& option, 0049 const QModelIndex& index) const override; 0050 0051 /** 0052 * Set the data to be shown in the delegate. For the quantity column, 0053 * We pass the text value. This allows the user to correct an invalid 0054 * expression without having to retype everything. 0055 * @param editor 0056 * @param index 0057 */ 0058 void setEditorData(QWidget* editor, const QModelIndex& index) const override; 0059 0060 /** 0061 * Get the data to be shown in the model. For the quantity column, 0062 * We pass the text value. If the entered expression was incorrect, 0063 * we display it in red so that the user can see it is wrong and 0064 * correct it 0065 * @param editor 0066 * @param model 0067 * @param index 0068 */ 0069 void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; 0070 0071 /** 0072 * Add a parameter 0073 * @param iParameter the parameter name 0074 * @param iValue the value 0075 */ 0076 virtual void addParameterValue(const QString& iParameter, double iValue); 0077 0078 private: 0079 Q_DISABLE_COPY(SKGSplitTableDelegate) 0080 0081 SKGDocument* m_document; 0082 QMap<QString, double> m_parameters; 0083 QStringList m_listAttributes; 0084 SKGTableWidget* m_table; 0085 }; 0086 0087 #endif // SKGSPLITTABLEDELEGATE_H