Check-in [f36ce55776]

Not logged in

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

Overview
Comment:Prototype is ready. Added GUI, Progressbar, Timer handling, start and close session, note adding, callback mechanism.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f36ce55776d5a1605cf9e9f79e3fe0368d233dc9
User & Date: azadok 2013-12-16 08:40:39
Context
2013-12-16
21:53
Cli Parset was connected to the application. Csv2Html class was refactored. Timer was udpated. check-in: 9b90ae9676 user: azadok tags: trunk
08:40
Prototype is ready. Added GUI, Progressbar, Timer handling, start and close session, note adding, callback mechanism. check-in: f36ce55776 user: azadok tags: trunk
2013-12-15
19:00
(no comment) check-in: 960acd27e5 user: assafkal tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to RapidReporter2/keyenterreceiver.cpp.

19
20
21
22
23
24
25




26
27
28
29
30
31
32
        }
        else
        {
            return QObject::eventFilter(obj, event);
        }
        return true;
    }




    else
    {
        return QObject::eventFilter(obj, event);
    }

    return false;
}







>
>
>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        }
        else
        {
            return QObject::eventFilter(obj, event);
        }
        return true;
    }
    else if (false) {
        //event->type() == QEvent::
    }

    else
    {
        return QObject::eventFilter(obj, event);
    }

    return false;
}

Changes to RapidReporter2/mainwindow.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



































































































#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    keyEnterReceiver *key = new keyEnterReceiver();
    ui->textEdit->installEventFilter(key);
    ui->label_field->setText("Reporter:");
    QFont f( "Arial", 22, QFont::Bold);
    ui->label_field->setFont(f);
    ui->textEdit->setFont(f);
    connect(&(*key),SIGNAL(keyEnterReceived()),this,SLOT(GetUserText()));



}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::GetUserText()
{
    QString content = ui->textEdit->toPlainText();

    QString field = ui->label_field->text().replace(":","");



    EmitFieldContent(field,content);

    qDebug() <<" Field: " + field + " Content: " + content;
}






































































































>






|
|
|
|
|
|
|
>
>
>













>
>

|
<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
128
129
130
131
132
133
134
135
136
137
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    sessionStarted=false;
    keyEnterReceiver *key = new keyEnterReceiver();
    ui->textEdit->installEventFilter(key);
    UpdateFieldLable("Reporter:");
    connect(&(*key),SIGNAL(keyEnterReceived()),
            this,SLOT(GetUserText()));
    connect(this,SIGNAL(EmitFieldContent(QString,QString)),
            this,SLOT(HandleCatchFieldContent(QString,QString)));


}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::GetUserText()
{
    QString content = ui->textEdit->toPlainText();

    QString field = ui->label_field->text().replace(":","");

    qDebug() <<" Field: " + field + " Content: " + content;

    EmitFieldContent(field,content);
}


void MainWindow::on_pushButton_clicked()
{
    if (sessionStarted) {
        emit EmitTakeScreenshot();
    }
}

// Grabs the content of the current field and update the GUI
void MainWindow::HandleCatchFieldContent(QString field, QString content)
{
    if ("Reporter" == field) {
        setReporterTmp(content);
        UpdateFieldLable("Charter");

    } else if ("Charter" == field) {

        this->session=new Session(reporterTmp,content);
        connect(this,SIGNAL(EmitNoteTake(QString,QString)),
                this->session,SLOT(NoteWasTakeSlot(QString,QString)));
        connect(this,SIGNAL(EmitTakeScreenshot()),
                &this->session->screenshot,SLOT(ShootScreenSlot()));
        connect(this->session,SIGNAL(EmitsessionTimeOut(int)),
                this,SLOT(UpdateProgerssBar(int)));
        connect(this,SIGNAL(EmitResetTimer()),
                this->session,SLOT(ReserTimerSlot(int)));

        session->StartSession();
        QString lableTitle = session->getCurrentNoteType();
        UpdateFieldLable(lableTitle);
        sessionStarted=true;


    } else {
        emit EmitNoteTake(field,content);
        QString lableTitle = session->getCurrentNoteType();
        UpdateFieldLable(lableTitle);
    }
}

