API Documentation
Loading...
Searching...
No Matches
ReportIterator.h
Go to the documentation of this file.
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/SoftwareService.h>
4#include <NDEVR/WidgetIterator.h>
5#include <NDEVR/TranslatedString.h>
6#include <NDEVR/BaseValues.h>
7#include <NDEVR/UUID.h>
8#include <NDEVR/String.h>
9#include <NDEVR/JSONNode.h>
10#include <QSize>
11#include <QRect>
12class QWidget;
13class QMenu;
14namespace NDEVR
15{
16 class JSONNode;
17 class QTModelManager;
18 class File;
19 class Model;
20 /**--------------------------------------------------------------------------------------------------
21 \brief A simple Template for a report
22 **/
24 {
28 ReportTemplate(const String& id, File resource);
29 ReportTemplate(const String& id, const String& base_64);
30 };
31 /**--------------------------------------------------------------------------------------------------
32 \brief Creates a JSON data structure that can be used for generating a report in MSWord.
33 **/
43 /**--------------------------------------------------------------------------------------------------
44 \brief Handles creating a report page from some given data. A report page is a QWidget object that
45 is formatted for printing to a printer or PDF page.
46 **/
48 {
49 public:
50 ReportHandler(const TranslatedString& name, const TranslatedString& description, const String& icon)
51 : m_name(name)
52 , m_description(description)
53 , m_icon(icon)
54 {}
55 virtual ~ReportHandler() {};
56 const TranslatedString& name() const { return m_name; }
57 const TranslatedString& description() const { return m_description; }
58 const String& icon() const { return m_icon; }
59 //Given a list of model objects, returns report IDs it requests to handle. Note report ID's can be Model IDs, or unique to this object.
60 //Returned IDs will be stored, then used with canHandle, getReport, and createReportJSON
62
63 virtual QMenu* popupOptions() const { return nullptr; }
64 //Returns true if report can handle this ID
65 virtual bool canHandle(UUID, QTModelManager*) const { return false; };
66
67 //Can be nullptr if cannot generate report
68 virtual QWidget* getReport(const UUID&, QTModelManager*, const QRect&) const { return nullptr; };
69
70 //Allowed to be no-op. Given root parent node, create nodes that contain information for report
71 virtual void createReportJSON(const UUID&, JSONNode&, ReportJSONMaker&) const {};
72
73 virtual UUID id() const { return UUID::CreateUUID(m_name.translationID()); }
74 virtual bool defaultEnabled() const { return m_default_enabled; }
75 protected:
79 bool m_default_enabled = true;
80 };
81 /**--------------------------------------------------------------------------------------------------
82 \brief Iterates through a series of reports for drawing, sending to a PDF or printing.
83 **/
106 /**--------------------------------------------------------------------------------------------------
107 \brief Storage class for all ReportHandlers.
108 **/
110 {
111 public:
112 static void RegisterReportHandler(const ReportHandler* handler);
113 static const Buffer<const ReportHandler*>& ReportHandlers() { return s_report_handlers; };
114 protected:
116 };
117}
#define NDEVR_API
Definition DLLInfo.h:50
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
Definition JSONParser.h:60
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
Definition QTModelManager.h:105
Handles creating a report page from some given data. A report page is a QWidget object that is format...
Definition ReportIterator.h:48
TranslatedString m_description
Definition ReportIterator.h:77
ReportHandler(const TranslatedString &name, const TranslatedString &description, const String &icon)
Definition ReportIterator.h:50
virtual QWidget * getReport(const UUID &, QTModelManager *, const QRect &) const
Definition ReportIterator.h:68
String m_icon
Definition ReportIterator.h:78
virtual ~ReportHandler()
Definition ReportIterator.h:55
const TranslatedString & description() const
Definition ReportIterator.h:57
virtual Buffer< UUID > defaultReportIDs(const Buffer< UUID > &, QTModelManager *) const
Definition ReportIterator.h:61
const String & icon() const
Definition ReportIterator.h:58
TranslatedString m_name
Definition ReportIterator.h:76
virtual void createReportJSON(const UUID &, JSONNode &, ReportJSONMaker &) const
Definition ReportIterator.h:71
virtual UUID id() const
Definition ReportIterator.h:73
virtual QMenu * popupOptions() const
Definition ReportIterator.h:63
virtual bool canHandle(UUID, QTModelManager *) const
Definition ReportIterator.h:65
virtual bool defaultEnabled() const
Definition ReportIterator.h:74
const TranslatedString & name() const
Definition ReportIterator.h:56
Iterates through a series of reports for drawing, sending to a PDF or printing.
Definition ReportIterator.h:85
Buffer< UUID > m_objects_to_report
Definition ReportIterator.h:101
void setObjectsToReport(const Buffer< UUID > &objects_to_report)
JSONNode createJSONNode() const
ReportIterator(const Buffer< const ReportHandler * > &reports, const Buffer< UUID > &objects_to_report, QTModelManager *manager)
QWidget * getReport(uint04 report_index) const override
Buffer< std::pair< const ReportHandler *, UUID > > m_report_objects
Definition ReportIterator.h:102
ReportIterator(QTModelManager *manager)
Buffer< const ReportHandler * > m_report_handlers
Definition ReportIterator.h:104
void saveReportMetaData(const File &file) const
virtual bool canHandle(UUID model_id, QTModelManager *)
void setReportHandlers(const Buffer< const ReportHandler * > &handlers)
ReportIterator(const Buffer< const ReportHandler * > &reports, QTModelManager *manager)
QTModelManager * m_manager
Definition ReportIterator.h:103
const Buffer< const ReportHandler * > & reportHandlers()
Definition ReportIterator.h:97
Storage class for all ReportHandlers.
Definition ReportIterator.h:110
static void RegisterReportHandler(const ReportHandler *handler)
static const Buffer< const ReportHandler * > & ReportHandlers()
Definition ReportIterator.h:113
static Buffer< const ReportHandler * > s_report_handlers
Definition ReportIterator.h:115
Software Services provide an interface for adding to or changing the software behavior via functional...
Definition SoftwareService.h:9
Software Service Managers take a Software service to modify the behavior of the software.
Definition SoftwareService.h:15
The core String class for the NDEVR API.
Definition String.h:69
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
Provides a way to iterate over a series of widgets, useful for printing dialogs or turning Widgets in...
Definition WidgetIterator.h:15
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Creates a JSON data structure that can be used for generating a report in MSWord.
Definition ReportIterator.h:35
JSONNode root
Definition ReportIterator.h:37
void setTemplate(const ReportTemplate &report_template, JSONNode &node)
JSONNode & templateRoot()
QTModelManager * manager
Definition ReportIterator.h:36
ReportJSONMaker(QTModelManager *manager)
A simple Template for a report.
Definition ReportIterator.h:24
ReportTemplate(const String &id, const String &base_64)
File file
Definition ReportIterator.h:27
String id
Definition ReportIterator.h:25
String base_64
Definition ReportIterator.h:26
ReportTemplate(const String &id, File resource)