File indexing completed on 2024-05-05 17:18:51
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 SKGQUERYCREATOR_H 0007 #define SKGQUERYCREATOR_H 0008 /** @file 0009 * A query creator for skrooge. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 #include <qwidget.h> 0014 0015 #include "skgbankgui_export.h" 0016 #include "ui_skgquerycreator.h" 0017 0018 class SKGDocument; 0019 0020 0021 /** 0022 * This file is a query creator for skrooge 0023 */ 0024 class SKGBANKGUI_EXPORT SKGQueryCreator : public QWidget 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 /** 0030 * Default Constructor 0031 * @param iParent the parent 0032 */ 0033 explicit SKGQueryCreator(QWidget* iParent); 0034 0035 /** 0036 * Default Destructor 0037 */ 0038 ~SKGQueryCreator() override; 0039 0040 /** 0041 * Set parameters 0042 * @param iDocument the document 0043 * @param iTable the table 0044 * @param iListAttribute the list of attribute (empty means all attributes supported of the table) 0045 * @param iModeUpdate to enable update mode 0046 */ 0047 void setParameters(SKGDocument* iDocument, const QString& iTable, const QStringList& iListAttribute = QStringList(), bool iModeUpdate = false); 0048 0049 /** 0050 * Set XML representing the query 0051 * @param iXML the XML representing the query 0052 */ 0053 void setXMLCondition(const QString& iXML); 0054 0055 /** 0056 * Get XML representing the query 0057 * @return the XML representing the query 0058 */ 0059 QString getXMLCondition(); 0060 0061 /** 0062 * Get the number of line 0063 * @return the number of line 0064 */ 0065 int getLinesCount(); 0066 0067 /** 0068 * Get the number of line 0069 * @return the number of line 0070 */ 0071 int getColumnsCount(); 0072 0073 /** 0074 * Get the advanced search mode 0075 */ 0076 bool advancedSearchMode() const; 0077 0078 public Q_SLOTS: 0079 /** 0080 * Clear table content 0081 */ 0082 void clearContents(); 0083 0084 /** 0085 * Remove a line 0086 * @param iRow the index of the line (-1 for all) 0087 */ 0088 void removeLine(int iRow = -1); 0089 0090 /** 0091 * Remove a column 0092 * @param iColumn the index of the column 0093 */ 0094 void removeColumn(int iColumn); 0095 0096 /** 0097 * Add a new line 0098 */ 0099 void addNewLine(); 0100 0101 /** 0102 * Set/unset the advanced search mode 0103 * @param iAdvancedMode the mode 0104 */ 0105 void setAdvancedSearchMode(bool iAdvancedMode) const; 0106 0107 /** 0108 * Switch the advanced search mode 0109 */ 0110 void switchAdvancedSearchMode() const; 0111 0112 Q_SIGNALS: 0113 /** 0114 * Emitted when the search is triggered 0115 */ 0116 void search(); 0117 0118 private Q_SLOTS: 0119 void onCloseEditor(); 0120 void onAddColumn(); 0121 void onAddText(); 0122 void onTextFilterChanged(const QString& iFilter); 0123 0124 private: 0125 Q_DISABLE_COPY(SKGQueryCreator) 0126 0127 int getIndexQueryColumn(const QString& iAttribute, int row = -1); 0128 void addColumnFromAttribut(const QListWidgetItem* iListItem); 0129 void resizeColumns(); 0130 0131 Ui::skgquerycreator_base ui{}; 0132 SKGDocument* m_document; 0133 QString m_table; 0134 bool m_updateMode; 0135 QStringList m_attributes; 0136 }; 0137 0138 #endif // SKGQUERYCREATOR_H