void MainWindow::UpdateProgerssBar(int interval)
{
    int value = ui->progressBar->value()+interval;

    if (100 < value) {
        ui->progressBar->setValue(100);
        NotifySessionTimeEnded();
        session->setSessionTimeOver(true);
        emit EmitResetTimer(90);
    }
    else {
        ui->progressBar->setValue(value);
    }
}

void MainWindow::SessionTimeEnded()
{
    void NotifySessionTimeEnded();
}


//Update the filed and content for the GUI lable and textedit controls
void MainWindow::UpdateFieldLable(QString field)
{
    QFont f( "Arial", 22, QFont::Bold);
    ui->label_field->setFont(f);
    ui->label_field->setText(field);
    ui->textEdit->setText("");
    ui->textEdit->setCurrentFont(f);
    ui->textEdit->setFont(f);
}

void MainWindow::NotifySessionTimeEnded()
{
    QMessageBox::about(this, tr("Session time ended"),
            tr("Please note that the session time is ended.\nYou may continue use RR2 or initilize a new session."));
}

QString MainWindow::getReporterTmp() const
{
    return reporterTmp;
}

void MainWindow::setReporterTmp(const QString &value)
{
    reporterTmp = value;
}


void MainWindow::closeEvent(QCloseEvent *event)
{
    if (sessionStarted) {
        session->CloseSession();
    }
    event->accept();
}




Changes to RapidReporter2/mainwindow.h.

1
2
3
4
5
6

7
8
9
10
11
12
13
..
15
16
17
18
19
20
21



22
23
24




25
26
27
28



29

30



31
32
33
34




35
36
37
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QKeyEvent>
#include "keyenterreceiver.h"


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
................................................................................

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();






private slots:

    void GetUserText();





signals:

    void EmitFieldContent(QString,QString);





protected:



    //void keyPressEvent(QKeyEvent *);

private:
    Ui::MainWindow *ui;




};

#endif // MAINWINDOW_H






>







 







>
>
>



>
>
>
>




>
>
>

>

>
>
>




>
>
>
>



1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QKeyEvent>
#include "keyenterreceiver.h"
#include "session.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
................................................................................

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();



    QString getReporterTmp() const;
    void setReporterTmp(const QString &value);

private slots:

    void GetUserText();
    void on_pushButton_clicked();
    void HandleCatchFieldContent(QString,QString);
    void UpdateProgerssBar(int);
    void SessionTimeEnded();

signals:

    void EmitFieldContent(QString,QString);
    void EmitTakeScreenshot();
    void EmitNoteTake(QString,QString);
    void EmitResetTimer(int);


protected:
    void creatAndStartSession(QString,QString);
    void UpdateFieldLable(QString);
    void NotifySessionTimeEnded();
    //void keyPressEvent(QKeyEvent *);

private:
    Ui::MainWindow *ui;
    bool sessionStarted;
    Session * session;
    QString reporterTmp;
    void closeEvent(QCloseEvent *);
};

#endif // MAINWINDOW_H

Changes to RapidReporter2/mainwindow.ui.

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
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>652</width>
    <height>120</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>10</y>
      <width>75</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>Screenshot</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_2">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>40</y>
      <width>75</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>RTF</string>
    </property>
   </widget>
   <widget class="QTextEdit" name="textEdit">
    <property name="geometry">
     <rect>
      <x>240</x>
      <y>10</y>
      <width>391</width>
      <height>51</height>
     </rect>
    </property>
    <property name="readOnly">
     <bool>false</bool>
    </property>
    <property name="html">
     <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_field">
    <property name="geometry">
     <rect>
      <x>100</x>
      <y>10</y>
      <width>131</width>
      <height>51</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
    <property name="alignment">
     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    </property>
   </widget>




























  </widget>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>652</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QToolBar" name="mainToolBar">
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>
  <widget class="QStatusBar" name="statusBar"/>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>







|
|









|

|










|

|










|












|
|





|

|










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|
|











