android: Fix XML form filter.
[qpwmc.git] / applicationForm.h
blobaa7f6a8e7c93410c285b3d8dd4724863120ee227
1 /*
2 Copyright (C) 2013-2023 Ben Kibbey <bjk@luxsci.net>
4 This file is part of qpwmc.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
21 #ifndef APPLICATIONFORM_H
22 #define APPLICATIONFORM_H
24 #include <QWizard>
25 #include "applicationFormFinalizePage.h"
26 #include "pwmdTreeWidget.h"
27 #include "applicationFormWidget.h"
29 #include "ui_applicationForm.h"
31 class PwmdMainWindow;
32 class ApplicationFormXmlStream;
33 class ApplicationFormWidget;
34 class ApplicationForm : public QWizard
36 Q_OBJECT
37 public:
38 ApplicationForm (const QString &filename);
39 ApplicationForm (Pwmd * = 0, const QString &filename = 0,
40 PwmdTreeWidget * = 0, PwmdMainWindow * = 0);
41 ApplicationForm (const QString &filename, QString, QString, QString);
42 ~ApplicationForm ();
43 bool hasError ();
44 void setHasError (bool = true);
45 bool modified ();
46 QString socket ();
47 QString filename ();
48 QString elementPath ();
50 public slots:
51 void slotRadioButtonClicked (bool);
52 void slotPageChanged (int);
54 signals:
55 void knownHostRc (gpg_error_t);
57 private slots:
58 void slotCancel (bool);
59 void slotChangeExpiry ();
60 void slotAccepted ();
61 void slotElementSelector ();
62 void slotDateSelector (const QDate &);
63 void slotSocketSelector ();
64 void slotFormElementSelected (QTreeWidgetItem *, QTreeWidgetItem *);
65 void slotKnownHostCallback (void *data, const char *host, const char *key,
66 size_t len);
68 private:
69 QString buildElementPath (QString path, QString element, bool &);
70 void updateForm (QString, QString, QString);
71 void doForm (const QString &);
72 void addFormRow (QFormLayout *fl, QHBoxLayout *hb, ApplicationFormWidget *w,
73 QWizardPage *wp, bool withLabel);
74 void addExpiry (ApplicationFormWidget *w, QHBoxLayout *hb);
75 void keyPressEvent (QKeyEvent *);
76 void setModified ();
78 friend class ApplicationFormXmlStream;
79 friend class ApplicationFormFinalizePage;
80 ApplicationFormFinalizePage *finalPage;
81 Ui::ApplicationForm ui;
82 ApplicationFormXmlStream *stream;
83 PwmdMainWindow *parent;
84 PwmdTreeWidget *elementTree;
85 bool _error;
86 Pwmd *pwm;
87 QList<QObject *> widgetsToDelete;
88 QRegularExpressionValidator *lineEditValidator;
89 QString _socket;
90 QString _dataFilename;
91 QString _elementPath;
92 bool _modified;
95 class ApplicationElement
97 public:
98 ApplicationElement (QString path, bool hidden)
100 _isHidden = hidden;
101 _path = path;
104 bool isHidden ()
106 return _isHidden;
109 QString path ()
111 return _path;
114 QString pathNoContent ()
116 QString s = _path;
118 if (s.endsWith ("\t"))
120 s.chop (1);
121 return s;
124 int n = _path.lastIndexOf ("\t");
125 if (n != -1)
126 return _path.left (n);
128 return _path;
131 void setAttrs (QList<ApplicationFormAttr *> a)
133 _attrs = a;
136 QList<ApplicationFormAttr *> attrs ()
138 return _attrs;
141 private:
142 bool _isHidden;
143 QString _path;
144 QList<ApplicationFormAttr *> _attrs;
147 #endif