Opensim Control Panel BRIGADOON-0013
This program provides a control panel for an Open Simulator Instance
Loading...
Searching...
No Matches
DirClass Class Reference

#include <dirclass.h>

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

Public Slots

void ListInputDirectory (void)

Signals

void SendInputTable (QList< DIR_INFO > file_list)
void SendRegionLocation (REMOTE_REGION_ADDRESS region_address)
void SendLogEntry (REMOTE_LOG_ENTRY LogEntry)
 Send Log Entry via the Signal-Slot Method.

Public Member Functions

 DirClass (QObject *parent=nullptr)
void SetInputTable (QTableWidget *InputTable)
void SetOutputTable (QTableWidget *OutputTable)
bool LoadInputTable (QString InputDirectory)
bool LoadOutputTable (QString OutputDirectory)
void SetInputDirectory (QString DirectoryString)

Private Member Functions

bool AddInputFiles (QString FileName)
bool AddOutputFiles (QString FileName)
QStringList SplitFilename (QString file_name)
QList< DIR_INFOProcessInputFilenames (QString InputDirectory)
void DisplayInputTable (QList< DIR_INFO > InputTableList)
void LogAdd (LOGGING_SEVERITY Severity, LOGGING_MODE Mode, QString Message)
 Send Message to the Log.

Private Attributes

QTableWidget * input_table
QTableWidget * output_table
QString input_directory
QList< DIR_INFOinput_list
QList< DIR_INFOoutput_list

Detailed Description

Definition at line 54 of file dirclass.h.

Constructor & Destructor Documentation

◆ DirClass()

DirClass::DirClass ( QObject * parent = nullptr)
explicit

Definition at line 7 of file dirclass.cpp.

8 : QObject{parent}
9{
10
11}

Member Function Documentation

◆ AddInputFiles()

bool DirClass::AddInputFiles ( QString FileName)
private

Definition at line 74 of file dirclass.cpp.

75{
76 bool result = false;
77 return(result);
78}

◆ AddOutputFiles()

bool DirClass::AddOutputFiles ( QString FileName)
private

Definition at line 80 of file dirclass.cpp.

81{
82 bool result = false;
83 return(result);
84}

◆ DisplayInputTable()

void DirClass::DisplayInputTable ( QList< DIR_INFO > InputTableList)
private

Definition at line 155 of file dirclass.cpp.

156{
157 QBrush ItemBrush(Qt::black);
158
159 // Clear the Input Table
160 input_table->clearContents();
161 input_table->setSortingEnabled(false);
162 input_table->setRowCount(InputTableList.count());
163 // Load the Table with the Data from the Directory
164 int row = 0;
165 for (const auto &item : InputTableList)
166 {
167 // Include the Select Widget in the Table Row
168 QWidget *check_box_widget = new QWidget();
169 QCheckBox *select_button = new QCheckBox();
170 select_button->setText("");
171 select_button->setChecked(true);
172 select_button->setCheckable(true);
173 QHBoxLayout *layout_select_box = new QHBoxLayout(check_box_widget);
174 layout_select_box->addWidget(select_button); //add QCheckBox to layout
175 layout_select_box->setAlignment(Qt::AlignCenter); //set Alignment layout
176 layout_select_box->setContentsMargins(0,0,0,0);
177 input_table->setCellWidget(row, INPUT_SELECT_COLUMN, check_box_widget);
178
179 // Make A Table Widget for the Region Identifier and Insert
180 QString region_name = item.RegionName;
181 QTableWidgetItem *new_project_ident = new QTableWidgetItem(region_name);
182 new_project_ident->setFlags(new_project_ident->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsSelectable));
183 new_project_ident->setTextAlignment(Qt::AlignCenter);
184 new_project_ident->setForeground(ItemBrush);
185 input_table->setItem( row, INPUT_NAME_COLUMN, new_project_ident );
186
187 // Include the Processed Widget in the Table Row
188 QWidget *check_done_widget = new QWidget();
189 QCheckBox *done_button = new QCheckBox();
190 done_button->setText("");
191 done_button->setChecked(false);
192 done_button->setCheckable(false);
193 QHBoxLayout *layout_done_box = new QHBoxLayout(check_done_widget);
194 layout_done_box->addWidget(done_button); //add QCheckBox to layout
195 layout_done_box->setAlignment(Qt::AlignCenter); //set Alignment layout
196 layout_done_box->setContentsMargins(0,0,0,0);
197 input_table->setCellWidget(row, INPUT_DONE_COLUMN, check_done_widget);
198
199 // Pass the Location to the Auto Area Calculation
200 REMOTE_REGION_ADDRESS region_address;
201 region_address.RegionXLocation = item.x_position;
202 region_address.RegionYLocation = item.y_position;
203 emit SendRegionLocation(region_address);
204
205 // Move to the Next Row
206 row++;
207 }
208 input_table->repaint();
209}
QTableWidget * input_table
Definition dirclass.h:69
void SendRegionLocation(REMOTE_REGION_ADDRESS region_address)
@ INPUT_DONE_COLUMN
Definition dirclass.h:32
@ INPUT_SELECT_COLUMN
Definition dirclass.h:30
@ INPUT_NAME_COLUMN
Definition dirclass.h:31

