Project Documentation Manager BRIGADOON-0002
Project Documentation Manager
Loading...
Searching...
No Matches
projectdocmanager.cpp
Go to the documentation of this file.
2#include "projectdocmanager.h"
4#include "projectsubstitute.h"
5#include "doxygenmanager.h"
6#include "readprojectinfo.h"
7#include <QMessageBox>
8#include <QProcess>
9
15
16
24
25ProjectDocManager::ProjectDocManager(Ui::MainWindow* UI_Window)
26{
27 ui = UI_Window;
28
29 // Connect to the Relevant Controls
30 QObject::connect(ui->ControlDocAccess, SIGNAL(stateChanged(int)), this, SLOT(SetDocAccess(int)));
31 QObject::connect(ui->EnableDoxyOptions, SIGNAL(stateChanged(int)), this, SLOT(SetDoxyOptions(int)));
32 QObject::connect(ui->DonationsWelcome, SIGNAL(stateChanged(int)), this, SLOT(SetDonationsWelcome(int)));
33 QObject::connect(ui->GetDoxyLogo, SIGNAL(pressed()), this, SLOT(GetDoxyLogo()));
34 QObject::connect(ui->GetDoxyHeader, SIGNAL(pressed()), this, SLOT(GetDoxyHeader()));
35 QObject::connect(ui->GetDoxyFooter, SIGNAL(pressed()), this, SLOT(GetDoxyFooter()));
36 QObject::connect(ui->GetDoxyStylesheet, SIGNAL(pressed()), this, SLOT(GetDoxyStylesheet()));
37 QObject::connect(ui->EnableProjectEdit, SIGNAL(stateChanged(int)), this, SLOT(SetEditState(int)));
38 QObject::connect(ui->SelectProjectList, SIGNAL(activated(int)), this, SLOT(ReadActivated(int)));
39 QObject::connect(ui->CreateNewProject, SIGNAL(pressed()), this, SLOT(StartProject()));
40 QObject::connect(ui->AbortNewProject, SIGNAL(pressed()), this, SLOT(DoEditAbort()));
41}
42
47
49{
50 bool state = (bool)State;
51
52 ui->OnlyInfoPage->setEnabled(state);
53 ui->LimitToAssoc->setEnabled(state);
54}
55
57{
58 bool state = (bool)State;
59
60 ui->OfferPaypal->setEnabled(state);
61}
62
64{
65 bool state = (bool)State;
66
67 ui->DoxygenOptions->setEnabled(state);
68}
69
71{
72 ui->DoxyProjectLogo->setText(GetFile(ui->DoxyProjectLogo->text(), GET_IMAGE_FILE));
73}
74
76{
77 ui->DoxyHeader->setText(GetFile(ui->DoxyHeader->text(), GET_HTML_FILE));
78}
79
81{
82 ui->DoxyFooter->setText(GetFile(ui->DoxyFooter->text(), GET_HTML_FILE));
83}
84
86{
87 ui->DoxyStylesheet->setText(GetFile(ui->DoxyStylesheet->text(), GET_CSS_FILE));
88}
89
90QString ProjectDocManager::GetFile( QString InitialName, GET_FILE_TYPE FileType )
91{
92 QString filter_string;
93 QString prompt_name;
94
95 switch(FileType)
96 {
97 case GET_IMAGE_FILE:
98 filter_string = "*.png *.xpm *.jpg *.svg";
99 prompt_name = "Image";
100 break;
101
102 case GET_HTML_FILE:
103 filter_string = "*.htm *.html";
104 prompt_name = "HTML";
105 break;
106
107 case GET_CSS_FILE:
108 filter_string = "*.css";
109 prompt_name = "CSS";
110 break;
111 }
112
113 QString file_name = QFileDialog::getOpenFileName(nullptr, prompt_name, InitialName, filter_string);
114 if (file_name == "")file_name = InitialName;
115 return(file_name);
116}
117
119{
120 // Clear the Current List
121 ui->SelectProjectList->clear();
122 ui->SelectProjectList->clearEditText();
123
124 // Get the Project Information From the Database
125 QSqlQuery project_list_query("select project_index, project_name, project_lock from project where project_index > 1 order by project_index");
126
127 // List out all the Projects
128 // Step through the Results
129 int row_index = 0;
130 while ( project_list_query.next() )
131 {
132 int project_number = project_list_query.value(0).toInt();
133 QString project_name = project_list_query.value(1).toString();
134 bool project_lock = project_list_query.value(2).toBool();
135 QString list_entry = ui->ProjectPrefix->currentText() + "-" + QString::number(project_number).rightJustified(ui->ProjectNumberSize->value(), '0') + " : " + project_name;
136 if (!project_lock)
137 {
138 ui->SelectProjectList->addItem(list_entry, project_number);
139 row_index++;
140 }
141 else
142 {
143 LogAdd(LOG_INFO, MODE_DATABASE, list_entry + " was not included in list as it is LOCKED.");
144 }
145 }
146 if (row_index == 0)
147 {
148 LogAdd(LOG_INFO, MODE_DATABASE, "No Projects were available for listing.");
149 }
150 else
151 {
152 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("%1 Projects are available for listing.").arg(QString::number(row_index)));
153 }
154};
155
157{
158 bool state = (bool)State;
159 ui->SelectProjectList->setEnabled(!state);
160 ui->CreateNewProject->setEnabled(!State);
161 ui->SelectProjectList->setEnabled(!State);
162 ui->ExecutableName->setReadOnly(!ui->ExecutableName->text().isEmpty());
163 if (state)
164 {
166 ui->SelectProjectList->setEnabled(state);
167 }
168 else
169 {
170 ui->SelectProjectList->clear();
171 ui->SaveProject->setEnabled(false);
172 ui->AbortNewProject->setEnabled(false);
173 emit SendClear();
174 if (current_locked_project != 0) read_project_info->SetProjectStatus(current_locked_project, false, false);
175 }
176}
177
179{
181 emit LoadSubstituteTable();
182 SetEditButtons(true);
183 ui->ExecutableName->setReadOnly(false);
184 ui->SelectProjectList->clearEditText();
185 ui->SelectProjectList->setEnabled(false);
186 ui->CreateNewProject->setEnabled(false);
187 project_info.ProjectDesc.ProjectIndex = 0;
188 emit SendClear();
189 LockSubsButtons(true);
190}
191
192void ProjectDocManager::LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString Message)
193{
194 REMOTE_LOG_ENTRY log_entry;
195 log_entry.Severity = Severity;
196 log_entry.Mode = Mode;
197 log_entry.Message = Message;
198 emit SendLogEntry(log_entry);
199}
200
202{
203 QString item_text = ui->SelectProjectList->itemText(Item);
204 LogAdd(LOG_DEBUG, MODE_OPERATOR, QString("Project %1 selected for editing.").arg(item_text));
205 uint project_index = ui->SelectProjectList->itemData(Item).toInt();
206 if (! read_project_info->SetProjectStatus(project_index, true, false))
207 {
208 ShowMessage(QString("Unable to Reserve Project \"%1\" for Editing").arg(item_text));
209 }
210 else
211 {
212 LoadProjectFromDatabase(project_index);
214 SetEditButtons(true);
215 }
216}
217
219{
220 project_info = ProjectId;
221 //emit SendProjectId(&project_info);
222}
223
225{
226 QMessageBox message_box;
227 message_box.setText(Message);
228 message_box.exec();
229}
230
232{
233 // Clear the Project Display
234 emit SendClear();
235
236 // request the Project Data from the Database
237 QSqlQuery read_project_query(QString("select * from project where project_index = %1").arg(QString::number(Item)));
238 int row_counter = 0;
239 while ( read_project_query.next() )
240 {
241 project_info.ProjectDesc.ProjectIndex = read_project_query.value(PT_PROJECT_INDEX).toInt();
242 project_info.ProjectDesc.ProjectName = read_project_query.value(PT_PROJECT_NAME).toString();
243 project_info.VersionInfo.MajorVersion = read_project_query.value(PT_MAJOR_VERSION).toInt();
244 project_info.VersionInfo.MinorVersion = read_project_query.value(PT_MINOR_VERSION).toInt();
245 project_info.VersionInfo.Revision = read_project_query.value(PT_REVISION).toInt();
246 project_info.ProjectDesc.BriefDescription = read_project_query.value(PT_BRIEF_DESCRIPTION).toString();
247 project_info.DevFamilyInfo.DevFamilyIndex = read_project_query.value(PT_DEV_FAMILY).toInt();
248 project_info.LangFamilyInfo.LangFamilyIndex = read_project_query.value(PT_COMPILER_FAMILY).toInt();
249 project_info.StatusInfo.StatusIndex = read_project_query.value(PT_PROJECT_STATUS).toInt();
250 project_info.ProjectLock = read_project_query.value(PT_PROJECT_LOCK).toBool();
251 project_info.CompFamilyInfo.CompFamilyIndex = read_project_query.value(PT_COMPILER_TYPE).toInt();
252 project_info.StatusInfo.StatusDateTime = read_project_query.value(PT_STATUS_DATE).toDateTime().toLocalTime();
253 project_info.DocLicence.LicenceIndex = read_project_query.value(PT_DOC_LICENCE).toInt();
254 project_info.SoftwareLicence.LicenceIndex = read_project_query.value(PT_SOFTWARE_LICENCE).toInt();
255 project_info.HardwareLicence.LicenceIndex = read_project_query.value(PT_HARDWARE_LICENCE).toInt();
256 project_info.ProjectContact = read_project_query.value(PT_PROJECT_CONTACT).toInt();
257 project_info.ProjectDesc.FullDescription = read_project_query.value(PT_FULL_DESCRIPTION).toString();
258 project_info.ProgramInformation.LocalDevelopmentDirectory = read_project_query.value(PT_PROJECT_DIRECTORY).toString();
259 project_info.ProjectDesc.ProjectIcon = read_project_query.value(PT_ICON_FILENAME).toString();
260 project_info.ProjectDesc.ProjectOptions = read_project_query.value(PT_PROJECT_OPTIONS).toInt();
261 project_info.ProjectDesc.ProjectIdent = read_project_query.value(PT_PROJECT_IDENT).toString();
262 project_info.DoxyOptions.DoxyLogoFilename = read_project_query.value(PT_DOXY_PROJECT_LOGO_FILENAME).toString();
263 project_info.DoxyOptions.DoxyHtmlHeaderFilename = read_project_query.value(PT_DOXY_HTML_HEADER_FILENAME).toString();
264 project_info.DoxyOptions.DoxyHtmlFooterFilename = read_project_query.value(PT_DOXY_HTML_FOOTER_FILENAME).toString();
265 project_info.DoxyOptions.DoxyExtraStylesheetFilename = read_project_query.value(PT_DOXY_EXTRA_STYLESHEET_FILENAME).toString();
266 project_info.InAssocInfo.InAssociationIndex = read_project_query.value(PT_ASSOC_GROUP).toInt();
267 ui->InAssociationList->setCurrentIndex(project_info.InAssocInfo.InAssociationIndex);
268 project_info.ProjectQueued = read_project_query.value(PT_PROJECT_QUEUED).toBool();
269 project_info.TargetFamilyInfo.TargetFamilyIndex = read_project_query.value(PT_TARGET_FAMILY).toInt();
270 project_info.ProjectDesc.DepartureURL = read_project_query.value(PT_DEPARTURE_URL).toString();
271 project_info.ProjectDesc.ExeDirectory = read_project_query.value(PT_EXECUTABLE_DIRECTORY).toString();
272 project_info.ProjectDesc.ExeName = read_project_query.value(PT_EXECUTABLE_NAME).toString();
273 row_counter++;
274 }
275 if (row_counter == 1)
276 {
278 ui->FullDescription->setPlainText(project_info.ProjectDesc.FullDescription);
279 ui->InAssociationList->setCurrentIndex(project_info.InAssocInfo.InAssociationIndex);
280 ui->SelectProjectList->setEnabled(false);
281 }
282 else LogAdd(LOG_ERROR, MODE_DATABASE, QString("Unable to read Project Information for Item %1").arg(QString::number(Item)));
283}
284
286{
287 emit SendClear();
288 SetEditButtons(false);
289 ui->EnableProjectEdit->setChecked(false);
290 ui->FullDescription->clear();
291 ui->PrimaryTool->clear();
292 ui->DepartureURL->clear();
293 ui->ExecutableName->clear();
294 ui->ExecutableName->setReadOnly(true);
295 ui->CreateNewProject->setEnabled(true);
296 ui->EnableStatusEditing->setCheckState(Qt::Unchecked);
297 EnableUserInterface(false);
298 LockProject(project_info.ProjectDesc.ProjectIndex, false);
299 project_info.ProjectDesc.ProjectIndex = 0;
300}
301
302void ProjectDocManager::DoEditSave(void) // To be updated
303{
304 DoEditAbort();
305 LogAdd(LOG_INFO, MODE_DATABASE, "Project Updated to Database.");
306}
307
309{
310 ui->SaveProject->setEnabled(State);
311 ui->AbortNewProject->setEnabled(State);
312 ui->EnableProjectEdit->setEnabled(!State);
313 if (State)
314 {
315 ui->ExecutableName->setReadOnly(!ui->ExecutableName->text().isEmpty());
316 }
317 else
318 {
319 ui->ExecutableName->setReadOnly(true);
320 }
321}
322
324{
325 emit SendSubstituteState(State);
326 ui->ProjectInfoGroupBox->setEnabled(State);
327 ui->ProjectOptionsGroupBox->setEnabled(State);
328}
329
331{
332 if (project_info.ProjectDesc.ProjectIndex != 0)
333 {
335 }
336 else
337 {
338 // Check if the Data is There to Save a Project
339 if (IsSaveAvailable())
340 {
341 // Write the Data to the Project Table
342 ui->ProjectStatusDate->setDateTime(QDateTime::currentDateTime());
344 }
345 else
346 {
347 QMessageBox msgBox;
348 msgBox.setText("Enter all fields with red prompts");
349 msgBox.exec();
350 }
351 }
352}
353
355{
357
358 QString full_description_field_string = ", full_description ";
359
360 // Create Full Description Field Update
361 if (ui->FullDescription->document()->toPlainText().isEmpty())
362 {
363 full_description_field_string += "= null";
364 }
365 else
366 {
367 full_description_field_string += QString("= \"") + ui->FullDescription->document()->toPlainText() + QString("\"");
368 }
369
370 QString project_icon_field_string = "', icon_filename ";
371
372 // Create Project icon Field Update
373 if (ui->ProjectIcon->text().isEmpty())
374 {
375 project_icon_field_string += "= null";
376 }
377 else
378 {
379 project_icon_field_string += QString("= '") + ui->ProjectIcon->text() + QString("'");
380 }
381
382 // Process the doxy Extra Stylesheet Filename
383 QString doxy_extra_field_string = ", doxy_extra_stylesheet_filename ";
384
385 // Create Project icon Field Update
386 if (project_info.DoxyOptions.DoxyExtraStylesheetFilename.isEmpty())
387 {
388 doxy_extra_field_string += "= null";
389 }
390 else
391 {
392 doxy_extra_field_string += QString("= '") + project_info.DoxyOptions.DoxyExtraStylesheetFilename + QString("'");
393 }
394
395 // Process the doxy Extra Stylesheet Filename
396 QString doxy_footer_field_string = ", doxy_html_footer_filename ";
397
398 // Create Project icon Field Update
399 if (project_info.DoxyOptions.DoxyHtmlFooterFilename.isEmpty())
400 {
401 doxy_footer_field_string += "= null";
402 }
403 else
404 {
405 doxy_footer_field_string += QString("= '") + project_info.DoxyOptions.DoxyHtmlFooterFilename + QString("'");
406 }
407
408 // Process the doxy Header Filename
409 QString doxy_header_field_string = ", doxy_html_header_filename ";
410
411 // Create Project icon Field Update
412 if (project_info.DoxyOptions.DoxyHtmlHeaderFilename.isEmpty())
413 {
414 doxy_header_field_string += "= null";
415 }
416 else
417 {
418 doxy_header_field_string += QString("= '") + project_info.DoxyOptions.DoxyHtmlHeaderFilename + QString("'");
419 }
420
421 // Process the doxy Header Filename
422 QString doxy_project_logo_field_string = "', doxy_project_logo_filename ";
423
424 // Create Project icon Field Update
425 if (project_info.DoxyOptions.DoxyLogoFilename.isEmpty())
426 {
427 doxy_project_logo_field_string += "= null";
428 }
429 else
430 {
431 doxy_project_logo_field_string += QString("= '") + project_info.DoxyOptions.DoxyLogoFilename + QString("'");
432 }
433
434 QString update_command_string = QString("UPDATE project SET ")
435 + " project_name = '" + ui->ProjectName->text()
436 + "', major_version = " + QString::number(ui->MajorVersion->value())
437 + ", minor_version = " + QString::number(ui->MinorVersion->value())
438 + ", revision = " + QString::number(ui->Revision->value())
439 + ", brief_description = '" + ui->BriefDescription->text()
440 + "', dev_family = " + QString::number(ui->DevelopmentFamily->currentIndex() + 1)
441 + ", compiler_family = " + QString::number(ui->LanguageFamily->currentIndex() + 1)
442 + ", target_family = " + QString::number(ui->TargetFamily->currentIndex() + 1)
443 + ", project_status = " + QString::number(ui->ProjectStatus->currentIndex() + 1)
444 + ", project_lock = false"
445 + ", compiler_type = " + QString::number(ui->PrimaryTool->currentIndex() + 1)
446 + ", status_date = '" + ui->ProjectStatusDate->dateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")
447 + "', doc_licence = " + QString::number(GetLicenceIndex(ui->DocumentationLicenceList->currentText()))
448 + ", software_licence = " + QString::number(GetLicenceIndex(ui->SoftwareLicenceList->currentText()))
449 + ", hardware_licence = " + QString::number(GetLicenceIndex(ui->HardwareLicenceList->currentText()))
450 + ", project_contact = " + QString::number(ui->ProjectContactList->currentIndex() + 1)
451 + full_description_field_string
452 + ", project_directory = '" + (ui->LocalDevDirectory->text() + "/" + ui->ProjectIdent->text())
453 + project_icon_field_string
454 + ", project_options = " + QString::number(project_opts_manager->WriteOptionState())
455 + ", project_ident = '" + ui->ProjectIdent->text()
456 + doxy_project_logo_field_string
457 + doxy_header_field_string
458 + doxy_footer_field_string
459 + doxy_extra_field_string
460 + ", assoc_group =" + QString::number(ui->InAssociationList->currentIndex())
461 + ", project_queued = false"
462 + ", target_family = " + QString::number(ui->TargetFamily->currentIndex() + 1)
463 + ", departure_url = '" + ui->DepartureURL->text()
464 + "', executable_directory = '" + ui->ExecutableDirectory->text()
465 + "', executable_name = '" + ui->ExecutableName->text()
466 + "', dot_image_type = '" + ui->DotImageType->currentText()
467 + "', doxy_tab_size = " + QString::number(ui->DoxyTabSize->value())
468 + " where project_index = " + QString::number(project_info.ProjectDesc.ProjectIndex);
469
470 QSqlQuery update_query;
471 if (update_query.exec(update_command_string))
472 {
473 PROJECT_INFORMATION* project_file_info = new PROJECT_INFORMATION;
474 read_project_info->LoadProjectInfo(project_file_info, project_info.ProjectDesc.ProjectIndex, ui->ProjectPrefix->currentIndex());
475 project_subs_manager->LoadFileSubsList(project_file_info);
476
478 doxy_manager->ProcessProject(project_file_info);
479
480 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Project: %1 has been updated and saved.").arg(project_info.ProjectDesc.ProjectName) );
481 DoEditSave();
482 }
483 else
484 {
485 LogAdd(LOG_ERROR, MODE_DATABASE, QString("Project: %1 was NOT updated or saved.").arg(project_info.ProjectDesc.ProjectName) );
486 ShowMessage(update_command_string);
487 }
488}
489
490// Create a New Project Number
492{
493 uint project_number=0;
494
495 // Find the Next Project Number
496 QString query_string = QString("select max(project_index) from project");
497 QSqlDatabase db = QSqlDatabase::database();
498
499 QSqlQuery licence_query(query_string);
500 while(licence_query.next())
501 {
502 project_number = licence_query.value(0).toUInt();
503 }
504
505 // Get the Next Number
506 project_number++;
507 project_info.ProjectDesc.ProjectIndex = project_number;
508
509 // Create the Project Identifier
510 QString project_identifier = ui->ProjectPrefix->currentText() + "-" + QStringLiteral("%1").arg(project_number, ui->ProjectNumberSize->value(), 10, QLatin1Char('0'));
511 ui->ProjectIdent->setText(project_identifier);
512
513 // Return the Project Number
514 return(project_number);
515}
516
518{
519 uint licence_index = -1;
520
521 // Find the Licence Index of the Software Licence
522 QString query_string = QString("select licence_index from licence where short_name = '%1'").arg(LicenceName);
523 QSqlDatabase db = QSqlDatabase::database();
524
525 QSqlQuery licence_query(query_string);
526 while(licence_query.next())
527 {
528 licence_index = licence_query.value(0).toInt();
529 }
530 return(licence_index);
531}
532
534{
535 int project_number = CreateProjectId();
536
537 ui->ProjectStatusDate->setDateTime(QDateTime::currentDateTime());
538
539 QString insert_command_template = QString("INSERT INTO project(%1) VALUES (%2);");
540
541 QString storage_location;
542 if(ui->LocalDevDirectory->text().isEmpty()) storage_location = ui->ProjectIdent->text(); else storage_location = ui->LocalDevDirectory->text() + "/" + ui->ProjectIdent->text();
543
544 QString field_string = QString("project_index, project_name, major_version, minor_version, revision, brief_description, dev_family, compiler_family, project_status, project_lock, ") +
545 QString("compiler_type, status_date, doc_licence, software_licence, hardware_licence, project_contact, full_description, project_directory, icon_filename, project_options, ") +
546 QString("project_ident, doxy_project_logo_filename, doxy_html_header_filename, doxy_html_footer_filename, doxy_extra_stylesheet_filename, assoc_group, project_queued, target_family, departure_url, executable_directory, ") +
547 QString("executable_name, dot_image_type, doxy_tab_size");
548
549 QString value_string = QString::number(project_number) + ",'" + // Project Index
550 ui->ProjectName->text() + "'," + // Project Name
551 QString::number(ui->MajorVersion->value()) + "," + // Major Version
552 QString::number(ui->MinorVersion->value()) + "," + // Minor Version
553 QString::number(ui->Revision->value()) + ",'" + // Revision
554 ui->BriefDescription->text() + "'," + // Brief Description
555 QString::number(ui->DevelopmentFamily->currentIndex() + 1) + "," + // Development Family
556 QString::number(ui->LanguageFamily->currentIndex() + 1) + "," + // Compiler Family
557 QString::number(ui->ProjectStatus->currentIndex() + 1) + "," + // Project Status
558 "false," + // Project Lock
559
560 QString::number(ui->PrimaryTool->currentIndex() + 1) + ",'" + // Compiler Type
561 ui->ProjectStatusDate->dateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + "'," + // Status DateTime
562 QString::number(GetLicenceIndex(ui->DocumentationLicenceList->currentText())) + "," + // Documentation Licence
563 QString::number(GetLicenceIndex(ui->SoftwareLicenceList->currentText())) + "," + // Software Licence
564 QString::number(GetLicenceIndex(ui->HardwareLicenceList->currentText())) + "," + // Hardware Licence
565 QString::number(ui->ProjectContactList->currentIndex() + 1) +" ,'" + // Project Contact
566 ui->FullDescription->document()->toPlainText() + "','" + // Project Full Description
567 storage_location + "','" + // Project Storage Location
568 ui->ProjectIcon->text() + "'," + // Project Icon Name
569 QString::number(project_opts_manager->WriteOptionState()) + ",'" + // Project Options
570
571 ui->ProjectIdent->text() + "','" + // Project Identification String
572 ui->DoxyProjectLogo->text() + "','" + // Doxygen Project Logo Filename
573 ui->DoxyHeader->text() + "','" + // Doxygen Project header Filemame
574 ui->DoxyFooter->text() + "','" + // Doxygen Project Footer Filename
575 ui->DoxyStylesheet->text() + "'," + // Doxygen Extra Stylesheet Filename
576 QString::number(ui->InAssociationList->currentIndex()) + "," + // The Group Associated with the Project
577 "false,'" + // Project Queued
578 QString::number(ui->TargetFamily->currentIndex() + 1) + "', '" + // Target Family
579 ui->DepartureURL->text() + "', '" + // Departure (Return) URL
580 ui->ExecutableDirectory->text() + "', '" + // Executable's Directory
581
582 ui->ExecutableName->text() + "', '" + // Name of the Executable
583 ui->DotImageType->currentText() + "', " + // Dot Image Type
584 QString::number(ui->DoxyTabSize->value()); // Doxygen Tab Size
585
586 QString insert_command_string = insert_command_template.arg(field_string).arg(value_string);
587
588 QSqlQuery insert_query;
589 bool insert_result = insert_query.exec(insert_command_string);
590
591 if (insert_result)
592 {
593 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Project %1 has been inserted into database.").arg(ui->ProjectName->text()) );
594
595 // Create the Basic Project Directory
596 QString source_directory = ui->SharedTemplateDir->text() + "/project_template";
597 if (CopyRecursively(source_directory, storage_location))
598 {
599 // Add the Source Directory
600
601 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Project directory %1 has been created.").arg(source_directory) );
602
603 // Add any Development Family Information to the Project Files
604 source_directory = ui->SharedTemplateDir->text() + "/family_template/" + ui->DevelopmentFamily->currentText();
605 if (CopyRecursively(source_directory, storage_location))
606 {
607 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Added %1 information to %2.").arg(ui->DevelopmentFamily->currentText()).arg(source_directory) );
608 }
609 else
610 {
611 LogAdd(LOG_ERROR, MODE_DATABASE, QString("Failed to add %1 information to %2.").arg(ui->DevelopmentFamily->currentText()).arg(source_directory) );
612 }
613
614 // Add it Any Development Language Specific Files
615 source_directory = ui->SharedTemplateDir->text() + "/language_template/" + ui->LanguageFamily->currentText();
616 if (CopyRecursively(source_directory, storage_location))
617 {
618 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Added %1 information to %2.").arg(ui->LanguageFamily->currentText()).arg(source_directory) );
619 InitiasliseGitDirectory(storage_location);
620 }
621 else
622 {
623 LogAdd(LOG_ERROR, MODE_DATABASE, QString("Failed to add %1 information to %2.").arg(ui->LanguageFamily->currentText()).arg(source_directory) );
624 }
625
626 // Add Any Tool Specific Files
627 source_directory = ui->SharedTemplateDir->text() + "/tool_template/" + ui->PrimaryTool->currentText();
628 if (CopyRecursively(source_directory, storage_location))
629 {
630 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Added %1 information to %2.").arg(ui->LanguageFamily->currentText()).arg(source_directory) );
631 InitiasliseGitDirectory(storage_location);
632 }
633 else
634 {
635 LogAdd(LOG_ERROR, MODE_DATABASE, QString("Failed to add %1 information to %2.").arg(ui->LanguageFamily->currentText()).arg(source_directory) );
636 }
637
638 // Create the Directory for the Source Code
639 QString code_directory = storage_location + "/source/" + ui->ExecutableName->text();
640 QDir dir;
641 if (!dir.mkdir(code_directory))
642 {
643 LogAdd(LOG_ERROR, MODE_FILE, QString("Could NOT create Code Directory %1").arg(code_directory));
644 }
645 else
646 {
647 LogAdd(LOG_DEBUG, MODE_FILE, QString("Created Code Directory %1").arg(code_directory));
648
649 // Copy in the AutoSrc Files.
650 QString autosrc_template = ui->SharedTemplateDir->text() + "/autosrc_template/" + ui->LanguageFamily->currentText();
651 if (CopyRecursively(autosrc_template, storage_location + "/autosrc/"))
652 {
653 LogAdd(LOG_DEBUG, MODE_FILE, QString("Transferred Auto Source Files to %1").arg(code_directory));
654 InitiasliseGitDirectory(storage_location);
655 }
656 else
657 {
658 LogAdd(LOG_ERROR, MODE_FILE, QString("Could NOT transfer Auto Source Files to %1").arg(code_directory));
659 }
660 }
661 }
662 else
663 {
664 LogAdd(LOG_ERROR, MODE_DATABASE, QString("Project directory %1 has NOT been created.").arg(source_directory) );
665 }
666 DoEditSave();
667 }
668 else
669 {
670 ShowMessage(insert_command_string);
671 LogAdd(LOG_ERROR, MODE_DATABASE, QString("Project %1 has NOT been inserted into database.").arg(ui->ProjectName->text()) );
672 }
673 return(insert_result);
674}
675
677{
678 ui->SaveSubstituitions->setEnabled(!State);
679 ui->ReloadSubstituitions->setEnabled(!State);
680}
681
683{
684 return (!ui->ProjectName->text().isEmpty() &&
685 !ui->BriefDescription->text().isEmpty()) &&
686 !ui->FullDescription->toPlainText().isEmpty() &&
687 !ui->DepartureURL->text().isEmpty() &&
688 !ui->ExecutableName->text().isEmpty();
689}
690
691bool ProjectDocManager::CopyRecursively(const QString &srcFilePath, const QString &tgtFilePath)
692{
693 // Check if the Source is a File or a Directory
694 QFileInfo srcFileInfo(srcFilePath);
695 if (srcFileInfo.isDir())
696 {
697 // If the Target Directory Doesn't Exist, Create It
698 QDir targetDir(tgtFilePath);
699 if ( !targetDir.exists() )
700 {
701 // Go Up a Level and Create the Directory
702 targetDir.cdUp();
703 if (!targetDir.mkpath(QFileInfo(tgtFilePath).fileName()))
704 {
705 return false;
706 }
707 }
708
709 // Copy Each Entry in the Directory to the Target
710 QDir sourceDir(srcFilePath);
711 QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
712 foreach (const QString &fileName, fileNames) {
713 const QString newSrcFilePath
714 = srcFilePath + QLatin1Char('/') + fileName;
715 const QString newTgtFilePath
716 = tgtFilePath + QLatin1Char('/') + fileName;
717 if (!CopyRecursively(newSrcFilePath, newTgtFilePath))
718 {
719 return false;
720 }
721 }
722 }
723
724 // If it is a File Copy It
725 else
726 {
727 if (!QFile::copy(srcFilePath, tgtFilePath))
728 {
729 LogAdd( LOG_ERROR, MODE_FILE, QString( "Error in file copy from '" ) + srcFilePath + QString("' to '") + tgtFilePath + "." );
730 return false;
731 }
732 }
733 return true;
734}
735
737{
738 bool result = false;
739
740 // Move to the default .git Directory
741 QDir dir;
742 dir.cd(SrcFilePath);
743
744 // Output the git Command
745 QProcess git;
746 QStringList Arg;
747 Arg << "init" << SrcFilePath << "--template=/usr/share/git-core/templates";
748
749 git.start( "git", QStringList() << Arg );
750 if (!git.waitForStarted())
751 {
752 LogAdd( LOG_ERROR, MODE_THREAD, "git did NOT Start." );
753 }
754 else
755 {
756 LogAdd( LOG_DEBUG, MODE_THREAD, QString( "Started git Process with \"init\"" ) );
757 if (git.waitForFinished())
758 {
759 LogAdd( LOG_DEBUG, MODE_THREAD, "git finished on time." );
760 // Commit the git Entries
761 Arg.clear();
762 Arg << "commit -m \"Initial creation by ProjectManager.\"";
763 git.start( "git", QStringList() << Arg );
764 if (!git.waitForStarted())
765 {
766 LogAdd( LOG_ERROR, MODE_THREAD, "git did NOT Start on time." );
767 }
768 else
769 {
770 LogAdd( LOG_DEBUG, MODE_THREAD, QString( "Started git Process with \"commit\"") );
771 if (git.waitForFinished())
772 {
773 LogAdd( LOG_DEBUG, MODE_THREAD, "git finished on time." );
774 result = true;
775 }
776 else
777 {
778 LogAdd( LOG_ERROR, MODE_THREAD, "git did NOT finish on time." );
779 }
780
781 }
782 }
783 else
784 {
785 LogAdd( LOG_ERROR, MODE_THREAD, "git did NOT finish on time." );
786 }
787 }
788 return(result);
789}
790
791bool ProjectDocManager::CommitGitDirectory(QString SrcFilePath, QString VersionString, QString Message)
792{
793 bool result = false;
794
795 // Move to the default .git Directory
796 QDir dir;
797 dir.cd(SrcFilePath);
798
799 // Output the git Command
800 QProcess git;
801 QStringList Arg;
802 QString commit_string = QString("Version: %1. %2").arg(VersionString).arg(Message);
803 QString arg_string = QString("commit -m \"Project Version %1\"").arg(commit_string);
804
805 Arg << arg_string;
806
807 git.start( "git", QStringList() << Arg );
808 if (!git.waitForStarted())
809 {
810 LogAdd( LOG_ERROR, MODE_THREAD, "git did NOT Start." );
811 }
812 else
813 {
814 LogAdd( LOG_DEBUG, MODE_THREAD, QString("Started git Process with %1").arg(arg_string));
815 if (git.waitForFinished())
816 {
817 result = true;
818
819 }
820 else
821 {
822 LogAdd( LOG_ERROR, MODE_THREAD, "git Commit did NOT finish on time." );
823 }
824 }
825 return(result);
826}
827
828bool ProjectDocManager::LockProject(int ProjectIndex, bool LockState)
829{
830 bool result = false;
831
832 QString update_command_string = QString("UPDATE project SET project_lock = ") + QVariant(LockState).toString() + " "
833 + "where project_index = " + QString::number(ProjectIndex);
834
835 QSqlQuery update_query;
836 if (update_query.exec(update_command_string))
837 {
838 LogAdd(LOG_DEBUG, MODE_DATABASE, QString("Project Index: %1 Lock Updated.").arg(QString::number(ProjectIndex)) );
839 if (LockState == true)current_locked_project = ProjectIndex; else current_locked_project = 0;
840 result = true;
841 }
842 else
843 {
844 LogAdd(LOG_ERROR, MODE_DATABASE, QString("Project Index: %1 Lock NOT Updated.").arg(QString::number(ProjectIndex)) );
845 }
846 return(result);
847}
Class for utilising the Doxygen tool.
bool InitiasliseGitDirectory(QString SrcFilePath)
Initialise the Project's Git Directory.
~ProjectDocManager()
ProjectManager Class Deconstructor.
void ReceiveProjectId(PROJECT_INFORMATION ProjectId)
Receive the Project's Information for processing.
int CreateProjectId(void)
Create the next unused project number.
void GetDoxyHeader(void)
Get Custom Doxygen Header.
void LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, const QString Message)
Send Message to the Log.
QString GetFile(QString InitialName, GET_FILE_TYPE FileType)
Read a file into a String.
void LoadSubstituteTable()
Load System Substituitions.
void StartProject(void)
Enable the Project User Interface for editing.
void SendLogEntry(REMOTE_LOG_ENTRY LogEntry)
Send Log Entry via the Signal-Slot Method.
ProjectDocManager(Ui::MainWindow *UI_Window)
ProjectManager Class Constructor.
void SaveLocalSubstitutes(void)
Send a Trigger to Load.
void SetDonationsWelcome(int State)
Enable/Disable Donation Options.
bool CommitGitDirectory(QString SrcFilePath, QString VersionsString, QString Message)
Commit Project Files to Git.
void ShowMessage(QString Message)
Shows Message in popup window.
void SaveProject(void)
Save a new project to the database.
void SendSubstituteState(bool State)
Send the Substitute Enable State.
void GetDoxyLogo(void)
Get the Doxygen Logo from known image files.
bool CopyRecursively(const QString &SourceFilePath, const QString &TargetFilePath)
Recursively copy files from Source to Destination.
void GetDoxyFooter(void)
Get Custom Doxygen Footer.
PROJECT_INFORMATION project_info
Structure to hold Project Information.
int GetLicenceIndex(QString LicenceName)
Get the Licence Database Index from the Licence Name.
bool LockProject(int ProjectIndex, bool LockState)
Lock/Unlock Project in the Database.
void SetDocAccess(int State)
Enable/Disable Document Access Restrictions.
void LoadProjectList()
Load Select Project List from Database.
void UpdateProjectToDatabase(void)
Updates an Existing Project.
void LoadProjectFromDatabase(int Item)
Load Project Information from Database.
void DoEditSave(void)
Abort Editing after Saving.
void SetDoxyOptions(int State)
Enable/Disable Custom Doxy Options.
void SendClear(void)
Send a Project Clear Command.
void SetEditButtons(bool State)
Enable/Disable Edit buttons.
void SendProjectId(PROJECT_INFORMATION *ProjectId)
Send out Project Information for Updates.
bool IsSaveAvailable(void)
Check if Project Save is Enabled.
void LockSubsButtons(bool State)
Lock/unlock the Substitution Buttons.
bool InsertNewProjectInDatabase(void)
Inserts new project into the database.
void ReadActivated(int Item)
Load a Project & Enable editing.
void GetDoxyStylesheet(void)
Get Custom Doxygen Stylesheet.
void EnableUserInterface(bool State)
Enable the Project User Interface.
void SetEditState(int State)
Enable/Disable editing.
Ui::MainWindow * ui
Pointer to the Main Window.
void DoEditAbort(void)
Abort Editing without Saving.
Common Structure Defintitions.
#define ONLY_UPDATE_SOURCE
Mask to Test if Only Source Code should be Processed.
@ PT_SOFTWARE_LICENCE
@ PT_STATUS_DATE
@ PT_PROJECT_QUEUED
@ PT_ICON_FILENAME
@ PT_COMPILER_TYPE
@ PT_PROJECT_INDEX
@ PT_DOC_LICENCE
@ PT_REVISION
@ PT_DOXY_HTML_HEADER_FILENAME
@ PT_PROJECT_NAME
@ PT_DEV_FAMILY
@ PT_PROJECT_IDENT
@ PT_DOXY_EXTRA_STYLESHEET_FILENAME
@ PT_EXECUTABLE_NAME
@ PT_PROJECT_CONTACT
@ PT_MAJOR_VERSION
@ PT_PROJECT_OPTIONS
@ PT_ASSOC_GROUP
@ PT_PROJECT_LOCK
@ PT_DEPARTURE_URL
@ PT_MINOR_VERSION
@ PT_EXECUTABLE_DIRECTORY
@ PT_DOXY_HTML_FOOTER_FILENAME
@ PT_PROJECT_DIRECTORY
@ PT_COMPILER_FAMILY
@ PT_BRIEF_DESCRIPTION
@ PT_PROJECT_STATUS
@ PT_HARDWARE_LICENCE
@ PT_DOXY_PROJECT_LOGO_FILENAME
@ PT_TARGET_FAMILY
@ PT_FULL_DESCRIPTION
ReadProjectInfo * read_project_info
Doxygen Defintitions.
LOGGING_SEVERITY
Log Severity allow the selection of logging events based on Severity.
Definition logger.h:48
@ LOG_ERROR
Definition logger.h:52
@ LOG_INFO
Definition logger.h:55
@ 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_FILE
Definition logger.h:32
@ MODE_OPERATOR
Definition logger.h:34
@ MODE_THREAD
Definition logger.h:25
@ MODE_DATABASE
Definition logger.h:35
ProjectOptionsManager * project_opts_manager
PROJECT_INFORMATION project_information
DoxygenManager * doxy_manager
ProjectSubstitute * project_subs_manager
int current_locked_project
Database Index of currently locked Project.
GET_FILE_TYPE
Type of File to Search for.
@ GET_IMAGE_FILE
@ GET_HTML_FILE
@ GET_CSS_FILE
Class Controlling the Database Creation.
Class Controlling Text Substitution.
Class for Reading Projects.
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