00001 /* 00002 * $Id$ 00003 * Kockpit - an Qt application for user/group management on unix based systems. 00004 * 00005 * Copyright (C) 2010 Julian Thome 00006 * 00007 * This program is free software; you can redistribute it and/or modify it under the terms of 00008 * the GNU General Public License as published by the Free Software Foundation; 00009 * either version 3 of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00012 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 * See the GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along with this program; 00016 * if not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 #ifndef KOCKPITVALIDATOR_H 00019 #define KOCKPITVALIDATOR_H 00020 00021 #include <QString> 00022 #include <QStringList> 00023 #include <QVariant> 00024 #include <QObject> 00025 00027 00030 typedef enum { 00031 SCRIPT_AUTOFILL, 00032 SCRIPT_VALIDATE, 00033 SCRIPT_AUTOBUILD 00034 } scriptmode; 00035 00037 00040 typedef enum { 00041 VALIDATION_OK = 0, 00042 VALIDATION_FAILED = 1, 00043 VALIDATION_RESULTS 00044 } validationResult; 00045 00047 00050 typedef struct { 00051 QString item; 00052 QString errmsg; 00053 validationResult errcode; 00054 } KockpitValidationObj; 00055 00057 00060 class KockpitValidator: public QObject { 00061 00062 Q_OBJECT 00063 00064 public: 00066 00069 KockpitValidator(QObject *parent = 0); 00070 00072 virtual ~KockpitValidator(){ } 00073 00075 00082 Q_INVOKABLE void appendValidationObj(const QString &item, const QString &errmsg, int errcode); 00083 00085 00090 void computeErrState(QStringList *result = NULL); 00091 00093 00096 void clear(); 00097 00099 00103 validationResult getErrState() const; 00104 00106 00111 friend std::ostream& operator <<(std::ostream& output, const KockpitValidator& validator); 00112 00113 private: 00114 00116 QList<KockpitValidationObj> vallist; 00118 validationResult errstate; 00119 }; 00120 00121 Q_DECLARE_METATYPE(KockpitValidator*) 00122 #endif //KOCKPITVALIDATOR_H