<





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
128
129
130
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>847</width>
    <height>144</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>100</x>
      <y>10</y>
      <width>91</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>Screenshot</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_2">
    <property name="geometry">
     <rect>
      <x>100</x>
      <y>40</y>
      <width>91</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>RTF</string>
    </property>
   </widget>
   <widget class="QTextEdit" name="textEdit">
    <property name="geometry">
     <rect>
      <x>430</x>
      <y>10</y>
      <width>391</width>
      <height>51</height>
     </rect>
    </property>
    <property name="readOnly">
     <bool>false</bool>
    </property>
    <property name="html">
     <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_field">
    <property name="geometry">
     <rect>
      <x>200</x>
      <y>10</y>
      <width>211</width>
      <height>51</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
    <property name="alignment">
     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    </property>
   </widget>
   <widget class="QProgressBar" name="progressBar">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>10</y>
      <width>21</width>
      <height>71</height>
     </rect>
    </property>
    <property name="sizePolicy">
     <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
      <horstretch>0</horstretch>
      <verstretch>0</verstretch>
     </sizepolicy>
    </property>
    <property name="value">
     <number>0</number>
    </property>
    <property name="alignment">
     <set>Qt::AlignCenter</set>
    </property>
    <property name="orientation">
     <enum>Qt::Vertical</enum>
    </property>
    <property name="textDirection">
     <enum>QProgressBar::BottomToTop</enum>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>847</width>
     <height>20</height>
    </rect>
   </property>
  </widget>
  <widget class="QToolBar" name="mainToolBar">
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>

 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>

Changes to RapidReporter2/screenshot.cpp.

34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55

    // notify registered classes
    emit ScreenshotCaptured(fullPath);
}

QString Screenshot::ShootScreen()
{
    // Generage unique file name
    QString fileName = "RR2_"
            + QDateTime::currentDateTime().toString(Qt::SystemLocaleShortDate)
            + ".png";


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

    // Take the screenshot and save it to the file
    screenshotPixmap = new QPixmap();
    QScreen *screen = QGuiApplication::primaryScreen();
    if (screen)
        *screenshotPixmap = screen->grabWindow(0);
    screenshotPixmap->save(fileName);







|
|
|
|
>



|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

    // notify registered classes
    emit ScreenshotCaptured(fullPath);
}

QString Screenshot::ShootScreen()
{

    QString time = QTime::currentTime().toString();
    QString date = QDate::currentDate().toString(Qt::SystemLocaleShortDate);

    QString fileName = "RR2_" + date + "_" + time + ".png";

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

    // Take the screenshot and save it to the file
    screenshotPixmap = new QPixmap();
    QScreen *screen = QGuiApplication::primaryScreen();
    if (screen)
        *screenshotPixmap = screen->grabWindow(0);
    screenshotPixmap->save(fileName);

Changes to RapidReporter2/session.cpp.

1
2
3
4


5















































6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
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
..
91
92
93
94
95
96
97



98
99
100
101
102
103
104
...
150
151
152
153
154
155
156





























































157
158
159
160
161
162









163
164
165
166

167
168
169
170
171
172

173
174

175
176

177
178
179
180
181
182
183
184
185
#include "session.h"
#include <QDebug>
#include <QCoreApplication>



















































QString Session::GenerateCsvFileName()
{

    QString time = QTime::currentTime().toString();
    QString date = QDate::currentDate().toString(Qt::SystemLocaleShortDate);

    QString fileName = "RR2_" + date + "_" + time + ".csv";

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

    return fileName;
}

void Session::CreateCsvFile(QString fileName)
{
................................................................................
        out << line << "\n";
        out.flush();
        csvFile->flush();
        csvFile->close();
    }
}

Session::Session(QObject *parent) :
    QObject(parent)
{

    currentUserType = 0; // first user type
}


Session::Session(QString Reporter, QString Charter, QObject *parent) :
    QObject(parent)

{
    reporter=Reporter;
    charter=Charter;
}










void Session::StartSession()
{    
    csvFileName = GenerateCsvFileName();
    CreateCsvFile(csvFileName);

................................................................................
    AddLineToCsvfile(columnHeaders);
    AddLineToCsvfile(versionLine);
    AddLineToCsvfile(reporterLine);
    AddLineToCsvfile(charterLine);

    sessionStartTime = QDateTime::currentDateTime();




    qDebug() << "StartSession was called!\n";
}


