Project Documentation Manager BRIGADOON-0002
Project Documentation Manager
Loading...
Searching...
No Matches
LicenceManager Class Reference

Class to Manager the Project Licences. More...

#include <licencemanager.h>

Inheritance diagram for LicenceManager:
[legend]
Collaboration diagram for LicenceManager:
[legend]

Public Slots

void SaveQtLicence (void)
 Save the Default Qt Licence to settings.
void ReadPrimaryTool (int ToolIndex)
 read Primary Tool & Apply any licence Restrictions
void ReadLicenceState (LICENCE_STATE LicenceState)
 process the Licence state including any restrictions
void TriggerSendLicence (void)
 Trigger to send out the Licence states.
void DoClear (void)
 Resest the Licences fro the Database.

Signals

void SendLogEntry (REMOTE_LOG_ENTRY LogEntry)
 Send Log Entry to the Log \LogEntry Structure holding Log information.
void SendLicenceState (LICENCE_STATE LicenceState)
 Send the State of the Licences.
void UpdateSoftwareLicence (QString LicenceName)
 Emits the Text Name of the Software Lidence.
void UpdateHardwareLicence (QString LicenceName)
 Emits the Text Name of the Hardware Lidence.
void UpdateDocumentationLicence (QString LicenceName)
 Emits the Text Name of the Documentation Lidence.

Public Member Functions

 LicenceManager (Ui::MainWindow *UI_Window)
 LicenceManager Construction routine.
void LoadLicences (void)
 Load the Licence Data from the Database.
void WriteLicenceState (void)
 Read the Current Lilcence Stae on Display & Send out.

Private Slots

void SetSoftwareLicence (int LicenceIndex)
 Set the Software Licence.
void SetHardwareLicence (int LicenceIndex)
 Set the Hardware Licence.
void SetDocumentationLicence (int LicenceIndex)
 Set the Documentation Licence.

Private Member Functions

void LogAdd (LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString Message)
 Add a Log Entry.
void SendStatusMessage (QString Type, int Counter)
 Send the Type of Licence and the number licences loaded.
void LoadQtLicence (void)
 Load the Qt Licence from settings.
void ProcessSoftwareRestriction (int DocumentationRestriction)
 Use the Soft Restrictions to limit the possible licence selections.
void ProcessDocumentationRestriction (int DocumentationRestriction)
 Use the Documenrtation Restrictions to limit the possible licence selections.
void ProcessHardwareRestriction (int HardwareRestriction)
 Use the Hardware Restrictions to limit the possible licence selections.
uint GetLicenceIndex (QString LicenceText)
 Find the Licence Index from the Licence text.

Private Attributes

Ui::MainWindow * ui
 Pointer to the Main Window.
int primary_tool_index
 Index of the Primary Tool.
int qt_licence_index
 Index of the Qt Licence.

Detailed Description

Class to Manager the Project Licences.

Definition at line 17 of file licencemanager.h.

Constructor & Destructor Documentation

◆ LicenceManager()

LicenceManager::LicenceManager ( Ui::MainWindow * UI_Window)
explicit

LicenceManager Construction routine.

Parameters
UI_WindowPOinter to the main window

Member Function Documentation

◆ DoClear

void LicenceManager::DoClear ( void )
slot

Resest the Licences fro the Database.

Definition at line 281 of file licencemanager.cpp.

282{
283 LoadLicences();
284}
void LoadLicences(void)
Load the Licence Data from the Database.

References LoadLicences().

Here is the call graph for this function:

◆ GetLicenceIndex()

uint LicenceManager::GetLicenceIndex ( QString LicenceText)
private

Find the Licence Index from the Licence text.

Parameters
LicenceShort Name Licence Text
Returns
Index of the Licence Entry

Return the Licence Index, or 0 if there is no match

Definition at line 264 of file licencemanager.cpp.

265{
266 uint licence_index = 0;
267 QSqlQuery licence_index_query( QString("select licence_index from licence where short_name = '%1'").arg(LicenceText));
268 while ( licence_index_query.next() )
269 {
270 licence_index = licence_index_query.value(0).toInt();
271 }
272 return(licence_index);
273}

Referenced by WriteLicenceState().

Here is the caller graph for this function:

◆ LoadLicences()

void LicenceManager::LoadLicences ( void )

Load the Licence Data from the Database.

Definition at line 17 of file licencemanager.cpp.

