Check-in [11b8c3ef2b]

Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Removed unused classes and added fullreportgenerator class
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:11b8c3ef2b0a644ec4e9b211ca9ad233f0b65764
User & Date: avi 2014-09-19 09:51:45
Context
2014-09-19
11:08
[bug fix] Fixed running RR2 with custom types based on cli configuration check-in: b4863e9612 user: avi tags: trunk
09:51
Removed unused classes and added fullreportgenerator class check-in: 11b8c3ef2b user: avi tags: trunk
09:48
Added full report creation using cli arg -report check-in: 7c1d5a319f user: avi tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added RapidReporter2/fullreportgenerator.cpp.































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "fullreportgenerator.h"
#include <QDebug>
#include <QStringList>
#include <QCoreApplication>
#include <iostream>
#include <QTime>
#include <QDate>
#include <QTextStream>

using namespace std;


FullReportGenerator::FullReportGenerator(QObject *parent) :
    QObject(parent)
{
}

/// Collect all RR2 session reports and create an integrated report
void FullReportGenerator::GenerateFullReport()
{
    QDir currentdir(QCoreApplication::applicationDirPath());

    QStringList files = currentdir.entryList(QStringList("*.csv"),
                                        QDir::Files | QDir::NoSymLinks
                                        ,QDir::Time | QDir::Reversed);

    if(0 == files.count())
    {
        ReportErrorAndExit( "Threre is no report files to combine, aborting!");
     }

    // Create new full report file
    QString fullReportFileName = currentdir.filePath(GenerateFullReportFileName());
    QFile fullReportFile(fullReportFileName);


    // Iterate all RR2 session files inside the folder and concatante to one report file
    foreach (QString fileName, files) {

        if (!IsReportFile(fileName) && IsSessionReportFile(fileName))
        {
            QString filePath = currentdir.filePath(fileName);

            if(!ConcatanateReport(filePath,fullReportFile))
            {
                ReportErrorAndExit("Cannot add report file " + fileName + "\nAborting!!!");
            }

        }
    }

}

/// Print error message to console and exit
void FullReportGenerator::ReportErrorAndExit(QString msg)
{
    std::cout << msg.toStdString();
    exit(0);
}

