File indexing completed on 2024-04-28 04:48:05

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Gary Steinert <gary.steinert@gmail.com>                           *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef LOG_H
0018 #define LOG_H
0019 
0020 #include <QList>
0021 #include <QString>
0022 #include <QStringList>
0023 
0024 class LogEntry 
0025 {
0026 
0027   public:
0028     enum Type {
0029       information,
0030       error,
0031       warning,
0032       success,
0033       failure
0034     };
0035 
0036     enum PrintStyle {
0037       plainText,
0038       HTML
0039     };
0040 
0041     LogEntry( const QString &filename, const QString &message, Type type );
0042     ~LogEntry();
0043 
0044     QString getFilename() { return m_filename; }
0045     QString getMessage() { return m_message; }
0046     Type getType() { return m_type; }
0047 
0048   private:
0049     QString m_filename;
0050     QString m_message;
0051     Type m_type;
0052 
0053 };
0054 
0055 class Log: public QList<LogEntry>
0056 {
0057 
0058   public:
0059 
0060     class CopyHolder {
0061       public:
0062     CopyHolder( const QString &a, const QString &b )
0063     {
0064       name = a;
0065       email = b;
0066     }
0067 
0068     void addFile( const QString &a )
0069     {
0070       files.append( a );
0071       files.sort();
0072     }
0073     
0074     QString name;
0075     QString email;
0076     QStringList files;
0077     };
0078 
0079     Log() {}
0080     ~Log() {}
0081 
0082     void printFullReport( LogEntry::PrintStyle style, const QString &filename ) { print( style, true, true, true, true, filename ); }
0083     void printErrorReport( LogEntry::PrintStyle style, bool warnings, const QString &filename ) { print( style, true, warnings, true, false, filename ); }
0084     void writeShellScript( const QString & filename );
0085     void addCopyHolder( const QString &a, const QString & b, const QString & filename );
0086     void addProblemFile( const QString &a ) { problemFiles.append( a ); }
0087 
0088   private:
0089     void print( LogEntry::PrintStyle style, bool errors, bool warnings, bool information, bool success, QString filename );
0090     QList<CopyHolder> copyHolders;
0091     QList<QString> problemFiles;
0092 
0093 };
0094 
0095 #endif