18{
19 QSqlDatabase db = QSqlDatabase::database();
20
21 // Clear the Licence List
22 ui->SoftwareLicenceList->clear();
23
24 // Get a List of the Development Families from Database
25 QSqlQuery soft_licence_query( "select licence_index, short_name from licence where licence_type = 1 or licence_type = 3 order by short_name" );
26
27 // Step through the Results
28 int row_index = 0;
29 while ( soft_licence_query.next() )
30 {
31 int licence_index = soft_licence_query.value(0).toInt();
32 QString software_entry = soft_licence_query.value(1).toString();
33 ui->SoftwareLicenceList->addItem( software_entry, licence_index );
34 row_index++;
35 }
36 SendStatusMessage("Software Licence", row_index);
37
38 // Clear the Licence List
39 ui->DocumentationLicenceList->clear();
40
41 // Get a List of the Development Families from Database
42 QSqlQuery doc_licence_query( "select licence_index, short_name from licence where licence_type = 1 or licence_type = 2 order by short_name" );
43
44 // Step through the Results
45 row_index = 0;
46 while ( doc_licence_query.next() )
47 {
48 int licence_index = doc_licence_query.value(0).toInt();
49 QString doc_licence_entry = doc_licence_query.value(1).toString();
50 ui->DocumentationLicenceList->addItem( doc_licence_entry, licence_index );
51 row_index++;
52 }
53 SendStatusMessage("Documentation Licence", row_index);
54
55 // Clear the Licence List
56 ui->HardwareLicenceList->clear();
57
58 // Get a List of the Development Families from Database
59 QSqlQuery hardware_licence_query( "select licence_index, short_name from licence where licence_type = 1 or licence_type = 4 order by short_name" );
60
61 // Step through the Results
62 row_index = 0;
63 while ( hardware_licence_query.next() )
64 {
65 int licence_index = hardware_licence_query.value(0).toInt();
66 QString hardware_entry = hardware_licence_query.value(1).toString();
67 ui->HardwareLicenceList->addItem( hardware_entry, licence_index );
68 row_index++;
69 }
70 SendStatusMessage("Hardware Licence", row_index);
71
72 // Initialise the Qt Licence List
73 ui->QtLicenceList->clear();
74 ui->QtLicenceList->addItems({QString("Community"), QString("Professional"), QString("Enterprise")});
75 SendStatusMessage("Qt Licence List", 3);
76
78}
Ui::MainWindow * ui
Pointer to the Main Window.
void SendStatusMessage(QString Type, int Counter)
Send the Type of Licence and the number licences loaded.
void LoadQtLicence(void)
Load the Qt Licence from settings.

References LoadQtLicence(), SendStatusMessage(), and ui.

Referenced by DoClear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadQtLicence()

void LicenceManager::LoadQtLicence ( void )
private

Load the Qt Licence from settings.

Definition at line 92 of file licencemanager.cpp.

93{
94 // Open the Settings Data
95 QSettings settings( "brigadoon/netprojectmanager" );
96 ui->QtLicenceList->setCurrentText(settings.value( "Qt/Licence", "Community").toString());
97 LogAdd(LOG_DEBUG, MODE_CONFIG, QString("Qt Licence for Site loaded as %1.").arg(ui->QtLicenceList->currentText()));
98}
void LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString Message)
Add a Log Entry.
@ LOG_DEBUG
Definition logger.h:56
@ MODE_CONFIG
Definition logger.h:26

References LOG_DEBUG, LogAdd(), MODE_CONFIG, and ui.

Referenced by LoadLicences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogAdd()

void LicenceManager::LogAdd ( LOGGING_SEVERITY Severity,
LOGGING_MODE Mode,
const QString Message )
private

Add a Log Entry.

Parameters
SeveritySeverity of the Logged Event
ModePart of the Program being Logged
MessageDescription of the Log Event

Definition at line 108 of file licencemanager.cpp.

109{
110 REMOTE_LOG_ENTRY log_entry;
111 log_entry.Severity = Severity;
112 log_entry.Mode = Mode;
113 log_entry.Message = Message;
114 emit SendLogEntry(log_entry);
115}
void SendLogEntry(REMOTE_LOG_ENTRY LogEntry)
Send Log Entry to the Log \LogEntry Structure holding Log information.
LOGGING_MODE Mode
Definition logger.h:61
QString Message
Definition logger.h:63
LOGGING_SEVERITY Severity
Definition logger.h:62

References REMOTE_LOG_ENTRY::Message, REMOTE_LOG_ENTRY::Mode, SendLogEntry(), and REMOTE_LOG_ENTRY::Severity.

Referenced by LoadQtLicence(), SaveQtLicence(), SendStatusMessage(), and TriggerSendLicence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessDocumentationRestriction()

