File indexing completed on 2024-05-05 05:00:09
0001 /* 0002 SPDX-FileCopyrightText: 2002 to whoever created and edited this file before 0003 SPDX-FileCopyrightText: 2002 Leo Savernik <l.savernik@aon.at> 0004 Generalizing the policy dialog 0005 0006 */ 0007 0008 #ifndef _POLICYDLG_H 0009 #define _POLICYDLG_H 0010 0011 #include <QDialog> 0012 #include <QLineEdit> 0013 #include <QStringList> 0014 0015 class QLabel; 0016 class QComboBox; 0017 class QString; 0018 class QVBoxLayout; 0019 class QPushButton; 0020 0021 class Policies; 0022 0023 /** 0024 * A dialog for editing domain-specific policies. 0025 * 0026 * Each dialog must be associated with a relevant Policies instance which 0027 * will be updated within this dialog appropriately. 0028 * 0029 * Additionally you can insert your own widget containing controls for 0030 * specific policies with addPolicyPanel. 0031 * 0032 * @author unknown 0033 */ 0034 class PolicyDialog : public QDialog 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 /** 0040 * Enumerates the possible return values for the "feature enabled" 0041 * policy 0042 */ 0043 enum FeatureEnabledPolicy { InheritGlobal = 0, Accept, Reject }; 0044 0045 /** constructor 0046 * @param policies policies object this dialog will write the settings 0047 * into. Note that it always reflects the current settings, 0048 * even if the dialog has been canceled. 0049 * @param parent parent widget this belongs to 0050 * @param name internal name 0051 */ 0052 explicit PolicyDialog(Policies *policies, QWidget *parent = nullptr, const char *name = nullptr); 0053 0054 ~PolicyDialog() override {} 0055 0056 /* 0057 * @return whether this feature should be activated, deactivated or 0058 * inherited from the respective global policy. 0059 */ 0060 FeatureEnabledPolicy featureEnabledPolicy() const; 0061 0062 /** 0063 * @return the textual representation of the current "feature enabled" 0064 * policy 0065 */ 0066 QString featureEnabledPolicyText() const; 0067 0068 /* 0069 * @return the hostname for which the policy is being set 0070 */ 0071 QString domain() const 0072 { 0073 return le_domain->text(); 0074 } 0075 0076 /* 0077 * Sets the line-edit to be enabled/disabled. 0078 * 0079 * This method will set the text in the lineedit if the 0080 * value is not null. 0081 * 0082 * @param state @p true to enable the line-edit, otherwise disabled. 0083 * @param text the text to be set in the line-edit. Default is NULL. 0084 */ 0085 void setDisableEdit(bool /*state*/, const QString &text = QString()); 0086 0087 /** 0088 * Sets the label for the "feature enabled" policy 0089 * @param text label text 0090 */ 0091 void setFeatureEnabledLabel(const QString &text); 0092 0093 /** 0094 * Sets the "What's This" text for the "feature enabled" policy 0095 * combo box. 0096 * @param text what's-this text 0097 */ 0098 void setFeatureEnabledWhatsThis(const QString &text); 0099 0100 /** 0101 * Syncs the controls with the current content of the 0102 * associated policies object. 0103 */ 0104 void refresh(); 0105 0106 /** 0107 * Adds another panel which contains controls for more policies. 0108 * 0109 * The widget is inserted between the "feature enabled" combo box and 0110 * the dialog buttons at the bottom. 0111 * 0112 * Currently at most one widget can be added. 0113 * @param panel pointer to widget to insert. The dialog takes ownership 0114 * of it, but does not reparent it. 0115 */ 0116 void addPolicyPanel(QWidget *panel); 0117 0118 protected Q_SLOTS: 0119 0120 void accept() override; 0121 void slotTextChanged(const QString &text); 0122 0123 private: 0124 Policies *policies; 0125 QVBoxLayout *topl; 0126 int insertIdx; 0127 QLineEdit *le_domain; 0128 QLabel *l_feature_policy; 0129 QComboBox *cb_feature_policy; 0130 QWidget *panel; 0131 QStringList policy_values; 0132 QPushButton *okButton; 0133 }; 0134 0135 #endif