void Session::CloseSession()
{
    QString currentTime = QDate::currentDate().toString(Qt::SystemLocaleShortDate)
................................................................................
}

void Session::CloseSessionSlot()
{
    CloseSession();
}






























































QString Session::getNextUserType(QString userTypes[], int count)
{
    QString ret;
    int index = (currentUserType + 1) % count;
    ret = userTypes[index];
    currentUserType = index;










    return ret;
}


QString Session::getPrevUserType(QString userTypes[], int count)
{
    QString ret;
    currentUserType--;
    if (currentUserType < 0) currentUserType = count - 1;
    ret = userTypes[currentUserType];

    return ret;
}


QString Session::getSpecificUserType(QString userTypes[], int &index, int count)

{
    // need to check this
    if (index < 0) throw "Index cannnot be smaller then zero";
    if (index >= count) throw "Index cannot be equal or high from user types count";

    currentUserType = index;
    return userTypes[currentUserType];
}





>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










<







 







|
<

>
|

>
|
<
|
>
|
<
<
|
>
>
>
>
>
>
>
>







 







>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

|
<
<
<
>
>
>
>
>
>
>
>
>




>
|


<
<
|
>
|
|
>

<
>
|
<
|
<
|
<
<
|
<
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
..
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
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
...
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295


296
297
298
299
300
301

302
303

304

305


306

#include "session.h"
#include <QDebug>
#include <QCoreApplication>

Session::Session(QObject *parent) :
    QObject(parent)
{
    currentTypeIndex = 0; // first user type
}

Session::Session(QString Reporter, QString Charter, QObject *parent) :
    QObject(parent)
{
    reporter=Reporter;
    charter=Charter;

    timerInit = 10;
    timeinterval = (100 / timerInit) + 1;
    sessionTimeOver = false;

    userTypes << "Setup:" <<  "Note:" <<  "Test:" <<
                 "Check:" << "Bug:" << "Question:" << "Next Time:";

    currentTypeIndex = 0;

    connect(&this->screenshot,SIGNAL(ScreenshotCaptured(QString)),
            this,SLOT(ScreenshotTakenSlot(QString)));
    connect(&this->sessionTimer,SIGNAL(timeout()),
            this,SLOT(TimeOutSlot()));
    sessionTimer.setInterval(timeinterval);
    sessionTimer.start(timerInit);
}


QStringList Session::getUserTypes() const
{
    return userTypes;
}

void Session::setUserTypes(const QStringList &value)
{
    userTypes = value;
}


int Session::getCurrentTypeIndex() const
{
    return currentTypeIndex;
}

void Session::setCurrentTypeIndex(int value)
{
    currentTypeIndex = value;
}
QString Session::GenerateCsvFileName()
{

    QString time = QTime::currentTime().toString();
    QString date = QDate::currentDate().toString(Qt::SystemLocaleShortDate);

    QString fileName = "RR2_" + date + "_" + time + ".csv";

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

    fileName.replace(regexp,"");

    return fileName;
}

void Session::CreateCsvFile(QString fileName)
{
................................................................................
        out << line << "\n";
        out.flush();
        csvFile->flush();
        csvFile->close();
    }
}

void Session::StartSessionTimer(int sec)

{
    sessionTimer.setInterval(1000);
    sessionTimer.start(1000 * sec);
}
bool Session::getSessionTimeOver() const
{

    return sessionTimeOver;
}





void Session::setSessionTimeOver(bool value)
{
    sessionTimeOver = value;
}





void Session::StartSession()
{    
    csvFileName = GenerateCsvFileName();
    CreateCsvFile(csvFileName);

................................................................................
    AddLineToCsvfile(columnHeaders);
    AddLineToCsvfile(versionLine);
    AddLineToCsvfile(reporterLine);
    AddLineToCsvfile(charterLine);

    sessionStartTime = QDateTime::currentDateTime();


    startTimer(10, Qt::VeryCoarseTimer);

    qDebug() << "StartSession was called!\n";
}


void Session::CloseSession()
{
    QString currentTime = QDate::currentDate().toString(Qt::SystemLocaleShortDate)
................................................................................
}