void LicenceManager::ProcessDocumentationRestriction ( int DocumenationRestriction)
private

Use the Documenrtation Restrictions to limit the possible licence selections.

Parameters
DocumentationRestrictionPosible restriction to Software Licences

Definition at line 198 of file licencemanager.cpp.

199{
200 bool licence_enabled = true;
201
202 // Check if there is No Documentation ERestriction
203 if (DocumentationRestriction != 0)
204 {
205 QString licence_name;
206 QSqlDatabase db = QSqlDatabase::database();
207 int row_index = 0;
208 QSqlQuery licence_restriction_query(QString("select short_name from licence where licence_index = %1").arg(QString::number(DocumentationRestriction)));
209 while ( licence_restriction_query.next() )
210 {
211 licence_name = licence_restriction_query.value(0).toString();
212 row_index++;
213 }
214
215 if (row_index != 0)
216 {
217 ui->DocumentationLicenceList->setCurrentText(licence_name);
218 }
219 }
220 ui->DocumentationLicenceList->setEnabled(licence_enabled);
221}

References ui.

Referenced by ReadLicenceState(), and ReadPrimaryTool().

Here is the caller graph for this function:

◆ ProcessHardwareRestriction()

void LicenceManager::ProcessHardwareRestriction ( int HardwareRestriction)
private

Use the Hardware Restrictions to limit the possible licence selections.

Parameters
HardwareRestrictionPosible restrictions to Hardware Licences

Definition at line 223 of file licencemanager.cpp.

224{
225 bool licence_enabled = true;
226
227 // Check if there is No Documentation Restriction
228 if (HardwareRestriction != 0)
229 {
230 QString licence_name;
231 QSqlDatabase db = QSqlDatabase::database();
232 int row_index = 0;
233 QSqlQuery licence_restriction_query(QString("select short_name from licence where licence_index = %1").arg(QString::number(HardwareRestriction)));
234 while ( licence_restriction_query.next() )
235 {
236 licence_name = licence_restriction_query.value(0).toString();
237 row_index++;
238 }
239
240 if (row_index != 0)
241 {
242 ui->HardwareLicenceList->setCurrentText(licence_name);
243 }
244 }
245 ui->HardwareLicenceList->setEnabled(licence_enabled);
246}

References ui.

Referenced by ReadLicenceState(), and ReadPrimaryTool().

Here is the caller graph for this function:

◆ ProcessSoftwareRestriction()

void LicenceManager::ProcessSoftwareRestriction ( int SoftwareRestriction)
private

Use the Soft Restrictions to limit the possible licence selections.

Parameters
SoftwareRestrictionPosible restriction to Software Licences

Definition at line 172 of file licencemanager.cpp.

173{
174 QString licence_name;
175 bool licence_enabled = true;
176
177 // Check if there is No Software ERestriction
178 if (SoftwareRestriction != 0)
179 {
180 QSqlDatabase db = QSqlDatabase::database();
181 int row_index = 0;
182 QSqlQuery licence_restriction_query(QString("select short_name from licence where licence_index = %1").arg(QString::number(SoftwareRestriction)));
183 while ( licence_restriction_query.next() )
184 {
185 licence_name = licence_restriction_query.value(0).toString();
186 row_index++;
187 }
188
189 if (row_index != 0)
190 {
191 ui->SoftwareLicenceList->setCurrentText(licence_name);
192 licence_enabled = false;
193 }
194 }
195 ui->SoftwareLicenceList->setEnabled(licence_enabled);
196}

References ui.

Referenced by ReadLicenceState(), and ReadPrimaryTool().

Here is the caller graph for this function:

◆ ReadLicenceState

void LicenceManager::ReadLicenceState ( LICENCE_STATE LicenceState)
slot

process the Licence state including any restrictions

Parameters
LicenceStateStructure holding the state of the licences

Definition at line 248 of file licencemanager.cpp.

249{
253}
void ProcessSoftwareRestriction(int DocumentationRestriction)
Use the Soft Restrictions to limit the possible licence selections.
void ProcessDocumentationRestriction(int DocumentationRestriction)
Use the Documenrtation Restrictions to limit the possible licence selections.
void ProcessHardwareRestriction(int HardwareRestriction)
Use the Hardware Restrictions to limit the possible licence selections.

References LICENCE_STATE::DocumentationLicence, LICENCE_STATE::HardwareLicence, ProcessDocumentationRestriction(), ProcessHardwareRestriction(), ProcessSoftwareRestriction(), and LICENCE_STATE::SoftwareLicence.

