Check-in [b456644aa7]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge: improvements-to-main-menu
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both
Files: files | file ages | folders
SHA1:b456644aa77ae7b95a3b699764c96df9f1550c70
User & Date: tion 2019-02-16 02:17:27
Context
2019-02-16
02:20
v0.6.1 release check-in: 34d4528c03 user: tion tags: trunk, v0.6.1
02:17
Merge: improvements-to-main-menu check-in: b456644aa7 user: tion
02:11
cleanup: the rest of the tab to spaces Closed-Leaf check-in: 612332f50d user: tion tags: improvements-to-main-menu
2019-02-15
06:09
Fix minor typo with author check-in: ec284f5af0 user: tion tags: trunk
Changes

Changes to src/CoordinateData.cpp.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23












24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
..
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

126

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
212
213
214
215
216
217
218

219
220
221
222
223
224
225
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
...
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
...
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
//==================================================================
///////////////////////////
// CLASS: coordinateData //
///////////////////////////
//==================================================================
coordinateData::coordinateData()
{
   initCoordinates();
   initGlyphs();
}
//------------------------------------------------------------------
coordinateData::coordinateData (const QString &_code, bool isCoordinate)
{
	initCoordinates();
	initGlyphs();

   if ( isCoordinate == true )
      coordinates = _code;
   else
      glyph_code = _code;












}
//------------------------------------------------------------------
///////////////////////
// COPY CONSTRUCTORS //
///////////////////////
//------------------------------------------------------------------
coordinateData::coordinateData (const coordinateData &other)
{
	initCoordinates();
	initGlyphs();

   portal = other.portal;
   coordinates = other.coordinates;
   glyph_code = other.glyph_code;
   error_info = other.error_info;
}
//------------------------------------------------------------------
coordinateData::coordinateData (coordinateData &other)
{
	initCoordinates();
	initGlyphs();

   portal = other.portal;
   coordinates = other.coordinates;
   glyph_code = other.glyph_code;
   error_info = other.error_info;
}
//------------------------------------------------------------------
................................................................................

   return (*this);
}
//------------------------------------------------------------------
coordinateData &coordinateData::operator = (coordinateData &other)
{
   // Handle self-assignment
   if ( this != &other )

   {
      portal = other.portal;
      coordinates = other.coordinates;
      glyph_code = other.glyph_code;
      error_info = other.error_info;
   }

   return (*this);
}
//------------------------------------------------------------------
//////////////////////
// PUBLIC FUNCTIONS //
//////////////////////
//------------------------------------------------------------------
QString coordinateData::getGlyphCode() const
{
	return (glyph_code.toUpper());
}
//------------------------------------------------------------------
QString coordinateData::getCoordinate() const
{
	return (coordinates.toUpper());
}
//------------------------------------------------------------------
QString coordinateData::getCoordinates() const
{
	return (getCoordinate());
}
//------------------------------------------------------------------
QStringList coordinateData::getErrorInfo() const
{
	return (error_info);
}
//------------------------------------------------------------------
QString coordinateData::showErrorInfo() const
{
   // Ideally this function should never be called unless
   // there is something to display from error_info.
   QString result = QString();

   if ( error_info.isEmpty() == false )
      result.append( QString("[" + getErrorInfo().join("] [") + "]") );

   return (result);
}
//------------------------------------------------------------------
QString coordinateData::toString() const
{
	QString result = QString();

	if ( (coordinates.isEmpty() == true && glyph_code.isEmpty() == true) 
	  || (coordinates == ":::" && glyph_code.isEmpty() == true) )

		result += "No coordinate data found." + QString ("\n");

	else
	{
		if ( coordinates.isEmpty() == false
		  && coordinates != ":::" )
		{
			result += coordinates;
			result += ", portal #" + QString::number (portal);
			result += QString ("\n");
		}
	
		if ( glyph_code.isEmpty() == false )
			result += glyph_code + QString ("\n");
	}

	return (result);
}
//------------------------------------------------------------------
int coordinateData::getPortal() const
{
	return (portal);
}
//------------------------------------------------------------------
void coordinateData::setCoordinate (const QString &_code)
{
	if ( _code != coordinates )
		coordinates = _code;
}
//------------------------------------------------------------------
void coordinateData::setPortal (const int _number)
{
   if ( is_valid_portal(_number) == true )
      portal = (_number);
   else
      portal = 1;
}
//------------------------------------------------------------------
void coordinateData::setGlyphCode (const QString &_code)
{
	if ( _code != glyph_code )
		glyph_code = _code;
}
//------------------------------------------------------------------
void coordinateData::addToErrorInfo (const QString &error_data)
{
	if ( error_data.size() > 0 && error_data.at (0) != ':' )
		error_info += error_data;
}
//------------------------------------------------------------------
void coordinateData::reset()
{
   clearCoordinates();
   clearGlyphCode();
   clearErrorInfo();
}
//------------------------------------------------------------------
void coordinateData::clearCoordinates()
{
	coordinates.clear();

}
//------------------------------------------------------------------
void coordinateData::clearGlyphCode()
{
	glyph_code.clear();
}
//------------------------------------------------------------------
void coordinateData::clearErrorInfo()
{
	error_info.clear();
}
//------------------------------------------------------------------
void coordinateData::convertFromGlyph()
{
   // Verify glyph code is valid hexadecimal and is valid
   // glyph code sequence.
   clearErrorInfo();
................................................................................
          => Glyph #7, #8, #9: (coordinate_z - 0x81)
          => Glyph #10, #11, #12: (coordinate_x - 0x801)
      */
      QString coordinate_star, coordinate_x, coordinate_y, coordinate_z,
              temp_str, _glyph;
      int temp_value, offset = 0, temp_convert;
      _glyph.clear();

      // Iterate over the "strings" in _glyph, each of which is
      // a digit in the glyph code
      QStringList them_glyphs = glyph_code.split("");

      for (int i = 0; i < them_glyphs.size(); i++)
         _glyph += them_glyphs.at(i).toLocal8Bit().constData();

................................................................................
      temp_str = coordinate_x + ":" + coordinate_y + ":" + coordinate_z +
                 ":" +
                 coordinate_star;
      coordinates = (QString(temp_str).toUpper());
   }
   else
   {
      // Add invalid code segments to element info
      if ( temp_info.isEmpty() == false )
      {
         for (int i = 0; i < temp_info.size(); i++)
            addToErrorInfo (QString(temp_info.at(i)));
      }
      else
         addToErrorInfo (glyph_code);
   }
}
//------------------------------------------------------------------
void coordinateData::convertToGlyph()
................................................................................
   }
}
//------------------------------------------------------------------
///////////////////////
// PRIVATE FUNCTIONS //
///////////////////////
//------------------------------------------------------------------
void coordinateData::initGlyphs()
{
	glyph_code = QString();
}
//------------------------------------------------------------------
void coordinateData::initCoordinates()
{
	coordinates = QString();
	portal = int(1);
	error_info = QStringList();
}
//------------------------------------------------------------------
//////////////////////
// FRIEND FUNCTIONS //
//////////////////////
//------------------------------------------------------------------
QTextStream &operator >> (QTextStream &readInputInto, coordinateData &target)
{
   // Read into ins:
   //  coordinate portal glyph_code
   //
   // Error information will be determined upon conversion attempt.
   readInputInto >> target.coordinates >> target.portal;
   readInputInto >> target.glyph_code;

   return (readInputInto);
}
//------------------------------------------------------------------
QTextStream &operator << (QTextStream &outs, const coordinateData &the_data)
{
	outs << the_data.toString();

   return (outs);
}
//------------------------------------------------------------------
QTextStream &operator << (QTextStream &outs, coordinateData &the_data)
{
	outs << the_data.toString();

   return (outs);
}
//------------------------------------------------------------------
QDebug operator << (QDebug dbg, const coordinateData &the_data)
{
	QDebug outs = dbg.nospace();

	outs << "[DEBUG][coordinateData]";

	if ( (the_data.coordinates.isEmpty() == true
	  && the_data.glyph_code.isEmpty() == true)
	  || (the_data.coordinates == ":::" && the_data.glyph_code.isEmpty() == true) )
	{
		outs << ": No coordinate data found.\n";
	}
	else
	{
   	if ( the_data.coordinates.size() > 0
   	  && the_data.coordinates != ":::" )
   	{
	   	outs << "\nCoordinates: ";
   	   outs.noquote() << the_data.coordinates.toUpper();
      	outs << ", portal #" << the_data.portal;
      }

	   if ( the_data.glyph_code.isEmpty() == false )
	   {
	   	outs << "\nGlyph code: ";
	      outs.noquote() << the_data.glyph_code.toUpper();
	   }

	   if ( the_data.error_info.isEmpty() == false )
	   {
	      outs << "\ninvalid segments: ";
	      outs.noquote() << the_data.showErrorInfo();
	   }
   }

	return (dbg);
}
//------------------------------------------------------------------
QDebug operator << (QDebug dbg, coordinateData &the_data)
{
	QDebug outs = dbg.nospace();

	outs << "[DEBUG][coordinateData]";

	if ( (the_data.coordinates.isEmpty() == true
	  && the_data.glyph_code.isEmpty() == true)
	  || (the_data.coordinates == ":::" && the_data.glyph_code.isEmpty() == true) )
	{
		outs << ": No coordinate data found.\n";
	}
	else
	{
   	if ( the_data.coordinates.size() > 0
   	  && the_data.coordinates != ":::" )
   	{
	   	outs << "\nCoordinates: ";
   	   outs.noquote() << the_data.coordinates.toUpper();
      	outs << ", portal #" << the_data.portal;
      }

	   if ( the_data.glyph_code.isEmpty() == false )
	   {
	   	outs << "\nGlyph code: ";
	      outs.noquote() << the_data.glyph_code.toUpper();
	   }

	   if ( the_data.error_info.isEmpty() == false )
	   {
	      outs << "\ninvalid segments: ";
	      outs.noquote() << the_data.showErrorInfo();
	   }
   }

	return (dbg);
}
//------------------------------------------------------------------
std::ostream &operator << (std::ostream &outs, const coordinateData &the_data)
{
	outs << the_data.toString().toStdString();

   return (outs);
}
//------------------------------------------------------------------
std::ostream &operator << (std::ostream &outs, coordinateData &the_data)
{
	outs << the_data.toString().toStdString();

   return (outs);
}
//------------------------------------------------------------------
//////////////////////////
// COMPARISON OPERATORS //
//////////////////////////
................................................................................
   }

   return (result);
}
//------------------------------------------------------------------
bool operator != (const coordinateData &a, const coordinateData &b)
{
	bool result = false;

	if ( !(a == b) )
		result = true;

   return (result);
}
//------------------------------------------------------------------
bool operator != (coordinateData &a, coordinateData &b)
{
	bool result = false;

	if ( !(a == b) )
		result = true;

   return (result);
}
//------------------------------------------------------------------
bool operator < (const coordinateData &a, const coordinateData &b)
{
   bool result = false;







|
|




|
|





>
>
>
>
>
>
>
>
>
>
>
>








|
|









|
|







 







|
>
|
|
|
|
|
<










|




|




|




|




<
<










|

|
|
>
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|

|




|




|
|












|
|




|
|











|
>




|




|







 







>







 







|



|







 







|

|


|

|
|
|








|











|






|






|

|

|
|
|
|
|
|
|
|
|
|
|
|
|
|


|
|
|
|
|

|
|
|
|
|


|




|

|

|
|
|
|
|
|
|
|
|
|
|
|
|
|


|
|
|
|
|

|
|
|
|
|


|




|






|







 







|

|
|






|

|
|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
78
79
80
81
82
83
84
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121


122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
...
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
...
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
//==================================================================
///////////////////////////
// CLASS: coordinateData //
///////////////////////////
//==================================================================
coordinateData::coordinateData()
{
   createCoordinates();
   createGlyphs();
}
//------------------------------------------------------------------
coordinateData::coordinateData (const QString &_code, bool isCoordinate)
{
   createCoordinates();
   createGlyphs();

   if ( isCoordinate == true )
      coordinates = _code;
   else
      glyph_code = _code;
}
//------------------------------------------------------------------
////////////////
// DESTRUCTOR //
////////////////
//------------------------------------------------------------------
coordinateData::~coordinateData()
{
   coordinates.clear();
   glyph_code.clear();
   error_info.clear();
   portal = -1;
}
//------------------------------------------------------------------
///////////////////////
// COPY CONSTRUCTORS //
///////////////////////
//------------------------------------------------------------------
coordinateData::coordinateData (const coordinateData &other)
{
   createCoordinates();
   createGlyphs();

   portal = other.portal;
   coordinates = other.coordinates;
   glyph_code = other.glyph_code;
   error_info = other.error_info;
}
//------------------------------------------------------------------
coordinateData::coordinateData (coordinateData &other)
{
   createCoordinates();
   createGlyphs();

   portal = other.portal;
   coordinates = other.coordinates;
   glyph_code = other.glyph_code;
   error_info = other.error_info;
}
//------------------------------------------------------------------
................................................................................

   return (*this);
}
//------------------------------------------------------------------
coordinateData &coordinateData::operator = (coordinateData &other)
{
   // Handle self-assignment
   if ( this == &other )
      return (*this);

   portal = other.portal;
   coordinates = other.coordinates;
   glyph_code = other.glyph_code;
   error_info = other.error_info;


   return (*this);
}
//------------------------------------------------------------------
//////////////////////
// PUBLIC FUNCTIONS //
//////////////////////
//------------------------------------------------------------------
QString coordinateData::getGlyphCode() const
{
   return (glyph_code.toUpper());
}
//------------------------------------------------------------------
QString coordinateData::getCoordinate() const
{
   return (coordinates.toUpper());
}
//------------------------------------------------------------------
QString coordinateData::getCoordinates() const
{
   return (getCoordinate());
}
//------------------------------------------------------------------
QStringList coordinateData::getErrorInfo() const
{
   return (error_info);
}
//------------------------------------------------------------------
QString coordinateData::showErrorInfo() const
{


   QString result = QString();

   if ( error_info.isEmpty() == false )
      result.append( QString("[" + getErrorInfo().join("] [") + "]") );

   return (result);
}
//------------------------------------------------------------------
QString coordinateData::toString() const
{
   QString result = QString();

   if ( (coordinates.isEmpty() == true && glyph_code.isEmpty() == true) 
     || (coordinates == ":::" && glyph_code.isEmpty() == true) )
   {
      result += "No coordinate data found." + QString ("\n");
   }
   else
   {
      if ( coordinates.isEmpty() == false
        && coordinates != ":::" )
      {
         result += coordinates;
         result += ", portal #" + QString::number (portal);
         result += QString ("\n");
      }

      if ( glyph_code.isEmpty() == false )
         result += glyph_code + QString ("\n");
   }

   return (result);
}
//------------------------------------------------------------------
int coordinateData::getPortal() const
{
   return (portal);
}
//------------------------------------------------------------------
void coordinateData::setCoordinate (const QString &_code)
{
   if ( _code != coordinates )
      coordinates = _code;
}
//------------------------------------------------------------------
void coordinateData::setPortal (const int _number)
{
   if ( is_valid_portal(_number) == true )
      portal = (_number);
   else
      portal = 1;
}
//------------------------------------------------------------------
void coordinateData::setGlyphCode (const QString &_code)
{
   if ( _code != glyph_code )
      glyph_code = _code;
}
//------------------------------------------------------------------
void coordinateData::addToErrorInfo (const QString &error_data)
{
   if ( error_data.size() > 0 && error_data.at (0) != ':' )
      error_info += error_data;
}
//------------------------------------------------------------------
void coordinateData::reset()
{
   clearCoordinates();
   clearGlyphCode();
   clearErrorInfo();
}
//------------------------------------------------------------------
void coordinateData::clearCoordinates()
{
   coordinates.clear();
   portal = 1;
}
//------------------------------------------------------------------
void coordinateData::clearGlyphCode()
{
   glyph_code.clear();
}
//------------------------------------------------------------------
void coordinateData::clearErrorInfo()
{
   error_info.clear();
}
//------------------------------------------------------------------
void coordinateData::convertFromGlyph()
{
   // Verify glyph code is valid hexadecimal and is valid
   // glyph code sequence.
   clearErrorInfo();
................................................................................
          => Glyph #7, #8, #9: (coordinate_z - 0x81)
          => Glyph #10, #11, #12: (coordinate_x - 0x801)
      */
      QString coordinate_star, coordinate_x, coordinate_y, coordinate_z,
              temp_str, _glyph;
      int temp_value, offset = 0, temp_convert;
      _glyph.clear();

      // Iterate over the "strings" in _glyph, each of which is
      // a digit in the glyph code
      QStringList them_glyphs = glyph_code.split("");

      for (int i = 0; i < them_glyphs.size(); i++)
         _glyph += them_glyphs.at(i).toLocal8Bit().constData();

................................................................................
      temp_str = coordinate_x + ":" + coordinate_y + ":" + coordinate_z +
                 ":" +
                 coordinate_star;
      coordinates = (QString(temp_str).toUpper());
   }
   else
   {
      // Invalid glyph code entered. DO NOT COMPUTE coordinates.
      if ( temp_info.isEmpty() == false )
      {
         for (int i = 0; i < temp_info.size(); i++)
            addToErrorInfo (QString(temp_info.at (i)));
      }
      else
         addToErrorInfo (glyph_code);
   }
}
//------------------------------------------------------------------
void coordinateData::convertToGlyph()
................................................................................
   }
}
//------------------------------------------------------------------
///////////////////////
// PRIVATE FUNCTIONS //
///////////////////////
//------------------------------------------------------------------
void coordinateData::createGlyphs()
{
   glyph_code = QString();
}
//------------------------------------------------------------------
void coordinateData::createCoordinates()
{
   coordinates = QString();
   portal = int(1);
   error_info = QStringList();
}
//------------------------------------------------------------------
//////////////////////
// FRIEND FUNCTIONS //
//////////////////////
//------------------------------------------------------------------
QTextStream &operator >> (QTextStream &readInputInto, coordinateData &target)
{
   // Read the format:
   //  coordinate portal glyph_code
   //
   // Error information will be determined upon conversion attempt.
   readInputInto >> target.coordinates >> target.portal;
   readInputInto >> target.glyph_code;

   return (readInputInto);
}
//------------------------------------------------------------------
QTextStream &operator << (QTextStream &outs, const coordinateData &the_data)
{
   outs << the_data.toString();

   return (outs);
}
//------------------------------------------------------------------
QTextStream &operator << (QTextStream &outs, coordinateData &the_data)
{
   outs << the_data.toString();

   return (outs);
}
//------------------------------------------------------------------
QDebug operator << (QDebug dbg, const coordinateData &the_data)
{
   QDebug outs = dbg.nospace();

   outs << "[DEBUG][coordinateData]";

   if ( (the_data.coordinates.isEmpty() == true
     && the_data.glyph_code.isEmpty() == true)
     || (the_data.coordinates == ":::" && the_data.glyph_code.isEmpty() == true) )
   {
      outs << ": No coordinate data found.\n";
   }
   else
   {
      if ( the_data.coordinates.size() > 0
        && the_data.coordinates != ":::" )
      {
         outs << "\nCoordinates: ";
         outs.noquote() << the_data.coordinates.toUpper();
         outs << ", portal #" << the_data.portal;
      }

      if ( the_data.glyph_code.isEmpty() == false )
      {
         outs << "\nGlyph code: ";
         outs.noquote() << the_data.glyph_code.toUpper();
      }

      if ( the_data.error_info.isEmpty() == false )
      {
         outs << "\ninvalid segments: ";
         outs.noquote() << the_data.showErrorInfo();
      }
   }

   return (dbg);
}
//------------------------------------------------------------------
QDebug operator << (QDebug dbg, coordinateData &the_data)
{
   QDebug outs = dbg.nospace();

   outs << "[DEBUG][coordinateData]";

   if ( (the_data.coordinates.isEmpty() == true
     && the_data.glyph_code.isEmpty() == true)
     || (the_data.coordinates == ":::" && the_data.glyph_code.isEmpty() == true) )
   {
      outs << ": No coordinate data found.\n";
   }
   else
   {
      if ( the_data.coordinates.size() > 0
        && the_data.coordinates != ":::" )
      {
         outs << "\nCoordinates: ";
         outs.noquote() << the_data.coordinates.toUpper();
         outs << ", portal #" << the_data.portal;
      }

      if ( the_data.glyph_code.isEmpty() == false )
      {
         outs << "\nGlyph code: ";
         outs.noquote() << the_data.glyph_code.toUpper();
      }

      if ( the_data.error_info.isEmpty() == false )
      {
         outs << "\ninvalid segments: ";
         outs.noquote() << the_data.showErrorInfo();
      }
   }

   return (dbg);
}
//------------------------------------------------------------------
std::ostream &operator << (std::ostream &outs, const coordinateData &the_data)
{
   outs << the_data.toString().toStdString();

   return (outs);
}
//------------------------------------------------------------------
std::ostream &operator << (std::ostream &outs, coordinateData &the_data)
{
   outs << the_data.toString().toStdString();

   return (outs);
}
//------------------------------------------------------------------
//////////////////////////
// COMPARISON OPERATORS //
//////////////////////////
................................................................................
   }

   return (result);
}
//------------------------------------------------------------------
bool operator != (const coordinateData &a, const coordinateData &b)
{
   bool result = false;

   if ( !(a == b) )
      result = true;

   return (result);
}
//------------------------------------------------------------------
bool operator != (coordinateData &a, coordinateData &b)
{
   bool result = false;

   if ( !(a == b) )
      result = true;

   return (result);
}
//------------------------------------------------------------------
bool operator < (const coordinateData &a, const coordinateData &b)
{
   bool result = false;

Changes to src/CoordinateData.h.

1
2
3
4
5
6
7

8

9
10
11
12
13
14
15
..
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47



48
49
50
51
52
53
54
55
56




57
58
59
60
61
62
63
64
65
66
67




68
69
70
71
72
73
74
75
76
77
78
79
80



81

82
83
84
85
86
87
88
...
154
155
156
157
158
159
160

161
162
163
164
165
166
167
...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195

196
197
198
199
200
201








202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
//==================================================================
#ifndef __COORDINATE_DATA_H__
#define __COORDINATE_DATA_H__
//==================================================================
#include <QtCore>
//==================================================================
/** \class CoordinateData

 *  \brief Holds data about a coordinate and its glyph code.

 *  \details A coordinate is comprised a 19-digit hexadecimal value, 
 *  colon-separated every 4 digits. 
 *  Its corresponding glyph code is a 12-digit hexadecimal value.
 * 
 *  Valid coordinates exist between:
 * 
 *      0001:0001:0001:0001 ... 0FFF:00FF:0FFF:02FF
................................................................................
*/
class coordinateData : public QObject
{
   public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      /** \details Default constructor. Initializes all variables to
       *  null/empty values.
      */
      coordinateData();
      /** \details Recommend constructor to initialize to a known
       *  coordinate or glyph code. By default, a coordinate is
       *  assumed to be provided as these are more common to
       *  encounter (requires less work to obtain).
       * 
       *  \param[in] _code A valid coordinate or glyph code.
       *  \param[in] isCoordinate Defines the input type.

       *  \warning No error-checking that isCoordinate correctly
       *  corresponds to the type of input _code is.
      */
      coordinateData(const QString &_code, bool isCoordinate = true);




      // Copy Constructors
      /** \details Copy constructor for const CoordinateData object.
       * 
       *  \param[in] other An initialized CoordinateData object to
       *  copy data from.
      */
      coordinateData(const coordinateData &other);
      /** \overload coordinateData(coordinateData &other) **/




      coordinateData(coordinateData &other);
      
      // Assignment Operator
      /** \details Assignment operator for const CoordinateData
       *  object.
       * 
       *  \param[in] source An initialized CoordinateData object to
       *  copy data from.
      */
      coordinateData &operator = (const coordinateData &source);
      /** \overload operator=(coordinateData &source) */




      coordinateData &operator = (coordinateData &source);

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      /** \returns The glyph code of the coordinate. */
      QString getGlyphCode() const;
      /** \returns The coordinate. */
      QString getCoordinate() const;
      /** \returns The coordinate. */
      QString getCoordinates() const;
      /** \returns Error information about the code. */
      QStringList getErrorInfo() const;



      /** \returns Error information about the coordinate/glyph code. */

      QString showErrorInfo() const;
      /** \returns The portal number. */
      int getPortal() const;
      /** Prints the coordinates or glyph code in a human-readable
       *  format.
       *
       *  \returns A QString of coordinate values.
................................................................................
       *      <glyph code>
       * 
       *      0123:0045:0678:009A, portal #2
       *      000202002002
       * 
       *  \param[in,out] readInputInto The stream to read data from.
       *  \param[in,out] target The object to read data into.

       *  \warning Avoid using as this is not fully tested, nor functional.
      */
      friend QTextStream &operator >> (QTextStream &readInputInto, coordinateData &target);
      /** \details Outputs the contents of CoordinateData object in a
       *  human-readable format.
       * 
       *  \param[in,out] outs The stream to output data into.
................................................................................
       *  \param[in] the_data The data to read data from.
      */
      friend QTextStream &operator << (QTextStream &outs, coordinateData &the_data);
      /** \overload operator<<(QDebug, const coordinateData &)
       *
       *  Allows output to QDebug stream. For example:
       *
       *			coordinateData b;
       *			b.setCoordinate ("0123:0045:0678:009A");
       *			qDebug() << b;
       *
       *  \param[in,out] dbg The QDebug stream to output data into.
       *  \param[in] the_data The data to read data from.
      */
      friend QDebug operator << (QDebug dbg, const coordinateData &the_data);
      /** \overload operator<<(QDebug, coordinateData &)
       * 
       *  \param[in,out] dbg The QDebug stream to output data into.
       *  \param[in] the_data The data to read data from.
      */
      friend QDebug operator << (QDebug dbg, coordinateData &the_data);
      /** \overload operator<<(std::ostream &, const coordinateData &)

       *  Allows output to a stream, for example std::cout.
		 *
       *  \param[in,out] outs The stream to output data into.
       *  \param[in] the_data The data to read data from.
      */
      friend std::ostream &operator << (std::ostream &outs, const coordinateData &the_data);









   private:
      /*
         PRIVATE FUNCTIONS
      */
      /** \details Sets glyph code to empty value. */
      void initGlyphs();
      /** \details Sets coordinate to empty value, and portal number
       *  to default value of one (1).
      */
      void initCoordinates();

      /*
         PRIVATE VARIABLES
      */
      /** \var QString coordinates
       *
       *  \brief The coordinate sequence.







>

>







 







|
<
<
|



|



>



|
>
>
>








|
>
>
>
>










|
>
>
>
>













>
>
>
|
>







 







>







 







|
|
|












>






>
>
>
>
>
>
>
>






|



|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
28
29
30
31
32
33
34
35


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
//==================================================================
#ifndef __COORDINATE_DATA_H__
#define __COORDINATE_DATA_H__
//==================================================================
#include <QtCore>
//==================================================================
/** \class CoordinateData
 *
 *  \brief Holds data about a coordinate and its glyph code.
 *
 *  \details A coordinate is comprised a 19-digit hexadecimal value, 
 *  colon-separated every 4 digits. 
 *  Its corresponding glyph code is a 12-digit hexadecimal value.
 * 
 *  Valid coordinates exist between:
 * 
 *      0001:0001:0001:0001 ... 0FFF:00FF:0FFF:02FF
................................................................................
*/
class coordinateData : public QObject
{
   public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      /** Default constructor. */


      explicit coordinateData();
      /** \details Recommend constructor to initialize to a known
       *  coordinate or glyph code. By default, a coordinate is
       *  assumed to be provided as these are more common to
       *  encounter (requires less effort to obtain).
       * 
       *  \param[in] _code A valid coordinate or glyph code.
       *  \param[in] isCoordinate Defines the input type.
       *
       *  \warning No error-checking that isCoordinate correctly
       *  corresponds to the type of input _code is.
      */
      explicit coordinateData(const QString &_code, bool isCoordinate = true);

      /** Default destructor **/
      ~coordinateData();

      // Copy Constructors
      /** \details Copy constructor for const CoordinateData object.
       * 
       *  \param[in] other An initialized CoordinateData object to
       *  copy data from.
      */
      coordinateData(const coordinateData &other);
      /** \overload coordinateData(coordinateData &other)
       * 
       *  \param[in] other An initialized CoordinateData object to
       *  copy data from.
      */
      coordinateData(coordinateData &other);
      
      // Assignment Operator
      /** \details Assignment operator for const CoordinateData
       *  object.
       * 
       *  \param[in] source An initialized CoordinateData object to
       *  copy data from.
      */
      coordinateData &operator = (const coordinateData &source);
      /** \overload operator=(coordinateData &source)
       *
       *  \param[in] source An initialized CoordinateData object to
       *  copy data from.
      */
      coordinateData &operator = (coordinateData &source);

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      /** \returns The glyph code of the coordinate. */
      QString getGlyphCode() const;
      /** \returns The coordinate. */
      QString getCoordinate() const;
      /** \returns The coordinate. */
      QString getCoordinates() const;
      /** \returns Error information about the code. */
      QStringList getErrorInfo() const;
      /** Ideally this function should never be called unless
       *  there is something to display from error_info.
       *
       *  \returns Error information about the coordinate/glyph code.
      */
      QString showErrorInfo() const;
      /** \returns The portal number. */
      int getPortal() const;
      /** Prints the coordinates or glyph code in a human-readable
       *  format.
       *
       *  \returns A QString of coordinate values.
................................................................................
       *      <glyph code>
       * 
       *      0123:0045:0678:009A, portal #2
       *      000202002002
       * 
       *  \param[in,out] readInputInto The stream to read data from.
       *  \param[in,out] target The object to read data into.
       *
       *  \warning Avoid using as this is not fully tested, nor functional.
      */
      friend QTextStream &operator >> (QTextStream &readInputInto, coordinateData &target);
      /** \details Outputs the contents of CoordinateData object in a
       *  human-readable format.
       * 
       *  \param[in,out] outs The stream to output data into.
................................................................................
       *  \param[in] the_data The data to read data from.
      */
      friend QTextStream &operator << (QTextStream &outs, coordinateData &the_data);
      /** \overload operator<<(QDebug, const coordinateData &)
       *
       *  Allows output to QDebug stream. For example:
       *
       *	      coordinateData b;
       *	      b.setCoordinate ("0123:0045:0678:009a");
       *	      qDebug() << b;
       *
       *  \param[in,out] dbg The QDebug stream to output data into.
       *  \param[in] the_data The data to read data from.
      */
      friend QDebug operator << (QDebug dbg, const coordinateData &the_data);
      /** \overload operator<<(QDebug, coordinateData &)
       * 
       *  \param[in,out] dbg The QDebug stream to output data into.
       *  \param[in] the_data The data to read data from.
      */
      friend QDebug operator << (QDebug dbg, coordinateData &the_data);
      /** \overload operator<<(std::ostream &, const coordinateData &)
       *
       *  Allows output to a stream, for example std::cout.
		 *
       *  \param[in,out] outs The stream to output data into.
       *  \param[in] the_data The data to read data from.
      */
      friend std::ostream &operator << (std::ostream &outs, const coordinateData &the_data);
      /** \overload operator<<(std::ostream &, coordinateData &)
       *
       *  Allows output to a stream, for example std::cout.
		 *
       *  \param[in,out] outs The stream to output data into.
       *  \param[in] the_data The data to read data from.
      */
      friend std::ostream &operator << (std::ostream &outs, coordinateData &the_data);

   private:
      /*
         PRIVATE FUNCTIONS
      */
      /** \details Sets glyph code to empty value. */
      void createGlyphs();
      /** \details Sets coordinate to empty value, and portal number
       *  to default value of one (1).
      */
      void createCoordinates();

      /*
         PRIVATE VARIABLES
      */
      /** \var QString coordinates
       *
       *  \brief The coordinate sequence.

Changes to src/CoordinateMain.cpp.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//==================================================================
void to_glyphs (const QString &code, const bool valid,
                QTextStream &outs, const bool verbosity)
{
   coordinateData *window = new coordinateData(code, valid);
   window -> convertToGlyph();

//	qDebug() << *window;

   if ( window -> getGlyphCode().isEmpty() == false )
      outs << window -> getGlyphCode() << "\n";
   else
   {
      if ( verbosity == true )
      {
      	if ( window -> getErrorInfo().size() > 0 )
	      	outs << window -> showErrorInfo();
	      else
	      {
	      	if ( window -> getCoordinates().isEmpty() == false )
	      		outs << *window;
	      	else
		      	outs << "No coordinates provided.";
	      }
      }
   }
}
//------------------------------------------------------------------
void to_coords (const QString &code, const bool valid,
                QTextStream &outs, const bool verbosity)
{
   coordinateData *guess = new coordinateData (code, valid);
   guess -> convertFromGlyph();

//	qDebug() << *guess;

   if ( guess -> getCoordinate().isEmpty() == false )
   {
      outs << guess -> getCoordinate() << ", portal #";
      outs << guess -> getPortal() << "\n";
   }
   else
   {
      if ( verbosity == true )
      {
      	if ( guess -> getErrorInfo().size() > 0 )
      		outs << guess -> showErrorInfo();
      	else
      	{
      		if ( guess -> getGlyphCode().isEmpty() == false )
		      	outs << *guess;
		      else
		      	outs << "No glyph code provided.";
		   }
		}
   }
}
//------------------------------------------------------------------
inline void setApplicationSettings()
{
   QCoreApplication::setOrganizationName ("tion");
   QCoreApplication::setApplicationName ("nmspd");
................................................................................
      QTextStream outs (stdout);

      if ( coord == true && glyph == false )
      {
         // convert coordinates -> glyph
         for (int i = 0; i < args.size(); i++)
         {
            to_glyphs (args.at(i), bool(true), outs, verb);
         }
      }
      else if ( glyph == true && coord == false )
      {
         // convert glyph -> coordinates
         for (int i = 0; i < args.size(); i++)
         {
            to_coords (args.at(i), bool(false), outs, verb);
         }
      }
      else
      {
         if ( args.size() == 0 )
         {
            outs << "Did you want to run the gui? ";
................................................................................
         {
            // Options are mixed so best guess the inputs
            for (int i = 0; i < args.size(); i++)
            {
               if ( args.at(i).size() == 12 )
               {
                  // Assume is glyph code
                  to_coords (args.at(i), bool(false), outs, verb);
               }
               else if ( args.at(i).size() == 19 )
               {
                  // Assume is coordinate
                  to_glyphs (args.at(i), bool(true), outs, verb);
               }
               else { }
            }
         }
      }

      // Exit properly rather than keep waiting for input.
      app.quit();
   }
   else
   {
      QApplication app (argc, argv);
	  	setApplicationSettings();

      // Set GUI style
      QString gui_look = "Fusion", used;

      if ( argc >= 1 && argv[2] != QString() )
      {
         const QString temp_string = argv[2];

         if ( temp_string.size() < 15 )
            gui_look = QString(argv[2]);	// Get GUI-style to use
      }

      QApplication::setStyle(QStyleFactory::create(gui_look));
      used = QApplication::style() -> objectName();

      if ( gui_look.toLower() != used.toLower() )
      {
         qDebug() << gui_look << "cannot be used. Defaulting to" <<
                  used;
         qDebug() << "Available options for \'-style\':" <<
                  QStyleFactory::keys().join(", ");
      }

      MainWindow main_screen;
      main_screen.show();
      return app.exec ();
   }

   return (0);
}







<
<






|
|
|
|
|
|
|
|
|










<
<













|
|
|
|
|
|







 







|







|







 







|




|

|




|





|

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|

<








8
9
10
11
12
13
14


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168


















169
170

171
172
173
174
175
176
177
178
//==================================================================
void to_glyphs (const QString &code, const bool valid,
                QTextStream &outs, const bool verbosity)
{
   coordinateData *window = new coordinateData(code, valid);
   window -> convertToGlyph();



   if ( window -> getGlyphCode().isEmpty() == false )
      outs << window -> getGlyphCode() << "\n";
   else
   {
      if ( verbosity == true )
      {
         if ( window -> getErrorInfo().size() > 0 )
            outs << window -> showErrorInfo();
         else
         {
            if ( window -> getCoordinates().isEmpty() == false )
               outs << *window;
            else
               outs << "No coordinates provided.";
         }
      }
   }
}
//------------------------------------------------------------------
void to_coords (const QString &code, const bool valid,
                QTextStream &outs, const bool verbosity)
{
   coordinateData *guess = new coordinateData (code, valid);
   guess -> convertFromGlyph();



   if ( guess -> getCoordinate().isEmpty() == false )
   {
      outs << guess -> getCoordinate() << ", portal #";
      outs << guess -> getPortal() << "\n";
   }
   else
   {
      if ( verbosity == true )
      {
      	if ( guess -> getErrorInfo().size() > 0 )
      		outs << guess -> showErrorInfo();
      	else
      	{
            if ( guess -> getGlyphCode().isEmpty() == false )
               outs << *guess;
            else
               outs << "No glyph code provided.";
         }
      }
   }
}
//------------------------------------------------------------------
inline void setApplicationSettings()
{
   QCoreApplication::setOrganizationName ("tion");
   QCoreApplication::setApplicationName ("nmspd");
................................................................................
      QTextStream outs (stdout);

      if ( coord == true && glyph == false )
      {
         // convert coordinates -> glyph
         for (int i = 0; i < args.size(); i++)
         {
            to_glyphs (args.at(i), true, outs, verb);
         }
      }
      else if ( glyph == true && coord == false )
      {
         // convert glyph -> coordinates
         for (int i = 0; i < args.size(); i++)
         {
            to_coords (args.at(i), false, outs, verb);
         }
      }
      else
      {
         if ( args.size() == 0 )
         {
            outs << "Did you want to run the gui? ";
................................................................................
         {
            // Options are mixed so best guess the inputs
            for (int i = 0; i < args.size(); i++)
            {
               if ( args.at(i).size() == 12 )
               {
                  // Assume is glyph code
                  to_coords (args.at(i), false, outs, verb);
               }
               else if ( args.at(i).size() == 19 )
               {
                  // Assume is coordinate
                  to_glyphs (args.at(i), true, outs, verb);
               }
               else { /* Assume invalid input */ }
            }
         }
      }

      // Exit properly rather than waiting for input.
      app.quit();
   }
   else
   {
      QApplication app (argc, argv);
      setApplicationSettings();



















      qDebug() << "Available options for \'-style\':" <<
                  QStyleFactory::keys().join(", ");


      MainWindow main_screen;
      main_screen.show();
      return app.exec ();
   }

   return (0);
}

