Project Documentation Manager BRIGADOON-0002
Project Documentation Manager
Loading...
Searching...
No Matches
projectidentifier.cpp
Go to the documentation of this file.
2#include "projectidentifier.h"
3#include <QSqlDatabase>
4#include <QSqlQuery>
5#include <QFileDialog>
6
8
9ProjectIdentifier::ProjectIdentifier(Ui::MainWindow* UI_Window)
10{
11 ui = UI_Window;
15
16 // Preset the Preferred Site
17 QSettings settings( "brigadoon/netprojectmanager" );
18 ui->ProjectPrefix->setCurrentText(settings.value( "Project/ProjectSite", "BRIGADOON").toString());
19 ui->ProjectNumberSize->setValue(settings.value("Project/ProjectIdSize", 4).toInt());
20 SetSite(ui->ProjectPrefix->currentIndex() + 1);
21 ui->BuildProgram->setText(qVersion());
22
23 // Set the Save Connection
24 QObject::connect(ui->UpdateProjectIdSettings, SIGNAL(pressed()), this, SLOT(SavePreferredProject()));
25 QObject::connect(ui->SelectProjectIcon, SIGNAL(pressed()), this, SLOT(SelectIconImage()));
26 QObject::connect(ui->ProjectName, SIGNAL(textChanged(QString)), this, SLOT(UpdateProjectName(QString)));
27 QObject::connect(ui->DepartureURL, SIGNAL(textChanged(QString)), this, SLOT(UpdateDepartureURL(QString)));
28 QObject::connect(ui->ProjectIcon, SIGNAL(textChanged(QString)), this, SLOT(UpdateProjectIcon(QString)));
29 QObject::connect(ui->BriefDescription, SIGNAL(textChanged(QString)), this, SLOT(UpdateProjectBrief(QString)));
30 QObject::connect(ui->ProjectContactList, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateProjectContact(int)));
31 QObject::connect(ui->InAssociationList, SIGNAL(currentIndexChanged(int)), this, SLOT (UpdateInAssociation(int)));
32}
33
35{
36 // Clear the List
37 ui->ProjectPrefix->clear();
38
39 QSqlQuery site_list_query("select project_prefix, suffix_size from project_manager");
40
41 // Step through the Results
42 int row_index = 0;
43 while ( site_list_query.next() )
44 {
45 QString project_prefix = site_list_query.value(0).toString();
46 int suffix_size = site_list_query.value(1).toInt();
47 ui->ProjectPrefix->addItem(project_prefix, suffix_size);
48 row_index++;
49 }
50 if (row_index == 0) LogAdd(LOG_ERROR, MODE_DATABASE, "Failed to Read Project Identifiers from table \"project_manager\"");
51 else LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Read %1 Site name entries from table \"project_manager\"").arg(QString::number(row_index)));
52}
53
55{
56 // Clear the List
57 ui->ProjectContactList->clear();
58
59 QSqlQuery contact_list_query("select developer_index, developer_handle, developer_name from developer");
60
61 // Step through the Results
62 int row_index = 0;
63 while ( contact_list_query.next() )
64 {
65 int developer_index = contact_list_query.value(0).toInt();
66 QString developer_handle = contact_list_query.value(1).toString();
67 QString developer_name = contact_list_query.value(2).toString();
68 QString list_entry = QString("%1 (%2)").arg(developer_handle, developer_name);
69 ui->ProjectContactList->addItem(list_entry, developer_index);
70 row_index++;
71 }
72 if (row_index == 0) LogAdd(LOG_ERROR, MODE_DATABASE, "Failed to Read Contacts from table \"developer\"");
73 else LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Read %1 developers from table \"developer\"").arg(QString::number(row_index)));
74}
75
77{
78 // Get a List of the Projects from Database
79 QString query_string_template = QString("select * from project_manager where proj_manager_index = %1");
80 QString query_string = QString(query_string_template).arg(QString::number(SiteId));
81 QSqlQuery proj_man_query(query_string);
82
83 // Step through the Results
84 int row_index = 0;
85 while ( proj_man_query.next() )
86 {
87 project_information.ProgramInformation.ProjectPrefix = proj_man_query.value(PM_PROJ_MANAGER_INDEX).toString();
88
89 project_information.ProgramInformation.SuffixSize = proj_man_query.value(PM_SUFFIX_SIZE).toInt();
90
91 project_information.ProgramInformation.SharedTemplateDirectory = proj_man_query.value(PM_SHARED_TEMPLATE_DIR).toString();
92 ui->SharedTemplateDir->setText(project_information.ProgramInformation.SharedTemplateDirectory);
93
94 project_information.ProgramInformation.LocalDevelopmentDirectory = proj_man_query.value(PM_LOCAL_DEV_DIRECTORY).toString();
95 ui->LocalDevDirectory->setText(project_information.ProgramInformation.LocalDevelopmentDirectory);
96
97 project_information.ProgramInformation.PrimaryWebsiteDirectory = proj_man_query.value(PM_PRIMARY_WEBSITE_DIRECTORY).toString();
98 ui->PrimaryWebsiteDirectory->setText(project_information.ProgramInformation.PrimaryWebsiteDirectory);
99
100 project_information.ProgramInformation.SiteName = proj_man_query.value(PM_SITE_NAME).toString();
101
102 project_information.ProgramInformation.SiteURL = proj_man_query.value(PM_SITE_URL).toString();
103 ui->SiteURL->setText(project_information.ProgramInformation.SiteURL);
104
105 project_information.ProgramInformation.DevelopmentDoxyDocDirectory = proj_man_query.value(PM_PROJECT_DEVELOPMENT_DOXY_DIRECTORY).toString();
106 ui->ProjDevDoxyDocDir->setText(project_information.ProgramInformation.DevelopmentDoxyDocDirectory);
107
108 project_information.ProgramInformation.SiteLogo = proj_man_query.value(PM_SITE_LOGO).toString();
109 ui->SiteLogo->setText(project_information.ProgramInformation.SiteLogo);
110
111 project_information.ProgramInformation.PublisherName = proj_man_query.value(PM_PUBLISHER_NAME).toString();
112 ui->PublisherName->setText(project_information.ProgramInformation.PublisherName);
113
114 project_information.ProgramInformation.PublisherWebsite = proj_man_query.value(PM_PUBLISHER_WEBSITE).toString();
115 ui->PublisherWebsite->setText(project_information.ProgramInformation.PublisherWebsite);
116
117 project_information.ProgramInformation.PublisherContactEmail = proj_man_query.value(PM_PUBLISHER_CONTACT_EMAIL).toString();
118 ui->PublisherEmail->setText(project_information.ProgramInformation.PublisherContactEmail);
119
120 project_information.ProgramInformation.ProjectListHeaderFilename = proj_man_query.value(PM_PROJECT_LIST_HEADER_FILENAME).toString();
121 ui->ProjectListHeaderFile->setText(project_information.ProgramInformation.ProjectListHeaderFilename);
122
123 project_information.ProgramInformation.ProjectListFooterFilename = proj_man_query.value(PM_PROJECT_LIST_FOOTER_FILENAME).toString();
124 ui->ProjectListFooterFile->setText(project_information.ProgramInformation.ProjectListFooterFilename);
125
126 project_information.ProgramInformation.ProjectListLineFilename = proj_man_query.value(PM_PROJECT_LIST_LINE_FILENAME).toString();
127 ui->ProjectListLineFile->setText(project_information.ProgramInformation.ProjectListLineFilename);
128
129 project_information.ProgramInformation.ProjectListWebpageFilename = proj_man_query.value(PM_PROJECT_LIST_WEBPAGE_FILENAME).toString();
130 ui->ProjectListWebTableFile->setText(project_information.ProgramInformation.ProjectListWebpageFilename);
131
132 project_information.ProgramInformation.ProjectListWebpageFilename = proj_man_query.value(PM_PROJECT_LIST_OPENSIM_FILENAME).toString();
133 ui->ProjectListOSTableFile->setText(project_information.ProgramInformation.ProjectListWebpageFilename);
134
135 project_information.ProgramInformation.DefaultReturnAddress = proj_man_query.value(PM_PROJECT_LIST_RETURN_ADDRESS).toString();
136 ui->DefaultReturnAddress->setText(project_information.ProgramInformation.DefaultReturnAddress);
137
138 QPixmap the_pixmap(project_information.ProgramInformation.SiteLogo);
139 ui->SiteLogo->setPixmap(the_pixmap.scaledToWidth(140));
140
141 row_index++;
142 }
143
144 if (row_index == 0) LogAdd(LOG_ERROR, MODE_DATABASE, "Failed to Read Project Identifiers from table \"project_mqanater\"");
145 else LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Read Project Prefix \"%1\" and Suffix Size \"%2\" from table \"project_manager\"").arg(project_information.ProgramInformation.ProjectPrefix, QString::number(project_information.ProgramInformation.SuffixSize)));
146}
147
148void ProjectIdentifier::LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, QString Message)
149{
150 REMOTE_LOG_ENTRY log_entry;
151 log_entry.Severity = Severity;
152 log_entry.Mode = Mode;
153 log_entry.Message = Message;
154 emit SendLogEntry(log_entry);
155}
156
158{
159 int index = ui->ProjectPrefix->currentIndex() + 1;
160 SetSite(index);
161 QSettings settings("brigadoon/netprojectmanager");
162 settings.setValue("Project/ProjectSite", ui->ProjectPrefix->currentText());
163 settings.setValue("Project/ProjectIdSize", ui->ProjectNumberSize->value());
164 ui->SharedTemplateDir->setText(project_information.ProgramInformation.SharedTemplateDirectory);
165 ui->LocalDevDirectory->setText(project_information.ProgramInformation.LocalDevelopmentDirectory);
166 ui->PrimaryWebsiteDirectory->setText(project_information.ProgramInformation.PrimaryWebsiteDirectory);
167 ui->PublisherName->setText(project_information.ProgramInformation.PublisherName);
168 ui->PublisherWebsite->setText(project_information.ProgramInformation.PublisherWebsite);
169 ui->PublisherEmail->setText(project_information.ProgramInformation.PublisherContactEmail);
170}
171
172
174{
175 // Clear the List
176 ui->InAssociationList->clear();
177
178 QSqlQuery association_list_query("select short_name, in_assoc_index from in_association");
179
180 // Step through the Results
181 int row_index = 0;
182 while ( association_list_query.next() )
183 {
184 QString associate = association_list_query.value(0).toString();
185 int associate_index = association_list_query.value(1).toInt();
186 ui->InAssociationList->addItem(associate, associate_index);
187 row_index++;
188 }
189 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Added %1 entries to the In-Association List from table \"in_association\"").arg(QString::number(row_index)));
190}
191
193{
194 QString directory_name;
195 QString selected_file;
196 if (ui->ProjectIdent->text().isEmpty())
197 {
198 directory_name = "";
199 }
200 else
201 {
202 directory_name = ui->LocalDevDirectory->text() + "/" + ui->ProjectIdent->text();
203 }
204 selected_file = GetFile( directory_name );
205 if ( selected_file != "" )
206 {
207 ui->ProjectIcon->setText( selected_file );
208 }
209}
210
211QString ProjectIdentifier::GetFile( QString InitialName )
212{
213 QString file_name = QFileDialog::getOpenFileName(nullptr, "Select Project's Icon", InitialName, "*.png *.xpm *.jpg *.svg");
214 if (file_name == "")file_name = InitialName;
215
216 return(file_name);
217}
218
220{
221 LoadSiteList();
224 ui->ProjectName->clear();
225 ui->ProjectIcon->clear();
226 ui->ProjectIdent->clear();
227 ui->BriefDescription->clear();
228 ui->DepartureURL->clear();
229}
230
232{
233 LICENCE_STATE licence_state;
234 DEVELOPMENT_FAMILY dev_family;
235 REMOTE_VERSION_ENTRY version_info;
236
237 QString project_prefix = ui->ProjectPrefix->currentText();
238 int suffix_size = ui->ProjectPrefix->currentData().toInt();
239
240 LogAdd(LOG_DEBUG, MODE_GENERAL, QString("Starting Initial Project Loading"));
241
242 ui->ProjectName->setText(ProjectId->ProjectDesc.ProjectName);
243 ui->ProjectIdent->setText( project_prefix + "-" + QString::number(ProjectId->ProjectDesc.ProjectIndex).rightJustified(suffix_size, '0'));
244 ui->ProjectIcon->setText(ProjectId->ProjectDesc.ProjectIcon);
245 ui->BriefDescription->setText(ProjectId->ProjectDesc.BriefDescription);
246 ui->DepartureURL->setText(ProjectId->ProjectDesc.DepartureURL);
247 ui->ExecutableDirectory->setText(ProjectId->ProjectDesc.ExeDirectory);
248 ui->ExecutableName->setText(ProjectId->ProjectDesc.ExeName);
249 dev_family.DevelopmentFamily = ProjectId->DevFamilyInfo.DevFamilyIndex;
250 dev_family.LanguageFamily = ProjectId->LangFamilyInfo.LangFamilyIndex;
251 dev_family.CompilerFamily = ProjectId->CompFamilyInfo.CompFamilyIndex;
252 dev_family.TargetFamily = ProjectId->TargetFamilyInfo.TargetFamilyIndex;
253 emit SendDevelopmentFamily(dev_family);
254
255 licence_state.DocumentationLicence = ProjectId->DocLicence.LicenceIndex;
256
257 licence_state.SoftwareLicence = ProjectId->SoftwareLicence.LicenceIndex;
258
259 licence_state.HardwareLicence = ProjectId->HardwareLicence.LicenceIndex;
260 emit SendLicenceState(licence_state);
261 version_info.ProjectNumber = ProjectId->ProjectDesc.ProjectIndex;
262 version_info.VersionInfo.MajorVersion = ProjectId->VersionInfo.MajorVersion;
263 version_info.VersionInfo.MinorVersion = ProjectId->VersionInfo.MinorVersion;
264 version_info.VersionInfo.Revision = ProjectId->VersionInfo.Revision;
265 version_info.VersionInfo.VersionDate = ProjectId->StatusInfo.StatusDateTime;
266}
267
269{
270 emit SendProjectName(ProjectName);
271}
272
274{
275 emit SendProjectIcon(ProjectIcon);
276}
277
279{
280 emit SendDepartureURL(DepartureURL);
281}
282
284{
285 emit SendProjectBrief(ProjectBrief);
286}
287
289{
290 emit SendProjectContact(ui->ProjectContactList->itemText(ContactIndex));
291}
292
294{
295 QString group_name = ui->InAssociationList->itemText(Index);
297}
void ReadProjectId(PROJECT_INFORMATION *ProjectId)
Read the Project Identifiers from Disk.
void SendInAssociation(QString InAssocGroup)
Send Associated Group name via signal/slot.
void LoadSiteList(void)
Load the Site Name List from Database.
void LoadInAssociationList(void)
Read known Association Lilst from Database.
Ui::MainWindow * ui
Pointer to the Main Window.
void SendLicenceState(LICENCE_STATE LicenceState)
Send the Licence State using Signal Slot.
void UpdateProjectContact(int Index)
Update Project Contact from User Interface.
void SetSite(int SiteId)
Set the Destination Site using the Site Index.
void UpdateInAssociation(int Index)
Update Associated Organisation from User Interface.
void DoClear()
Clear User Interface of Project identifiers.
void SendProjectName(QString ProjectName)
void LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, QString Message)
Send Message to the Log.
void SendProjectIcon(QString ProjectIcon)
void SavePreferredProject(void)
Save the Preferred Project and related Information.
void UpdateProjectName(QString Name)
Update Project Name from User Interface.
void UpdateProjectIcon(QString Name)
Update Project Icon from User Interface.
void SendLogEntry(REMOTE_LOG_ENTRY LogEntry)
Send Log Entry to the Log \LogEntry Structure holding Log information.
QString GetFile(QString InitialName)
Read contents of file into string.
void LoadContactList(void)
Load Contact List from the Database.
void SendDepartureURL(QString DepartureURL)
void SendProjectBrief(QString ProjectBrief)
Send Project Brief Description via signal/slot.
void UpdateDepartureURL(QString Name)
Update Departure URL from User Interface.
void UpdateProjectBrief(QString Name)
Update Project Brief Description from User Interface.
ProjectIdentifier(Ui::MainWindow *UI_Window)
ProjectIdentifier Class Constructor.
void SendProjectContact(QString ProjectContact)
Send Project Contact name via signal/slot.
void SelectIconImage(void)
Select Icon triggered by User Selection.
void SendDevelopmentFamily(DEVELOPMENT_FAMILY DevFamily)
Send the Development Family using Signal Slot.
Common Structure Defintitions.
@ PM_PROJECT_LIST_FOOTER_FILENAME
@ PM_PUBLISHER_CONTACT_EMAIL
@ PM_PROJECT_DEVELOPMENT_DOXY_DIRECTORY
@ PM_PUBLISHER_NAME
@ PM_SITE_URL
@ PM_PROJECT_LIST_RETURN_ADDRESS
@ PM_PROJ_MANAGER_INDEX
@ PM_SHARED_TEMPLATE_DIR
@ PM_PROJECT_LIST_HEADER_FILENAME
@ PM_PROJECT_LIST_OPENSIM_FILENAME
@ PM_LOCAL_DEV_DIRECTORY
@ PM_PROJECT_LIST_WEBPAGE_FILENAME
@ PM_PRIMARY_WEBSITE_DIRECTORY
@ PM_PROJECT_LIST_LINE_FILENAME
@ PM_PUBLISHER_WEBSITE
@ PM_SITE_NAME
@ PM_SITE_LOGO
@ PM_SUFFIX_SIZE
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
@ MODE_GENERAL
Definition logger.h:24
PROJECT_INFORMATION project_information
Project Identifier Class.
Summary of Project Types.
Assigned Software, Hardware and COgumenttaion Licences.
Project Information Passed Between Functions.
TARGET_FAMILY_INFO TargetFamilyInfo
DEV_FAMILY_INFO DevFamilyInfo
PROJECT_DESCRIPTION ProjectDesc
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
Version Structure used between functions.
VERSION_INFO VersionInfo
uint ProjectNumber
QDateTime StatusDateTime