Here is the call graph for this function:

◆ ReadPrimaryTool

void LicenceManager::ReadPrimaryTool ( int ToolIndex)
slot

read Primary Tool & Apply any licence Restrictions

Definition at line 117 of file licencemanager.cpp.

118{
119 // Assume No Restrictions will be found
120 ui->SoftwareLicenceList->setEnabled(true);
121 ui->DocumentationLicenceList->setEnabled(true);
122 ui->HardwareLicenceList->setEnabled(true);
123
124 QSqlDatabase db = QSqlDatabase::database();
125
126 // See if there is a Licence Restriction for this Tool from Database
127 QSqlQuery tool_restriction_query( QString("select software_licence_restriction, documentation_licence_restriction, hardware_licence_restriction from compiler_instance where compiler_instance_index = %1").arg(QString::number(ToolIndex+1)));
128
129 // Find Any Licence Restrictions for the Primary Tool
130 int row_index = 0;
131 int software_restriction; int documentation_restriction; int hardware_restriction;
132 while ( tool_restriction_query.next() )
133 {
134 software_restriction = tool_restriction_query.value(0).toInt();
135 documentation_restriction = tool_restriction_query.value(1).toInt();
136 hardware_restriction = tool_restriction_query.value(2).toInt();
137 row_index++;
138 }
139
140 // If Entries were found for the Primary Tool, Process Them
141 if (row_index != 0)
142 {
143 // Process Software Licemce Exceptions (if any)
144 bool do_software_restriction = true;
145
146 // Apply Special Exceptions (if any)
147 if ((ToolIndex == 2) &&(ui->QtLicenceList->currentIndex() != 0)) do_software_restriction = false;
148
149 // Process the Software Restrictions
150 if (do_software_restriction) ProcessSoftwareRestriction(software_restriction);
151
152 // Process Software Licemce Exceptions (if any)
153 bool do_documentation_restriction = false;
154
155 // Apply Special Exceptions (if any)
156
157
158 // Process the Documenttaion Restrictions
159 if (do_documentation_restriction) ProcessDocumentationRestriction(documentation_restriction);
160
161 // Process Software Licemce Exceptions (if any)
162 bool do_hardware_restriction = false;
163
164 // Apply Special Exceptions (if any)
165
166
167 // Process the Software Restrictions
168 if (do_hardware_restriction) ProcessHardwareRestriction(hardware_restriction);
169 }
170}

References ProcessDocumentationRestriction(), ProcessHardwareRestriction(), ProcessSoftwareRestriction(), and ui.

Here is the call graph for this function:

◆ SaveQtLicence

void LicenceManager::SaveQtLicence ( void )
slot

Save the Default Qt Licence to settings.

Definition at line 100 of file licencemanager.cpp.

101{
102 // Open the Settings Data
103 QSettings settings( "brigadoon/netprojectmanager" );
104 settings.setValue( "Qt/Licence", ui->QtLicenceList->currentText());
105 LogAdd(LOG_INFO, MODE_CONFIG, QString("Qt Licence for Site saved as %1.").arg(ui->QtLicenceList->currentText()));
106}
@ LOG_INFO
Definition logger.h:55

References LOG_INFO, LogAdd(), MODE_CONFIG, and ui.

Here is the call graph for this function:

◆ SendLicenceState

void LicenceManager::SendLicenceState ( LICENCE_STATE LicenceState)
signal

Send the State of the Licences.

Parameters
Structureholding Licence Information

Referenced by WriteLicenceState().

Here is the caller graph for this function:

◆ SendLogEntry

void LicenceManager::SendLogEntry ( REMOTE_LOG_ENTRY LogEntry)
signal

Send Log Entry to the Log \LogEntry Structure holding Log information.

Referenced by LogAdd().

Here is the caller graph for this function:

◆ SendStatusMessage()

void LicenceManager::SendStatusMessage ( QString Type,
int Counter )
private

Send the Type of Licence and the number licences loaded.

Parameters
TypeThe Type of Licence in text
CounterThe number Licences of that Type loaded

Definition at line 80 of file licencemanager.cpp.

81{
82 if (Counter > 0)
83 {
84 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("%1 Loaded with %2 entries.").arg(Type, QString::number(Counter)));
85 }
86 else
87 {
88 LogAdd(LOG_ERROR, MODE_DATABASE, QString("%1 FAILED to load any entries.").arg(Type, Counter));
89 }
90}
@ LOG_ERROR
Definition logger.h:52
@ MODE_DATABASE
Definition logger.h:35