References INPUT_DONE_COLUMN, INPUT_NAME_COLUMN, INPUT_SELECT_COLUMN, input_table, REMOTE_REGION_ADDRESS::RegionXLocation, REMOTE_REGION_ADDRESS::RegionYLocation, and SendRegionLocation().

Referenced by LoadInputTable().

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

◆ ListInputDirectory

void DirClass::ListInputDirectory ( void )
slot

Definition at line 41 of file dirclass.cpp.

42{
44}
QString input_directory
Definition dirclass.h:72
bool LoadInputTable(QString InputDirectory)
Definition dirclass.cpp:46

References input_directory, and LoadInputTable().

Here is the call graph for this function:

◆ LoadInputTable()

bool DirClass::LoadInputTable ( QString InputDirectory)

Definition at line 46 of file dirclass.cpp.

47{
48 bool result = false;
49 QList<DIR_INFO> file_list;
50
51 // Load Regios from the Database if ther eis access available
52 //if (useDatabase) result = LoadFromDatabase(InputDirectory);
53 // else
54 //{
55
56 // Process the Files in the Input Directory
57 file_list = ProcessInputFilenames(InputDirectory);
58 result = !file_list.empty();
59
60 //}
61
62 if (result) DisplayInputTable(file_list);
63 return(result);
64}
QList< DIR_INFO > ProcessInputFilenames(QString InputDirectory)
Definition dirclass.cpp:86
void DisplayInputTable(QList< DIR_INFO > InputTableList)
Definition dirclass.cpp:155

References DisplayInputTable(), and ProcessInputFilenames().

Referenced by ListInputDirectory().

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

◆ LoadOutputTable()

bool DirClass::LoadOutputTable ( QString OutputDirectory)

Definition at line 66 of file dirclass.cpp.

67{
68 bool result = false;
69
70 return(result);
71}

◆ LogAdd()

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

Send Message to the Log.

Parameters
SeveritySeverity of the Log Message
ModeWhich part of the program does the message relate to
MessageText message to be added to the Log

Definition at line 145 of file dirclass.cpp.

146{
147 REMOTE_LOG_ENTRY log_entry;
148 log_entry.Severity = Severity;
149 log_entry.Mode = Mode;
150 log_entry.Message = Message;
151 emit SendLogEntry(log_entry);
152}
void SendLogEntry(REMOTE_LOG_ENTRY LogEntry)
Send Log Entry via the Signal-Slot Method.
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 ProcessInputFilenames().

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

◆ ProcessInputFilenames()

QList< DIR_INFO > DirClass::ProcessInputFilenames ( QString InputDirectory)
private

Definition at line 86 of file dirclass.cpp.

87{
88 QDir dir(InputDirectory);
89 QList<DIR_INFO> dir_list;
90
91 // Check if the Directory Exists
92 if (dir.exists())
93 {
94 // Preset the Directory Filtering
95 dir.setFilter(QDir::Files | QDir::NoSymLinks);
96 QStringList name_filter;
97 name_filter << "*.r32";
98 dir.setNameFilters(name_filter);
99
100 // Get the Filtered List of Region Files
101
102 QFileInfoList list = dir.entryInfoList();
103
104 // Process the List of Files
105 for (int i = 0; i < list.size(); ++i)
106 {
107 // Save the Filename for Later
108 QFileInfo file_info = list.at(i);
109 DIR_INFO dir_info;
110 QString file_name =file_info.fileName();
111 dir_info.FileName = file_name;
112 LogAdd(LOG_DEBUG, MODE_FILE, "Found filename = " + file_name);
113
114 // Find the Size of the File
115 dir_info.file_size = file_info.size();
116
117 // Find out the size of the region
118
119 // Split the Filename to get the Region Name & Save it
120 QStringList filename_split = file_name.split(QRegularExpression("\\s+"));
121 QString region_name = filename_split.at(0);
122 dir_info.RegionName = region_name;
123
124 // Split the Remainder to Get the Region Address
125 QString part_name = filename_split.at(1);
126 int start_position = part_name.indexOf("(") + 1;
127 int end_position = part_name.indexOf(")");
128 int length = end_position - start_position;
129 QString location = part_name.mid(start_position, length);
130
131 // Split the address strings into X and Y
132 int break_position = location.indexOf(",");
133 dir_info.x_position = location.mid(0, break_position).toInt();
134 dir_info.y_position = location.mid((break_position + 1), -1).toInt();
135
136 // Flag that this is not to be processed by default
137 dir_info.doProcessing = false;
138
139 dir_list << dir_info;
140 }
141 }
142 return(dir_list);
143}
void LogAdd(LOGGING_SEVERITY Severity, LOGGING_MODE Mode, QString Message)
Send Message to the Log.
Definition dirclass.cpp:145
@ LOG_DEBUG
Definition logger.h:56
@ MODE_FILE
Definition logger.h:32
bool doProcessing
Definition dirclass.h:16
int x_position
Definition dirclass.h:14
QString FileName
Definition dirclass.h:11
int y_position
Definition dirclass.h:15
QString RegionName
Definition dirclass.h:12
qint64 file_size
Definition dirclass.h:13