/// Add the session file contant to the full report file
bool FullReportGenerator::ConcatanateReport(QString fileToAdd, QFile & fullReportFile)
{
    bool status = true;

    if(!fullReportFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
        ReportErrorAndExit("Cannot create a full report file, aborting!!!");

    QTextStream out(&fullReportFile);

    QFile infile(fileToAdd);
    if(!infile.open(QIODevice::ReadOnly | QIODevice::Text))
        ReportErrorAndExit("Cannot open file " + fileToAdd + " to read, aborting!!!");

    QTextStream in(&infile);

    QString line = in.readLine();

    // If report file is empty - add the first line from the first session file too.
    if(0 == fullReportFile.pos())
    {
        out << line << "\n";
        out.flush();
    }

    line = in.readLine();
    while (!line.isNull())
    {
        out << line << "\n";
        out.flush();
        line = in.readLine();
    };

    fullReportFile.flush();
    fullReportFile.close();
    infile.close();

    return status;
}

///Returns true if it's a RR2 session file
bool FullReportGenerator::IsSessionReportFile(QString fileName)
{
    return fileName.startsWith("RR2_");
}

///Reture true if it's a full report file
bool FullReportGenerator::IsReportFile(QString fileName)
{
    return fileName.startsWith("Report_");
}

/// Generate a uniqe full report file name
QString FullReportGenerator::GenerateFullReportFileName()
{
    QString time = QTime::currentTime().toString();
    QString date = QDate::currentDate().toString(Qt::SystemLocaleShortDate);

    QString fileName = "Report_RR2_";
    fileName.append(date).append("_").append(time).append(".csv");

    // Remove chars which disturb the save proccess
    QRegExp regexp("[' ' | '\' | '/' | ':']");
    fileName.replace(regexp,"");

    return fileName;
}

Added RapidReporter2/fullreportgenerator.h.



































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef FULLREPORTGENERATOR_H
#define FULLREPORTGENERATOR_H

#include <QObject>
#include <QString>
#include <QDir>
#include <QFile>
#include <QList>

///
/// \brief The FullReportGenerator class
/// This class generates an integrated report from all RR2 session reports in the current folder
///
class FullReportGenerator : public QObject
{
    Q_OBJECT
public:
    explicit FullReportGenerator(QObject *parent = 0);

signals:

public slots:
    void GenerateFullReport();

protected:
    QString GenerateFullReportFileName();
    bool IsReportFile(QString fileName);
    bool IsSessionReportFile(QString fileName);
    bool ConcatanateReport(QString fileToAdd, QFile &fullReportFile);
    void ReportErrorAndExit(QString msg);
};

#endif // FULLREPORTGENERATOR_H

Deleted RapidReporter2/logger.cpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "logger.h"

const QString Logger::LOG_FILE_NAME = QString("-_-");

Logger::Logger(QObject *parent) :
    QObject(parent)
{
    startDate = dateTimeGen.currentDateTime().toString();


   msgType = new QString [5];
   //msgType[f::INFO_MSG] = "[Error]";
   //msgType[MyEnum::INFO_MSG] = "[Info]";

}

void Logger::Record(QString msg)
{
    QFile logFile(LOG_FILE_NAME);

    if (!logFile.open(QIODevice::WriteOnly | QIODevice::Text
                       | QIODevice::Append))
        return;

    QTextStream out(&logFile);

    out <<startDate << " " <<  msg << endl ;
}


//void Logger::Record(QString msg, MyEnum myEnum)
//{
//    QFile logFile(LOG_FILE_NAME);

//    if (!logFile.open(QIODevice::WriteOnly | QIODevice::Text
//                       | QIODevice::Append))
//        return;

//    QTextStream out(&logFile);
//    out <<startDate << " " <<  msg << endl ;
//}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































Deleted RapidReporter2/logger.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef LOGGER_H
#define LOGGER_H

#include <QObject>
#include <QString>
#include <QDir>
#include <QFile>
#include <QTextStream>
#include <QDateTime>
#include <string>

using namespace std;

class Logger : public QObject
{
    Q_OBJECT
    Q_ENUMS(f)
    static const QString LOG_FILE_NAME;
    QString startDate;
    QString currentDate;
    QDateTime dateTimeGen;
    QString * msgType;

public:
    explicit Logger(QObject *parent = 0);
    //void Record(QString msg, MyEnum myEnum);
    void Record(QString msg);

    enum f {ERR_MSG,INFO_MSG,Unknown};


signals:

public slots:

};

#endif // LOGGER_H
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































Deleted RapidReporter2/note.cpp.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "note.h"

Note::Note(QObject *parent) :
    QObject(parent)
{
   // currentUserType = 0;  // first type;  probably it's insert here by mistake
}

// User Types

void Note::SetUserTypes(QString types[], int size)
{
    UserTypesCount = size;
    UserTypes = new QString[UserTypesCount];

    for (int i = 0; i < UserTypesCount; i++)
        UserTypes[i] = types[i];
}

void Note::AddUserTypes(QString types[], int size)
{
    QString *tmp = new QString[UserTypesCount + size];
    for (int i = 0; i < UserTypesCount; i++)
        tmp[i] = UserTypes[i];
    for (int i = 0; i < size; i++)
        tmp[i + UserTypesCount] = types[i];
    UserTypesCount += size;
    delete[] tmp;
}

void Note::AddUserType(QString type)
{
    QString *tmp = new QString[UserTypesCount + 1];
    for (int i = 0; i < UserTypesCount; i++)
        tmp[i] = UserTypes[i];
    tmp[UserTypesCount] = type;
    UserTypesCount++;
    delete[] tmp;
}

// Extra Columns Section

void Note::SetExtraColumns(QString columns[], int size)
{
    ExtraColumnsCount = size;
    ExtraColumns = new QString[ExtraColumnsCount];

    for (int i = 0; i < ExtraColumnsCount; i++)
        ExtraColumns[i] = columns[i];
}

void Note::AddExtraColumns(QString columns[], int size)
{
    QString *tmp = new QString[ExtraColumnsCount + size];
    for (int i = 0; i < ExtraColumnsCount; i++)
        tmp[i] = ExtraColumns[i];
    for (int i = 0; i < size; i++)
        tmp[i + ExtraColumnsCount] = columns[i];
    ExtraColumnsCount += size;
    delete[] tmp;
}

void Note::AddExtraColumn(QString column)
{
    QString *tmp = new QString[ExtraColumnsCount + 1];
    for (int i = 0; i < ExtraColumnsCount; i++)
        tmp[i] = ExtraColumns[i];
    tmp[ExtraColumnsCount] = column;
    ExtraColumnsCount++;
    delete[] tmp;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































Deleted RapidReporter2/note.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef NOTE_H
#define NOTE_H

#include <QObject>
#include <QString>

class Note : public QObject
{
    Q_OBJECT
public:
    explicit Note(QObject *parent = 0);

    // User Types Methods
    void SetUserTypes (QString types[], int size);
    void AddUserTypes (QString types[], int size);
    void AddUserType  (QString type);
    int getUserTypesCount() { return UserTypesCount; }

    // Extra Columns Methods
    void SetExtraColumns (QString columns[], int size);
    void AddExtraColumns (QString columns[], int size);
    void AddExtraColumn  (QString column);
    int getExtraColumnsCount() { return ExtraColumnsCount; }

    // Sets for defualt columns
    void setReporter (QString reporter) { Reporter = reporter;  }
    void setCharter  (QString charter)  { Charter = charter;    }
    void setContent  (QString content)  { Content = content;    }
    void setRTFnoteLink    (QString RTFlink)        { RTFnoteLink = RTFlink; }
    void setScreenshotLink (QString scrShootLink)   { ScreenshotLink = scrShootLink; }

    // Gets for defualt columns
    QString getReporter ()		 { return Reporter;      }
    QString getCharter  ()		 { return Charter;       }
    QString getContent  ()		 { return Content;       }
    QString getRTFnoteLink    () { return RTFnoteLink;   }
    QString getScreenshotLink () { return ScreenshotLink;}

signals:

public slots:

private:
    // Default columns
    QString Reporter, Charter, Content, RTFnoteLink, ScreenshotLink;

    // Extra columns (can added via the plugins
    QString *ExtraColumns;
    int ExtraColumnsCount;
    // need to add current variable - to know where we are now

    // User types can change via CMD
    QString *UserTypes;
    int UserTypesCount;
};

#endif // NOTE_H
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































Deleted RapidReporter2/test.cpp.

1
2
3
4
5
6
#include "test.h"

test::test(QObject *parent) :
    QObject(parent)
{
}
<
<
<
<
<
<












Deleted RapidReporter2/test.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef TEST_H
#define TEST_H

#include <QObject>

class test : public QObject
{
    Q_OBJECT
public:
    explicit test(QObject *parent = 0);

signals:

public slots:

};

#endif // TEST_H
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<