References LOG_DEBUG, LOG_ERROR, LogAdd(), and MODE_DATABASE.

Referenced by LoadLicences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDocumentationLicence

void LicenceManager::SetDocumentationLicence ( int LicenceIndex)
privateslot

Set the Documentation Licence.

Parameters
LicenceIndex

Definition at line 298 of file licencemanager.cpp.

299{
300 QString LicenceName = ui->DocumentationLicenceList->itemText(LicenceIndex);
301 emit UpdateDocumentationLicence(LicenceName);
302}
void UpdateDocumentationLicence(QString LicenceName)
Emits the Text Name of the Documentation Lidence.

References ui, and UpdateDocumentationLicence().

Here is the call graph for this function:

◆ SetHardwareLicence

void LicenceManager::SetHardwareLicence ( int LicenceIndex)
privateslot

Set the Hardware Licence.

Parameters
LicenceIndex

Definition at line 292 of file licencemanager.cpp.

293{
294 QString LicenceName = ui->HardwareLicenceList->itemText(LicenceIndex);
295 emit UpdateHardwareLicence(LicenceName);
296}
void UpdateHardwareLicence(QString LicenceName)
Emits the Text Name of the Hardware Lidence.

References ui, and UpdateHardwareLicence().

Here is the call graph for this function:

◆ SetSoftwareLicence

void LicenceManager::SetSoftwareLicence ( int LicenceIndex)
privateslot

Set the Software Licence.

Parameters
LicenceIndex

Definition at line 286 of file licencemanager.cpp.

287{
288 QString LicenceName = ui->SoftwareLicenceList->itemText(LicenceIndex);
289 emit UpdateSoftwareLicence(LicenceName);
290}
void UpdateSoftwareLicence(QString LicenceName)
Emits the Text Name of the Software Lidence.

References ui, and UpdateSoftwareLicence().

Here is the call graph for this function:

◆ TriggerSendLicence

void LicenceManager::TriggerSendLicence ( void )
slot

Trigger to send out the Licence states.

Definition at line 275 of file licencemanager.cpp.

276{
277 LogAdd(LOG_DEBUG, MODE_QT, "Request to Send Licences Received.");
279}
void WriteLicenceState(void)
Read the Current Lilcence Stae on Display & Send out.
@ MODE_QT
Definition logger.h:23

References LOG_DEBUG, LogAdd(), MODE_QT, and WriteLicenceState().

Here is the call graph for this function:

◆ UpdateDocumentationLicence

void LicenceManager::UpdateDocumentationLicence ( QString LicenceName)
signal

Emits the Text Name of the Documentation Lidence.

Referenced by SetDocumentationLicence().

Here is the caller graph for this function:

◆ UpdateHardwareLicence

void LicenceManager::UpdateHardwareLicence ( QString LicenceName)
signal

Emits the Text Name of the Hardware Lidence.

Referenced by SetHardwareLicence().

Here is the caller graph for this function:

◆ UpdateSoftwareLicence

void LicenceManager::UpdateSoftwareLicence ( QString LicenceName)
signal

Emits the Text Name of the Software Lidence.

Referenced by SetSoftwareLicence().

Here is the caller graph for this function:

◆ WriteLicenceState()

void LicenceManager::WriteLicenceState ( void )

Read the Current Lilcence Stae on Display & Send out.

Definition at line 255 of file licencemanager.cpp.

256{
257 LICENCE_STATE project_licences;
258 project_licences.SoftwareLicence = GetLicenceIndex(ui->SoftwareLicence->text());
259 project_licences.DocumentationLicence = GetLicenceIndex(ui->SoftwareLicence->text());
260 project_licences.HardwareLicence = GetLicenceIndex(ui->HardwareLicence->text());
261 emit SendLicenceState(project_licences);
262}
uint GetLicenceIndex(QString LicenceText)
Find the Licence Index from the Licence text.
void SendLicenceState(LICENCE_STATE LicenceState)
Send the State of the Licences.

References LICENCE_STATE::DocumentationLicence, GetLicenceIndex(), LICENCE_STATE::HardwareLicence, SendLicenceState(), LICENCE_STATE::SoftwareLicence, and ui.

Referenced by TriggerSendLicence().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ primary_tool_index

int LicenceManager::primary_tool_index
private

Index of the Primary Tool.

Definition at line 86 of file licencemanager.h.

◆ qt_licence_index

int LicenceManager::qt_licence_index
private

Index of the Qt Licence.

Definition at line 92 of file licencemanager.h.

◆ ui


The documentation for this class was generated from the following files: