File indexing completed on 2024-05-12 05:09:47
0001 /*************************************************************************** 0002 Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #ifndef FILTERRULEWIDGET_H 0026 #define FILTERRULEWIDGET_H 0027 0028 #include <QWidget> 0029 0030 #include "../datavectors.h" 0031 0032 class KComboBox; 0033 class KLineEdit; 0034 class KDateComboBox; 0035 0036 class QRadioButton; 0037 class QDialog; 0038 class QStackedWidget; 0039 class QLineEdit; 0040 class QPushButton; 0041 0042 namespace Tellico { 0043 namespace GUI { 0044 class ComboBox; 0045 } 0046 class FilterDialog; 0047 0048 /** 0049 * A widget to edit a single FilterRule. 0050 * It consists of a read-only @ref KComboBox for the field, 0051 * a read-only @ref KComboBox for the function and 0052 * a @ref KLineEdit for the content or the pattern (in case of regexps). 0053 * 0054 * This class borrows heavily from KMSearchRule in kmail by Marc Mutz 0055 * 0056 * @author Robby Stephenson 0057 */ 0058 class FilterRuleWidget : public QWidget { 0059 Q_OBJECT 0060 0061 public: 0062 /** 0063 * Constructor. You give a @ref FilterRule as parameter, which will 0064 * be used to initialize the widget. 0065 */ 0066 FilterRuleWidget(FilterRule* rule, QWidget* parent); 0067 0068 /** 0069 * Set the rule. The rule is accepted regardless of the return 0070 * value of @ref FilterRule::isEmpty. This widget makes a shallow 0071 * copy of @p rule and operates directly on it. If @p rule is 0072 * 0, the widget resets itself, takes user input, but does essentially 0073 * nothing. If you pass 0, you should probably disable it. 0074 */ 0075 void setRule(const FilterRule* rule); 0076 /** 0077 * Return a reference to the currently worked-on @ref FilterRule. 0078 */ 0079 FilterRule* rule() const; 0080 /** 0081 * Resets the rule currently worked on and updates the widget accordingly. 0082 */ 0083 void reset(); 0084 0085 Q_SIGNALS: 0086 void signalModified(); 0087 0088 public Q_SLOTS: 0089 void setFocus(); 0090 0091 protected Q_SLOTS: 0092 void slotRuleFieldChanged(int which); 0093 void slotRuleFunctionChanged(int which); 0094 0095 private: 0096 static QString anyFieldString(); 0097 void initLists(); 0098 void initWidget(); 0099 void updateFunctionList(); 0100 0101 KComboBox* m_ruleField; 0102 GUI::ComboBox* m_ruleFunc; 0103 QStackedWidget* m_valueStack; 0104 KLineEdit* m_ruleValue; 0105 KDateComboBox* m_ruleDate; 0106 QStringList m_ruleFieldList; 0107 enum RuleType { 0108 General, 0109 Date, 0110 Number, 0111 Image, 0112 Bool 0113 }; 0114 RuleType m_ruleType; 0115 }; 0116 0117 } // end namespace 0118 #endif