References DIR_INFO::doProcessing, DIR_INFO::file_size, DIR_INFO::FileName, LOG_DEBUG, LogAdd(), MODE_FILE, DIR_INFO::RegionName, DIR_INFO::x_position, and DIR_INFO::y_position.

Referenced by LoadInputTable().

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

◆ SendInputTable

void DirClass::SendInputTable ( QList< DIR_INFO > file_list)
signal

◆ SendLogEntry

void DirClass::SendLogEntry ( REMOTE_LOG_ENTRY LogEntry)
signal

Send Log Entry via the Signal-Slot Method.

Parameters
LogEntryStructure holding the Log Entry parameters

Referenced by LogAdd().

Here is the caller graph for this function:

◆ SendRegionLocation

void DirClass::SendRegionLocation ( REMOTE_REGION_ADDRESS region_address)
signal

Referenced by DisplayInputTable().

Here is the caller graph for this function:

◆ SetInputDirectory()

void DirClass::SetInputDirectory ( QString DirectoryString)

Definition at line 13 of file dirclass.cpp.

14{
15 input_directory = DirectoryString;
16}

References input_directory.

◆ SetInputTable()

void DirClass::SetInputTable ( QTableWidget * InputTable)

Definition at line 18 of file dirclass.cpp.

19{
20 input_table = InputTable;
21 input_table->setColumnCount( INPUT_TABLE_COLUMN_COUNT );
22 input_table->setHorizontalHeaderLabels( QStringList( {"Sel.", "Region", "Done"} ));
23
27}
#define INPUT_DONE_WIDTH
Definition dirclass.h:38
#define INPUT_SELECT_WIDTH
Definition dirclass.h:37
#define INPUT_TABLE_COLUMN_COUNT
Definition dirclass.h:35
#define INPUT_NAME_WIDTH
Definition dirclass.h:39

References INPUT_DONE_COLUMN, INPUT_DONE_WIDTH, INPUT_NAME_COLUMN, INPUT_NAME_WIDTH, INPUT_SELECT_COLUMN, INPUT_SELECT_WIDTH, input_table, and INPUT_TABLE_COLUMN_COUNT.

◆ SetOutputTable()

void DirClass::SetOutputTable ( QTableWidget * OutputTable)

Definition at line 29 of file dirclass.cpp.

30{
31 output_table = OutputTable;
32 output_table->setColumnCount( OUTPUT_TABLE_COLUMN_COUNT );
33 output_table->setColumnCount( INPUT_TABLE_COLUMN_COUNT );
34 output_table->setHorizontalHeaderLabels( QStringList( {"Sel.", "Region", "Done"} ));
35
39}
QTableWidget * output_table
Definition dirclass.h:70
#define OUTPUT_DONE_WIDTH
Definition dirclass.h:51
#define OUTPUT_TABLE_COLUMN_COUNT
Definition dirclass.h:48
#define OUTPUT_NAME_WIDTH
Definition dirclass.h:52
#define OUTPUT_SELECT_WIDTH
Definition dirclass.h:50
@ OUTPUT_DONE_COLUMN
Definition dirclass.h:45
@ OUTPUT_SELECT_COLUMN
Definition dirclass.h:43
@ OUTPUT_NAME_COLUMN
Definition dirclass.h:44

References INPUT_TABLE_COLUMN_COUNT, OUTPUT_DONE_COLUMN, OUTPUT_DONE_WIDTH, OUTPUT_NAME_COLUMN, OUTPUT_NAME_WIDTH, OUTPUT_SELECT_COLUMN, OUTPUT_SELECT_WIDTH, output_table, and OUTPUT_TABLE_COLUMN_COUNT.

◆ SplitFilename()

QStringList DirClass::SplitFilename ( QString file_name)
private

Field Documentation

◆ input_directory

QString DirClass::input_directory
private

Definition at line 72 of file dirclass.h.

Referenced by ListInputDirectory(), and SetInputDirectory().

◆ input_list

QList<DIR_INFO> DirClass::input_list
private

Definition at line 74 of file dirclass.h.

◆ input_table

QTableWidget* DirClass::input_table
private

Definition at line 69 of file dirclass.h.

Referenced by DisplayInputTable(), and SetInputTable().

◆ output_list

QList<DIR_INFO> DirClass::output_list
private

Definition at line 75 of file dirclass.h.

◆ output_table

QTableWidget* DirClass::output_table
private

Definition at line 70 of file dirclass.h.

Referenced by SetOutputTable().


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