Project Documentation Manager BRIGADOON-0002
Project Documentation Manager
Loading...
Searching...
No Matches
developmentfamily.cpp
Go to the documentation of this file.
1#include <QSqlDatabase>
2#include <QSqlQuery>
3#include "developmentfamily.h"
4
5DevelopmentFamily::DevelopmentFamily(Ui::MainWindow* UI_Window)
6{
7 // Save the Pointer to the Main Window & Pointer to Log
8 ui = UI_Window;
9 QObject::connect(ui->PrimaryTool, SIGNAL(currentIndexChanged(int)), this, SLOT(PrimaryToolChanged(int)));
10 QObject::connect(ui->DevelopmentFamily, SIGNAL(currentIndexChanged(int)), this, SLOT(PostDevelopmentFamily()));
11 QObject::connect(ui->LanguageFamily, SIGNAL(currentIndexChanged(int)), this, SLOT(PostDevelopmentFamily()));
12 QObject::connect(ui->TargetFamily, SIGNAL(currentIndexChanged(int)), this, SLOT(PostDevelopmentFamily()));
13}
14
16{
17 QSqlDatabase db = QSqlDatabase::database();
18
19 // Clear the Development Family List
20 ui->DevelopmentFamily->clear();
21
22 // Get a List of the Development Families from Database
23 QSqlQuery dev_family_query( "select dev_family_index, short_name from dev_family" );
24
25 // Step through the Results
26 int row_index = 0;
27 while ( dev_family_query.next() )
28 {
29 int dev_family_index = dev_family_query.value(0).toInt();
30 QString development_entry = dev_family_query.value(1).toString();
31 ui->DevelopmentFamily->addItem( development_entry, dev_family_index );
32 row_index++;
33 }
34 SendStatusMessage("Development Family", row_index);
35
36 // Clear the Language Family List
37 ui->LanguageFamily->clear();
38
39 // Get a List of the Language from Database
40 QSqlQuery lang_family_query( "select comp_family_index, short_name from compiler_family" );
41
42 // Step through the Results
43 row_index = 0;
44 while ( lang_family_query.next() )
45 {
46 int comp_family_index = lang_family_query.value(0).toInt();
47 QString language_entry = lang_family_query.value(1).toString();
48 ui->LanguageFamily->addItem( language_entry, comp_family_index );
49 row_index++;
50 }
51 SendStatusMessage("Language Family", row_index);
52
53 ui->PrimaryTool->clear();
54 // Get a List of the Major Compiler/Tools from Database
55 QSqlQuery comp_instance_query( "select compiler_instance_index, short_name from compiler_instance" );
56
57 // Step through the Results
58 row_index = 0;
59 while ( comp_instance_query.next() )
60 {
61 int comp_instance_index = comp_instance_query.value(0).toInt();
62 QString compiler_instance = comp_instance_query.value(1).toString();
63 ui->PrimaryTool->addItem( compiler_instance, comp_instance_index );
64 row_index++;
65 }
66 SendStatusMessage("Primary Tool", row_index);
67
68 // Clear the Development Family List
69 ui->TargetFamily->clear();
70
71 // Get a List of the Target System Families from Database
72 QSqlQuery target_family_query( "select target_family_index, short_name from target_family" );
73
74 // Step through the Results
75 row_index = 0;
76 while ( target_family_query.next() )
77 {
78 int target_family_index = target_family_query.value(0).toInt();
79 QString target_entry = target_family_query.value(1).toString();
80 ui->TargetFamily->addItem( target_entry, target_family_index );
81 row_index++;
82 }
83 SendStatusMessage("Target Family", row_index);
84}
85
86void DevelopmentFamily::SendStatusMessage(QString Type, int Counter)
87{
88 if (Counter > 0)
89 {
90 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("%1 Loaded with %2 entries.").arg(Type, QString::number(Counter)));
91 }
92 else
93 {
94 LogAdd(LOG_ERROR, MODE_DATABASE, QString("%1 FAILED to load any entries.").arg(Type, Counter));
95 }
96}
97
98void DevelopmentFamily::LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString Message)
99{
100 REMOTE_LOG_ENTRY log_entry;
101 log_entry.Severity = Severity;
102 log_entry.Mode = Mode;
103 log_entry.Message = Message;
104 emit SendLogEntry(log_entry);
105}
106
112
114{
115 ui->DevelopmentFamily->setCurrentIndex(ui->DevelopmentFamily->findData(ProjectId->DevFamilyInfo.DevFamilyIndex));
116 ui->LanguageFamily->setCurrentIndex(ui->LanguageFamily->findData(ProjectId->LangFamilyInfo.LangFamilyIndex));
117 ui->PrimaryTool->setCurrentIndex(ui->PrimaryTool->findData(ProjectId->CompFamilyInfo.CompFamilyIndex));
118 ui->TargetFamily->setCurrentIndex(ui->TargetFamily->findData(ProjectId->TargetFamilyInfo.TargetFamilyIndex));
119}
120
122{
123 DEVELOPMENT_FAMILY DevFamily;
124 DevFamily.LanguageFamily = ui->LanguageFamily->currentData().toInt();
125 DevFamily.LanguageFamilyString = ui->LanguageFamily->currentText();
126 DevFamily.DevelopmentFamilyString = ui->DevelopmentFamily->currentText();
127 DevFamily.DevelopmentFamily = ui->DevelopmentFamily->currentData().toInt();
128 DevFamily.CompilerFamilyString = ui->PrimaryTool->currentText();
129 DevFamily.CompilerFamily = ui->PrimaryTool->currentData().toInt();
130 DevFamily.TargetFamilyString = ui->TargetFamily->currentText();
131 DevFamily.TargetFamily = ui->TargetFamily->currentData().toInt();
132
133 emit SendDevelopmentFamily(DevFamily);
134}
135
136/*QString DevelopmentFamily::ReadDevNameFromIndex(int Index)
137{
138 QString dev_family_name;
139
140 QSqlQuery read_dev_name_query(QString("select short_name from dev_family where dev_family_index = %1").arg(QString::number(Index)));
141 while (read_dev_name_query.next())
142 {
143 dev_family_name = read_dev_name_query.value(0).toString();
144 }
145 return(dev_family_name);
146}
147*/
void ReadProjectId(PROJECT_INFORMATION *ProjectId)
Read the Development, Compiler, Primary Tool and Target System Name.
Ui::MainWindow * ui
void PostDevelopmentFamily(void)
take signal from widget and broadcast new status
void SendPrimaryToolChanged(int Index)
Advertise a change to the Primary Tool.
void SendStatusMessage(QString Type, int Counter)
Send the Data Type and number of entries obtained.
DevelopmentFamily(Ui::MainWindow *UI_Window)
DevelopmentFamily Constructor.
void SendDevelopmentFamily(DEVELOPMENT_FAMILY DevFamily)
Advertise out the current state of the development families.
void LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString Message)
Send Message to the Log.
void DoClear(void)
Reload the Development Famlies.
void PrimaryToolChanged(int Index)
Receive signal that Primary Tool has Changed & process.
void LoadDevelopmentFamilies(void)
void SendLogEntry(REMOTE_LOG_ENTRY LogEntry)
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_DATABASE
Definition logger.h:35
Summary of Project Types.
Project Information Passed Between Functions.
TARGET_FAMILY_INFO TargetFamilyInfo
DEV_FAMILY_INFO DevFamilyInfo
COMP_FAMILY_INFO CompFamilyInfo
LANG_FAMILY_INFO LangFamilyInfo
Definition logger.h:60
LOGGING_MODE Mode
Definition logger.h:61
QString Message
Definition logger.h:63
LOGGING_SEVERITY Severity
Definition logger.h:62