void Session::CloseSessionSlot()
{
    CloseSession();
}

// Add screenshot note to the csv file which contains the path to the taken screenshot
void Session::ScreenshotTakenSlot(QString screenshotPath)
{
    QString currentTime = QDate::currentDate().toString(Qt::SystemLocaleShortDate)
            + " " + QTime::currentTime().toString();
    QString COMMA = ",";

    QString screenshotLine = currentTime + COMMA
            + reporter + COMMA
            + "autogenerated" + COMMA
            + "screenshot saved" + COMMA + screenshotPath + COMMA;

    AddLineToCsvfile(screenshotLine);
}


// Add general note to the csv file
void Session::NoteWasTakeSlot(QString noteType, QString noteContent)
{
    QString currentTime = QDate::currentDate().toString(Qt::SystemLocaleShortDate)
            + " " + QTime::currentTime().toString();
    QString COMMA = ",";

    QString screenshotLine = currentTime + COMMA
            + reporter + COMMA
            + noteType + COMMA
            + noteContent + COMMA + COMMA;

    AddLineToCsvfile(screenshotLine);
}


// Add rtf note to the csv file which contains the path to the rtf
void Session::RtfWasTakeSlot(QString rtfPath)
{
    QString currentTime = QDate::currentDate().toString(Qt::SystemLocaleShortDate)
            + " " + QTime::currentTime().toString();
    QString COMMA = ",";

    QString screenshotLine = currentTime + COMMA
            + reporter + COMMA
            + "autogenerated" + COMMA
            + "extended note saved" + COMMA + COMMA + rtfPath;

    AddLineToCsvfile(screenshotLine);
}

void Session::TimeOutSlot()
{
    if (!sessionTimeOver) {
        emit EmitsessionTimeOut(timeinterval);
    }

}

void Session::ReserTimerSlot(int timeToInit)
{
    timerInit = 1000 * 60 * timeToInit;
    sessionTimer.start(timerInit);
}

QString Session::getNextUserType()
{
    QString ret ="";





    return ret;
}

QString Session::getPrevUserType()
{
    QString ret ="";


    return ret;
}


QString Session::getCurrentNoteType()
{
    QString ret;


    ret = userTypes[currentTypeIndex];
    int count = userTypes.count();
    currentTypeIndex = (++currentTypeIndex == count) ? 0 : currentTypeIndex;

    QString d(currentTypeIndex);


    qDebug() << "Current index is: "  ;


    return ret;

}




Changes to RapidReporter2/session.h.

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
#include <QObject>
#include <QTimer>
#include <QDateTime>
#include <QString>
#include <QStringList>
#include <QFile>
#include "note.h"


class Session : public QObject
{
    Q_OBJECT

    // util members
    QString startTime;
    QDateTime sessionStartTime;
    QDateTime dateTimeGenerator;
    QTimer sessionTimer;

    QString reporter;
    QString charter;
    QString csvFileName;
    QFile * csvFile;



    int currentUserType;


    // file hendling members
    QString workingDir;
    QString sessionFile;
    QString sessionFileFull;

    QString GenerateCsvFileName();
    void CreateCsvFile(QString fileName);
    void AddLineToCsvfile(QString line);














public:
    explicit Session(QObject *parent = 0);
    explicit Session(QString Reporter, QString Charter, QObject *parent = 0);
    void StartSession();
    void CloseSession();
    void SaveToSessionNotes(QString note);
    void UpdateNotes(int type, QString note, QString screenshot, QString RTFNote);
    void UpdateNotes(QString type, QString note, QString screenshot = "", QString RTFNote = "");


    QString TimeConversion(int msecs);

    QString getNextUserType(QString userTypes[], int count);
    QString getPrevUserType(QString userTypes[], int count);
    QString getSpecificUserType (QString userTypes[], int &index,int count);
















signals:


public slots:
    void StartSessionSlot();
    void CloseSessionSlot();






};

#endif // SESSION_H







>









|






>
>
|











>
>
>
>
>
>
>
>
>
>
>
>









<
>


|
|
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>