Changes to src/CoordinateMainWindow.cpp.

4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
...
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
...
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
#include "PortalAddressWindow.h"
#include "CoordinateMainWindow.h"
//==================================================================
///////////////////
// CLASS: Window //
///////////////////
//==================================================================
Window::Window (QWidget *parent) : QWidget (parent)

{
   initCoordinates();
   initGlyphs();

   createLayout();
}
//------------------------------------------------------------------
Window::Window (const QString &_code, bool isCoordinate)

{
   initCoordinates();
   initGlyphs();

   if ( isCoordinate == false )
      glyph_sequence -> setText (_code);
   else
      coordinates_input -> setText (_code);

	createLayout();
}
//------------------------------------------------------------------
QString Window::getGlyphCode()
{
	return (glyph_sequence -> text());
}
//------------------------------------------------------------------
QString Window::getCoordinate()
{
	return (coordinates_input -> text());
}
//------------------------------------------------------------------
QString Window::getCoordinates()
{
	return (getCoordinate());
}
//------------------------------------------------------------------
int Window::getPortal()
{
	return (portal_number -> value());
}
//------------------------------------------------------------------
void Window::createLayout()
{
   // Set minimum size of window
   setMinimumSize(415, 50);
   
................................................................................
void Window::showMessages (QStringList the_errors)
{
   // Set up QMessageBox::warning describing what is wrong with the
   // coordinate/glyph code
   QMessageBox *invalid_messages = new QMessageBox;
   QString text = QString();

	if ( the_errors.isEmpty() == true || QString(the_errors.join("")) == ":::" )
		text += QString (tr ("No code provided."));
	else
   {
	   text += QString(tr ("Problematic section: "));
   	text += QString ("[" + the_errors.join ("] [") + "]");
   	text += "\n\n";
   	text += QString(tr ("Please adjust."));
   }

   invalid_messages -> setText ( QString("<center> " +
                                         tr("INVALID CODE") + " </center") );
................................................................................
//------------------------------------------------------------------
void Window::preset_hova()
{
   setCoordinatePreset ("0467:0081:0D71:00AD", 1);
   GUI_convertToGlyph();
}
//------------------------------------------------------------------
void Window::initGlyphs()
{
   // QLineEdit to store glyph code sequence
   glyph_sequence = new QLineEdit;
   glyph_sequence -> setMaxLength (12);
   glyph_sequence -> setPlaceholderText ("F00101001001");
   glyph_sequence -> setCursorMoveStyle (Qt::VisualMoveStyle);
   glyph_sequence -> setClearButtonEnabled (true);
}
//------------------------------------------------------------------
void Window::initCoordinates()
{
   /*
      QLineEdit to store coordinate data
       Using inputMask rather than validator to allow for easier  
       user edits of this input field. With validator, the user will 
       have to either delete the whole line and retype, or 
       backspace/delete from the end of the line until where they 
................................................................................
{
   clearCoordinates();
   clearGlyphCode();
}
//------------------------------------------------------------------
void Window::clearCoordinates()
{
	coordinates_input -> clear();
	portal_number -> setValue (1);
}
//------------------------------------------------------------------
void Window::clearGlyphCode()
{
	glyph_sequence -> clear();
}
//------------------------------------------------------------------
void Window::clearMessages()
{
	//blackbox -> clearErrorInfo();
}
//------------------------------------------------------------------
void Window::GUI_convertFromGlyph()
{
   if ( glyph_sequence -> text().size() == 12 )
   {
   	coordinateData *blackbox = new coordinateData;

      // Move user input into blackbox for conversion
      blackbox -> setGlyphCode (glyph_sequence -> text());

      // Perform conversion: glyph code -> coordinates
      blackbox -> convertFromGlyph();

      if ( blackbox -> getCoordinates().size() == 19 )
      {
         // Move successful/valid conversion results to GUI
         coordinates_input -> setText (blackbox -> getCoordinate());
         glyph_sequence -> setText (blackbox -> getGlyphCode());
         portal_number -> setValue (blackbox -> getPortal());
         emit validCoordinate();
      }
      else
      {
      	qDebug() << "emitting haveErrors";
      	qDebug() << *blackbox;
         emit haveErrors (blackbox -> getErrorInfo());
      }
   }
}
//------------------------------------------------------------------
void Window::GUI_convertToGlyph()
{
   if ( coordinates_input -> text().isEmpty() == false
     && coordinates_input -> text() != ":::" )
   {
   	coordinateData *blackbox = new coordinateData;

      // Move user inputs to blackbox for conversion
      blackbox -> setPortal (portal_number -> value());
      blackbox -> setCoordinate (coordinates_input -> text());

      // Perform conversion: coordinates -> glyph code
      blackbox -> convertToGlyph();

      if ( blackbox -> getGlyphCode().size() == 12 )
      {
         // Move successful/valid conversion results to GUI
         glyph_sequence -> setText (blackbox -> getGlyphCode());
         coordinates_input -> setText (blackbox -> getCoordinate());
         portal_number -> setValue (blackbox -> getPortal());
         emit validGlyphCode();
      }
      else
      {
      	qDebug() << "emitting haveErrors";
      	qDebug() << *blackbox;
         emit haveErrors (blackbox -> getErrorInfo());
      }
   }
}
//------------------------------------------------------------------
void Window::syncGlyphCode()
{
	emit glyphChange();
}
//------------------------------------------------------------------







|
>

|
|




|
>

|
|






|




|




|




|




|







 







|
|
|

|







 







|









|







 







|
|




|
<
<
<
<
<






|


|


|

|

|
|
|
|




<
|
|









|


|
|


|

|

|
|
|
|




<
|
|






|


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
...
306
307
308
309
310
311
312
313
314
315
316
317
318
319





320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343

344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373

374
375
376
377
378
379
380
381
382
383
384
#include "PortalAddressWindow.h"
#include "CoordinateMainWindow.h"
//==================================================================
///////////////////
// CLASS: Window //
///////////////////
//==================================================================
Window::Window (QWidget *parent)
   : QWidget (parent)
{
   createCoordinates();
   createGlyphs();

   createLayout();
}
//------------------------------------------------------------------
Window::Window (const QString &_code, bool isCoordinate, QWidget *parent)
   : QWidget (parent)
{
   createCoordinates();
   createGlyphs();

   if ( isCoordinate == false )
      glyph_sequence -> setText (_code);
   else
      coordinates_input -> setText (_code);

   createLayout();
}
//------------------------------------------------------------------
QString Window::getGlyphCode()
{
   return (glyph_sequence -> text());
}
//------------------------------------------------------------------
QString Window::getCoordinate()
{
   return (coordinates_input -> text());
}
//------------------------------------------------------------------
QString Window::getCoordinates()
{
   return (getCoordinate());
}
//------------------------------------------------------------------
int Window::getPortal()
{
   return (portal_number -> value());
}
//------------------------------------------------------------------
void Window::createLayout()
{
   // Set minimum size of window
   setMinimumSize(415, 50);
   
................................................................................
void Window::showMessages (QStringList the_errors)
{
   // Set up QMessageBox::warning describing what is wrong with the
   // coordinate/glyph code
   QMessageBox *invalid_messages = new QMessageBox;
   QString text = QString();

   if ( the_errors.isEmpty() == true || QString(the_errors.join("")) == ":::" )
      text += QString (tr ("No code provided."));
   else
   {
      text += QString(tr ("Problematic section: "));
   	text += QString ("[" + the_errors.join ("] [") + "]");
   	text += "\n\n";
   	text += QString(tr ("Please adjust."));
   }

   invalid_messages -> setText ( QString("<center> " +
                                         tr("INVALID CODE") + " </center") );
................................................................................
//------------------------------------------------------------------
void Window::preset_hova()
{
   setCoordinatePreset ("0467:0081:0D71:00AD", 1);
   GUI_convertToGlyph();
}
//------------------------------------------------------------------
void Window::createGlyphs()
{
   // QLineEdit to store glyph code sequence
   glyph_sequence = new QLineEdit;
   glyph_sequence -> setMaxLength (12);
   glyph_sequence -> setPlaceholderText ("F00101001001");
   glyph_sequence -> setCursorMoveStyle (Qt::VisualMoveStyle);
   glyph_sequence -> setClearButtonEnabled (true);
}
//------------------------------------------------------------------
void Window::createCoordinates()
{
   /*
      QLineEdit to store coordinate data
       Using inputMask rather than validator to allow for easier  
       user edits of this input field. With validator, the user will 
       have to either delete the whole line and retype, or 
       backspace/delete from the end of the line until where they 
................................................................................
{
   clearCoordinates();
   clearGlyphCode();
}
//------------------------------------------------------------------
void Window::clearCoordinates()
{
   coordinates_input -> clear();
   portal_number -> setValue (1);
}
//------------------------------------------------------------------
void Window::clearGlyphCode()
{
   glyph_sequence -> clear();





}
//------------------------------------------------------------------
void Window::GUI_convertFromGlyph()
{
   if ( glyph_sequence -> text().size() == 12 )
   {
      coordinateData blackbox = coordinateData();

      // Move user input into blackbox for conversion
      blackbox.setGlyphCode (glyph_sequence -> text());

      // Perform conversion: glyph code -> coordinates
      blackbox.convertFromGlyph();

      if ( blackbox.getCoordinates().size() == 19 )
      {
         // Move successful conversion results to GUI
         coordinates_input -> setText (blackbox.getCoordinate());
         glyph_sequence -> setText (blackbox.getGlyphCode());
         portal_number -> setValue (blackbox.getPortal());
         emit validCoordinate();
      }
      else
      {

         qDebug() << blackbox;
         emit haveErrors (blackbox.getErrorInfo());
      }
   }
}
//------------------------------------------------------------------
void Window::GUI_convertToGlyph()
{
   if ( coordinates_input -> text().isEmpty() == false
     && coordinates_input -> text() != ":::" )
   {
      coordinateData blackbox = coordinateData();

      // Move user inputs to blackbox for conversion
      blackbox.setPortal (portal_number -> value());
      blackbox.setCoordinate (coordinates_input -> text());

      // Perform conversion: coordinates -> glyph code
      blackbox.convertToGlyph();

      if ( blackbox.getGlyphCode().size() == 12 )
      {
         // Move successful conversion results to GUI
         glyph_sequence -> setText (blackbox.getGlyphCode());
         coordinates_input -> setText (blackbox.getCoordinate());
         portal_number -> setValue (blackbox.getPortal());
         emit validGlyphCode();
      }
      else
      {

         qDebug() << blackbox;
         emit haveErrors (blackbox.getErrorInfo());
      }
   }
}
//------------------------------------------------------------------
void Window::syncGlyphCode()
{
   emit glyphChange();
}
//------------------------------------------------------------------

Changes to src/CoordinateMainWindow.h.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
...
130
131
132
133
134
135
136
137
138
139


140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163
164
165
166
167
 * 
*/
class Window : public QWidget
{
   // Macro to allow for custom slots and signals
   Q_OBJECT

	public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      /** Default constructor */
      explicit Window(QWidget *parent = 0);
      /** \overload Window(const QString &, bool)
       * 
       *  \param[in] _code A valid coordinate or glyph code.
       *  \param[in] isCoordinate Denotes _code as being a coordinate.
      */
      Window(const QString &_code, bool isCoordinate = true);

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      /** Initialize GUI objects/elements */
      void createLayout();

		/** \returns The glyph code. */
		QString getGlyphCode();
		/** \returns The coordinates. */
	   QString getCoordinate();
	   /** Convenience function for getCoordinate.
	    * 
	    *  \returns The coordinates.
	    * 
	    *  \see getCoordinate
	   */
	   QString getCoordinates();
	   /** \returns The portal number. */
	   int getPortal();

		/** Sets the coordinate and portal value. Intended for location
		 *  presets and as such has no error-checking of the provided
		 *  inputs.
		 * 
		 *  \param[in] _code A valid coordinate.
		 *  \param[in] _portal A valid portal number.
		*/
      void setCoordinatePreset(const QString &_code, const int _portal = 1);
      /** Sets the glyph code value. Intended for location presets
       *  and as such has no error-checking of the provided _code.
       * 
       *  \param[in] _code A valid glyph code.
      */
      void setGlyphCodePreset(const QString &_code);

   signals:
   	/** This signal is emitted when the coordinate or glyph code
   	 *  is invalid.
   	*/
      void haveErrors (QStringList);
      /** This signal is emitted when the glyph code has been
       *  validated.
      */
	  	void validGlyphCode();
	  	/** This signal is emitted when the coordinate has been
	  	 *  validated.
	  	*/
	  	void validCoordinate();
	  	/** This signal is emitted when there is a change to the 
	  	 *  glyphs.
	  	*/
	  	void glyphChange();

   public slots:
   	/** Calls the method to convert the current coordinates into 
   	 *  a glyph code.
   	 * 
   	 *  \see CoordinateData::convertToGlyph
   	*/
      void GUI_convertToGlyph();
      /** Calls the method to convert the current glyph code into
       *  coordinates.
       * 
       *  \see CoordinateData::convertFromGlyph
      */
      void GUI_convertFromGlyph();
      /** Emits the signal glyphChange. */
	  	void syncGlyphCode();
      //void about();
      /** Show errors in a QMessageBox about the supplied code
       *  preventing conversion.
      */
      void showMessages (QStringList);

      // Show coordinates/portal address for location preset
      /** Pre-fills coordinate data for the preset: HUB. */
      void preset_hub();
      /** Pre-fills coordinate data for the preset: Amino. */
      void preset_amino();
      /** Pre-fills coordinate data for the preset: DTT. */
................................................................................
      */
      /** Clears all private variable values to null/empty. */
      void reset(); 
      /** Clears coordinates value. */
      void clearCoordinates();
      /** Clears all glyph images. */
      void clearGlyphCode();
      /** Clears error messages about coordinate data.
       * 
       *  This function is mostly useless as reset will perform this


       *  functionality as well.
       * 
       *  \deprecated To be removed by version 1.0. Consider using 
       *  reset() instead.
      */
      void clearMessages();

   private:
   	/** Removes any existing glyphs. */
      void initGlyphs();
      /** Sets coordinates and portal number to default value:
       *  empty, 1.
      */
      void initCoordinates();

		/** \var coordinateData *blackbox

		 * 
		 *  \brief Holds temporary coordinate data.
		*/
      //coordinateData *blackbox;

      // GUI-specific objects
      /** \var QLineEdit *coordinates_input
       * 
       *  \brief Holds the coordinates value.
      */
      QLineEdit *coordinates_input;
      /** \var QLineEdit *glyph_sequence







|










|







|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|









|
|
|
|



|
|
|
|
|
|
|
|
|


|
|
|
|
|




|



|
<



|







 







<
|
<
>
>
|
|
<
<
<
<
<
<
|
|



|

|
>
|
<
<
<
<







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
117
118
119
120
...
129
130
131
132
133
134
135

136

137
138
139
140






141
142
143
144
145
146
147
148
149
150




151
152
153
154
155
156
157
 * 
*/
class Window : public QWidget
{
   // Macro to allow for custom slots and signals
   Q_OBJECT

   public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      /** Default constructor */
      explicit Window(QWidget *parent = 0);
      /** \overload Window(const QString &, bool)
       * 
       *  \param[in] _code A valid coordinate or glyph code.
       *  \param[in] isCoordinate Denotes _code as being a coordinate.
      */
      explicit Window(const QString &_code, bool isCoordinate = true, QWidget *parent = 0);

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      /** Initialize GUI objects/elements */
      void createLayout();

      /** \returns The glyph code. */
      QString getGlyphCode();
      /** \returns The coordinates. */
      QString getCoordinate();
      /** Convenience function for getCoordinate.
       * 
       *  \returns The coordinates.
       * 
       *  \see getCoordinate
       */
      QString getCoordinates();
      /** \returns The portal number. */
      int getPortal();

      /** Sets the coordinate and portal value. Intended for location
       *  presets and as such has no error-checking of the provided
       *  inputs.
       * 
       *  \param[in] _code A valid coordinate.
       *  \param[in] _portal A valid portal number.
      */
      void setCoordinatePreset(const QString &_code, const int _portal = 1);
      /** Sets the glyph code value. Intended for location presets
       *  and as such has no error-checking of the provided _code.
       * 
       *  \param[in] _code A valid glyph code.
      */
      void setGlyphCodePreset(const QString &_code);

   signals:
      /** This signal is emitted when the coordinate or glyph code
       *  is invalid.
      */
      void haveErrors(QStringList errorList);
      /** This signal is emitted when the glyph code has been
       *  validated.
      */
      void validGlyphCode();
      /** This signal is emitted when the coordinate has been
       *  validated.
      */
      void validCoordinate();
      /** This signal is emitted when there is a change to the 
       *  glyphs.
      */
      void glyphChange();

   public slots:
      /** Calls the method to convert the current coordinates into 
       *  a glyph code.
       * 
       *  \see coordinateData::convertToGlyph
      */
      void GUI_convertToGlyph();
      /** Calls the method to convert the current glyph code into
       *  coordinates.
       * 
       *  \see coordinateData::convertFromGlyph
      */
      void GUI_convertFromGlyph();
      /** Emits the signal glyphChange. */
      void syncGlyphCode();

      /** Show errors in a QMessageBox about the supplied code
       *  preventing conversion.
      */
      void showMessages(QStringList the_errors);

      // Show coordinates/portal address for location preset
      /** Pre-fills coordinate data for the preset: HUB. */
      void preset_hub();
      /** Pre-fills coordinate data for the preset: Amino. */
      void preset_amino();
      /** Pre-fills coordinate data for the preset: DTT. */
................................................................................
      */
      /** Clears all private variable values to null/empty. */
      void reset(); 
      /** Clears coordinates value. */
      void clearCoordinates();
      /** Clears all glyph images. */
      void clearGlyphCode();



   private:
      /*
         PRIVATE FUNCTIONS
      */






      /** Removes any existing glyphs. */
      void createGlyphs();
      /** Sets coordinates and portal number to default value:
       *  empty, 1.
      */
      void createCoordinates();

      /*
         PRIVATE VARIABLES
      */




      // GUI-specific objects
      /** \var QLineEdit *coordinates_input
       * 
       *  \brief Holds the coordinates value.
      */
      QLineEdit *coordinates_input;
      /** \var QLineEdit *glyph_sequence

Changes to src/HelperFunctions.cpp.

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
            errors.append (pad_with_zeros(coord, 4));
         }
      }
   }
   else
   {
      result = false;
		errors.append (__code);
   }

   return (result);
}
//------------------------------------------------------------------
bool is_valid_glyph_code (const QString &_code, QStringList &error)
{







|







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
            errors.append (pad_with_zeros(coord, 4));
         }
      }
   }
   else
   {
      result = false;
      errors.append (__code);
   }

   return (result);
}
//------------------------------------------------------------------
bool is_valid_glyph_code (const QString &_code, QStringList &error)
{

Changes to src/HelperFunctions.h.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/** \file HelperFunctions.h
 *
 *  \brief Helper functions to assist in manipulating coordinate data.
 *
 *  \details Provides convenience functions to facilitate converting
 *  between coordinates and glyph codes.
 * 
 *  \see CoordinateData
*/
//------------------------------------------------------------------
#ifndef __HELPER_FUNCTIONS_H__
#define __HELPER_FUNCTIONS_H__
//------------------------------------------------------------------
#include <QtCore>
//------------------------------------------------------------------







|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/** \file HelperFunctions.h
 *
 *  \brief Helper functions to assist in manipulating coordinate data.
 *
 *  \details Provides convenience functions to facilitate converting
 *  between coordinates and glyph codes.
 * 
 *  \see coordinateData
*/
//------------------------------------------------------------------
#ifndef __HELPER_FUNCTIONS_H__
#define __HELPER_FUNCTIONS_H__
//------------------------------------------------------------------
#include <QtCore>
//------------------------------------------------------------------

Changes to src/MainWindow.cpp.

7
8
9
10
11
12
13
14
15

16
17
18
19

20

21
22
23
24
25
26
27

28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
..
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98
99
100

101
102
103
104
105
106

107
108
109
110
111
112

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136


137
138
139
140
141
142
143
...
145
146
147
148
149
150
151





152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// CLASS: MainWindow //
///////////////////////
//------------------------------------------------------------------
/////////////////
// CONSTRUCTOR //
/////////////////
//------------------------------------------------------------------
MainWindow::MainWindow()
{

   setWindowTitle ("nmspd");
   
   conversion_screen = new Window;
   setCentralWidget (conversion_screen);



   portal_address = new Glyphs;
   QDockWidget *topWidget = new QDockWidget(tr ("Portal Address"), this);
   topWidget -> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
   topWidget -> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   topWidget -> setWidget (portal_address);
   addDockWidget (Qt::TopDockWidgetArea, topWidget);


   glyph_selector = new PortalDialer;
   QDockWidget *bottomWidget = new QDockWidget (tr ("Glyph Entry"), this);
   bottomWidget -> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
   bottomWidget -> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   bottomWidget -> setWidget (glyph_selector);
   addDockWidget (Qt::BottomDockWidgetArea, bottomWidget);

   createActions();

   createMenus();
   createToolBar();
}
//------------------------------------------------------------------
//////////////////
// PUBLIC SLOTS //
//////////////////
................................................................................
   portal_address -> reset();
   glyph_selector -> reset();
}
//------------------------------------------------------------------
///////////////////////
// PRIVATE FUNCTIONS //
///////////////////////

void MainWindow::createToolBar()
{
   // TODO: Find (or create) some icons to use for these toolbar 
   //  actions. As it stands, these are text-only toolbar buttons
   QToolBar *mainToolBar;
   mainToolBar = addToolBar (tr ("Control"));
   mainToolBar -> setAllowedAreas (Qt::AllToolBarAreas);
   
   // Toggle glyph entry window (PortalAddressPickerWindow -- Glyphs)
   QAction *showPortalAction = new QAction (tr ("&Glyph entry"));

   QObject::connect (showPortalAction, &QAction::triggered, this, &MainWindow::showPortal);
   mainToolBar -> addAction (showPortalAction);
   mainToolBar -> addSeparator ();
   
   // Toggle portal address window (PortalAddressWindow -- PortalDialer)
   QAction *showGlyphInput = new QAction (tr ("&Portal Address"));

   QObject::connect (showGlyphInput, &QAction::triggered, this, &MainWindow::showGlyphs);
   mainToolBar -> addAction (showGlyphInput);
   mainToolBar -> addSeparator ();
   
   // Clear inputs of main window and portal address
   QAction *clearInputsAction = new QAction (tr ("Clear All"));

   QObject::connect (clearInputsAction, &QAction::triggered, this, &MainWindow::reset);
   mainToolBar -> addAction (clearInputsAction);
   mainToolBar -> addSeparator ();
}
//------------------------------------------------------------------
void MainWindow::createActions()
{
   exit_action = new QAction (QIcon(QIcon::fromTheme ("application-exit")), tr ("E&xit"));
   exit_action -> setShortcuts (QKeySequence::Quit);
   exit_action -> setStatusTip (tr ("Exit the application"));
   //connect (exit_action, &QAction::triggered, this, &QWidget::close);
   QObject::connect (exit_action, &QAction::triggered, this, &QApplication::quit);

   about_action = new QAction (tr ("&About"));
   about_action -> setStatusTip (tr ("Show the application's About box"));
   QObject::connect (about_action, &QAction::triggered, this, &MainWindow::about);

   about_qt_action = new QAction (tr ("About &Qt"));
   about_qt_action -> setStatusTip (tr ("Show the Qt library's About box"));
   QObject::connect (about_qt_action, &QAction::triggered, qApp, &QApplication::aboutQt);
   
   // TODO: Update glyph code from conversion_screen to 
   // glyph_selector because right now it syncs one way: 
   // glyph_selector --> conversion_screen.


   QObject::connect (glyph_selector, &PortalDialer::codeChange, this, &MainWindow::updateGlyphsFromInputWindow);
   QObject::connect (conversion_screen, &Window::validCoordinate, this, &MainWindow::updatePortalAddressFromMainWindow);
   QObject::connect (conversion_screen, &Window::validGlyphCode, this, &MainWindow::updatePortalAddressFromMainWindow);
   QObject::connect (glyph_selector, &PortalDialer::codeReady, this, &MainWindow::conversion);
   QObject::connect (conversion_screen, &Window::glyphChange, this, &MainWindow::updateGlyphsToInputWindow);
}
//------------------------------------------------------------------
................................................................................
{
   fileMenu = menuBar() -> addMenu (tr ("&File"));
   fileMenu -> addAction (exit_action);

   helpMenu = menuBar() -> addMenu (tr ("&Help"));
   helpMenu -> addAction (about_action);
   helpMenu -> addAction (about_qt_action);





}
//------------------------------------------------------------------
///////////////////
// PRIVATE SLOTS //
///////////////////
//------------------------------------------------------------------
void MainWindow::about()
{
	QMessageBox::about (this, tr ("About nmspd"),
					tr ("<center><h2>nmspd</h2>v0.6.0<br><br><br>" 
					"Author: <a href=\"https://codeberg.org/tfnm/nmspd\">tion</a>"
					"</center>"
					"<hr />"
					"<p>"
					"The glyph symbols used in this program are slightly modified "
					"from images on "
					"<a href=\"https://nomanssky.gamepedia.com/Glyph\">"
					"https://nomanssky.gamepedia.com</a>. These images are "
					"property of Hello Games. The use of "
					"these images is for educational purposes only.</p><hr /><p>"
					"This program is free software: you can redistribute it "
					"and/or modify it under the terms of the GNU General "
					"Public License as published by the Free Software "
					"Foundation, either version 3 of the License, or (at your option) "
					"any later version.</p><p>"
					"This program is distributed in the hope that it will be useful, but "
					"WITHOUT ANY WARRANTY; without even implied warranty of MERCHANTABILITY "
					"or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License "
					"for more details.</p><p>"
					"You should have received a copy of the GNU General Public License along "
					"with this program. If not, see &lt;"
					"<a href=\"http://www.gnu.org/licenses/\" target=\"_blank\">"
					"http//www.gnu.org/licenses/</a>&gt;.</p>"));
}
//------------------------------------------------------------------







|
<
>
|
|
<

>

>







>








>







 







>










>



|


>



|


>










<









|



>
>







 







>
>
>
>
>








|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
7
8
9
10
11
12
13
14

15
16
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// CLASS: MainWindow //
///////////////////////
//------------------------------------------------------------------
/////////////////
// CONSTRUCTOR //
/////////////////
//------------------------------------------------------------------
MainWindow::MainWindow (QWidget *parent)

   : QMainWindow (parent),
   conversion_screen (new Window(this))
{

   setCentralWidget (conversion_screen);
   setWindowTitle ("nmspd");

   // Create dock widget: Top
   portal_address = new Glyphs;
   QDockWidget *topWidget = new QDockWidget(tr ("Portal Address"), this);
   topWidget -> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
   topWidget -> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   topWidget -> setWidget (portal_address);
   addDockWidget (Qt::TopDockWidgetArea, topWidget);

   // Create dock widget: Bottom
   glyph_selector = new PortalDialer;
   QDockWidget *bottomWidget = new QDockWidget (tr ("Glyph Entry"), this);
   bottomWidget -> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
   bottomWidget -> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   bottomWidget -> setWidget (glyph_selector);
   addDockWidget (Qt::BottomDockWidgetArea, bottomWidget);

   createActions();
   createStatusBar();
   createMenus();
   createToolBar();
}
//------------------------------------------------------------------
//////////////////
// PUBLIC SLOTS //
//////////////////
................................................................................
   portal_address -> reset();
   glyph_selector -> reset();
}
//------------------------------------------------------------------
///////////////////////
// PRIVATE FUNCTIONS //
///////////////////////
//------------------------------------------------------------------
void MainWindow::createToolBar()
{
   // TODO: Find (or create) some icons to use for these toolbar 
   //  actions. As it stands, these are text-only toolbar buttons
   QToolBar *mainToolBar;
   mainToolBar = addToolBar (tr ("Control"));
   mainToolBar -> setAllowedAreas (Qt::AllToolBarAreas);
   
   // Toggle glyph entry window (PortalAddressPickerWindow -- Glyphs)
   QAction *showPortalAction = new QAction (tr ("&Glyph entry"));
   showPortalAction -> setStatusTip (tr ("Show/Hide glyph entry window"));
   QObject::connect (showPortalAction, &QAction::triggered, this, &MainWindow::showPortal);
   mainToolBar -> addAction (showPortalAction);
   mainToolBar -> addSeparator ();

   // Toggle portal address window (PortalAddressWindow -- PortalDialer)
   QAction *showGlyphInput = new QAction (tr ("&Portal Address"));
   showGlyphInput -> setStatusTip (tr ("Show/Hide portal address window"));
   QObject::connect (showGlyphInput, &QAction::triggered, this, &MainWindow::showGlyphs);
   mainToolBar -> addAction (showGlyphInput);
   mainToolBar -> addSeparator ();

   // Clear inputs of main window and portal address
   QAction *clearInputsAction = new QAction (tr ("Clear All"));
   clearInputsAction -> setStatusTip (tr ("Reset coordinates, glyph code, and glyphs."));
   QObject::connect (clearInputsAction, &QAction::triggered, this, &MainWindow::reset);
   mainToolBar -> addAction (clearInputsAction);
   mainToolBar -> addSeparator ();
}
//------------------------------------------------------------------
void MainWindow::createActions()
{
   exit_action = new QAction (QIcon(QIcon::fromTheme ("application-exit")), tr ("E&xit"));
   exit_action -> setShortcuts (QKeySequence::Quit);
   exit_action -> setStatusTip (tr ("Exit the application"));

   QObject::connect (exit_action, &QAction::triggered, this, &QApplication::quit);

   about_action = new QAction (tr ("&About"));
   about_action -> setStatusTip (tr ("Show the application's About box"));
   QObject::connect (about_action, &QAction::triggered, this, &MainWindow::about);

   about_qt_action = new QAction (tr ("About &Qt"));
   about_qt_action -> setStatusTip (tr ("Show the Qt library's About box"));
   QObject::connect (about_qt_action, &QAction::triggered, qApp, &QApplication::aboutQt);

   // TODO: Update glyph code from conversion_screen to 
   // glyph_selector because right now it syncs one way: 
   // glyph_selector --> conversion_screen.
   //
   // Edit: Let's not.
   QObject::connect (glyph_selector, &PortalDialer::codeChange, this, &MainWindow::updateGlyphsFromInputWindow);
   QObject::connect (conversion_screen, &Window::validCoordinate, this, &MainWindow::updatePortalAddressFromMainWindow);
   QObject::connect (conversion_screen, &Window::validGlyphCode, this, &MainWindow::updatePortalAddressFromMainWindow);
   QObject::connect (glyph_selector, &PortalDialer::codeReady, this, &MainWindow::conversion);
   QObject::connect (conversion_screen, &Window::glyphChange, this, &MainWindow::updateGlyphsToInputWindow);
}
//------------------------------------------------------------------
................................................................................
{
   fileMenu = menuBar() -> addMenu (tr ("&File"));
   fileMenu -> addAction (exit_action);

   helpMenu = menuBar() -> addMenu (tr ("&Help"));
   helpMenu -> addAction (about_action);
   helpMenu -> addAction (about_qt_action);
}
//------------------------------------------------------------------
void MainWindow::createStatusBar()
{
   statusBar() -> showMessage (tr ("Ready!"), 5000);
}
//------------------------------------------------------------------
///////////////////
// PRIVATE SLOTS //
///////////////////
//------------------------------------------------------------------
void MainWindow::about()
{
   QMessageBox::about (this, tr ("About nmspd"),
            tr ("<center><h2>nmspd</h2>v0.6.0<br><br><br>" 
            "Author: <a href=\"https://codeberg.org/tfnm/nmspd\">tion</a>"
            "</center>"
            "<hr />"
            "<p>"
            "The glyph symbols used in this program are slightly modified "
            "from images on "
            "<a href=\"https://nomanssky.gamepedia.com/Glyph\">"
            "https://nomanssky.gamepedia.com</a>. These images are "
            "property of Hello Games. The use of "
            "these images is for educational purposes only.</p><hr /><p>"
            "This program is free software: you can redistribute it "
            "and/or modify it under the terms of the GNU General "
            "Public License as published by the Free Software "
            "Foundation, either version 3 of the License, or (at your option) "
            "any later version.</p><p>"
            "This program is distributed in the hope that it will be useful, but "
            "WITHOUT ANY WARRANTY; without even implied warranty of MERCHANTABILITY "
            "or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License "
            "for more details.</p><p>"
            "You should have received a copy of the GNU General Public License along "
            "with this program. If not, see &lt;"
            "<a href=\"http://www.gnu.org/licenses/\" target=\"_blank\">"
            "http//www.gnu.org/licenses/</a>&gt;.</p>"));
}
//------------------------------------------------------------------

Changes to src/MainWindow.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64


65
66
67
68
69
70
71
..
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//==================================================================
#ifndef __NMS_CONVERT_MAIN_WINDOW_H__
#define __NMS_CONVERT_MAIN_WINDOW_H__
//==================================================================
#include <QMainWindow>
#include <QAction>
#include <QMenu>

#include "CoordinateMainWindow.h"
#include "PortalAddressWindow.h"
#include "PortalAddressPickerWindow.h"
//==================================================================
//class ToolBar;
//QT_FORWARD_DECLARE_CLASS (QMenu)
/** \class MainWindow
 * 
 *  \brief The main window to handle coordinate/glyph code
 *  conversion.
 * 
 *  To create a MainWindow:
 * 
 * 		// Create a bare object
 * 		MainWindow example;
 * 
*/
class MainWindow : public QMainWindow
{
   Q_OBJECT

   public:
      /////////////////
      // CONSTRUCTOR //
      /////////////////
      /** Default constructor. */
      MainWindow();

   signals:

   public slots:
      //void action_triggered (QAction *);
      /** Show input portal address window. */
      void showPortal();
      /** Show resulting portal address window. */
      void showGlyphs();
		/** Updates changes to glyphs into glyph code input field. */
      void updateGlyphsToInputWindow();
      /** Updates changes from input field to glyphs. */
	  	void updateGlyphsFromInputWindow();
	  	/** Updates changes from input fields to portal address. */
	  	void updatePortalAddressFromMainWindow();
	  	/** Calls the methods to convert the coordinates or glyph code
	  	 *  into a portal address.
	  	*/
	  	void conversion();
	  	/** Clears all input fields, glyphs, and portal address. */
	  	void reset();

   private:
   	/** Initializes and sets the menu items. */
      void createMenus();
      /** Initializes actions for menu items and private variables. */
      void createActions();
      /** Initializes and sets the toolbar items. */
	  	void createToolBar();



      // MenuBar items
      /** \var QMenu *fileMenu
       *
       *  \brief Menu item for 'File'.
      */
      QMenu *fileMenu;
................................................................................
      QAction *about_action;
      /** \var QAction *about_qt_action
       *
       *  \brief Action to view information about Qt.
      */
      QAction *about_qt_action;

		/** \var Window *conversion_screen
		 *
		 *  \brief Central widget showing the input fields for
		 *  coordinates and glyph code.
		 *
		 *  \see Window
		*/
	  	Window *conversion_screen;
	  	/** \var Glyphs *portal_address
	  	 *
	  	 *  \brief Top dock widget showing the resulting portal
	  	 *  address.
	  	*/
	  	Glyphs *portal_address;
	  	/** \var PortalDialer *glyph_selector
	  	 *
	  	 *  \brief Bottom dock widget showing the glyph selection
	  	 *  window.
	  	*/
      PortalDialer *glyph_selector;

   private slots:
      // Respond to user activating the menu entries.
      /** Show a QMessageBox with information about this program. */
      void about();
};
//==================================================================
#endif	// __NMS_CONVERT_MAIN_WINDOW_H__
//==================================================================




<
<
<
<




<
<







|
|











|









|


|
|
|
|
|
|
|
|
|


|




|
>
>







 







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|










1
2
3
4




5
6
7
8


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//==================================================================
#ifndef __NMS_CONVERT_MAIN_WINDOW_H__
#define __NMS_CONVERT_MAIN_WINDOW_H__
//==================================================================




#include "CoordinateMainWindow.h"
#include "PortalAddressWindow.h"
#include "PortalAddressPickerWindow.h"
//==================================================================


/** \class MainWindow
 * 
 *  \brief The main window to handle coordinate/glyph code
 *  conversion.
 * 
 *  To create a MainWindow:
 * 
 *       MainWindow example;
 *	      example.show();
 * 
*/
class MainWindow : public QMainWindow
{
   Q_OBJECT

   public:
      /////////////////
      // CONSTRUCTOR //
      /////////////////
      /** Default constructor. */
      explicit MainWindow(QWidget *parent = 0);

   signals:

   public slots:
      //void action_triggered (QAction *);
      /** Show input portal address window. */
      void showPortal();
      /** Show resulting portal address window. */
      void showGlyphs();
      /** Updates changes to glyphs into glyph code input field. */
      void updateGlyphsToInputWindow();
      /** Updates changes from input field to glyphs. */
      void updateGlyphsFromInputWindow();
      /** Updates changes from input fields to portal address. */
      void updatePortalAddressFromMainWindow();
      /** Calls the methods to convert the coordinates or glyph code
       *  into a portal address.
      */
      void conversion();
      /** Clears all input fields, glyphs, and portal address. */
      void reset();

   private:
      /** Initializes and sets the menu items. */
      void createMenus();
      /** Initializes actions for menu items and private variables. */
      void createActions();
      /** Initializes and sets the toolbar items. */
      void createToolBar();
      /** Initializes the status bar. */
      void createStatusBar();

      // MenuBar items
      /** \var QMenu *fileMenu
       *
       *  \brief Menu item for 'File'.
      */
      QMenu *fileMenu;
................................................................................
      QAction *about_action;
      /** \var QAction *about_qt_action
       *
       *  \brief Action to view information about Qt.
      */
      QAction *about_qt_action;

      /** \var Window *conversion_screen
       *
       *  \brief Central widget showing the input fields for
       *  coordinates and glyph code.
       *
       *  \see Window
      */
      Window *conversion_screen;
      /** \var Glyphs *portal_address
       *
       *  \brief Top dock widget showing the resulting portal
       *  address.
      */
      Glyphs *portal_address;
      /** \var PortalDialer *glyph_selector
       *
       *  \brief Bottom dock widget showing the glyph selection
       *  window.
      */
      PortalDialer *glyph_selector;

   private slots:
      // Respond to user activating the menu entries.
      /** Show a QMessageBox with information about this program. */
      void about();
};
//==================================================================
#endif	// __NMS_CONVERT_MAIN_WINDOW_H__
//==================================================================

Changes to src/PortalAddressPickerWindow.cpp.

2
3
4
5
6
7
8
9

10
11

12
13
14
15

16
17
18

19
20
21
22
23




24
25
26
27
28
29

30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170












171
172
173
174
175
176
177
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
...
234
235
236
237
238
239
240
241
242






243
244
245









246
247
248
#include "PortalAddressPickerWindow.h"
#include "HelperFunctions.h"
//==================================================================
/////////////////////////
// CLASS: PortalDialer //
/////////////////////////
//------------------------------------------------------------------
PortalDialer::PortalDialer (QWidget *parent) : QWidget (parent)

{
   initGlyphs();

   initLayout();
}
//------------------------------------------------------------------
PortalDialer::PortalDialer (const QString &_code)

{
   initGlyphs();
   setGlyphs(_code);

   initLayout();
}
//------------------------------------------------------------------
void PortalDialer::initGlyphs()
{




   code = new QStack<QChar>;
   code -> clear();

   for (int i = 0; i < 16; i++)
   {
      glyph_input[i] = new QPushButton;

      glyph_input[i] -> setIconSize (QSize(40, 40));

      glyph_input[i] -> setAutoFillBackground (false);
      glyph_input[i] -> setCheckable (false);
      glyph_input[i] -> setFlat (false);
      glyph_input[i] -> setIcon (QIcon (QString (":" + QString(
                                           convert_integer_to_hex(i)).toUpper() + QString(".jpg"))));
   /*
      if ( i < 12 ) {
         glyph_select[i] = new QPushButton;
         glyph_select[i] -> setFlat (false);
         glyph_select[i] -> setCheckable (false);
         glyph_select[i] -> setAutoFillBackground (true);
         glyph_select[i] -> setIconSize (QSize(60, 60));
         glyph_select[i] -> setIcon (QIcon (QString (":empty.png")));
      }
   */
   }
}
//------------------------------------------------------------------
void PortalDialer::setGlyphs (const QString &_code)
{
   if ( _code.size() <= 12 )
   {
      QString fileName = QString();

      if ( code -> isEmpty() == false &&
           (_code.toLower() != glyph_code -> text().toLower()) )
      {
         reset();
         QStack<QChar> temp;
         temp.clear();
         const QRegularExpression validHex ("[0-9A-F]");
         QRegularExpressionMatch isValidHex;

         for (int i = 0; i < 12; i++)
         {
            if ( _code.isEmpty() == true )
            {
................................................................................
            }
            else
            {
               isValidHex = validHex.match (_code.at(i).toUpper());

               if ( isValidHex.hasMatch() == true )
               {
                  //code -> push(_code.at(i).toUpper());
                  temp.push(_code.at(i).toUpper());
                  //emit codeChange();
                  fileName = ":" + QString(_code.at(i)).toUpper() + ".jpg";
               }
            }

            //glyph_select[i] -> setIcon (QIcon (QString (fileName)));
         }

         glyph_code -> setText (getCode());
         code -> swap (temp);
         emit codeChange();

         if ( glyph_code -> text().size() == 12 )
................................................................................
//------------------------------------------------------------------
QString PortalDialer::getCode()
{
   QString result = QString();

   for (int i = 0; i < code -> size(); i++)
   {
      result += QString(code -> at(i));
   }

   return (result);
}
//------------------------------------------------------------------
void PortalDialer::getGlyph (const int index)
{
   if ( code -> size() < 12 )
   {
      int i = (code -> size());
      QChar result = convert_integer_to_hex(index).at(0);

      if ( i < 0 )
         i = 0;

      if ( i < 12  )
      {
         //glyph_select[i] -> setIcon (QIcon (QString (":" + QString(result) + ".jpg")));
         code -> push(result);
         glyph_code -> setText (getCode());
         emit codeChange();
      }
   }

   // Update status of code after (any) change
   if ( code -> size() == 12 )
      emit codeReady();
   else
   {
................................................................................
}
//------------------------------------------------------------------
void PortalDialer::clearOne()
{
   if ( code -> isEmpty() == false )
   {
      code -> pop();
      //glyph_select[code -> size()] -> setIcon (QIcon (QString (":empty.png")));
      glyph_code -> setText (getCode());
      emit codeIncomplete();
   }

   emit codeChange();
}
//------------------------------------------------------------------
void PortalDialer::initLayout()
{
   glyph_code = new QLineEdit;
   glyph_code -> setMaxLength (12);
   glyph_code -> setReadOnly (true);













   QPushButton *back_button = new QPushButton;
   back_button -> setText (tr ("Delete"));
   back_button -> setToolTip (
      tr ("Backspace/Delete one digit to the left"));
   back_button -> setCheckable (false);

   QPushButton *reset_button = new QPushButton;
................................................................................
   reset_button -> setText (tr ("Clear"));
   reset_button -> setToolTip (tr ("Reset all glyphs entered"));
   reset_button -> setCheckable (false);

   /*
      Create grid layout.

     control_group:
      +--------+-------+
      | delete | clear |
      +--------+-------+
      |   glyph_code   |
      +----------------+
   */
   QGroupBox *control_group = new QGroupBox;
   QGridLayout *buttons = new QGridLayout;
   buttons -> addWidget (back_button, 0, 0, 1, 1);
   buttons -> addWidget (reset_button, 0, 1, 1, 1);
   buttons -> addWidget (glyph_code, 1, 0, 1, 2);
   control_group -> setLayout (buttons);
................................................................................

   /*
     Handle pushing the buttons
   */
   // Delete glyph(s) previously selected
   QObject::connect (back_button, &QPushButton::clicked, this, &PortalDialer::clearOne);
   QObject::connect (reset_button, &QPushButton::clicked,this, &PortalDialer::reset);

   // Glyph buttons






   for (int i = 0; i < 16; i++)
   {
   	QObject::connect (glyph_input[i], &QPushButton::clicked, this, [=] { getGlyph (i); });









   }
}
//------------------------------------------------------------------







|
>

|
>
|


|
>

|

>
|


|

>
>
>
>






>

>


|


<
<
<
<
<
<
<
<
<
<













|
<







 







<
|
<
|


<
<







 







|







|

<
|
<
<
<
<
<
<
<
<
|
|
<







 







<







|

|
|
<
|
>
>
>
>
>
>
>
>
>
>
>
>







 







|
|
|
|
|
|







 







|
|
>
>
>
>
>
>


<
>
>
>
>
>
>
>
>
>



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45










46
47
48
49
50
51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
..
69
70
71
72
73
74
75

76

77
78
79


80
81
82
83
84
85
86
..
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

110








111
112

113
114
115
116
117
118
119
...
135
136
137
138
139
140
141

142
143
144
145
146
147
148
149
150
151
152

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245

246
247
248
249
250
251
252
253
254
255
256
257
#include "PortalAddressPickerWindow.h"
#include "HelperFunctions.h"
//==================================================================
/////////////////////////
// CLASS: PortalDialer //
/////////////////////////
//------------------------------------------------------------------
PortalDialer::PortalDialer (QWidget *parent)
   : QWidget (parent)
{
   createGlyphs();
   createActions();
   createLayout();
}
//------------------------------------------------------------------
PortalDialer::PortalDialer (const QString &_code, QWidget *parent)
   : QWidget (parent)
{
   createGlyphs();
   setGlyphs(_code);
   createActions();
   createLayout();
}
//------------------------------------------------------------------
void PortalDialer::createGlyphs()
{
   glyph_code = new QLineEdit;
   glyph_code -> setMaxLength (12);
   glyph_code -> setReadOnly (true);

   code = new QStack<QChar>;
   code -> clear();

   for (int i = 0; i < 16; i++)
   {
      glyph_input[i] = new QPushButton;
      glyph_input[i] -> setDisabled (false);
      glyph_input[i] -> setIconSize (QSize(40, 40));
      glyph_input[i] -> setMaximumSize (QSize (60,60));
      glyph_input[i] -> setAutoFillBackground (false);
      glyph_input[i] -> setCheckable (false);
      glyph_input[i] -> setFlat (true);
      glyph_input[i] -> setIcon (QIcon (QString (":" + QString(
                                           convert_integer_to_hex(i)).toUpper() + QString(".jpg"))));










   }
}
//------------------------------------------------------------------
void PortalDialer::setGlyphs (const QString &_code)
{
   if ( _code.size() <= 12 )
   {
      QString fileName = QString();

      if ( code -> isEmpty() == false &&
           (_code.toLower() != glyph_code -> text().toLower()) )
      {
         reset();
         QStack<QChar> temp = QStack<QChar>();

         const QRegularExpression validHex ("[0-9A-F]");
         QRegularExpressionMatch isValidHex;

         for (int i = 0; i < 12; i++)
         {
            if ( _code.isEmpty() == true )
            {
................................................................................
            }
            else
            {
               isValidHex = validHex.match (_code.at(i).toUpper());

               if ( isValidHex.hasMatch() == true )
               {

                  temp.push (_code.at (i).toUpper());

                  fileName = ":" + QString(_code.at (i)).toUpper() + ".jpg";
               }
            }


         }

         glyph_code -> setText (getCode());
         code -> swap (temp);
         emit codeChange();

         if ( glyph_code -> text().size() == 12 )
................................................................................
//------------------------------------------------------------------
QString PortalDialer::getCode()
{
   QString result = QString();

   for (int i = 0; i < code -> size(); i++)
   {
      result += QString(code -> at (i));
   }

   return (result);
}
//------------------------------------------------------------------
void PortalDialer::getGlyph (const int index)
{
   if ( code -> size() >= 0 && code -> size() < 12 )
   {

      code -> push (convert_integer_to_hex(index).at (0));








      glyph_code -> setText (getCode());
      emit codeChange();

   }

   // Update status of code after (any) change
   if ( code -> size() == 12 )
      emit codeReady();
   else
   {
................................................................................
}
//------------------------------------------------------------------
void PortalDialer::clearOne()
{
   if ( code -> isEmpty() == false )
   {
      code -> pop();

      glyph_code -> setText (getCode());
      emit codeIncomplete();
   }

   emit codeChange();
}
//------------------------------------------------------------------
void PortalDialer::createActions()
{
   // Glyph buttons
   for (int i = 0; i < 16; i++)

   {
      QObject::connect (glyph_input[i], &QPushButton::clicked, this, [=] { getGlyph (i); });
   }

   // Block further input once full code has been entered
   QObject::connect (this, &PortalDialer::codeReady, this, &PortalDialer::disableGlyphInput);

   // Re-enable input for less than full code
   QObject::connect (this, &PortalDialer::codeIncomplete, this, &PortalDialer::enableGlyphInput);
}
//------------------------------------------------------------------
void PortalDialer::createLayout()
{
   QPushButton *back_button = new QPushButton;
   back_button -> setText (tr ("Delete"));
   back_button -> setToolTip (
      tr ("Backspace/Delete one digit to the left"));
   back_button -> setCheckable (false);

   QPushButton *reset_button = new QPushButton;
................................................................................
   reset_button -> setText (tr ("Clear"));
   reset_button -> setToolTip (tr ("Reset all glyphs entered"));
   reset_button -> setCheckable (false);

   /*
      Create grid layout.

      control_group:
       +--------+-------+
       | delete | clear |
       +--------+-------+
       |   glyph_code   |
       +----------------+
   */
   QGroupBox *control_group = new QGroupBox;
   QGridLayout *buttons = new QGridLayout;
   buttons -> addWidget (back_button, 0, 0, 1, 1);
   buttons -> addWidget (reset_button, 0, 1, 1, 1);
   buttons -> addWidget (glyph_code, 1, 0, 1, 2);
   control_group -> setLayout (buttons);
................................................................................

   /*
     Handle pushing the buttons
   */
   // Delete glyph(s) previously selected
   QObject::connect (back_button, &QPushButton::clicked, this, &PortalDialer::clearOne);
   QObject::connect (reset_button, &QPushButton::clicked,this, &PortalDialer::reset);
}
//------------------------------------------------------------------
///////////////////
// PRIVATE SLOTS //
///////////////////
//------------------------------------------------------------------
void PortalDialer::disableGlyphInput()
{
   for (int i = 0; i < 16; i++)
   {

      glyph_input[i] -> setDisabled (true);
   }
}
//------------------------------------------------------------------
void PortalDialer::enableGlyphInput()
{
   for (int i = 0; i < 16; i++)
   {
      glyph_input[i] -> setDisabled (false);
   }
}
//------------------------------------------------------------------

Changes to src/PortalAddressPickerWindow.h.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75



76
77
78
79


80



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96












97
98
99
100
 *  to in-game portals.
 * 
 *  \details Displays a list of possible glyphs and accepts any 
 *  sequence of glyphs the user may wish to input.
 * 
 *  To create a PortalDialer:
 * 
 *  		// Create an empty object
 * 		PortalDialer example;
 * 
 * 		// Show a specific glyph code sequence
 * 		example.setGlyphs ("00234567890AB");
 * 		example.show();
 * 
*/
class PortalDialer : public QWidget
{
   Q_OBJECT
    
	public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      /** Default constructor */
      explicit PortalDialer(QWidget *parent = 0);
      /** \overload PortalDialer(const QString &)
       * 
       *  \param[in] _code A valid glyph code to set as.
      */
		PortalDialer(const QString &_code);

		/**
		 *  \details Sets the glyph code along with its corresponding glyphs.
		 * 
		 *  \param[in] _code A valid glyph code.
		*/
      void setGlyphs(const QString &_code);
      /** \returns The glyph code. */
      QString getCode();

	signals:
		/** This signal is emitted when there is a change to the glyph code. */
		void codeChange();
		/** This signal is emitted when the glyph code has not been filled to 
		 *  twelve (12) hex characters. Indicates the glyph code is between 0
		 *  and 11 characters.
		*/
		void codeIncomplete();
		/** This signal is emitted when the glyph code has been filled to twelve
		 *  (12) hex characters. Indicates the glyph code is ready to be 
		 *  validated.
		*/
		void codeReady();

	public slots:
		/** Removes the most recent/last glyph selected. */
		void clearOne();
		/** Clears the glyphs and glyph code. */
      void reset();
      /** Selects the glyph image corresponding to the value of index.
       *
       *  \param[in] index An integer between 0 - 15.
      */
		void getGlyph(const int index);

	private:



		/** Initializes glyph_input to empty QPushButtons. */
      void initGlyphs();
      /** Initializes the layout. */
      void initLayout();






      /** \var QPushButton *glyph_input[16]
       *
       *  Holds the glyph image for each possible glyph.
      */
     	QPushButton *glyph_input[16];
     	/** \var QStack<QChar> *code
     	 *
     	 *  Stores the selected glyph code.
     	*/
     	QStack<QChar> *code;
     	/** \var QLineEdit *glyph_code
     	 *
     	 *  Displays the current glyph code.
     	*/
     	QLineEdit *glyph_code;
     	//QPushButton *glyph_select[12];












};
//==================================================================
#endif	// __NMS_PORTAL_DIAL_H__
//==================================================================







|
|

|
|
|






|









|

|
|
|
|
|




|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|





|

|
>
>
>
|
|

|
>
>

>
>
>




|
|
|
|
|
|
|
|
|
|
|
<
>
>
>
>
>
>
>
>
>
>
>
>




10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 *  to in-game portals.
 * 
 *  \details Displays a list of possible glyphs and accepts any 
 *  sequence of glyphs the user may wish to input.
 * 
 *  To create a PortalDialer:
 * 
 *       // Create an empty object
 *       PortalDialer example;
 * 
 *       // Show a specific glyph code sequence
 *       example.setGlyphs ("00234567890AB");
 *       example.show();
 * 
*/
class PortalDialer : public QWidget
{
   Q_OBJECT
    
   public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      /** Default constructor */
      explicit PortalDialer(QWidget *parent = 0);
      /** \overload PortalDialer(const QString &)
       * 
       *  \param[in] _code A valid glyph code to set as.
      */
      explicit PortalDialer(const QString &_code, QWidget *parent = 0);

      /**
       *  \details Sets the glyph code along with its corresponding glyphs.
       * 
       *  \param[in] _code A valid glyph code.
      */
      void setGlyphs(const QString &_code);
      /** \returns The glyph code. */
      QString getCode();

   signals:
      /** This signal is emitted when there is a change to the glyph code. */
      void codeChange();
      /** This signal is emitted when the glyph code has not been filled to 
       *  twelve (12) hex characters. Indicates the glyph code is between 0
       *  and 11 characters.
      */
      void codeIncomplete();
      /** This signal is emitted when the glyph code has been filled to twelve
       *  (12) hex characters. Indicates the glyph code is ready to be 
       *  validated.
      */
      void codeReady();

   public slots:
      /** Removes the most recent/last glyph selected. */
      void clearOne();
      /** Clears the glyphs and glyph code. */
      void reset();
      /** Selects the glyph image corresponding to the value of index.
       *
       *  \param[in] index An integer between 0 - 15.
      */
      void getGlyph(const int index);

   private:
      /*
         PRIVATE FUNCTIONS
      */
      /** Initializes glyph_input to empty QPushButtons. */
      void createGlyphs();
      /** Initializes the layout. */
      void createLayout();
      /** Initializes actions for the private variables. */
      void createActions();

      /*
         PRIVATE VARIABLES
      */
      /** \var QPushButton *glyph_input[16]
       *
       *  Holds the glyph image for each possible glyph.
      */
      QPushButton *glyph_input[16];
      /** \var QStack<QChar> *code
       *
       *  Stores the selected glyph code.
      */
      QStack<QChar> *code;
      /** \var QLineEdit *glyph_code
       *
       *  Displays the current glyph code.
      */
      QLineEdit *glyph_code;


   private slots:
      /** Disables all glyph input. Useful when 12 codes have been 
       *  entered.
       *
       *  Should only be called when codeReady is emitted.
      */
      void disableGlyphInput();
      /** Enables all glyph input. This is the default state of the
       *  object.
      */
      void enableGlyphInput();
};
//==================================================================
#endif	// __NMS_PORTAL_DIAL_H__
//==================================================================

Changes to src/PortalAddressWindow.cpp.

1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
..
31
32
33
34
35
36
37

38

39
40
41
42
43

44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

//==================================================================
#include "PortalAddressWindow.h"
#include "HelperFunctions.h"
//==================================================================
///////////////////
// CLASS: Glyphs //
///////////////////
//==================================================================
Glyphs::Glyphs (QWidget *parent) : QWidget (parent)

{
   initGlyphs();
   setGlyphs (QString());
   createLayout();
}
//------------------------------------------------------------------
Glyphs::Glyphs (const QString &_code)

{
   initGlyphs();
   setGlyphs (_code);
   createLayout();
}
//------------------------------------------------------------------
void Glyphs::initGlyphs()
{
   for (int i = 0; i < 12; i++)
      glyph[i] = new QPushButton;
}
//------------------------------------------------------------------
void Glyphs::setGlyphs (const QString &_code)
{
................................................................................
   QStringList ignoreThis;

   // Do not change glyph code if provided code is the same as 
   // what we already have; just redraw it. Also must be a valid 
   // glyph code.
   if ( glyph_code.toLower() != _code.toLower() &&
        (is_valid_glyph_code (_code, ignoreThis) == true) )

      glyph_code = _code;


   for (int i = 0; i < 12; i++)
   {
      // Using aliases from qrc
      if ( _code.isEmpty() == false )

         glyph[i] -> setIcon (QIcon (QString(":" + QString(glyph_code.at(
                                                i).toUpper()) + ".jpg")));

      else
         glyph[i] -> setIcon (QIcon (QString(":empty.png")));

      glyph[i] -> setIconSize (QSize(40, 40));		// (60,60) is nice, too
      glyph[i] -> setAutoFillBackground (true);
      glyph[i] -> setText (QString());
      glyph[i] -> setCheckable (false);
      glyph[i] -> setFlat (false);
   }
}
//------------------------------------------------------------------
void Glyphs::showGlyphs()
{
	setGlyphs (glyph_code);
}
//------------------------------------------------------------------
void Glyphs::showGlyphs (const QString &_code)
{
	setGlyphs (_code);
}
//------------------------------------------------------------------
void Glyphs::reset()
{
   glyph_code.clear();
   for (int i = 0; i < 12; i++)
      glyph[i] -> setIcon (QIcon (":empty.png"));
}
//------------------------------------------------------------------
void Glyphs::createLayout()
{
   /*
   QPushButton *go_back = new QPushButton;
   go_back -> setText (tr ("Hide"));
   go_back -> setToolTip (tr ("Hide portal address window"));
   go_back -> setCheckable (false);

   QPushButton *exit = new QPushButton;
   exit -> setText (tr ("Quit"));
   exit -> setToolTip (tr ("Exit the application"));
   exit -> setCheckable (false);
   */
   /*
      Create horizontal layout.

      the_glyphs:
       +--------+--------+-----+---------+
       | glyph1 | glyph2 | ... | glyph12 |
       +--------+--------+-----+---------+
................................................................................
   QHBoxLayout *sequence = new QHBoxLayout;

   for (int i = 0; i < 12; i++)
      sequence -> addWidget (glyph[i]);

   the_glyphs -> setLayout (sequence);

   /*
      Create vertical layout.

      the_buttons:
       +---------+
       | go_back |
       +---------+
       |   exit  |
       +---------+
   */
   //QGroupBox *the_buttons = new QGroupBox;
   //QVBoxLayout *_buttons = new QVBoxLayout;
   //_buttons -> addWidget (go_back);
   //_buttons -> addWidget (exit);
   //the_buttons -> setLayout (_buttons);

   /*
      Create grid layout for the program.

      _layout:
       +----------------------------+
       | the_buttons |  the_glyphs  |
       +---------+------------------+
   */
   QGridLayout *_layout = new QGridLayout;
   _layout -> addWidget (the_glyphs, 0, 1, 1, 1);
   //_layout -> addWidget (the_buttons, 0, 0, 2, 1);
   setLayout (_layout);

   // Handle button signals (events)
   // Note: Using hide() rather than close() seems to keep memory
   // usage more consistent while application is open.
   //QObject::connect (go_back, SIGNAL (clicked(bool)),
   //                  this, SLOT (hide()));
   //QObject::connect (exit, SIGNAL (clicked(bool)),
   //                  QApplication::instance(), SLOT (quit()));
}
//==================================================================

|


|



|
|
>

|




|
>

|




|







 







>

>





>


>







|





|




|











<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










<

|
<
<
<
<
<
<
<
<
<
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81











82
83
84
85
86
87
88
..
91
92
93
94
95
96
97
















98
99
100
101
102
103
104
105
106
107

108
109









110
//------------------------------------------------------------------
#include "PortalAddressWindow.h"
#include "HelperFunctions.h"
//------------------------------------------------------------------
///////////////////
// CLASS: Glyphs //
///////////////////
//------------------------------------------------------------------
Glyphs::Glyphs (QWidget *parent)
   : QWidget (parent)
{
   createGlyphs();
   setGlyphs (QString());
   createLayout();
}
//------------------------------------------------------------------
Glyphs::Glyphs (const QString &_code, QWidget *parent)
   : QWidget (parent)
{
   createGlyphs();
   setGlyphs (_code);
   createLayout();
}
//------------------------------------------------------------------
void Glyphs::createGlyphs()
{
   for (int i = 0; i < 12; i++)
      glyph[i] = new QPushButton;
}
//------------------------------------------------------------------
void Glyphs::setGlyphs (const QString &_code)
{
................................................................................
   QStringList ignoreThis;

   // Do not change glyph code if provided code is the same as 
   // what we already have; just redraw it. Also must be a valid 
   // glyph code.
   if ( glyph_code.toLower() != _code.toLower() &&
        (is_valid_glyph_code (_code, ignoreThis) == true) )
   {
      glyph_code = _code;
   }

   for (int i = 0; i < 12; i++)
   {
      // Using aliases from qrc
      if ( _code.isEmpty() == false )
      {
         glyph[i] -> setIcon (QIcon (QString(":" + QString(glyph_code.at(
                                                i).toUpper()) + ".jpg")));
      }
      else
         glyph[i] -> setIcon (QIcon (QString(":empty.png")));

      glyph[i] -> setIconSize (QSize(40, 40));		// (60,60) is nice, too
      glyph[i] -> setAutoFillBackground (true);
      glyph[i] -> setText (QString());
      glyph[i] -> setCheckable (false);
      glyph[i] -> setFlat (true);
   }
}
//------------------------------------------------------------------
void Glyphs::showGlyphs()
{
   setGlyphs (glyph_code);
}
//------------------------------------------------------------------
void Glyphs::showGlyphs (const QString &_code)
{
   setGlyphs (_code);
}
//------------------------------------------------------------------
void Glyphs::reset()
{
   glyph_code.clear();
   for (int i = 0; i < 12; i++)
      glyph[i] -> setIcon (QIcon (":empty.png"));
}
//------------------------------------------------------------------
void Glyphs::createLayout()
{











   /*
      Create horizontal layout.

      the_glyphs:
       +--------+--------+-----+---------+
       | glyph1 | glyph2 | ... | glyph12 |
       +--------+--------+-----+---------+
................................................................................
   QHBoxLayout *sequence = new QHBoxLayout;

   for (int i = 0; i < 12; i++)
      sequence -> addWidget (glyph[i]);

   the_glyphs -> setLayout (sequence);

















   /*
      Create grid layout for the program.

      _layout:
       +----------------------------+
       | the_buttons |  the_glyphs  |
       +---------+------------------+
   */
   QGridLayout *_layout = new QGridLayout;
   _layout -> addWidget (the_glyphs, 0, 1, 1, 1);

   setLayout (_layout);
}









//------------------------------------------------------------------

Changes to src/PortalAddressWindow.h.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
69
70
71
72
73
74
75



76
77
78
79
80
81
82
83
84
85
86
87
88



89
90
91
92
93


94
95
96
97
 *
 *  \brief Holds graphical data about a glyph sequence.
 * 
 *  \details Displays the glyphs in a given a glyph code sequence.
 * 
 *  To create a Glyphs:
 * 
 * 		// Create empty glyph sequence
 * 		Glyphs example;
 * 
 * 		// Show sequence: 200d01345678
 * 		example.showGlyphs ("200d01345678");
 * 		example.show();
 * 
 *  \see CoordinateData::glyph_code
*/
class Glyphs : public QWidget
{
   // Macro to allow for custom slots and signals
   Q_OBJECT

   public:
................................................................................
       * 
       *  Initializes class with a given glyph sequence.
       * 
       *  \param[in] _code A valid glyph code.
       * 
       *  \see CoordinateData::glyph_code
      */
      Glyphs(const QString &_code);

      /** Initializes the GUI elements */
      void createLayout();

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      /** Sets the glyph code sequence to be displayed.
       * 
       *  \param[in] _code A valid glyph code.
................................................................................
       *  the same as what is currently set.
       * 
       *  \param[in] _code A valid glyph code.
      */
      void showGlyphs(const QString &_code);

   private:



   	/** \var QString glyph_code
   	 * 
   	 *  The glyph code sequence to be displayed.
   	 * 
   	 *  \see CoordinateData::glyph_code
   	*/
      QString glyph_code;
      /** \var QPushButton *glyph[12]
       * 
       *  The actual glyphs corresponding to the glyph code.
      */
      QPushButton *glyph[12];




		/** Initializes private variables:
		 * 
		 *  glyph_code of size zero, and empty QPushButtons for the glyphs.
		*/
      void initGlyphs();


};
//==================================================================
#endif	// __NMS_GLYPHS_H__
//==================================================================







|
|

|
|
|

|







 







|
<
<
<







 







>
>
>
|
|
|
|
|
|







>
>
>
|
|
|
|
|
>
>




8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
36
37
38
39
40
41
42
43



44
45
46
47
48
49
50
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 *
 *  \brief Holds graphical data about a glyph sequence.
 * 
 *  \details Displays the glyphs in a given a glyph code sequence.
 * 
 *  To create a Glyphs:
 * 
 *       // Create empty glyph sequence
 *       Glyphs example;
 * 
 *       // Show sequence: 200d01345678
 *       example.showGlyphs ("200d01345678");
 *       example.show();
 * 
 *  \see coordinateData::glyph_code
*/
class Glyphs : public QWidget
{
   // Macro to allow for custom slots and signals
   Q_OBJECT

   public:
................................................................................
       * 
       *  Initializes class with a given glyph sequence.
       * 
       *  \param[in] _code A valid glyph code.
       * 
       *  \see CoordinateData::glyph_code
      */
      explicit Glyphs(const QString &_code, QWidget *parent = 0);




      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      /** Sets the glyph code sequence to be displayed.
       * 
       *  \param[in] _code A valid glyph code.
................................................................................
       *  the same as what is currently set.
       * 
       *  \param[in] _code A valid glyph code.
      */
      void showGlyphs(const QString &_code);

   private:
      /*
         PRIVATE VARIABLES
      */
      /** \var QString glyph_code
       * 
       *  The glyph code sequence to be displayed.
       * 
       *  \see CoordinateData::glyph_code
      */
      QString glyph_code;
      /** \var QPushButton *glyph[12]
       * 
       *  The actual glyphs corresponding to the glyph code.
      */
      QPushButton *glyph[12];

      /*
         PRIVATE FUNCTIONS
      */
      /** Initializes private variables:
       * 
       *  glyph_code of size zero, and empty QPushButtons for the glyphs.
      */
      void createGlyphs();
      /** Initializes the GUI elements */
      void createLayout();
};
//==================================================================
#endif	// __NMS_GLYPHS_H__
//==================================================================