Project Documentation Manager BRIGADOON-0002
Project Documentation Manager
Loading...
Searching...
No Matches
projectstatus.cpp
Go to the documentation of this file.
1#include "projectstatus.h"
2#include <QSqlDatabase>
3#include <QSqlQuery>
5
6ProjectStatus::ProjectStatus(Ui::MainWindow* UI_Window)
7{
8 ui = UI_Window;
9
10 QObject::connect(ui->ProjectStatus, SIGNAL(currentIndexChanged(int)), this, SLOT(StatusChanged(int)));
11 QObject::connect(ui->IncrementStatus, SIGNAL(pressed()), this, SLOT(DoIncrement()));
12 QObject::connect( ui->EnableStatusEditing, SIGNAL( stateChanged(int) ), this, SLOT( SetStatusEditing(int)));
13 QObject::connect(ui->SetStatusDateNow, SIGNAL(pressed()), this, SLOT(DoStatusDateNow()));
14}
15
17{
18 // Clear the Development Family List
19 ui->ProjectStatus->clear();
20 // Get a List of the Development Families from Database
21 QSqlQuery status_query( "select proj_status_index, status_name from project_status order by proj_status_index" );
22
23 // Step through the Results
24 int row_index = 0;
25 while ( status_query.next() )
26 {
27 int status_index = status_query.value(0).toInt();
28 QString status_entry = status_query.value(1).toString();
29 ui->ProjectStatus->addItem( status_entry, status_index );
30 row_index++;
31 }
32 if (row_index == 0)
33 {
34 LogAdd(LOG_ERROR, MODE_DATABASE, "Status List loading FAILED.");
35 }
36 else
37 {
38 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Status List loaded %1 item.").arg(QString::number(row_index)));
39 }
40}
41
42void ProjectStatus::LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString Message)
43{
44 REMOTE_LOG_ENTRY log_entry;
45 log_entry.Severity = Severity;
46 log_entry.Mode = Mode;
47 log_entry.Message = Message;
48 emit SendLogEntry(log_entry);
49}
50
52{
53 SetNextStatusPrompt(NewStatus);
54 LogAdd(LOG_DEBUG, MODE_OPERATOR, QString("Project Status Changed to %1").arg(ui->ProjectStatus->itemText(NewStatus)));
55}
56
58{
59 int current_index = ui->ProjectStatus->currentIndex();
60 int top_item = ui->ProjectStatus->count();
61
62 // Ignore the Status Selection that Occurs at Load Time
63 if (top_item == 1) return;
64
65 // Set the text for the Status Increment Button, but Not if it is "Inactive"
66 if (current_index == (top_item - 1))
67 {
68 ui->IncrementStatus->setText("No More Levels");
69 }
70 else
71 {
72 ui->IncrementStatus->setText(QString("Set Status to %1").arg(ui->ProjectStatus->itemText(NewStatus+1)));
73 if (!ui->EnableStatusEditing->isChecked()) ui->ProjectStatusDate->setDateTime(QDateTime::currentDateTime());
74 PostStatus();
75 }
76}
77
79{
80 int current_index = ui->ProjectStatus->currentIndex();
81 int top_count = ui->ProjectStatus->count() - 1;
82
83 if (current_index != top_count)
84 {
85 ui->ProjectStatus->setCurrentIndex(current_index + 1);
86 SetNextStatusPrompt(current_index + 1);
87 }
88}
89
91{
92 bool is_checked = (bool)EditStatus;
93
94 ui->ProjectStatus->setEnabled(is_checked);
95 ui->ProjectStatusDate->setEnabled(is_checked);
96 ui->SetStatusDateNow->setEnabled(is_checked);
97}
98
100{
101 LogAdd(LOG_DEBUG, MODE_OPERATOR, "Request to Send Status Received.");
102 emit SendStatus(ui->ProjectStatus->currentIndex());
103}
104
106{
107 ui->ProjectStatusDate->setDateTime(QDateTime::currentDateTime());
108}
109
111{
112 LoadStatus();
113 ui->IncrementStatus->setText(QString("Set Status to %1").arg(ui->ProjectStatus->itemText(1)));
114}
115
117{
118 // Get the Status Information
119 STATUS_INFO status_info;
120 status_info.StatusName = ui->ProjectStatus->currentText();
121 status_info.StatusIndex = ui->ProjectStatus->currentIndex() + 1;
122 status_info.StatusDateTime = ui->ProjectStatusDate->dateTime();
123 status_info.StatusDateTimeString = ui->ProjectStatusDate->dateTime().toString("hh:mm:ss dd-MMM-yyyy");
124 //status_info.ProjectIndex = project_index;
125
126 // Update the Project in the Database
127 QString query_string = QString("update project set project_status = %1, status_date = '%2' where project_index = %3").
128 arg(QString::number(status_info.StatusIndex), status_info.StatusDateTime.toString(DATETIME_DATABASE_FORMAT), QString::number(project_index));
129
130 QSqlQuery update_status_query;
131 bool result = update_status_query.exec(query_string);
132 if (result)
133 {
134 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Status Update to %1").arg(status_info.StatusName));
135 emit SendStatusInfo(status_info);
136 }
137 else
138 {
139 LogAdd(LOG_ERROR, MODE_DATABASE, QString("Unable to update Status to %1").arg(status_info.StatusName));
140 }
141}
142
144{
146 ui->ProjectStatus->setCurrentIndex(Info->StatusInfo.StatusIndex - 1);
147 ui->ProjectStatusDate->setDateTime(Info->StatusInfo.StatusDateTime);
148}
void LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, QString Message)
Add a Log Entry.
void LoadStatus(void)
Load Status definitions from the Database.
void SendLogEntry(REMOTE_LOG_ENTRY LogEntry)
Send Log Entry to the Log \LogEntry Structure holding Log information.
void StatusChanged(int StatusIndex)
When Status Changes Update the Next Status Level Button.
ProjectStatus(Ui::MainWindow *UI_Window)
ProjectStatus Constructor.
void ReadProjectInfo(PROJECT_INFORMATION *Info)
Read teh Status from the Project Info to the User Interface.
void SendStatusInfo(STATUS_INFO StatusInfo)
Emit the current Status Information Structure.
void PostStatus(void)
Get Current Status from User Inface, Save to Database & Forward.
void DoStatusDateNow(void)
Set the Status Date as the current DateTime.
void SetStatusEditing(int EditStatus)
Turn Custom Status Setting On or Off.
Ui::MainWindow * ui
Pointer to the Main Window.
void DoIncrement(void)
Increment the Project's Status to the Next Level.
void SendStatus(int StatusIndex)
Emit the current Status Database Index.
void DoClear(void)
Reset the Uer Interface Status Display.
void SetNextStatusPrompt(int NewStatus)
Set the Next Available Status Level in the Increment Button.
void TriggerSendStatus(void)
Respond to Request for Status by Sending it.
int project_index
The Database Table index of the Project.
Common Structure Defintitions.
#define DATETIME_DATABASE_FORMAT
text format of the DateTime used by the Database.
LOGGING_SEVERITY
Log Severity allow the selection of logging events based on Severity.
Definition logger.h:48
@ LOG_ERROR
Definition logger.h:52
@ LOG_DEBUG
Definition logger.h:56
LOGGING_MODE
Log Severity allow the selection of logging events based on the mode.
Definition logger.h:21
@ MODE_OPERATOR
Definition logger.h:34
@ MODE_DATABASE
Definition logger.h:35
Class Controlling the Project Status COntrol & Display.
Project Information Passed Between Functions.
PROJECT_DESCRIPTION ProjectDesc
Definition logger.h:60
LOGGING_MODE Mode
Definition logger.h:61
QString Message
Definition logger.h:63
LOGGING_SEVERITY Severity
Definition logger.h:62
Information about the Development Status.
QString StatusDateTimeString
QDateTime StatusDateTime