<
>
>
>
>
>



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
#include <QObject>
#include <QTimer>
#include <QDateTime>
#include <QString>
#include <QStringList>
#include <QFile>
#include "note.h"
#include "screenshot.h"

class Session : public QObject
{
    Q_OBJECT

    // util members
    QString startTime;
    QDateTime sessionStartTime;
    QDateTime dateTimeGenerator;


    QString reporter;
    QString charter;
    QString csvFileName;
    QFile * csvFile;

    // Handle note typs such as: Setup: Note: Test: Check: Bug: Question: Next Time:  etc..
    QStringList userTypes;
    int currentTypeIndex;


    // file hendling members
    QString workingDir;
    QString sessionFile;
    QString sessionFileFull;

    QString GenerateCsvFileName();
    void CreateCsvFile(QString fileName);
    void AddLineToCsvfile(QString line);


    // timer utils
    void StartSessionTimer(int);
    int timeinterval;
    int timerInit;
    bool sessionTimeOver;



protected:



public:
    explicit Session(QObject *parent = 0);
    explicit Session(QString Reporter, QString Charter, QObject *parent = 0);
    void StartSession();
    void CloseSession();
    void SaveToSessionNotes(QString note);
    void UpdateNotes(int type, QString note, QString screenshot, QString RTFNote);
    void UpdateNotes(QString type, QString note, QString screenshot = "", QString RTFNote = "");

    Screenshot screenshot;
    QString TimeConversion(int msecs);

    QString getNextUserType();
    QString getPrevUserType();
    //QString getSpecificUserType (QString userTypes[], int &index,int count);

    QString getCurrentNoteType();

    QTimer sessionTimer;

    QStringList getUserTypes() const;
    void setUserTypes(const QStringList &value);

    int getCurrentTypeIndex() const;
    void setCurrentTypeIndex(int value);



    bool getSessionTimeOver() const;
    void setSessionTimeOver(bool value);

signals:
    void EmitsessionTimeOut(int);

public slots:
    void StartSessionSlot();
    void CloseSessionSlot();

    void ScreenshotTakenSlot(QString);
    void NoteWasTakeSlot(QString,QString);
    void RtfWasTakeSlot(QString);
    void TimeOutSlot();
    void ReserTimerSlot(int);
};

#endif // SESSION_H

Changes to RapidReporter2/ui_mainwindow.h.

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
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QWidget>

QT_BEGIN_NAMESPACE

class Ui_MainWindow
................................................................................
{
public:
    QWidget *centralWidget;
    QPushButton *pushButton;
    QPushButton *pushButton_2;
    QTextEdit *textEdit;
    QLabel *label_field;

    QMenuBar *menuBar;
    QToolBar *mainToolBar;
    QStatusBar *statusBar;

    void setupUi(QMainWindow *MainWindow)
    {
        if (MainWindow->objectName().isEmpty())
            MainWindow->setObjectName(QStringLiteral("MainWindow"));
        MainWindow->resize(652, 120);
        centralWidget = new QWidget(MainWindow);
        centralWidget->setObjectName(QStringLiteral("centralWidget"));
        pushButton = new QPushButton(centralWidget);
        pushButton->setObjectName(QStringLiteral("pushButton"));
        pushButton->setGeometry(QRect(10, 10, 75, 23));
        pushButton_2 = new QPushButton(centralWidget);
        pushButton_2->setObjectName(QStringLiteral("pushButton_2"));
        pushButton_2->setGeometry(QRect(10, 40, 75, 23));
        textEdit = new QTextEdit(centralWidget);
        textEdit->setObjectName(QStringLiteral("textEdit"));
        textEdit->setGeometry(QRect(240, 10, 391, 51));
        textEdit->setReadOnly(false);
        label_field = new QLabel(centralWidget);
        label_field->setObjectName(QStringLiteral("label_field"));
        label_field->setGeometry(QRect(100, 10, 131, 51));
        label_field->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);












        MainWindow->setCentralWidget(centralWidget);
        menuBar = new QMenuBar(MainWindow);
        menuBar->setObjectName(QStringLiteral("menuBar"));
        menuBar->setGeometry(QRect(0, 0, 652, 21));
        MainWindow->setMenuBar(menuBar);
        mainToolBar = new QToolBar(MainWindow);
        mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
        MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
        statusBar = new QStatusBar(MainWindow);
        statusBar->setObjectName(QStringLiteral("statusBar"));
        MainWindow->setStatusBar(statusBar);

        retranslateUi(MainWindow);

        QMetaObject::connectSlotsByName(MainWindow);
    } // setupUi

    void retranslateUi(QMainWindow *MainWindow)
................................................................................
    {
        MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
        pushButton->setText(QApplication::translate("MainWindow", "Screenshot", 0));
        pushButton_2->setText(QApplication::translate("MainWindow", "RTF", 0));
        textEdit->setHtml(QApplication::translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><br /></p></body></html>", 0));
        label_field->setText(QString());
    } // retranslateUi

};

namespace Ui {
    class MainWindow: public Ui_MainWindow {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_MAINWINDOW_H







|
|







 







>


<





|




|


|


|



|

>
>
>
>
>
>
>
>
>
>
>
>



|




<
<
<







 







|
|












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
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QProgressBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QWidget>

QT_BEGIN_NAMESPACE

class Ui_MainWindow
................................................................................
{
public:
    QWidget *centralWidget;
    QPushButton *pushButton;
    QPushButton *pushButton_2;
    QTextEdit *textEdit;
    QLabel *label_field;
    QProgressBar *progressBar;
    QMenuBar *menuBar;
    QToolBar *mainToolBar;


    void setupUi(QMainWindow *MainWindow)
    {
        if (MainWindow->objectName().isEmpty())
            MainWindow->setObjectName(QStringLiteral("MainWindow"));
        MainWindow->resize(847, 144);
        centralWidget = new QWidget(MainWindow);
        centralWidget->setObjectName(QStringLiteral("centralWidget"));
        pushButton = new QPushButton(centralWidget);
        pushButton->setObjectName(QStringLiteral("pushButton"));
        pushButton->setGeometry(QRect(100, 10, 91, 23));
        pushButton_2 = new QPushButton(centralWidget);
        pushButton_2->setObjectName(QStringLiteral("pushButton_2"));
        pushButton_2->setGeometry(QRect(100, 40, 91, 23));
        textEdit = new QTextEdit(centralWidget);
        textEdit->setObjectName(QStringLiteral("textEdit"));
        textEdit->setGeometry(QRect(430, 10, 391, 51));
        textEdit->setReadOnly(false);
        label_field = new QLabel(centralWidget);
        label_field->setObjectName(QStringLiteral("label_field"));
        label_field->setGeometry(QRect(200, 10, 211, 51));
        label_field->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
        progressBar = new QProgressBar(centralWidget);
        progressBar->setObjectName(QStringLiteral("progressBar"));
        progressBar->setGeometry(QRect(20, 10, 21, 71));
        QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(progressBar->sizePolicy().hasHeightForWidth());
        progressBar->setSizePolicy(sizePolicy);
        progressBar->setValue(0);
        progressBar->setAlignment(Qt::AlignCenter);
        progressBar->setOrientation(Qt::Vertical);
        progressBar->setTextDirection(QProgressBar::BottomToTop);
        MainWindow->setCentralWidget(centralWidget);
        menuBar = new QMenuBar(MainWindow);
        menuBar->setObjectName(QStringLiteral("menuBar"));
        menuBar->setGeometry(QRect(0, 0, 847, 20));
        MainWindow->setMenuBar(menuBar);
        mainToolBar = new QToolBar(MainWindow);
        mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
        MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);




        retranslateUi(MainWindow);

        QMetaObject::connectSlotsByName(MainWindow);
    } // setupUi

    void retranslateUi(QMainWindow *MainWindow)
................................................................................
    {
        MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
        pushButton->setText(QApplication::translate("MainWindow", "Screenshot", 0));
        pushButton_2->setText(QApplication::translate("MainWindow", "RTF", 0));
        textEdit->setHtml(QApplication::translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;\"><br /></p></body></html>", 0));
        label_field->setText(QString());
    } // retranslateUi

};

namespace Ui {
    class MainWindow: public Ui_MainWindow {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_MAINWINDOW_H